Artifact and completion-detection lifecycle¶
Mental model page. This is explanation, not a how-to. For the practical artifact authoring path, see Artifacts and Advanced artifact configuration.
An artifact is the durable evidence a phase produces. Ralph Workflow’s artifact lifecycle is what turns a phase’s agent invocation into reviewable, terminal evidence that survives the run.
Why artifacts, not transcripts¶
A chat transcript shows what the agent said. An artifact shows what the agent did. For unattended runs that you review in the morning, the artifact is what you actually inspect.
Ralph Workflow’s policy declares an artifact contract per phase. The
runtime validates the contract before accepting the phase as done. If
the contract is missing, the phase returns fix-needed or blocked,
not done.
The artifact schema¶
Every artifact in Ralph Workflow is a JSON document that matches the artifact submission contract:
ralph/mcp/artifacts/format_docs/<type>.md— per-type schema docsralph/mcp/artifacts/canonical_submit.py— the canonical submission pathralph/mcp/artifacts/contract.py— the Pydantic models that enforce the schema
The submission contract is verified by
tests/test_artifact_submission_canonical_path.py and audited by
ralph.testing.audit_artifact_submission_canonical_path.
The submission path¶
Every artifact is submitted via submit_artifact_canonical in
ralph/mcp/artifacts/canonical_submit.py. This is the only supported
submission path; ad-hoc writes to the artifact store are not permitted.
The submission path:
Validates the artifact against the per-type Pydantic model
Writes the artifact to
.agent/artifacts/<run-id>/<type>.jsonEmits an artifact-submitted event into the reducer stream
Returns the artifact path to the calling phase
The runtime then consults the artifact contract for the current phase and decides whether the artifact satisfies it.
The artifact types¶
Ralph Workflow defines several artifact types per phase. The most common:
Type |
Produced by |
What it must contain |
|---|---|---|
|
development phase |
Outcome, changed files, checks run, reviewer focus |
|
review phase |
List of issues raised during review |
|
fix cycle |
Same shape as |
|
commit phase |
Conventional-commit subject + structured payload |
|
commit phase |
Actions to delete / gitignore / git-exclude before commit |
|
planning analysis |
analysis decision for a plan section |
|
review analysis |
analysis decision for a review section |
|
development analysis |
analysis decision for a development section |
|
smoke-test commands |
Black-box test summary |
|
product spec phase |
Spec the run was built against |
Each type’s contract lives at
ralph/mcp/artifacts/format_docs/<type>.md. The format docs are the
authoritative source — read them when authoring an artifact.
Completion detection¶
A phase is done when all of:
The agent invocation returned (no timeout, no crash)
The artifact submitted via
submit_artifact_canonicalThe artifact satisfies the phase’s declared contract
The reducer for the artifact type advances the pipeline state
If any step fails, the phase is not done. The reducer typically returns
fix-needed (artifact missing or malformed) or blocked (a precondition
failed) instead of advancing.
The declare_complete terminal¶
When the final reducer decides the run is at a terminal state, the runtime
calls ralph_declare_complete. The terminal is the single, structured
handoff the user reviews:
done— the development_result is the review surfaceblocked— the issues artifact explains what blockedbudget-exceeded— the most recent artifact shows what was achievedregression— the verification artifact shows what failed
The terminal is the only signal the runtime hands back. There is no
“trust the transcript” path. If the terminal is done, the run is done.
Why the canonical path matters¶
The canonical submission path is audited because ad-hoc artifact writes are an attack surface: a bad artifact could advance the pipeline past verification. By making the canonical path the only supported write, the runtime guarantees:
Every artifact is validated against its Pydantic model
Every artifact is associated with a run ID
Every artifact is recorded in the audit sink
No artifact can bypass schema validation
The audit (ralph.testing.audit_artifact_submission_canonical_path) flags
any artifact submission that does not go through the canonical path.