Repository navigation
Use fullmatch for anchored digest, commit and rational patterns - #10
Conversation
The patterns end in $, which also matches before a final newline, so a value with one trailing newline was accepted. Parsed values were still correct. Switch the call sites to fullmatch and add tests that fail if any site goes back to match.
ahrazzle
left a comment
There was a problem hiding this comment.
Content review by grk-proof, posted unchanged by grk-ship.
Proven-Commons/mcproof #10 review
PR: #10
Reviewer: grk-proof (content review; cloud agent bc-a977a2df)
Head’s parent is the base tip. Python 3.12.3. One commit. Draft. [source claim] Fixes #8.
- The bad input passes on the base tip and fails at the head. [verified]
PYTHONPATH pointed at each checkout. Probe calls _parse_exact_rational, audit_transition_certificate, verify_rational_lp_certificate, and build_lineage_manifest.
Base 71d1a58:
rational 3/4\n PASS 3/4
rational -5\n PASS -5
witness + newline passed=True status='VERIFIED' rules=[]
checker_sha256 + \n passed=True status='VERIFIED' rules=[]
checker_auditor_py_sha256 + \n passed=True status='VERIFIED'
LP y = "1/2\n" passed=True status=VERIFIED
build commit+\n PASS stored='81f83c38918382b4ca142b81debd3cc5ccf61d3a\n'
Head 3e634b93:
rational 3/4\n FAIL invalid exact rational token '3/4\n'
rational -5\n FAIL
witness + newline passed=False rules=['CERT_INVALID_WITNESS_SHA256']
checker_sha256 + \n rules=['CERT_TCB_MANIFEST_UNLOCKED']
checker_auditor_py_sha256 + \n rules=['CERT_TCB_MANIFEST_UNLOCKED']
LP y = "1/2\n" passed=False rule=LP_CERT_MALFORMED
build commit+\n StaleLineageError: ... commit is not 40-hex: '81f83c...\n'
Canonical 3/4, -5, and a 64-hex witness with real pins still return VERIFIED and rules=[] on the head. [verified]
- Known-answer tests at the head. [verified]
cd checkout-3e634b93
python3 -m pytest tests/test_regex_fullmatch.py --override-ini='addopts=' -q --tb=short
.....
5 passed in 0.04s
test_canonical_rational_still_parses is the pure positive. The witness test also requires a clean 64-hex certificate to have no findings.
- Planted-bug control. The new tests bite the reverted call sites. They do not bite
_git_head_sha. [verified]
git checkout 71d1a58afc7fb0f77749a3f56ac2609bce3ba814 -- src/mcproof/domain_protocol.py src/mcproof/lineage.py
python3 -m pytest tests/test_regex_fullmatch.py --override-ini='addopts=' -q --tb=line
.FFFF
FAILED test_rational_trailing_newline_rejected DID NOT RAISE ValueError
FAILED test_witness_digest_trailing_newline_rejected expected 'CERT_INVALID_WITNESS_SHA256' in []
FAILED test_tcb_checker_digest_trailing_newline_rejected expected 'CERT_TCB_MANIFEST_UNLOCKED' in []
FAILED test_upstream_commit_trailing_newline_rejected DID NOT RAISE StaleLineageError
4 failed, 1 passed
The one pass is test_canonical_rational_still_parses. Sources restored afterward. git status clean.
Reverting only _git_head_sha from fullmatch to match:
.....
5 passed in 0.05s
The commit message says the tests fail if a call site returns to match. [source claim] That is false for _git_head_sha. [verified] head = proc.stdout.strip() runs first, and match and fullmatch agree on the stripped string. [verified]
- Full suite. [verified]
base 71d1a58: 48 passed, 26 skipped in 3.59s
head 3e634b93: 53 passed, 26 skipped in 3.47s
The five new tests are the difference. Skips are missing mde, pinned deps, Lean 4.35.0, weft, and live llama. Same 26 on both.
PR’s own command, re-run:
python3 -m pytest tests/test_regex_fullmatch.py tests/test_neon_audit_regressions.py tests/test_domain_and_repair_loop.py --override-ini='addopts=' -q
16 passed, 4 skipped in 1.34s
Count matches the PR body. [source claim] The four skips are three mde checkouts and one Lean toolchain (test_neon_audit_regressions.py:110). The body says “missing mde build and pinned deps.” [source claim] The Lean skip is on the base subset too (11 passed, 4 skipped without the new file). [verified]
- Gaps. [verified] unless marked otherwise.
- The three patterns still end in
$:^[0-9a-f]{64}$,^[0-9a-f]{40}$,^-?[0-9]+(?:/[1-9][0-9]*)?$. On the head,SHA256_64_RE.search(hex64+"\n")is still true and.matchis still true..fullmatchis false. Every current caller of those three objects usesfullmatch. [verified] - Uppercase hex, Arabic digits, fullwidth digits,
\r\n,\n\n, a leading newline, and an internal space were already rejected on the base. [verified] verify_lineage_manifestnever appliesCOMMIT_RE. A lineage whoseProven-Commons/missioncommit is the real 40-hex plus\n, withdomain_commits.corpusandcorpus_tree_sha256recomputed to match, and the deps manifest holding the same string, returnspassed=True,findings=[]on the head. No git checkout was present. [verified]instance_sha256andcanonical_instance_sha256are an equality check. Both set tohex64+"\n", andinstance_sha256alone set tohex64+"\n", still returnpassed=True status='VERIFIED'on the head. [verified]domain_protocol.pysandbox key check is stillre.match(r"^[A-Za-z_][A-Za-z0-9_]{0,63}$", key).match("foo\n")is true. [verified] The next line useskey!r. Sandbox execution not run.SHA256_REinlineage.pyis defined and has no caller. [verified]stack/.../runtime.py_COMMIT_TOKEN_REis still$plus.match, so a raw"abc1234\n"matches.parse_llama_server_version_outputsplits lines first. A cleancommit 7fe450e19parses.7fe450e19EXTRAraisesRuntimeError. [verified]- This head still reports
{}aspassed=True status='VERIFIED'andaudit-certexits 0. That is #11’s bug. The branches are siblings. [verified]
[proposed] Put \Z in the three patterns so .match and .search reject the trailing newline too. Run COMMIT_RE.fullmatch in verify_lineage_manifest. Reject an instance_sha256 that is not 64 lowercase hex.
Verdict: APPROVE
Reasons: the targeted trailing-newline inputs pass on the base and are rejected at the head; canonical inputs still verify; the new tests fail when the four tested call sites are reverted; the full suite goes from 48 to 53 passing with the same 26 skips. Not blocking, and best handled as follow-ups: the commit message's claim that the tests catch a revert at every call site does not hold for _git_head_sha, which is safe anyway because it strips first. Pre-existing gaps outside this diff: verify_lineage_manifest never applies COMMIT_RE, and instance_sha256 is only an equality check.
|
Ready to mark ready. grk-proof approved this PR at This branch and the other fix on |
2db0a56
into
feat/formal-verification-loop-v0.2
Fixes #8
Digest, commit and rational checks now use
fullmatch.The patterns already ended in
$.re.matchstill accepted one trailing newline, because$matches before it. A parsed rational was the token before that newline, and a digest of the right length with a newline passed. Canonical values still pass. The tests fail if a call site returns tomatch.Validation
16 passed. 4 skipped for a missing mde build and pinned deps. Those skips are on the base branch as well.