issue #116 Phase 1-C: smooth sigmoid read-gate (observability slice)#120
Closed
TSchonleber wants to merge 1 commit into
Closed
issue #116 Phase 1-C: smooth sigmoid read-gate (observability slice)#120TSchonleber wants to merge 1 commit into
TSchonleber wants to merge 1 commit into
Conversation
Memo §1.4 Stage 2 argues hard `--limit N` truncation is both noise-
sensitive (items near the boundary flip in and out unpredictably)
and non-learnable (zero gradient at the boundary). The memo's
recommendation is a smooth sigmoid threshold with learnable slope
and midpoint, calibrated from operational data.
This ships the **observability slice** only — the math + a
per-item `_sigmoid_rank_weight` field. Rank order unchanged, no
items dropped, bench output structure identical modulo the new
field. Learning slope/midpoint from outcomes is Phase 4 work and
deliberately deferred.
- agentmemory.sigmoid_gate module: SigmoidParams, sigmoid(),
normalize_rank(), weight_for_rank(), weights_for_results(),
annotate_with_weights(). Pure math, no DB access. Conservative
defaults slope=6.0, midpoint=0.5 per memo §1.4 ("Start with a
shallow slope and a conservative midpoint, then tighten as data
accumulates").
- cmd_search hookpoint annotates each surfaced item with
_sigmoid_rank_weight derived from its 1-based rank in the bucket.
Failures swallow so a bad gate cannot break search.
- 14 new tests: endpoint behavior, midpoint crossing, monotonicity,
extreme-overflow handling, SigmoidParams validation, rank
normalization edges, bucket annotation, idempotence, non-dict
handling.
Live smoke (context bucket, 3 items):
rank 1 of 3 → weight 0.9526
rank 2 of 3 → weight 0.5000 (midpoint exactly)
rank 3 of 3 → weight 0.0474
145/145 tests green across sigmoid_gate, motivational_gate,
retrieval_pathway_log, brain, brain_enhanced, profiles.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
TSchonleber
added a commit
that referenced
this pull request
May 20, 2026
Bumps pyproject.toml and __init__.__version__ to 2.8.0 and promotes the [Unreleased] CHANGELOG block to [2.8.0] dated 2026-05-20. This release lands the issue #116 brain-architecture work (16 new subsystems via migrations 067-082) alongside the v2 MCP tool surface consolidation (370 registered → 100 visible) and Windows hardening. Supersedes overnight PRs #120-#137 as a single artifact. Minor bump rationale: although the v1 tool names are hidden from list_tools, every one of them remains callable internally through the consolidated dispatchers — same compatibility shape as 2.7.0's procedural-memory landing. Clients with stale name allowlists get a hard-fail at startup pointing at docs/TOOL_MIGRATION_V2.md, never a silent breakage. A revert is one-line (the _VISIBLE_TOOL_NAMES filter). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
Superseded by #138 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Third and final slice of issue #116 Phase 1. Ships the observability piece of the memo's smooth sigmoid read-gate recommendation (§1.4 Stage 2) — math + per-item weight surface — without changing rank order or dropping any items. Calibration of slope/midpoint from accumulated outcomes is Phase 4 work, intentionally deferred.
Stays on its own branch by request — not auto-merged like Phase 1-A (
84c8776) and 1-B (c781043) were. Higher-risk piece even in observability mode because it touches result-item dicts every search, and benchmark fixtures deserve a manual look before merge.What's in
agentmemory.sigmoid_gate— new pure-math module:SigmoidParams(validated frozen dataclass),sigmoid(x, slope, midpoint),normalize_rank(rank, total),weight_for_rank(rank, total),weights_for_results(total),annotate_with_weights(items).slope=6.0,midpoint=0.5per memo §1.4 Stage 2 ("Start with a shallow slope and a conservative midpoint, then tighten as data accumulates").cmd_searchhook: one new block before output formatting that callsannotate_with_weightson every result bucket. Items get a new_sigmoid_rank_weightfield; existing field if any is preserved (idempotent). Failures swallow.What's NOT in (deliberately)
Live smoke
`brainctl search "cerebellum boundary detection" --limit 3` with the new code, `context` bucket (3 items):
Midpoint crossing at the median is the correct shape.
Tests
Test plan
Phase 1 status after this lands
Phase 4 enforcement readiness review is the next planned step, gated on accumulating 4+ weeks of pathway-log data before deciding whether the BG/cerebellum learning loops are calibrated enough to flip from shadow to enforcement.
🤖 Generated with Claude Code