Repository navigation
refactor(time): the wall clock is read once, by time::EpochMs; a gate keeps every other read at zero - #5000
Merged
Conversation
…vate clocks, 12 wrappers and 200 inline reads move onto it, and a gate keeps them at zero Joel, 2026-10-12: "Utils are lazy. Think Java." Measured on canary 73e4ae1 with the gate's own predicate: 176 SystemTime::now()->UNIX_EPOCH chains, 24 Utc::now().timestamp* reads and 69 private now_ms/now_millis/epoch_ms functions across 153 files, plus 12 wrappers under other names. Each copy chose its own meaning for a pre-1970 clock. - time::EpochMs owns the read, with each pre-1970 policy named: now() (reads the epoch), now_or_latest() (fails open: the lane breaker, SWE refusal expiry), read() (Err for callers that report it or treat it as no evidence). of(SystemTime), millis/secs/since, rfc3339(). - utils::age becomes time::age::Age (ago/span); its bucket test is unchanged. - Three hand-rolled ISO-8601 formatters ("without chrono", in a crate that depends on chrono) and a clock-seeded "random" are deleted; plasticity's created_at was "<secs>Z". - The orm pool's LRU stamp moves to a monotonic Instant (keeps nanosecond resolution, which test_lru_eviction needs); its idle cutoff saturates instead of underflowing. - Every caller's written pre-1970 reason stays at the call: 26 beside the read, 15 restored where their deleted clock held them, 2 non-reasons dropped. - resolve_dispatch_roster's doc, stranded on epoch_secs, is back on its function. - Gate: source-hygiene wall_clock::WallClockReadOnlyByEpochMs, baseline 0, production and test code. Mutation-proven: a private clock added to runtime/handle.rs fails it by line. Tests: cargo test -p continuum-core --lib on this box: 8812 passed, 34 failed; the same run at the base 73e4ae1: 8811 passed, 35 failed, and every branch failure is in the base set (environment: audio, GPU, shell steps on Windows). source-hygiene: 30 passed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
joelteply
added a commit
that referenced
this pull request
Oct 13, 2026
…rites follow the code into the package #5000 (time::EpochMs) rewrote nine clock sites in serving_daemon.rs, and #4996 had moved most of that code into serving_daemon/. The conflict keeps the split file, and every #5000 rewrite is applied where its code now lives: chat::now_ms and trace::now_ms become EpochMs::now().millis() (serving_daemon.rs, measure.rs, prompt_cache.rs, health.rs, reconcile.rs x3); vram.rs's private epoch_ms() is deleted and its two callers read EpochMs; snapshot.rs's ready_verified_at_ms reads EpochMs::read. source-hygiene, including #5000's wall_clock gate, exits 0. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply
added a commit
that referenced
this pull request
Oct 13, 2026
… too, and the gate scans tests/ (#5006) Four tests in core/continuum-core/tests/ kept private clocks after #5000: architecture_demand_pull_cognition, architecture_killer_loop_burst_cognition and capability_grant_e2e each had a `now_ms`; forge_custodian_daemon hashed the clock for a "unique" tmp dir, which now uses Uuid::new_v4().simple(). wall_clock::WallClockReadOnlyByEpochMs now also scans tests/, so they stay at zero. Mutation-proven: a planted clock in capability_grant_e2e.rs failed it at :151. Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Joel, 2026-10-12: "no intention to any of the code… dumped into files rather than architected into base classes… A tree", then "Utils are lazy. Think Java." This is step 1 of the plan posted to cambriantech (card e452fe9e): time becomes a value type that owns the clock read.
What changed
time::EpochMs(newtime/package, next toid_resolve). It is the only place continuum-core reads the wall clock as epoch time. Each pre-1970 policy is a named read:now(): a broken clock reads as the epoch. This is what most copies did.now_or_latest(): a broken clock reads as past every deadline. Used by the two callers that must fail open: the airc lane breaker (review of fix(persona): the command inbound pump re-opens its stream; remote requests name their model; sender breaker #3814) and SWE refusal expiry.read(): returnsErr(ClockBeforeEpoch)for callers that report a broken clock as an error, or treat it as "no evidence" (None).of(SystemTime)converts a file's mtime;millis()/secs()/since()/rfc3339()give the forms.time::age::Ageis the oldutils::age, now a type:Age::ago()/Age::span()replacehumanize_age/humanize_span. The bucket test is kept unchanged.now_ms/now_millis/epoch_msfunctions, 68 in the lib and 1 in the CLI binary. Other modules had been calling persona's privatetrace::now_msby path, 55 times.now(code/shell_session),now_unix_ms×3,now_ms_default×2,wall_clock_now_ms,now_ms_for_capture,timestamp_ms,now_epoch_ms,now_ms_for_decision,epoch_secs.SystemTime::now().duration_since(UNIX_EPOCH)chain and everyUtc::now().timestamp_millis().format!("{}Z", secs), which was never ISO.rand_u32(), which read the clock's subsecond nanos "without pulling in rand". rand is a dependency, so it is nowrand::random::<u32>().ManagedPoolLRU stamp moves to a monotonicInstantclock. A wall clock set backwards would reorder its LRU and make a pool read as idle. It keeps nanosecond precision, which its doc saystest_lru_evictionneeds.resolve_dispatch_roster's doc comment had been stranded onepoch_secssince someone inserted two functions between the doc and its function; deleting the wrapper puts it back.Pre-1970 reasons:
MAXfail-open pair, theErrcommands, theNoneliveness stamps, slots' fallback to the key's own stamp, lease renewal denied, the disk-eviction gap, and the decision tallies.unwrap_or:, since nounwrap_oris left there, topre-1970 reads 0:);EpochMs::now's doc says to re-audit these callers before changing its policy.SystemTimeas a value is untouched: mtime comparisons,set_modified, footprintlast_active, and the five change fingerprints that hash mtime nanoseconds. Changing those would invalidate stored fingerprints, and none of them is a clock read.The gate
source-hygiene::wall_clock::WallClockReadOnlyByEpochMsscans production and test code outsidetime/. It flags:SystemTime::now()chain that reachesUNIX_EPOCH;Utc::now().timestamp*;fn now_ms|now_millis|epoch_ms;EpochMsread (a wrapper under another name).The baseline is 0. Mutation proof: adding
fn now_ms() -> u64 { 0 }toruntime/handle.rsfailed the gate withruntime/handle.rs:130 — fn now_ms() -> u64 {; the file was restored.Measured
Counted with the gate's predicate on
core/continuum-core/src. Canary is 73e4ae1; the branch is this PR's head, rebased on canary and re-gated.SystemTime::now()→UNIX_EPOCHchainsUtc::now().timestamp*Diff: 195 files changed, 1041 insertions(+), 1858 deletions(-).
Tests:
cargo check -p continuum-core --lib --tests --binsis clean of new warnings; the dead-code warnings already on canary are listed in the follow-up below.cargo test -p continuum-core --libon this Windows box: 8812 passed, 34 failed. The same run at the base 73e4ae1: 8811 passed, 35 failed. Every branch failure is in the base set (audio, GPU, sentinel shell steps, Windows paths); the base's extra failure,training_producer::…work_submission_commands_bind…, passes here.cargo test -p source-hygiene wall_clock: 2 passed. New tests:time::tests::the_clock_reads_forward_and_an_age_never_wraps,time::tests::rfc3339_is_a_real_utc_date_with_milliseconds, and the gate's own 2.Behaviour changes, named
persona/service_module.rs's clock used.expect("system time before UNIX_EPOCH"), as did 2 test copies. A pre-1970 clock no longer panics the persona service; it reads as the epoch.created_atwas"<secs>Z"and is now RFC 3339.measured_at_msin the two training-rate rows goes from i64 to u64. The JSON is identical for every real clock.Not in this PR (owned)
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc