Skip to content

CORE (signing sitting): tripwire for the line-ending-dependent matcher stamp - #68

Merged
githubscum merged 2 commits into
mainfrom
lotor-lane/matcher-stamp-eol-tripwire
Oct 22, 2026
Merged

githubscum merged 2 commits into
mainfrom
lotor-lane/matcher-stamp-eol-tripwire

Conversation

@githubscum

Copy link
Copy Markdown
Owner

WO

WO-EOL-TRIPWIRE-01 (lotor lane run 40). Addresses the line-ending limit found in run 39 and recorded in #67 (numbered 75 there; 75 is also claimed by #61 and #62, so the number settles at merge). This PR adds no KNOWN-LIMITS text of its own, because the entry lives in #67.

What it is

A tripwire, not the fix. One new file: test/policy-matcher-stamp-eol.test.js. It asserts the current defect and fails when the fix lands, the same pattern as the KNOWN-LIMITS 63 stamp-coverage tripwire.

The defect: matcherVersionHash() is sha256 of matcherHashInputs(), which joins Function.prototype.toString() source text exactly as checked out. A core.autocrlf=true clone stamps different bytes than an LF clone of the same commit. Every receipt from a Windows autocrlf machine carries a matcherHash that no LF clone or CI run can reproduce, so comparing stamps across machines silently tells you nothing.

Why CORE

The fix is in the policy module, which is non-delegable core. An executor edit there is gated, so following #48 and #49 this lane ships the tripwire plus the exact recipe and queues the change for the signing sitting.

The fix recipe (for the sitting)

In matcherHashInputs(), before caching:

cachedMatcherInputs = parts.join(' ').replace(/\r\n/g, '\n');

Then bump MATCHER_SCHEMA to matcher/3, update the two matcher/2 assertions (policy-matcher-stamp-coverage, stamp-reach-coverage), invert this tripwire, and amend the limit.

The correction to run 39's note: this does not move every stamp. LF clones already hash LF, so their stamp is byte-identical before and after (e0877fab0f459e0c at 5198a07). Only CRLF-clone stamps move, onto the canonical LF value. The schema bump is still right, because it is how a reader tells a matcher/2 CRLF stamp (not comparable across machines) from a matcher/3 one.

The existing "stamp IS the digest of the exported inputs" control still holds after the fix, because normalization happens inside the exported function.

Tested

  • npm test: 1060/1060 (+4) on this autocrlf checkout. Test 4 took its assert path rather than skipping, so the defect is confirmed live here.
  • A fresh core.autocrlf=false clone of 5198a07 with the test copied in: 3 pass, 1 skip (the CRLF-only test). That clone stamps e0877fab0f459e0c, which matches run 39's measurement.
  • Executor: glm-5.3-flash, session b2f783ef, chain seq 36526. It touched only this file. Its sandbox could not run node, so the orchestrator ran every test.

Eval

None of E1-E6 applies; this is stamp integrity (trust), not v3 granularity.

What a reviewer should doubt

  1. Test 3 is structural: it fails if matcherHashInputs's source contains a backslash-r anywhere. A fix that normalizes some other way (say split(/\r?\n/)) would also contain one, which is intended. A fix written outside that function would not trip it, but tests 2 and 4 would catch that on a CRLF machine.
  2. On LF CI this file proves less. Tests 1-3 pass there, and test 3 is the only one that detects the fix. The behavioural proof needs a CRLF checkout, and CI does not have one.
  3. Lone \r (classic Mac) is not handled by the recipe. Git autocrlf never produces it, so I judged it out of scope.
  4. Should the fix go further and normalize at checkout via .gitattributes (* text=auto eol=lf)? That would fix every clone's bytes, but it changes repo config and does nothing for a stamp computed from an already-CRLF working tree. I recommend the in-hash normalization; the call is yours.

🤖 Generated with Claude Code

githubscum and others added 2 commits October 20, 2026 12:36
matcherVersionHash() digests Function.toString() text exactly as checked
out, so an autocrlf clone stamps c4165ee9ff7612bd at 5198a07 while an LF
clone of the same commit stamps e0877fab0f459e0c. This test asserts the
current defective behaviour and fails when the core fix lands; the fix
recipe is in the header and the PR body, queued for a signing sitting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… says how to turn each test around

- Test 2 compared digests of two strings the test built itself, so it
  held before and after any fix. It now copies the policy module out
  twice (LF and CRLF) into temp ESM packages, imports each, and asserts
  the module's own matcherVersionHash() differs between them, after a
  control that the copy reproduces this checkout's live stamp. Checked
  in throwaway clones: passes on an LF checkout and a CRLF checkout, and
  fails on both once the PR's fix recipe is applied.
- Header: "invert the assertions" would have made test 2 fail forever
  and test 4 skip forever. It now says what to do per test after the
  fix: keep 1, flip 2 to equal, invert or delete 3 depending on how the
  fix is written, rewrite 4 to assert the live stamp equals the LF copy
  with no skip.

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

Copy link
Copy Markdown
Owner Author

Review fixes pushed in 9ea3718. Both findings re-checked against the code first; both held.

Fixed

  1. Test 2 could not fail. It compared sha16(lf) and sha16(crlf) of two strings the test built itself, and matcherVersionHash() === sha16(matcherHashInputs()) still holds after a fix that normalizes inside that function. So it was true before and after any fix. It now copies the policy module out twice (every .js in src/policy, working tree as it stands), once LF and once CRLF, into temp dirs marked {"type":"module"}. It imports each copy and asserts the module's own matcherVersionHash() differs between them. That is the same technique as matcherHashAt in limit 53: a matcherHash resolves to its commit; found limit 77 (stamp is line-ending-sensitive) #67. A control first checks that the copy matching this checkout reproduces the live stamp, so the copies are faithful stand-ins.
  2. "Invert the assertions" would not work. Inverting the old test 2 gave a test that fails forever. Inverting test 4 gives one that skips forever: once matcherHashInputs() normalizes, its output never contains \r, so the CRLF branch is never taken. The header now says what to do with each test after the fix: keep 1; flip 2 to equal (that is the regression guard); invert 3 only if the fix is a \r pattern inside matcherHashInputs(), otherwise delete it; rewrite 4 to assert, with no skip, that matcherVersionHash() equals the LF copy's stamp.

Checked in throwaway clones of this branch (not pushed):

checkout as pushed with the PR's fix recipe applied recipe + header's turnaround
core.autocrlf=false (LF) 3 pass, 1 skip test 2 and test 3 fail 4 pass, 0 skip
core.autocrlf=true (CRLF) 4 pass test 2 and test 3 fail; test 4 now skips 4 pass, 0 skip

npm test on this branch (CRLF checkout): 1060 pass, 0 fail, 0 skipped.

One line of the PR body is now stale. Doubt 2 says that on LF CI "test 3 is the only one that detects the fix". Test 2 now detects it on LF too, behaviourally, without depending on how the fix is spelled. The body's recipe line "invert this tripwire" should be read as "turn it around per the header".

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>
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,
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
githubscum merged commit 6ed6e6e 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