Memory, per-turn usage accounting, full AGY cognition, and durable-write fixes - #3
Merged
Conversation
… see partial json
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.
What
Memory is switched on. Mneme now flows end to end: recall into the prompt,
recordTurnwrite-back after. Wired in-process rather than over MCP, because recall is prompt-side — MCP can only offer tools the model may call once the prompt exists, so it cannot prepend a recall packet, and write-back would depend on the model choosing to call a tool. The legacy generated-Pi runtime already did exactly this; the daimon organization runtime had lost the wiring.Proven by a test that drives two real wakes and asserts turn 1's content reappears in turn 2's prompt.
Per-turn usage accounting. An advisory append-only ledger, one line per completed turn, 64 MiB rotation, written in the broker success branch after the completed record is sealed — not in the
completedframe, which would permanently break crash-recovery replay. Grok and AGY are metered; codex is deliberately absent so it can never claim zero.Validated against a live Grok frame:
input 11828 · output 34 · cacheRead 5248 · total 17110 · $0.0045for a two-word reply.Counts are labelled a lower bound everywhere they surface. An all-zero usage block reads as unknown, not free — the vendor's own documented rule.
AGY becomes a first-class engine. Previously
toolAccess: "none"andmaxToolTurns: 1, so AGY agents could not use Moltnet and could not participate in an organization. That was Daimon policy, not an AGY limitation: AGY supports MCP and calls tools headlessly under--print, verified live against a probe server. Now registered throughagy mcp add --type httpagainst the same per-wake endpoint Codex and Grok get, scoped by the per-agentHOMEso agents cannot collide.maxToolTurnsis 16, not unbounded: AGY's terminal usage frame is the sum over model steps and each tool step resends the whole context — measured, one call against an empty-schema tool takes a wake from 13,796 to 45,381 tokens.AGY's non-spec
server/discoverhandshake request is answered; every other unknown method still getsMethodNotFound.Durability fixes.
main: a style commit deleted two trailing blank lines from the.incsources without regenerating the provenance sidecars, sosource_sha256mismatched. Restoring them fixes it with no digest re-pinning; rebuilding would have moved five pins.writeFile— 64 concurrent allocations all returned seq 1. Now temp-write → fsync → rename → dirsync, with an advisory lock across the read-increment-write.acquireLeasepublished the final filename before writing valid JSON. Now publishes vialink(2), notrename(2)— rename overwrites unconditionally and would have turned a torn read into a double-lease bug.Verification
408 tests, 404 pass, 0 fail, 4 skipped.
tsc --noEmitclean.npm run buildpasses for the first time in this branch.Every fix carries a failing-before test and a mutation check. Two worth noting: the causal-sequence in-process queue is a contention optimization only — correctness is owned entirely by the lock file; and the lease exclusion guarantee is pinned by a deterministic contract test (publish onto an existing name must fail
EEXISTand leave content intact) rather than an unwinnable race test.Not included
Session continuity via
--continue/--conversationwas assessed and rejected: it carries every prior wake's transcript into every future one with no compaction hook Daimon owns, converting a bounded per-wake cost into an unbounded one, and it breaks the at-least-once wake-replay semantics the contract manifest pins.--continue,--conversation, and-care now rejected incommandArgsso it cannot be half-enabled.