2.7 KiB
2.7 KiB
OpenSpec Change: timing-spec-conformance
- Change ID: timing-spec-conformance
- Package:
@suaveplan/timing - Status: PROPOSED
- Date: 2026-04-26
Summary
Add **Verified by:** lines to every requirement in openspec/specs/timing/spec.md, fix two real implementation drifts inline, and add a consolidated src/timing.spec-conformance.test.ts so that bun scripts/openspec-conformance.ts @suaveplan/timing exits 0. No public surface trimming.
Current state
@suaveplan/timing has 12 requirements (TM-01 through TM-12) and 137 passing tests across stopwatch, scheduler, throttle/debounce, decay, timer/countdown, vector-clock, errors, and OTel modules. Two real drifts surfaced during the audit:
- TM-11 incomplete OTel emission. The spec required "stopwatch elapsed, scheduler queue depth, and timer tick counter" to emit. Only standalone helpers
recordStopwatchElapsedandincrementTimerTickexisted; they were never called bystopwatch,scheduler, ortimermodules, andrecordSchedulerQueueDepthdid not exist at all. - No
**Verified by:**lines on any of the 12 requirements.
Plus the audit-level finding that openspec/archive/2026-04-19-enterprise-timing/tasks.md carries the historical phrase retroactively ticked; opening this change folder lifts that block.
What changes
- Add
recordSchedulerQueueDepthtosrc/otel/timing-otel.ts(lazyObservableGaugewith mutable observed value, no-op without exporter). Re-export fromsrc/index.ts. - Wire
scheduler.schedule, the per-taskfinally, handle-cancel, top-levelcancel, anddisposeto callrecordSchedulerQueueDepth(_tasks.size)so queue-depth telemetry tracks the live task map. - Wire
stopwatch.stopto callrecordStopwatchElapsed(_accumulated). - Wire
createTimer.startto invokeincrementTimerTick()on each interval before the user'sonTick. - Add
src/timing.spec-conformance.test.tscovering: throttle window count, debounce flush/cancel/maxWait, vector-clock relation matrix + JSON round-trip +updatemax-merge, scheduler drain order + pre-abort, countdown pause/resume invariant with injected clock, stopwatch monotonicity across laps, and OTel no-op smoke for the new gauge plus the existing helpers. - Add
**Verified by:**lines under every requirement inopenspec/specs/timing/spec.md.
Impact
- Public API gains one new export:
recordSchedulerQueueDepth. No removals, no renames. - Stopwatch
.stop(), scheduler enqueue/dequeue, and timer ticks now emit OTel telemetry (no-op without exporter, so observable behaviour for existing consumers is unchanged). - One new test file (~200 lines).
openspec/specs/timing/spec.mdgains 12**Verified by:**lines.