Implementation
06: Build And Approve The Work Bucket Plan¶
Only when evaluating or executing
parallel-specialists, read parallel-lifecycle.md before freezing its plan; parent-owned and sequential routes do not load it. The reference preserves production lifecycle's containment, dispatch-record, verification, reconciliation, rollback, and cleanup obligations.
On return from PR scope selection, verify the current PR target before freezing a source-dependent plan. Before any selected-scope edit or specialist spawn, write <run-directory>/resolution-workplan.md sections:
## Work Bucket Plan: one row per bucket with selected indexes, role, owned files/evidence, dependencies, and checks; identify intentionally shared files.## Parallel Approval: parallel feasibility, exact plan digest, dispatch source/status, and actual execution mode. For an ineligible parallel plan using the workflow-default parent-only route, include exactly one nonemptyIneligibility reason: <reason>line tied to this plan and available runtime. The validator rejects common placeholders; the parent must verify the reason against available evidence. Do not ask the user to approve parent-owned or sequential execution.## Execution Order: dependency-aware bucket order andparent-owned|sequential-specialists|parallel-specialistsmode.## Ungrouped Items: alwaysnone; every selected item belongs to exactly one bucket, including parent-owned work.
Before the first selected-scope edit, record <run-directory>/commit-baseline.json: current HEAD, the parsed path/status inventory from raw git status --porcelain=v1 -z, and the exact paths planned for each work bucket. This is an ownership boundary for an optional later commit, not a requirement for remediation. Unrelated tracked or untracked changes, including a lockfile such as uv.lock, do not block remediation or PR collection unless checkout would overwrite that exact path. A path already changed at the baseline is never automatically commit-eligible; retain it unstaged and do not restore, stash, reset, or otherwise hide it. Exclude run artifacts under .reports/ from every commit unit.
Late baseline capture is an agent process error. Current dirtiness alone proves neither pre-existing user edits nor agent ownership. Preserve the late capture unchanged and record commit-ownership-recovery.md: identify the first edit, retained pre-edit status and source snapshots, exact baseline HEAD/branch, affected paths, and the complete agent edit sequence through current bytes. Recover a separate pre-edit commit-baseline.json from those contemporaneous records only when they prove each candidate path was initially clean and every subsequent edit is task-owned; cite the preserved late capture and recovery in the commit plan. If that name already holds the late capture, retain it byte-exact under a distinct evidence path before writing the recovered baseline. Never infer ownership from memory, current HEAD or dirty status; never fabricate an empty baseline. Absent or disputed evidence leaves affected paths unstaged with the precise ownership gap, while other authorized checks and closeout continue. This recovery supplies ownership proof only; it grants no commit authorization and waives no verification or destination check.
Also write <run-directory>/work-bucket-plan.json with exact work_buckets array used to render user-visible table. Use schema_version=1 for parent-owned, sequential, and planning-only work. For production parallel-specialists, include consumer, source repository relative to its workspace parent, a supported isolated worktree root, exact baseline HEAD/tree, rollback and cleanup policies, context-pack hashes, resource locks, output paths, and the fixed verification gate. Put exact scoped verification commands in the context packs. Use an existing sibling .codex-rig-worktrees/<run-id> root or prefer source-local .reports/codex/code-remediate-worktrees/<run-id> when it is Git-ignored and resolves to the source repository or one child directory. Reject symlinked or escaping roots and pre-existing run roots. Keep plan, dispatch record, state, patches, reconciliation, rollback material, and lifecycle projection in source-local <run-directory>. Hash exact plan bytes with SHA-256 and record digest in workplan before dispatch. The table, JSON, metadata, and dispatch record must describe and bind the same plan bytes. Choose the schema before freezing the plan.
For an explicit, still-authorized group findings by topic choice, put findings that close the same behavior or module in the same commit unit. A wave qualifies for worker-owned commits when it has two to four independent units with pairwise disjoint tracked paths, each unit fits one work bucket, the authoritative source is attached to a verified branch, and it can run the configured test suite on the consolidated source before delivery. Freeze schema_version=3, commit_mode=grouped, and source_branch from git symbolic-ref HEAD in that case. Record the explicit choice in commit_choice with mode=grouped and source=explicit-input|user-prompt. Before writing the grouped plan, record two separate lines under ## Upfront Decisions in resolution-workplan.md. Write Commit choice: group findings by topic (<source>) using the actual explicit answer and its recorded source. Determine the full test invocation from project guidance and record its exact command on the Full test command: <command> line. Freeze that same command as tests_command and each bucket’s exact targeted commands as verification_commands. Order independent buckets by stable IDs and record any dependencies before choosing the route. If the units share paths or cannot meet these checks, keep the parallel patch route when eligible and do the authorized topic commits at step 12. All-at-once runs can use multiple parallel patch workers. The parent creates their single final commit after consolidation and verification. Use schema_version=2 for parallel patch work.
Group per capable specialist/domain when it reduces duplicated context or preserves one root cause. Valid keys:
- shared affected files/modules/tests/docs/CI workflows
- same closure type: code, tests, docs, CI, security, typing, performance, review-gate, merge/conflict
- same root cause/expected fix
- same verification command/closure evidence
- same merge/conflict collision risk
Group by coherent fix and capable role; do not manufacture a second task or spawn one specialist per finding merely to claim parallelism. A work bucket contains at most five selected items and each selected item appears in exactly one bucket. Parallel buckets may name the same exact repo-relative file when their roles have independent work in isolated worktrees. Reject absolute paths, globs, .., duplicate aliases, and ancestor/descendant path overlap. Identify every shared file and the parent reconciliation owner before dispatch. A collision discovered after join stays in the integration worktree until the parent reconciles it and verifies the final postimage; never silently choose a child's version.
Check the retained run directory against the production helper’s evidence boundary before choosing isolated workers. The helper requires plan, approval and state under the source checkout’s .reports/codex/code-remediate/. When intake placed the authoritative run under the Git directory or outside that checkout, retain it there, record this concrete parallel-ineligibility reason, and execute the selected work through the parent-owned or sequential route.
Plan parallel dispatch by default after selection:
- Create the fewest coherent role/domain buckets that cover selected items, whether the selection has fewer or more than five items; never split one coherent fix only to reach two buckets.
- Use
parallel-specialistswhenever at least two buckets can work independently in isolated worktrees, including when they share an exact file that the parent can reconcile after join. Do not convert eligible work to parent-owned or sequential because handoff overhead is higher. - If selected work is indivisible, dependent, or runtime capacity is unavailable, continue with the available parent-owned or sequential route and record the concrete reason, actual mode, and applicable plan status. Put exactly one nonempty
Ineligibility reason: <reason>line in## Parallel Approval, tied to this plan and available runtime. The validator rejects common placeholders; the parent verifies whether evidence supports the reason. Do not fabricate independent writers from dependent implementation, QA, or read tasks. If a production precondition fails, identify the specific unsafe operation and path, evidence of possible damage, and safe isolation alternatives; unrelated dirty paths, a sibling-root inconvenience, handoff overhead, and reconcilable shared-file edits alone are not blockers. Missing parallel capacity is not a reason to stop authorized work.
For an eligible parallel plan, show the complete ## Work Bucket Plan table and SHA-256 digest before dispatch. Record source=workflow-default, response=approve, and prompt_presented=false against the exact frozen plan bytes; this is a workflow dispatch decision, not a claim of user approval for that specific digest. An existing explicit user choice for the exact plan may instead use source=explicit-input or source=user-prompt. Only when the upfront packet answer is show the plan and wait for my approval, ask Approve / Deny for the shown digest through User Questions and record source=user-prompt with prompt_presented=true; this opted-in review is the one plan question allowed mid-run. Do not spawn until the plan, context packs, baseline, and verification preflight pass. For an ineligible plan, record why parallel execution is unavailable and continue authorized work in the available mode without an approval prompt. An explicit user denial still stops the denied route; missing authorization for an unsafe operation still stops that operation.
Write <run-directory>/parallel-approval.json with exactly plan_sha256, source=workflow-default|explicit-input|user-prompt|not-required, response=approve|parent-only|not-required, and prompt_presented. Parallel dispatch requires response=approve, parallel_approval_status=approved, and approved_plan_sha256 equal to current bucket-plan digest. For an ineligible plan, the four-field approval artifact records response=parent-only, source=workflow-default, and prompt_presented=false. In CODE_REMEDIATE_METADATA.resolution_workplan, also record parallel_eligible=false, parallel_approval_required=false, parallel_approval_status=parent-only, and approved_plan_sha256=null; this records the parent-only route and is not approval for a different or unsafe operation. Historical not-required records remain readable through the historical result reader. New result.candidate.json validation rejects that legacy dispatch source for selected work; emit the current default or explicit-choice dispatch record before promotion.
For a selection of at most five items, multiple sequential buckets are permitted when execution_mode=sequential-specialists, owners include distinct capable roles, and every bucket declares nonempty grouping_rationale, expected_closure, and dependencies. Dependencies name earlier bucket IDs only; use [] for no prerequisite. Keep the concrete parallel-ineligibility evidence above. One coherent parent bucket remains the default for indivisible work; artificial same-owner per-finding fan-out remains invalid.
After writing work-bucket-plan.json and parallel-approval.json, inspect PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/remediation_finalize.py workplan --help and run its workplan action. It writes the ## Work Bucket Plan, ## Parallel Approval, ## Execution Order, and ## Ungrouped Items sections of resolution-workplan.md from those two files and keeps every other section, such as ## Upfront Decisions; pass --ineligibility-reason for a workflow-default parent-only plan. Do not hand-write those four sections or copy the plan, its digest, approval fields, or group counts into metadata: the helper derives them. Author only parallel_eligible and parallel_approval_required in the workplan metadata. Then run PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/remediation_finalize.py preflight --run <run-directory> --stage plan --metadata <metadata-draft.json> before any selected-scope edit or dispatch. It derives plan copies and checks ownership, exact selection coverage, dependencies, approval digest and rendered plan together. No completed outcome is needed. Parallel work still requires its existing production preflight before dispatch and complete runtime evidence at finalization; the planning check never replaces either gate.
Every bucket row records:
- bucket id
- selected indexes
- severity range
- grouping rationale
- primary owner:
parent|sw-engineer|qa-specialist|doc-scribe|cicd-steward|linting-expert|data-steward|scientist|squeezer|oss-shepherd - verifier:
parent|qa-specialist|security-auditor|linting-expert|cicd-steward|challenger|solution-architect|none - context pack path
- expected closure evidence
- dependencies or
none - owned files/evidence; identify exact files shared by parallel buckets for parent reconciliation
- execution mode:
parent|sequential|parallel - execution status:
planned|in-progress|fixed|verified|deferred|unresolved, recorded only asbucketstatus events and rendered in the table'sStatuscolumn (defaultplanned)
When a selected scope has distinct independent role/domain work, use separate buckets even with five or fewer items. A single coherent, indivisible, or dependency-bound bucket continues parent-owned or sequentially with the concrete reason recorded; the parent retains acceptance and source application.
Owner assignment rules:
- implementation/refactor/API:
sw-engineerprimary,qa-specialistverifier. A public API/migration concern stays with the parent/session unless the user expressly requests architecture advice or selectssolution-architect; then it is a bounded read-only verifier/context artifact, never primary, returned to the parent for acceptance. - test gap/regression proof:
qa-specialistprimary,parentverifier. - docs/changelog/examples/docstrings:
doc-scribeprimary,parentorqa-specialistverifier for executable docs. - CI/workflow/release gate:
cicd-stewardprimary,parentverifier. Permission/secret work stays with the parent/session unless the user expressly requests security advice or selectssecurity-auditor; then it is a bounded read-only evidence artifact returned to the parent for acceptance. - SemVer/compatibility classification, deprecation-cycle correctness, or release-readiness/blocker impact:
oss-shepherdprimary,parentverifier; changelog/migration prose staysdoc-scribe, release automation stayscicd-steward. - lint/type/pre-commit/suppression:
linting-expertprimary,parentorqa-specialistverifier when runtime could change. - security/dependency/permission/data exposure: parent/session primary,
challengerverifier for high/critical/non-obvious closure. Usesecurity-auditoronly on user-explicit advisory request or role selection, as bounded read-only evidence artifact; it never becomes primary or accepts closure. - data/ML/research/performance:
data-steward,scientist, orsqueezerprimary;qa-specialistverifies tensor/data boundaries. - review-gate/follow-up: primary role matching missing evidence,
parentverifier; unresolved when evidence needs unavailable CI, maintainer review, user-deferred external step. - merge/conflict collision:
sw-engineerprimary;challengerverifies critical/high/non-obvious; cite<run-directory>/merge-prestage.md.
For each non-parent bucket write narrow <run-directory>/specialists/<bucket-id>-context.md: selected bucket only, relevant files/hunks/logs, closure question, stop rule, expected evidence. Omit unrelated findings, full PR discussion, and full review report by default.
Every owner/verifier must be one of enums above. Parent buckets use execution_mode=parent; specialist buckets use sequential|parallel. Every specialist context-pack path must resolve inside run directory and exist before dispatch.
Record CODE_REMEDIATE_METADATA.resolution_workplan: existing group/owner/verifier counts and path; max_items_per_bucket=5; execution_mode; bucket_plan_path, bucket_plan_sha256, parallel_approval_path, eligibility, approval requirement/status/source/response, prompt flag, approved_plan_sha256; plus work_buckets with bucket id, selected indexes, owner, owned paths/evidence, execution mode, and any singleton rationale.
Production Parallel Lifecycle¶
For parallel-specialists, follow loaded lifecycle reference through verification, join, any parent reconciliation, source application, and cleanup before claiming completion. Parent-owned and sequential execution continues with step 07 after recording its ineligibility reason and actual mode.
07: Apply Fixes In Selected Scope¶
Fix selected scope in priority: critical -> high -> medium -> low.
In mode=pr, integrate the fetched target and complete its authorized merge commit, including when conflict-free (skip the merge only when target ancestry proves it is already included) before selected report/online-review findings. For parent-owned or sequential execution, fix one selected valid group at a time. For approved production parallel execution, follow the loaded production lifecycle reference and treat the parent join as the barrier before source application. <run-directory>/resolution-workplan.md remains the execution ledger. Never edit unselected findings or a selected item outside its assigned group unless the workplan is updated first with the reason and affected closure evidence. After each group, append its closure record to the append-only <run-directory>/closure-log.md: write one ### <bucket-id> block with changed files, verification, and evidence to <run-directory>/closure-log.md.rec with the filesystem tool, then run PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/remediation_finalize.py append --run <run-directory> --ledger closure-log.md, which appends it, creates the ## Closure Evidence heading on first use, and removes the .rec file. Never rewrite an earlier closure entry; a correction is a new block. Record the group's status change as a bucket status event.
For any PR, apply Contributed Code Execution to targeted runs and the step 09 gate. Reuse an authenticated safe review for matching inputs. Otherwise inspect the exact command, its startup hooks, configuration, tests and code it loads in the current checkout. Run safe checks normally under existing host permissions. If the command would execute suspicious code, inspect it statically and repair it first when authorized. Record that evidence in place of an unsafe failing reproduction. Reassess the modified inputs before running verification. When risk remains, confine that command or leave it unexecuted, and continue independent safe work. An explicit --sandbox applies throughout.
Targeted pytest runs during implementation and verification in steps 07 and 08 follow Sandboxed Test Runs: add -p no:xdist when its conditions hold, so they run inside the sandbox without escalation. Use that section’s direct PR remediation test launcher for sandboxed pytest runs on the protected contributor route, for authorized reproductions and post-edit reruns. After each group's edit, inspect PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/test_targets.py --help, run it for that group's changed files and run its pytest_args, or the group's targeted acceptance check for non-Python scope; never run the full suite per finding or per group. After a sole common:refs stop, try the verified target-branch fast-forward procedure. For eligible ignored-file drift, follow Restart after inspected integrity drift and repeat the affected gate in the verified interval. The full suite runs exactly once, at the step 09 gate, with the repository's own settings; a later file change reruns that complete bundle under step 09's rerun rule. A documentation-only change skips that run as step 09 states.
08: Challenge Closure Before Full Gates¶
For schema-3 topic commits, challenge the consolidated changes in the detached integration checkout and bind all review and verification inputs to its exact tip. Keep the authoritative checkout at its frozen baseline until step 09 passes.
For every selected fixed finding answer:
- Does original failure still reproduce?
- Could it pass review but remain functionally wrong?
- Which regression check protects it now?
- What risk remains?
Missing closure evidence keeps item unresolved. When the original failure does not reproduce or contradicts the finding, consult reviewer evidence before closing it as rejected.
Append the item's closure evidence to closure-log.md through the step 07 append before recording its fixed status event.
Classify how closure happened, not just whether the item is open. An implemented item requires this run's finding-specific change and verification evidence. A target integration is not finding implementation: record its commit and upstream files separately, and count a finding fixed by integration only when its exact required behavior and regression evidence are demonstrated. Fresh passing CI may close the corresponding CI obligation without any source change; it cannot close an independent-review or code-behavior obligation. Existing correct behavior, signed agreements, stale notices, and duplicate findings need their own evidence-backed dispositions, not implied patches.
Apply ../../../shared/specialist-orchestration.md when selected findings cross specialist domain. <run-directory>/resolution-workplan.md is source of truth for closure ownership; write <run-directory>/specialist-closure-plan.md only for post-fix verification beyond workplan owner/verifier. Context packs stay group-local: selected group, changed files, closure evidence, exact verification question; omit unrelated review items/PR discussion.
Execute already-authorized workplan owner/verifier assignments without another review choice; do not retroactively add an optional reviewer to those assignments. The selected remediation scope authorizes its required local checks. For an implemented change, obtain one bounded independent challenge of the changed result under Proportional Execution, preserving actual host and paid-execution boundaries; this bounded pass is not an iterative loop. It is not closure evidence for any finding, not required specialist verification and not an explicit independence requirement; closure rests on each finding's own regression and gate evidence. When it cannot run — its route stays unavailable after one bounded diagnosis of an agent-owned setup failure, a bridge or provider call is denied by approval review, or the user declines it — do not ask, retry it through another route, or record an unresolved row, blocker or incomplete status for it. Record implementation challenge not run: <reason> under the result limitations and the confidence gap (-0.NN) implementation-challenge-not-run: <reason>, continue to step 09, and complete when selected findings are closed and gates pass. An additional independent review requires the specific user decision in Review limitations and additional review; all, a confidence gap or a failed reviewer launch alone does not authorize it. Joined +review authorizes its intake review step; the separate implementation challenge follows the shared proportional contract. An explicitly approved bounded closure review permits at most one closure-verification pass for its stated expectation. After corrections rerun affected executable checks, but do not dispatch another reviewer by default. If the user declines or dismisses another pass, finish with the factual verification limitation and no synthetic finding, blocker, open review obligation or repeated request. Do not claim independent coverage was obtained when it was not. Explicitly requested convergence workflows retain their own authorized loop.
After that authority check, select closure roles by domain below; these triggers alone never authorize dispatch. Before freezing inputs or dispatching an authorized pass, complete step 09's format preparation. These roles do not start a convergence loop:
qa-specialist: bug fix, test gap, regression proof, or behavioralready-appliedclaim.security-auditor: only when user expressly requests that advisory pass or selects that role for auth, credentials, deserialization, dependency/supply-chain, permissions, or data exposure; return its bounded read-only evidence artifact to the parent/session for closure acceptance.cicd-steward: GitHub Actions, release automation, flaky CI, gate-environment failures.linting-expert: ruff, mypy, pre-commit, type/lint config, suppression changes.doc-scribe: public docs, changelog, examples, migration text, public docstrings.data-steward,scientist, orsqueezer: data/ML/research/performance findings.challenger: critical/high, conflict resolution, or closure based on non-obvious assumption.
For required or already-authorized verification, if its specialist is unavailable, write labeled in-main substitute evidence in <run-directory>/specialists; lower confidence when independence mattered. A substitute cannot satisfy an explicit independence requirement. Never mark selected high/critical resolved only from parent claim when closure evidence depends on required specialist verification. A declined optional pass creates no substitute-review obligation. An implementation challenge that could not run needs no in-main substitute; any parent re-check stays parent evidence and never counts as independent coverage.
Before authorized dispatch, check that the selected reviewer can inspect every required input under its actual route. A no-tools reviewer must receive the relevant source, diff, and evidence inline; artifact paths alone are not readable context. A context-delivery failure is not a substantive review and does not close the item. Preserve the failed attempt, repair the context, and resume within existing authorization, dispatch-wave and recurrence rules; re-plan before another independent pass when required. If no independent route is available for required or already-authorized work, explain the failed proof and offer the permitted parent-sequential alternative without pretending it meets explicitly required independence. Ask only for a genuinely missing route or scope decision. The bounded implementation challenge above is the exception: its unavailability is a limitation and confidence gap, never a question.
Missing coverage details are an investigation checkpoint, not proof that no fix is possible. Inspect existing coverage artifacts and the project's configured focused coverage command; run authorized reproducible checks and compare missing branches with the selected finding before proposing tests. Obtain external details only through the approved read boundary. Do not add speculative tests or declare missing coverage resolved from green CI alone. If usable evidence remains unavailable after permitted recovery, record the attempted commands, specific missing capability or data, owner, and smallest next action; resume the selected finding when that checkpoint is repaired instead of restarting or silently abandoning it.
09: Run Shared Quality Gates¶
Before running source-dependent gates in PR mode, verify the current PR target.
Before freezing selected changed-file inputs, issuing mutation receipts, or dispatching independent closure review, run the configured format hook on every selected changed file, including tests. If formatting changes a file or the hook fails, resolve it and rerun that same hook until clean, then freeze the inputs and receipts. Run the canonical gate bundle afterward; this preparation does not replace its format result. Any later file change requires refreshed review inputs and a complete bundle rerun, with no skipped applicable checks or rewritten receipts.
Inspect PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/run_gates.py --help and run every project-relevant closure gate with an explicit command or skip reason. Reassess each gate’s actual inputs after a merge or edit. Run safe gates under existing host permissions. When a particular gate requires independent confinement, repeat --sandbox-gate <gate> for each affected gate in the same bundle. An explicit workflow-wide --sandbox request requires verified host confinement for every command or the runner’s strict --sandbox flag. Retain these requirements across retries under Sandboxed Test Runs.
Determine which verification each selected finding requires from the user's request, the finding's acceptance criteria and the project's configured gates. Run every applicable check possible locally, including representative checks on the changed source. Inspect test selection and skips before counting exercised behavior. Prepare declared dependencies and use authorized recovery for a missing capability.
Inspect the cause and logs of every failing gate. For sharded tests, inspect every nonpassing entry in checks[].shards and use that entry’s cause, exit code, and log paths. When any of those causes is missing-python-package or hook-cache-unwritable, build a reviewer-owned environment instead of recording an environment limit: inspect PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/gate_env_provision.py --help, run plan with the review base, the current head, the selected interpreter, an --env-root outside the checkout and the selected test lane's --group, --extra or --requirements (its available_lanes lists the declared ones), run apply --plan <plan.json> --repo <checkout> --base <sha> --head <sha> --python <abs-interpreter> --env-root <abs-dir> --plan-digest <digest> --out <result.json> under the owning network approval. Show the original plan’s plan_digest when requesting approval and pass it as a literal alongside the same five trust inputs, then rerun the gate bundle with the plan's run_gates_args and its gate_environment passed through the execution tool's environment field. Add worktree_run_gates_args only to a worktree-bound run. Names the plan lists under gated, and a blocked plan, stay with the contributor-code gate and keep their recorded cause. A missing-python-package record lists missing_modules; a module still missing after provisioning that the checkout does not provide is an environment cause, while a missing submodule of the project's own package is recorded as command-failed and investigated as a source failure. A source refusal is the single top-level refusal record in gates.json; repair its one reason instead of treating each refused gate as a separate failure. After the gate bundle, run PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/remediation_finalize.py start --run <run-directory> --checkpoint gates-run.
For a selected finding about an author's performance or memory claim, measure the review base and the current head on this host with one method through the same execution route as the gates, then record the verdicts with PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/benchmark_claims.py compare. Compare the relative effect, never the author's absolute numbers. Each record keeps this host's class (operating system, machine and native architecture, accelerators) as a fact of the run, never as a gap. hardware-unavailable applies only to a claim needing a host class this host does not have; its reason starts not reproducible on this host: and names only that class, with the probe evidence for an accelerator. Take a required operating system only from the claim line itself; one named elsewhere is the author's environment (author_os). A claim this host can run records nothing about the host, and nothing is emulated.
- Complete local remediation through the normal validation, delivery and promotion steps when every selected obligation has evidence-backed closure and all applicable local checks pass. An additional comparison requiring unavailable hardware, a hosted runner or another external environment is a verification limit. Record what could not run and why, the affected behavior and the evidence obtained locally. Proceed without another scope decision.
- Keep remediation incomplete for an open or uncertain fix, a skipped feasible check, a failed or timed-out required gate, or outstanding required live verification. If the selected work or project requires a particular environment to prove closure, record the missing proof, owner and next action. Preserve the canonical gate result and its observed failures.
For an ordinary PR remediation with unstaged fixes, launch the gate runner from the exact collected checkout root. Its execution_cwd records the command's starting directory. Retain the source-byte checks for every PR and contributor integrity evidence when the protected route applies.
In the grouped worker-commit route, run these gates with --worktree <integration-checkout> --expected-head <integration_head> --out <run-directory> before applying source. Pass the frozen tests_command through --tests. The receipt binds the executed command and retained output to the integrated tip. Require that exact full test command to pass. A recovery that changes the invocation needs a fresh grouped plan binding, even when it keeps the full suite. When the protected contributor route applies, use its writer barrier and integrity checks with the integration checkout as the selected source. If a configured formatter would change a draft commit, fix the responsible unit in isolation and regenerate the integrated tip before running the final gates. Pass the retained gates.json to apply-source --gates after the gate passes and any required contributor integrity checks succeed. Reuse that source-bound gate run for finalization after verifying that the authoritative branch contains the exact tested tip.
Configured-hook failures follow Hook Failure Recovery, including equivalent PR/target checks, root-cause evidence, authorized repair and revalidation. A known failing hook blocks a commit, not permitted investigation and repair; retain scope, recurrence and actual capability boundaries.
Independent closure dispatch follows step 08's authority boundary; these gates do not authorize another review pass.
Keep the repository's configured test command unchanged on the first attempt. For a pre-collection loopback bind denial from xdist coordination, retain the failed gate, verify integrity on the protected contributor route and apply the full source-bound serial retry in Sandboxed Test Runs. When xdist supplies scheduling only, retry the gate in the same sandbox with the same checkout and proof, full selection, reruns, coverage and timeouts. Remove the effective xdist settings and add -p no:xdist only for the retry. Repeat integrity verification on the protected contributor route and report both attempts. If worker isolation, xdist-specific behavior or an exact command is required, keep that gate blocked and label any serial result separately. A sandbox-only choice excludes an unsandboxed approval request.
The gate runner writes raw coverage data and default pytest-cov file reports under <run-directory>/checks/. Configured report destinations inside the run directory are retained. A fresh protected pytest cache inherits the configured cache’s built-in selection history. Repeated tests in the same evidence directory use the updated run-local history. The pinned test-runner approval does not cover the gate runner: when the test gate still requires escalated pytest and the user permits that route, request a one-time escalation for the complete run_gates.py command without prefix_rule, as Sandboxed Test Runs defines. When a protected interval applies, run verify after the gate and preserve its confinement under Contributed Code Execution. The ordinary gate uses normal host approval on any origin. A documentation-only change uses that section's approval-free --skip-tests record instead of the test command.
Verify the current PR target¶
For PR remediation, check the base again when work resumes after selection, before final source-dependent gates, and before delivery or a push offer. After a pause, use the audited PR reader to confirm the PR is still open and that its base repository and branch and original head still match collection. For a push offer, reuse the verified verdict from PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/publication_preflight.py --routing <admitted run>/pr/pr-routing.json already run in step 1 of the publication gate. If the PR was retargeted, retain the former receipts and collect the new routing before integrating. Run PLUGIN_ROOT/bin/python PLUGIN_ROOT/shared/collect_pr.py --target <canonical PR URL> --out <absolute run-directory>/pr --check-integration-target from the verified PR checkout. Use the returned full target_oid in git merge-base --is-ancestor <target_oid> <expected delivery HEAD>. Exit 0 permits continuation even if the target advanced since collection. Exit 1 requires integration. A failed read or Git error leaves freshness unverified. Keep the original target and merge receipts as evidence of the initial integration.
When the new target is absent, retain the observation in merge-prestage.md. Prove the last integrated target is its ancestor before treating it as a fast-forward. A rewritten target takes the source drift recovery route. For an ordinary run on a clean attached branch, use the same authorization, merge preview, conflict review, exact-OID merge and two-parent verification as step 03. Record the new target, pre-merge and resulting commits, resolved paths and checks separately in that log and the delivery ledger. Reassess selected findings on the resulting source and rerun the affected closure checks and final gates. An explicit OID limit or a withheld merge still controls. Keep uncommitted work intact: when commit grouping was authorized, finish its existing verification and authorized units before the clean merge. When changes must stay unstaged, preserve them and report the exact integration still pending if the merge is withheld. Preserve unrelated dirty work under the existing checkout recovery rules.
A grouped lifecycle binds its integration baseline, gate digest and applied commit. When catch-up changes one of those values, or an existing publication offer or promoted result binds the old delivery, use a new run and fresh source collection. Keep the old run and unpublished branch intact. If that branch already has local commits, use the established independent checkout route in a separate repository with its required location choice. Verify native checkout at the remote PR head, integrate the live target, reuse still-valid selections and reconcile each previously owned fix against the new source. Replay only proven finding changes that are still needed, respecting the chosen commit groups. Complete the plan, local gates and delivery against the new revision before offering its exact commit for push. An explicit decline or an uncertain earlier send still stops publication.
10: Write Unresolved Findings¶
Write unresolved findings to <run-directory>/unresolved.txt.
When selected items remain unresolved, distinguish fixed work from still-needed process/environment/CI/external-review action. Include:
Unresolved Work Summary: selected total/resolved/unresolved; local actionable unresolved; process/gate unresolved; environment blocked; external-owner blocked; whether all local code/doc findings closed.Why Selected Items Remain Unresolved: one row/unresolved selected item or reason group: selected indexes, severity, closure class, status, reason, attempted evidence, next owner/action.Next Action: smallest concrete action closing each unresolved reason group.
Use closure classes: local-code-or-doc, process-gate, independent-review, environment-blocked, external-ci, user-deferred, already-closed, other. With remediation_scope=all, never say "resolved all" while selected item unresolved. Say "all local actionable findings are closed" only when local code/doc closed; separately list remaining selected gate/process obligations.