Skip to content

core, offline: stamp action-log and offline-queue times from an injected wall clock - #842

Merged
Yaraslaut merged 1 commit into
masterfrom
core/inject-wall-clock
Sep 29, 2026
Merged

Yaraslaut merged 1 commit into
masterfrom
core/inject-wall-clock

Conversation

@Yaraslaut

Copy link
Copy Markdown
Member

Partially addresses #807 (the wall-clock row).

What

Two places stamped a wall-clock time straight from std::chrono::system_clock::now(), so no test could pin it:

  • IModelHolder::recordIfAttached → LogEntry::timestampMs
  • SqliteOfflineQueue → the enqueued_at column

Both now read a core::platform::WallClockRef, from core-cpp v0.5.0:

  • IModelHolder::attachActionLog(log, contextKey, wallClock = defaultSystemWallClock())
  • SqliteOfflineQueue(..., busyTimeout, wallClock = defaultSystemWallClock())

Both default to the system clock, so existing callers are unchanged. The clock is borrowed, not owned, and WallClockRef refuses a temporary at compile time. Specs (journal.md, offline.md) and CHANGELOG.md are updated.

Not in this PR: folding the global DateTime::now() override and session::Clock into the same seam. Those are the rest of #807's clock row.

Verification

Debug build on macOS (Apple clang, -Weverything), with MORPH_BUILD_OFFLINE_SQLITE=ON and MORPH_BUILD_EXAMPLES=OFF:

  • The build produced no warnings.
  • morph_tests: test cases: 1661 | 1660 passed | 1 failed as expected.
  • morph_offline_sqlite_tests: test cases: 30 | 29 passed | 1 failed. The failure is not from this PR: master fails the same way here (assertions: 135 | 134 passed | 1 failed). The directory-fsync test compares "/private/var/folders/.../T" == "/var/folders/.../T", a macOS /var → /private/var symlink mismatch in the test itself.
  • Mutation check: with the two reads switched back to system_clock::now(), both new tests fail (1 failed each). They pass again once the change is restored.

Not verified locally: the WebAssembly build and the Doxygen doc target. core/platform/Clock.hpp is already included unconditionally by timeout_scheduler.hpp, so I expect it to compile under wasm, but I haven't built it.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ted wall clock

IModelHolder::recordIfAttached and SqliteOfflineQueue read
std::chrono::system_clock directly, so neither LogEntry::timestampMs nor the
queue's enqueued_at column could be pinned in a test. Both now read a
core::platform::WallClockRef: attachActionLog takes one as an optional third
parameter, and SqliteOfflineQueue's constructor as its last. Both default to
the system clock, so existing callers are unchanged.

Part of #807 (the wall-clock row).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yaraslaut
Yaraslaut force-pushed the core/inject-wall-clock branch from c5190e9 to c1f3a17 Compare September 29, 2026 13:02
@Yaraslaut
Yaraslaut merged commit 9d00105 into master Sep 29, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Subsystem: core enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant