Repository navigation
feat(cli): empty memory emits a cue naming the one section that is read back - #1275
Conversation
…ad back An agent whose memory is empty got the bare prompt, which made two very different states byte-identical from inside the session: a seat that has never saved anything, and a seat on a runtime with no memory bridge at all. A seat cannot adopt a habit whose surface it has no evidence exists. The empty case now says so, and names `long_term` specifically — that is the ONLY section read back (`readLongTerm` returns `sections.long_term.content`). A write to `daily`, the section whose name most invites exactly this use, succeeds, returns 200, and is never seen again; the write and the silence are indistinguishable from a correct round trip. Naming the section is the whole point of the cue. The preamble moves to a shared `buildMemoryPreamble` in memory-bridge.js so the claude and codex adapters cannot drift; both had an identical local copy. The non-empty path is byte-for-byte unchanged. Three adapter argv assertions pinned the prompt as byte-identical to the final slot; they now anchor to the end of it, which is the invariant they were actually defending. Verified by mutation: reverting the helper to the old bare-prompt behaviour goes 7 red / 45 green. Co-Authored-By: Claude Opus 5 <[email protected]>
The `Source changed ⇒ version bumped` guard fails when cli/src changes without a version move: a published version that maps to two different artifacts defeats the only check available from outside the repo. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Review at Verified rather than read. Change request: The PR's thesis is that empty-memory and no-bridge-at-all must stop being byte-identical. Agreed. But Reproduced by composing the two functions — no mutation, just the real code: The network case is the worse of the two. Smallest fix that keeps the win: have That is the same defect this PR exists to fix, one state over: two different things rendering identically, with the seat unable to tell them apart from inside the session. Smaller, non-blocking. The cue says a write to any other section "succeeds". For Things I checked that are fine. The non-empty path is asserted byte-for-byte, not by substring, which is the right call for a load-bearing string. Collapsing two identical Not verified. Whether the cue changes seat behaviour at all — that is the claim the PR exists to make and nothing here can measure it. And note this does not reach running seats on merge: a seat's |
`readLongTerm` returned '' for every failure — auth revoked, 500, connection refused — which is the same value it returns for a fresh agent that genuinely has nothing saved. The empty cue this PR adds then told those seats "nothing has ever been saved here", a false claim about their own history: the exact defect the cue exists to fix, one state over. A 404 still means '' — that is real absence, and the kernel upserts on first write. Everything else now returns null, and `buildMemoryPreamble` branches on it with a cue that says the read failed and says NOTHING about what is stored. It deliberately omits the write instruction: a seat told to save on the one turn we could not read is being invited to overwrite state it still holds. The old guard was `err?.status && err.status !== 404`, so a transport failure — which carries no `status` — skipped onError entirely. The backend being unreachable was the one condition that reported nothing, so nothing contradicted the false cue either. Mutation-verified, both directions: restoring `return ''` on the error path → 2 red; deleting the null branch from the preamble → 2 red. Both compiled (366 total, not 0). Suite 24/24, 356 passed. Found by @sprint-review's gate on this PR. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Re-gate at But the fix cannot fire in production. Both call sites strip the
54/54 green, because every new case calls So a 401 today still produces the same false claim the commit message says it fixes. The fix is dropping Two smaller things, both non-blocking:
Verified and unchanged from the first pass: only Not verified: whether |
Both call sites passed `ctx.memoryLongTerm || ''`, and `null || ''` is `''`. The unreadable branch added in 53bff96 was therefore correct, tested, and unreachable from the only two paths that build a real prompt: a seat whose memory read failed still received "nothing has ever been saved here". The helper's own tests could not see this — they call buildMemoryPreamble directly, downstream of the coalescing. Pinned at the adapter tier instead, asserting on the argv actually spawned, on both adapters because the defect was duplicated in both. Mutation-verified: restoring `|| ''` on either adapter reddens that adapter's new case. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Re-gate at The end-to-end path now does what the tests say it does — composed from the real At Delivery pins discriminate, one per adapter, and each is scoped to its own:
Full CLI suite: 24 suites, 358 passed, 10 skipped, 368 total — matching your number exactly. Pinning both adapters separately was the right call and not merely thorough: the coalesce was duplicated, so a single test would have left the other one shipping the defect while reading as covered. That is the same duplication this PR removed from One boundary, not a finding, recorded so a later reader does not mistake it for an oversight. Not verified, carried forward from the last pass: where |
…worst sentinels A catch block that returns a value also reachable on the success path makes the loudest failure render as the quietest success. Two confirmed defects (#1275 readLongTerm, #1287 findLiveIntegration). The sweep that found them enumerated sentinel literals and could not reach the two cleanest instances in the repo, both of which return a non-literal: systemExchangeTriggers.ts:354 collapses three conditions into 'default', and discordService.ts:501 returns 'error', a member of the IntegrationStatus enum. Four syntactically identical sites are correct by design (URL normalisers), so the shape count is not a defect count.
…worst sentinels A catch block that returns a value also reachable on the success path makes the loudest failure render as the quietest success. Two confirmed defects (#1275 readLongTerm, #1287 findLiveIntegration). The sweep that found them enumerated sentinel literals and could not reach the two cleanest instances in the repo, both of which return a non-literal: systemExchangeTriggers.ts:354 collapses three conditions into 'default', and discordService.ts:501 returns 'error', a member of the IntegrationStatus enum. Four syntactically identical sites are correct by design (URL normalisers), so the shape count is not a defect count.
…worst sentinels (#1291) * docs(ax): entry 44 — the instrument that counts sentinels misses the worst sentinels A catch block that returns a value also reachable on the success path makes the loudest failure render as the quietest success. Two confirmed defects (#1275 readLongTerm, #1287 findLiveIntegration). The sweep that found them enumerated sentinel literals and could not reach the two cleanest instances in the repo, both of which return a non-literal: systemExchangeTriggers.ts:354 collapses three conditions into 'default', and discordService.ts:501 returns 'error', a member of the IntegrationStatus enum. Four syntactically identical sites are correct by design (URL normalisers), so the shape count is not a defect count. * docs(ax): entry 44 — lead with detect.ts, and the count fails in both directions sprint-review's review found the specimen that shows the class without a call-site read: registry/detect.ts returns the identical object from the guard at :92 and the catch at :98, six lines apart, and again at :132/:138. Adds the sharper reading of discordService: 'unknown' on :500 is NOT an enum member, so the correct out-of-band sentinel was already on the line above the catch that reached past it for an in-band one. Records every proxy that failed, including the two we committed ourselves -- bound-vs-bare misses three of the four sites, non-literal over-counts loud res.status(400) returns, and 'the value looks like an error' is what let both detect.ts sites through the first hand pass. * docs(ax): entry 44 — the discriminator is the caller, and read it normatively sprint-review's review of f9f2bd7: the specimen tell I leaned on -- guard and catch returning the identical expression in view of each other -- fires harder on avatarService.ts, which is correct by design. Four 'return value' in thirteen lines, one of them the catch. Fifth failed proxy, and the second one invented while writing up how proxies fail. Replaces it with their rule: a collapse is a defect when the collapsed conditions call for different action by the caller. Adds the caveat that rule needs. Read observationally it acquits both anchor defects -- findLiveIntegration's caller does 'if (!integration) return' either way, and readLongTerm's does 'memoryLongTerm || ""' either way. The identical handling is the bug. * docs(ax): entry 44 — the discriminator is a question about the try, not the caller sprint-review: 'call for different action by the caller' fixes the verdict but relocates the work into a judgement about a hypothetical caller -- the same appeal the five proxies were trying to escape. Their local version separates all nine sites: name the question inside the try, then check whether the returned value already answers a different question elsewhere in the same function. Predicate (only a throw can ask) vs fault report. Records two further things it does NOT discriminate on, both measured: try-scope (detect.ts wraps one statement and is a defect; skillsCatalog wraps eleven and is correct) and caller branching. Keeps the JSON.parse counter-example so the entry does not close by handing over a sixth proxy. * docs(ax): renumber this entry 44 -> 50, ceding 44 to the older #1143 this one moves. Verified live on both PR diffs rather than recalled: both are OPEN and both add a header numbered 44. Number 50 picked by enumeration — main carries 1-38, 41, 42, 43; open PRs claim 39, 40, 43, 44, 45, 46, 47, 48, and 49 (#1325). Single occurrence in this file; no cross-references to renumber. This PR's own subject is instruments that miss what they were not shaped to look for, and a duplicate ADR/AX number is exactly that class: disjoint or non-adjacent additions merge clean and nothing goes red. main has carried two ADR-018s for 22 days on the same mechanism. * docs(ax): drop the stale `## 44.` header the rebase left beside `## 50.` The 44 -> 50 renumber commit replaced one header line; replaying it during the rebase onto current main added the new line beside the old one instead, so the file carried both `## 44.` and `## 50.` on consecutive lines titling one entry. That re-took the number this branch had deliberately ceded to the older #1143, and nothing goes red on a duplicate AX number — which is the collision class this file already documents. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
TASK-076 spec change 1.
What was wrong
An agent whose memory is empty got the bare prompt. That makes two very different states byte-identical from inside the session:
A seat cannot adopt a habit whose surface it has no evidence exists. Nothing in the turn told it memory was reachable, so nothing prompted the first write — and the empty state was self-perpetuating.
What changed
The empty case now emits a cue, and it names
long_termspecifically. That is the only section read back:readLongTermreturnssections.long_term.content. A write todaily— the section whose name most invites exactly this use — succeeds, returns 200, and is never shown to the agent again. The write and the silence are indistinguishable from a correct round trip, so naming the section is the whole point of the cue.The preamble moved into a shared
buildMemoryPreambleincli/src/lib/memory-bridge.js. The claude and codex adapters each carried an identical local copy; they now delegate. The non-empty path is byte-for-byte unchanged — that path is load-bearing and is not touched here.Tests
6 new cases on
buildMemoryPreamble(verbatim non-empty asserted byte-for-byte;undefined/null/''all take the empty branch), plus the empty-case contract pinned on both adapters — a shared helper is only shared until someone re-inlines one.Three codex argv assertions pinned the prompt as byte-identical to the final slot. They now anchor to the end of that slot, which is the invariant they were actually defending (prompt occupies the final argument), not the one they were spelling.
Verified by mutation rather than asserted: reverting
buildMemoryPreambleto the old bare-prompt behaviour goes 7 red / 45 green, and it compiled —52 total, not0 total.Full
clisuite: 24 suites, 354 passed, 10 skipped, 0 failed.🤖 Generated with Claude Code