| Loop | Use it for | Primary command |
|---|---|---|
| Pre-prod | Run scenario checks before a change ships, classify failures, optionally let a coding agent patch, rerun, validate, and publish a draft PR | archal preprod run |
| Post-prod traces | Import traces after an agent has already run, grade them, reproduce real failures against clones, and open reviewable fixes | archal attach |
archal run: your harness calls the
real agent path, the agent keeps using normal service SDKs and URLs, and Archal
handles clone routing, isolation, scoring, and evidence capture behind that
boundary.
The post-prod loop is not arbitrary production trace replay. Attach reproduces
only when the imported trace plus repo-owned scenario and seed context contain
enough evidence to rebuild the relevant clone state. If that evidence is
missing, the safe outcome is a blocked artifact that names the missing data.
First preflight
Install and authenticate once:- a runnable headless harness in
.archal.json,--harness, or a repo-local harness file - scenario markdown with setup, prompt, success criteria, and clone config
- model/provider keys needed by the agent
- a GitHub origin remote if the loop will open a PR
Pre-prod loop
Start by asking Archal what it can run:--write-scenarios writes parser-validated starter scenarios under archal/
by default. --write-config writes .archal.json only when it can do so
without overwriting an existing config.
Then resolve the loop without running scenarios:
.archal.json and preprod plan could not write a new
one, pass the generated scenario paths from
.archal/preprod-plan.json (authoredScenarios[].path) explicitly.
Let a coding agent patch and rerun only after reviewing the dry-run artifacts:
--dry-run for a classification-only stop. Omit
--allow-external-execution to prevent local fix or PR commands from running.
Omit --open-pr to finish after scenarios and validation pass.
Fix and PR commands run in a restricted environment. The fix command receives
ARCHAL_PREPROD_FAILURES_JSON and ARCHAL_PREPROD_ATTEMPT; the PR command
receives ARCHAL_PREPROD_VALIDATION_JSON. Commands that spend their own model
tokens can write usage JSON to ARCHAL_PREPROD_USAGE_PATH with fields such as
inputTokens, outputTokens, provider, model, isByok, and costUsd.
Pre-prod status
archal preprod run reports one of these statuses:
| Status | Meaning |
|---|---|
passed | scenarios passed, validation passed, and PR publishing was either not requested or completed |
planned | --plan resolved scenarios and stopped |
dry_run | --dry-run classified failures and stopped before fix commands |
blocked | the loop stopped before a safe next phase, such as missing harness, disabled external execution, or denied cost reservation |
budget_exhausted | fix attempts reached --max-fix-attempts |
validation_failed | scenario reruns passed, but --validation-command failed |
pr_failed | validation passed, but the PR command or PR verification failed |
--artifacts <dir> is set, inspect:
| File | What to read |
|---|---|
preprod-result.json | full redacted loop result, status, stop reason, attempts, scenario run ids, validation, and PR summary |
preprod-failures.json | schema-limited failure classifications for a coding agent or handoff |
Post-prod trace loop
Use Attach when traces already exist from pre-production or production agent runs. Run a readiness check first:archal trace-source:
trace-source sync or trace-source watch for pull-style sources such as
Langfuse, Braintrust, S3/GCS mirrors, or Postgres views. Use
trace-source serve for HTTP/OTel push sources.
Stop that local file-backed loop with:
archal detach only stops local file-backed attachments. Hosted database
sources are registered for hosted workers and are not stopped by detach.
Attach status and artifacts
For local file-backed Attach, inspect:archal attach-status --repo . to summarize trace jobs, and
archal attach-reprocess --repo . <trace-id> to retry a terminal trace job
after fixing the blocker.
Key artifacts:
| Artifact | What to inspect |
|---|---|
grades/<trace>/grade.json | verdict, summary, and whether reproduction should continue |
seeds/<trace>/scenario.md | generated reproduction scenario |
seeds/<trace>/seed.json | generated seed request or materialized seed metadata |
runs/<trace>/manifest.json | reproduction status, command, attempts, and evidence |
runs/<trace>/stdout.json | machine-readable run output |
runs/<trace>/stderr.log | reproduction stderr |
fixes/<trace>/status.json | blocked fix status |
fixes/<trace>/pr-details.md | reviewer summary for a generated fix |
fixes/<trace>/repo.patch | patch captured when PR creation cannot complete |
Safe resume and stop patterns
- Pre-prod: rerun the same
archal preprod run ... --artifacts <dir>command after fixing setup or code. The loop is bounded by--max-fix-attemptsand does not run fix or PR commands unless--allow-external-executionis set. - Pre-prod PRs: keep PR creation behind
--open-prand a draft-producing--pr-command. Archal verifies the PR head, changed files, draft status, and checks before reporting success. - Attach local: use
archal detach <trace-dir> --repo .to stop the watcher. Useattach-statusto find terminal jobs andattach-reprocessto retry after the evidence or setup is corrected. - Attach hosted: use
--checkbefore registration, then keep credentials read-only and source mappings explicit. Hosted source state is operated by Archal workers, so localdetachdoes not apply.
What to hand off
For every loop, include:- exact command and repo
- scenario paths or source name
- execution policy or pre-prod options
- final status and stop reason
- artifact directory and the two or three files that justify the decision
- PR URL, if opened
- remaining blocker, if any
