8000 Produce protected publication candidates by Mnehmos · Pull Request #31 · Mnehmos/MathOS · GitHub
[go: up one dir, main page]

Skip to content

Produce protected publication candidates - #31

Merged
Mnehmos merged 5 commits into
mainfrom
feat/protected-publication-candidate
Jul 20, 2026
Merged

Mnehmos merged 5 commits into
mainfrom
feat/protected-publication-candidate

Conversation

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

Outcome

  • Produces a real canonical publication_request/1 and non-authoritative publication_report/1 from a fresh no-import Lean lifecycle.
  • Retains a closed 25-role publication_retained_closure/1 with fixed paths, semantic identities, exact byte hashes, local evidence, protected rebuild output, parser-derived dependency output, and axiom-audit output.
  • Adds mcl verify validate-publication-candidate, which replays the retained chain, Store/CAS snapshots, policies, jobs, reports, logs, protected dependencies, and axioms, then dry-run re-derives the request without promotion.
  • Exercises the producer in simulated pull-request CI and attests/challenges the exact candidate report only in the protected main workflow.
  • Preserves bounded structured attempt diagnostics and available CAS bytes on failures.

Trust-boundary corrections

Security review found that main was not actually protected. Using gh api, repository protection now requires pull requests, strict passage of all five CI jobs, resolved conversations, stale-review dismissal, and admin enforcement; force-pushes and deletions are disabled. Both the workflow and script also fail unless GitHub reports the main ref as actively protected.

Review also found that line-based import detection missed valid Lean forms such as comment-prefixed imports. The candidate now runs pinned Lean --deps inside Bubblewrap, retains the raw output, clears the inherited environment, and accepts only the implicit pinned /opt/lib/lean/Init.olean closure with empty matching manifests.

Additional fail-closed fixes cover failed git status, oversized decimal run identities, symlinked/out-of-root inputs, output-path aliases, wall-clock/memory/output bounds, and structured protected-execution failures.

CodeRabbit's final hardening review was addressed by binding both attestation action outputs through step environment variables instead of interpolating them into privileged shell bodies.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace --all-targets - 102 tests passed
  • MCL_RUN_LEAN_INTEGRATION=1 cargo test --test lean_worker -- --nocapture
  • PYTHONPATH=src PYTHONWARNINGS=error::ResourceWarning python -m unittest discover -s tests -v - 39 tests passed
  • Bash syntax for all publication scripts
  • Actionlint 1.7.12 and YAML parsing
  • CLI help surfaces, mcl init, mcl health, and mcl doctor
  • Two independent adversarial/security reviews plus CodeRabbit
  • git diff --check

Final exact-head CI: run 29716143032; all five required jobs passed and CodeRabbit completed.

  • Head commit: 2752340bd32bf5eaef7b9bac10ae7a1fe81bb99c
  • Tree: 7508582f4ac01b6cd4533c135d7da5f238ad2149
  • Tested PR merge commit: b4cb29c908537ad0a46e8df7a24ee09f1c6c2dfa
  • Candidate request: c4caee527389958d0c1a558debab4cb3f070e03a706f178079567a6d72a1244b
  • Retained closure: 0ba5266fc5c208b961efb64b4ab09b05d81802222dfe17038df8cba51ecbadc8
  • Publication report: fb40d86eab3030e61da432898530b3582b3cc38c5898cdbd5b06d2687222b6a6
  • Candidate result: authoritative:false

Run 29714982064 retained a thread-creation failure under the initial 4 GiB process ceiling. Run 29715179869 proved the corrected protected rebuild/dependency/axiom path, retained its bounded failed attempt artifact, and exposed a direct-job-snapshot selector error. Both findings were repaired before the green runs.

Non-goals

Every report, validation result, attempt record, and attestation-verification record remains authoritative:false. This PR does not ingest downloaded attestations, create authoritative proof/refutation evidence, or derive mathematical truth status.

Advances #21.

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

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds a retained-closure contract and protected publication-candidate lifecycle. It implements strict application and CLI validation, creates isolated candidates with bounded Lean execution, updates protected workflows and artifact retention, and documents the resulting authority-boundary requirements.

Changes

Publication candidate lifecycle

Layer / File(s) Summary
Retained closure contract and fixtures
src/domain/publication.rs, src/domain/mod.rs, schemas/publication/..., fixtures/environment/...
Defines fixed retained-artifact roles, schema validation, request bindings, closure hashing, and the no-import Lean environment fixture.
Candidate validation pipeline
src/app.rs
Validates canonical reports and closures, retained file hashes and semantics, protected dependency output, store consistency, and request re-derivation while returning authoritative: false.
Candidate validation CLI and input boundaries
src/cli/mod.rs, tests/phase1_cli.rs
Adds mcl verify validate-publication-candidate with safe path handling and bounded reads, including oversized-input coverage.
Isolated candidate producer
scripts/publication-candidate.sh
Builds evidence and requests, runs protected Lean rebuild/dependency/audit phases, creates the retained closure and report, and self-validates the candidate.
Protected workflow enforcement and evidence
.github/workflows/ci.yml, .github/workflows/publication.yml
Adds isolation tooling checks, protected-main enforcement, candidate generation, attestation verification, and expanded artifact retention.
Publication boundary documentation
docs/decisions/..., docs/trust/..., docs/implementation/..., docs/dev-diary/...
Records retained-closure requirements, protected candidate behavior, validation status, release evidence, and the new diary entry.

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

Possibly related issues

  • Mnehmos/MathOS issue 21 — The PR implements the Phase 3 publication-authority boundary through retained closures, protected workflows, and non-authoritative candidate validation.

Possibly related PRs

  • Mnehmos/MathOS#22 — Shares the publication-boundary workflow and Bubblewrap isolation setup; this PR replaces the earlier smoke path with candidate generation.
  • Mnehmos/MathOS#30 — The new candidate validator re-derives and checks publication requests produced by the request-preparation path.

Sequence Diagram(s)

sequenceDiagram
  participant ProtectedWorkflow
  participant PublicationCandidate
  participant LeanSandbox
  participant MCL
  participant AttestationVerifier
  ProtectedWorkflow->>PublicationCandidate: provide protected workflow context
  PublicationCandidate->>MCL: prepare request and evidence
  PublicationCandidate->>LeanSandbox: execute protected rebuild and audits
  LeanSandbox-->>PublicationCandidate: return bounded execution evidence
  PublicationCandidate->>MCL: generate and validate retained closure
  ProtectedWorkflow->>AttestationVerifier: attest and verify publication report
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is off-template and omits many required sections such as Change class, TDD evidence, risk/recovery, and review readiness. Rewrite the PR description to follow the repository template and fill in each required section with concrete details, evidence, and rollback notes.
✅ Passed checks (3 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 highlights the main change: producing protected publication candidates.
✨ 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/protected-publication-candidate

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 commented Jul 20, 2026
Copy link
Copy Markdown
Owner Author

Hosted failure retained before repair:\n\n- CI run: https://github.com/Mnehmos/MathOS/actions/runs/29714982064\n- job: https://github.com/Mnehmos/MathOS/actions/runs/29714982064/job/88266362527\n- exact PR head: 7d4bbdc\n- successful before failure: pinned Lean installation, real local Lean integration, prior isolation smoke, protected candidate rebuild, and protected parser-derived dependency scan\n- failing stage: verifier-controlled ProtectedAudit.lean\n- retained log: libc++abi: terminating due to uncaught exception of type lean::exception: failed to create thread\n- script result: stable exit 70, classified execution_failed\n\nThe four-gibibyte process address-space limit was sufficient for the smaller rebuilds but not the axiom-driver runtime/thread overhead. I am preserving a four-gibibyte Lean heap cap while raising the OS address-space ceiling to six GiB, and adding failed-attempt artifact upload to PR CI. No check is being bypassed and no authority is created.

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

Second hosted failure retained and inspected:

  • CI run: https://github.com/Mnehmos/MathOS/actions/runs/29715179869
  • job: https://github.com/Mnehmos/MathOS/actions/runs/29715179869/job/88266955678
  • failed-attempt artifact: 8450312976
  • GitHub archive digest: sha256:8976c4a151487bae6b414e605216fcd86c1bfe99dd792afb2cc505d0c9e145db
  • attempt-summary SHA-256: 6bb4225231c8ca6f2230dd48ce81e9833a543d6770551d293ab2f8d478c8e43b
  • protected-audit execution-record SHA-256: 2b88621744afd82c5f711481870dfb57d98e727276f42446f5f145c67d6d26f3
  • protected dependency stdout SHA-256: 2e350d051f4180d906decf117cb97b26fd4238b8e206cb5c0d377660cdef27c9
  • protected axiom stdout SHA-256: e2a1650b6ef5ad761df19724de654942791280743a79b9eebd97686c5c2cada6

The memory repair is confirmed: protected rebuild, lean --deps, and controlled #print axioms all passed; only implicit /opt/lib/lean/Init.olean was observed and the declaration reported no axioms.

The remaining failure is a JSON-shape bug after those controls: verify status returns a direct job snapshot, while the producer selected .job.result_artifact_hash, yielding null. The correction extracts .result_artifact_hash, .request.policy_hash, and .canonical_input_hash directly and validates each as lowercase SHA-256 before use.

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

Final pre-merge evidence for the exact current head:

  • CI run: https://github.com/Mnehmos/MathOS/actions/runs/29715543650
  • Required jobs: all five passed
  • Head commit: 85b5a81b4fbd218bbe6bb38709791a0258f14950
  • Tree: f18b938abced334689ce4db49eabb65b07b9ac04
  • Tested PR merge commit: 20efcdbf526a57954a7173d5ecf96cd1afab85e0
  • Candidate request: eb010ed504a7d2f9010ab8039ba99a50aed5b36c41675cf9d3fbbbeb04170dd8
  • Retained closure: e7166f4fb8dd32c18b0ef809907fb6aeb57a0a4785cea7a1f447c2cd50fbc877
  • Publication report: 25f797d40612e12cf7fd897a9f20b7532b86b4ba2117f11facfaf1cf5ff30949
  • Result: authoritative:false

The two earlier hosted failures remain documented in this PR and were repaired before this green run. Merge will use an exact-head guard; the protected-main publication artifact will be inspected separately after merge.

@Mnehmos
Mnehmos marked this pull re 8000 quest as ready for review July 20, 2026 03:57
@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)
.github/workflows/publication.yml (1)

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

Pass the attestation bundle path through env instead of interpolating ${{ }} into the run script.

${{ steps.attest_candidate.outputs.bundle-path }} is expanded directly into the shell body of a step in a job that holds id-token: write and attestations: write. Even though this output originates from the trusted actions/attest step, injecting expression results into run: is the pattern static analysis flags; binding it to an env var and referencing the shell variable removes the interpolation surface. The same pattern also exists (unchanged) at Line 96 for the smoke path.

🔒 Proposed hardening
       - name: Verify exact candidate attestation and retain the challenge result
         shell: bash
         env:
           PUBLICATION_GH_BIN: ${{ runner.temp }}/gh_2.96.0_linux_amd64/bin/gh
+          CANDIDATE_BUNDLE_PATH: ${{ steps.attest_candidate.outputs.bundle-path }}
         run: |
           scripts/publication-attestation-verify.sh \
             "${RUNNER_TEMP}/publication-candidate/publication-report.json" \
-            "${{ steps.attest_candidate.outputs.bundle-path }}" \
+            "${CANDIDATE_BUNDLE_PATH}" \
             "${RUNNER_TEMP}/publication-candidate-attestation-verification"
🤖 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/publication.yml around lines 120 - 128, Update the
attestation verification steps around “Verify exact candidate attestation and
retain the challenge result” and the corresponding smoke-path step to pass the
attest_candidate bundle-path output through the step’s env block, then reference
the shell environment variable in each run script instead of interpolating the
GitHub expression directly.

Source: Linters/SAST tools

🤖 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 @.github/workflows/publication.yml:
- Around line 120-128: Update the attestation verification steps around “Verify
exact candidate attestation and retain the challenge result” and the
corresponding smoke-path step to pass the attest_candidate bundle-path output
through the step’s env block, then reference the shell environment variable in
each run script instead of interpolating the GitHub expression directly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3dad79c0-5a45-4ef9-9c10-767284da61cc

📥 Commits

Reviewing files that changed from the base of the PR and between da33431 and 85b5a81.

📒 Files selected for processing (18)
  • .github/workflows/ci.yml
  • .github/workflows/publication.yml
  • docs/decisions/ADR-0006-oidc-attested-publication-authority.md
  • docs/dev-diary/0034-a-proof-must-travel-with-its-luggage.md
  • docs/dev-diary/README.md
  • docs/implementation/RELEASE_CHECKLIST.md
  • docs/implementation/STATUS.md
  • docs/trust/PUBLICATION_AUTHORITY.md
  • fixtures/environment/lean-4.32-no-imports-local.json
  • fixtures/environment/lean-4.32-no-imports-local.sha256
  • schemas/publication/publication-retained-closure-1.schema.json
  • scripts/publication-candidate.sh
  • src/app.rs
  • src/cli/mod.rs
  • src/domain/environment.rs
  • src/domain/mod.rs
  • src/domain/publication.rs
  • tests/phase1_cli.rs

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

Addressed the review hardening in 2752340bd32bf5eaef7b9bac10ae7a1fe81bb99c:

  • smoke bundle output now enters the shell only through SMOKE_BUNDLE_PATH
  • candidate bundle output now enters the shell only through CANDIDATE_BUNDLE_PATH
  • direct [object Object] interpolation was removed from both privileged run: bodies
  • Actionlint 1.7.12 and git diff --check pass

No review thread was created. The exact new head is now running the full protected check suite.

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

Exact review-fixed head is green and ready for the guarded merge:

  • CI run: https://github.com/Mnehmos/MathOS/actions/runs/29716143032
  • Head: 2752340bd32bf5eaef7b9bac10ae7a1fe81bb99c
  • Tree: 7508582f4ac01b6cd4533c135d7da5f238ad2149
  • Tested PR merge commit: b4cb29c908537ad0a46e8df7a24ee09f1c6c2dfa
  • Request: c4caee527389958d0c1a558debab4cb3f070e03a706f178079567a6d72a1244b
  • Closure: 0ba5266fc5c208b961efb64b4ab09b05d81802222dfe17038df8cba51ecbadc8
  • Report: fb40d86eab3030e61da432898530b3582b3cc38c5898cdbd5b06d2687222b6a6
  • Validator result: authoritative:false

All five required jobs passed; CodeRabbit completed on this head; there are no inline review comments or unresolved conversations.

@Mnehmos
Mnehmos merged commit 55a0ae0 into main Jul 20, 2026
6 checks passed
@Mnehmos
Mnehmos deleted the feat/protected-publication-candidate branch July 20, 2026 04:11
@Mnehmos
Mnehmos commented Jul 20, 2026
Copy link
Copy Markdown
Owner Author

First protected-main candidate run after merge failed closed and was retained:

  • source commit 55a0ae0fad9fe5cfd20ed0a5fbddf6b80a5303c1
  • tree 7508582f4ac01b6cd4533c135d7da5f238ad2149
  • publication run https://github.com/Mnehmos/MathOS/actions/runs/29716292659
  • job 88270125287
  • failed artifact 8450708477
  • archive digest sha256:29c70446a4ba089b44621b254bd6ff54ca3a109a836ff8c60a4525e8e7059c27

The protected-ref workflow gate passed, as did smoke execution, smoke attestation, and the constrained smoke challenge. Candidate construction then exited 65.

Root cause: the script's report constant RUNNER_ENVIRONMENT=github_hosted shadowed GitHub's immutable RUNNER_ENVIRONMENT=github-hosted, making the protected-only runner comparison unsatisfiable. PR #32 contains the two-line identifier repair and a matching/self-hosted fail-closed context test. No check is bypassed and no authority is created.

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

Protected candidate production is now complete and independently inspected.

Exact merged source:

Downloaded candidate audit:

  • canonical request: 9f32d3eca940100b92f6ceb91e975fb859f99c1cf97fb98ae859e6cd79419103
  • 25-role retained closure: ff67bc6f101681ff5c8345c763036ca1c07caed4eec714ba8c35f5017a5c28e3
  • publication report: 12f0aaca0f6e9a16c242205da24f53fadc08ba9177cff6e039ec394c50ee1012
  • retained validator result: 1d5adfc932ffa566f859c45caba62d97443e80ee1a3eb4532f792e5ca69362c0
  • attempt summary: 503c86845b6e0a78fa3712b9cf999f78203c15df2550356e3965a12944740ea5
  • candidate Sigstore bundle: a23d190fdaffe7e87fc98747b32525f96f199aa05f5431cba39548b38207a84e
  • raw pinned-gh verification: 1e6063a8ca1ef58476992d8691f702cc39d547ce94d82ebf90a848eef75d549a
  • constrained verification record: 93871363affcfcc6a36d954577779de5791752d2951340c90f77df095c81ce3a
  • verified Rekor timestamp: 2026-07-20T04:22:41Z

Inspection confirmed exactly 25 sorted fixed-path closure members and all member hashes; source commit/tree/run/attempt agreement; clean checkout; GitHub-hosted protected main; enforced network, memory, time, and output controls; empty environment/formalization imports; protected dependency output containing only /opt/lib/lean/Init.olean; one exact no-axioms result in both local and protected audits; seven intact retained CAS objects; three passed protected execution records; report-subject digest agreement; SLSA v1 predicate; exact workflow certificate identity; exact source commit/ref; GitHub-hosted runner; and one verified timestamp.

The report, attempt, validator result, and constrained attestation record all remain authoritative:false. This completes candidate production and retained evidence only. Controlled ingestion, authoritative proof/refutation evidence, and mathematical-status derivation remain unavailable.

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