Closed-Loop Agent Orchestration
codedecay loop turns the redteam report and agent task bundle into a safe fix -> re-verify loop.
It does not embed a model, call a hosted LLM, send telemetry, or use a CodeDecay API key. If you do not pass --agent-cmd, the command runs in plan-only mode and prints what it would send to your own agent.
Plan-Only Mode
codedecay loop --format markdownPlan-only mode:
- runs deterministic CodeDecay redteam analysis
- runs configured checks only when they exist and
safety.allowCommands: true - renders the agent bundle and fix tasks
- makes no edits
- runs no agent command
Agent Mode
codedecay loop --agent-cmd "your-agent-command" --max-rounds 4The command must be user-owned and explicit. CodeDecay passes the rendered task bundle on stdin. The agent may edit the working tree, but CodeDecay never commits or pushes those edits.
After each agent action that changes files, CodeDecay re-runs deterministic analysis and configured checks. This post-agent verification still runs when the edit happens in the final allowed round, including --max-rounds 1, and it never invokes the agent a second time. Agent output is treated as untrusted suggestion text until the deterministic checks prove the current working tree.
Progress considers merge risk, decay risk, security risk, weak-test findings, product-failure bundles, and configured-check state. The JSON report records a postAgentVerification snapshot on the agent round so callers can distinguish agent execution failure from a deterministic check failure after an edit.
Safety Rules
codedecay loop never prints an unqualified "safe" verdict. Clean outcomes are always qualified by evidence depth.
The loop can only report a verified or shallow-proof verdict when all of these are true:
- final risk is at or below the configured safe threshold,
lowby default - weak-test findings are zero
- security score is at or below the configured threshold,
0by default - no high-severity findings remain in deterministic analysis
- configured checks exist and pass
If no checks are configured, the best possible terminal status is unverified, not a verified verdict.
verified means configured checks passed, deterministic security matchers were clean, Semgrep was enabled and clean, and coverage/mutation evidence was available if configured. Legacy alias: merge-safe-verified.
shallow-proof means the gates passed, but one or more deeper evidence streams were missing. Treat it as heuristic clean, not as deep verification. Run codedecay doctor to configure OSS adapters such as Semgrep, coverage, and StrykerJS. Legacy alias: merge-safe-shallow.
Terminal statuses:
verified: configured and enabled checks found nothing at the selected thresholds, including available security/coverage/mutation depthshallow-proof: risk, weak-test, security-score, and configured-check gates passed, but depth evidence such as Semgrep, coverage, or mutation testing is missingunverified: risk and weak-test evidence are clean, but no configured checks proved the resultplan-only: no agent command was configuredstuck: the agent made no progress for two rounds, oscillated, or widened scope unsafelybudget-exhausted: round, wall-time, model-call, or changed-file budget exhaustedunsafe-change: verifier edited files, or protected/out-of-scope paths changedneeds-human: max rounds were reachedbuilder-error/verifier-error/agent-error: role command failed, timed out, was skipped, or was blocked by safety policy
Example
codedecay loop \
--cwd ../my-repo \
--agent-cmd "codex exec --apply" \
--max-rounds 3 \
--max-security-score 0 \
--format markdownEnable command execution explicitly in .codedecay/config.yml before using agent mode:
version: 1
commands:
test:
- pnpm test
safety:
allowCommands: trueDo not configure deploys, production migrations, package publishes, or destructive git commands as loop commands.
