Tasks · 005-tax-lots
FIFO/LIFO tax lot tracking
Ordered, parallelizable work. Tests precede implementation. Drive through with
/spectastic.implement — one task per invocation.
005-tax-lots
Created
Read time
16 tasks across five phases. Setup → Foundational → User stories (US1·US2·US3) → Polish. Tasks marked [P] can run in parallel — different files, no dependency. Tests for a story MUST be written and failing before its implementation tasks start.
1 · Execution strategy
Implement US1 end-to-end. Ship. Iterate to US2 and US3 only after US1 is verified.
Setup → Foundational → US1 → US2 → US3 → Polish. Each story closes its conformance before the next opens.
One team on each user story after Foundational. Coordinate at shared seams (data model, API contracts) via the spec, not Slack.
2 · Phase 1 — Setup
quarkus-micrometer-registry-prometheus, quarkus-smallrye-openapi, and the jacoco plugin are already wired by 001. pom.xml3 · Phase 2 — Foundational
Shared infrastructure no story can ship without. Sequential where order matters.
TradeEvent, PriceTick, and PRICE_SCALE; define no umbrella types here. src/main/java/io/spectastic/portfolio/model/4 · Phase 3a — US1 · Open lots on buys
Tests (write & fail first)
Implementation
ArrayDeque<Lot> per (account, instrument) in acquisition order. src/main/java/io/spectastic/portfolio/tax/TaxLotBook.javaCloses FR-001.
5 · Phase 3b — US2 · Relieve by FIFO or LIFO on a sell
Tests (write & fail first)
Implementation
qtyOpen; realized gain qty·(sellPrice − lotBasis) in long arithmetic. src/main/java/io/spectastic/portfolio/tax/TaxLotBook.java6 · Phase 3c — US3 · Auditable realized gain
Tests (write & fail first)
RealizedGainRecord names lot, policy, proceeds, basis, gain; summing reproduces cumulative realized gain. src/test/java/io/spectastic/portfolio/TaxLotBookTest.javaPriceTick; incremental equals a full replay to the cent. src/test/java/io/spectastic/portfolio/TaxLotBookTest.javaImplementation
7 · Phase 4 — Polish
/q/metrics; JMH microbench confirms relief p99 < 40 µs at 1000 lots. src/main/java/io/spectastic/portfolio/tax/TaxLotBook.java8 · Dependencies
Setup → Foundational
Foundational → US1, US2, US3 (independent after this point)
US1, US2, US3 → Polish
7 · Add HIFO relief policy (applied change 2026-07-22-hifo-relief)
Folded from the applied proposal's §6 (the archive is frozen).
10 · Change log
- Initial task breakdown. TDD per story: US1 acquisition-ordered lot opens (T-100/T-110), US2 FIFO/LIFO relief with the SC-001 worked example as the headline test plus short-lot oversell (T-200/T-210/T-211), US3 immutable audit records and unrealized-on-tick reconcile-to-replay (T-300/T-301/T-310/T-311). Polish: bounded-lot assertion, Micrometer relief timer with JMH envelope check, diff-aware jacoco.