# Plan: metadata_generational_handle_20260624 3 tasks, 3 atomic commits. Same pattern as child 1. ## Phase 1: Behavioral Test (1 task) - [ ] Task 1.1: Write `tests/test_metadata_generational_handle.py`. - WHERE: New file `tests/test_metadata_generational_handle.py` - WHAT: 4 tests (per spec FR3) - HOW: Use 1-space indentation - SAFETY: Test imports `MetadataHandle` and `MetadataHandleRegistry` from their production location - COMMIT: `test(metadata): behavioral test for generational handle (MetadataHandle + Registry)` - GIT NOTE: 4 tests; will be RED until Phase 2 ships - VERIFY: `uv run pytest tests/test_metadata_generational_handle.py -v` shows 4/4 FAIL (expected) ## Phase 2: Implementation (1 task) - [ ] Task 2.1: Add `MetadataHandle` + `MetadataHandleRegistry` + migrate lifetime-check code. - WHERE: `src/aggregate.py` (or another existing module; no new `src/.py` files) - WHAT: - Add `@dataclass(frozen=True) class MetadataHandle` with `index: int` and `generation: int` - Add `class MetadataHandleRegistry` with `register`, `lookup`, `bump_generation` methods - Migrate lifetime-check sites in `src/aggregate.py`, `src/ai_client.py`, and any other production files - HOW: Use `manual-slop_py_add_def` for the new types; `manual-slop_edit_file` for the migration sites - SAFETY: Verify with `ast.parse`; run the 4 tests + the child-1 tests + the 14 previously-failing tests - COMMIT: `feat(metadata): MetadataHandle + Registry + lifetime-check migrations` - GIT NOTE: Lifetime checks now go through registry.lookup; generation mismatch returns NIL_METADATA from child 1 - VERIFY: `uv run pytest tests/test_metadata_generational_handle.py tests/test_metadata_nil_sentinel.py -v` shows all PASS ## Phase 3: Verification + Budget Gate (1 task) - [ ] Task 3.1: Run all 6 VCs; capture the budget gate measurement. - WHERE: All audit gates + test suite + SSDL measurement - WHAT: - Run VC1-VC6 - Compute the new effective-codepaths number - Compare to post-child-1 measurement; require drop ≥ 20% - Write TRACK_COMPLETION report - Update state.toml to `status = "completed"`, all 3 phases completed - Append to campaign_measurements_20260624.md - Update conductor/tracks.md - HOW: Same as child 1 phase 3 - SAFETY: Same as child 1 - COMMIT: 3 commits (state, TRACK_COMPLETION, tracks.md) - GIT NOTE: Per workflow.md - VERIFY: All 6 VCs pass; budget gate met; campaign unblocked for child 3 ## Commit Log (Expected) 1. `test(metadata): behavioral test for generational handle` (Task 1.1) 2. `feat(metadata): MetadataHandle + Registry + lifetime-check migrations` (Task 2.1) 3. `conductor(state): metadata_generational_handle_20260624 SHIPPED` (Task 3.1) 4. `docs(reports): TRACK_COMPLETION for metadata_generational_handle_20260624` (Task 3.1) 5. `conductor(tracks): add metadata_generational_handle_20260624 row` (Task 3.1) ## Verification Commands ```bash # VC1: types exist grep -rn "class MetadataHandle\|class MetadataHandleRegistry" src/ # VC2: production uses handle grep -rn "registry.lookup\|registry.register" src/ # VC3: tests pass uv run pytest tests/test_metadata_generational_handle.py -v # VC4: budget gate uv run python -c "from src.code_path_audit_ssdl import compute_effective_codepaths; ...; print(compute_effective_codepaths(metadata_profile, 'src'))" # VC5: full test suite uv run python scripts/run_tests_batched.py # VC6: 4 audit gates uv run python scripts/audit_weak_types.py --strict uv run python scripts/generate_type_registry.py --check uv run python scripts/audit_main_thread_imports.py uv run python scripts/audit_no_models_config_io.py ```