Review: Option D sizing engine -- optimized stack with hedging
Verdict: APPROVED
Re-review after refinement. Previous review (review-1690-2026-07-02) found 3 issues: missing arch-app note, missing dependency on #1, 6 ACs needing consolidation. All three are now resolved.
Template Completeness
- [x] Type -- Feature
- [x] Lineage -- Depends on #1 (Rails scaffold) and #3 (schema). Both must complete before this sprint:3 ticket.
- [x] Repo -- ldraney/kalshi-assistant
- [x] User Story -- present, well-formed
- [x] Context -- present, references docs/strategy/sizing-models.md (verified)
- [x] File Targets -- 2 files to create (app/services/sizing_engine.rb, app/services/scenario_analyzer.rb)
- [x] Feature Flag -- "none"
- [x] Acceptance Criteria -- 5 items (consolidated from 6)
- [x] Test Expectations -- 3 tests + run command (rails test)
- [x] Constraints -- present (pure Ruby, <1s for 10 picks)
- [x] Checklist -- present
- [x] Related -- present
Traceability
- [x] story:portfolio-builder label -- AI Portfolio Builder
- [x] story note verified -- story-kalshi-assistant-portfolio-builder exists, listed in project-kalshi-assistant user-stories section
- [x] arch:app label -- application component
- [x] arch note verified -- arch-app note exists in pal-e-docs (slug: arch-app, type: architecture, status: active). Contains Mermaid service diagram, component table with SizingEngine entry, and key decisions documenting the 83/17 split.
- [x] Forgejo issue -- ldraney/kalshi-assistant#5, open
File Targets
- [x] app/services/sizing_engine.rb -- to be created. Path depends on Rails scaffold (#1). Dependency is declared in Lineage.
- [x] app/services/scenario_analyzer.rb -- to be created. Same dependency chain as above.
- [x] docs/strategy/sizing-models.md -- verified: contains Option D math (83% YES / 17% NO split, -$5.77 worst case, all scenario tables with probabilities and P&L). Context reference is accurate.
Repo Placement
OK. Issue filed on ldraney/kalshi-assistant, work targets ldraney/kalshi-assistant. Single repo, no cross-repo concerns.
Dependencies
- Declared: #1 (Rails app scaffold, board item #1686, sprint:1, backlog) -- provides the app/services/ directory structure and test runner. Hard blocker.
- Declared: #3 (Strategy engine -- database schema, board item #1688, sprint:2, backlog) -- provides the strategy/trade schema the sizing engine operates on.
- Both dependencies are in backlog. Sprint ordering (1 → 2 → 3) enforces the correct sequence.
- Note: The arch-app diagram shows Watchdog (#1689, issue #4, sprint:3) consumes SizingEngine. That dependency belongs on the Watchdog ticket, not this one.
Acceptance Criteria
5 acceptance criteria, all concrete and agent-verifiable:
- Input contract: picks array with ticker/yes_ask/no_ask + budget -- well-defined interface
- Optimization method: brute-force over 50-99% YES/NO ratio -- deterministic, reproducible
- Output contract: optimal ratio, expected value, contracts per position -- complete output spec
- Scenario table: 2^N outcomes with probability and P&L -- verifiable against docs
- Scale constraint: 1-10 picks (1024 scenarios max) -- bounded and testable
Test expectations reference concrete values from docs (83/17, -$5.77) which are verified in sizing-models.md. Run command (rails test) is standard.
Blast Radius
Low. Creates new service classes in a greenfield codebase. No existing code to search for similar patterns. No downstream consumers at this stage. SizingEngine is self-contained computation with no external integrations.
Decomposition Assessment
- File targets: 2 files in 1 repo -- OK (below >3 across >2 repos threshold)
- Acceptance criteria: 5 -- at threshold, not over
- Estimated agent time: under 5 minutes -- math fully documented, two tightly coupled services
No decomposition needed.
Previous Review Issues -- Resolution
| Issue | Type | Status |
|---|---|---|
| arch-app note missing | [SCOPE] | FIXED -- arch-app note created with service diagram, component table, key decisions |
| Missing dependency on #1 in Lineage | [BODY] | FIXED -- Lineage now reads "Depends on #1 (Rails app scaffold) and #3 (schema)" |
| 6 ACs exceeding threshold | [BODY] | FIXED -- Consolidated to 5 by merging "Returns optimal ratio and expected value" into the output AC |
Recommendation
No action needed. All previous issues resolved. Ticket is ready to move to todo.