Skip to content

fix(hooks): uptake credits a hint's use on a connection its session alone declared - #699

Merged
atlas-from-plumb merged 3 commits into
mainfrom
atlas/hint-first-prompt-attr
Oct 16, 2026
Merged

atlas-from-plumb merged 3 commits into
mainfrom
atlas/hint-first-prompt-attr

Conversation

@atlas-from-plumb

Copy link
Copy Markdown
Collaborator

plumb hooks uptake's consumed proxy joined a hint to later calls only through tool_calls.logical_agent. plumb writes that column only while several agents share a connection, so every Codex hint, and every hint to a Claude Code session without subagents, read as unattributed. That includes the first-prompt hints that matter most. In the live Codex dogfood (PLAN-511), the agent read the hinted file 17 s after the hint, and the report still said "unattributed 1".

Fix (internal/stats/db_agent_inputs.go): InputsForAgent also returns the unstamped calls of a connection that the session alone declared. That holds when every session_start on the connection carries a session_id, all of them carry the same one, it is this session's, and the connection never recorded a stamped call. The declaration may follow the hint. Every rule fails closed.

Evidence

  • On a read-only copy of the real stats.db, the 2026-10-12 Codex hint now finds its follow-up calls: session_start plus three reads of plumb/internal/topology/indexer_calls.go. The query takes 39 ms for a 10-minute window and 72 ms for a week with no match, using idx_tc_called_at, idx_tc_tool_dur and idx_tc_session.
  • Tests:
    • a fixture with one connection per rule: solo, early, stamped, two declarers, an undeclared session_start, shared, another session's, garbage JSON, and both window bounds;
    • limit and ordering;
    • an end-to-end run of runHooksUptake over both real stores, with an undeclared decoy as the control.
    • InputsForAgent had no tests before this.
  • Mutation: the old query fails the new tests. All 8 mutants were killed: each fail-closed rule, the stamped path, both window bounds and the ordering.

🤖 Generated with Claude Code

atlas-from-plumb and others added 3 commits October 16, 2026 11:45
…lone declared

plumb stamps logical_agent only while several agents share a connection, so
the consumed proxy, which joined on logical_agent alone, could never credit a
Codex hint or one sent to a single-agent Claude Code session. The live Codex
dogfood (PLAN-511) read the hinted file 17 s after a first-prompt hint and
still counted as unattributed.

InputsForAgent now also returns the unstamped calls of a connection whose
every session_start declared this one session id, and that never recorded a
stamped call. The declaration may follow the hint, which is the first-prompt
case. Measured on the real stats.db: 39 ms for a 10-minute window, 72 ms for
a week with no match, all on idx_tc_called_at, idx_tc_tool_dur and
idx_tc_session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plumb-Session: forest-ridge
…he recorder

Review round 1 (independent Sonnet):
- BLOCKING: the docs claimed an unstamped call is never credited to the wrong
  agent. An agent that never identifies itself leaves no trace on the
  connection, so its calls count as the declaring session's. Say "never
  observed shared" and state that limit in the code, the CHANGELOG, the
  reference docs and the --help text.
- Pin the all-time scope: a stamped call, or a second declaration, after the
  window withdraws the connection (two new fixtures).
- The e2e test records session_start through statsToolData, so redacting
  session_id there would fail it.
- CROSS JOIN keeps win outer, so the plan probes idx_tc_session instead of
  scanning every session_start.
- Drop two dead predicates. Note that namespaces are not told apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plumb-Session: forest-ridge
Review round 2 NIT: the CROSS JOIN is the query's performance contract, and
reverting it left every test green. EXPLAIN QUERY PLAN must show the
session_start rows reached through idx_tc_session; with the old join form the
test fails (SEARCH d USING INDEX idx_tc_tool_dur).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plumb-Session: forest-ridge

@golimpio golimpio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review: round 1 FAIL (1 BLOCKING doc overclaim, 3 SHOULD), all fixed; round 2 PASS; its NIT folded in (plan pinned to idx_tc_session). Mutation: old query fails the new tests; 12/12 mutants killed incl. the reviewer's survivors and a session_id-redaction mutant. CI 9/9 green on head; make verify-full-container EXIT=0 on d426b08.

@atlas-from-plumb
atlas-from-plumb merged commit ca3f388 into main Oct 16, 2026
9 checks passed
@atlas-from-plumb
atlas-from-plumb deleted the atlas/hint-first-prompt-attr branch October 16, 2026 01:33
atlas-from-plumb added a commit that referenced this pull request Oct 16, 2026
Hooks stay inside their session's namespace (#698); context-hint uptake credits
a hint's use on a connection its session alone declared (#699); the shared file
watcher leaves linked git worktrees out (#700); an [lsp] restart can no longer
land on a superseded config (#701).


Plumb-Session: forest-ridge

Co-authored-by: Claude Opus 5.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.

2 participants