8000 Create receipt-bound publication proof authority by Mnehmos · Pull Request #36 · Mnehmos/MathOS · GitHub
[go: up one dir, main page]

Skip to content

Create receipt-bound publication proof authority - #36

Merged
Mnehmos merged 3 commits into
mainfrom
feat/issue-21-publication-authority
Jul 20, 2026
Merged

Mnehmos merged 3 commits into
mainfrom
feat/issue-21-publication-authority

Conversation

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

Summary

  • Add closed evidence/2 and publication_authority_binding/1 contracts without changing any evidence/1 byte identity.
  • Replay an exact controlled-ingestion receipt, stage, 25-role CAS closure, report, request, bundle, raw verifier output, canonical receipt, and current Store state before deriving proof/refutation authority.
  • Bind the receipt subject to the retained controlled publication request, then recheck subject, current head, environment, polarity, closure, uniqueness, and idempotency in one immediate Store transaction.
  • Reject caller-authored authority through a crate-private non-deserializable commit, strict SQLite insert triggers, immutable projections, and read-time integrity checks.
  • Expose only receipt-hash promotion through the shared CLI/MCP application service and exercise it in the protected publication workflow.
  • Retain receipt-bound verifier bytes before promotion so failed gates preserve replayable evidence.

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: the protected-publication boundary that may create authoritative formal proof/refutation evidence. The receipt is only a locator; authority is derived from exact replay inside the application and Store transaction.

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 #21 and the existing publication contracts denied this authority path before implementation. Independent review then produced concrete failing regressions for cross-subject receipt substitution and post-ingestion failure retention; both were fixed at the boundary. The final review added individual fail-closed enforcement-flag cases.

Green evidence: exact receipt/request subject binding now holds at ingestion, Store promotion, SQL insertion, retry, and evidence read. Promotion covers dry-run, persist, exact retry, missing CAS, altered staged content, forbidden caller inputs, and every protected-report pass condition.

Commands and results:

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace --all-targets — 112 library, 1 Lean-worker, 3 MCP, and 10 CLI tests on the initial head; the review follow-up adds one case group without changing production code
  • MCL_RUN_LEAN_INTEGRATION=1 cargo test --test lean_worker -- --nocapture — real pinned Lean 4.32.0
  • PYTHONPATH=src PYTHONWARNINGS=error::ResourceWarning python -m unittest discover -s tests -v — 39 passed
  • Bash syntax for all four publication scripts
  • Actionlint 1.7.12
  • git diff --check
  • Hands-on Windows CLI smoke: migration 11, healthy mcl health/mcl doctor, and unknown receipt rejected as MCL_PUBLICATION_RECEIPT_NOT_FOUND

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: real Lean 4.32.0 integration passed locally and in required CI. The exact merged-main protected-publication run remains a post-merge acceptance condition and will be independently audited before issue #21 is closed. This change creates authority only for the exact Lean formalization named by the request; it does not derive source-claim truth.

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: ADR-0007, docs/trust/PUBLICATION_AUTHORITY.md, the retained closure and attestation contracts, and issue #21.

Risk and recovery

Known limitations: this is formalization authority only. SPEC section 11 still requires a later read combining current formal authority with current verified statement fidelity and all other derived-truth preconditions. Docstring coverage remains advisory; the public trust contract is documented in the ADR, schema, trust guide, CLI help, and tests.

Rollback or recovery plan: revert the merge commit. Migration 11 is additive; legacy evidence/1 identities and reads remain unchanged. A failed promotion retains the exact raw and canonical receipt CAS bytes for replay and diagnosis.

Follow-up work: independently audit the protected-main artifact, record exact hashes/run metadata, close issue #21 only if every criterion passes, then implement the separate fidelity-bound source-truth read.

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

Review-driven hardening

  • An independent review found the initial Store gate did not relate the commit subject back to the retained request. The final implementation persists immutable receipt subject projections and checks exact request-artifact metadata at ingestion, Store promotion, SQL insertion, and evidence read. Same-environment/same-polarity A→B substitution now fails through receipt retry, Store API, raw SQL, and read-time corruption paths.
  • A final handoff review found promotion failures could occur before receipt-bound CAS bytes were copied into the uploaded directory. The script now copies and strict-hash-checks those bytes immediately after ingestion and before promotion.
  • CodeRabbit's final review found one valid test-only gap. The follow-up checks each protected-report enforcement flag individually while keeping the classification Passed.

Advances #21. Do not close #21 until the exact merged tree produces and retains a protected-main authority record and that artifact is independently audited.

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

Review Change Stack

📝 Walkthrough

Walkthrough

Adds receipt-bound publication authority promotion across evidence contracts, SQLite storage, application, CLI, MCP, scripts, tests, and trust documentation. The new flow replays staged artifacts, requires a passed publication report, and atomically persists authoritative proof or refutation evidence.

Changes

Publication authority promotion

Layer / File(s) Summary
Authority contracts and documentation
src/domain/evidence.rs, schemas/evidence/*, docs/decisions/*, docs/trust/*, docs/implementation/*, docs/dev-diary/*
Adds closed evidence/2 and publication_authority_binding/1 contracts, preserves legacy evidence compatibility, and documents the receipt-bound authority boundary.
Receipt-bound storage gate
migrations/0011_publication_authority.sql, src/store/mod.rs
Adds receipt and stage projections, uniqueness and validation triggers, subject-binding checks, atomic authoritative evidence creation, and read-time integrity validation.
Promotion service and entrypoints
src/app.rs, src/cli/mod.rs, src/mcp/mod.rs, scripts/publication-ingest.sh, .github/workflows/publication.yml
Adds application promotion with replay and passed-report checks, exposes CLI/MCP actions, and promotes and validates authority in the ingestion script.
Promotion workflow validation
tests/mcp_stdio.rs, tests/phase1_cli.rs, src/app.rs, src/store/mod.rs
Covers capabilities, required and forbidden fields, missing receipts, migration version changes, dry-run behavior, persistence, retries, and altered staged content.

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

Possibly related PRs

  • Mnehmos/MathOS#34: Provides the controlled publication-ingestion workflow and receipt artifacts consumed by this authority-promotion flow.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.95% 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 implement the direct #21 goals: closed authority contracts, receipt-bound promotion, safe CLI/MCP surfaces, tests, and trust documentation.
Out of Scope Changes check ✅ Passed I don't see material code changes outside the publication-authority scope; the added docs, tests, scripts, schema, and migration all support #21.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding receipt-bound publication proof authority.
Description check ✅ Passed The description follows the required template and covers the major sections with sufficient detail.
✨ 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/issue-21-publication-authority

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 20, 2026 07:48
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@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 (1)
src/app.rs (1)

5602-5620: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extend the gate test to the enforcement-flag paths.

validate_publication_authority_report also rejects a Passed report when any of clean_checkout, dependency_closure_complete, network_isolation_enforced, memory_limit_enforced is false, or when authoritative is true. This test only flips classification, so those fail-closed branches are unverified. Consider adding cases that keep classification == Passed while individually clearing each flag (and setting authoritative = true) and asserting MCL_PUBLICATION_AUTHORITY_REPORT_NOT_PASSED.

🤖 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/app.rs` around lines 5602 - 5620, Extend
publication_authority_requires_an_explicit_passed_report to retain
classification as Passed while individually setting clean_checkout,
dependency_closure_complete, network_isolation_enforced, and
memory_limit_enforced to false, plus authoritative to true. For each case,
assert validate_publication_authority_report returns
MCL_PUBLICATION_AUTHORITY_REPORT_NOT_PASSED, preserving the existing
classification checks.
🤖 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/app.rs`:
- Around line 5602-5620: Extend
publication_authority_requires_an_explicit_passed_report to retain
classification as Passed while individually setting clean_checkout,
dependency_closure_complete, network_isolation_enforced, and
memory_limit_enforced to false, plus authoritative to true. For each case,
assert validate_publication_authority_report returns
MCL_PUBLICATION_AUTHORITY_REPORT_NOT_PASSED, preserving the existing
classification checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5d488c4c-a3cb-4903-a6e4-eac5d9c3220f

📥 Commits

Reviewing files that changed from the base of the PR and between 63da130 and 11f5c27.

📒 Files selected for processing (18)
  • .github/workflows/publication.yml
  • docs/decisions/ADR-0007-atomic-receipt-bound-publication-authority.md
  • docs/dev-diary/0035-a-witness-must-name-the-exact-thing.md
  • docs/dev-diary/README.md
  • docs/implementation/RELEASE_CHECKLIST.md
  • docs/implementation/STATUS.md
  • docs/trust/PUBLICATION_AUTHORITY.md
  • migrations/0011_publication_authority.sql
  • schemas/evidence/evidence-2.schema.json
  • scripts/publication-ingest.sh
  • src/app.rs
  • src/cli/mod.rs
  • src/domain/evidence.rs
  • src/domain/mod.rs
  • src/mcp/mod.rs
  • src/store/mod.rs
  • tests/mcp_stdio.rs
  • tests/phase1_cli.rs

@Mnehmos
Mnehmos commented Jul 20, 2026
Copy link
Copy Markdown
Owner Author

Addressed the final CodeRabbit test-coverage finding in 761171f.

publication_authority_requires_an_explicit_passed_report now keeps the report classification Passed while independently testing:

  • clean_checkout = false
  • dependency_closure_complete = false
  • network_isolation_enforced = false
  • memory_limit_enforced = false
  • authoritative = true

Every case fails closed with MCL_PUBLICATION_AUTHORITY_REPORT_NOT_PASSED; the existing rejected/failed classification cases remain covered.

Local validation on the exact commit:

  • cargo fmt --all -- --check
  • focused authority-report test
  • cargo test --workspace --all-targets (112 library, 1 Lean-worker, 3 MCP, 10 CLI)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • git diff --check

@Mnehmos
Mnehmos merged commit 0ef8a13 into main Jul 20, 2026
6 checks passed
@Mnehmos
Mnehmos commented Jul 20, 2026
Copy link
Copy Markdown
Owner Author

Exact merged-main publication-authority evidence

PR #36 merged as 0ef8a132dfb99e63238325ac035de948e893f791, tree f3ed084c9c495de68e20a5a9cdda818fd4637d6b. The reviewed PR head was 761171fb093cecc4b2391ac53ef89c315ff1eeea; PR CI run 29726454494 passed all five required jobs after the final test-only review fix.

Post-merge evidence:

  • Main CI run 29726693096, attempt 1, passed on the exact merge SHA. Jobs: real storage 88301342236, legacy Python 88301342238, pinned Lean 88301342242, Rust Ubuntu 88301342270, and Rust Windows 88301342459.
  • Protected publication run 29726693055, attempt 1, passed on the same SHA. Boundary job: 88301341952.
  • Retained artifact: 8454565233, publication-boundary-0ef8a132dfb99e63238325ac035de948e893f791, 82,717 bytes.
  • GitHub archive digest: sha256:fae9d075ab9fbd4388474ed51458e6707ba8b9e337f9b18800a8f86e19a0e828. A separate gh api download rehashed to the same SHA-256.
  • main reports protected:true; strict passage of the five named CI checks, pull requests, stale-review dismissal, conversation resolution, and admin enforcement remain enabled. Force pushes and deletions remain disabled.

Downloaded byte audit:

  • publication request: 3cfe3ebfa30e4446b659081cc8874ccbca684fd51d3b2c53a98b1534423a501c
  • publication policy: 5e9f69968913a7f1f716baa1a1e548f27d5d6958582e75278b37f3fac245f167
  • candidate report: 31934fcc89b045f04f57d4a0807c0f599d188887be56507f296a9fe4d8c9e643
  • retained closure: 20059d3ab54b2e075a7476250cf4de73f9a6c8196dd0005a7a96281d789c87df
  • candidate Sigstore bundle: 99850335bf53d095653fbf59b777cbcc9c33d6fe0a769d71f3c5b8701aa9b42f
  • canonical quarantine stage: 527e4db5e0852268e1eda4d9dc5aa0e32432c6ac76e2b06f130e16aac7dbc9c6
  • raw pinned-gh verification: 6adc6e41385249651adf372ece8334c650013b549093587891b36cafa7087453
  • canonical attestation-verification record and receipt identity: 56166a02475a1d47be9013a024693bc3228801ad98d62c65fca06e6aebd90e40
  • final authority evidence ID: 019f7e90-7adb-7f03-8e37-e591b13eac4d
  • canonical final evidence hash: dbaecfb7163476b98aead72d742891c7d8502494e81bf37e81aa5b214a9ef8cc
  • evidence kind/result/class: lean_kernel_proof / accepted / authoritative
  • authority timestamp/actor: 2026-07-20T08:07:05Z / publication-boundary
  • verified Rekor timestamp: 2026-07-20T08:06:54Z

The audit checked exactly 72 regular files with no symbolic links, all 25 fixed retained roles by canonical path/identity/byte hash, 24 sorted unique final artifact hashes after content deduplication, all eight empty stderr files, and 18 explicitly false authoritative booleans. The only authoritative semantic is the final evidence/2 payload's authority_class.

The final payload names formalization 019f7e90-4338-7473-9028-e4bded1f71b8 at version b9b56c5e754d42a7fddf72758d5683e1f3eeeabcbac3bb6f0f321548c51194e6, environment c6d7874c5bafa12e639f04db2a935d966aa742e2a5b4463a6cb688b4614fba1a, and declaration MathOS.Publication.smoke. It has no producing local run/job, no supersession, and no stale state. Its exact nine-field publication_authority_binding/1 matches the receipt, stage, report, closure, bundle, raw verification, request, and policy hashes above.

The certificate and SLSA statement bind immutable repository/owner IDs, the protected workflow, refs/heads/main, push event, exact merge commit, run/attempt, GitHub-hosted runner, and exact report subject. Candidate, stage, ingestion, validation, and verification records remain non-authoritative.

This completes issue #21's receipt-bound formal proof-authority boundary. It does not create source-claim proved status: derived truth remains unavailable until a separate read combines exact current authority with exact current verified statement fidelity and the remaining SPEC preconditions. MathOS 1.0 is not complete.

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.

Phase 3: define publication-profile proof authority and retained evidence

1 participant

0