Fix Integration Test Checkpoint Metadata Rename · Entire
Review: PR #1263 — Fix Cursor hook misattribution + token usage
Verdict: Sound design, well-tested, but has one merge blocker. The author's "rebased latest main" claim is now stale — main has moved and the branch no longer merges cleanly.
What it does (two independent fixes)
- Cross-agent hook guard (#1262) —
shouldSkipForwardedHook()short-circuitsexecuteAgentHookwhen a hook fires for agent X but the payload'stranscript_pathbelongs to agent Y's session dir. - Cursor token usage (#1264) — parses token fields from Cursor's
stophook, threads them throughevent.TokenUsage, and adds per-checkpoint scoping viaSessionState.CheckpointTokenUsage.
Correctness — looks right
I traced the token-scoping flow against main:
SaveStepaccumulates into bothTokenUsage(session-wide, forentire status) andCheckpointTokenUsage(pending delta). ✓CondenseSessionbackfillssessionData.TokenUsagefromCheckpointTokenUsageonly when transcript-derived usage is empty — correct for Cursor, no-op for agents with real transcript usage. ✓- All three callers of
CondenseSessionresetCheckpointTokenUsage = nilafter condensing. ThePerCheckpointScopingintegration test asserts exactly this. ✓ - The negative-clamp and nil-vs-zero semantics in
tokenUsageFromStopare thoughtful and tested.
The guard fails open in every ambiguous case (no SessionRef, unattributable path, unresolvable repo root) — the safe default. .cursor/hooks.json correctly matches the existing committed .codex/hooks.json / .gemini/settings.json dogfooding convention, so that's not a stray file.
🔴 Blocker: merge conflict
mergeable: CONFLICTING. A real textual conflict exists in cmd/entire/cli/lifecycle_test.go — both main and this branch added adjacent test helpers/functions. It's mechanical (keep-both), not logical. Everything else auto-merges. The author needs to rebase/merge main again and resolve it.
🟡 Minor notes (non-blocking)
- Scope creep: two unrelated edits ride along —
telemetry/detached_test.go(adds a redundantreturnaftert.Fatal, presumably to silence a nil-deref linter) andinternal/coreapi/UPSTREAM.md(drops a trailing newline). Harmless, but worth asking the author to drop them or call them out. - Subagent tokens for Cursor:
handleLifecycleTurnEndnow prefersevent.TokenUsageand skipsCalculateTokenUsage, which is whereSubagentAwareExtractoradds subagent tokens. - CI: no checks ran — it's a fork PR, so CI is gated. Can't independently confirm the "full suite + lint pass" claim without running it on the merged tree.
Suggested reply to the contributor
Thanks for the follow-up. The token-scoping design is correct and the test coverage is exactly what I wanted. One blocker before I can merge: the branch conflicts with current
main— there's a content conflict incmd/entire/cli/lifecycle_test.go(both sides added test helpers in the same spot; keep-both resolves it). Please merge/rebasemainagain and push. Two small asks: (1) drop the unrelatedtelemetry/detached_test.goandinternal/coreapi/UPSTREAM.mdchanges (or note why they're here), and (2) confirm whether Cursor'sstoppayload includes subagent tokens — since we now skip the transcript-based subagent extractor for Cursor turns.
Summary
mergeable flipped from CONFLICTING → MERGEABLE. What I did:
- Fetched the fork branch and merged current
origin/maininto it. - Resolved the conflict in
cmd/entire/cli/lifecycle_test.go— an interleaved "both sides added adjacent code" conflict. Kept both independent additions intact. - Verified:
go build,go vet, tests pass, lint → 0 issues. - Pushed the merge commit to the PR branch via
maintainerCanModify.
Your working tree is back on a clean main; the temporary pr1263-merge branch is deleted.
The remaining items from my earlier review are unchanged (non-blocking): the unrelated changes, and the question about whether Cursor's stop payload folds in subagent tokens.