Skip to content

CORE (signing sitting): v3 V3-02: reach certificate, measured not declared, on session receipts - #70

Merged
githubscum merged 6 commits into
mainfrom
lotor-lane/v3-02-reach-certificate
Oct 22, 2026
Merged

githubscum merged 6 commits into
mainfrom
lotor-lane/v3-02-reach-certificate

Conversation

@githubscum

@githubscum githubscum commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

CORE. Lands only at the owner's signing sitting. Do not merge before then.

Work order V3-02 of the Lotor v3 spec (LOTOR-V3-SPEC-2026-10-18): the reach certificate. Each session states the model, the runtime and the deepest rung recorded, measured, not declared, so a later finding can never claim more depth than its record had.

What it does

  • src/reach/certificate.js (new; moved from src/reach/index.js on 2026-10-22, because v3 V3-05: observe reach rungs from the response, never the request #60 owns that file). The rung ladder R0 to R6, plus:
    • buildOpenCertificate(payload, harness): the open half. Model and runtime as the harness states them, each with its basis. The rung is not-yet-measured, because nothing has been emitted yet at open and any rung stated there would be a guess. The Lotor build is not repeated; it points at the same payload's observer field (package version and whole-tree source digest).
    • measureCloseCertificate(summary, transcript): the close half, measured. Per rung, overall and per model.
    • attachOpenReference(cert, entries, sessionId): links the close certificate to the session's latest session-open on the chain (opened: { seq, hash }) and takes the runtime (harness name and basis) from it.
    • checkCertificate(cert, receipt?): for readers (the meter, a verifier). Rejects any certificate whose stated depth is not backed by its own rung map, or whose recorded counts are not backed by the receipt's own fields.
  • src/ingest/index.js. Every session receipt (SessionEnd) now carries reach, the close certificate. The open link is taken inside the chain lock. A measurement failure is recorded as failed (and refused by checkCertificate) and never costs the session its receipt.
  • proposals/v3-02-session-open-reach.patch (staged, not applied). The two-line wiring that puts the open certificate on the session-open receipt. See "Why the hook is staged" below.

Design decisions

  1. Measured from the response side only. Nothing that declares a rung is read: not request options, not a reach/rungs field in a hook payload or transcript, not the think flag. Only response-side fields that are present and non-empty count. This is V3-01's finding turned into code: Ollama cloud accepts logprobs: true, answers 200, and omits the field, and that case is a test here.
  2. Three statuses per rung.
    • recorded: the receipt holds a per-item record of this rung (R1 in ran, R3 in session.thinkingBlocks) and the transcript carried it.
    • observed: the transcript carried it, but this build keeps no per-item record of it (bound only through transcriptHash). Today: R0 text, R2 tool results, R4 logprobs.
    • unrecorded: nothing found or kept.
  3. The ceiling. recorded requires both halves, so neither a receipt that claims more than its transcript held nor a transcript the receipt never kept can raise the certificate. deepestRecorded is never deeper than deepestObserved. Tested with forged receipts and forged certificates.
  4. "Deepest" is the highest-numbered rung with a record, and the full rung map travels with it, because reach is not contiguous (V3-01: qwen2.5 had R4 and no R3).
  5. Per model. A session can run more than one model, and reach is per model, not per runtime (V3-01). byModel uses the same bucket keys as cost.byModel so they join. A tool result is attributed to the model that made the call.
  6. R5 and R6 are never read from a transcript. No runtime Lotor sits on exposes them there, and a field named activations in a message is a claim, not a capture. They stay unrecorded until a capture path exists (V3-06).
  7. Extensible for V3-03 and V3-04. A rung becomes recordable by adding one entry to RECORD_FIELDS in src/reach/certificate.js. No hook change is needed for that.

How absence is recorded

  • A rung with nothing is { "status": "unrecorded" } with no count field at all. A 0 would read as "measured, and the model did none of this", which the record cannot back: a model that thought without exposing it looks identical to one that did not think. checkCertificate rejects any certificate that carries a zero.
  • Nothing recorded at any rung: deepestRecorded: "unrecorded", not "R0" and not null.
  • No model in the transcript: model.id: "unrecorded". No model in the SessionStart payload: { id: "unrecorded", basis: "none" }.
  • No session-open on the chain for this session: opened: "unrecorded", runtime.harness: "unrecorded".
  • At open: rungs and deepestRecorded are both "not-yet-measured".

Tests

test/reach-certificate.test.js, 26 tests in 5 suites (one marked todo). The suite total grows by 27 because the classification test also gains a case for src/reach. Fail-first: on main the file fails at import (module absent); with src/reach present and ingest not yet wired, the four chain tests failed, and they pass with the wiring. Covered:

  • Open half: basis labels, absent model, declared rungs ignored, hostile id capped.
  • Close half: a Claude-shaped session, absence never zero, the V3-01 silent logprobs drop, logprobs that did come back read as observed and not recorded, per-model reach, re-derivation from the receipt.
  • Ceiling: forged receipt, unkept transcript rung, declared reach in the transcript, forged certificates, zero counts, failed measurement.
  • Chain fidelity, eval E2: the certificate verifies on the chain, and four different tamperings each break verification at that entry. Also the open link and subsession receipts.

npm test on this branch:

ℹ tests 1083
ℹ suites 184
ℹ pass 1081
ℹ fail 1
ℹ cancelled 0
ℹ skipped 0
ℹ todo 1

Baseline on main at 5198a07: 1056 tests, 1056 pass, 0 fail.

Left failing or todo, and why

  1. FAILING on this branch alone: test/core-classification.test.js, "src/reach is either core or explicitly grantable". v3 V3-05: observe reach rungs from the response, never the request #60 (merges first) adds reach to GRANTABLE, which settles it for both modules once v3 V3-05: observe reach rungs from the response, never the request #60 is on main; the owner can still reverse it. This test refuses any new directory under src/ until a human classifies it, and says it will not guess. The lane did not guess either. Recommendation: grantable today, reason "states evidentiary depth on a receipt; can mislead a reader, cannot change what the gate permits" (the same line drawn for harness.js, ingest, parser). It moves to core the day a policy reads a certificate (the spec's secrets-material rule), and then it goes into both CORE_DIRS and selfModFragmentsForBase(). The grantable option is one line in GRANTABLE in that test file.
  2. TODO: "session-open carries an open certificate that verifies on the chain". It runs the real SessionStart hook, so it can only pass once the staged patch is applied. It is marked todo so it reports without failing the suite. It was run and it does fail today (no reach on the open), so it is a real test and not a placeholder.
  3. No version pin or freshness stamp was touched, and none failed. Adding src/reach changes the whole-tree build digest (observer.build) by design.

Why the hook is staged

The self-mod rule gates every bin/*.js edit in every mode, and it matches by path fragment, so it gates the hook in a lane clone the same as in the live install. The lane did not ask for a signature and did not route around the gate. The wiring is two lines, staged as proposals/v3-02-session-open-reach.patch. git apply --check passes against main at 5198a07, both on the working tree (CRLF checkout) and from the index. The reasoning is in proposals/v3-02-reach-certificate-2026-10-22.md.

The close half does not depend on the patch: session-open receipts on main already carry harness, so the close certificate links to them and takes the runtime from them today.

What the owner does at the signing sitting

  1. Decide the classification of src/reach (above), and make that one edit.
  2. Apply proposals/v3-02-session-open-reach.patch (git apply proposals/v3-02-session-open-reach.patch).
  3. Remove the todo option from the last test in test/reach-certificate.test.js, then run npm test. Expected: 0 fail, 0 todo. This has not been run green, because applying the patch is the gated act.
  4. If wanted: a CHANGELOG entry and KNOWN-LIMITS lines for the residuals below. The lane did not edit either, to avoid touching the KNOWN-LIMITS pin and to keep rebases clean for V3-03 and V3-04.

Residuals and open questions

  • The SessionStart model field is unverified. The open half reads payload.model (a string, or an object with id). This lane did not capture a live SessionStart payload to confirm that Claude Code sends one. If it does not, the open certificate says unrecorded, which is honest, and the close half measures the model anyway.
  • R2 is counted as observed only, although failed[].errorDigest digests the output of failed calls. That is a deliberate under-claim, which is the safe direction. V3-03 makes R2 recordable through RECORD_FIELDS.
  • The R0/R3 boundary leak from V3-01 is not classified here. Reasoning that lands in text content (a stray </think>) counts as R0 observed. That under-claims R3 (safe), but it puts reasoning text in the R0 count. Classifying it by marker is V3-04's job.
  • redacted_thinking blocks are counted at no rung.
  • Per-model recorded is inherited, not re-derived. The parser records every tool call and thinking block whatever the model, and ran[] carries no model field, so per-model recorded status is inherited from the session-level status. checkCertificate enforces that a model can never be recorded at a rung the session is not.
  • The model id is self-attested by the runtime (KNOWN-LIMITS 1). Lotor measures what the runtime wrote; that does not authenticate it.
  • npm run receipts does not render the certificate yet.
  • Rebase surface for V3-03 and V3-04: one block in src/ingest/index.js after the chapters binding, and two hunks in bin/hook-session-start.js (import list and the payload literal, after harness,).

🤖 Generated with Claude Code

githubscum and others added 2 commits October 22, 2026 11:49
New module src/reach: the v3 rung ladder (R0 to R6), an open-half builder,
a close-half measurer, and checkCertificate for readers. The close half is
computed from what the receipt holds and what the transcript carried, never
from anything requested or declared: a rung is "recorded" only when both the
receipt has a per-item record of it and the transcript carried it, so the
certificate can never state a deeper rung than was observed. Absence is
{ status: 'unrecorded' } with no count, never a zero.

src/ingest attaches the close certificate to every session receipt and, inside
the chain lock, links it to the session's open receipt (seq and hash) and takes
the runtime from it. A measurement failure is recorded as failed and never
costs the session its receipt.

Tests: test/reach-certificate.test.js, fail-first (the module is absent on
main; the four chain tests failed with the module present and ingest
unwired). Includes the V3-01 silent logprobs drop, the ceiling, forged
certificates, and chain fidelity (verifies; tampering breaks it). The
session-open hook test is todo until the staged hook patch is applied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The open half of the certificate needs two lines in the SessionStart hook,
which is core and gated in every mode, so it is staged as a patch rather than
applied by the lane. git apply --check passes against main (working tree and
index). The proposal records the one decision left to the owner: whether
src/reach is grantable or core (test/core-classification.test.js fails until
that is decided, by design).

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>
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, #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>
#60 (V3-05) creates src/reach/index.js for observeRungs and reachReport
and merges first, so this branch no longer claims that file. The
certificate module moves to src/reach/certificate.js unchanged apart from
its header, and every import follows it: src/ingest/index.js,
test/reach-certificate.test.js, and the staged session-start wiring in
proposals/v3-02-session-open-reach.patch (same line counts, so the hunk
headers stand; `git apply --check` passes on the committed blob, against
the working tree and the index). The proposal table names the new path
and notes that #60's GRANTABLE line for `reach` settles the
classification test once #60 is on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@githubscum

Copy link
Copy Markdown
Owner Author

Merge-order fix: certificate moved to src/reach/certificate.js (commit db56510)

#60 creates src/reach/index.js (observeRungs, reachReport) and merges first, so it keeps that file. This branch now puts the certificate in src/reach/certificate.js. Nothing in the module changed except its header.

Expected conflict at merge time (not rebased, per instruction): #69 merges first and also edits src/ingest/index.js. Two hunks conflict:

  1. Imports: keep CORE (signing sitting): v3 V3-04: reasoning trace chained per step (R3) #69's reasoningBinding import and this PR's ../reach/certificate.js import.
  2. After the chapters binding: keep CORE (signing sitting): v3 V3-04: reasoning trace chained per step (R3) #69's reasoning block (reasoningSidecar, bindReasoning) first, then this PR's reachMeasured block. The rest of the merge is automatic: attachOpenReference sits at the top of the buildPayload callback, and bindReasoning stays on both return paths.

Today the reach R3 count reads session.thinkingBlocks, so measuring before bindReasoning is correct. If R3 later reads #69's reasoning field, the measurement has to move inside the lock, after bindReasoning. Simulated the full order with this resolution: 0 fail.

githubscum and others added 2 commits October 22, 2026 12:26
…an object key

F1: a model id named __proto__ wrote to Object.prototype through the
certificate's tallies and the parser's cost.byModel; constructor/toString
wrote to shared builtins and dropped the model from the certificate.
Tallies are Maps, the parser publishes buckets as own properties, and the
certificate's byModel is now a sorted list of { model, ... } entries, so a
model id is a value and is always inside the chain hash. checkCertificate
refuses a keyed byModel.
F2: model.id is "multiple" when more than one model was seen, so it never
stands beside the session-union deepestRecorded as one model's reach;
model.lastSeen carries the last model. checkCertificate enforces it.
F3: checkCertificate checks per-model deepestObserved.
F4/F8: failedCloseCertificate: rung fields read "measurement-failed", not
"unrecorded"; the chain gets an error code and a sha256 of the message,
never the text. checkCertificate refuses it by name.
F6: close-half model ids and harness version capped like the open half.
F7: the line-level logprobs branch is dropped (cannot be told from a
request echo); tested, and the silent-drop test comment corrected.
F9: the test helper no longer passes an unused opts.

Fail-first: 12 new tests failed against the pre-fix module; all pass now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The F1 fix showed the chain canonicaliser drops an own "__proto__" key from
the hash (plain-object assignment sets the prototype), so the value under
it can be edited without breaking verification. Core, so staged, not
applied: proposals/v3-02-chain-proto-key.patch (null-prototype sorted
object plus test/chain-proto-key.test.js). Fail-first run against the
unpatched chain; git apply --check passes. KNOWN-LIMITS number left for the
sitting (75-78 are claimed by open PRs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@githubscum

Copy link
Copy Markdown
Owner Author

Review fixes: second-family review (minimax-m3), V3-02 reach certificate

I checked every finding against src/reach/certificate.js on this branch before fixing it. Commits: 168d9ce (fixes and tests), 5bc7eba (staged core patch). Head is 5bc7eba.

Tests (npm test, run locally on 5bc7eba): tests 1094, pass 1092, fail 1, todo 1. The one failure is src/reach is either core or explicitly grantable, the known classification test that #60 settles. The todo is the session-open hook test, which still waits on the staged patch. Before the fixes the suite was 1083 / 1081 / 1 / 1. That is +12 new tests, less the one failed-measurement test they replace. All 12 failed against the pre-fix module. git apply --check passes for proposals/v3-02-session-open-reach.patch and for the new proposals/v3-02-chain-proto-key.patch.

Fixed

  • F1, prototype pollution: confirmed, and worse than reported. I ran it. A model named __proto__ put R0/R1/R2 on Object.prototype through the certificate, and inputTokens/messages/... through src/parser cost.byModel, the same hole the review pointed at. With constructor, toString or hasOwnProperty, the tallies were written onto the builtin functions. The model was also silently dropped: model.models was [] and byModel had no entry, so the certificate understated what happened. Fix: the tallies are now Maps. The parser looks buckets up in a Map and publishes them as own properties. The certificate's byModel is now a sorted list of { model, deepestRecorded, deepestObserved, rungs }, so the id is a value, never a key. I used a list rather than Object.create(null) because of what the fix turned up in the chain (see "Staged" below). A keyed object would have left a __proto__ entry outside the hash. checkCertificate refuses a keyed byModel. Tests: all four hostile ids each assert the snapshot of Object.prototype, Object and the builtin functions is unchanged, the model is stated, its R2 is attributed and the certificate round-trips through JSON. There is a parser test for cost.byModel, and a chain test showing that an edit under a __proto__ model's entry breaks verification.
  • F2, model.id beside the session-union deepestRecorded: holds. When more than one model was seen, model.id is now "multiple". The new model.lastSeen carries the last model. With exactly one model, the id and the rung both belong to it. checkCertificate rejects a single id when several models are listed, and rejects "multiple" when there are not. The id now comes from the same transcript pass as the rungs, not from summary.session.model.
  • F3, per-model deepestObserved unchecked: holds. It is checked now, with a test using the review's forged R6.
  • F4, failed measurement reads as unrecorded: holds. The new failedCloseCertificate(err) sets status, rungs, deepestRecorded and deepestObserved to "measurement-failed". A reader that skips the checker still cannot read it as "measured, found nothing". checkCertificate refuses it and says why.
  • F6, close half uncapped: holds. model.models, the per-model ids and runtime.harnessVersion now use the same 128-character cap as the open half. The test also bounds the serialized certificate.
  • F7, line-level logprobs: holds. I dropped the branch rather than testing it, because a line-level field cannot be told apart from a request echo and the module must under-claim. A test now pins that a non-empty line-level logprobs is not R4, and the silent-drop test's comment now says what it actually covers.
  • F8, exception text on the chain: fixed. A failure now carries failed: { code, digest }. The code is the error's own code or name if it is a plain identifier, otherwise Error. The digest is a sha256 of the message. The test asserts that the message, a path and a token-like string never reach the serialized certificate.
  • F9, unused opts: fixed.

Not fixed in this PR

  • F5, checkCertificate has no production caller: holds, and the caller belongs in a later work order. A writer-side call in src/ingest would re-check the output with the same code that built it. It would add no independent assurance and would change what lands on the chain. The real caller is whatever relies on the certificate: the meter's reach reader, a receipts view or verifier, or the policy that will read a rung. None of these exists in this repo yet. The PR's own staging already says so: "moves to core the day a policy reads it". In the meantime, F4's fix puts the failure in the rung fields themselves, so it no longer depends on the checker. I corrected the ingest comment, which claimed a guarantee no shipped code applies. The PR body still contains the overstated lines the review cites (PR-BODY:13, :14, :206). This comment supersedes them.

Staged (core, not applied)

The chain canonicaliser drops an own __proto__ key from the hash. sortKeysReplacer rebuilds objects with plain assignment, so sorted['__proto__'] = v sets a prototype and creates no property. The value under that key can be edited and verifyChain still passes. I reproduced it with a probe. Today this affects cost.byModel on any session receipt whose transcript names a model __proto__. The fix is proposals/v3-02-chain-proto-key.patch: a null-prototype sorted, plus test/chain-proto-key.test.js. Its second test pins that every entry without such a key hashes exactly as before. I ran fail-first against the unpatched chain: the tamper test fails and the compatibility test passes. I did not run the green side, because applying the patch to src/chain is the gated act. Before it lands, check the live chain for any existing own __proto__ key: such an entry would stop verifying. The KNOWN-LIMITS number is left for the sitting. 75 to 78 are claimed by #61/#62, #67 and #71, and the numbering test requires a contiguous 1..N. Details are in proposals/v3-02-reach-certificate-2026-10-22.md.

Shape change for readers

reach.byModel changed from an object keyed by model to a list, and reach.model gained lastSeen. reach/1 has not merged, so nothing reads the old shape.

…h-certificate

# Conflicts:
#	src/ingest/index.js
@githubscum
githubscum merged commit d3c7fa6 into main Oct 22, 2026
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>
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