# Core Architecture v2 — S7 Tactical WorkGraph

**Slice:** S7 — Supply-Chain Provenance Gate
**Checkpoint:** `a7b52da73baba35779696aa837aa330438744359` (`core-architecture-v2`)
**Scope:** the approved S7 objective and gate only. S8 controller-owned delivery/reconciliation, S13 real-provider certification, and S14 self-hosting are excluded.

## Frozen source facts and contract

- `CORE_ARCHITECTURE_V2.md` remains normative and unchanged. Its candidate-truth contract makes the current `CandidateRevision` the sole source truth; its certification contract separates deterministic fixture evidence from provider certification; supply-chain evidence is candidate/build-bound.
- Status records S1 candidate/build identity as present and S6 as accepted. S7 is next, depends on candidate/build identity, may progress alongside S4–S6, and is downstream-required by S8 only where policy requires provenance.
- Current delivery finalization already requires the current S6 AcceptanceOracle before effects and invokes `verifySupplyChainGate` before the commit/push/PR path. S7 may strengthen this existing gate but may not add, own, or reorder delivery effects.
- The current provenance module generates file digests, SBOM, in-toto/SLSA data, BuildIdentity, and optional Cosign evidence. Its strict verifier selects the lexically latest evidence files and does not require an exact current candidate/build/artifact/builder binding. Existing generated manifests are internal artifacts; superseded internal schema/selection paths will be migrated and removed without compatibility aliases.

The S7 evidence contract is deterministic. Every strict verification is evaluated against an explicit current `CandidateRevision`, the policy-selected packed artifact and its content digest, the artifact's valid `BuildIdentity`, the policy revision used to produce the evidence, the expected builder identity, the SBOM digest, the in-toto subject/predicate, and any policy-required Cosign verification key. Evidence must be structurally valid, current for those exact bindings, and content-verifiable. Missing, malformed, stale, tampered, wrong-artifact, wrong-candidate, wrong-build, or wrong-builder evidence fails closed. When signing is required, a missing/invalid signature or signature that does not verify under the configured policy key fails closed. No arbitrary metadata is interpreted semantically. Deterministic fixtures prove these checks only and never claim provider-backed signing certification.

The policy-required verifier remains inert when no supply-chain requirement is configured. Strict delivery verification requires a current candidate binding and the configured packed-artifact reference; standalone manifest inspection remains a read-only contract check and cannot authorize delivery. S7 does not accept candidates, grant capability, or cause external effects. Current S6 AcceptanceOracle ordering and S1 frozen identity remain unchanged.

## Tactical WorkGraph — S7 only

| ID | Work unit | Ownership class | Mechanism | Dependencies | Scope / files | Invariants | Acceptance and tests |
| --- | --- | --- | --- | --- | --- | --- | --- |
| S7-W0 | Freeze this S7 evidence contract, regression matrix, and versioned manifest/gate boundary before implementation. | LUNA_OWNED | DETERMINISTIC | Clean checkpoint; accepted S1 identity; accepted S6 oracle; frozen target/status | This artifact; inspect `src/build/identity.ts`, `src/provenance/generate.ts`, config/policy readers, `src/delivery/finalize.ts`, provenance/build-hygiene/delivery/certification tests. | CandidateRevision remains sole truth; policy and identity checks are deterministic; no acceptance/effect authority; target semantics unchanged; no compatibility fallback. | Contract and tests explicitly cover exact candidate/artifact/build/policy/builder binding, SBOM and in-toto chain, required signing fail-closed behavior, stale/tampered/wrong identity evidence, and deterministic/provider evidence distinction. No source code edited before this WorkGraph is recorded. |
| S7-W1 | Add an isolated regression suite for the frozen S7 evidence contract using deterministic artifacts and fake signing boundaries only. | FLASH_DELEGATABLE | DETERMINISTIC | S7-W0 contract frozen; separate Paseo worktree | New `tests/provenanceS7.test.ts` only. Do not edit implementation, shared fixtures, policy/schema files, or existing test files. | Tests must not certify providers, bypass current candidate identity, accept metadata as authority, mutate normative target or weaken existing gates. Fixtures clearly identify fake signing. No nested agents. | Cover a valid complete strict chain; missing chain components; artifact and SBOM tampering; wrong/stale CandidateRevision and BuildIdentity; wrong builder/policy; required signing missing/invalid; and non-strict policy behavior. Test outcomes assert only deterministic gate decisions. |
| S7-W2 | Replace the incomplete internal evidence format/selection with an explicit versioned artifact-bound provenance contract; generate candidate, artifact, SBOM, BuildIdentity, policy, builder, and attestation bindings. | LUNA_OWNED | DETERMINISTIC | S7-W0; S7-W1 test contract | `src/provenance/generate.ts`, focused config/schema reader only if required, `src/build/identity.ts` only if artifact identity extraction needs a canonical helper. | Deterministic digests and exact identity equality; no arbitrary metadata inference; stale format fails explicitly; required evidence fails closed; no paid hosted service. | Focused provenance regressions prove the complete contract, invalid/missing fields fail, generated predicate binds all exact identities, and old internal evidence cannot pass through a legacy branch. |
| S7-W3 | Thread the exact current S6 candidate and frozen supply-chain policy into the pre-effect provenance gate; make only the existing S7 check stricter. | LUNA_OWNED | DETERMINISTIC | S7-W2; current S6 AcceptanceOracle and S1 candidate identity | `src/delivery/finalize.ts`, `src/cli.ts` only for verification context, `tests/deliveryFinalize.test.ts`, provenance tests. | AcceptanceOracle stays first and required before effects; S7 only returns a deterministic allow/block result; no external action before the full gate; S8 subsystem remains untouched. | Required missing/stale/wrong-candidate/wrong-artifact/wrong-builder evidence blocks before any delivery request or Git commit/push; valid current evidence reaches the already-existing S6/S3 action gates. Non-strict policy preserves its explicit no-requirement behavior. |
| S7-W4 | Reconcile current status, conformance, evidence lane, and historical ledger records; retain this WorkGraph as durable evidence. | LUNA_OWNED | DETERMINISTIC | S7-W2–W3 implementation and evidence | `docs/CORE_ARCHITECTURE_V2_STATUS.md`, `docs/CORE_ARCHITECTURE_V2_CONFORMANCE.md`, `docs/ENGINEERING_LEDGER.md`, this file. `CORE_ARCHITECTURE_V2.md` is not edited. | Report deterministic fixtures separately from REAL_PROVIDER signing; do not claim S13 certification; preserve S6 acceptance and S8 ownership. | All affected status row fields are current; conformance claim matches implementation/evidence; ledger entry is evidence-backed; target has no diff. |
| S7-W5 | Run regression-first focused checks, TypeScript, build, affected Vitest suites, applicable deterministic system tests, and final diff review. | SEQUENTIAL_AFTER_CONTRACT_FREEZE | DETERMINISTIC | S7-W1–W4 complete | Exact commands/results in final report and docs. | No tests weakened; no commit/push; report unavailable REAL_PROVIDER/signing lane exactly; no S8 implementation. | Gate evidence covers every S7 statement; `git diff --check` clean; independently review exact candidate/artifact/policy/signer/builder/freshness bindings and delivery ordering. |

## Delegation Assessment — S7 only

`S7-W1` is a meaningful, safely separable tests-only task. Its dedicated new test file does not overlap Luna's implementation, integration, config, documentation, or existing-test files. It was authored in a separate Paseo worktree and encodes only the deterministic contract above. It could not write production source, select policy, alter candidate truth, decide acceptance, authorize signing, certify a provider, or create agents. Luna owns contract interpretation, policy and identity semantics, production implementation, lifecycle integration, docs, validation, and final review. Concurrent writes were isolated by the dedicated worktree. The configured profile was materialized immediately after `list_profiles`: profile ID `agent_profile_mueqxfzp_3t66dje5yj5`, name `DeepSeek V4.1 Flash Implementer`, provider `opencode`, model `opencode-go/deepseek-v4.1-flash`, mode `build`, thinking `max`, feature values `{ "auto_accept": true }`; create-agent provider `opencode/opencode-go/deepseek-v4.1-flash`. Paseo agent `efdc90cb-4c69-4c68-aa6c-199a0d0902ba` used workspace `wks_89187e6a5298a10e`, path `/home/james/.paseo/worktrees/0jx5pvzi/s7-provenance-flash-tests`, branch `s7-provenance-flash-tests`. Its prompt included OBJECTIVE, EXACT SCOPE, FILES/AREAS, DEPENDENCIES, INVARIANTS, ACCEPTANCE CRITERIA, TESTS, EXPLICIT EXCLUSIONS, and NO NESTED DELEGATION. No worker commit or push occurred.

## Frozen deterministic acceptance matrix

1. A current candidate, configured artifact, matching artifact digest, valid BuildIdentity, current policy binding, expected builder, SBOM, and valid in-toto chain pass strict verification.
2. Missing manifest, subject, BuildIdentity, SBOM when required, statement/predicate, or required signature blocks.
3. Artifact or SBOM byte changes, digest changes, malformed evidence, stale policy/build/candidate bindings, wrong candidate, wrong artifact, or wrong builder block.
4. Required signing is verified against the configured key. A fake verifier/fixture is explicitly deterministic evidence and cannot set provider certification state.
5. Strict failure occurs before any commit, push, PR request, or other effect; S6 AcceptanceOracle remains required before S7/effects.
6. Non-strict policy does not invent a provenance requirement.

This contract and WorkGraph were recorded before source or test edits.

## Execution record

The Flash worker returned only `tests/provenanceS7.test.ts` (29 tests). Its isolated pre-implementation run was 1 file, 21 passed and 8 failed; the eight expected red cases identified missing candidate/artifact/BuildIdentity/policy/builder bindings and the obsolete operation-evidence message. The file was copied into the primary checkout and its fixtures were aligned with manifest version 2 and the current required operation-evidence contract; Luna added strict-config regressions for the retired alias and escaping outputDir, configured-run-directory candidate lookup, stale SBOM-command policy binding, and a delivery no-effects regression. The final `tests/provenanceS7.test.ts` passed 1 file / 33 tests; the broader focused provenance/build/delivery set passed 4 files / 49 tests. Full non-system Vitest passed 158 files (1 skipped), 965 tests passed (7 skipped); TypeScript and production build passed. The S7-specific system missing-manifest case passed. A broader three-suite system run retained two unrelated adversarial terminal-operation fixture failures because those fixtures omit S6 objective-completion and AcceptanceOracle evidence; that failure is recorded in Conformance and the ledger, with no out-of-slice S6 fix.

The configured signing test uses a deterministic fake Cosign/PATH shim and explicitly labels its bundle `NOT_REAL_PROVIDER`. No REAL_PROVIDER signing run was made because the `cosign` CLI is unavailable in this environment; no certification claim was made. At this initial S7 close, the Campaign Director's independent review remained pending; no commit or push was made.

## Same-slice S7 schema-guard remediation — frozen 2026-09-24

This remediation covers only the Campaign Director's bounded S7 finding in `schemas/project.schema.json`. It does not reopen or reinterpret `CORE_ARCHITECTURE_V2.md`, alter lifecycle/authority/acceptance semantics, change S1 frozen execution identity or S6 AcceptanceOracle-before-effects ordering, or begin S8.

### Finding and frozen config contract

The S7 `provenance` schema's two `allOf` conditions use nested `properties` checks without presence guards. Under JSON Schema, an absent property does not make a `properties` subschema fail, so a `then.required` branch can apply to a non-strict object. The existing `src/core/config.ts` Zod contract is the remediation authority for current config shape: artifact is required only when `provenance.required`, `sbom.required`, `signing.required`, or `verification.required` is explicitly `true`; when signing or verification is explicitly required, both `signing.key` and `verification.publicKey` are required. An optional/non-strict provenance object may contain `outputDir` and `buildType` without artifact/signing settings, as in `templates/project.yaml`.

`npm ls ajv --all --depth=5` reports no installed AJV package, and `require.resolve('ajv')` reports `AJV_NOT_RESOLVABLE`. No JSON Schema validator is available in the existing dependency tree, so the regression will prove the required guards structurally and exercise the existing Zod config loader for the non-strict template and valid/invalid strict configurations. No dependency will be added for this repair.

### Remediation WorkGraph — S7 only

| ID | Work unit | Ownership class | Mechanism | Dependencies | Scope / files | Invariants | Acceptance criteria and tests |
| --- | --- | --- | --- | --- | --- | --- | --- |
| S7-R0 | Freeze this bounded finding, config contract, and regression/delegation boundary before source or test implementation. | LUNA_OWNED | DETERMINISTIC | Expected HEAD `a7b52da73baba35779696aa837aa330438744359`; declared S7 working tree; frozen target; current status/conformance/ledger; current schema, config, template, and tests inspected. | This workgraph only. | S7 only; no target/lifecycle/authority/acceptance change; preserve S1 and S6 ordering; no S8; no compatibility alias/fallback. | Record the exact Zod condition semantics, absence of an available JSON Schema validator, work-unit scopes, dependency ordering, and testable acceptance before editing implementation/tests. |
| S7-R1 | Add a bounded regression for guarded provenance schema conditions and the existing config contract. | FLASH_DELEGATABLE | DETERMINISTIC | S7-R0 frozen; dedicated Paseo worktree provisioned with the current S7 schema, template, and config reader; no shared-checkout writes. | `tests/projectSchemaS7.test.ts` only. | Tests only; do not edit schema/source/docs/other tests; do not add dependencies; no provider-certification claims; no nested delegation. | First run against the defective schema demonstrates missing guards. Structural assertions require `required` at each top-level/nested condition boundary and verify the `then` constraints. Config-loader cases accept the template's non-strict provenance and an explicit valid strict config; reject missing artifact and missing required signing keys; confirm absent flags do not trigger requirements. Use the existing Vitest command for this file. |
| S7-R2 | Correct the JSON Schema `if` branches to require the relevant parent and nested `required` flags before matching `const: true`. | LUNA_OWNED | DETERMINISTIC | S7-R0; S7-R1 contract frozen; regression file returned and reviewed. | `schemas/project.schema.json` only. | Mirror `src/core/config.ts` and `templates/project.yaml`; absent flags do not match; explicit true flags enforce artifact and paired signing/verification keys; do not weaken Zod/runtime policy. | The regression's schema-structure assertions pass; JSON remains parseable; no new validator dependency. |
| S7-R3 | Integrate the isolated regression, review its scope, run S7 focused validation, and record evidence/status. | SEQUENTIAL_AFTER_CONTRACT_FREEZE | HYBRID | S7-R1 returned; S7-R2 complete; current dirty S7 implementation preserved. | Integrate only `tests/projectSchemaS7.test.ts`; then update applicable `docs/CORE_ARCHITECTURE_V2_STATUS.md`, `docs/CORE_ARCHITECTURE_V2_CONFORMANCE.md`, and `docs/ENGINEERING_LEDGER.md`. `CORE_ARCHITECTURE_V2.md` remains untouched. | The S7 provenance gate remains before effects and after accepted S6 disposition; no unrelated S6 repair; no S8 work; fixtures stay distinct from provider evidence. | Run regression first, then provenance/config/schema/delivery focused suites, TypeScript noEmit, build, relevant deterministic S7 system case(s), JSON parse, and diff checks. Record exact results; Slice Lead closure remains advisory until the Campaign Director independently gates the slice. |

### Delegation Assessment — remediation only

`S7-R1` is meaningful and safely separable after this contract freeze because it touches one dedicated new test file while Luna owns the one-line-schema-contract repair, integration, all existing implementation, validation, and docs. Paseo must create a separate worktree from the current branch; before agent launch, Luna will materialize only the current S7 schema, config reader, template, package/dependency context needed for the tests. The worker's write authority is limited to `tests/projectSchemaS7.test.ts` in that worktree. It cannot change schema or runtime policy, claim provider evidence, affect the shared checkout, or spawn children. Luna will review the returned diff and copy/integrate only the assigned file after the worker completes. No nested delegation is allowed.

For this launch, `list_profiles` was freshly called and every returned profile note was read. The selected configured profile is `DeepSeek V4.1 Flash Implementer`: create-agent provider `opencode/opencode-go/deepseek-v4.1-flash`, `settings.modeId: "build"`, `settings.thinkingOptionId: "max"`, and `settings.features: { "auto_accept": true }`. These settings are copied from the current profile result, not inferred or reused from history.

### Remediation execution record

- The required regression-first run occurred in Paseo worktree `wks_980401dce49edf4b`, path `/home/james/.paseo/worktrees/0jx5pvzi/s7-provenance-schema-regression`, branch `s7-provenance-schema-regression`, based on expected HEAD `a7b52da73baba35779696aa837aa330438744359`.
- Paseo agent `04fef23f-93a8-4d56-b1d0-b6d0276f9174` used the freshly materialized DeepSeek V4.1 Flash Implementer settings above. Its prompt included all required assignment sections and explicitly prohibited shared-checkout writes and nested delegation. Its only changed file was `tests/projectSchemaS7.test.ts`; it created no agents, commit, or push.
- Before Luna changed the primary schema, `npx vitest run tests/projectSchemaS7.test.ts --reporter=dot` in the worktree reported 1 failed file, 6 expected structural guard tests failed, and 15 passed. The worker also applied the guards in a throwaway copy and reported 21/21 passing; the primary worktree schema remained defective during the red run.
- Luna reviewed and integrated only the assigned test file, added required guards for both the parent property and nested boolean flag in each conditional branch, and left the runtime Zod contract unchanged. The primary post-fix schema test passed 21/21. The S7-focused provenance/config/schema/delivery command passed 5 files / 70 tests; TypeScript noEmit and production build passed; the scenario matrix passed 8 tests; the isolated adversarial missing-manifest case passed 1 test with 27 skipped; JSON schema parsing passed.
- No JSON Schema validator is installed or resolvable, so the regression asserts condition structure and separately exercises actual template/strict-config behavior through `loadProjectConfig`. No dependency was added. The Campaign Director accepted the S7 deterministic gate on 2026-09-24 after independent reruns: focused 5 files / 70 tests, TypeScript noEmit, build (release-1790310426337-17-0e3b4825), full non-system 159 files passed, 1 skipped (986 passed, 7 skipped), scenario matrix 8 passed, adversarial missing-manifest 1 passed / 27 skipped, JSON schema parsing, and diff checks.
