Skip to content

refactor(wcxb): bind the metric module by normalized AST - #133

Merged
lanyue-llk merged 6 commits into
mainfrom
refactor/wcxb-metric-module-binding
Nov 3, 2026
Merged

lanyue-llk merged 6 commits into
mainfrom
refactor/wcxb-metric-module-binding

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #116

Summary

The WCXB metric binding hashed the inspect.getsource() text of word_f1 and snippet_check. Reformatting broke it, and it did not cover the helpers those functions call. This PR changes what is bound:

  • word_f1 and snippet_check move unchanged to src/harness/web_fetch/wcxb_metrics.py. The module may import only the standard library, and an import from anywhere else is rejected, so the binding covers the per-page metric functions and everything they call. The call site and aggregation in wcxb_scoring.py (which arguments are passed, classification, exclusions, averaging) are not bound, the same scope as before this PR and as WCXB metric binding hashes source text instead of behaviour #116 asks.
  • wcxb-metric-bindings.json (schema 2) now binds a digest of the module's AST with docstrings removed. Comments, docstrings, quotes and layout keep the binding. Any code change breaks it, including an added helper, a changed constant or a decorator.
  • The digest uses its own serialization rather than ast.dump, whose output differs between Python versions.
  • wcxb_latency.py now watches the new module and the authority for changes during timing runs, and wcxb_scoring.py reads them through the same guarded evidence reader.
  • The word_f1 and snippet_check names in wcxb_scoring.py must also be the bound module's functions, so rebinding either name is rejected. This catches the scoring module drifting away from the bound functions. It does not prove what _score calls, and wcxb_scoring.py itself is not bound, so it is not tamper protection.

The issue lists adding a decorator as a change that should not break the binding. I kept it as a breaking change on purpose, because a decorator can change scores.

Existing evidence

Certified WCXB profiles, certificates, score summaries and timing receipts may name the old digest 35dc50a1.... They cannot be rewritten, so the authority keeps it in superseded_source_text_digests, mapped to the new module digest 34fd9387....

  • A frozen value verifies only while the mapped code is current. If the metric code changes, the old digest stops verifying.
  • New certificates, summaries and receipts record the new digest.
  • A test keeps the retired source text and proves two things: it hashes to 35dc50a1..., and with the module's imports added it normalizes to the digest now bound.
  • Before committing, I confirmed the moved functions still produce 35dc50a1... under the old inspect.getsource() method.

Not checked against real evidence: this machine has no certified WCXB evidence (no wcxb-score-summary.json under ~/.browser-eval), and no profile in Git names the digest. Frozen verification is covered only by synthetic documents and fixture cohorts carrying the old digest. It is worth running the WCXB report build against the real evidence once.

Golden cases

The golden cases are fixed inputs with exact expected floats, and they replace the two smaller metric tests in test_wcxb_huggingface_inputs.py. I downloaded evaluate.py at the pinned revision, confirmed its SHA-256 matches UPSTREAM_EVALUATOR_SHA256, and ran only its three metric functions (extracted by AST) on all 24 inputs. The results were identical to this module's. Upstream code is not part of the repository or of test runs, so CI checks the fixed values only.

Test plan

  • tests/test_wcxb_metric_binding.py covers:
    • tampered module code, an added helper and an unbound import are rejected, including import x and imports nested in a function
    • a replaced word_f1 or snippet_check name in wcxb_scoring is rejected
    • changing the module or authority during score() is rejected
    • a hand-reformatted module and real ruff format --isolated output keep the binding
    • the golden cases
    • the old digest verifies in a profile, certificate, summary and receipt
    • rescoring a frozen cohort leaves its profile and certificate bytes unchanged
    • an unknown digest is rejected, and the old digest is rejected once the code changes
  • tests/test_wcxb_latency_collection.py covers changing the module or authority during collect and certify, and certify on a receipt naming the superseded digest (passes) and an unknown digest (fails).
  • Each guard was removed in turn, and a test failed for every removal. Details are in the review-round comment.
  • tests/test_golden_reports.py, tests/benchmarks and all tests/test_wcxb_* targets: 11576 passed. Route hashes are unchanged.
  • Lint gate: ruff check --config 'include=["*.py"]' --select F,TID252 . and ruff check both pass.
  • Round 2: tests/test_golden_reports.py and all tests/test_wcxb_* targets: 260 passed, lint gate passes. Reducing the import x guard branch to imported = [] fails the two new import x cases.
  • CI on b57580cb: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" pass. ocr-review reports one blocking finding, disputed in the round 2 comment. I did not run the full suite or tests/package_smoke.py locally.
  • Round 4 (documentation only, the metric module and digest are unchanged): tests/test_golden_reports.py, tests/test_wcxb_metric_binding.py and tests/test_wcxb_latency_collection.py: 95 passed, lint gate passes.

Move word_f1 and snippet_check into wcxb_metrics.py and bind a digest of that module's AST without docstrings instead of inspect.getsource() text. Formatting and comments no longer break the binding, and any code change in the module does, including added helpers. The module may import only the standard library.

The authority maps the retired source-text digest to the module digest it represents, so frozen profiles, certificates, summaries and timing receipts keep verifying without being rewritten.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · 8c630d7

No findings in this review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review, round 1

Reviewed head 8c630d70. Two findings, one P1 and one P2.

Findings

P1: the binding no longer proves that scoring runs the bound code

src/harness/web_fetch/wcxb_scoring.py:61 (import at :26, calls at :499-501)

Problem: metric_implementation_binding now hashes wcxb_metrics.py from disk, but _score calls the names word_f1 and snippet_check in wcxb_scoring's own namespace. Nothing connects the two. On the base commit, inspect.getsource followed those same names, so a replaced function was rejected.

I replaced both names on the imported module with functions that return zero, then ran score() on the fixture cohort. It was accepted, reported digest 34fd9387 and produced alpha f1 = 0.0, where the unmodified cohort gives f1 == 1.

The source-level equivalent is a local def word_f1 or a wrapper added to wcxb_scoring.py, or an import changed to point elsewhere. Any of these changes scores without changing the digest. That is the failure #116 sets out to remove, and it contradicts the PR's "nothing that can affect a score sits outside the binding".

The PR also deleted the two negative controls that covered this: test_changed_word_metric_rejects_legacy_profile and test_changed_snippet_metric_rejects_legacy_profile.

Fix: have the binding also require that the functions in use come from the bound module, for example:

if word_f1 is not wcxb_metrics.word_f1 or snippet_check is not wcxb_metrics.snippet_check:
    raise ValueError('WCXB metric implementation binding mismatch')

Restore both deleted controls. The fault-injection tests at tests/test_wcxb_scoring.py:248 and :311 already stub the binding, so they keep working.

P2: the new evidence guards have no failing test

src/harness/web_fetch/wcxb_scoring.py:359, src/harness/web_fetch/wcxb_latency.py:146, :270, :286

Problem: the PR describes these as behaviour changes, but none of them is exercised. I applied each mutation below on its own and ran test_wcxb_metric_binding, test_wcxb_latency_collection, test_wcxb_scoring and test_wcxb_profile_admission. All 125 tests passed each time:

Mutation Lost behaviour
Drop read=inputs.read in _score Changes to the module or authority during scoring go undetected
Remove wcxb_metrics.py from the collect watch list Module changes during a timing run go undetected
Remove wcxb_metrics.py from the certify watch list Module changes during timing certification go undetected
Delete metric_implementation_binding(authority, receipt=receipt) in certify certify accepts a receipt with an unknown digest

The receipt= branch is tested only by calling the binding function directly, so the PR's "verifies in a ... receipt" holds at function level but not through certify.

Fix: add behaviour tests through the public entry points:

  • Change the metric module or the authority during score() and expect "changed during scoring". Inject the change from a hook other than word_f1 so it still works after the P1 fix.
  • Change the module during collect and during certify, and expect rejection.
  • Run certify on one receipt naming the superseded digest, which must pass, and one naming an unknown digest, which must fail.

Using METRIC_MODULE in wcxb_latency.py instead of a second Path(__file__).with_name(...) would make the first two watch-list tests easier to write.

Verified, no defect

  • Golden values: I downloaded evaluate.py at the pinned revision and its SHA-256 matches UPSTREAM_EVALUATOR_SHA256. Upstream tokenize, word_f1 and snippet_check match all 24 golden cases exactly and match wcxb_metrics.py on 200,000 random inputs for each metric. They also agree on None inputs to word_f1.
  • Moved code: re-deriving the old inspect.getsource text from the base commit gives 35dc50a1.... The test's retired text with the imports added normalizes to 34fd9387....
  • Digest stability: 34fd9387... is the same on Python 3.11.16 and 3.13.16. I read _normal_form and found no field collisions, and dropped type_params, kind and type_comment do not affect the digest. Python 3.12 and 3.14 were not available to run.
  • Metric hash consumers: every use goes through metric_implementation_binding (certification.py, report_build.py, wcxb_latency.py, wcxb_scoring.py), so none compares the old digest directly. Mixed documents, with an old-digest profile or certificate and a new-digest summary, pass the same check.
  • scorer_sha256: it changes because wcxb_scoring.py changed, but it is only recorded in new summaries and nothing verifies it, so frozen summaries are unaffected.
  • Other evidence: no hash-bound evidence, profile or receipt is modified in this diff. A search of .json files under the local ~/.browser-eval/evidence found no file naming the digest, which matches the PR's disclosure. Real certified evidence remains unchecked.
  • Scope: the code changes cover the module move, the AST binding and the golden cases. The decorator deviation from the issue text is disclosed and defensible. Closes #116 is appropriate once the P1 is fixed.

Tests and CI

  • Local: both lint gate commands pass. tests/test_golden_reports.py, test_wcxb_metric_binding, test_wcxb_scoring, test_wcxb_profile_admission, test_wcxb_latency_collection and test_wcxb_huggingface_inputs gave 142 passed. No route hashes changed. test_ruff_format_keeps_the_binding ran rather than being skipped.
  • CI at this head: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks", "Python 3.11" and ocr-review all pass. No failure is caused by this PR. CI does not cover either finding.

The digest covers the module bytes, but scoring calls names in its own namespace, so a local definition, wrapper or redirected import changed scores without changing the digest. Reject any name that is not the bound module's function, and restore the two negative controls that covered this.
Changing the metric module or authority during score, collect or certify must be rejected, and certify must accept a receipt naming the superseded digest but not an unknown one. Certify now also watches the authority, and the latency watch lists use the scoring module's paths so they follow the same binding.
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1 fixes, new head 1799b846. Both findings are fixed; none are disputed.

P1, scoring names not tied to the bound module: fixed in 05406ca8

  • metric_implementation_binding now raises the binding mismatch error unless word_f1 is wcxb_metrics.word_f1 and snippet_check is wcxb_metrics.snippet_check.
  • test_changed_word_metric_rejects_legacy_profile and test_changed_snippet_metric_rejects_legacy_profile are restored.
  • Limit: the check compares the names in wcxb_scoring with the loaded module's attributes. It does not catch an in-process replacement of wcxb_metrics.word_f1 itself together with the scoring name.

P2, evidence guards had no failing test: fixed in 1799b846

  • score(): changing the module or the authority during scoring is rejected with "changed during scoring".
  • collect: changing either file during calls issues no receipt.
  • certify: changing either file is rejected with "changed during certification".
  • certify receipts: one naming the superseded digest passes and returns the current digest; one naming an unknown digest fails and writes no certificate.
  • The mutations use a trailing newline, which leaves the digest unchanged, so only the byte guards can catch them.
  • wcxb_latency.py now uses METRIC_MODULE and METRIC_BINDINGS from the scoring module.

One addition beyond the finding: certify did not watch the authority file, so it now does.

Mutation check

Each mutation below was applied alone, then the four target files were run (test_wcxb_metric_binding, test_wcxb_latency_collection, test_wcxb_scoring, test_wcxb_profile_admission). Each one failed the tests listed.

Mutation Failing test
Drop read=inputs.read in _score test_metric_inputs_changed_during_scoring_reject_all_outputs (module, authority)
Remove the module from the collect watch list test_mid_call_metric_change_cannot_issue_receipt[module]
Remove the authority from the collect watch list test_mid_call_metric_change_cannot_issue_receipt[authority]
Remove the module from the certify watch list test_certification_rejects_metric_change_during_source_recheck[module]
Remove the authority from the certify watch list test_certification_rejects_metric_change_during_source_recheck[authority]
Delete the receipt= binding check in certify test_certification_rejects_a_receipt_naming_an_unknown_digest
Delete the identity check Both restored negative controls

Local test results

  • tests/test_golden_reports.py, tests/test_wcxb_*.py and tests/benchmarks: 11576 passed. Route hashes are unchanged.
  • Lint gate: passes.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Re-review complete · 1799b84

No findings in this incremental review.

@lanyue-llk lanyue-llk left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review, round 2

Reviewed head 1799b846. Two P3 findings and no defect in scoring or evidence verification. Both round 1 fixes hold.

Findings

P3: the module docstring and PR body overstate what the binding covers

src/harness/web_fetch/wcxb_metrics.py:9, and the Summary bullet "nothing that can affect a score sits outside the binding"

Problem: the docstring says "Everything that can change a WCXB score belongs here" and that the binding "covers the whole metric". The call arguments, classify, the exclusions and the aggregation are all in wcxb_scoring._score, outside the digest. I changed snippet_check(predicted, gt["with"]) to pass gt["without"] at wcxb_scoring.py:505. score() accepted it with digest 34fd9387, and with_rate for alpha, beta and gamma went from 1.0, 0.5, 1.0 to 0.0, 0.0, 0.0. scorer_sha256 records that file, but nothing verifies it. This scope matches the base commit and #116, so it is not a regression. Only the claim is wrong, and a later reader may rely on it.

Fix: say what is actually bound, for example "The per-page metric functions and everything they call belong here... The call site and aggregation in wcxb_scoring.py are not part of this binding." Correct the PR body line the same way.

P3: the import x branch of the import guard has no failing test

src/harness/web_fetch/wcxb_scoring.py:53, tests/test_wcxb_metric_binding.py:90

Problem: the guard behaves correctly. import harness.web_fetch.safety, import numpy as np and a nested import harness inside a function are all rejected. The test covers only from harness.web_fetch import safety and from . import safety. With the ast.Import branch reduced to imported = [], all 135 tests in test_wcxb_metric_binding, test_wcxb_latency_collection, test_wcxb_scoring and test_wcxb_profile_admission still pass. The digest would still catch the edit, so only the guard's protection during a deliberate authority revision is unproven.

Fix: add import harness.web_fetch.safety\n and a nested import to the rejected inputs in that test.

What I verified

Metric code

  • word_f1 and snippet_check in wcxb_metrics.py are byte-identical to the base commit's function source. Joining the base source the way inspect.getsource did reproduces 35dc50a1....
  • I downloaded evaluate.py at the pinned revision and its SHA-256 matches UPSTREAM_EVALUATOR_SHA256. Its tokenize, word_f1 and snippet_check, extracted by AST, return the exact expected value for all 24 golden cases.
  • They also matched this module on 200,000 random inputs covering Unicode, underscores, case folding and empty strings.

Digest

  • metric_module_digest gives 34fd9387... on Python 3.11.16 and 3.13.16. requires-python is >=3.11.
  • It keeps the digest for the u string prefix. It separates return from return None, a[1:] from a[:1], 1 from 1.0 from True, moved defaults, and a docstring-only body from pass.
  • A second string statement is not treated as a docstring.

Frozen evidence

  • Every consumer of the digest goes through binds_current: score(), certify, collect, certification.py and report_build.py. None of them compares a frozen value directly.
  • No hash in Git covers wcxb_scoring.py or the card, and nothing verifies scorer_sha256. Editing the scoring file therefore invalidates nothing.
  • ~/.browser-eval holds no WCXB evidence and Git holds no WCXB publication target, so I could not check real evidence either. The PR's disclosure is accurate, and its suggested report build against the real evidence is still worth doing once.

Round 1 fixes

  • The identity check and both restored controls are in place.
  • The behaviour tests for score(), collect and certify exist. I did not repeat the author's mutation table.
  • The disclosed limit is real: replacing wcxb_metrics.word_f1 itself together with the scoring name is not caught. I am not raising it, because that takes deliberate in-process replacement.

Scope and rules

  • "Closes #116" holds. Treating a decorator as a breaking change departs from the issue, but the PR explains it and the reason is sound, since a decorator can change scores.
  • I found no compatibility alias or parallel implementation, and no evidence or frozen profile is touched. The retired source text in the test is justified by the authority naming its digest.

Tests and CI

  • Both lint gates pass.
  • test_wcxb_metric_binding, test_wcxb_latency_collection, test_wcxb_scoring, test_wcxb_profile_admission, test_wcxb_huggingface_inputs and test_golden_reports give 152 passed with no skips, so the ruff format test ran. Route hashes are unchanged. I did not run the full suite locally.
  • CI on 1799b846: all checks pass, including "Tests and static checks" and "Installation and packaging". The PR is mergeable and its base is the current main (27401304).

@lexmount-ocr lexmount-ocr Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Review complete · b57580c

This review found 1 issue(s), including 1 blocking issue(s).

Comment on lines +73 to +74
if word_f1 is not wcxb_metrics.word_f1 or snippet_check is not wcxb_metrics.snippet_check:
raise ValueError('WCXB metric implementation binding mismatch')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
P2 — This checks that two mutable references agree, not that either executes the module source being hashed. For example, adding wcxb_metrics.word_f1 = word_f1 = lambda predicted, reference: (0., 0., 0.) in the unbound scoring module after its imports passes this check and the unchanged module digest, while score() publishes zero word scores under the approved implementation hash. Mutating the shared function's __code__ also preserves this identity check. The current replacement tests only patch the scoring alias, so they miss this bypass of the stated call-site binding requirement. Tie the functions actually used for scoring to the validated module bytes (rather than trusting mutable module attributes), and add a negative control that replaces both references before scoring.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 2, head b57580cb.

Fixed

  • P3, overstated binding scope: 9ea60daf. The wcxb_metrics.py docstring now says the per-page metric functions and everything they call are bound, and that wcxb_scoring.py is not (arguments, classification, exclusions, aggregation). The PR body is corrected the same way. The change is a docstring only, so the digest stays 34fd9387....
  • P3, untested import x guard branch: b57580cb. The rejected inputs now include import harness.web_fetch.safety and nested import and from statements inside a function. Reducing that branch to imported = [] now fails the two import x cases; before, all tests still passed.

Disputed: ocr-review P2 on b57580cb (replace both wcxb_metrics.word_f1 and the wcxb_scoring alias)

The finding is factually correct. I replaced both references with a zero function, and score() published f1 = 0.0 under digest 34fd9387.

I am not changing the code, because the same result needs no reference replacement at all. Adding f1 = 0.0 after the call at wcxb_scoring.py:504 also published f1 = 0.0 under 34fd9387. The round 2 reviewer showed the same with gt["without"] at line 505. wcxb_scoring.py is outside the binding, as the base commit and #116 scope it and as the docstring now states, so tying the function objects to the module bytes would close one route and leave this one open.

Binding the call site and aggregation would be a real scope extension and an owner decision. It would change what certified evidence is bound to, so it should have its own issue rather than go in this PR.

The PR body claimed more than the identity check does, so it now says the check catches drift and is not tamper protection.

The ocr-review check still shows failed because of this finding. I have not dismissed it, so it needs an owner decision.

Checks

  • Local: tests/test_golden_reports.py and tests/test_wcxb_*, 260 passed, route hashes unchanged. Lint gate passes.
  • CI on b57580cb: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" pass.

lanyue-llk added a commit that referenced this pull request Nov 2, 2026

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review, round 3

Reviewed head b57580cb. One P3 finding, in documentation. I found no defect in scoring, the digest or evidence verification.

Finding

P3: the README and binding docstring still say a local definition or wrapper in wcxb_scoring.py is rejected

src/harness/web_fetch/README.md:145-146, src/harness/web_fetch/wcxb_scoring.py:65-66, and the same Summary bullet in the PR body

Problem: the check only compares the names word_f1 and snippet_check with the module's attributes. It does not look at what _score calls. I added def _local(predicted, reference): return 0., 0., 0. to wcxb_scoring.py and changed line 504 to call it. score() accepted this with digest 34fd9387 and published alpha f1 = 0.0. So a local definition or wrapper under another name is not rejected, and the sentence "The binding also requires wcxb_scoring.py to call this module's functions" is not true as written.

Round 2 corrected the PR body with a "not tamper protection" caveat and corrected the wcxb_metrics.py docstring. The README has no caveat, and it is the text that will outlast this PR. The binding docstring also says "The digest covers the module bytes", but the digest covers the AST without docstrings, and comments and layout are excluded.

Fix: describe the check as it is, in both places. For example: "The binding also requires the word_f1 and snippet_check names in wcxb_scoring.py to be this module's functions, so rebinding either name there is rejected. This catches drift. It does not prove what _score calls, and wcxb_scoring.py itself is not bound." Change "module bytes" to "module's code". Reword the PR body's "so a local definition, wrapper or redirected import there is rejected" the same way. No code change is needed, and the digest does not change if only the wcxb_scoring.py docstring and the README are edited.

Disputes from round 2

I accept the author's dispute of the ocr-review P2. I reproduced the same result without replacing any reference, as shown above. wcxb_scoring.py is outside the binding in both the base commit and #116, so hardening the function objects would close one route and leave the others open. Binding the call site is a separate owner decision. I am not raising it as a finding.

CI on b57580cb

  • Pass: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks", "Python 3.11", "OCR dispatch", "Select check scope".
  • Fail: the ocr-review commit status, because of the disputed finding above. It is not caused by a test or build failure. I found no required status checks on main (the branch rules query returned none, and classic protection returned 404), but someone with admin access should confirm that. An owner still has to decide what to do about this status.

What I verified

  • Moved code: the source of word_f1 and snippet_check is byte-identical between base 27401304 and wcxb_metrics.py, and the old inspect.getsource() method still gives 35dc50a1... on the moved functions.
  • Upstream parity: I downloaded evaluate.py at the pinned revision and its SHA-256 equals UPSTREAM_EVALUATOR_SHA256. I extracted its tokenize, word_f1 and snippet_check by AST. All 24 golden cases match exactly, and 200,000 randomized word and snippet comparisons (mixed Unicode, including casefold edge characters) showed no difference.
  • Digest: metric_module_digest gives 34fd9387... on both Python 3.11 and 3.13. I read _normal_form for collisions and found none: None constants, return versus return None, 1 versus 1.0 and True all stay distinct. Removing docstrings during ast.walk is safe because children are queued before each node is yielded.
  • Evidence consumers: every reader of metric_implementation_sha256 goes through metric_implementation_binding (certification.py, wcxb_latency.py, report_build.py, wcxb_scoring.py). None compares the digest directly, and no file in evaluation/ names it. As the PR body says, real certified evidence was not available, so this is covered only by synthetic documents and fixture cohorts.
  • Issue scope: Closes #116 is supported. The module move, AST binding and golden cases are all present, and the one deliberate difference (a decorator breaks the binding) is stated in the PR body.
  • Local checks: the lint gate passes, and tests/test_golden_reports.py, tests/test_wcxb_*.py and tests/benchmarks give 11580 passed with route hashes unchanged. test_ruff_format_keeps_the_binding runs rather than skips. I did not run the full suite locally.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 3 follow-up, head 47ef8c60046e208ee3d9ae5e57971601e463970d.

Fixed

  • P3, overstated description of the name check (47ef8c60): the README and the metric_implementation_binding docstring no longer say that scoring must call the module's functions or that a local definition or wrapper is rejected. They now say the word_f1 and snippet_check names in wcxb_scoring.py must be this module's functions, so rebinding either name is rejected. This catches drift. It does not prove what _score calls, and wcxb_scoring.py itself is not bound. "Module bytes" is now "the module's code". The PR body bullet is reworded the same way.

The change is documentation only. wcxb_metrics.py is untouched, so the digest stays 34fd9387....

Disputed

None in this round.

Checks

tests/test_golden_reports.py, tests/test_wcxb_metric_binding.py and tests/test_wcxb_latency_collection.py: 95 passed. Lint gate passes. CI on this head is still running.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · 47ef8c6

No findings in this review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review, round 4

Head reviewed: 47ef8c60. No defects found.

What I verified

  • Round 3 fix: the README and the metric_implementation_binding docstring now describe the name check as it is. The commit changes only documentation, and the digest is still 34fd9387....
  • Upstream match: I downloaded evaluate.py at the pinned revision, and its SHA-256 matches UPSTREAM_EVALUATOR_SHA256. I extracted tokenize, word_f1 and snippet_check by AST and ran them on all 24 golden cases, and they gave exactly the expected floats. They also matched wcxb_metrics.py on 200,000 random Unicode-heavy inputs (case folding, combining marks, underscores) and on None inputs, under Python 3.11 and 3.13.
  • Digest stability: metric_module_digest returns 34fd9387... under Python 3.11.16 and 3.13.16, so the 3.12+ type_params AST field does not change it. I read _normal_form for collisions from the dropped None and empty-list fields and found none that could change behaviour.
  • Frozen evidence: the only comparisons against stored digests go through binds_current, in score(), certify and the WCXB report build. Other callers only record the current digest or compare it with itself. No profile or evidence file in Git names 35dc50a1...; it appears only in the authority and in tests. scorer_sha256 is recorded but not compared with the current source, so changing wcxb_scoring.py does not invalidate it.
  • Scope: the Closes #116 claim holds. The metric moved to its own module, the binding uses a normalized AST and the golden cases are in place. The one departure, adding a decorator still breaks the binding, is disclosed in the PR body and is reasonable because a decorator can change scores.
  • AGENTS.md: I found no aliases or parallel implementation. wcxb_scoring imports the two names because _score calls them. Stale references were updated in THIRD_PARTY.md, docs/architecture.md and the dataset card. No measured evidence was changed.
  • Local checks: tests/test_golden_reports.py and all tests/test_wcxb_* targets gave 260 passed, and the lint gate passes. Golden snapshots are not modified by this PR.
  • CI on this head: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" all pass. ocr-review passes with 0 findings.

Not verified

This machine has no certified WCXB evidence (no wcxb-score-summary.json under ~/.browser-eval), so frozen verification was only exercised with synthetic documents and fixture cohorts. The PR body already says this. A WCXB report build against the real evidence is still worth running once.

I did not repeat the guard-removal mutations from rounds 1 and 2, because no code has changed since them.

lanyue-llk added a commit that referenced this pull request Nov 2, 2026
@lanyue-llk
lanyue-llk merged commit 3d6aaef into main Nov 3, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/wcxb-metric-module-binding branch November 3, 2026 04:26
lanyue-llk added a commit that referenced this pull request Nov 3, 2026
Main moved the other regex uses out of wcxb_scoring in #133, and the shared WCXB_ERROR policy replaced the last one.
lanyue-llk added a commit that referenced this pull request Nov 3, 2026
…#136)

* refactor(helpers): share data-home, dotenv parsing and path redaction

Replace the private copies with harness.data_home, harness.env_file and the policy table in harness.reporting.privacy. Resolve the data home at call time, parse every .env with python-dotenv without interpolation, and keep each surface's redaction output unchanged.

* fix(web-fetch): read the WCXB visual check binary through the shared parser

* fix(env-file): drop values that span lines instead of delivering them

* fix(web-fetch): judge imported credentials by the shared parser

* test(env-file): reject line-split, startswith and regex .env parsers

* test(data-home): pin the retained entry point defaults to the selected home

* fix(env-file): stop a rejected statement from reviving an earlier value

* test(data-home): catch getenv and tilde-path copies in the grep guard

* test(privacy): recognise home, tmp and root copies in the grep guard

* fix(wcxb): drop the re import left unused after the rebase

Main moved the other regex uses out of wcxb_scoring in #133, and the shared WCXB_ERROR policy replaced the last one.
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.

WCXB metric binding hashes source text instead of behaviour

1 participant