<!-- task=m-iop-agent-chronos-extraction-decoupling/04+03_bundle_exporter plan=3 tag=REVIEW_REFACTOR milestone-task=transfer -->

# 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-08-02
task=m-iop-agent-chronos-extraction-decoupling/04+03_bundle_exporter, plan=3, tag=REVIEW_REFACTOR

## Archive Evidence Snapshot

- `agent-task/m-iop-agent-chronos-extraction-decoupling/04+03_bundle_exporter/plan_cloud_G10_2.log` and `code_review_cloud_G10_2.log` are the predicted archives for the failed plan-2 loop. The review has two Required findings: disjoint owner-state provenance/quarantine is missing, and shared-workspace output confinement is heuristic.
- Fresh reviewer verification passed the predecessor PASS check, manifest SHA check, pinned commit check, `go test -count=1`, `go vet`, `go test -count=1 -race`, ten repeated package runs, and `git diff --check`. `evidence_integrity_failure=false`; the failure is behavioral rather than a false verification claim.
- The `transfer` Milestone contribution remains S02 exporter evidence only. Actual current-input reconciliation, private owner export, isolated staging build, and final bundle closure remain downstream Task 06 responsibilities.

## 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-G10.md` → `code_review_cloud_G10_3.log` and `PLAN-cloud-G10.md` → `plan_cloud_G10_3.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-iop-agent-chronos-extraction-decoupling/04+03_bundle_exporter/`. 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>`, preserve the first-line `milestone-task` metadata in `complete.log` and report it for the runtime aggregation event. Roadmap state evaluation belongs to `sync-milestone-workstate`.
5. Check applicable `Review-Only Checklist` items at the final `.log` location before reporting.

---

## Implementation Item Completion

| Item | Status |
|------|---------|
| REVIEW_REFACTOR-1 Bind owner-state records to disjoint payload evidence | [x] |
| REVIEW_REFACTOR-2 Remove workspace-name heuristics from output confinement | [x] |

## Implementation Checklist

- [x] Replace aggregate owner-state aliases with exact, disjoint logical payload provenance; only invalid or unmapped residual bytes may enter non-resumable quarantine.
- [x] Enforce output confinement against the canonical workspace boundary without basename or sibling-existence heuristics.
- [x] Add and run focused owner-state and arbitrary-workspace regressions, then run the fresh full package, race, vet, baseline, and formatting verification.
- [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_G10_3.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G10_3.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-chronos-extraction-decoupling/04+03_bundle_exporter/` to `agent-task/archive/YYYY/MM/m-iop-agent-chronos-extraction-decoupling/04+03_bundle_exporter/` and update this checklist at the final archive path.
- [ ] If PASS and task group is `m-<milestone-slug>`, preserve and report `milestone-task` metadata for runtime aggregation, without modifying roadmap or directly calling `update-roadmap`.
- [ ] If PASS for split work, remove empty active parent `agent-task/m-iop-agent-chronos-extraction-decoupling/` 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

No scope deviations. The implementation adds one fail-closed regression for an invalid required `state.json` envelope and strengthens the exact/disjoint regression with lease, process/session locator, and non-recovery locator assertions.

## Key Design Decisions

- Decode the owner-local YAML through the strict runtime config schema, separate project registrations from the remaining local config, and require a checksum-valid schema-v1 `agentstate` envelope before projecting any resumable state.
- Emit exactly one regular `acceptance-v1/<bundle_path>` member per canonical logical ID. Each state-index digest and size is calculated from that member's exact bytes and checked again by the owner binding validator before archive assembly.
- Partition manager leases and process/session locators out of the manager checkpoint, route known versioned integration-record prefixes to their owning logical payload, and place unknown or schema-invalid integration records and unmapped root files only in the non-resumable quarantine payload.
- Treat configured cache/temp trees as their explicit runtime-owned roots, admit only stable digest-bound overlay/log layouts as resumable, and keep absolute host paths and payload bytes out of the canonical state index and external receipt.
- Define the shared workspace as the unconditional canonical parent of the verified Git top-level, so output below that boundary is rejected independently of basename or sibling existence.

## Reviewer Checkpoints

- Every owner-state index record resolves to one exact regular archive member whose digest and size match its bytes.
- No owner payload member is shared across resumable and quarantine records; invalid or unmapped residual bytes are non-resumable only.
- Host paths and raw owner bytes remain absent from the canonical state index and exact 12-key receipt.
- Output below the verified repository parent is rejected for arbitrary workspace names even when no Chronos sibling exists; a new external owner-only output still succeeds.
- Pinned Git-tree input, deterministic archive/receipt, live-writer/socket rejection, and self-contained behavior regressions remain passing.

## Verification Results

> Paste actual stdout/stderr for every command below. Do not summarize or reconstruct output. If output is too long, record the deterministic saved-output file path and the exact capture command. Any replacement command requires a `Deviations from Plan` entry.

### Verification 1

Command: `go test -count=1 ./cmd/iop-chronos-transfer -run 'TestOwnerStatePayloadsAreExactAndDisjoint|TestInvalidOwnerResidualIsOnlyNonResumableQuarantine|TestExportOwnerStateSnapshotIsRedactedAndQuiesced|TestRefusesConcurrentStateMutation|TestRefusesLiveStateSocket'`

_Actual stdout/stderr and exit code (or exact saved-output path and capture command):_

```text
ok  	iop/cmd/iop-chronos-transfer	0.634s
exit code: 0
```

### Verification 2

Command: `go test -count=1 ./cmd/iop-chronos-transfer -run 'TestRejectsOutputInsideWorkspace|TestRejectsOutputInsideArbitrarilyNamedWorkspace|TestOutputContractAndReceiptSchema'`

_Actual stdout/stderr and exit code (or exact saved-output path and capture command):_

```text
ok  	iop/cmd/iop-chronos-transfer	0.262s
exit code: 0
```

### Verification 3

Command: `bash -lc 'set -euo pipefail; mapfile -t predecessor_logs < <({ test ! -f agent-task/m-iop-agent-chronos-extraction-decoupling/03+02_inventory_closure/complete.log || printf "%s\n" agent-task/m-iop-agent-chronos-extraction-decoupling/03+02_inventory_closure/complete.log; find agent-task/archive -path "*/m-iop-agent-chronos-extraction-decoupling/03+02_inventory_closure/complete.log" -type f -print 2>/dev/null; } | sort -u); test "${#predecessor_logs[@]}" -eq 1; awk '\''BEGIN {in_summary=0; count=0} /^## Summary$/ {in_summary=1; next} in_summary && /^## / {in_summary=0} in_summary {line=$0; while (match(line, /final verdict: PASS/)) {count++; line=substr(line, RSTART+RLENGTH)}} END {exit count==1 ? 0 : 1}'\'' "${predecessor_logs[0]}"'`

_Actual stdout/stderr and exit code (or exact saved-output path and capture command):_

```text
(no stdout/stderr)
exit code: 0
```

### Verification 4

Command: `test "$(sha256sum scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv | awk '{print $1}')" = 7026fedc8b0eb24eab5c4124d3818400f66db5f1d116a71e7781f346fbd256a7`

_Actual stdout/stderr and exit code (or exact saved-output path and capture command):_

```text
(no stdout/stderr)
exit code: 0
```

### Verification 5

Command: `git cat-file -e 3155be0e275437a8eedc1aa93497955a7d30465b^{commit} && test "$(git rev-parse HEAD)" != 3155be0e275437a8eedc1aa93497955a7d30465b`

_Actual stdout/stderr and exit code (or exact saved-output path and capture command):_

```text
(no stdout/stderr)
exit code: 0
```

### Verification 6

Command: `go test -count=1 ./cmd/iop-chronos-transfer`

_Actual stdout/stderr and exit code (or exact saved-output path and capture command):_

```text
ok  	iop/cmd/iop-chronos-transfer	4.517s
exit code: 0
```

### Verification 7

Command: `go test -count=1 -race ./cmd/iop-chronos-transfer`

_Actual stdout/stderr and exit code (or exact saved-output path and capture command):_

```text
ok  	iop/cmd/iop-chronos-transfer	6.205s
exit code: 0
```

### Verification 8

Command: `go vet ./cmd/iop-chronos-transfer`

_Actual stdout/stderr and exit code (or exact saved-output path and capture command):_

```text
(no stdout/stderr)
exit code: 0
```

### Verification 9

Command: `git diff --check`

_Actual stdout/stderr and exit code (or exact saved-output path and capture command):_

```text
(no stdout/stderr)
exit code: 0
```

---

> **[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) |
| 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 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 — `cmd/iop-chronos-transfer/main.go:1048`: owner integration records are classified by key prefix plus `schema_version`/`version` alone, so a structurally invalid payload such as `client-process/flutter = {"schema_version":1}` is emitted in resumable `state:client-process-records` instead of non-resumable quarantine. A fresh focused reviewer reproducer failed with `structurally invalid client record was accepted as resumable state:client-process-records`, while `cmd/iop-chronos-transfer/main_test.go:325` covers only a mismatched version and does not validate the actual durable key or payload schema. Validate each supported integration-record key shape and complete strict payload contract (including integrity where the owning format defines it) before assigning its resumable logical ID; route every unknown or structurally invalid record only to `state:broken-residual-records`, and add table-driven regressions for malformed version-1 records and invalid durable identities across the supported record families.
- Routing Signals: `review_rework_count=2`, `evidence_integrity_failure=false`
- Next Step: Prepare and validate a freshly routed follow-up PLAN/CODE_REVIEW pair for strict integration-record identity and payload validation, then archive this active pair and materialize the routed follow-up state.
