8000 feat: establish verifier-gated zero-to-one slice by Mnehmos · Pull Request #2 · Mnehmos/MathOS · GitHub
[go: up one dir, main page]

Skip to content

feat: establish verifier-gated zero-to-one slice - #2

Merged
Mnehmos merged 7 commits into
mainfrom
feat/zero-to-one-vertical-slice
Jul 19, 2026
Merged

Mnehmos merged 7 commits into
mainfrom
feat/zero-to-one-vertical-slice

Conversation

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

Summary

Establish the first complete MathOS claim lifecycle across ingestion, finite formalization, untrusted proof search, verifier-gated outcomes, certainty-preserving pedagogy, tamper-evident provenance, CLI and MCP interfaces, and validated RL trajectory export.

MathOS remains the product. MCP is one interface. MnehmosAI is the company and publishing vehicle.

Change class

Class 3: release and verifier-critical trust-boundary work.

Affected boundaries: claim state transitions, finite verification, counterexample validation, provenance replay, trajectory evidence, CLI, and MCP stdio.

TDD evidence

The initial collection run failed with ModuleNotFoundError: mathos, establishing Red before the package existed. A later hardening Red run exposed five missing guarantees: materialized-state replay, complete RL lifecycle validation, terminal-only export, bounded integer growth, and bounded statement input. Those tests failed for the intended reasons before implementation and now pass.

Verification

make install
make check
make adversarial
make demo
make validate-demo
.venv/bin/python -m pip check
git diff --check

Local results:

  • 38 tests pass with ResourceWarning promoted to an error
  • 13 dedicated adversarial scenarios pass
  • 200 deterministic randomized Boolean claims match a separate reference oracle
  • canonical demo returns one proved, one disproved, and one unresolved claim
  • all three RL exports validate
  • a wheel installs and runs in a new virtual environment
  • installed package passes pip check

Provenance and dependencies

The runtime is Python standard library only. No third-party code or data is introduced. Canonical fixtures and generated demo artifacts are repository-authored. Local demonstration databases and exports are ignored.

Known limitations

  • Search and verification are separate but share expression semantics, so common-mode implementation risk remains.
  • The ledger hash chain is tamper-evident, not signed or externally anchored.
  • Natural-language intent alignment is not proved.
  • Lean is not installed in this release. The adapter fails closed.
  • MCP covers the declared stdio surface; broader client interoperability follows this release.

These limits are explicit in docs/architecture/TRUST_MODEL.md.

Recovery

Revert this single commit. The release introduces no remote service, migration, or persistent production data.

Definition of Done

Local and GitHub Actions evidence is complete. All eight review threads are resolved, CodeRabbit passes, and the verified branch was squash-merged to main as 4d51e535e17436e00feb9282bf6de9c8c07b40d0. The remaining release-administration gate is the remote v0.1.0 tag on that exact commit.

Summary by CodeRabbit

  • New Features

    • Added MathOS v0.1.0 with claim submission, finite-domain proof checking, counterexample detection, and explicit unresolved outcomes.
    • Added command-line workflows for processing claims, reviewing results, replaying provenance, and exporting validated trajectories.
    • Added MCP stdio support for JSON-RPC tool integration.
    • Added tamper-evident provenance tracking and export validation.
    • Added Lean file verification when the Lean toolchain is available.
  • Documentation

    • Added product specifications, architecture and trust-model guidance, release criteria, examples, and quick-start instructions.
  • Tests

    • Added comprehensive integration, adversarial, provenance, export, and MCP coverage.

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

Review Change Stack

Warning

Review limit reached

@Mnehmos, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0c179645-428b-4807-9505-a131c05a3204

📥 Commits

Reviewing files that changed from the base of the PR and between a6034df and 32fa45c.

📒 Files selected for processing (17)
  • .github/workflows/ci.yml
  • docs/architecture/SYSTEM_OVERVIEW.md
  • docs/architecture/TRUST_MODEL.md
  • docs/dev-diary/0003-the-space-between-events.md
  • docs/dev-diary/README.md
  • docs/implementation/0001-zero-to-one-evidence.md
  • docs/product/ZERO_TO_ONE_DOD.md
  • src/mathos/cli.py
  • src/mathos/engine.py
  • src/mathos/lean.py
  • src/mathos/ledger.py
  • src/mathos/mcp_server.py
  • src/mathos/trajectory.py
  • tests/test_adversarial.py
  • tests/test_claim_engine.py
  • tests/test_cli.py
  • tests/test_mcp.py
📝 Walkthrough

Walkthrough

MathOS adds a trusted claim-verification vertical slice with finite-domain proof search, independent verification, SQLite provenance, trajectory exports, CLI and MCP interfaces, packaging metadata, adversarial tests, documentation, and CI validation.

Changes

Trusted claim lifecycle

Layer / File(s) Summary
Domain contracts and provenance ledger
src/mathos/models.py, src/mathos/canonical.py, src/mathos/ledger.py
Defines claim states, verification records, deterministic hashes, SQLite persistence, append-only events, state transitions, and chain validation.
Finite search and independent verification
src/mathos/finite.py, src/mathos/lean.py
Adds bounded finite specification validation, search certificates, independent proof/counterexample verification, and fail-closed Lean subprocess verification.
Claim processing and exports
src/mathos/engine.py, src/mathos/pedagogy.py, src/mathos/trajectory.py
Orchestrates submission, verification, status transitions, pedagogy output, provenance events, and validated RL trajectory exports.
CLI, MCP, and demo interfaces
src/mathos/cli.py, src/mathos/mcp_server.py, src/mathos/demo.py, src/mathos/__main__.py, src/mathos/__init__.py
Exposes engine operations through CLI and JSON-RPC, adds the canonical demo workflow, and configures package entry points and versioning.
Fixtures and validation tests
tests/*, examples/finite/*
Adds proved, disproved, and unresolved fixtures plus integration, adversarial, provenance, trajectory, CLI, and MCP tests.
Packaging, CI, and documentation
pyproject.toml, Makefile, .github/workflows/*, README.md, docs/*, .gitignore
Adds build metadata, development targets, CI installation/wheel smoke tests, local demo ignores, and product, architecture, release, and development documentation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CLI_or_MCP
  participant ClaimEngine
  participant FiniteSearchEngine
  participant FiniteDomainVerifier
  participant ProvenanceLedger
  participant TrajectoryValidator

  Client->>CLI_or_MCP: Submit claim
  CLI_or_MCP->>ClaimEngine: submit(...)
  ClaimEngine->>ProvenanceLedger: persist claim.submitted
  Client->>CLI_or_MCP: Run claim
  CLI_or_MCP->>ClaimEngine: process(...)
  ClaimEngine->>FiniteSearchEngine: search formal specification
  FiniteSearchEngine-->>ClaimEngine: candidate certificate
  ClaimEngine->>FiniteDomainVerifier: verify candidate
  FiniteDomainVerifier-->>ClaimEngine: verification result
  ClaimEngine->>ProvenanceLedger: persist status and evidence events
  Client->>CLI_or_MCP: Export and validate trajectory
  CLI_or_MCP->>ClaimEngine: export_trajectory(...)
  ClaimEngine->>TrajectoryValidator: verify_trajectory(...)
  TrajectoryValidator-->>Client: valid trajectory result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.93% 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 Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: a verifier-gated zero-to-one slice.
Description check ✅ Passed The description covers all required template sections with concrete summary, TDD, verification, provenance, limitations, recovery, and readiness details.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/zero-to-one-vertical-slice

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.

@Mnehmos
Mnehmos marked this pull request as ready for review July 19, 2026 05:11
@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: a6034df02e

ℹ️ 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/mathos/cli.py Resolved
Comment thread src/mathos/trajectory.py Resolved
Mnehmos commented Jul 19, 2026
Copy link
Copy Markdown
Owner Author

@codex review

Both P1 findings from the prior review are fixed with regression tests. Please review the current head, 2f98353.

Mnehmos commented Jul 19, 2026
Copy link
Copy Markdown
Owner Author

@coderabbitai review

Please review the current head, 2f98353. The two prior P1 findings are fixed and resolved.

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

@Mnehmos I’ll review the current head (2f98353), with particular attention to the resolved P1 regressions and verifier-critical boundaries.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 2f98353da9

ℹ️ 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/mathos/trajectory.py Resolved
Comment thread src/mathos/engine.py 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.

Actionable comments posted: 4

🧹 Nitpick comments (3)
.github/workflows/ci.yml (1)

20-20: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Prevent credential persistence in the checkout action.

By default, actions/checkout stores the GITHUB_TOKEN in the local Git configuration. Since this workflow only runs tests and builds without pushing changes back to the repository, you should disable this behavior to minimize security risks (such as accidental leakage if .git files are included in future artifacts).

🛡️ Proposed fix to limit credential persistence
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@v4
+        with:
+          persist-credentials: false
🤖 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 @.github/workflows/ci.yml at line 20, Update the actions/checkout@v4 step to
disable credential persistence by setting persist-credentials to false. Keep the
existing checkout behavior unchanged otherwise.

Source: Linters/SAST tools

tests/test_cli.py (1)

20-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reuse run_cli helper instead of duplicating the subprocess call.

This block reimplements the same subprocess.run invocation as run_cli (lines 11-17); using the helper avoids drift between the two call sites.

♻️ Proposed refactor
     def test_demo_runs_complete_vertical_slice(self) -> None:
         with tempfile.TemporaryDirectory() as directory:
-            completed = subprocess.run(
-                [
-                    sys.executable,
-                    "-m",
-                    "mathos",
-                    "demo",
-                    "--workspace",
-                    directory,
-                    "--reset",
-                ],
-                check=True,
-                capture_output=True,
-                text=True,
-            )
-            result = json.loads(completed.stdout)
+            result = self.run_cli("demo", "--workspace", directory, "--reset")
🤖 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/test_cli.py` around lines 20 - 34, Replace the duplicated
subprocess.run invocation in the demo test with the existing run_cli helper,
passing the same CLI arguments and workspace directory. Preserve the current
check, output capture, and text behavior provided by the helper.
tests/test_mcp.py (1)

24-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract shared server spawn/teardown into a helper.

Both tests duplicate the same subprocess.Popen setup and finally teardown (terminate/wait/close streams). A small helper (context manager or setUp/tearDown) would remove the duplication.

Also applies to: 145-157, 136-142, 180-186

🤖 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/test_mcp.py` around lines 24 - 30, Extract the duplicated MCP server
lifecycle from the affected tests into a shared helper, such as a context
manager, covering the subprocess.Popen configuration and
terminate/wait/stream-close teardown. Update each test’s setup and cleanup to
use this helper while preserving the existing server arguments and cleanup
behavior.
🤖 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.

Inline comments:
In `@src/mathos/engine.py`:
- Around line 47-54: Handle deterministic duplicate claims across all submission
interfaces: in src/mathos/engine.py lines 47-54, update ClaimEngine.submit() to
catch the ledger collision from insert_claim and raise a clear ValueError or
make identical submissions idempotent; in src/mathos/cli.py lines 124-126,
include sqlite3.Error in main()’s handled exceptions; and in
src/mathos/mcp_server.py lines 197-201, include sqlite3.Error in _call_tool’s
handled exceptions so both interfaces return their structured error responses.

In `@src/mathos/lean.py`:
- Around line 43-49: Wrap the subprocess.run call in the verification flow
around completed so subprocess.TimeoutExpired and OSError are caught, then
return or construct VerificationOutcome.UNKNOWN consistently with the adapter’s
fail-closed behavior. Preserve normal completed-process handling and avoid
allowing execution failures to propagate to callers.

In `@src/mathos/ledger.py`:
- Around line 92-145: Move the existing-claim lookup in insert_claim inside the
BEGIN IMMEDIATE transaction, or catch a concurrent INSERT constraint failure and
reconcile it by reloading the stored claim. Return the existing claim when its
informal_statement and formal_spec match, and raise ValueError("claim identifier
collision") when they differ; do not expose a raw sqlite3.IntegrityError, while
preserving rollback behavior for other failures.

In `@src/mathos/trajectory.py`:
- Around line 47-70: The trajectory verification loop around previous_sequence
and event_hash must also validate the chain linkage: require the first event’s
previous_hash to be None and each subsequent event’s previous_hash to equal the
prior event_hash. Track the prior hash while iterating and return the existing
invalid-event verification failure when the linkage is incorrect.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Line 20: Update the actions/checkout@v4 step to disable credential persistence
by setting persist-credentials to false. Keep the existing checkout behavior
unchanged otherwise.

In `@tests/test_cli.py`:
- Around line 20-34: Replace the duplicated subprocess.run invocation in the
demo test with the existing run_cli helper, passing the same CLI arguments and
workspace directory. Preserve the current check, output capture, and text
behavior provided by the helper.

In `@tests/test_mcp.py`:
- Around line 24-30: Extract the duplicated MCP server lifecycle from the
affected tests into a shared helper, such as a context manager, covering the
subprocess.Popen configuration and terminate/wait/stream-close teardown. Update
each test’s setup and cleanup to use this helper while preserving the existing
server arguments and cleanup behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d95350b-bb5d-491e-bed4-a9f25a27a1d2

📥 Commits

Reviewing files that changed from the base of the PR and between ac1513e and a6034df.

📒 Files selected for processing (38)
  • .github/workflows/ci.yml
  • .gitignore
  • Makefile
  • README.md
  • docs/architecture/SYSTEM_OVERVIEW.md
  • docs/architecture/TRUST_MODEL.md
  • docs/architecture/adr/0001-finite-verifier-first.md
  • docs/dev-diary/0001-trust-before-scale.md
  • docs/dev-diary/0002-a-history-that-can-disagree.md
  • docs/dev-diary/README.md
  • docs/implementation/0001-zero-to-one-evidence.md
  • docs/product/SPEC.md
  • docs/product/ZERO_TO_ONE_DOD.md
  • examples/finite/excluded_middle.json
  • pyproject.toml
  • src/mathos/__init__.py
  • src/mathos/__main__.py
  • src/mathos/canonical.py
  • src/mathos/cli.py
  • src/mathos/demo.py
  • src/mathos/engine.py
  • src/mathos/finite.py
  • src/mathos/lean.py
  • src/mathos/ledger.py
  • src/mathos/mcp_server.py
  • src/mathos/models.py
  • src/mathos/pedagogy.py
  • src/mathos/trajectory.py
  • tests/__init__.py
  • tests/fixtures/disproved.json
  • tests/fixtures/proved.json
  • tests/fixtures/unresolved.json
  • tests/helpers.py
  • tests/test_adversarial.py
  • tests/test_claim_engine.py
  • tests/test_cli.py
  • tests/test_finite_verifier.py
  • tests/test_mcp.py

Comment thread src/mathos/engine.py Resolved
Comment thread src/mathos/lean.py Resolved
Comment thread src/mathos/ledger.py Resolved
Comment thread src/mathos/trajectory.py Resolved
@Mnehmos
Mnehmos merged commit 4d51e53 into main Jul 19, 2026
2 checks passed
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.

1 participant

0