<!-- task=m-iop-agent-cli-runtime/09+05_workflow_evidence plan=2 tag=REVIEW_REFACTOR -->

# Code Review Reference - REVIEW_REFACTOR

> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.**
> The task is NOT complete until every implementation-owned section below is filled in.
> Complete the `Implementation Checklist`; the final checklist item is mandatory before saving.
> Fill implementation-owned sections, then stop with active files in place and report ready for review.
> If implementation is blocked, record the exact blocker, attempted commands/output, and resume condition only in implementation-owned evidence fields.
> Do not ask the user directly, present choices, call user-input tools, create control-plane stop files, or classify the next state.
> Finalization (`Code Review Result`, log rename, `complete.log`, archive moves, `Review-Only Checklist`) is review-agent-only, even after compaction/resume.
> Follow the ownership table at the bottom of this file for which sections you own.

## Overview

date=2026-07-29
task=m-iop-agent-cli-runtime/09+05_workflow_evidence, plan=2, tag=REVIEW_REFACTOR

## Roadmap Targets

- Milestone: `agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-cli-runtime.md`
- Milestone link: [Milestone 문서](agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-cli-runtime.md)
- Task ids:
  - `workflow-evidence`: common artifact matcher, review gate, Pi evidence repair
- Completion mode: check-on-pass

## Archive Evidence Snapshot

- Prior plan: `agent-task/m-iop-agent-cli-runtime/09+05_workflow_evidence/plan_local_G02_1.log`
- Prior review: `agent-task/m-iop-agent-cli-runtime/09+05_workflow_evidence/code_review_cloud_G05_1.log`
- Verdict: FAIL
- Findings: Required=1, Suggested=0, Nit=0. `RecoveryExecutionSubmitted` bypasses `Submission.Ready` and `gateSubmissionEvidence` before official review.
- Affected files: `packages/go/agenttask/reconcile.go`, `packages/go/agenttask/manager_test.go`
- Reviewer verification: focused matcher/manager tests, package tests, race, vet, all `packages/go/...` tests, formatting, boundary search, and `git diff --check` passed; the passing suite does not exercise recovered placeholder/mismatched evidence.
- Roadmap carryover: `workflow-evidence` remains pending until recovery uses the same matcher gate and records review-invocation/locator evidence.

## For the Review Agent

> **[REVIEW AGENT ONLY]** The finalization steps below are review-agent only. Implementing agents must not execute this section.

Compare implementation of each item against source files and verify that output in `Verification Results` matches code.
Review completion means the following steps are finished:

1. Append verdict and `review_rework_count` / `evidence_integrity_failure` routing signals.
2. Archive `CODE_REVIEW-cloud-G06.md` → `code_review_cloud_G06_2.log` and `PLAN-cloud-G06.md` → `plan_cloud_G06_2.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-iop-agent-cli-runtime/09+05_workflow_evidence/`. If WARN/FAIL, fully write the next filesystem state required by the code-review skill.
4. If PASS and task group is `m-<milestone-slug>`, report completion event metadata. Roadmap state check and `update-roadmap` calls are runtime responsibilities.
5. Check applicable `Review-Only Checklist` items at the final `.log` location before reporting.

---

## Implementation Item Completion

| Item | Status |
|------|---------|
| REVIEW_REFACTOR-1 Enforce the workflow evidence gate during recovery | [x] |

## Implementation Checklist

- [x] Gate `RecoveryExecutionSubmitted` with `Submission.Ready` and `gateSubmissionEvidence` before persisting `submitted`/`reviewing`; retain typed blockers and Pi repair/rematch behavior.
- [x] Add a recovery regression matrix proving complete evidence can review while recovered incomplete, placeholder, inactive/identity-mismatched evidence cannot, and Pi reviews only after same-context repair plus rematch.
- [x] Run every Final Verification command exactly and paste actual stdout/stderr into `CODE_REVIEW-cloud-G06.md`.
- [x] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Review-Only Checklist

> **[REVIEW AGENT ONLY]** This checklist is used only by the review agent.
> Implementing agents must not modify or check this section.

- [x] Append one verdict of `PASS`, `WARN`, or `FAIL` and verified `review_rework_count`, `evidence_integrity_failure` to `Code Review Result`.
- [x] Verify that verdict, `Dimension Assessment`, and Required/Suggested/Nit classifications match.
- [x] Archive active `CODE_REVIEW-*-G??.md` to `code_review_cloud_G06_2.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G06_2.log`.
- [x] Verify that the Agent-Ops managed block in `.gitignore` unignores `agent-task/**/*.md` and `agent-task/**/*.log` and ignores `agent-roadmap/current.md`.
- [x] If PASS, write `complete.log` based on `agent-ops/skills/common/code-review/templates/complete-log-template.md` and leave no active `.md` files.
- [x] If PASS, move active task directory `agent-task/m-iop-agent-cli-runtime/09+05_workflow_evidence/` to `agent-task/archive/YYYY/MM/m-iop-agent-cli-runtime/09+05_workflow_evidence/` and update this checklist at the final archive path.
- [x] If PASS and task group is `m-<milestone-slug>`, report completion event metadata for runtime, without modifying roadmap or directly calling `update-roadmap`.
- [x] If PASS for split work, remove empty active parent `agent-task/m-iop-agent-cli-runtime/` or verify it was kept due to remaining siblings/files.
- [ ] If WARN/FAIL, write the next filesystem state matching code-review verdict and do not write `complete.log`.

## Deviations from Plan

None.

## Key Design Decisions

Updated `applyExecutionRecovery` in `packages/go/agenttask/reconcile.go` to clone the recovered submission and evaluate `Submission.Ready` and `gateSubmissionEvidence` before persisting `submitted`/`reviewing` states or invoking the reviewer. Added `TestRestartRecoveredSubmissionRequiresWorkflowEvidence` in `packages/go/agenttask/manager_test.go` to verify complete evidence recovery, incomplete submission readiness blocking, non-Pi placeholder evidence blocking, identity-mismatched evidence blocking, successful Pi repair/rematch, and failed Pi rematch blocking.

## Reviewer Checkpoints

- Confirm every recovered submission checks `Ready` and provider-neutral evidence before any `reviewing` transition.
- Confirm recovered non-Pi placeholder, inactive/identity mismatch, and Pi incomplete-rematch cases make zero reviewer calls.
- Confirm recovered Pi repair uses the persisted native session locator/dispatch ordinal and reviews only after a fresh complete rematch.
- Confirm normal dispatch matching and existing recovery/integration replay behavior remain unchanged.

## Verification Results

Paste actual stdout/stderr below each command. If a command changes, record the replacement and reason in Deviations from Plan.

### `command -v go && readlink -f "$(command -v go)" && go version && go env GOROOT`

```
/config/.local/bin/go
/config/opt/go/bin/go
go version go1.26.2 linux/arm64
/config/opt/go
```

### `git status --short`

```
 M agent-contract/index.md
 M agent-contract/inner/agent-runtime.md
 M agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-cli-runtime.md
 M agent-roadmap/sdd/automation-runtime-bridge/iop-agent-cli-runtime/SDD.md
 M go.mod
 M packages/go/agentguard/admission_integration_test.go
 M packages/go/agentguard/canonical.go
 M packages/go/agentguard/types.go
 M packages/go/agentprovider/catalog/lifecycle_conformance_test.go
 M packages/go/agentprovider/cli/status/quota.go
 M packages/go/agentprovider/cli/status/quota_test.go
 M packages/go/agenttask/dispatch.go
 M packages/go/agenttask/integration_queue.go
 M packages/go/agenttask/integration_queue_test.go
 M packages/go/agenttask/intent.go
 M packages/go/agenttask/manager.go
 M packages/go/agenttask/manager_integration_test.go
 M packages/go/agenttask/manager_test.go
 M packages/go/agenttask/ports.go
 M packages/go/agenttask/reconcile.go
 M packages/go/agenttask/review.go
 M packages/go/agenttask/state_machine.go
 M packages/go/agenttask/state_machine_test.go
 M packages/go/agenttask/test_support_test.go
 M packages/go/agenttask/types.go
 M packages/go/agenttask/workflow.go
?? agent-contract/inner/iop-agent-cli-runtime.md
?? agent-task/archive/2026/07/m-iop-agent-cli-runtime/05_contract_boundary/
?? agent-task/archive/2026/07/m-iop-agent-cli-runtime/06+05_config_registry/
?? agent-task/archive/2026/07/m-iop-agent-cli-runtime/07+06_target_policy/
?? agent-task/archive/2026/07/m-iop-agent-cli-runtime/08+06,07_quota_failure/
?? agent-task/archive/2026/07/m-iop-agent-cli-runtime/10+06_state_recovery/
?? agent-task/m-iop-agent-cli-runtime/
?? packages/go/agentconfig/runtime_config.go
?? packages/go/agentconfig/runtime_config_test.go
?? packages/go/agentconfig/watcher.go
?? packages/go/agentpolicy/
?? packages/go/agentstate/
?? packages/go/agenttask/confinement_dispatch_test.go
?? packages/go/agenttask/failure_continuation_test.go
?? packages/go/agenttask/workflow_evidence.go
?? packages/go/agenttask/workflow_evidence_test.go
?? packages/go/agentworkspace/
```

### `go test -count=1 -run 'TestRestartRecoveredSubmissionRequiresWorkflowEvidence|TestManagerWorkflowEvidenceGateAndPiRepair|TestMatchWorkflowEvidence' -v ./packages/go/agenttask`

```
=== RUN   TestManagerWorkflowEvidenceGateAndPiRepair
=== RUN   TestManagerWorkflowEvidenceGateAndPiRepair/complete_evidence_invokes_review
=== RUN   TestManagerWorkflowEvidenceGateAndPiRepair/placeholder_from_another_provider_never_repairs_or_reviews
=== RUN   TestManagerWorkflowEvidenceGateAndPiRepair/wrong_active_artifact_identity_never_invokes_review
=== RUN   TestManagerWorkflowEvidenceGateAndPiRepair/Pi_repair_rejects_a_stale_native_locator
=== RUN   TestManagerWorkflowEvidenceGateAndPiRepair/Pi_repair_rematches_before_review
=== RUN   TestManagerWorkflowEvidenceGateAndPiRepair/Pi_repair_without_a_fresh_completed_match_never_invokes_review
--- PASS: TestManagerWorkflowEvidenceGateAndPiRepair (0.05s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/complete_evidence_invokes_review (0.01s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/placeholder_from_another_provider_never_repairs_or_reviews (0.01s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/wrong_active_artifact_identity_never_invokes_review (0.01s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/Pi_repair_rejects_a_stale_native_locator (0.01s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/Pi_repair_rematches_before_review (0.01s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/Pi_repair_without_a_fresh_completed_match_never_invokes_review (0.01s)
=== RUN   TestRestartRecoveredSubmissionRequiresWorkflowEvidence
=== RUN   TestRestartRecoveredSubmissionRequiresWorkflowEvidence/complete_evidence_recovers_and_reviews
=== RUN   TestRestartRecoveredSubmissionRequiresWorkflowEvidence/incomplete_submission_blocks_without_evidence_check_or_review
=== RUN   TestRestartRecoveredSubmissionRequiresWorkflowEvidence/placeholder_from_non-Pi_provider_blocks_without_repair_or_review
=== RUN   TestRestartRecoveredSubmissionRequiresWorkflowEvidence/inactive_or_identity_mismatched_evidence_blocks_review
=== RUN   TestRestartRecoveredSubmissionRequiresWorkflowEvidence/Pi_repair_rematches_and_reviews_successfully
=== RUN   TestRestartRecoveredSubmissionRequiresWorkflowEvidence/Pi_repair_without_fresh_match_blocks_review
--- PASS: TestRestartRecoveredSubmissionRequiresWorkflowEvidence (0.01s)
    --- PASS: TestRestartRecoveredSubmissionRequiresWorkflowEvidence/complete_evidence_recovers_and_reviews (0.00s)
    --- PASS: TestRestartRecoveredSubmissionRequiresWorkflowEvidence/incomplete_submission_blocks_without_evidence_check_or_review (0.00s)
    --- PASS: TestRestartRecoveredSubmissionRequiresWorkflowEvidence/placeholder_from_non-Pi_provider_blocks_without_repair_or_review (0.00s)
    --- PASS: TestRestartRecoveredSubmissionRequiresWorkflowEvidence/inactive_or_identity_mismatched_evidence_blocks_review (0.00s)
    --- PASS: TestRestartRecoveredSubmissionRequiresWorkflowEvidence/Pi_repair_rematches_and_reviews_successfully (0.00s)
    --- PASS: TestRestartRecoveredSubmissionRequiresWorkflowEvidence/Pi_repair_without_fresh_match_blocks_review (0.00s)
=== RUN   TestMatchWorkflowEvidence
=== RUN   TestMatchWorkflowEvidence/complete_active_pair
=== RUN   TestMatchWorkflowEvidence/placeholder_active_pair
=== RUN   TestMatchWorkflowEvidence/wrong_attempt_identity
=== RUN   TestMatchWorkflowEvidence/inactive_pair
=== RUN   TestMatchWorkflowEvidence/unknown_completeness_is_invalid
--- PASS: TestMatchWorkflowEvidence (0.00s)
    --- PASS: TestMatchWorkflowEvidence/complete_active_pair (0.00s)
    --- PASS: TestMatchWorkflowEvidence/placeholder_active_pair (0.00s)
    --- PASS: TestMatchWorkflowEvidence/wrong_attempt_identity (0.00s)
    --- PASS: TestMatchWorkflowEvidence/inactive_pair (0.00s)
    --- PASS: TestMatchWorkflowEvidence/unknown_completeness_is_invalid (0.00s)
PASS
ok  	iop/packages/go/agenttask	0.064s
```

### `go test -count=1 ./packages/go/agenttask`

```
ok  	iop/packages/go/agenttask	0.536s
```

### `go test -race -count=1 ./packages/go/agenttask`

```
ok  	iop/packages/go/agenttask	1.950s
```

### `go vet ./packages/go/...`

```

```

### `go test -count=1 ./packages/go/...`

```
ok  	iop/packages/go/agentconfig	0.046s
ok  	iop/packages/go/agentguard	0.024s
ok  	iop/packages/go/agentpolicy	0.018s
ok  	iop/packages/go/agentprovider/catalog	0.092s
ok  	iop/packages/go/agentprovider/cli	30.044s
?   	iop/packages/go/agentprovider/cli/internal/testutil	[no test files]
ok  	iop/packages/go/agentprovider/cli/status	39.894s
ok  	iop/packages/go/agentruntime	0.638s
ok  	iop/packages/go/agentstate	0.087s
ok  	iop/packages/go/agenttask	0.616s
ok  	iop/packages/go/agentworkspace	1.015s
ok  	iop/packages/go/audit	0.007s
?   	iop/packages/go/auth	[no test files]
ok  	iop/packages/go/config	0.070s
?   	iop/packages/go/events	[no test files]
ok  	iop/packages/go/hostsetup	0.007s
?   	iop/packages/go/jobs	[no test files]
?   	iop/packages/go/metadata	[no test files]
ok  	iop/packages/go/observability	0.013s
?   	iop/packages/go/policy	[no test files]
ok  	iop/packages/go/streamgate	0.889s
?   	iop/packages/go/version	[no test files]
```

### `test -z "$(gofmt -d packages/go/agenttask/reconcile.go packages/go/agenttask/manager_test.go)"`

```

```

### `test -z "$(rg --sort path -n 'USER_REVIEW|complete\.log' packages/go/agenttask || true)"`

```

```

### `git diff --check`

```

```

---

> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section?**
> If anything is blank, go back and fill it in before saving this file.
> Leave review-agent-only sections unchanged.

## Section Ownership

| Section | Owner | Note |
|---------|-------|------|
| Header comment, Overview, Review Agent Instructions | Fixed at stub creation | Implementing agent must not modify or execute these (archive, complete.log, and task-directory archive move are review-agent only) |
| Roadmap Targets | Fixed at stub creation from plan when present | Implementing agent must not modify; code-review copies it into `complete.log` as `Roadmap Completion` only on PASS |
| Archive Evidence Snapshot | Fixed at stub creation from plan when present | Implementing agent uses it as default prior-loop context; read only the specific archive files cited there when more detail is required |
| Implementation Item Completion (item names) | Fixed at stub creation | Implementing agent checks `[ ]` → `[x]` only |
| Implementation Checklist (item text/order) | Fixed at stub creation from plan | Implementing agent checks `[ ]` → `[x]` only |
| Review-Only Checklist | Review agent only | Implementing agents must not modify or check this section |
| Deviations from Plan, Key Design Decisions | Implementing agent | Replace placeholder text with actual content |
| Reviewer Checkpoints | Fixed at stub creation | Pre-filled from plan |
| Verification Results (section headings + commands) | Fixed at stub creation | Implementing agent fills in command output only; command changes require a `Deviations from Plan` entry |
| Code Review Result | Review agent appends | Not included in stub |

## Code Review Result

- Overall Verdict: PASS
- Dimension Assessment:
  - Correctness: Pass
  - Completeness: Pass
  - Test Coverage: Pass
  - API Contract: Pass
  - Code Quality: Pass
  - Implementation Deviation: Pass
  - Verification Trust: Pass
  - Spec Conformance: Pass
- Findings: None
- Routing Signals: `review_rework_count=2`, `evidence_integrity_failure=false`
- Next Step: PASS — archive the active pair, write `complete.log`, move the task to the monthly archive, and emit Milestone completion metadata for the runtime.
