Repository navigation
CORE (signing sitting): v3 V3-03: tool I/O digest on post-tool-use receipts (R2) - #71
Merged
Merged
Conversation
…ring staged src/toolio/index.js builds a toolio/1 object describing what a tool returned without holding it: full SHA-256 over a canonical serialization (CRLF folded to LF in every string leaf, keys sorted with the params/1 canonicalizer, now exported from src/parser), the UTF-8 byte length, and the host's own error flag (tri-state; null means no signal). A missing, null or unserializable response is recorded:false with a reason and no digest key, never an empty digest. test/toolio-digest.test.js: 22 tests, green. Pin derived out of band, key order, CRLF vs LF (including the suite's own checkout), error flag, absence, canary leak test, and chain fidelity on a real signed chain. The two-line hook wiring is core and is NOT applied: it is staged in proposals/v3-03-tool-io-digest-2026-10-22.patch for the signing sitting. Its five tests in test/hook-post-tool-use-toolio.test.js run as TODO until that patch flips WIRED. src/toolio classified grantable in test/core-classification.test.js (owner to confirm). KNOWN-LIMITS 75 recorded; the limits pin is not re-stamped. Suite: 1084 tests, 1079 pass, 0 fail, 5 todo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
githubscum
added a commit
that referenced
this pull request
Oct 22, 2026
The KNOWN-LIMITS numbering test requires contiguous entries, so numbers follow the merge order #65, #66, #64, #63, #60, #62, #61, #67, #68, #69, #70, #71: #62 takes 75, #61 takes 76, this PR takes 77. Every citation on this branch moves with it (KNOWN-LIMITS.md heading and the limit 53 note, src/views/matcher-history.js header, test/matcher-history.test.js comment). On this branch alone the numbering test reports 75 and 76 missing; that clears once #62 and #61 are on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The KNOWN-LIMITS numbering test requires contiguous entries, so numbers follow the merge order #65, #66, #64, #63, #60, #62, #61, #67, #68, #69, #70, #71: #62 takes 75, #61 takes 76, #67 takes 77, this PR takes 78. Every citation on this branch moves with it: KNOWN-LIMITS.md heading, CHANGELOG.md, docs/receipt-coverage.md, and the V3-03 proposal note. The staged .patch carries no limit number and is unchanged. On this branch alone the numbering test reports 75, 76 and 77 missing; that clears once #62, #61 and #67 are on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Merge-order fix: limit renumbered 75 -> 78 (commit 0066849) Numbers assume the owner's merge order: #65, #66, #64, #63, #60, #62, #61, #67, #68, #69, #70, #71. #62 takes 75, #61 takes 76, #67 takes 77, this PR takes 78.
Expected conflicts at merge time (not rebased, per instruction):
Simulated the full merge order locally with those resolutions: 1225 tests, 1218 pass, 0 fail, 7 todo (all staged-patch tests). |
F1: toolIo carries a code stamp. `hash` is the first 16 hex of SHA-256 over
the source of every function in src/toolio/ that shapes the record, beside
`schema`, mirroring parser: { schema, hash }. Source CRLF is folded before
hashing, so CRLF and LF checkouts of one commit stamp the same (tested by
importing both spellings of the module).
F2: responseOk vs toolIo.error. Precedence documented in the module header,
limit 78 and docs/receipt-coverage.md: toolIo is authoritative when recorded.
The agreement table, including the three divergent inputs, is pinned against
the real hook's legacy field in a test that runs today.
F3: no more distinct-values-one-digest. The module walks the value once into
null-prototype objects (an own __proto__ key is data) and calls anything
without an exact JSON form unserializable (undefined, functions, toJSON,
Dates, Maps, class instances, NaN, holes, symbols, BigInt, cycles). It no
longer imports the params/1 canonicalizer, so src/parser is back to main;
output is byte-identical for every value without an own __proto__ key and
the pin is unchanged. The params/1 __proto__ hole is recorded in limit 78,
not fixed: fixing it moves digests already on gate receipts.
F4: a runnable leak test on the full receipt: the real unpatched hook's
receipt plus the staged field in the staged position, signed onto a real
chain, chain file scanned on disk. F6 test renamed, F7 tamper assertions made
consistent, F8 engine-error receipt asserted to carry no toolIo.
Also: the staged patch failed `git apply --check` in a core.autocrlf=true
checkout (two blank context lines written as empty lines). They are now a
single space; the check passes in CRLF and LF form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The self-mod gate blocks an Edit to the hook even in a scratch worktree, and this lane did not route around it. The proposal now states that the six wiring tests are the sitting's to confirm, not a result already in hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
Review fixes: second-family review (minimax-m3), V3-03Pushed Fixed
Not fixed, and why
Found while fixing
What was and was not run
Nothing merged, approved or opened. |
…-io-digest # Conflicts: # KNOWN-LIMITS.md # test/core-classification.test.js
githubscum
added a commit
that referenced
this pull request
Oct 22, 2026
Applied in the live install, each step signed by the owner: - store: tail-only append (proposals/store-tail-append, #72); PENDING_LANDING flipped in the same change. Precondition: live chain 37,173 entries, seq continuous. - hooks: V3-02 session-open reach certificate (#70), V3-04 per-step reasoning (#69), V3-03 tool I/O digest (#71), applied from git's stored patches. - chain: canonicaliser keeps an own __proto__ key in the hash (found while fixing #70); existing hashes unchanged (live chain had zero such keys). - tests: hook-wiring todo markers removed. npm test: 1292 tests, 1292 pass, 0 fail, 0 todo. Deferred to the post-merge evaluation: the #68 matcher line-ending fix, the KNOWN-LIMITS pin re-stamp (needs re-verification of every limit), verifyChain seq continuity, keyed digests, R2 on every tool call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Rung R2 (tool I/O) from the v3 spec, work order V3-03. The post-tool-use receipt gets a
toolIofield that says what the tool returned without holding any of it:or, when there was nothing to see:
Lotor captures; it never judges intent. The module hashes, measures and copies the host's own error flag. It never reads meaning into a response.
The hook wiring is NOT applied in this PR. It is
bin/, so it is staged as a patch for the signing sitting (see below). Everything that is not core is on the branch and tested.Files
src/toolio/index.js(new):describeToolResponse,canonicalResponseText,reportedError,TOOLIO_SCHEMA. The header comment is the full contract.src/parser/index.js:canonicalizeis now exported, so R2 uses the same canonicalizer asparams/1instead of a third copy. One word plus a comment; the function is unchanged and theparams/1pin still passes.test/toolio-digest.test.js(new, 22 tests, green).test/hook-post-tool-use-toolio.test.js(new, 5 tests, TODO until the patch lands).test/core-classification.test.js:src/toolioadded to GRANTABLE, with the reason. Owner decision, see below.proposals/v3-03-tool-io-digest-2026-10-22.patch+.md: the staged hook diff and why.KNOWN-LIMITS.md: limit 78.CHANGELOG.md,docs/receipt-coverage.md: entries saying the field is staged, not yet live.Design decisions
responseDigest(16-hex, unordered,'empty'for absent) andresponseOkstay exactly as they are, so old readers and old receipts keep working. Same move asparamsDigestCanonicalbesideparamsDigest.toolio/1: CRLF folded to LF in every string leaf (keys untouched, lone CR kept as content), keys sorted recursively, arrays in order,JSON.stringify, UTF-8.digestis the full SHA-256 (no 16-hex truncation, same birthday-bound reason asparamsDigestCanonical).bytesis the length of that canonical text, so it is stable across checkouts and is not the raw size the tool emitted.core.autocrlf=truecheckout and an LF checkout gives the same digest. The digest depends on the response only, never on source bytes. (The existingmatcherHash/parserVersionHashstamps hashFunction.toString(), which carries the checkout's line endings. This field does not repeat that.) Tested with explicit\r\nescapes in fixtures, and against this test file's own on-disk bytes, so the result cannot depend on the checkout the suite runs in.is_error/isErrorboolean, then a booleanerror, then a non-empty string or objecterror, then an HTTP-shapedstatus/statusCode. Nothing recognizable givesnull, which means "no signal", not "succeeded". The word "error" in stderr is content, and judging it is the meter's job. Note: Claude Code's Bash response carries no error flag, so real Bash receipts will mostly readnull.describeToolResponseis receipt-agnostic, and putting it there is one line. Recorded as limit 78.Privacy guarantee
No response content, prefix, excerpt or response key name is ever returned by the module or written to the receipt. The
toolIoshape is closed (schema,response;recorded,digest,bytes,errororrecorded,reason), and a test fails if any other key appears. A canary test plants a GitHub-token-shaped secret in values, a secret-shaped key name, and nested copies, and asserts that none of them, nor a 16-character slice of the token, appear. The wiring tests repeat the canary check on the real hook's receipt.What does leave, stated plainly: the size, and a digest that is dictionary-reversible for short or guessable responses (a "yes", an exit code, a 6-digit code, a file the reader already has).
paramsDigesthas had the same property since v1; R2 widens it from what was asked to what came back. A keyed HMAC would close it, and would also stop two installs (or the meter's evals) comparing digests. That trade is yours. Limit 78.How absence is recorded
recorded: falsewithreason, and nodigest,bytesorerrorkey at all:absent: the host payload had notool_responsenull: the host senttool_response: nullunserializable: a circular value, BigInt or bare function (does not throw)An empty string or empty object is recorded, with a real digest (
bytes: 2), because an empty answer is still an answer. The legacy'empty'sentinel never appears intoolIo.Tests
Fail-first: on main,
test/toolio-digest.test.jsfails at import (ERR_MODULE_NOT_FOUND; checked by movingsrc/toolioaside). The five wiring tests fail against the unpatched hook and are reported as TODO.78d33f99…5874, 54 bytes, derived out of band withprintf | sha256sum, not by running the code.nullon Bash-shaped and string responses, and flipping the flag changes the digest too.LOTOR_HOME: receipts with recorded and unrecordedtoolIoverify; tampering with the digest, the byte count or the error flag, upgrading an unrecorded response to a recorded one, or stripping the field each break verification at that entry.npm test summary (this branch, Windows, Node 24.18, CRLF checkout):
Main at
5198a07on the same machine: 1056 tests, 1056 pass. The 5 TODO are the wiring tests. Nothing else is left failing. No pin or stamp test failed; I did not re-stamp the KNOWN-LIMITS pin.E5 cost, measured on this machine: about 0.03 ms per call at 1 KB, 1 ms at 100 KB, 9.5 ms at 1 MB, 155 ms at 10 MB. The field adds about 155 bytes per receipt regardless of response size. No new chain I/O.
Why the hook edit is a patch and not a commit
bin/hook-post-tool-use.jsis self-mod protected. The live gate on the build machine gates anybin/*.jsedit, this clone included (it already refused one shell command on this clone that named a protected path). So I did not attempt the edit, and I did not route around the gate. The diff is inproposals/v3-03-tool-io-digest-2026-10-22.patch:import { describeToolResponse } from '../src/toolio/index.js';toolIo: describeToolResponse(toolResponse),on theegress-eventreceipt, beside the legacy fieldsWIREDtotrueintest/hook-post-tool-use-toolio.test.jsChecked on this branch with
git apply --check --cached: exit 0, no offset. To check the wiring before staging, I ran the five wiring tests against a scratch copy of the hook (outside the repo, never registered) with the sametoolIoline added: 5 of 5 pass.What the owner does at the signing sitting
git apply proposals/v3-03-tool-io-digest-2026-10-22.patch, signing the onebin/file. Limit 73: make it one signed operation for that file (the patch, one Edit covering both hunks, or one whole-file Write). Two separately staged hunks will purge each other.npm test: expect 1084 tests, 1084 pass, 0 todo.src/toolio. I put it in GRANTABLE (reporting, not enforcement; same line as parser, ingest, harness and toolpins, which hooks already import). Once wired it runs inside a core hook's process. If you want it core, that means adding it toCORE_DIRSinsrc/grant/core-paths.jsand toselfModFragmentsForBase()insrc/policy/index.js, both core, same sitting.npm run limits-pin -- --stamp) after merge. This branch adds limit 78 and touchessrc/, and I left the pin alone.Overlap with other lanes
bin/hook-post-tool-use.js. My hunks are one import line next to the existing imports and one property in theegress-eventliteral, so the rebase should be trivial. If V3-04 adds a per-step receipt, it should carrytoolIo: describeToolResponse(toolResponse)as well; that is what makes R2 complete.toolIowithrecorded: true. The certificate should be computed from that, not declared.test/known-limits-numbering.test.jsreports 75, 76 and 77 missing until those three are on main.CHANGELOG.mdtop entry will conflict textually with any other lane's top entry. Trivial.🤖 Generated with Claude Code