Skip to content

fix(runtime): make Moltnet sends reach the network and meter codex turns - #5

Open
apresmoi wants to merge 1 commit into
feat/codex-turn-usagefrom
fix/moltnet-machine-and-codex-usage
Open

fix(runtime): make Moltnet sends reach the network and meter codex turns#5
apresmoi wants to merge 1 commit into
feat/codex-turn-usagefrom
fix/moltnet-machine-and-codex-usage

Conversation

@apresmoi

Copy link
Copy Markdown
Collaborator

Three defects that together made the Clank & Slop organization mute and its
usage ledger empty. All three were found by running the deployed organization,
and all three are proven fixed by a live cascade: brass sent to room:assignment,
the mention woke cogsworth, and both wakes appear in the fuse admission ledger
and the turn-usage ledger.

1. Moltnet identifiers were rejected as scoped agent ids (P0)

productionAgentTools.ts minted daimon:<sha256> for correlation_id and
delivery_id. Moltnet's machine protocol refuses any identifier that parses as
a scoped agent id, and ParseScopedAgentID treats every left:right string
as one. Every moltnet_send an agent ever attempted failed with
error: invalid request, on every engine.

Reproduced directly against the shipped moltnet binary inside the running
container: the daimon:-prefixed request exits 1 with error: invalid request,
the identical request with a colon-free id is accepted.

Fixed by prefixing with daimon-.

2. moltnet machine was cancelled by its own caller (P0)

machine() wrote the request with child.stdin.end(...). moltnet machine
treats end-of-input as cancellation of everything in flight, so the send was
cancelled before it completed and the CLI answered
{"error":{"code":"canceled"}}. Confirmed by holding stdin open for the same
request, which is accepted and returns a real message_id.

Stdin is now held open until the response line arrives.

The test fake previously waited for stdin end before answering, which is
exactly the shape that hid both defects. It is replaced by
src/runtime/fixtures/testMoltnetMachine.mjs, a faithful stand-in that refuses
colon-bearing ids and cancels on EOF.

3. Codex turns were never metered (P1)

decodeCodexTurnUsage required cache_write_input_tokens. Codex 0.142.3 (in
the runtime image) and 0.151.0 (on the host) both emit only input_tokens,
cached_input_tokens, output_tokens and reasoning_output_tokens, so every
real turn decoded to usage: undefined and the codex half of the usage ledger
recorded nothing — while the suite stayed green against a fixture that invented
the field.

The field is now optional (absent means zero); present-but-malformed still
degrades the whole block, as before.

Verification

  • Full suite: 449 pass / 0 fail.
  • Mutation-verified: restoring the colon prefix → red; restoring
    stdin.end(request) → red; making cache_write_input_tokens required again →
    red. Restored → green.
  • Live: a real wake through /v2/wakes on the deployed organization produced a
    moltnet_send, a mention-driven wake of a second agent, two admission-ledger
    lines and two turn-usage lines. All four were zero before this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant