Skip to content

Source-to-Exported Manufacturing Artifact Proof — Design Contract

Current tracking status (2026-11-18): #771 is closed as an implementation tracking issue. Independent real-customer/source-to-fabrication acceptance remains open under #1197, #154, and #1161. The dated section below preserves the original October evidence and is not a current acceptance claim.

Historical status (2026-10-12): #771 remains OPEN. The opt-in target-repository export/signing workflow and strict CLI policy are implemented; one independently owned public-repository run generated and signed real KiCad manufacturing outputs, subsequently verified against 27 subjects. This is not two-private-installation acceptance (#154), a customer-facing GA trust badge, or a production/release approval. Coordinate #756 and #753.

The user question

Did these exact fabrication bytes come from the source commit I am approving?

A structurally valid Gerber set can be months older than the KiCad board in the same review. A file hash can establish consistency with a manifest; a self-reported commit value does not establish who generated the bytes. Gerber X2 TF.CreationDate and Git commit timestamps are informational, not source-to-export evidence. A legitimate re-export of unchanged source may have a newer timestamp.

The user-facing outcome must not say “provenance verified” unless the source commit, generation execution and output bytes are all bound by a trusted execution identity. Missing or unsupported evidence must be clearly advisory, not a falsely exact PASS or a fabricated blocking stale-export allegation.

Historical starting surfaces and gaps (audited at dfde5490)

  • src/release/generate.ts writes a GenerateManifest (schema version 1) with optional git.sha, recipe.hash, KiCad version, and generated artifact hashes. It does not record the sourceFingerprint expected by src/core/provenance.ts.
  • src/core/provenance.ts:verifyExportProvenance verifies a source fingerprint and hashes listed artifacts but compares a Git SHA only when the caller supplies currentGitSha.
  • src/rules/release/artifact-provenance.ts calls the verifier without currentGitSha. Its normal manifest candidate is build/boardreadyops-generate/manifest.json, which is currently a different manifest contract. A self-claimed git.sha must not be treated as authenticated.
  • The release evidence-bundle manifest.json is another schema (version 2). release sign/verify can validate a pinned signer and included bytes; that alone does not prove the exporter used the reviewed KiCad source. An optional --provenance-attestation URI is not equivalent to the CLI independently verifying the attestation.

Do not conflate these three manifests or promote their existing “verified” statuses into a stronger source-commit attestation.

Chosen trust levels for implementation

Level Preconditions UI / gate behavior
Source-bound verified Pinned reviewed commit, clean source-input fingerprint, actual same-run KiCad generation, complete output set and hashes, independently validated trusted workflow identity/attestation “Generated from this source revision” with exact SHA, workflow and artifact digest evidence; may satisfy a separately enabled strict release policy
Byte-consistent only All listed artifact digests and source files agree with a self-reported manifest, but no trusted generator-to-commit execution attestation “Package files are internally consistent; source-to-export link not verified”; never satisfy strict source-bound policy
Unverified / insufficient Missing, unsupported or incomplete manifest, external upload without provenance or unsupported toolchain Actionable low-confidence advisory with reason and recommended verified-export path
Contradictory / tampered Trusted attestation subject mismatch, pinned commit mismatch, changed/missing declared outputs, source fingerprint mismatch or prohibited path traversal Explicit mismatch and evidence; release may block according to reviewed policy, not timestamp heuristics

These are future product semantics. Do not silently relabel the current release.artifact-provenance finding as source-bound verification.

Authoritative same-run workflow (first supported strong path)

  1. The target repository GitHub Actions job resolves the immutable commit being reviewed, installation/repository identity and attempt binding (not an unchecked mutable branch name, unrelated fork or synthetic merge SHA). Reject a dirty or ambiguous KiCad input state before generation.
  2. Snapshot and hash the explicit KiCad input set with normalized root-relative paths and bytes. Record the resolved KiCad CLI binary/version and canonical recipe/options hash. Re-check the source fingerprint after generation to detect in-run changes.
  3. Run kicad-cli in that job into an empty, controlled output root. Do not accept pre-existing fab/ files as proof that a new export ran. Enumerate every output; record normalized paths, SHA-256 and sizes. Reject path escapes, symlink hops and unlisted/additional outputs under strict coverage.
  4. Write an unambiguous export-provenance manifest with a discriminator (e.g. kind: boardreadyops.export-provenance), its own version, source repository/commit/input fingerprint, generator recipe/toolchain, output hash set, and execution identity/attempt. Do not confuse this version with the release evidence-bundle schema.
  5. Bind the manifest and the output artifact set to the trusted job using a verifiable GitHub Artifact Attestation or equivalent trusted signing mechanism. The verifier must validate issuer, repository, workflow/run identity, immutable reviewed commit and attested subject digest against the actual bytes; a URL string alone is insufficient.
  6. Verification independently recomputes all input/artifact hashes from the appropriate scoped workspace and compares the pinned review SHA. Only after all links pass may the result be source-bound verified. Failure/timeout/lost attestation must fail closed to uncertainty or mismatch, without inventing success.

Preserve the existing target-repository runner authority (ADR-0010); do not introduce a managed central worker fleet or a new long-lived credential path. Fork and unrelated-installation jobs must not borrow a different installation's trusted status. Respect scoped OIDC, nonce, attempt/replay and tenant authorization contracts.

Existing outputs, offline teams and UX

Teams often upload manufacturing packages exported on their workstation. They must still be able to inspect Gerber, drill, geometry and vendor rules. Present a Byte-consistent only or Unverified status when the exporter-to-reviewed-commit link is absent, rather than blocking every legitimate manual re-export or falsely blessing it. The UI should show source SHA, export time (informational), KiCad version, artifact digest, linked GitHub run if independently verified, the reason trust is limited, and one clear “Generate from this commit” workflow affordance. A source mismatch is not inferred from timestamps.

An unsigned export manifest supplied alongside its Gerbers is an untrusted assertion even if the checksum list agrees. A local signed bundle establishes integrity only relative to an independently trusted public key; it is not automatically equivalent to a trusted review-run identity.

Real KiCad byte-inventory integration evidence (not signed provenance)

tests/integration/manufacturing-real-kicad-provenance.test.ts runs actual KiCad 10.0.x kicad-cli Gerber and Excellon export against a temporary, locally committed fixture. It checks the manifest against actual hashes and exercises wrong reviewed SHA, tampered Gerber bytes, a missing drill output, unlisted artwork and changed KiCad source. The existing KiCad 10 CI integration matrix runs this regression; local runs may skip when KiCad 10.0.x is absent. A locally created Git commit and self-reported manifest are not an attestation. This test establishes only byte consistency and negative-case coverage. It does not satisfy the separate signed, independently verified exact-commit/source/ workflow/run-attempt requirements of #771 or the two distinct installations of #154. No new source-bound “verified” UI or release PASS is authorized by this integration check.

Reviewed-commit local export guard (pre-attestation prerequisite)

The runGenerate library accepts an opt-in reviewedSourceSha (a full lowercase 40-character SHA) for trusted-runner development. Before deleting anything or invoking KiCad, it requires the explicit root to be the actual Git checkout top level, its HEAD to equal the pinned SHA, a clean worktree (including untracked files), both Gerber and drill steps, source files inside the root and an empty output directory. It rechecks the source snapshot, Git state, step outcomes and actual file inventory after generation. All fingerprinted KiCad source files must be tracked by that Git commit, including files that Git would otherwise silently ignore. A dirty, stale, incomplete, or byte-inconsistent run throws rather than emitting a successful result. For this first implementation, output must be a separate, Git-ignored directory inside the checkout because the local verifier requires an in-root manifest. An external output directory is rejected before writing, not silently promoted or moved across the trust boundary.

Security limit: reviewedSourceSha is supplied by the caller. A local Git assertion alone cannot authenticate the installation, issuer, GitHub workflow, run attempt or code that performed the export; it cannot create a signed attestation. The guard does not enable a user-facing source-bound verified state, alter manual/offline workflows or lift any strict production HOLD. Only a separately verified GitHub/Sigstore attestation over the manifest AND actual outputs with independently checked runner provenance can do so.

Required acceptance before changing the release gate

  • Valid unchanged source re-exported later must not be flagged stale based on time alone.
  • Stale but well-formed Gerber/drill outputs from an old source revision must not receive source-bound verified status.
  • Mutated KiCad input after generation, wrong git.sha, dirty checkout, moved/refetched PR SHA, fork cross-installation and replayed attempt must fail the strong trust boundary.
  • Added, missing, truncated, reordered or replaced artifact bytes, path traversal, symlinks and mismatched attestation subjects must not be accepted as a complete trusted set.
  • Generator schema, verifier input and rule acceptance must agree; migration of old manifests is explicit and does not silently upgrade their trust.
  • Manual/offline uploaded packages remain inspectable with honest advisory status and a UI-visible way to request an authoritative export.
  • Unit, adversarial, targeted GitHub Actions integration and two-unrelated-installation acceptance tests must pass, with both positive proof and deliberately forged near-misses.

Delivery phases

Phase 1 — contract and compatibility: align generator, source fingerprint and verifier with a discriminated export schema. Define source-root discovery and Git environment sanitation. Add positive/negative tests. Preserve older manifests as limited trust rather than returning strong verified from optional fields.

Phase 2 — source-bound attestation: trusted target-repository, SHA-pinned same-run export + manifest/artifact subject verification, with issuer/repository/run constraints and replay protection. Fail closed on provider or toolchain uncertainty.

Phase 3 — customer-facing release decision: tenant-scoped policy choice and clear UI trust levels, audit trail and evidence navigation; strict block only when the approved strong policy applies. Document source-bound gate eligibility and manual-upload downgrade.

This design does not assert implementation, signed manufacturing attestations, or general availability. Track actual completion through issue #771 and exact-head CI evidence.

Phase 2 library prerequisite: verify the attested export subject set

The opt-in src/release/export-attestation.ts library now provides two non-release primitives. prepareExportAttestationChecksums rechecks a clean, pinned export manifest and writes no files; its returned SHA-256 checksums text covers manifest.json and every Gerber, drill, and other generated output with root-relative subject names. An authorized target-repository job may write that text to a separate checksums file outside the generated-output tree and pass it to the officially supported actions/attest subject-checksums input. The action supports at most 1,024 subjects, enforced by the helper.

verifyReviewedExportAttestation takes independently authorized expected repository name and numeric ID, reviewed commit SHA, source ref, workflow path, triggering event, run ID and run attempt. It first verifies actual KiCad source bytes and the complete generated output inventory. It then runs gh attestation verify with the exact repository, signer workflow, signer/source commit digests, source ref, GitHub OIDC issuer, GitHub-hosted runner requirement and the manifest's actual bytes. It accepts a result as an eligible piece of proof only when the cryptographically verified certificate also binds the expected repository ID, workflow, source commit, ref, event, run/attempt, and the signed statement includes exactly the manifest and every actual output hash, with no duplicates or extra subjects.

Signing checksum preparation also re-verifies the complete source fingerprint and generated-output inventory after hashing the subjects, and re-hashes the manifest before returning. It refuses a source mutation, unlisted output, or manifest edit observed across the preparation window. This is a local pre-signing integrity check, not a workspace lock: the authorized runner must still keep its checkout and output directory quiescent through the actual OIDC signing call.

After the external gh attestation verify process completes, the local verifier re-reads the pinned source and full output inventory and refuses an eligible result if files were added, removed, modified or replaced while the cryptographic check ran. The signature and initial checksums alone cannot bless a workspace that changed during a long-running verification. This is a defense-in-depth local consistency check, not a replacement for a trusted run identity or a production release approval.

The expected identity values must come from an independently authorized target-repository installation/run record and a reviewed workflow. They must never be copied from the unsigned export manifest, untrusted workflow output, a browser request, or an incoming callback. Verification of an arbitrary attestation or a URL is not an authority check. The signed subject list cannot substitute for a safe generator job: it must follow the opt-in reviewedSourceSha preflight and recheck a clean and immutable source before signing. A mutable checkout, other-repository workflow, PR synthetic merge, untrusted fork, self-hosted job, or reused run attempt is not accepted as the trusted path merely because a signature exists.

Important availability limit (checked 2026-10-10): GitHub's native actions/attest supports public repositories on standard current plans, but private/internal repositories require GitHub Enterprise Cloud. That is not a general-purpose private-customer fallback. An alternate independently authenticated signing/verifier transport for non-Enterprise private targets is not implemented; do not promise or automatically enable a source-bound gate there. Official references: GitHub attestation requirements, actions/attest, and GitHub CLI verification policy.

Current status: the library prerequisites above have been exercised by a real GitHub-hosted, protected-branch target workflow with an OIDC-signed manufacturing export in one independently owned public repository. Independent verification of that run's 27 manifest/Gerber/drill subjects and adversarial near-misses is recorded in #771. This does not establish two-private-installation isolation (#154), a general customer-facing strong verification state, or release/GA approval. A positive library result alone must not grant a tenant-facing badge.

Opt-in target-runner export and signature path (one public canary; not GA)

The reviewed manufacturing export runbook now documents a separately packaged composite Action and a target-repository workflow_dispatch template under examples/github/workflows/. The caller pins the immutable BoardReadyOps action commit; its protected, GitHub-hosted target job checks out the exact github.sha, runs real KiCad 10 Gerber and Excellon generation with the opt-in reviewedSourceSha guard, recomputes a manifest-plus-every-output checksum set and invokes SHA-pinned actions/attest inside the target repository using that job's OIDC. The associated CLI supports independent credentialed gh attestation verify against explicit owner-authorized repository/run/attempt expectations.

A separately owned public canary followed this contract in target workflow run #38026832338: protected main source 61473d6b7c2f3beb6daa0dcba191f4ea61ce04c9, GitHub-hosted workflow_dispatch, real KiCad generation and GitHub OIDC signing. The documented independent verification matched all 27 signed manifest/Gerber/drill subjects and rejected wrong repository, run, attempt, source and modified output evidence. This is one real public example, not two unrelated private installation owners or complete customer acceptance.

For a new target, the workflow template still requires independently reviewed immutable Action pin and real project path; never execute a mutable ref. Private/internal native signing is Enterprise Cloud-gated; unsupported private targets remain unverified. The opt-in CLI strict policy exists, but no global GA trust level, automatic dashboard badge, release pack approval or production policy is authorized. #771 and #154 remain open.

Phase 3 bounded CLI policy prerequisite (not GA)

The opt-in policy.rules[].type: require-source-bound-export now connects the independently verified signed export primitive to the explicit boardreadyops policy command and its advisory/enforced exit code. The signed subject certificate and actual artifact bytes must match the separately authorized repository/run identity; an unsigned manifest alone can only be byte-consistent-only, never source-bound-verified. This does not automatically change release pack, production deployment, dashboard trust badges or customer GA acceptance. See policy-engine for the exact CLI invocation and the separate #154 two-private-installation requirement.

Separate the reviewed source commit from the signing workflow commit

A workflow_dispatch run can check out a reviewed source commit that differs from the commit containing the target repository's workflow definition. GitHub's signed OIDC sha claim identifies the commit that triggered the workflow run. The distinct signed workflow_sha claim identifies the commit containing the workflow file (the signer). Neither claim substitutes for the actual reviewed checkout, whose source SHA is independently verified.

The verifier therefore accepts: - reviewedSha: the independently authorized target commit whose KiCad source and generated outputs are hashed; - signerSha: the workflow definition commit, obtained only from the cryptographically verified GitHub OIDC workflow_sha claim for the exact persisted repository/workflow/ref/run/attempt. The OIDC sha claim is separately checked against the expected triggering commit.

The CLI local policy path remains backward-compatible: when no separate signerSha is provided, it continues to expect the signer and source commit to be the same. An API integration must never accept signerSha from an unsigned request field or manifest. It must call verifyGitHubActionsOidcTokenClaims after loading the independent run expectations, then pass that verifier-returned workflowSha as signerSha.

The composite export Action now verifies that Git HEAD equals the supplied reviewed-source-sha; it deliberately does not require this source SHA to equal GitHub's workflow-run GITHUB_SHA. The signer SHA remains independently checked against the Sigstore certificate's githubWorkflowSHA and buildSignerDigest, while sourceRepositoryDigest must equal reviewedSha.

This change fixes the two-SHA identity contract only. It does not itself persist a tenant delivery, grant sharing authorization, or enable a source-bound manufacturing revision. The signed export ingestion and tenant lifecycle remain separate acceptance work.

Hosted tenant import (implementation phase)

The opt-in target-repository readiness workflow can now run the pinned manufacturing export action when the repository's non-secret BOARDREADYOPS_PROJECT variable selects one project directory or .kicad_pro file. The target job signs the manifest and every Gerber, drill, BOM and CPL subject using a GitHub-internal Sigstore bundle, then sends one self-contained archive with a short-lived GitHub OIDC token to the current BoardReadyOps run/attempt import route.

The cloud derives run, execution attempt, repository, installation, target source SHA, signer workflow path/ref and dispatched GitHub run ID from PostgreSQL and the verified token. It verifies the bundle with gh, checks the complete archive inventory and every subject digest, and persists the archive with a separate immutable, tenant-scoped evidence row. BoardReadyOps attempt numbering is not conflated with GitHub OIDC run_attempt; same-run GitHub re-runs remain fail-closed and require a new control-plane dispatch.

A revision candidate is labelled source-bound-verified only if its exact artifact, current execution attempt and source SHA match that persisted proof. Legacy/manual archives remain not-established and inspectable, but are not eligible for new revisions, share authorizations or guest delivery until a fresh signed source-bound export is imported. The importer never creates a revision, guest link or manufacturing approval by itself.