8000 Add controlled attested Comparator evidence authority by Mnehmos · Pull Request #66 · Mnehmos/MathOS · GitHub
[go: up one dir, main page]

Skip to content
8000

Add controlled attested Comparator evidence authority - #66

Merged
Mnehmos merged 3 commits into
mainfrom
feat/65-comparator-authority
Jul 25, 2026
Merged

Mnehmos merged 3 commits into
mainfrom
feat/65-comparator-authority

Conversation

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

Summary - add the closed evidence/3 Comparator authority contract while preserving evidence/1 and evidence/2 canonical behavior - stage and replay the exact run, release, plan, policy, and attestation closure through immutable CAS-backed records - verify provenance with the pinned GitHub CLI, create a non-authoritative receipt, and promote only by receipt hash - enforce the gate independently in the application, Store transaction, SQLite trigger, and read-time projection checks - expose the same closed stage, ingest, promote, and currentness actions through CLI and MCP - run the path in the separate protected Comparator job and retain a database-independent portable audit closure ## Trust boundary The accepted Comparator report, workflow result, and attestation receipt remain structurally non-authoritative. Only receipt-bound application promotion derives accepted authoritative comparator_run evidence. Comparator evidence does not create Lean proof or refutation evidence, replace fidelity review, mutate proved or disproved status, or complete Pilot C. ## Local validation - cargo fmt --all -- --check - cargo clippy --workspace --all-targets --all-features -- -D warnings - cargo test --workspace --all-targets (187 library tests, 20 CLI tests, 4 MCP tests) - opt-in real Lean 4.32 worker integration - 39 legacy Python regressions - Bash syntax and ShellCheck 0.11.0 - Actionlint 1.7.12 - git diff --check ## Risk and recovery Migration 12 is additive and authority records are immutable by design. Before protected use, the change can be reverted normally. Once a receipt-bound authority record exists, recovery is quarantine plus exact replay; no manual database rewrite is an accepted path. Issue closure remains gated on exact-head CI, the protected same-run authority playtest, and an independent downloaded-artifact audit. Refs #65 ## Summary by CodeRabbit * New Features * Added controlled Comparator authority staging, attestation ingestion, promotion, and status reporting with current/stale outcomes. * Extended CLI and MCP verify actions to manage Comparator authority evidence end-to-end. * Introduced receipt-bound authoritative Comparator evidence and portable audit bundles for promoted results. * Documentation * Added/updated trust docs, ADR coverage, release guidance, and implementation status for the controlled authority workflow. * Bug Fixes * Strengthened protected validation with strict artifact/attestation/policy checks, canonical state snapshots, and anti-symlink/path-safety safeguards. * Tests / Chores * Added new fixtures, schemas, and migration coverage; updated CLI/MCP integration test expectations. ## Change class - [x] Class 3: Release, migration, or security-sensitive Affected trust boundary: Comparator attestation, immutable receipt creation, receipt-only promotion, evidence currentness, and protected portable auditability. ## TDD evidence - [x] Acceptance criteria were defined before implementation - [x] Focused failure-path tests drove the implementation - [x] The smallest coherent implementation made them pass - [x] Refactoring preserved passing behavior - [x] Relevant unit and integration suites pass - [x] Failure paths and boundary cases are covered Red evidence: adversarial Store/SQL/CLI/MCP tests rejected forged authority; review correction of only one encoded fixture made the exact protected parser fail until both source artifacts were rest 8000 ored. Green evidence: exact fixture hashes are asserted; 187 library, 1 Lean gate, 4 MCP, and 20 CLI tests pass with warnings-denied Clippy. ## Mathematical verification - [x] Candidate output was checked independently from its generator - [x] Formal proof passes the pinned checker - [x] Assumptions and dependency pins are recorded - [x] Artifact identifiers are linked in #65 Verifier and result: the accepted protected run is replayed from exact report, package, release, attestation, and tool pins. Comparator evidence cannot create Lean proof/refutation authority or set claim truth status. ## Provenance and licensing - [x] No new third-party code, data, model output, or dependency - [x] Generated artifacts retain tool versions, configuration, and hashes - [x] MathCorpus and RL export implications are unchanged and documented - [x] No credentials, private data, or access-controlled material are included Provenance references: protected run 29898749807, source 3a75ddc8bc5de685dc6425d6158791553be0ca40, report 42b29ecd69b222c26e1de47bed83f6e3e8df5910f35f1c2543a2d9ed72eb3198, package 7a3adfa8e30085cbda8ca240ab8288909a088d7ae0f9880ba0cc5b410645cc52, bundle a447696ceeb6e537c0bc6e5ebf81ab95d2e91006df57aa2bb632edc60d4cf0a5. ## Review readiness - [x] The branch is current with main - [x] The pull request addresses one coherent concern - [x] Required checks pass on the review-fix head - [x] Review threads are resolved - [x] Generated output is not represented as independently verified evidence

@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 commented Jul 22, 2026 •
Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a receipt-bound Comparator authority pipeline with strict schemas, immutable stage and receipt storage, replay-based promotion to evidence/3, CLI/MCP actions, protected workflow integration, portable audit output, fixtures, tests, and trust documentation.

Changes

Comparator authority

Layer / File(s) Summary
Authority contracts and integrity rules
migrations/0012_comparator_authority.sql, schemas/comparator/*, schemas/evidence/evidence-3.schema.json, src/domain/*
Defines Comparator authority types, schemas, evidence/3 validation, policy pins, immutable tables, and database integrity triggers.
Application orchestration and persistence
src/app.rs, src/store/mod.rs, src/comparator_authority.rs, src/publication_attestation.rs
Implements stage preparation, attestation verification, receipt registration, replay validation, CAS integrity checks, status calculation, and evidence promotion.
CLI, MCP, script, and protected workflow execution
src/cli/mod.rs, src/mcp/mod.rs, scripts/comparator-authority-ingest.sh, .github/workflows/publication.yml
Adds authority actions, safe path resolution, deterministic retries, portable audit packaging, canonical state snapshots, and protected job execution.
Interface and integration validation
tests/mcp_stdio.rs, tests/phase1_cli.rs
Tests action exposure, forbidden overrides, path bounds, missing stage/receipt errors, and migration version updates.
Trust model and release status documentation
docs/decisions/*, docs/trust/*, docs/implementation/*
Documents the authority lifecycle, evidence semantics, package and release status, validation evidence, and implementation readiness.

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

Possibly related PRs

  • Mnehmos/MathOS#22 — Updates the same publication boundary and attestation workflow surface.
  • Mnehmos/MathOS#61 — Provides the Comparator-ready package artifacts consumed by this authority flow.
  • Mnehmos/MathOS#64 — Provides the protected Comparator run bundle and report verification inputs used here.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.62% 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: adding controlled attested Comparator evidence authority.
Description check ✅ Passed The description covers the required template sections and includes summary, change class, validation, provenance, risk, and review readiness details.
✨ 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/65-comparator-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.

@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 (1)
scripts/comparator-authority-ingest.sh (1)

118-131: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Ingest step skips the dry-run parity check used for stage and promote.

Stage (Lines 90-91) and promote (Lines 159-160) both run a --dry-run invocation before the real/retry pair to validate the preview path is side-effect-free and deterministic. Ingest jumps straight to the real run, so an ingestion dry-run regression (e.g. accidental writes) wouldn't be caught here.

♻️ Mirror the stage/promote dry-run pattern
+"$mcl_bin" --root "$state_root" --json verify ingest-comparator-authority \
+  "${ingest_args[@]}" --dry-run >"$output_dir/ingestion-dry-run.json"
 "$mcl_bin" --root "$state_root" --json verify ingest-comparator-authority \
   "${ingest_args[@]}" >"$output_dir/ingestion.json"
 "$mcl_bin" --root "$state_root" --json verify ingest-comparator-authority \
   "${ingest_args[@]}" >"$output_dir/ingestion-retry.json"
🤖 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 `@scripts/comparator-authority-ingest.sh` around lines 118 - 131, Add a dry-run
invocation before the real/retry calls in the ingest step, matching the pattern
used by stage and promote. Use the same ingest arguments and state root, write
the preview output to the corresponding dry-run artifact, then preserve the
existing real invocation and byte-identical retry comparison.
🤖 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 `@docs/trust/RELEASES.md`:
- Around line 75-80: Clarify the authority statement near the referenced
“evidence/2” text so it applies specifically to portable-release
publication/proof authority, while preserving the separate Comparator evidence/3
authority model introduced in this paragraph. Distinguish the two scopes
explicitly and avoid implying that evidence/2 governs Comparator authority.

In `@fixtures/comparator/authority/pilot-a-attestation.json`:
- Line 1: Replace the mojibake checkpoint marker “—” in the Rekor checkpoint
envelope within the attestation fixture with the expected em dash “—”,
preserving all other protected-bundle bytes unchanged.

In `@src/app.rs`:
- Around line 3788-3809: Remove the MCL_COMPARATOR_AUTHORITY_POLICY_CHANGED
match arm mapping to ComparatorAuthorityStaleReason::PolicyChanged in the
stale_reason match within comparator_authority_status. Preserve the existing
replay_comparator_stage policy-drift error behavior and continue propagating
unmatched errors through the default branch.

In `@src/store/mod.rs`:
- Around line 6923-6937: Strengthen the comparator read-time validation
condition around stored receipt integrity by validating receipt_byte_size with
validate_publication_input_size, matching the checks in
read_publication_ingestion_receipt. Preserve the existing equality and other
integrity comparisons, while ensuring oversized or zero receipt sizes fail
closed.

---

Nitpick comments:
In `@scripts/comparator-authority-ingest.sh`:
- Around line 118-131: Add a dry-run invocation before the real/retry calls in
the ingest step, matching the pattern used by stage and promote. Use the same
ingest arguments and state root, write the preview output to the corresponding
dry-run artifact, then preserve the existing real invocation and byte-identical
retry comparison.
🪄 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: a9a4ea7b-b6b4-4777-98fa-6bf15d413087

📥 Commits

Reviewing files that changed from the base of the PR and between 3a75ddc and bd5f4e4.

📒 Files selected for processing (30)
  • .github/workflows/publication.yml
  • docs/decisions/ADR-0016-controlled-comparator-evidence-authority.md
  • docs/implementation/RELEASE_CHECKLIST.md
  • docs/implementation/STATUS.md
  • docs/trust/COMPARATOR_AUTHORITY.md
  • docs/trust/COMPARATOR_PACKAGES.md
  • docs/trust/RELEASES.md
  • fixtures/comparator/authority/pilot-a-attestation-verification-raw.json
  • fixtures/comparator/authority/pilot-a-attestation.json
  • fixtures/comparator/authority/pilot-a-report.json
  • migrations/0012_comparator_authority.sql
  • policies/comparator-authority-1.json
  • schemas/comparator/comparator-attestation-verification-1.schema.json
  • schemas/comparator/comparator-authority-policy-1.schema.json
  • schemas/comparator/comparator-authority-stage-1.schema.json
  • schemas/comparator/comparator-authority-status-1.schema.json
  • schemas/evidence/evidence-3.schema.json
  • scripts/comparator-authority-ingest.sh
  • src/app.rs
  • src/cli/mod.rs
  • src/comparator_authority.rs
  • src/domain/comparator_authority.rs
  • src/domain/evidence.rs
  • src/domain/mod.rs
  • src/lib.rs
  • src/mcp/mod.rs
  • src/publication_attestation.rs
  • src/store/mod.rs
  • tests/mcp_stdio.rs
  • tests/phase1_cli.rs

Comment thread docs/trust/RELEASES.md Resolved
Comment thread src/app.rs Resolved
Comment thread src/store/mod.rs Resolved
@Mnehmos
Mnehmos commented Jul 25, 2026
Copy link
Copy Markdown
Owner Author

Review follow-up 2ae2ac3 also adds the missing ingestion dry-run invocation before the persisted/retry pair. Bash syntax, ShellCheck 0.11.0, formatting, warnings-denied Clippy, and the full 187-lib/1-Lean/4-MCP/20-CLI Rust suite pass locally.

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

Cross-platform follow-up 4422168 fixes the Windows-only cryptographic fixture checkout drift by marking the protected Comparator fixture set as byte-preserved Git inputs. A local core.autocrlf=true checkout reproduced both protected hashes, and exact-head CI run 30172477751 now passes all five required jobs, including Windows.

@Mnehmos
Mnehmos merged commit 3e199a8 into main Jul 25, 2026
6 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