Skip to content

Add fail-closed gameplay evidence validator - #17

Open
ahrazzle wants to merge 2 commits into
feat/formal-verification-loop-v0.2from
feat/gameplay-evidence-exchange
Open

ahrazzle wants to merge 2 commits into
feat/formal-verification-loop-v0.2from
feat/gameplay-evidence-exchange

Conversation

@ahrazzle

Copy link
Copy Markdown
Member

Summary

  • Implement the gameplay-evidence/v0.1 schema and fail-closed validator.
  • Verify canonical JSON, action and trajectory commitments, negative controls, and producer/consumer provenance.
  • Separate producer assertions from independently admitted consumer badges.
  • Add mutation coverage for tampered payloads, actions, trajectories, checks, labels, and commitments.

Evidence boundary

Structural validation is not live execution or model proof. Independent structural admission is limited to OBSERVED; producer REPLAYED assertions are retained only as source evidence. A replay or fixture never promotes an artifact to LIVE_CONFIRMED.

The cross-repository acceptance fixtures and exact digests are recorded in the accompanying implementation commit and documentation. RMMZ fixture artifact SHA-256: c852b43bfa6c1279148625434af5119a4aa5767418e6e742ee97b645bf5a5f1d. Soko Heroes rr artifact SHA-256: 0a310102c655880e587ff3502600daedcd868a4a93578061891ee28eef78585b.

Verification

At commit ee2c2439160d5cee50098a397f7a11ca4f06aea9:

python -m pytest tests/test_gameplay_evidence.py -q

The evidence test suite passed. Cross-consumer checks accepted both pinned fixtures with admitted_badges limited to OBSERVED; resealed trajectory tampering failed closed through payload-commitment mismatches.

@zero-aska
zero-aska changed the base branch from main to feat/formal-verification-loop-v0.2 November 22, 2026 17:14

@abu-aska abu-aska 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.

The isolated gameplay-evidence commit ee2c2439 (4 files, +1,163/-0) is clean, zero-dependency, and passes 32/32 OK in tests/test_gameplay_evidence.py across -I -B, -I -O -B, and -I -B -W error (with zero bare asserts; rejects float 1.0/-0.0, NaN/Inf, duplicate JSON keys, int64 overflow, passed=1, cyclic objects, and enforces the mixed PASS+FAIL veto).

However, four concrete blocking issues (branch stacking, failing CI, recursion DoS, and surrogate/cross-repo parity bugs) should be resolved before merge:

  1. Branch stacked on an older commit of PR #16 (463 files +137,882/-5 / 48 commits vs. main @ 575286f0):
    • ee2c2439's parent is d8e92d84201a (one commit behind open PR #16 @ 8695c9e9, which itself builds on #6/#7/#15), pulling 459 unrelated files (47 commits, including +110 lines in .github/workflows/ci.yml) into PR #17.
    • Please rebase/cherry-pick ee2c2439 cleanly onto main (or hold until #6/#16 land) so the PR diff contains only the 4 gameplay-evidence files.
  2. Failing CI (standalone (ubuntu-24.04) & standalone (windows-2022) in run 45046280747):
    • Both runners fail python -m mcproof.prose_gate with 3 findings on docs/GAMEPLAY_EVIDENCE.md (reproduced locally, rc=1):
      • docs/GAMEPLAY_EVIDENCE.md:28: em dash (T2) (envelope—not)
      • docs/GAMEPLAY_EVIDENCE.md:30: semicolon stitching clauses (T2)
      • docs/GAMEPLAY_EVIDENCE.md: paragraph over 420 chars on lines [16, 28].
    • (Confirmed locally: verification/leak_audit.py passes 286 files and verification/build_final_receipt.py leaves verification/VERIFICATION_RECEIPT.json clean.)
  3. Uncaught RecursionError DoS crash on deeply nested JSON (src/mcproof/gameplay_evidence.py:64-91, 203-233):
    • _strict_json_tree and _validate_canonical_value recurse with no depth or size limit.
    • Reproduced live: a 1,200-deep nested array in payload.outcome passes load_gameplay_artifact and then crashes verify_gameplay_artifact with an unhandled RecursionError: maximum recursion depth exceeded (contrast warp-drive#36, which validates iteratively with GateLimits(max_depth=32) and returns envelope_valid=False). Convert traversal to an explicit stack with depth/size ceilings.
  4. Unpaired UTF-16 surrogates silently accepted in envelope fields (src/mcproof/gameplay_evidence.py:66, 101, 205):
    • UTF-8 encodability is checked only on source["raw"] (L366), while canonical_json_bytes uses json.dumps(..., ensure_ascii=True) (L101), silently escaping unpaired surrogates ("\ud800" -> \ud800).
    • Reproduced live: an artifact with "claim.statement": "bad \ud800 surrogate" returns valid=True, source_badges=['OBSERVED', 'REPLAYED'] here, while warp-drive#36 rejects it (INVALID_UNICODE). Validate .encode("utf-8") on every string and object key in _strict_json_tree and _validate_canonical_value.

Cross-Repo Parity & Minor Hygiene Notes

  • Cross-repo gameplay-evidence/v0.1 contract reconciliation with Moissanite-Labs/warp-drive#36:
    • payload.model and payload.initial_state: mcproof#17 (L274-284, schema:68,70) accept any jsonValue ([1,2,3]), while warp-drive#36 (L397-399) requires dict.
    • source.raw == "": accepted here (L336, schema:115), rejected in warp-drive#36 (L450).
    • mechanics[*].path: accepted here for CORE.YAML (rejected in warp-drive#36); also both validators currently accept bare ".yaml", newlines ("mechanics/a\nb.yaml"), and Windows drive prefixes ("C:foo.yaml").
    • negative_controls[*].mutation/.observed and identifier regex (^[A-Za-z0-9_.:-]+$): properly enforced here, currently missing/looser in warp-drive#36.
  • Minor input & fixture precision: REPOSITORY_RE (L58) matches "../..", COMMIT_RE (L56) accepts "0" * 40, raw JSON -0 parses as int(0) via json.loads (L130), and the PR body states the two pinned acceptance fixture digests (c852b43bfa6c..., 0a310102c655...) "are recorded in the accompanying implementation commit and documentation", but neither digest appears in the 4 committed files of ee2c2439.

Independent clean-room review by agentic team with human oversight (aletheia v2.0.0, live CI & adversarial repro).

@abu-aska abu-aska 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.

Clean-room re-verification of 51d241333194 (base feat/formal-verification-loop-v0.2 @ c2ed9ca5, 4 files +1,167/-0, 0 workflow changes, 6/6 CI green).

Blockers Closed Since ee2c2439

  • Blocker #1 (branch stacking) — CLOSED: PR diff is now cleanly scoped to the 4 gameplay-evidence files (docs/GAMEPLAY_EVIDENCE.md, schema/gameplay-evidence-v0.1.schema.json, src/mcproof/gameplay_evidence.py, tests/test_gameplay_evidence.py, +1,167/-0, 0 .github/ changes).
  • Blocker #2 (CI / mcproof.prose_gate) — CLOSED: Confirmed locally across -B, -O -B, and -B -W error: python3 -m mcproof.prose_gate docs/GAMEPLAY_EVIDENCE.md prints check-prose: clean (1 file(s), 34 lines). tests/test_gameplay_evidence.py passes 32/32 OK across all 3 standard modes (-B, -O -B, -B -W error) and all 3 isolated modes (-I -B, -I -O -B, -I -B -W error), and aletheia v2.0.0 audit-check --strict-ancestors --safety-scan passes on all 4/4 files (0 findings).

Remaining Open Blockers (Unchanged Since ee2c2439, src/mcproof/gameplay_evidence.py Untouched)

Commit 51d24133 updated only docs/GAMEPLAY_EVIDENCE.md, so both runtime fail-closed blockers in src/mcproof/gameplay_evidence.py still reproduce live:

  1. Uncaught RecursionError DoS on deeply nested JSON (src/mcproof/gameplay_evidence.py:64-91, 203-233):
    • Re-verified live on 51d24133: a 1,200-deep nested array in payload.outcome passes load_gameplay_artifact(), then crashes both verify_gameplay_artifact() and canonical_json_bytes() with RecursionError: maximum recursion depth exceeded. Replacing recursion in _strict_json_tree and _validate_canonical_value with an explicit stack + depth/node ceiling closes this cleanly.
  2. Unpaired UTF-16 surrogates silently accepted (src/mcproof/gameplay_evidence.py:66, 101, 205):
    • Re-verified live on 51d24133: setting claim.statement = "Bad surrogate \ud800 here" (both direct dict and JSON \ud800 via load_gameplay_artifact) returns valid=True, source_badges=['OBSERVED', 'REPLAYED'], admitted_badges=['OBSERVED'], errors=[], and an unpaired surrogate in an object key ({"bad\ud800key": True} in payload.outcome) also returns valid=True, admitted_badges=['OBSERVED']. Checking .encode("utf-8") on every string value and object key in _strict_json_tree and _validate_canonical_value closes this cleanly and restores parity with warp-drive#36.

Keeping the prior CHANGES_REQUESTED active for Blockers #3 and #4 — ready to approve immediately once those two runtime guards and regression tests land!


Independent clean-room re-verification by agentic team with human oversight (aletheia v2.0.0).

@orda-aska orda-aska 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.

I reviewed head 51d2413. The only change since ee2c243 is the docs reflow, so the code and test results below hold for both heads. The PR now diffs to 4 files (+1167) against the loop-v0.2 base and merges cleanly into it. CI is green. I recommend changes before merge, mainly the two runtime guards another review already raised, which I reproduced independently.

What passed. The 32 tests in tests/test_gameplay_evidence.py pass under -I -B, -I -O -B and -I -B -W error with identical output apart from timing. There are no bare assert statements in the module.

I rebuilt every digest the envelope claims (4 payload, 3 per check, source, self) with separate code and got 9 of 9. I compared the module's canonical bytes with a hand-written encoder on 20000 random values and got 20000 of 20000.

A trial merge into the current base left 168 passed in each mode, with 9 failures that need network access or a write my sandbox refused. I do not count those 9 for or against the PR.

Required changes.

  1. Deep nesting crashes the verifier instead of returning an invalid report. A 1200-deep array in payload.outcome loads, then verify_gameplay_artifact raises RecursionError. Smallest repair: reject nesting past a fixed depth (I tried 64) in both _strict_json_tree and _validate_canonical_value. With that change all 32 tests still pass and the 1500-deep and 5000-deep inputs return a normal rejection.

  2. Lone surrogates are accepted in every text field except source.raw. Witness: claim.statement set to "x\ud800", resealed, returns valid=True with source badges OBSERVED, REPLAYED. The canonical form escapes it, so another encoder that refuses lone surrogates will compute a different digest. Smallest repair: call .encode("utf-8") on every string and every object key in the same two traversals. I tried this together with change 1 and it rejects the witness with the reason pinned.

  3. The tests do not pin most field-format rules. Most one-field tests do not reseal the artifact, so the self-digest mismatch rejects first and the targeted rule never runs.

I deleted each rejection branch and ran the suite: 57 of 84 mutants were caught and 27 survived. Of the 27, 23 have a resealed input that the real code rejects and the mutant accepts, 3 are equivalent and 1 is stricter only.

Examples: claim.id set to "bad id", producer.repository set to "owner", checker.artifact_sha256 set to 64 zeros or to 65 characters, producer.revision set to 40 capitals, check.kind set to "other", check.status set to "SKIP", payload.actions set to {} with its digest recomputed, a NUL byte inside a mechanic path, and source.raw set to an integer.

Please reseal in those tests and assert the error text. The body's mutation claim holds for payload, action, trajectory, check and label tampering, and not for these format rules.

  1. A failed negative control does not veto. With two controls, one passed: true and one passed: false, source_badges still gains REPLAYED, while a single failed check does veto. Either require every control to pass or document why one passing control is enough.

Smaller points, not blocking.

  • Mechanic paths accept C:/x.yaml, ~/x.yaml and %2e%2e/x.yaml. Repository accepts ../.. and ./.. A consumer that joins these into a path or URL should not trust them.
  • A claim statement of one zero-width space counts as nonempty text.
  • -0 in JSON text loads as 0, and a commit of 40 zeros is accepted.
  • Nothing ties actions to trajectory to outcome. An artifact with empty actions, an empty trajectory and goal_reached: false under claim kind route is valid. The docs say domain semantics are out of scope, so this is only worth a sentence in the docs.
  • The two pinned fixture digests in the body do not appear in the 4 files, so I could not recheck them. Please add the fixtures or the files that produce those digests.
  • Key order is code point order. RFC 8785 sorts by UTF-16 code unit, so other implementations must match this module, not that RFC, when they hash keys outside the basic plane.

Scope. The docs and module header say validation is structural and digest consistency only. I found no claim that gameplay happened or that a result is verified. admitted_badges was OBSERVED or empty in all 85 inputs I tried.

Automated posting by agentic team with human oversight.

@ahrazzle

Copy link
Copy Markdown
Member Author

Cross-repo reference (steward pollination pass 2026-11-24): this fail-closed gameplay evidence validator aligns with Foundation-0/formal-claims-audit (Foundation-0/formal-claims-audit#16 AST lint/copy-rename detector for certificate checkers; Foundation-0/formal-claims-audit#19 fail on zero verdict files), the Foundation-0/proven-commons mirrors Foundation-0/proven-commons#9 and Foundation-0/proven-commons#10, and this repo's #18 (checkable proof site). Pattern to reuse: Proven-Commons/tar's proved no-escape gate Proven-Commons/tar#4 (containment proved for every printed line), the model among the org's lean-verified parser repos. Shared opportunity: one verdict-file schema (fail-closed on zero verdicts) replayed by both mcproof and the formal-claims-audit tooling.

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.

3 participants