Skip to content

fix(analytics): read pi's arguments wrapper in tool/file shapes + rollup repair pass (warren-677c) - #967

Merged
warren-auto-merge[bot] merged 2 commits into
mainfrom
warren-677c-pi-arguments-wrapper
Aug 18, 2026
Merged

fix(analytics): read pi's arguments wrapper in tool/file shapes + rollup repair pass (warren-677c)#967
warren-auto-merge[bot] merged 2 commits into
mainfrom
warren-677c-pi-arguments-wrapper

Conversation

@jayminwest

Copy link
Copy Markdown
Owner

Summary

Pi toolCall blocks wrap their args as {"name":"bash","type":"toolCall","arguments":{"command":…}}, but PI_TOOL_SHAPE (src/core/tool-shape.ts) read only payload.input.command / payload.command, and readPathsWith (src/core/file-shape.ts) read only payload.input. In production every pi bash rollup row (10,583/10,583) landed command=NULL and every pi edit/read/write row (3,944/3,944) landed empty file_paths/analytics/behavior command mining has been frozen on Jul 28–31 claude-code data while 311/319 runs are pi (warren-677c).

Changes

  • src/core/tool-shape.ts — pi readToolUse falls back to payload.arguments.command; precedence is input > arguments > top-level. Tests pin the exact observed prod payload.
  • src/core/file-shape.tsreadPathsWith now takes an args-container key list: claude-code reads ["input"] (arguments dialect stays pi-only), pi reads ["input", "arguments"].
  • repairToolCallRollup (src/runs/tool-calls-backfill.ts) — the boot backfill only targets runs with no rollup rows, so mis-extracted rows never re-enter its candidate set. The repair pass keyset-walks ToolCallsRepo.listRunsWithRollup, deletes each run's rollup rows, and replays its retained tool events through the same extraction seam the bridge/backfill use. Runs whose events were pruned are skipped, never deleted (the rollup is only derived state while its source survives). Idempotent end to end.
  • scripts/repair-tool-calls.ts — one-off prod entrypoint: WARREN_DB_URL required with no default, --dry-run counts candidate runs. events covers 318/319 prod runs, so the corpus is fully repairable.

Testing

  • New unit tests pin the pi arguments-wrapper shape for both command and file-path extraction, dialect precedence, and claude-code's non-reading of the pi dialect.
  • Repo tests cover listRunsWithRollup keyset paging + deleteForRun (sqlite + postgres suites).
  • Repair tests cover: re-extracting damaged rows the boot backfill skips, idempotency, events-pruned skip guard, paging, and result-join replay.
  • Local check:all: 11/12 gates pass; check:coverage fails only on the pre-existing warren-4de5 macOS test-order flake (fails identically on a clean tree).

Follow-up (not in this PR)

After merge + deploy, run the one-off repair against prod:
WARREN_DB_URL=… bun run scripts/repair-tool-calls.ts (optionally --dry-run first), then re-check /analytics/behavior.

🤖 Generated with Claude Code

…lup repair pass (warren-677c)

Pi toolCall blocks wrap args as {"name":"bash","type":"toolCall",
"arguments":{"command":...}}, but PI_TOOL_SHAPE read only
payload.input.command / payload.command and readPathsWith read only
payload.input. In production every pi bash rollup row (10,583/10,583)
landed command=NULL and every pi edit/read/write row (3,944/3,944)
landed empty file_paths, freezing /analytics/behavior mining on stale
claude-code data.

- PI_TOOL_SHAPE.readToolUse falls back to payload.arguments.command
  (input > arguments > top-level); tests pin the observed prod payload.
- readPathsWith takes an args-container list: claude-code reads
  ["input"], pi reads ["input","arguments"].
- repairToolCallRollup (src/runs/tool-calls-backfill.ts) re-extracts
  EXISTING rollup rows the boot backfill can never revisit (it only
  targets runs with no rollup rows): keyset walk over
  ToolCallsRepo.listRunsWithRollup, delete-and-replay per run from
  retained events, skipping runs whose events were pruned.
- scripts/repair-tool-calls.ts is the one-off prod entrypoint
  (WARREN_DB_URL required, no default; --dry-run counts candidates).

Local check:all: 11/12 gates pass; check:coverage fails only on the
pre-existing warren-4de5 macOS test-order flake (fails identically on
a clean tree).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@warren-auto-merge
warren-auto-merge Bot enabled auto-merge (squash) August 18, 2026 14:23
jayminwest added a commit that referenced this pull request Aug 18, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
jayminwest added a commit that referenced this pull request Aug 18, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@warren-auto-merge
warren-auto-merge Bot merged commit ae77095 into main Aug 18, 2026
5 checks passed
@warren-auto-merge
warren-auto-merge Bot deleted the warren-677c-pi-arguments-wrapper branch August 18, 2026 14:48
jayminwest added a commit that referenced this pull request Aug 18, 2026
…cf (judge live on GKE, PRs #968/#969); file warren-eecb/a106/941e follow-ups

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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