8000 feat: add atomic Pilot A counterexample repair by Mnehmos · Pull Request #45 · Mnehmos/MathOS · GitHub
[go: up one dir, main page]

Skip to content

feat: add atomic Pilot A counterexample repair - #45

Merged
Mnehmos merged 2 commits into
mainfrom
feat/pilot-a-counterexample-repair
Jul 21, 2026
Merged

Mnehmos merged 2 commits into
mainfrom
feat/pilot-a-counterexample-repair

Conversation

@Mnehmos
@Mnehmos Mnehmos commented Jul 21, 2026 •
Copy link
Copy Markdown
Owner

Closes #44

Summary

Adds the focused Pilot A repair slice: a closed counterexample package, an application-derived and atomically committed repaired claim, a controlled immutable repair edge, shared CLI/MCP access, and protected-workflow retention. The original false claim remains independently addressable and disproved; the repaired claim starts not_started.

Review follow-up a255608 additionally requires an exact matching counterexample_search_result/1 observation, preserves retries after later run events, and rejects any MCP dry_run field on the read action.

Change class

Select one:

  • Class 0: Administrative or documentation
  • Class 1: Standard implementation
  • Class 2: Verifier-critical
  • Class 3: Release, migration, or security-sensitive

Affected trust boundary: derived claim status, receipt-bound refutation reuse, counterexample provenance, canonical CAS packaging, and atomic immutable claim lineage. This path packages already revalidated evidence; it cannot create proof or refutation authority.

TDD evidence

  • Acceptance criteria were defined before implementation
  • A focused test or formal obligation failed first for the expected reason
  • The smallest coherent implementation made it pass
  • Refactoring preserved passing behavior
  • Relevant unit and integration suites pass
  • Failure paths and boundary cases are covered
  • Documentation-only exception applies and is explained below

Red evidence: issue #44 defined the closed package, atomicity, immutability, retry, concurrency, and interface obligations before the capability existed. Review then exposed three focused failing obligations: a start-only run was accepted, later run events blocked retry, and MCP get accepted dry_run:false.

Green evidence: the domain/application/store/CLI/MCP tests cover canonical identity, dry-run, rollback injection, concurrency, restart, idempotency rebinding, CAS corruption, start-only and mismatched search results, post-repair run extension, generic-edge denial, and forbidden MCP fields.

Commands and results:

  • cargo fmt --check - pass
  • cargo clippy --workspace --all-targets --all-features -- -D warnings - pass
  • cargo test --workspace - pass (140 unit, 12 CLI integration, 3 MCP integration, Lean worker baseline)
  • MCL_RUN_LEAN_INTEGRATION=1 cargo test --test lean_worker -- --nocapture - pass with Lean 4.32.0
  • legacy Python compile plus 39 unittest cases - pass
  • publication-script Bash syntax and Actionlint v1.7.12 - pass
  • git diff --check - pass
  • exact-head CI run 29866239855 - all five CI jobs pass at a255608aae1abf31bea27d6a11d26e08d18f0b22

Mathematical verification

  • No mathematical trust boundary is affected
  • Candidate output was checked independently from its generator
  • Formal proof passes the pinned kernel or checker
  • Counterexample premises and violated conclusion were checked
  • Assumptions, domains, tolerances, and dependency pins are recorded
  • Claim, theorem, witness, or artifact identifiers are linked

Verifier and result: Pilot A's exact refutation and derived disproved status were independently audited in #41 / #42 / #43. This change binds witness 2 to that exact negation formalization and its protected receipt. The updated exact head passes the pinned real-Lean CI job. The new merged-tree package remains subject to the protected-publication download and independent audit required by #44 before that issue closes.

Provenance and licensing

  • No new third-party code, data, model output, or dependency
  • New third-party material has source, license, and attribution recorded
  • Generated artifacts include tool, version, configuration, seed, and hash as applicable
  • MathCorpus and RL export implications are documented
  • No credentials, private data, or access-controlled material are included

Provenance references: #41, #42, #43, #44; ADR-0009; docs/trust/COUNTEREXAMPLE_REPAIR.md; protected publication receipt and retained closure.

Risk and recovery

Known limitations: this does not prove the repaired claim, create pedagogy units, export release/RL data, or complete Pilot A / MathOS 1.0. A failed commit may leave only an unregistered content-addressed byte object, which is explicitly non-semantic.

Rollback or recovery plan: revert the merge. The change introduces no external dependency and no destructive data rewrite; the original claim and evidence are never mutated.

Follow-up work: independently audit the merged protected artifact, then open a separate slice to formalize and prove "Every prime number other than 2 is odd."

Review readiness

  • The branch is current with main
  • The pull request addresses one coherent concern
  • Required checks pass
  • Review threads are resolved
  • I have not represented generated output as independently verified evidence

@coderabbitai
coderabbitai Bot commented Jul 21, 2026 •
Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an atomic counterexample-repair workflow with versioned contracts, canonical package hashing, independent repaired claims, controlled lineage edges, shared CLI/MCP access, transaction safeguards, Pilot A integration, tests, and documentation.

Changes

Counterexample repair

Layer / File(s) Summary
Counterexample contracts and schemas
src/domain/counterexample.rs, src/domain/mod.rs, schemas/counterexample/*
Defines closed request/package/edge types, validation rules, canonical serialization and hashes, and matching JSON Schemas.
Application repair and verification
src/app.rs
Adds repair, retrieval, and search-run validation APIs; derives evidence and status, supports dry-runs, and verifies stored lineage.
Atomic store commit and edge control
src/store/mod.rs
Atomically registers artifacts, creates repaired claims and controlled repair edges, records idempotency results, and handles rollback and conflicts.
CLI, MCP, and endpoint validation
src/cli/mod.rs, src/mcp/mod.rs, tests/mcp_stdio.rs, tests/phase1_cli.rs
Exposes repair and retrieval operations through both interfaces and validates malformed, incomplete, forbidden, and missing inputs.
Protected Pilot A workflow
scripts/publication-ingest.sh
Runs counterexample search and repair, checks deterministic retries, retrieves the package, and verifies original and repaired claim states.
Repair semantics and implementation records
docs/decisions/*, docs/trust/*, docs/implementation/STATUS.md, docs/dev-diary/*
Records package, lineage, trust, status, and correction semantics for the implemented workflow.

Estimated code review effort: 5 (Critical) | ~90+ minutes

Possibly related issues

Possibly related PRs

  • Mnehmos/MathOS#39 — Directly relates to the claim-research-status derivation refactor used by counterexample repair.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes appear to satisfy #44 by adding the closed package contract, atomic repair path, CLI/MCP exposure, and the required tests.
Out of Scope Changes check ✅ Passed No clear unrelated code changes stand out; the added docs, schema, scripts, and tests all support the counterexample repair slice.
Title check ✅ Passed The title clearly summarizes the main change: atomic Pilot A counterexample repair.
Description check ✅ Passed The description follows the template and covers summary, change class, evidence, verification, provenance, risk, and readiness.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/pilot-a-counterexample-repair

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fec9db8398

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app.rs Resolved
Comment thread src/app.rs Resolved
Comment thread src/mcp/mod.rs Resolved
@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
src/domain/counterexample.rs (1)

532-534: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low value

Optional: text_schema is more permissive than validate_text.

validate_text rejects whitespace-only strings (value.trim().is_empty()) and bounds by byte length, but the generated schema declares minLength: 1 / maxLength: MAX_TEXT_BYTES, which JSON Schema counts in characters and which admits whitespace-only strings. A payload that passes the committed schema (e.g. " ", or a multi-byte string near the limit) can still be rejected by the Rust contract. Since the Rust path is the enforced gate this is not exploitable, but the two representations of the "same" contract diverge. Consider documenting the byte/trim semantics as the authoritative bound.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/domain/counterexample.rs` around lines 532 - 534, Align text_schema with
validate_text by documenting that the Rust validator’s trimmed, byte-length
semantics are authoritative, or adjust the schema representation if the project
supports those constraints. Ensure the schema contract does not imply
character-based minLength/maxLength validation or acceptance of whitespace-only
strings.
tests/mcp_stdio.rs (1)

288-338: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a success-path counterexample MCP test.

All new counterexample coverage here exercises error paths (missing fields, malformed JSON, unknown artifact, forbidden dry_run). Nothing verifies a successful repair/get round trip through the MCP stdio transport itself — that leaves the Parameters<CounterexampleRequest> → Application → to_value → CallToolResult wiring for the happy path exercised only indirectly, via the CLI-driven Pilot A script and Application-layer unit tests, not via MCP.

Consider adding one test that runs a fixture through fidelity/authority setup (as the Application tests already do), then calls counterexample with action: "repair" (dry-run and persisted) and action: "get" over stdio, asserting isError == false and a few key structuredContent fields.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/mcp_stdio.rs` around lines 288 - 338, Extend the existing
counterexample MCP stdio test with a successful fixture setup using the same
fidelity/authority configuration as the Application tests. Exercise repair in
both dry-run and persisted modes, then call get for the persisted result over
stdio. Assert each response has isError false and validate key structuredContent
fields, including the repaired counterexample and retrieved artifact data.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/domain/counterexample.rs`:
- Around line 532-534: Align text_schema with validate_text by documenting that
the Rust validator’s trimmed, byte-length semantics are authoritative, or adjust
the schema representation if the project supports those constraints. Ensure the
schema contract does not imply character-based minLength/maxLength validation or
acceptance of whitespace-only strings.

In `@tests/mcp_stdio.rs`:
- Around line 288-338: Extend the existing counterexample MCP stdio test with a
successful fixture setup using the same fidelity/authority configuration as the
Application tests. Exercise repair in both dry-run and persisted modes, then
call get for the persisted result over stdio. Assert each response has isError
false and validate key structuredContent fields, including the repaired
counterexample and retrieved artifact data.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 017e7705-1b3c-4a61-adb5-323171a06420

📥 Commits

Reviewing files that changed from the base of the PR and between 364bad5 and fec9db8.

📒 Files selected for processing (18)
  • docs/decisions/ADR-0009-atomic-counterexample-package-and-claim-repair.md
  • docs/dev-diary/0037-a-correction-needs-two-names.md
  • docs/dev-diary/README.md
  • docs/implementation/STATUS.md
  • docs/trust/COUNTEREXAMPLE_REPAIR.md
  • docs/trust/FIDELITY.md
  • docs/trust/PUBLICATION_AUTHORITY.md
  • schemas/counterexample/counterexample-package-1.schema.json
  • schemas/counterexample/counterexample-repair-request-1.schema.json
  • scripts/publication-ingest.sh
  • src/app.rs
  • src/cli/mod.rs
  • src/domain/counterexample.rs
  • src/domain/mod.rs
  • src/mcp/mod.rs
  • src/store/mod.rs
  • tests/mcp_stdio.rs
  • tests/phase1_cli.rs

@Mnehmos
Mnehmos merged commit 1e9066f into main Jul 21, 2026
6 checks passed
@Mnehmos
Mnehmos deleted the feat/pilot-a-counterexample-repair branch July 21, 2026 20:39
@Mnehmos
Mnehmos commented Jul 21, 2026
Copy link
Copy Markdown
Owner Author

Protected merged-tree acceptance is complete.

Exact Git identities:

GitHub verification:

  • main CI run 29866704074: all five jobs passed on the exact merge commit
  • protected publication run 29866704122, job 88756652960: passed protected-ref enforcement, contained Lean, both attestations/challenges, controlled ingestion/promotion, atomic counterexample repair, and retention
  • retained artifact 8509521719, publication-boundary-1e9066f01ed75ba30156718710d2451db4f7a4a8, GitHub-reported archive size 105742 bytes

Independent downloaded-artifact audit:

  • audited all 91 retained files (67 JSON); all eight stderr files are empty
  • rechecked exact merge SHA/tree/run and the Sigstore certificate binding to protected refs/heads/main, GitHub-hosted execution, and run attempt 1
  • recomputed the complete two-event search chain
  • exact counterexample_search_result/1 event: 7e6627025dc9ed2ccd91eeb0ae08205babedea1d6c6ee17832aec28e5c0a008c
  • exact search run: 019f8669-618e-7291-a0e7-e161ceec44c0
  • exact witness: canonical Nat value 2
  • recomputed canonical package SHA-256 14bff23f2e7afe79d2fec05fa5d4d89a0340151398529e322e7112fd7dc83652 from its exact 2,944 bytes
  • package refutation witness matches authority 914f03a02ffba3a774fbcbb1c753c221593409d067fb07b5061b1a055e61eb55, fidelity 691e7def809ee7c2e11fafb69a7dff1a5067f57e0b0b82bd1347db5f83336230, and receipt 806f9a6e1cad16b76149c8cedac74b511100a40f8084ee1259abaa3e3c99ae90
  • original claim 019f8669-1b1e-7c32-8280-2bcaf4aa01f4 / f40843ae3c953ffd076d669ea878b7c0efad4e5fa92351114763b7e56460b237 remained byte-identically disproved
  • repaired claim 019f8669-622f-73c3-8ca7-cb5f15da829d / f7d4cdccc4e5be9d78991a5095d80b1eb7bf5a4e5ccffe8c1454d90377d2bb88 is a distinct no-predecessor claim/1 and starts not_started
  • controlled edge 019f8669-6230-7c01-9011-26ad0e840f3d points from the repaired exact version to the original exact version with exclude_boundary_case and the exact package/run/formalization binding
  • dry-run hashes matched persisted hashes; the persisted retry was structurally identical
  • package retrieval reproduced the exact artifact, package, repaired claim, and edge
  • the retained exact module matched the committed bytes and independently re-elaborated with the pinned local Lean toolchain

This satisfies issue #44. It does not prove the repaired claim or complete Pilot A / MathOS 1.0. The next focused slice is a new formalization, protected proof authority, and role-separated fidelity for the repaired claim without changing the original claim or repair package.

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.

Pilot A: atomic counterexample package and immutable claim repair

1 participant

0