Skip to content

WO-TRACE-BRIDGE-01: wire the subagent summary into ingestSession (write half, non-core) - #47

Merged
githubscum merged 2 commits into
mainfrom
lotor-lane/subagent-receipts
Sep 7, 2026
Merged

githubscum merged 2 commits into
mainfrom
lotor-lane/subagent-receipts

Conversation

@githubscum

Copy link
Copy Markdown
Owner

WO

WO-TRACE-BRIDGE-01, Isaac's top-priority item for this lane (2026-09-02
09:3x CDT): "Lotor lane needs to solve for this... best trace ever needs
to bridge across." The Agent-tool subagent path leaves no chain row and
no usage figures per child, which is invisible under a herded policy
config and a billing blind spot regardless.

What this closes

Two commits on this branch:

  • 4bfe127 (run 20): src/ingest/subagents.js, a pure reader that turns
    a child transcript sidecar directory into a structured summary. Nothing
    called it.
  • 6796c25 (this run): wires it in. ingestSession now accepts
    opts.transcriptPath; when a sibling <sessionId>/subagents/ directory
    exists it binds the summary onto receiptSummary.subagents before the
    chain append, same precedent as the 2026-08-29 thought sidecar (bind by
    summary, omit when absent, never a false zero).

It still ships dark. Nothing calls ingestSession with
transcriptPath yet. bin/hook-session-end.js needs one argument added
to its existing call -- the hook already has the value in scope as its
local transcriptPath -- and that file is bin/hook-* core, so it is
not applied here and queues for the signing sitting. Until it is
signed, this receipt is byte-identical to today's.

What a reviewer should doubt

  1. The one-line hook change is not in this PR, on purpose, per the
    lane's charter (core changes queue, never apply outside a signing
    sitting). It is exactly:
    ingestSession(text, { transcriptBytes: bytes, transcriptPath }) in
    bin/hook-session-end.js's main(), where transcriptPath is already
    the function's local variable. Small, but it is the switch that turns
    the feature on.
  2. priceTableDate is plumbed but never populated by any caller. The
    field exists in subagents.js's output shape and this wiring passes
    opts.priceTableDate through unchanged; nothing supplies it yet, so
    every subagents block on a real receipt will lack that field until a
    caller is written. Not a defect in this PR, just an honest gap in what
    "wired" means so far.
  3. The first draft of the test file had a real bug, caught by running
    the suite rather than trusting the executor's report: it reused one
    sessionId across all four cases sharing one store, which tripped
    ingestSession's own no-change guard (three of four calls came back
    skipped: true). Fixed by giving each case a distinct session id.
    Worth a second look because it is exactly the kind of test that looks
    right and silently proves nothing.

Tested

npm test: 952 pass / 0 fail, up from 948 on main. Four new cases:
no-sidecar-dir omits the field, one-child sidecar produces exact totals,
and both existing call shapes (ingestSession(text),
ingestSession(text, { transcriptBytes })) keep working with the field
absent.

Provenance

Drafted off-meter by glm-5.2:cloud via dispatch-to-ollama.ps1. Neither
the charter's named executor (deepseek-v4-flash:cloud) nor its fallback
(glm-5.3-flash:cloud) is present in this host's ollama list; glm-5.2
is the nearest available match and the same substitution run 20 made and
verified. The production diff (src/ingest/index.js) matched spec on
first read; the test-fixture bug above was found and fixed after running
the suite, not accepted from the executor's summary.

githubscum and others added 2 commits September 3, 2026 12:44
…half)

The subagent path leaves no child receipt on the chain and no usage figures,
so the most common shape of agentic work today is invisible to the witness.
This is the non-core half of the fix: a pure reader that derives the sidecar
directory from a transcript path and summarises each child.

collectSubagents distinguishes "no sidecar directory" (found:false) from
"directory present, no readable child" (found:true, children:[]), and
summarizeSubagents returns null only for the first, so a caller omits the
field rather than recording a false zero. All summing is defensive: a usage
field that is not a finite number contributes 0.

Imports nothing from the project and writes no files, so it is grantable
under the repo's own frozen core classification for ingest. The one line
that supplies opts.transcriptPath in the session-end hook is core and waits
for a signing sitting; until it is signed this ships dark and the receipt is
byte-identical to today's.

Tests: 7 new cases including the false-null guard. Full suite 948 pass / 0 fail.
Written off-meter by glm-5.2:cloud via dispatch-to-ollama.ps1; verified by
reading the artifacts and running the suite, not by the executor's report.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… write half continued)

Non-core continuation of 4bfe127. summarizeSubagents existed and nothing
called it. ingestSession now accepts opts.transcriptPath and, when a
sibling <sessionId>/subagents/ directory exists, binds the summary onto
receiptSummary.subagents before the chain append -- same precedent as the
thought sidecar (2026-08-29): bind by summary, omit when absent, never a
false zero. When transcriptPath is missing or summarizeSubagents returns
null, the field is left off the payload entirely, verified by three tests
alongside the one that proves the field appears with correct totals.

This is still core-adjacent by one line, not by this file: nothing calls
ingestSession with transcriptPath yet. bin/hook-session-end.js needs
exactly one argument added to its existing ingestSession(text, opts) call
-- opts.transcriptPath, which the hook already has in scope as the local
`transcriptPath` variable -- and that file is bin/hook-* core, so it
queues for Isaac's signing sitting rather than landing here. Until it is
signed, this ships dark: the receipt is byte-identical to today's.

Verification: the first draft's test file reused one sessionId across all
four cases against a shared store, which triggered ingestSession's own
no-change guard (a session whose transcript size has not grown is
skipped) on three of the four -- caught by running the suite rather than
trusting the executor's report, not a defect in the wiring itself. Fixed
by giving each case its own sessionId. Suite 952 pass / 0 fail, up from
948 on main.

Written off-meter by glm-5.2:cloud via dispatch-to-ollama.ps1 (the
charter's named executor and fallback, deepseek-v4-flash:cloud and
glm-5.3-flash:cloud, are not present in this host's ollama list; glm-5.2
is the nearest available match, same substitution run 20 made and
verified). Test-fixture fix applied directly after verification found it.

Co-Authored-By: Claude Sonnet 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