Repository navigation
Enforce symptom-first learning/blocker rows at the write gate - #424
Conversation
The #419 capture convention ('When <symptom>: <fact>') is a prompt request; the gate does not enforce it. The live store shows the gap: 443 learning/blocker rows, 6 with a symptom clause. The measured cost: the same lesson surfaced 0/8 as diary, ranks 1-7 symptom-first. - runWriteGate blocks learning/blocker content without the trigger clause: reason=symptom_missing, hint names the shape and the context/decision alternative. ON by default; OPENCODE_MEMORY_SYMPTOM=off|0|false is the escape hatch. - memory_remember type description states the rule at the point of choice (deliberate wire-contract move; boundaries pin re-captured). - Capture prompt: the gate rejects, so the capture model self-corrects. - scripts/symptom-fixer.ts: offline DRY-RUN backlog repair, symptoms grounded only in the store's own query ledger with a replay gate (385 proposals, 189 replay-eligible, 196 vetoed). No writes. - Suite pins the rule off in preload-isolation.ts (fixtures are pre-convention prose); test/gate-symptom.test.ts drives both states.
The fixer's repair is now kw-only: symptom words the row's vocabulary lacks go into kw — indexed, never injected; content stays byte-identical, so a logged query word-bag never becomes displayed prose. Retrieval still moves: kw rides every scorer's haystack. --apply runs each replay-eligible row through the real 4-gate pipeline with supersedesTs set (the memory_update contract), under the store batch lock: the successor inherits the target's repo stamp (no forged identity), the old row is superseded (snapshot-first), memory_undo stays the recovery path. Drift guard: content changed since replay = skip. OPENCODE_MEMORY_SYMPTOM=off is the documented automation escape hatch — content is unchanged, the new-prose rule does not apply. Live store, 2026-11-17: 152 replay-eligible, 132 applied, 20 blocked by GATE-2 stale path refs (rows left as-is, gate working), 215 vetoed by replay, 18 no-op. Verified: a previously-missed row now ranks 1 for its grounding query under the injection scorer.
WhollyMindless
left a comment
There was a problem hiding this comment.
[P2] Replay approves each repair against the original store, but applies all repairs together.
Reproduced by running the real script with --apply --window 1 against an isolated synthetic store on e028b95: two settled learning rows in different scopes, contents alpha beta orange and alpha beta violet, and one ledger event terms=[alpha,beta,gamma] mem=[]. The script reports two replay-eligible repairs, zero vetoes, and two applied updates; both successors acquire kw=[gamma]. Scoring the resulting active store for alpha beta gamma with window 1 returns only the violet row. The orange repair therefore fails the grounding-window condition in the actual applied result, despite passing its individual replay.
The replay loop always uses the original rows.map(swap); earlier accepted or applied changes never enter the next proposal's comparison. Competing repairs can invalidate one another, so the advertised pre-write replay guarantee is not a property of the batch. Please consider evaluating accepted changes cumulatively (or replaying the final batch and removing conflicting proposals), and revalidating against the current store under the write lock. This probe uses a supported --window value and no live-store data; the focused symptom-gate tests pass.
Disclosure: the base includes earlier contributions by me. This is verification of a new maintainer-authored path, not independent approval of my own code. Disposition remains yours.
abogartz
left a comment
There was a problem hiding this comment.
Review verdict: REQUEST_CHANGES (posted as comment — GitHub refuses approve/request-changes on self-authored PRs).
Blocking design finding: the rule has no new-vs-legacy distinction. retagQuarantinedRows rewrites legacy learning/blocker rows with byte-identical content, and a metadata-only memory_update on a legacy row re-submits unchanged content — both now hit symptom_missing, so quarantine repair stalls forever and legacy stores cannot be edited. Fix: skip the rule when ctx.supersedesTs is set and the candidate content equals the target's. That also retires the fixer's env-off workaround.
Also to address: leading-whitespace/BOM false-reject on ^when; the 160-char colon cap is undocumented in the hint; fixer ??= honors an inherited on-value (hard-set off); fixer best-proposal comparison uses mismatched operands (shared > prev.query.length); drift check must compare kw too; dead mergeSymptomKw export; e2e harness comment cites a nonexistent e2e/symptom-rule.test.ts.
Clean: tombstone path unaffected (blocked writes log evidence only, no tombstone); test isolation leak fixed; dry-run default holds; tsc clean.
Review of #424: the rule blocked unchanged-content rewrites, so retagQuarantinedRows and metadata-only memory_update on a legacy learning/blocker row would stall forever. The rule now skips when ctx.supersedesTs is set and the candidate content equals the target's — it shapes NEW lesson prose, not legacy-row maintenance. This also retires the fixer's env-off need (kept, harmless). - leading whitespace/BOM before the trigger accepted - hint states the 160-char trigger cap - fixer: hard-set SYMPTOM=off (??= honored an inherited on-value and would block every --apply write); best-proposal compares shared vs shared (was shared vs query.length); drift guard now also compares kw; dead export dropped - e2e harness comment no longer cites a nonexistent spec file - tests: repair promoted, NEW diary rewrite against supersedesTs still blocked, whitespace trigger accepted
|
All review findings addressed (commits ecfbf0f,4a7c899,a4b76bc): repair exemption — the rule now skips when |
WhollyMindless
left a comment
There was a problem hiding this comment.
Small clarification on "All review findings addressed": the legacy-repair fixes address the maintainer self-review, but my batch-replay finding remains on ecfbf0f. I reran the original isolated --apply --window 1 probe on that exact head in the previous pass: two repairs are still reported eligible and applied, while only one survives their shared grounding-query window. The replay loop still evaluates each proposal against the original rows. Details and reproduction are in #424 (review) . The new symptom/legacy tests pass; they exercise a different path. Please keep this finding open or explicitly record its disposition. Prior authorship disclosure still applies; no approval implied.
WhollyMindless #424 review: replay approved each repair against the ORIGINAL store while --apply writes the whole batch — two repairs could each pass alone and then evict each other from the shared grounding window (their --window 1 probe: both eligible, both applied, one survivor). Replay is now cumulative: proposals are evaluated strongest-grounding first against the store with all previously accepted rewrites applied, then the accepted set is re-scored as a whole against the final store and proposals a sibling invalidated are dropped, to stability. Under --apply each row is additionally revalidated against the CURRENT store inside the write lock, so earlier applied successors are priced in. Their probe now yields: 2 proposals, 1 batch-verified eligible, 1 applied, 1 dropped. Honest note: the 132 rows already repaired today were replayed under the old per-proposal rule; the batch-verification pass would have dropped only mutual evictions, and the window-5 live store makes those far rarer than the window-1 synthetic — future runs are exact.
|
@WhollyMindless finding accepted and fixed — replay is now cumulative (strongest grounding first, each proposal evaluated against the store with all previously accepted rewrites applied) plus a final batch-verification pass that re-scores the fully rewritten store and drops proposals a sibling invalidated, to stability; under |
WhollyMindless
left a comment
There was a problem hiding this comment.
Retested the original isolated --apply --window 1 reproduction on 06a6a5e: the script now retains one batch-verified repair, drops the competing proposal, and applies only the surviving repair. The resulting grounding window contains that repaired row. This addresses the original two-row mutual-eviction case I reported. I also inspected the cumulative replay/final verification changes; this is verification of that reproduction, not a claim that every concurrent-change or partial-apply scenario has been proved. As previously disclosed, the base includes earlier contributions by me; no independent approval implied.
# [0.29.0](v0.28.1...v0.29.0) (2026-11-18) ### Bug Fixes * **fixer:** cumulative replay + final batch verification ([#423](#423)) ([06a6a5e](06a6a5e)), closes [#424](#424) * **gate:** exempt byte-identical repairs; review findings ([#423](#423)) ([4a7c899](4a7c899)) ### Features * **fixer:** kw-only --apply through the gated update path ([#423](#423)) ([e028b95](e028b95)) * **gate:** enforce symptom-first learning/blocker rows ([#423](#423)) ([8781894](8781894)), closes [#419](#419)
|
🎉 This PR is included in version 0.29.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #423.
What
Makes the #419 convention enforceable:
learning/blockerrows must open with the observable trigger (When <symptom>: <fact>), or the write gate blocks them with reasonsymptom_missingand a rephrase hint. ON by default;OPENCODE_MEMORY_SYMPTOM=off|0|falseis the escape hatch for automation holding a pre-convention backlog.Why (measured, not taste)
Also in this PR: scripts/symptom-fixer.ts
Offline backlog repair, grounded ONLY in the store's own query ledger — a symptom is accepted only when a real session's logged query shares ≥2 rare content tokens with the row and the row was not returned. No invented symptoms.
Repair shape is kw-only (user decision 2026-11-17): symptom words the row's vocabulary lacks are appended to
kw— indexed, never injected; content stays byte-identical, so a logged word-bag never becomes displayed prose. Retrieval still moves:kwrides every scorer's haystack.Replay gate before any write (the consolidate discipline): a rewrite applies only if it enters the window for its grounding query AND keeps every ledger window the old row held.
--apply writes through the real 4-gate pipeline with
supersedesTsset (thememory_updatecontract), under the store batch lock: successor inherits the target's repo stamp (no forged identity), old row superseded snapshot-first,memory_undostays the recovery path. Drift guard: content changed since replay → skip.Executed against the live store 2026-11-17: 385 grounded proposals → 18 no-op, 215 replay-vetoed, 152 eligible → 132 applied, 20 blocked by GATE-2 stale path refs (rows left untouched — the gate outranking the fixer is the correct outcome). Verified end-to-end: a previously-missed row now ranks #1 for its grounding query under the injection scorer.
Tests
test/gate-symptom.test.ts: block + hint, blocker covered, conforming row stores, other types unaffected, escape hatch,symptomRuleEnabledunit.preload-isolation.ts(fixtures are pre-convention prose).