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)

  1. Cross-agent hook guard (#1262) — shouldSkipForwardedHook() short-circuits executeAgentHook when a hook fires for agent X but the payload's transcript_path belongs to agent Y's session dir.
  2. Cursor token usage (#1264) — parses token fields from Cursor's stop hook, threads them through event.TokenUsage, and adds per-checkpoint scoping via SessionState.CheckpointTokenUsage.

Correctness — looks right

I traced the token-scoping flow against main:

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)

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 in cmd/entire/cli/lifecycle_test.go (both sides added test helpers in the same spot; keep-both resolves it). Please merge/rebase main again and push. Two small asks: (1) drop the unrelated telemetry/detached_test.go and internal/coreapi/UPSTREAM.md changes (or note why they're here), and (2) confirm whether Cursor's stop payload includes subagent tokens — since we now skip the transcript-based subagent extractor for Cursor turns.

Summary

mergeable flipped from CONFLICTING → MERGEABLE. What I did:

  1. Fetched the fork branch and merged current origin/main into it.
  2. Resolved the conflict in cmd/entire/cli/lifecycle_test.go — an interleaved "both sides added adjacent code" conflict. Kept both independent additions intact.
  3. Verified: go build, go vet, tests pass, lint → 0 issues.
  4. 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.