|
| 1 | +--- |
| 2 | +phase: 03-graph-aware-proposer |
| 3 | +plan: 01 |
| 4 | +subsystem: selfplay |
| 5 | +tags: [graph-aware, proposer, cascade, topology, pyg, torch-geometric, bfs] |
| 6 | + |
| 7 | +# Dependency graph |
| 8 | +requires: |
| 9 | + - phase: 01-gnn-verifier |
| 10 | + provides: GridGraphBuilder (node_type constants, COO edge format) |
| 11 | + - phase: 02-hybrid-ensemble |
| 12 | + provides: CascadeLogicLayer._build_adjacency pattern, cascade decay convention |
| 13 | +provides: |
| 14 | + - Graph-aware ProposerAgent with topology-based seed selection |
| 15 | + - 2-hop cascade propagation with 0.7 decay through grid neighbors |
| 16 | + - ScenarioProposal.apply_to_graph_timeseries() for per-node magnitude scaling |
| 17 | + - ScenarioProposal.metadata enrichment with graph_aware, seed_nodes, affected_nodes |
| 18 | +affects: [03-02, selfplay-trainer, graph-training-loop] |
| 19 | + |
| 20 | +# Tech tracking |
| 21 | +tech-stack: |
| 22 | + added: [] |
| 23 | + patterns: [BFS cascade propagation, per-node magnitude blending, graph_data optional parameter] |
| 24 | + |
| 25 | +key-files: |
| 26 | + created: |
| 27 | + - tests/test_graph_proposer.py |
| 28 | + modified: |
| 29 | + - src/fyp/selfplay/proposer.py |
| 30 | + |
| 31 | +key-decisions: |
| 32 | + - "1-3 seed nodes per scenario (not 10-30%); cascade expands from few seeds" |
| 33 | + - "LV feeder (node_type=2) preference for COLD_SNAP, OUTAGE, EV_SPIKE seed selection" |
| 34 | + - "30% graph cap on affected nodes with seed preservation during subsampling" |
| 35 | + - "Per-node blending formula: baseline + magnitude * (transform - baseline)" |
| 36 | + |
| 37 | +patterns-established: |
| 38 | + - "graph_data optional parameter pattern for backward-compatible graph enrichment" |
| 39 | + - "BFS cascade with decay_factor per hop for anomaly propagation" |
| 40 | + - "apply_to_graph_timeseries per-node scaling for multi-node time series" |
| 41 | + |
| 42 | +requirements-completed: [SELF-01, SELF-02] |
| 43 | + |
| 44 | +# Metrics |
| 45 | +duration: 5min |
| 46 | +completed: 2026-03-28 |
| 47 | +--- |
| 48 | + |
| 49 | +# Phase 03 Plan 01: Graph-Aware Proposer Summary |
| 50 | + |
| 51 | +**Graph-aware ProposerAgent with topology-based seed selection, 2-hop BFS cascade propagation (0.7 decay), and per-node time-series application via apply_to_graph_timeseries** |
| 52 | + |
| 53 | +## Performance |
| 54 | + |
| 55 | +- **Duration:** 5 min |
| 56 | +- **Started:** 2026-03-28T14:05:05Z |
| 57 | +- **Completed:** 2026-03-28T14:10:34Z |
| 58 | +- **Tasks:** 3 (TDD: RED/GREEN for each) |
| 59 | +- **Files modified:** 2 |
| 60 | + |
| 61 | +## Accomplishments |
| 62 | +- ProposerAgent.propose_scenario() accepts optional graph_data parameter with full backward compatibility |
| 63 | +- Seed nodes selected from LV feeders (node_type=2) for COLD_SNAP/OUTAGE/EV_SPIKE, all nodes for PEAK_SHIFT/MISSING_DATA |
| 64 | +- Cascade propagates through 2-hop BFS with 0.7 decay per hop (seeds=1.0, hop1=0.7, hop2=0.49) |
| 65 | +- Affected nodes capped at 30% of graph with seed preservation during subsampling |
| 66 | +- apply_to_graph_timeseries() applies per-node magnitude scaling to 2-D time-series arrays |
| 67 | +- 24 tests covering all graph-aware behavior, backward compatibility, and per-node application |
| 68 | + |
| 69 | +## Task Commits |
| 70 | + |
| 71 | +Each task was committed atomically (TDD flow): |
| 72 | + |
| 73 | +1. **Task 1: Test scaffold for graph-aware proposer** - `dcb337a` (test) |
| 74 | +2. **Task 2: Implement graph-aware proposer methods** - `37cff8a` (feat) |
| 75 | +3. **Task 3: Implement apply_to_graph_timeseries** - `e7370d6` (feat) |
| 76 | + |
| 77 | +## Files Created/Modified |
| 78 | +- `tests/test_graph_proposer.py` - 24 tests across 9 test classes covering graph-aware proposer, seed selection, cascade propagation, decay, backward compat, diversity, cap, and per-node application |
| 79 | +- `src/fyp/selfplay/proposer.py` - Extended with graph_data parameter, _enrich_with_graph_topology, _select_seed_nodes, _build_adjacency, _propagate_through_neighbors, and apply_to_graph_timeseries |
| 80 | + |
| 81 | +## Decisions Made |
| 82 | +- **1-3 seed nodes per scenario:** Cascade expands from few seeds rather than affecting 10-30% directly. This produces realistic propagation patterns. |
| 83 | +- **LV feeder preference for cascading types:** COLD_SNAP, OUTAGE, EV_SPIKE affect end-consumer nodes first, matching physical grid behavior. |
| 84 | +- **30% cap with seed preservation:** When cascade exceeds cap, seeds are always kept and non-seed nodes are randomly subsampled. Ensures cascade structure is preserved. |
| 85 | +- **Per-node blending formula:** `baseline + magnitude * (transform - baseline)` provides smooth interpolation between untouched and fully transformed time series. |
| 86 | + |
| 87 | +## Deviations from Plan |
| 88 | + |
| 89 | +None - plan executed exactly as written. |
| 90 | + |
| 91 | +## Issues Encountered |
| 92 | + |
| 93 | +None. |
| 94 | + |
| 95 | +## Known Stubs |
| 96 | + |
| 97 | +None - all methods are fully implemented with no placeholder data. |
| 98 | + |
| 99 | +## User Setup Required |
| 100 | + |
| 101 | +None - no external service configuration required. |
| 102 | + |
| 103 | +## Next Phase Readiness |
| 104 | +- Graph-aware proposer ready for integration with SelfPlayTrainer in Plan 03-02 |
| 105 | +- apply_to_graph_timeseries() provides the per-node application method that SelfPlayTrainer will use when graph_data is available |
| 106 | +- All 28 existing selfplay tests continue to pass (backward compatibility confirmed) |
| 107 | + |
| 108 | +## Self-Check: PASSED |
| 109 | + |
| 110 | +- tests/test_graph_proposer.py: FOUND |
| 111 | +- src/fyp/selfplay/proposer.py: FOUND |
| 112 | +- 03-01-SUMMARY.md: FOUND |
| 113 | +- Commit dcb337a: FOUND |
| 114 | +- Commit 37cff8a: FOUND |
| 115 | +- Commit e7370d6: FOUND |
| 116 | + |
| 117 | +--- |
| 118 | +*Phase: 03-graph-aware-proposer* |
| 119 | +*Completed: 2026-03-28* |
0 commit comments