Helper CLI Contract¶
Apply Proactive recovery and delivery before helper preparation and after each recovered checkpoint. Helper success advances the requested workflow; it does not replace its promised delivery.
Invoke packaged helpers through PLUGIN_ROOT/bin/python; on native Windows use PLUGIN_ROOT/bin/python.cmd. Quote resolved launcher and script paths for the host shell (PowerShell uses & before a quoted executable path). The launcher selects an available Python 3.10+ and preserves helper arguments and exit status.
Apply Authorized Workflow Execution to every helper: use current grants without a new approval merely because a packaged launcher owns the command. Missing launchers are package evidence, not a permission denial. Diagnose installed package identity and the missing file; never silently select another cache or edit an install target. Continue authorized repository work through its declared environment and checks when that is the user's task, while reporting any unavailable installed-skill gate accurately.
Before submitting a gate command, choose one test transport: free-form --tests, or import-bound --pytest-python with imports and JSON arguments. Never combine them, including an inherited TESTS_CMD in import-bound mode. An argument-validation failure is an agent-owned construction error; correct it under existing authorization after confirming that no gate executed. An unavailable required review remains open, not not-applicable merely because its reviewer or environment needs recovery.
Helper option schemas live in --help, not skills. In plugin, derive PLUGIN_ROOT from selected SKILL.md path and require every helper in package-manifest.json; never choose cache with glob/latest/mtime logic or use source-tree fallback. The list below covers common shared and code-review helpers, not the complete release roster; other workflow helpers are documented by their owning skill. Run an entry only when current package manifest contains it. Before creating or changing invocation, run relevant packaged command:
PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/create_run.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/run_gates.py --help—--tool-cache <dir>gives pre-commit and uv a writable cache outside the checkoutPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/release_evidence.py --help— explicitrecord-demoexecutes an authorized local demo and retains script/output receipts; ordinary release validation never executes itPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/collect_diff.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/github_read.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/collect_pr.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/escalation_ledger.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/adversarial_loop.py --help— validates convergence ledger consistency, not reviewer authenticity;--appendadds the stagedloop-rounds.jsonl.recroundPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/codemap_adapter.py --help— optional structural-context probe;contextaccepts closed--query-kindvocabulary (skip,central,callers,blast,dependencies,test-impact,coupling,standard); seecodemap-contract.mdPLUGIN_ROOT/bin/python PLUGIN_ROOT/runtime/calibration/run.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/runtime/calibration/run_live_ab.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/runtime/calibration/score_behavioral.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/find-review-report.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/local_reviewer_wave.py --help— explicit paid review route;--check-hostverifies setup without model turn, not review completionPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/select-git-remote.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/write-result.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/final_handoff.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/validate-artifacts.py --help—--all-errorsreports every failed check group with a repair hint in one passPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/test_targets.py --help— changed-file pytest targets (codemap-py test impact, else name/import heuristics) and the sandbox-safe flag decision for loop and reproduction runs, never a final gatePLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/gate_env_provision.py --help—plan|applybuilds a disposable task-local environment for declared dependencies; seenative-skill-contract.md§Project Dependency PreparationPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/benchmark_claims.py --help—host|comparerecords the host class and compares an author's benchmark claim base against head; verdictsreproduced,not-reproduced,hardware-unavailable,no-benchmarkPLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/remediation_finalize.py --help—start --run <run> [--checkpoint allocated|source-collected|selection|plan|implementation|gates-run]writes therun-state.jsonstub of an unfinished run; code-remediate, code-review, and audit (--skill code-reviewalso derives canonical review action content in existing notes/handoff tables and runs the review validator): derives copied metadata, workplan sections, and handoff fields, then renders, writes, validates, and optionally promotes in one call; audit retains its authored findings and substantive evidence while deriving copied gates, confidence, and digest bindingsPLUGIN_ROOT/bin/python PLUGIN_ROOT/skills/code-review/validate_artifacts.py --helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/skills/code-review/review_prepare.py --help— deterministic native-wave preparation and assembly; inspect selected subcommand helpPLUGIN_ROOT/bin/python PLUGIN_ROOT/skills/code-review/review_context.py --help— audited frozen-context delivery to a native reviewer
For the selected workflow path, identify helpers whose invocation is already known, including its required start and closing gates. Run their independent --help commands in one tool batch when the host supports it; keep each command's exit status and complete output available. Return a compact labeled index of each helper's usage and relevant option descriptions, targeting at most 16 KiB of aggregate text; retain full help in the tool session or run artifacts so it can be inspected without rerunning the command. If the index exceeds that bound, return status and usage for every helper and inspect needed option details from retained output. If an option's meaning is absent or ambiguous in the index, inspect that helper's retained full help before invoking it. When top-level help lists only subcommands, inspect the selected subcommand's --help before using its options. Never silently truncate a failed help check or infer an option from a partial response. Do not run the full release roster on every skill invocation. Inspect a conditional helper when its branch is selected, and batch any helpers newly known at that point. Reuse help already observed for the same packaged helper bytes and invocation within the run; a changed package or unknown option requires fresh help. A failed help check blocks that helper's invocation, not unrelated work. Batching never combines approval boundaries or authorizes a networked or paid operation.
Before any PR review or PR remediation preparation, read and apply PR Helper Contract; it binds as if inline here. It covers PR run promotion and PR source/import proof requirements. Common local-diff guards and every workflow's completion lifecycle remain below.
Create every skill run with PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/create_run.py --skill <skill-id>. For a fresh PR review or remediation, add --pr-number <positive-number> from the existing entry preflight; for local review or report-only remediation, add --branch <branch-name> from local Git identity (use detached-<commit-id> for detached HEAD). PR number and branch are mutually exclusive. For Code Review of a PR, include the preflight’s canonical URL with --pr-url <canonical PR URL> so entry can recover a run interrupted before collection. For standalone local Code Review also record --local-scope working-tree|path|commit and add --local-target <selection> for path or commit scope. Omit creation options during promotion. Identity naming needs no additional network read. Other workflows and historical plain calls remain supported. Retain its single printed path, pass that literal path explicitly to every later helper and artifact operation. Never persist path in shell variable or assume state survives between command/tool calls.
Artifact namespaces use .reports/codex/<skill>/<canonical-safe-identity>/run-<NNN>/ only when the skill defines and validates a bounded canonical safe identity; otherwise they use the generated timestamp plus an atomically allocated random suffix under the canonical skill scope. Never serialize raw prompts, paths, URLs, refs, credentials, or arbitrary arguments into directory names. PR review is the first identity-indexed workflow, with the normalized authoritative identity pr-<number>.
Local reviews and non-PR workflows normally keep the initial .reports/codex/<skill>/<timestamp>/ path. Bounded challenge-resolve chunks are the exception: each child uses create_run.py --skill challenge-resolve --root <coordinator-run>/chunks/runs, keeping its ordinary skill/timestamp suffix under the coordinator. The initial run name retains its UTC timestamp and an atomically allocated random suffix, with pr-<number> or branch-<slug>-<digest> between them when supplied. Branch slugs contain at most 40 ASCII letters, digits and hyphens; a 12-character SHA-256 digest binds the original UTF-8 branch text, so slash, Unicode and path-like names never become path components. Existing flat code-review artifacts remain valid lookup inputs, require no migration. Local report-only remediation and collection failures keep timestamp paths; resumed runs retain their existing paths without re-promotion. Existing remediation artifacts are not migrated.
Also run each skill-specific local CLI's --help. Never copy full flags/templates into SKILL.md; state only:
- gate commands or skip reasons
- metadata variable and confidence gaps
- shared validator skill name
- prior skill-specific validator
- extra artifacts and pass/fail rules
Helper JSON and stable stderr codes are machine evidence, not user-facing answers. On any helper failure, owning workflow first explains failed operation in plain English, inspects its retained diagnostics, reports observed cause or explicitly unknown detail. Then retain exact code and evidence, state what safe work continues, name next action, owner, resume condition. Includes collection, report lookup, manifest/preflight validation, local reviewer waves, live calibration, shim diagnostics, escalation-ledger validation. Diagnose within existing authority before asking for action; never invent cause, expose raw sensitive output, rerun paid or deterministically failed operations unchanged, or turn helper's rejected result into acceptance.
Code Remediate validates intake and planning before edits with remediation_finalize.py obligations and preflight --stage selection|plan. The occurrence list is derived from retained producer bytes; the final validator checks exact coverage again. Planning validation retains final production-lifecycle checks and grants no dispatch permission. Finalization derives triage/resolution counts after folding status events.
For an executed canonical gate, gates.json records the chosen launcher in the check's execution_route. A macos-worktree route uses the native single-process sandbox. A standard route uses the existing execution environment and records why the worktree profile did not apply. A not-started route records a preparation or launch failure. Read the gate's status and exit code for the result. The workflow's existing approval and checkout ownership apply to all routes.
Result lifecycle:
run_gates.pywritesgates.jsonand per-gate evidence. Each output stream retains up to one MiB of command output. Longer streams preserve their first and last halves around an omission marker so a test failure summary at the end remains available. Its default per-gate elapsed-time budget is 7200 seconds (two hours);GATE_TIMEOUT_SECONDSand then--timeout-secondsoverride it. The parent monitors concrete progress and diagnoses a proven stall; the runner does not infer progress from output. Optional--expected-head <full-lowercase-sha>guards each executable command with clean Git head/status observations before and after execution; mismatches, dirtiness, inspection errors fail the gate. New release-contract runs require the head flag and matchingmetadata.release_head; unrelated unflagged callers retain their existing behavior. Keep output outside tested source or Git-ignored to avoid self-induced dirtiness. Git source receipts alone do not prove imported package identity.--project-env <absolute existing virtual environment>reuses an already provisioned environment for an isolated--worktree; it does not install tools, authorize network, or relax import-origin checks. Local-diff review mirrors are deliberately dirty: execute gates with that mirror as process working directory, retain artifacts outside it, and bracket acceptance withcollect_diff.py --verify-review-worktreeinstead of the clean-PR head guard.- Write new
final-handoff.jsonwithpresentation_version=17for every new terminal PR close disposition, 18 for an assessed review, or 15 for any other workflow or branch. Set its action policy.final_handoff.py rendervalidates it and writes digest-boundfinal.mdplusfinal-handoff.validation.json. A fresh candidate keeps an earlier supported presentation without a cosmetic migration only where its branch admits one: an assessed review admits versions 8–16 and 18, with 16 reserved for PRs. A Code Reviewunavailablebranch and every other workflow admit 8–15, and a terminal PR close requires 17. Historical results retain their recorded presentation and exact rendered bytes. write-result.pywrites schema-v2result.candidate.jsonfor other skills and schema-v3 candidates for every current Code Review disposition, reconciles status with gate evidence, and requires final-handoff binding in metadata.- Run configured skill-specific validation.
validate-artifacts.pyvalidates shared and skill-specific artifact contract, rerunsfinal_handoff.py check, reconciles handoff with gates, confidence, workflow evidence.- Rename only validated candidate to
result.json. For code-review, complete the named-run validation below before emitting any final bytes; other artifact workflows emit validatedfinal.mdbytes verbatim. Approved nested review uses Nested review delivery; all artifact and completion gates remain mandatory.
For code-review, step 6 finishes through find-review-report.py --complete-run <run-directory>: both artifact validators rerun against that run's canonical promoted result, without requiring it to be the newest report for its PR; emit final bytes only after that validation. Explicit --result intake and default PR report discovery retain their strict newest-run checks: the current report root supersedes legacy for the same PR because each root allocates run numbers independently, then each root orders its own PR runs numerically. Current schema-3 writers use the presentation assigned to their disposition above; readers admit the earlier candidate presentations step 2 lists for that branch; canonical historical results retain their existing compatibility; historical schema-2 caller-contract handoffs remain readable, and schema-2 or schema-3 reports without current proof are available only through explicitly unverified --archive-result output. A failed handoff starts with plain-English explanation of incomplete operation, then its exact process status, retained evidence, specific next action—not normal assessed-final verdict or bare blocker code. This command is read-only, does not repair or promote candidates; caller owns permitted diagnosis and evidence-backed recovery.
Review intake through --target or --result also reruns both artifact validators before returning the canonical artifact path. PR intake uses its recorded producer thread by default; an explicit producer override remains validated. Discovery metadata alone never makes a report actionable, including historical reports whose supported schema still must pass its validators.
Never hand-write result.json, promote unvalidated candidate, manually reconstruct validated final text, or infer flags from stale examples. See final-handoff-contract.md.
Resume And Re-entry¶
Applies to every skill at initial entry and automatically after a recovered failure or nested-skill return, as well as continuation after user intervention, approval, context compaction, or a repeated invocation. First apply Proactive recovery and delivery; no new user turn is needed to resume feasible authorized work. Re-entry changes where work resumes, not what completion requires. A request to continue or retry is not an exact-output override, never waives the normal closing gate.
- Re-read selected skill's current output contract, recover run path, objective, source identity, prior actions, gate status from retained evidence. Never infer completion from prior chat answer, passing tests alone, or notes containing recommendation.
- Identify first unmet checkpoint. Reuse evidence only while its source, scope, inputs remain valid; repeat invalidated checks, never replay completed work merely because user intervened. Preserve old attempts; missing trustworthy state requires fresh documented run, not invented provenance. Re-entry doesn't reset recurrence counts, authorize another failed paid wave, or broaden permissions.
- Complete remaining workflow and its normal closing gate. Artifact workflows still require gates, rendered handoff, candidate, validation, promotion, exact final output in order above. Code Review additionally requires its completion/discovery check. Preserve required summary labels and tables after plain-English opening; never replace them with informal bullet recap. Approved nested review uses Nested review delivery; all artifact and completion gates remain mandatory.
- If closure can't pass, explain incomplete checkpoint, actual cause or unknown detail, governing rule, continuing work, specific next action/owner/resume condition. Label evidence preliminary; never claim standard result passed or present merge verdict. Diagnose and perform authorized recovery before handing work back.
agent-shims retains its documented non-artifact exception, not closing-gate exception: re-entry still completes selected action's verification and diagnostic interpretation before its normal final answer. Never fabricate result artifacts or introduce new lifecycle solely to enforce presentation.