fix(herdr): rewrite CodexActivity against the real live rollout shape (S11)

The previous function_call/function_call_output shape was never verified
and doesn't exist in any real Codex rollout. Confirmed the real shape
against this machine's own ~/.codex/sessions files: file edits arrive as
event_msg/patch_apply_end (changes+success, no pairing needed), and shell
commands arrive as a freeform custom_tool_call named "exec" whose input is
a JS snippet embedding cmd:"..." rather than a flat arguments object, with
failure signaled by a literal "Script error:" prefix in the output text.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W1rkJ2hBMybnJctPbcy4tT
This commit is contained in:
kami
2026-07-28 00:19:48 +04:00
parent c85fb81663
commit 6fd7738a02
4 changed files with 243 additions and 23 deletions
+38
View File
@@ -1005,6 +1005,44 @@ refuses rather than guessing).
`go build ./...`, `go vet ./...`, `go test ./...` all pass.
## S11 — `CodexActivity` verified and rewritten against a live rollout, 2026-07-28
The guessed `function_call`/`function_call_output` shape did not exist in any
real rollout on this machine (`~/.codex/sessions`, checked directly, not
recalled). The real shape:
- File edits arrive as `event_msg`/`patch_apply_end`, carrying `changes`
(map of absolute path → diff) and a top-level `success` bool directly — a
strictly better source than the old assumption, no call/result pairing
needed.
- Shell commands arrive as a single freeform `response_item`/
`custom_tool_call` named `"exec"` whose `input` is a JS snippet
(`tools.exec_command({cmd:"...", ...})`), not a flat arguments object.
`codexExecCommand` regex-extracts the first embedded `cmd:"..."`.
Success/failure has no structured exit-code field either — but a failed
script's output block reliably starts with the literal string
`"Script error:"` on this machine's real transcripts (observed for both a
JS syntax error and an `apply_patch` verification failure), so that
heuristic is now confirmed, not guessed.
`internal/herdr/activity.go`'s `CodexActivity` rewritten to this shape;
`internal/herdr/activity_test.go` gained
`TestCodexActivityParsesRealRolloutShape` /
`TestCodexActivityMarksScriptErrorAsFailure`, fixtures built to match the
confirmed live shape, not an assumed one. Manually re-ran the new parser
against a real multi-hundred-line rollout file end-to-end (not just the unit
tests) and spot-checked the output — commands, file edits, and pass/fail all
matched the transcript by eye.
**Still open:** `DetectMilestone`'s "last call was `git commit`" check only
sees the *first* `cmd:"..."` in a chained exec script, so a commit issued
after other commands in the same script call won't be seen as the "last
call" even though it was the last command executed — a known limitation of
single-command extraction, not fixed here. Opencode still has no verified
per-tool-call source.
`go build ./...`, `go vet ./...`, `go test ./...` all pass.
## S8 — closed, 2026-07-27
No compensation-event mechanism existed — §3.1's own invariant ("a wrong