Files
ed 84c0b4ecc4 conductor(campaign): metadata_ssdl_defusing_20260624 - 3-child SSDL defusing campaign
Campaign: address the parent code_path_audit_20260607 Finding 1 (CRITICAL)
Metadata 4.01e22 effective codepaths via 3 SSDL techniques.

3 children, sequential, with budget gates:
1. metadata_nil_sentinel_20260624 (>= 10% drop): introduce
   NIL_METADATA sentinel + migrate 6 nil-check functions.
2. metadata_generational_handle_20260624 (>= 20% drop,
   BLOCKED_BY 1): wrap Metadata in (index, generation) handle;
   collapse lifetime branches to 1 lookup + 1 cmp.
3. metadata_field_cache_20260624 (>= 30% drop, BLOCKED_BY 2):
   MetadataFieldCache keyed by (handle.index, field_name);
   123 string-keyed entry.get('key', default) sites become
   cache lookups.

Each child has its own spec/plan/metadata/state. Budget gate
after each child: re-measure effective codepaths; if drop < threshold,
PAUSE the campaign and report to user.

End-of-campaign TRACK_COMPLETION captures the cumulative reduction
vs the 4.01e22 baseline. Deferred follow-up: apply the same
3 SSDL primitives to the 4 other dict[str, Any] aliases
(FileItem, CommsLogEntry, HistoryMessage, ToolDefinition, ToolCall).

16 files committed: 4 directories x 4 files each (spec, plan,
metadata, state).
2026-06-24 14:53:40 -04:00

3.6 KiB

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/<thing>.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

# 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