<!-- task=m-iop-agent-chronos-extraction-decoupling/03+02_inventory_closure plan=0 tag=TEST -->

# Inventory 양방향 completeness closure

## For the Implementing Agent

`CODE_REVIEW-cloud-G04.md`의 implementation-owned 섹션 작성은 필수다. encoded predecessor의 exact PASS를 확인하고 이 child 범위만 구현·검증한다. active pair를 유지해 review 준비 완료를 보고하며 finalization은 code-review agent만 수행한다. 차단되면 질문하거나 상태를 분류하지 말고 blocker, 실제 명령/출력, 재개 조건만 evidence 필드에 기록한다.

## Background

고정 universe와 분류 manifest의 양방향 차집합을 감사해 S01 inventory를 완료 가능한 evidence로 닫는다.

## Roadmap Targets

- Milestone: `agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-chronos-extraction-decoupling.md`
- Milestone link: [Milestone 문서](agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-chronos-extraction-decoupling.md)
- Task ids:
  - `inventory`: source revision과 모든 관련 활성 자산의 ownership/disposition manifest 확정
- Completion mode: check-on-pass

## Analysis

### Files Read

- `agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-chronos-extraction-decoupling.md`
- `agent-roadmap/sdd/automation-runtime-bridge/iop-agent-chronos-extraction-decoupling/SDD.md`
- `agent-task/m-iop-agent-chronos-extraction-decoupling/01_asset_universe/plan_local_G06_0.log`

### SDD Criteria

- SDD `agent-roadmap/sdd/automation-runtime-bridge/iop-agent-chronos-extraction-decoupling/SDD.md`는 `[승인됨]`, 잠금 `해제` 상태다.
- Target은 Acceptance Scenario `S01`과 Milestone Task `inventory`; Evidence Map row는 source revision, import graph, disposition audit와 미분류·중복 없는 manifest를 요구한다.
- 이 closure child는 그 row 전체를 재계산하는 missing/duplicate/orphan audit, evidence log와 Final Verification으로 묶어 `inventory` 완료 evidence를 만든다.

### Verification Context

- Handoff는 없다. Milestone, 승인 SDD, 보존된 parent plan을 읽었고 predecessor `02+01_disposition`의 exact PASS `complete.log`는 현재 missing이다.
- gap은 아직 생성되지 않은 manifest와 audit output이며, source tree 재열거와 deterministic `comm`/`awk` 결과가 모두 0일 때만 닫힌다. 외부 서비스는 필요 없다.
- Confidence는 high다. 이 child는 manifest를 수정하지 않고 완전성 evidence만 만든다.

### Test Coverage Gaps

- 새 제품 test는 없다. missing, duplicate, orphan, invalid state logical row가 모두 0이어야 한다.

### Symbol References

- symbol 변경 없음.

### Split Judgment

- 이 closure child만 inventory Roadmap Task를 닫는다.
- Predecessor `02`의 active/archived exact PASS `complete.log`는 missing이다. PASS evidence는 source diff, duplicate, orphan, invalid row가 모두 0인 audit log다.

### Scope Rationale

- manifest 내용 변경은 predecessor에 두고 이 child는 audit/evidence만 작성한다.

### Final Routing

- `evaluation_mode=isolated-reassessment`, finalizer=`finalize-task-policy.sh`, mode=`pair`.
- Build closures 모두 true. Scores=`1,0,0,2,1`, grade=`G04`, base/route=`local-fit`, lane=`local`.
- Review closures 모두 true. Scores=`1,0,0,2,1`, route=`official-review`, lane=`cloud`, grade=`G04`.
- `large_indivisible_context=false`; positive loop risks=`boundary_contract` (1); `review_rework_count=0`; `evidence_integrity_failure=false`; capability gap 없음.
- Canonical files: `PLAN-local-G04.md`, `CODE_REVIEW-cloud-G04.md`.

## Dependencies and Execution Order

1. `02+01_disposition` must each have exactly one matching PASS `complete.log`; all are currently missing.
2. Resolve only those exact predecessor completion artifacts, then implement this child scope.

## Implementation Checklist

- [ ] Refuse to start until predecessor 02+01_disposition has an exact PASS complete.log.
- [ ] Run the original bidirectional universe/manifest audit and prove zero missing, duplicate, or orphan rows.
- [ ] Write redacted exact command/output evidence to inventory-audit.log.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

### [TEST-3] 양방향 completeness audit

**Problem**

manifest 작성자의 수동 누락이나 과잉 포함은 후속 삭제 gate를 무효화한다.

```text
# agent-roadmap/sdd/automation-runtime-bridge/iop-agent-chronos-extraction-decoupling/SDD.md:86
S01 evidence = source revision, import graph와 disposition audit
```

**Solution**

asset universe 생성 명령, manifest path 집합, active reference 후보의 양방향 차집합과 row count를 `inventory-audit.log`에 실제 출력으로 저장한다. 문서·domain 의미상 false positive는 제거하지 말고 `reference` 행과 근거로 명시한다.

```text
# after: inventory-audit.log
source_revision=3155be0e...
missing=0
duplicates=0
orphans=0
```

**Modified Files and Checklist**

- [ ] `agent-task/m-iop-agent-chronos-extraction-decoupling/03+02_inventory_closure/inventory-audit.log` — 정확한 명령과 stdout/stderr, 집합 count를 기록한다.
- [ ] `agent-task/m-iop-agent-chronos-extraction-decoupling/03+02_inventory_closure/CODE_REVIEW-cloud-G04.md` — 실제 구현/검증 evidence를 채운다.

**Test Strategy**

- `comm` 기반 양방향 차집합을 fresh 실행한다. cache 개념은 적용되지 않는다.

**Verification**

- `cut -f1 scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv | tail -n +2 | LC_ALL=C sort | uniq -d | awk 'NF {bad=1} END {exit bad}'` — duplicate 0.
- `{ git ls-tree -r --name-only 3155be0e275437a8eedc1aa93497955a7d30465b -- apps/agent cmd/iop-provider-smoke packages/go/agentconfig packages/go/agentguard packages/go/agentpolicy packages/go/agentprovider packages/go/agentruntime packages/go/agentstate packages/go/agenttask packages/go/agentworkspace proto/iop/agent.proto proto/gen/iop/agent.pb.go configs/iop-agent.local.example.yaml configs/iop-agent.providers.yaml configs/iop-agent.runtime.yaml scripts/e2e-iop-agent-logged-smoke.sh scripts/fixtures/iop-agent-smoke-manifest.schema.json packages/flutter/iop_console; rg --sort path -l -i 'iop-agent|apps/agent|packages/go/agent|iop/agent|agent\.proto|IopAgentPanel|agentruntime|agentprovider|agentconfig|agentguard|agentpolicy|agentstate|agenttask|agentworkspace' README.md HANDOFF.md Makefile agent-contract agent-spec agent-ops/rules/project agent-roadmap agent-ui apps cmd packages proto configs scripts --glob '!agent-roadmap/archive/**' --glob '!agent-ui/**/archive/**' --glob '!agent-spec/archive/**' --glob '!scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv'; } | sed 's#^\./##' | LC_ALL=C sort -u > /tmp/iop-agent-asset-universe.txt` — tracked asset/reference universe 생성.
- `cut -f1 scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv | tail -n +2 | rg -v '^state:' | LC_ALL=C sort -u > /tmp/iop-agent-manifest-paths.txt && comm -23 /tmp/iop-agent-asset-universe.txt /tmp/iop-agent-manifest-paths.txt && comm -13 /tmp/iop-agent-asset-universe.txt /tmp/iop-agent-manifest-paths.txt` — 두 `comm` 출력 모두 비어 있어야 한다. `state:` logical rows는 실제 device path를 기록하지 않고 별도 schema audit한다.

## Modified Files Summary

| File | Item |
|------|------|
| `agent-task/m-iop-agent-chronos-extraction-decoupling/03+02_inventory_closure/inventory-audit.log` | TEST-3 |
| `agent-task/m-iop-agent-chronos-extraction-decoupling/03+02_inventory_closure/CODE_REVIEW-cloud-G04.md` | TEST-3 |

## Final Verification

1. Confirm exact PASS `complete.log` for `02+01_disposition`.
2. `cut -f1 scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv | tail -n +2 | LC_ALL=C sort | uniq -d | awk 'NF {bad=1} END {exit bad}'` — duplicate 0.
3. `{ git ls-tree -r --name-only 3155be0e275437a8eedc1aa93497955a7d30465b -- apps/agent cmd/iop-provider-smoke packages/go/agentconfig packages/go/agentguard packages/go/agentpolicy packages/go/agentprovider packages/go/agentruntime packages/go/agentstate packages/go/agenttask packages/go/agentworkspace proto/iop/agent.proto proto/gen/iop/agent.pb.go configs/iop-agent.local.example.yaml configs/iop-agent.providers.yaml configs/iop-agent.runtime.yaml scripts/e2e-iop-agent-logged-smoke.sh scripts/fixtures/iop-agent-smoke-manifest.schema.json packages/flutter/iop_console; rg --sort path -l -i 'iop-agent|apps/agent|packages/go/agent|iop/agent|agent\.proto|IopAgentPanel|agentruntime|agentprovider|agentconfig|agentguard|agentpolicy|agentstate|agenttask|agentworkspace' README.md HANDOFF.md Makefile agent-contract agent-spec agent-ops/rules/project agent-roadmap agent-ui apps cmd packages proto configs scripts --glob '!agent-roadmap/archive/**' --glob '!agent-ui/**/archive/**' --glob '!agent-spec/archive/**' --glob '!scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv'; } | sed 's#^\./##' | LC_ALL=C sort -u > /tmp/iop-agent-asset-universe.txt` — tracked asset/reference universe 생성.
4. `cut -f1 scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv | tail -n +2 | rg -v '^state:' | LC_ALL=C sort -u > /tmp/iop-agent-manifest-paths.txt && comm -23 /tmp/iop-agent-asset-universe.txt /tmp/iop-agent-manifest-paths.txt && comm -13 /tmp/iop-agent-asset-universe.txt /tmp/iop-agent-manifest-paths.txt` — 두 `comm` 출력 모두 비어 있어야 한다. `state:` logical rows는 실제 device path를 기록하지 않고 별도 schema audit한다.
5. `awk -F '\t' 'NR>1 && $2=="state" && $1 !~ /^state:/ {bad=1} END {exit bad}' scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv`

Commands containing `go test -count=1` require fresh output; all other checks are rerun against the current checkout.

After completing all code changes, fill implementation-owned sections in `CODE_REVIEW-*-G??.md`.
