pub fn seconds_ago(secs: i64) -> DateTime<Utc>Expand description
A wall-clock anchor secs seconds before the current instant — the
one-line Utc::now() - chrono::Duration::seconds(secs) chain lifted
to ONE typed owner past the ★★ PRIME-DIRECTIVE ≥ 2 duplication
threshold, and the composition partner of every timed-decision test
(or production caller) that needs a “recently-past” anchor to feed
elapsed_since or a humantime-parsed budget comparator.
Pre-lift the SAME chain was hand-authored at 21 workspace-wide
consumer sites across 6 files, each restating Utc::now() - chrono::Duration::seconds(<N>) verbatim to seed a
DateTime<Utc> N seconds in the past:
tatara-process— 15 sites acrosscrd.rs+lib.rs+lifetime_clock.rsseeding TTL-expiry, staleness-gate, and observed-anchor tests.tatara-reconciler::claim— 4 sites in the stable-name claim arbiter’s pure decision tests, each seeding agranted_atorcreated_atanchor for tie-break arithmetic.tatara-pool-reconciler— 2 sites inpool_decide+desired.rsseeding per-memberentered_state_at/created_atfor pool-convergence dwell-time decisions.
All 21 sites walked the SAME two-link chain — read the wall clock,
then subtract a whole-second chrono::Duration — differing only in
the second-count N (age_secs parameter, 500, 720, 42,
etc.). Post-lift each callsite reads seconds_ago(N) and the
wall-clock read + subtraction sink lives at ONE substrate owner.
Return-form axis: DateTime<Utc> — the copy-form anchor every
consumer’s downstream signed_duration_since / [elapsed_since]
/ Time(anchor) composer takes as its second operand. The i64
secs parameter matches chrono::Duration::seconds’s own signature
so a negative value (rare but permitted) yields a future anchor,
mirroring the pre-lift semantics.
Sibling to elapsed_since on the same (now, anchor) → Δ axis —
elapsed_since reads the delta between two given anchors,
seconds_ago produces the anchor N seconds before now that the
delta consumer needs.
A future normalization (a monotonic-clock cross-check, an injectable
time_source: impl Fn() -> DateTime<Utc> for deterministic tests,
a per-fleet skew Δ that clamps the wall-clock read past a known-bad
range) lands at THIS ONE substrate primitive and every downstream
consumer (production callers, test helpers, future timed-decision
gates) inherits the upgrade mechanically — no per-site edit at any
of the 21 listed callers or at future consumers.