Ci Schema Contracts
CI/CD Complete models end-user delivery pipelines independently of a forge.
CI/CD v1 schema ownership and compatibility
Brief and authority
CI/CD Complete models end-user delivery pipelines independently of a forge. The owner of CIPipeline and CIEnvironment is `cicd-complete`. The canonical authorities are the framework's `schemas/ci-pipeline.schema.json` and `schemas/ci-environment.schema.json`, with unique identities under `https://aiwg.io/schemas/cicd/v1/`. Both use draft-07 and `apiVersion: cicd.aiwg.io/v1`. Catalog registration lives in `schemas/catalog/domains/cicd-complete.json` at the AIWG repository root.
Consumers are the cicd-complete agents and skills (`ci-architect`, `ci-renderer`, `ci-pipeline-design`, `ci-render`, `ci-drift-check`), the capability library, and the provider extensions `cicd-gitea-actions` and `cicd-github-actions`. Rendering supports the reviewed ordered-actions/v1 direct contract and inert agent recipes; no consumer executes pipelines. Generated plugin schema copies are projections, verified byte-for-byte by the fixture suite and plugin-copy lint. There is no independent TypeScript or provider-specific contract in this change.
Contract shape
Both resources require `apiVersion`, `kind`, `metadata.name` and `spec`. Metadata may carry string labels. Governed objects reject unknown properties; labels, capability inputs and GatePack parameters are intentionally open maps.
CIPipeline requires `spec.triggers`, `environments`, `stages` and `render`. Triggers are objects with `type: push | pull_request | schedule | manual`, optional `branches` and `paths`; schedule triggers require `cron`. Stage and job dependency lists contain ids. Each job requires `id` and either an OpsCapability `capability` name or ordered `steps`. Retry uses positive `max_attempts` and a consumer-interpreted `backoff` string.
A stage may include `rollout`, with a strategy, steps, gates and rollback policy. Each step sets exactly one of `weight` or `percentage` (0–100), and may set `pause`, `gate` or `capability`. Pauses are duration strings. Gate references are objects with `pack` (a GatePack metadata id), `after` (a stage id) and optional `parameters`. Step `gate` strings name a GatePack id. GatePacks use `gates.aiwg.io/v1alpha1`; the existing `aiwg:dev/ci-flake` pack is a reference example, not a dependency. Rollback names a capability and triggers on `gate-failure` and/or `manual`.
For `strategy: flag`, a consumer defaults an omitted step capability to `progressive-rollout`. JSON Schema defaults are annotations; validation does not populate documents. Agents read the provider from project configuration `feature_flags.provider`, owned by sdlc-complete's feature-flags work. No flag provider or lifecycle fields belong in CIPipeline. `render.targets` supports `gitea-actions`, `github-actions` and `gitlab-ci`.
CIEnvironment requires `spec.runner.labels`. Optional `secrets` contain only `{name, ref}`; `ref` is a nonempty secret-store reference string whose resolution and store-specific syntax belong to the consumer. `value` is always rejected. Optional protection specifies a nonnegative `required_reviewers` count and `branch_restrictions` patterns.
Consumers resolve environment, capability, stage/job dependency and GatePack references, detect dependency cycles, apply defaults and validate provider-specific inputs. Structural schema validation does not establish reference integrity or execute a rollout.
Compatibility and verification
Version v1 permits additive changes only (optional fields or compatible relaxations). Removing fields, changing meaning or adding required fields needs a new API version and migration guidance. WorkflowExtension now accepts both `ops-complete` and `cicd-complete` parents, a backward-compatible widening; OpsExtension remains ops-only.
Valid and invalid fixtures live under `test/fixtures/cicd/{valid,invalid}`. `test/unit/workflow/ci-schema-validation.test.ts` checks every fixture and expected rejection keyword, rollout bounds, object closure and packaged projections. `workflow-schema-validation.test.ts` covers both supported extension parents and rejects unknown frameworks while preserving the ops-only contract.
Constraint profiles (v1alpha1)
ConstraintProfile and ConstraintDefinition use draft-07 and the API version `constraints.cicd.aiwg.io/v1alpha1`. CIEnvironment optionally selects profiles with per-ID enforcement and parameter overrides. The installed-definition registry binds the environment schema to known IDs and rejects unresolved references. See the constraint-profile reference at `$AIWG_ROOT/docs/frameworks/cicd-complete/constraint-profiles.md` for contract fields, checker phases and validation before template projection.
Ordered jobs, matrices and environment bindings (v1)
A job selects exactly one form: legacy `capability` plus optional `inputs`, or nonempty `steps`. Each ordered step has a unique source `id`, `capability`, optional `inputs`, `name` and string `env`. Preserve native job ids and every source step id; for unnamed source steps, record a stable index-derived id in the reviewed migration map. One provider job owns one workspace per matrix leg. Checkout, dependency installation, build and evidence consumers stay in order in that workspace. `needs` does not transfer local files between jobs. Do not add implicit checkout/cache/upload steps to an explicit ordered list. Job `retry` is inherited by each capability invocation; adapters must retain failure evidence. Optional step/job predicates, timeouts, scoped env and concurrency are described below. Existing capacity and opt-in pipeline-shape policies remain applicable.
`job.strategy` contains optional Boolean `fail_fast` and required `matrix`: `dimensions` maps identifier keys to nonempty unique arrays of string, number or Boolean values. Optional `include`/`exclude` contain typed scalar row maps. Expand the Cartesian product, exclude matching rows, then merge include rows into compatible original legs or append incompatible rows, following Actions semantics. Empty expansions and more than 256 legs block preflight. Each provider recipe emits native `strategy.matrix` and `fail-fast` without changing the source commands, display names or env. Omitted fail_fast retains the provider default; explicit false stays false. Include-only matrices are not supported.
Matrix expressions use `${{ matrix.key }}` in job/step names, env and capability inputs only. Every referenced key must exist on every effective leg of that job. Bracket access, arithmetic and dynamic matrix definitions are unresolved scope, not strings to pass through. Job ids, capability ids, dependencies, environment references and runner selection remain static. Other provider contexts retain existing recipe validation; this extension is not a general expression evaluator. Adapters must validate capability inputs after provider expression substitution.
Optional `job.environment: {kind: CIEnvironment, name: ci-test}` references an entry in `spec.environments`; optional apiVersion must be `cicd.aiwg.io/v1`. Without a reference, exactly one declared environment is the legacy default. Zero/multiple candidates, missing resources, duplicate names and undeclared references block preflight. The reference never becomes a capability input. Resolve runner_pool/default_pool, then runner_labels/pool labels/environment labels using the existing capacity rules; check profiles against their bound jobs.
Use the existing `validators/constraints.mjs` CLI with `--execution-bindings FILE` (or `executionBindings` in validateConstraints/renderWithConstraints). The reviewed JSON binding has provider (`gitea-actions` or `github-actions`), capability_command and registrations. Each registration contains environment, exact ordered labels, trust (`trusted`/`untrusted`), evidence (a local inventory identity/digest), and execution (`mode`: container/host/hosted; runtime: attested runtime identity). Container mode requires a digest-pinned image, projected as native job.container. Gitea requires act_runner inventory, not a GitHub hosted registration. Exactly one matching registration is required for every new-form job; legacy jobs retain the existing inventory review workflow. Inventory is operator-reviewed local evidence: never probe the network or claim that workflow labels prove current registration, trust or runtime availability.
`validators/job-execution.mjs:resolveJobExecution` supplies render receipt material: source job, complete ordered source/provider step map, shared-per-leg workspace, expanded legs, environment, labels, trust, execution and inventory evidence. Record these alongside the existing spec/template/pin/output digests. Receipts state reviewed-local-inventory and liveRegistration: unverified. Resolve both label pools separately, even when their names resemble hosted runner labels. CI_ENVIRONMENT is an adapter binding; GitHub protected environments and Gitea's external approval/secret broker retain their existing independent enforcement.
renderWithConstraints also checks its actual projection result before returning it. Audit-time checks require a workflow preview for new job fields. Pass parsed previews as `workflows` or CLI `--workflow` for the shared drift check. It rejects altered job/step names, env, commands/inputs, matrix/fail-fast, labels, environment adapter bindings, dependency removal, missing/reordered steps and extra unmapped steps. Generated helpers must remain separate reviewed jobs; explicit source-step jobs contain only the complete ordered invocation map. Keep CI_CAPABILITY/CI_INPUTS/CI_ENVIRONMENT/CI_BINDINGS/CI_RETRY reserved in env.
The frozen local source fixture has nine groups and 82 source steps at the recorded revision, with test-shards/deployment/packaging expanding to 4/3/4 legs (17 total). Both `ci-pipeline-ordered.yml` goldens are inert recipe projections; original shell commands remain verbatim in CI_INPUTS. Their source snapshot also retains conditions/timeouts/concurrency for review, but this extension projects only the requested ordering/matrix/environment subset. Do not install that partial projection as runnable parity until later condition/control work lands. A separate safe local test proves installed/built/evidence files flow between ordered invocations; no test executes the original source pipeline.
Execution and failure evidence controls (v1)
All additions are optional; old v1 documents remain valid. CIEnvironment may specify execution: `{mode, runtime, image}` for container mode. The image is a versioned SHA-256 digest reference, and runtime records exact Node/npm versions. The existing reviewed runner registration must match every specified field; labels, including ubuntu-latest, do not determine infrastructure or runtime. Host/hosted execution instead requires `{mode, runtime, attestation_ref, attestation_digest}` and trusted inventory with the same external attestation. No implicit host fallback is permitted; Gitea rejects hosted registrations. The receipt retains reviewed inventory evidence and liveRegistration unverified.
CIPipeline `spec.env` extends the existing string job.env/step.env maps. Preserve each scope exactly; native precedence is workflow < job < step. Reserved adapter keys are rejected across all scopes. Conditions are optional nonempty native `if` strings on jobs and steps; omitted predicates keep native success semantics, explicit always() retains failure evidence. Matrix expressions remain limited to names/env/inputs; conditions cannot introduce unresolved matrix keys. Provider context migration needs a reviewed native expression binding, never string loss.
Job and step `timeout_minutes` are positive integers mapped to timeout-minutes. Workflow (`spec.concurrency`) and job concurrency contain required string group and Boolean cancel_in_progress, mapped to native group/cancel-in-progress. Explicit false is preserved. Preflight/preview drift errors identify the exact control location; no control may be silently dropped or widened. Protected job guards and approvals must also hold when adding source predicates.
Checkout fetch_depth 0 requires verified complete history before push-range signature verification. Failure evidence uploads use step.if always(), missing files error, and a retained source_status_ref. Collection never replaces original test/threshold/security status. See the paired provider controls goldens and binding examples at `$AIWG_ROOT/test/fixtures/cicd/governed-controls/` and the provider extension READMEs for the seven strengthened capability bindings.
Runtime bindings and repeatability (#4479/#4482)
CIRuntimeBindings uses the additional draft-07 `ci-runtime-bindings.schema.json` authority under the same v1 namespace. This adds a versioned envelope to existing provider binding plans; CIPipeline and CIEnvironment schemas remain unchanged. Unversioned plans remain preview-compatible. Add `apiVersion: cicd.aiwg.io/v1`, `kind: CIRuntimeBindings` and `render_contract: ordered-actions/v1` to migrate. Runtime acceptance additionally requires reviewed digest-pinned implementations matching installed capability versions and definition digests, complete typed inputs and verified actual evidence; fixture-only plans remain HOLD.
The existing constraint registry and `--execution-bindings` validate the envelope. The existing job-execution module owns direct lowering; `renderWithConstraints` checks its projection, and `renderRepeatably` audits two isolated renders against source controls plus byte/semantic equality. No parallel provider schema or validator is introduced. See the paired provider README runtime/repeatability contracts for API arguments, unsupported controls and installation prerequisites. Receipts include input, binding-plan, template, pin, output and semantic SHA-256 digests. Fresh-process repeatability does not prove independent interpretation or provider acceptance.