<!-- task=m-iop-agent-cli-runtime/09+05_workflow_evidence plan=1 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=1, 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_cloud_G09_0.log`
- Prior review: `agent-task/m-iop-agent-cli-runtime/09+05_workflow_evidence/code_review_cloud_G09_0.log`
- Verdict: FAIL
- Findings: Required=1, Suggested=0, Nit=0. The implementation item, checklist, deviations, decisions, and verification results were all unfilled.
- Affected artifact: `agent-task/m-iop-agent-cli-runtime/09+05_workflow_evidence/CODE_REVIEW-cloud-G09.md`
- Reviewer verification: focused matcher/manager tests, package tests, race, vet, all `packages/go/...` tests, formatting, and `git diff --check` passed; the forbidden artifact search returned zero matches.
- Roadmap carryover: `workflow-evidence` remains pending until a PASS artifact records S08 review-invocation and 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-G05.md` → `code_review_cloud_G05_1.log` and `PLAN-local-G02.md` → `plan_local_G02_1.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 Restore implementation-owned S08 evidence | [x] |

## Implementation Checklist

- [x] Reconcile `plan_cloud_G09_0.log` and `code_review_cloud_G09_0.log` against the implemented S08 source/tests, then check the `REVIEW_REFACTOR-1` completion row in `CODE_REVIEW-cloud-G05.md`.
- [x] Replace the Deviations from Plan and Key Design Decisions placeholders with concrete evidence, including `None` when there was no deviation.
- [x] Run every Final Verification command exactly and paste its actual stdout/stderr into the matching section of `CODE_REVIEW-cloud-G05.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_G05_1.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_local_G02_1.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`.
- [ ] If PASS, write `complete.log` based on `agent-ops/skills/common/code-review/templates/complete-log-template.md` and leave no active `.md` files.
- [ ] 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.
- [ ] If PASS and task group is `m-<milestone-slug>`, report completion event metadata for runtime, without modifying roadmap or directly calling `update-roadmap`.
- [ ] 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.
- [x] If WARN/FAIL, write the next filesystem state matching code-review verdict and do not write `complete.log`.

## Deviations from Plan
- None. This follow-up changes no production source, contract, roadmap, or common Agent-Ops files. Only the active review artifact is populated with evidence from the already-completed S08 implementation.

## Key Design Decisions
- The S08 implementation (`packages/go/agenttask/ports.go`, `dispatch.go`, `workflow_evidence.go`, `workflow_evidence_test.go`, `manager_integration_test.go`) provides a provider-neutral artifact matcher with three match states (complete, placeholder, wrong-identity), Pi same-context repair gated by durable native locator and dispatch ordinal validation, mandatory rematch before reviewer invocation, and zero-review-before-match assertions.
- This follow-up does not introduce new design decisions. It restores the review artifact to faithfully record the already-implemented design.
- The forbidden-boundary search (`rg --sort path -n 'USER_REVIEW|complete\.log' packages/go/agenttask`) confirms the common package does not absorb agent-task archive finalization or write `USER_REVIEW.md`, preserving the architectural boundary defined in the S08 scope.

## Reviewer Checkpoints

- Confirm the active artifact records exact project/work/attempt/artifact matching, non-Pi repair denial, durable Pi session locator/dispatch ordinal validation, mandatory rematch, and zero reviewer calls before a match.
- Confirm every implementation-owned field is filled with actual current evidence and contains no placeholder.
- Confirm verification output corresponds to every command in the plan and no production source change was introduced by this follow-up.

## 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/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/
```
Note: The working tree contains prior-milestone changes from the S08 implementation and earlier task groups. This follow-up introduces no new modifications.

### `go test -count=1 -run 'TestMatchWorkflowEvidence|TestManagerWorkflowEvidenceGateAndPiRepair' -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.18s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/complete_evidence_invokes_review (0.04s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/placeholder_from_another_provider_never_repairs_or_reviews (0.02s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/wrong_active_artifact_identity_never_invokes_review (0.02s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/Pi_repair_rejects_a_stale_native_locator (0.01s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/Pi_repair_rematches_before_review (0.06s)
    --- PASS: TestManagerWorkflowEvidenceGateAndPiRepair/Pi_repair_without_a_fresh_completed_match_never_invokes_review (0.02s)
=== 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  \tiop/packages/go/agenttask\t0.184s
```

### `go test -count=1 ./packages/go/agenttask`
```
ok  \tiop/packages/go/agenttask\t1.210s
```

### `go test -race -count=1 ./packages/go/agenttask`
```
ok  \tiop/packages/go/agenttask\t1.923s
```

### `go vet ./packages/go/...`
```
(no output — all clear)
```

### `go test -count=1 ./packages/go/...`
```
ok  \tiop/packages/go/agentconfig\t0.058s
ok  \tiop/packages/go/agentguard\t0.038s
ok  \tiop/packages/go/agentpolicy\t0.032s
ok  \tiop/packages/go/agentprovider/catalog\t0.083s
ok  \tiop/packages/go/agentprovider/cli\t30.324s
?   \tiop/packages/go/agentprovider/cli/internal/testutil\t[no test files]
ok  \tiop/packages/go/agentprovider/cli/status\t40.051s
ok  \tiop/packages/go/agentruntime\t0.685s
ok  \tiop/packages/go/agentstate\t0.141s
ok  \tiop/packages/go/agenttask\t1.210s
ok  \tiop/packages/go/agentworkspace\t2.164s
ok  \tiop/packages/go/audit\t0.006s
?   \tiop/packages/go/auth\t[no test files]
ok  \tiop/packages/go/config\t0.177s
?   \tiop/packages/go/events\t[no test files]
ok  \tiop/packages/go/hostsetup\t0.010s
?   \tiop/packages/go/jobs\t[no test files]
?   \tiop/packages/go/metadata\t[no test files]
ok  \tiop/packages/go/observability\t0.014s
?   \tiop/packages/go/policy\t[no test files]
ok  \tiop/packages/go/streamgate\t0.903s
?   \tiop/packages/go/version\t[no test files]
```

### `test -z "$(gofmt -d packages/go/agenttask/ports.go packages/go/agenttask/dispatch.go packages/go/agenttask/workflow_evidence.go packages/go/agenttask/workflow_evidence_test.go packages/go/agenttask/manager_integration_test.go)"`
```
FORMAT_OK
```

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

### `git diff --check`
```
(no output — no diff check failures)
```

---

> **[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 |
| Agent UI Completion | Mixed | Present only for plan-required agent-ui code work; implementing agent fills actual evidence, review agent applies `구현됨` status/evidence update on PASS and copies the section into `complete.log` |
| 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 agent 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: FAIL
- Dimension Assessment:
  - Correctness: Fail
  - Completeness: Fail
  - Test Coverage: Fail
  - API Contract: Fail
  - Code Quality: Pass
  - Implementation Deviation: Fail
  - Verification Trust: Pass
  - Spec Conformance: Fail
- Findings:
  - Required — `packages/go/agenttask/reconcile.go:249`: `RecoveryExecutionSubmitted` validates only the recovered `Submission` identity and then moves the work directly through `submitted` to `reviewing` without checking `Submission.Ready` or calling `gateSubmissionEvidence`. `runWork` consequently invokes `Reviewer` for that recovered work, so a restart can bypass the provider-neutral matcher for incomplete, placeholder, inactive, or mismatched workflow artifacts. This violates SDD S08's requirement that every provider use the same matcher and that official review remain at zero calls until a match. Route recovered submissions through the same completeness/evidence gate before persisting `reviewing`, preserve the Pi same-context repair/rematch behavior, and add a recovery regression matrix proving complete evidence reviews while incomplete/placeholder/identity-mismatched evidence does not.
- Routing Signals: `review_rework_count=2`, `evidence_integrity_failure=false`
- Next Step: Invoke the plan skill in `prepare-follow-up` mode with this Required finding and the fresh reviewer verification output.
