# Complete - m-iop-agent-cli-runtime/21+13,17,20_project_log_sink

## Completed At

2026-07-30

## Summary

Implemented and verified project-wide manager event replay identity with atomic replay-index/journal persistence; the fourth review loop completed with a PASS verdict.

## Loop History

| Plan | Review | Verdict | Notes |
|------|--------|---------|-------|
| `plan_local_G08_0.log` | `code_review_cloud_G08_0.log` | FAIL | Production evidence projection, archive lifecycle, durable replay identity, and contract evidence were incomplete. |
| `plan_cloud_G10_1.log` | `code_review_cloud_G10_1.log` | FAIL | Events could be emitted before committed evidence, and volatile projection fields made logical replay unstable. |
| `plan_cloud_G10_2.log` | `code_review_cloud_G10_2.log` | FAIL | Replay identity remained scope-local and did not reject EventID reuse across work/project scope drift. |
| `plan_cloud_G10_3.log` | `code_review_cloud_G10_3.log` | PASS | The project-wide replay index, atomic batch CAS, scope-drift regressions, legacy recovery, and contract evidence passed fresh review verification. |

## Implementation and Cleanup

- Added cloned integration-record snapshots and atomic multi-record compare-and-swap while preserving the single-record API.
- Added one retained project/workspace replay index that owns each manager EventID scope, sequence, and stable logical fingerprint.
- Coupled new replay-index claims with exactly one scoped journal append in one state-store commit.
- Added fail-closed legacy recovery, cross-scope conflict, concurrent claimant, prune/restart, production sink, and contract regressions.

## Final Verification

- `command -v go && go version && go env GOROOT` - PASS; resolved `/config/.local/bin/go`, `go1.26.2 linux/arm64`, and `/config/opt/go`.
- `test -z "$(gofmt -d packages/go/agentstate/store.go packages/go/agentstate/store_test.go apps/agent/internal/projectlog/store.go apps/agent/internal/projectlog/store_test.go apps/agent/internal/projectlog/sink_test.go)"` - PASS; no formatting diff.
- `go test -count=1 ./packages/go/agentstate -run 'TestStoreIntegrationRecordSnapshot|TestStoreIntegrationRecordBatchCAS'` - PASS.
- `go test -count=1 ./apps/agent/internal/projectlog -run 'TestStoreRejectsLogicalEventIDReuseAcrossScopes|TestStoreEventReplayIndex|TestStoreEventReplayFingerprintSurvivesPruneAndRestart'` - PASS.
- `go test -count=1 ./apps/agent/internal/projectlog -run 'TestSinkRejectsLogicalEventIDReuseAcrossScopesBeforeEvidenceResolution|TestSinkReplayShortCircuitsEvidenceAfterClockAndStateAdvance'` - PASS.
- `go test -count=1 -race ./packages/go/agentstate ./apps/agent/internal/projectlog -run 'TestStoreIntegrationRecordBatchCAS|TestStoreEventReplayIndexSerializesCrossScopeCAS|TestS12LoopParallelArchiveMatrix'` - PASS.
- `go test -count=1 ./packages/go/agentstate ./apps/agent/internal/projectlog` - PASS.
- `go test -count=1 ./packages/go/...` - PASS.
- `go test -count=1 -race ./packages/go/agentstate ./apps/agent/internal/projectlog` - PASS.
- `go test -count=1 -race ./packages/go/agentstate ./packages/go/agenttask ./apps/agent/internal/projectlog` - PASS; reviewer-expanded S12 contract verification passed.
- `go vet ./packages/go/... ./apps/agent/internal/projectlog` - PASS.
- `rg --sort path -n 'project-wide replay index|atomic.*journal|scope drift|TestSinkRejectsLogicalEventIDReuseAcrossScopesBeforeEvidenceResolution|TestStoreEventReplayIndexSerializesCrossScopeCAS' agent-contract/inner/agent-runtime.md agent-contract/inner/iop-agent-cli-runtime.md` - PASS; both contracts contain the invariant and exact evidence anchors.
- `git diff --check` - PASS.

## Roadmap Completion

- Milestone: `agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-cli-runtime.md`
- Milestone link: [Milestone document](agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-cli-runtime.md)
- Completed task ids:
  - `project-logs`: PASS; evidence=`agent-task/archive/2026/07/m-iop-agent-cli-runtime/21+13,17,20_project_log_sink/plan_cloud_G10_3.log`, `agent-task/archive/2026/07/m-iop-agent-cli-runtime/21+13,17,20_project_log_sink/code_review_cloud_G10_3.log`; verification=`go test -count=1 -race ./packages/go/agentstate ./packages/go/agenttask ./apps/agent/internal/projectlog`
- Not completed task ids: None.

## Remaining Nits

- None.

## Follow-up Work

- None.
