Repository navigation
Description
Bug Description
simple/proof.py (build_membership_proof) reports membership_status: "excluded" and segments: [] for an article as soon as any chain entry has a control.exclude.wikipedia range that covers it. It does not check when the exclusion took effect.
The rest of the project treats that as invalid:
cmd_forkexits withpage N was already trained before boundary Kfor a document the run had already reached.verify_segmentrequires every excluded range of a fork entry to start at or after the cursor of the entry before it (all(s >= chain[k]["control"]["cursor"] for s, _ in excluded(...))) and reportsMISMATCHotherwise.
proof.py does not verify segments, so on a chain that breaks this rule it claims the run never saw an article that an earlier segment trained on, and it leaves that segment out of the proof.
How to reproduce
import sys; sys.path.insert(0, "simple")
import proof
doc = {"identity": ["a" * 64, "12", "1"], "offset": 0, "target_start": 0, "targets": 9037, "tokens": 9037}
wiki = lambda cursor, **kw: {"phase": "wikipedia", "cursor": cursor, "epoch": 0, "global_step": 0, "phase_step": 0, "pos": [0, 0], **kw}
honest = [
{"index": 0, "kind": "initial", "control": wiki(0), "state": "s0"},
{"index": 1, "kind": "progress", "control": wiki(20000), "state": "s1"}, # trained on article 12
]
late_fork = honest + [{"index": 2, "kind": "fork", "control": wiki(20000, exclude={"wikipedia": [[0, 9037]]}), "state": "s1"}]
for chain in (honest, late_fork):
p = proof.build_membership_proof(doc, chain, True, "h")
print(p["membership_status"], p["segments"])Output on main (1c63518):
trained [0]
excluded []
Expected Behavior
The second chain should not produce an exclusion proof. The fork entry excludes targets 0..9037 although its cursor is already 20000, which verify rejects.
Scope
fork cannot produce this chain, so it needs a hand-edited or malformed chain.jsonl. I am not claiming an honest run is affected. The point is that proof.py prints a stronger statement than verify would accept, and CONTRIBUTING rule 3 asks verification code to fail closed.
The two fork fixtures in tests/simple/test_proof.py also use a fork cursor of 274561003 for an excluded range that starts at 274560000, a state fork cannot produce, so they hide the gap.
Proposed fix
In build_membership_proof, when the entry that first adds a range covering the article has ex_start < cursor, exit with an error that names the entry, using the same rule as verify_segment. About 15 lines plus tests: the late-exclusion case is rejected, an exclusion starting exactly at the fork cursor is still accepted, and the two fixtures get their cursor moved to the start of the range. I chose an error over falling back to trained; tell me if you prefer the other.
I have the fix and tests ready locally (the full suite passes, ruff check is clean). There is no open PR that touches simple/proof.py (it came in with #298). Could you assign this issue to me? I will open the PR once it is assigned, as the contribution rules ask.
AI usage: an AI tool helped me read the code and write the fix and its tests. I reviewed it, ran the tests, and can explain every line.
Activity
rushil23shah-hue commentedon Nov 26, 2026
Hi @AnKiT-GaRG2, thanks for the sharp catch and clean reproduction script!
As the author of #298, I completely agree with your analysis:
ex_start < cursor), raising an explicit error is definitely the right choice over falling back to"trained". In a verifiable system, a malformed retroactive exclusion should be rejected outright rather than masked.test_proof.pyfixtures to274560000(matching the start of the excluded document) is the right fix to mirror honest fork creation.Maintainers don't always manually assign issues, but since you already have the fix, regression tests, and linter passing locally, please feel free to open your PR! I’d be glad to review it once it’s up.