feat(runtime): meter codex turns and add a fail-closed wake fuse - #4
Open
apresmoi wants to merge 5 commits into
Open
feat(runtime): meter codex turns and add a fail-closed wake fuse#4apresmoi wants to merge 5 commits into
apresmoi wants to merge 5 commits into
Conversation
Collaborator
Author
|
Two further rounds landed since the PR description was written:
Every fuse guarantee is now mutation-verified — deleted, suite observed red, restored:
Deferred P2/P3 findings are listed in |
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.
Scope
Stacked branch. This branch is cut from the local, unpushed
feat/operational-ecosystem, so the diff againstmaincarries 24 commits thatare not this change. This PR's own range is the last three commits:
ed8f8bbfeat(runtime): meter codex turns into the per-turn usage ledger8cf7a1ffeat(runtime): add a fail-closed wake fuse with a named halt pointa64e286fix(pi): publish a paid codex turn whose stream is truncated or trailingWhy
An organization of 16 agents exhausted a paid subscription in 24 hours across
2,481 wakes. Two things had to exist before that organization could be run again
and measured: every engine's spend had to be visible, and something had to be
able to stop it.
Codex metering
Codex turns were completely uninstrumented —
TURN_USAGE_ENGINESwas["agy", "grok"]and Codex ran in plain-text mode, which reports no tokenaccounting at all. Codex now runs
codex exec --jsonand a new decoder readsthe
turn.completedusage frame.The arithmetic is verified against a live
codex-cli 0.151.0capture:total_tokens 18115 = input 18110 + output 5, socached_input_tokensis asubset of
input_tokens— the opposite of AGY's disjointcache_read_tokens.Copying AGY's formula would over-count every cached turn, and a test locks that.
Codex's output format is now a Daimon-owned boundary like AGY's, guarded by
assertSafeCodexCommandArgs.The wake fuse
A durable, fail-closed admission ledger with a named halt point. On a trip:
acceptedare driven terminal, because leaving themparked is the burnout: startup re-dispatches every
acceptedrecord and thebus polls non-terminal records forever;
stopped/host_stoppingresponse.No new wire enum, so
DAIMON_CONTRACT_MANIFEST_SHA256is unchanged and everypinned image still attests.
Operator stop:
Review
Reviewed adversarially by a different vendor's model than the implementer.
Three P1s were found against the decoder — a paid turn's reply was discarded
when a frame followed
turn.completed, when the stream was truncated, and whena blank message clobbered a good one — and all three are fixed in
a64e286with failing-before tests. Deferred P2/P3 findings are recorded in
WAKE_WORK_LEDGER.md.Gates
npm test— 439 tests, 435 pass, 0 failnpm run typecheck— cleannpm run verify:contract-manifest— digest unchanged🤖 Generated with Claude Code