Repository navigation
Description
Task
T-002d· Milestone M1 — Foundation · Size XS · Priority P1 · Epic #1Implements FR-RUN-002
Branch
feat/t-002d-core-clock-clock-protocol-with— one task = one branch = one PR (doc 32 §6)
Summary
Provide an injectable Clock abstraction so domain/application code never calls time.time() directly and timing logic (heartbeats, reaper, stop rules) is testable with a fake clock.
Context / motivation
AGENTS.md §3 forbids wall-clock calls in domain code. FR-RUN-002's acceptance criterion is explicitly a fake-clock test.
Scope
In scope
ClockProtocol:now() -> datetime(UTC, tz-aware),monotonic() -> float,sleep(seconds: float) -> None.SystemClock.FakeClock(start: datetime)withadvance(seconds);sleepadvances instantly.- Re-export a
NoopTracer-style Null Object is not part of this issue.
Implementation guidance
- File
backend/src/roboprobe/core/clock.py.FakeClocklives insrc(not tests) because integration fixtures and the experiment runner use it. - Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff
PLR2004); public APIs typed (mypy strict) and documented.
Acceptance criteria
-
SystemClock.now()is tz-aware UTC. -
FakeClockdeterministic;advanceaffects bothnowandmonotonic. - 100 % coverage.
- Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
- Docs, config reference and CHANGELOG
Unreleasedupdated where behaviour, keys or interfaces changed. - Definition of Done (doc 32 §3) satisfied.
Tests required
tests/unit/core/test_clock.py.
Dependencies
Blocked by: #12 (T-001)
Blocks: #82 (T-042a)
Parallelization notes
Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:
backend/src/roboprobe/core/clock.pybackend/tests/unit/core/test_clock.py
Independent single file.
Definition of Done
Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-002d (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.
References
Design docs: doc 05 §13 · doc 16 §3 · AGENTS.md §3
Requirements: FR-RUN-002 (traceability: doc 28)
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity