Repository navigation
Description
Discovered by
pipeline-stage-audit agent (swarm 2026-04-26). Full report: .agent/scratch/swarm-2026-04-26/pipeline-stage-audit.md.
Problem
#323 (closed) modeled pipeline stages as executable specs (pipeline/stage_specs.py, pipeline/stage_models.py). Each PipelineStageSpec declares its inputs and outputs — but no runtime check verifies the contract when the pipeline crosses a stage boundary.
Concrete consequences (audit findings):
materializesilently returns zero items ifprocessed_idsis empty. The pipeline reports success; downstream stages produce nothing.parse → materializepasses state implicitly throughstate.processed_ids. A partial parse failure (some records OK, some not) makes materialize see a valid-looking but incompleteprocessed_idsset.render → sitedepends on render output existing;siteemits no diagnostic when the dependency is missing.
The four critical silent-failure sites in the companion silent-failure issue cluster at exactly these stage boundaries — the implicit-contract pattern is the meta-cause.
Target
Add runtime contract validation between stages. When the pipeline crosses a stage boundary, assert the prior stage's declared outputs are present and shaped correctly. On contract violation, fail loudly with a structured StageContractViolation exception that surfaces in RunResult and ReadinessReport.
Implementation sketch
@dataclass(frozen=True, slots=True)
class StageInput:
name: str
required: bool = True
shape: type | None = None # optional runtime type check
@dataclass(frozen=True, slots=True)
class PipelineStageSpec:
...
inputs: tuple[StageInput, ...]
outputs: tuple[StageInput, ...]
def validate_stage_inputs(spec: PipelineStageSpec, state: RunState) -> None:
missing = [i.name for i in spec.inputs if i.required and not state.has(i.name)]
if missing:
raise StageContractViolation(stage=spec.name, missing=missing)Run the validator on every stage entry, both in run all and individual run <stage> invocations.
Acceptance criteria
PipelineStageSpeccarries typed input/output declarations.- A runtime validator runs at every stage boundary; violations surface as typed exceptions.
RunResult/ReadinessReportinclude stage-contract diagnostics.- Tests: every stage has a test that mocks a missing input and asserts the validator fires.
- Tests: every stage has a test asserting normal-path inputs satisfy the declared contract.
- The four silent-failure sites in the companion issue resolve via this validation (or via their site-specific fixes).
Pattern
Follows the same evidence-driven specification pattern as #429 (topology), #435 (file-size), #437 (test-ownership): declarative spec + runtime check. The pattern from the structural-cohesion track applied to pipeline correctness.
Related
- refactor: model pipeline stages as executable specs #323 (closed) — stage spec model that this issue extends.
- Companion: silent-failure-sites fix issue (filed alongside).
- chore: track post-renewal consolidation and architectural cohesion #401 — post-renewal consolidation umbrella.
Activity
fix(pipeline): four critical silent-failure sites (#453)
fix(pipeline): four critical silent-failure sites (#453)
feat(pipeline): runtime stage contract validation (#458)