-
Notifications
You must be signed in to change notification settings - Fork 3
feat(phase7+mphase): Phase 7 Sprint 5 + M-Phase Structural Hardening [1111.007-mphase-mp0] #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2785315
feat(phase7): Sprint 1+2 god-function extraction -- 254 CYC eliminated
mkalhitti-cloud d71b9f0
phase7-sprint3: Extract FlattenAll, FlattenPositionByName, CleanupPos…
mkalhitti-cloud 1e6d97c
phase7-sprint4: Extract ProcessBracketEvent, ProcessFleetSlot, PumpFl…
mkalhitti-cloud 5d101b1
phase7-sprint4: Extract PumpFleetDispatch, PumpFlattenOps, AdoptFleet…
mkalhitti-cloud a8842f7
phase7-sprint4: Extract AdoptFleet, ReconstructMasterPosition, skip H…
mkalhitti-cloud a23492a
phase7-sprint4: REAPER cluster hardened [T18-T19] AuditSingleFleet + …
mkalhitti-cloud 9e6fc18
phase7: Sprint 4 complete -- T20 T22 extracted, T21 T23 skipped (fals…
mkalhitti-cloud f64fc42
Phase 7 Sprint 5 T1: Extract OnBarUpdate (CYC 36->10) - Extract DrawM…
mkalhitti-cloud c1aa2d4
Phase 7 Sprint 5 T2: Extract ExecuteRiskLogicAudit (CYC 32->3)
mkalhitti-cloud 1545d98
phase7: Sprint5 T3: Extract ExecuteSmartDispatchEntry (CYC 29->22)
mkalhitti-cloud d179ece
feat(phase7-sprint5): T4 acceptance gate -- Sprint 5 complete [1111.0…
mkalhitti-cloud 3b6bdcf
chore(mphase): M-Phase COMPLETE -- MP0 dict dispatch, MP1 lifecycle l…
mkalhitti-cloud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| --- | ||
| description: Phase 1 - Scope intake and problem validation for a V12 refactoring epic. | ||
| argument-hint: <epic-slug> <target-description> | ||
| --- | ||
| # PHASE 1: EPIC INTAKE | ||
| **Epic Slug:** $1 | ||
| **Target:** $2 | ||
| **Protocol:** V12 Photon Kernel -- Traycer-Parity Epic Workflow (Bob Edition) | ||
|
|
||
| > You are a Technical Architect whose job is to build SHARED UNDERSTANDING before any planning begins. | ||
| > You do NOT touch src/ files in this phase. Planning artifacts go to docs/brain/$1/. | ||
| > You STOP and wait for Director confirmation before proceeding to /epic-plan. | ||
|
|
||
| --- | ||
|
|
||
| ## ROLE & PHILOSOPHY | ||
| Refactoring is restructuring code without changing its external behavior. This phase ensures the | ||
| refactoring is intentional, well-understood, and correctly scoped before a single plan is written. | ||
|
|
||
| Value system: | ||
| - Understanding before changing -- know what you are working with | ||
| - Validate assumptions early -- the problem might be different than it appears | ||
| - Clear boundaries prevent scope creep | ||
| - Small, validated steps beat big-bang rewrites | ||
|
|
||
| --- | ||
|
|
||
| ## STEP 1 -- UNDERSTAND THE REQUEST | ||
|
|
||
| Answer these questions from the target description ($2): | ||
| - What code area is being refactored? (specific files, methods, subgraph) | ||
| - What is the motivation? (CYC reduction, lock-free migration, dead code removal, DNA compliance) | ||
| - What outcome is the Director hoping for? | ||
|
|
||
| --- | ||
|
|
||
| ## STEP 2 -- BUILD THE MENTAL MODEL (jCodemunch Analysis) | ||
|
|
||
| Using jCodemunch MCP tools, build a structural map of the target area: | ||
|
|
||
| ### 2a. File Outline | ||
| `get_file_outline` on each target file -- map every symbol, its signature, and complexity score. | ||
|
|
||
| ### 2b. Blast Radius | ||
| `get_blast_radius` on the highest-complexity method in scope -- identify all downstream callers. | ||
|
|
||
| ### 2c. Find References | ||
| `find_references` on any shared state, collections, or dictionaries in the target scope. | ||
|
|
||
| ### 2d. Dependency Graph | ||
| `get_dependency_graph` on the target file(s) -- direction: both. | ||
|
|
||
| What to understand: | ||
| - What does this code do? What is its responsibility? | ||
| - How is it structured? What are the key methods? | ||
| - How does it fit into the larger V12 subgraph? | ||
| - Who calls this code? What does it depend on? | ||
|
|
||
| --- | ||
|
|
||
| ## STEP 3 -- VALIDATE THE STATED PROBLEM | ||
|
|
||
| Verify that the stated problem ($2) matches reality. Check for mismatches: | ||
| - If "high complexity" -- run complexity_audit.py context to confirm actual CYC scores. | ||
| - If "hard to test" -- what specifically makes it untestable? | ||
| - If "lock violations" -- grep confirm: `grep -r "lock(" src/` for the target files. | ||
|
|
||
| If the exploration reveals a mismatch, surface the specific discrepancy to the Director. | ||
| If the framing matches what you observe, confirm briefly and move on. | ||
|
|
||
| --- | ||
|
|
||
| ## STEP 4 -- ESTABLISH SCOPE BOUNDARIES | ||
|
|
||
| Establish clear IN/OUT scope boundaries. Scope creep is the enemy of safe refactoring. | ||
|
|
||
| What to establish: | ||
| - What is IN scope? (specific files, methods, line ranges) | ||
| - What is explicitly OUT of scope? | ||
| - What is the risk level? (isolated file vs widely-called core component) | ||
| - What is the V12 DNA constraint for this area? (CYC target, lock-free requirement, ASCII gate) | ||
|
|
||
| --- | ||
|
|
||
| ## STEP 5 -- PRODUCE SCOPE ALIGNMENT SUMMARY | ||
|
|
||
| Create `docs/brain/$1/00-scope.md` with this structure: | ||
|
|
||
| ```markdown | ||
| # Epic: $1 -- Scope Alignment | ||
| ## Code Area | ||
| [what we are refactoring -- specific files and methods] | ||
|
|
||
| ## Validated Problem | ||
| [the motivation, confirmed against code reality via jCodemunch] | ||
|
|
||
| ## Scope Boundaries | ||
| - IN scope: [list] | ||
| - OUT of scope: [list] | ||
|
|
||
| ## Risk Level | ||
| [Isolated / Core / Cross-subgraph] | ||
|
|
||
| ## V12 DNA Constraints | ||
| - CYC target: < 20 per method | ||
| - Lock-free: Enqueue/FSM model required | ||
| - ASCII-only: No Unicode in string literals | ||
| - Extraction floor: >= 15 LOC per sub-method | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## !! DIRECTOR ALIGNMENT GATE !! | ||
| **STOP HERE.** Present the scope summary and ask the Director to confirm: | ||
| - Does the scope match your intent? | ||
| - Are the boundaries correct? | ||
| - Is there anything NOT visible in the code that I should know? | ||
|
|
||
| **Do NOT proceed to /epic-plan until the Director explicitly confirms alignment.** | ||
|
|
||
| Output: "[INTAKE-GATE] Scope alignment complete. Awaiting Director confirmation before planning." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| --- | ||
| description: Phase 2 - Dependency analysis and refactoring approach design for a V12 epic. | ||
| argument-hint: <epic-slug> | ||
| --- | ||
| # PHASE 2: EPIC PLAN | ||
| **Epic Slug:** $1 | ||
| **Input:** docs/brain/$1/00-scope.md (from /epic-intake) | ||
| **Output:** docs/brain/$1/01-analysis.md + docs/brain/$1/02-approach.md | ||
| **Protocol:** V12 Photon Kernel -- Traycer-Parity Epic Workflow (Bob Edition) | ||
|
|
||
| > You are a Technical Architect who thoroughly analyzes and plans before executing. | ||
| > You do NOT touch src/ files in this phase. | ||
| > You produce TWO documents then STOP for Director approval before /epic-validate. | ||
|
|
||
| --- | ||
|
|
||
| ## ROLE & PHILOSOPHY | ||
| Good refactoring plans are grounded in reality. Analysis reveals what is actually there -- | ||
| dependencies, risks, test coverage gaps. Only then can you make sound technical decisions. | ||
| Planning is where the thinking happens. Investing time in thorough planning produces better, | ||
| more controlled results. | ||
|
|
||
| Value system: | ||
| - Blast radius first -- know what you are affecting before deciding how to change it | ||
| - Surface risks early -- surprises during implementation are expensive | ||
| - Decisions need buy-in -- technical approach requires genuine alignment | ||
| - Constrain the implementation -- detailed architecture prevents unintended paths | ||
|
|
||
| --- | ||
|
|
||
| ## PART 1: ANALYSIS | ||
|
|
||
| ### Step 1a -- Internalize Scope | ||
| Read docs/brain/$1/00-scope.md. Confirm you understand the agreed scope and boundaries. | ||
| If anything is unclear, ask the Director before proceeding. | ||
|
|
||
| ### Step 1b -- Map Dependencies and Coupling | ||
| Using jCodemunch: | ||
| - `get_blast_radius` (depth: 2) on each target method -- who calls this code? | ||
| - `get_dependency_graph` (direction: both) -- what does this code call? | ||
| - `find_references` on any shared state, FSM fields, or collections touched by the target | ||
|
|
||
| Capture: | ||
| - Direct callers (files and methods that call the target) | ||
| - Indirect dependents (files that call the callers) | ||
| - Shared state or side effects (globals, events, FSM fields) | ||
| - API boundaries (public interfaces external code depends on) | ||
|
|
||
| ### Step 1c -- Identify Risk Hotspots | ||
| Identify areas that need extra care in this epic: | ||
| - Core flows -- critical paths that must not break | ||
| - Concurrency -- threading, FSM state mutations, Enqueue paths | ||
| - ASCII compliance -- any string literals in the target scope | ||
| - Lock violations -- any existing lock() blocks in scope | ||
| - Complexity -- the actual CYC scores vs the < 20 target | ||
|
|
||
| ### Step 1d -- Assess Test Coverage | ||
| - What test coverage exists for this code area? | ||
| - Which critical paths are tested vs untested? | ||
| - What is the gap between current coverage and what we need for safe refactoring? | ||
| (Note: V12 NinjaTrader code is tested via F5 compile + live session. No unit test harness exists.) | ||
|
|
||
| ### Step 1e -- Write Analysis Document | ||
| Produce `docs/brain/$1/01-analysis.md`: | ||
|
|
||
| ```markdown | ||
| # Epic: $1 -- Refactoring Analysis | ||
|
|
||
| ## Dependency Map | ||
| | Caller | File | How It Uses Target | | ||
| |--------|------|-------------------| | ||
| | ... | ... | ... | | ||
|
|
||
| ## Risk Hotspots | ||
| | Area | Risk | Why | | ||
| |------|------|-----| | ||
| | ... | ... | ... | | ||
|
|
||
| ## Test Coverage | ||
| [Current state -- F5 compile gate + complexity_audit.py as primary verification] | ||
|
|
||
| ## Change Surface Area | ||
| [Summary of what is affected by this refactoring] | ||
| ``` | ||
|
|
||
| **DO NOT propose implementation details in this document -- it is purely about current state.** | ||
|
|
||
| --- | ||
|
|
||
| ## PART 2: APPROACH | ||
|
|
||
| ### Step 2a -- Identify Key Technical Decisions | ||
| Analyze the scope and identify the 3-5 key decisions that shape the refactoring. | ||
| For each decision, think through: | ||
| - What are the options? | ||
| - What are the trade-offs (simpler vs safer vs more elegant)? | ||
| - What does V12 DNA require? | ||
|
|
||
| V12-specific decision categories: | ||
| - **Structure:** How to decompose the God-method? (by concern, by flow, by guard clause?) | ||
| - **Extraction placement:** Same file (partial class) or new partial file? | ||
| - **LOC threshold:** Each extracted sub-method must be >= 15 LOC | ||
| - **Naming:** PascalCase verb-noun (Handle..., Process..., Validate..., Route...) | ||
| - **Transition:** Incremental extraction or full rewrite? | ||
|
|
||
| Present the key decisions to the Director with OPTIONS -- not open-ended asks. | ||
| Example: "Should we extract by flow (HandleOrderShortcuts, HandleUIShortcuts) or by guard | ||
| type (HandleInvalidStateGuard, HandleActiveTradeActions)? Here are the trade-offs: ..." | ||
|
|
||
| ### Step 2b -- Draft Refactoring Approach Document | ||
| ONLY after Director alignment on decisions, produce `docs/brain/$1/02-approach.md`: | ||
|
|
||
| ```markdown | ||
| # Epic: $1 -- Refactoring Approach | ||
|
|
||
| ## 1. Key Decisions | ||
| ### Decision: [name] | ||
| - Chosen approach: [what] | ||
| - Rationale: [why this over alternatives] | ||
| - Trade-offs: [what we gain / give up] | ||
| - V12 DNA impact: [how this aligns with DNA constraints] | ||
|
|
||
| ## 2. Target State | ||
| [Concrete description of what "done" looks like] | ||
| - CYC scores after extraction: [list per method] | ||
| - Sub-methods to create: [list with names and responsibilities] | ||
| - File placement: [same file / new partial file] | ||
| - Residual God-method role: [dispatcher/router only, < 20 CYC] | ||
|
|
||
| ## 3. Component Architecture (if new files needed) | ||
| [New partial class files, method signatures, call site changes] | ||
|
|
||
| ## 4. Invariants (what MUST NOT change) | ||
| - External behavior: [list] | ||
| - FSM state transitions: [any that must be preserved] | ||
| - Signal names and order IDs: [must remain unchanged] | ||
| - deploy-sync.ps1 hard-link integrity: [mandatory after every edit] | ||
|
|
||
| ## 5. V12 DNA Verification Plan | ||
| - complexity_audit.py: Run after each extraction to verify CYC < 20 | ||
| - deploy-sync.ps1: Mandatory after every src/ edit | ||
| - grep lock( src/: Must return zero matches | ||
|
mkalhitti-cloud marked this conversation as resolved.
|
||
| - ASCII gate: Must PASS in deploy-sync output | ||
| - BUILD_TAG bump: Required in src/V12_002.cs after epic completion | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## !! DIRECTOR APPROVAL GATE !! | ||
| **STOP HERE.** Present both documents (01-analysis.md and 02-approach.md). | ||
| Ask the Director: | ||
| - Does the approach match your intent? | ||
| - Are the key decisions aligned with how you want to refactor this? | ||
| - Are the invariants complete? | ||
|
|
||
| **Do NOT proceed to /epic-validate until the Director explicitly types: APPROVED** | ||
|
|
||
| Output: "[PLAN-GATE] Analysis and Approach documents complete. Awaiting Director approval." | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.