Repository navigation
[CTX-1708] test(runtime): pin the bar clock timer chain past the pre-armed cap (bitty#2899) - #2901
Conversation
…armed cap (bitty#2899)
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 54 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Xuepoo
left a comment
There was a problem hiding this comment.
Independent review — I did not write this code.
Head SHA: 9ef3aa0c2702b027a40687b4f3f2488df7aa4b18 (branch ctx-1708-bar-tick, 1 commit)
Files: Cargo.lock, crates/bitty-runtime/Cargo.toml, crates/bitty-runtime/tests/bar_clock_tick.rs (+482/−0)
1. Test-only in effect — PASS
Non-test files touched: 2, both build metadata, neither changes shipped behaviour.
crates/bitty-runtime/Cargo.toml:183[dev-dependencies]; the added line iscrates/bitty-runtime/Cargo.toml:187chrono.workspace = true. Dev-dependencies are compiled only for tests/benches/examples;cargo build/release output is unchanged.Cargo.lock:445adds the single string"chrono"to the[[package]] name = "bitty-runtime"dependency list. No new[[package]]entry, no version bump.- No
crates/*/src/**file is in the diff (gh pr diff --name-only).
crates/bitty-runtime/tests/bar-pin — the plugin under test — is untouched, which is what makes tests 1–2 an end-to-end observation rather than a self-fulfilling fixture.
2. Flake / tautology analysis — PASS
No sleep, no retry, no wall-clock wait anywhere: the only Instant::now() calls are tests/bar_clock_tick.rs:237 and :376, used as the base for the fake clock; deadlines are then computed as base + n·cadence and pumped with pump_due_timers_at(deadline). Whole suite runs in 0.29–0.56 s.
pinned_bar_clock_ticks_past_the_prearmed_chain(:282) — not tautological. Drives the real pinned bar through 40 cadence deadlines and asserts the exact fire count 71 (:297-301), exactly oneui.updateper fired callback via the band version counter (:259-263), a live-minute capsule on every pump (:265-268), and that another wake stayed armed (:272-275). The count is externally fixed by the bar's chain semantics, not read back from the runtime.pinned_bar_clock_ticks_past_four_hundred_ticks(:326) — same shape, 431 fires (:332-336), still armed after (:337-340), stillActive(:342).bar_arm_shape_rearm_is_never_rejected(:391) — assertsrearm_fail == 0(:434-438) andfires == 431(:439-443) andpumps == 400(:433). The counter alone would be weak: the runtime skips an over-cap arm with a silentcontinue(crates/bitty-runtime/src/plugin_runtime/mod.rs:2257), so a rejected re-arm does not necessarily surface as a Lua error. Thefires/pumpspair is what actually catches it — and did, under mutation (below).one_shot_timer_control_still_fires_once(:449) — real control: exactly one fire (:470-471), no wake left (:472), second pump at the same instant delivers 0 (:473-474). It guards against the driver itself over-firing.
Non-tautology was verified by mutation on a throwaway git archive copy of the head tree (repo untouched): making the post-callback arm path refuse any pending deadline (mod.rs:2257, pending >= 1) turned tests 1, 2 and 3 red while the one_shot control stayed green. So the three chain tests bind to the re-arm mechanism, and the control does not depend on it.
Wall-clock boundary: the only real-clock assertion is is_live_local_minute (:201-217), which accepts now, now − 1 min, now + 1 min, so the minute rollover cannot fail it, and the render happens in the same instant as the check (no sleeping). The looser ±1 min window cannot mask staleness because re-render is pinned separately by the per-pump version increment (:259-263).
Repeatability: 12 consecutive runs of the binary, 4/4 pass each time (--test-threads=4, same as CI).
3. Dependency hygiene — PASS
Cargo.lockhunk present in this PR:Cargo.lock:445(+ "chrono",). Required by the project rule and satisfied in the same commit.- Version/feature consistency: workspace pin
Cargo.toml:74chrono = { version = "0.4", default-features = false, features = ["clock", "std"] }; the crate opts in withchrono.workspace = true, so it inherits that exact range and feature set — no per-crate feature drift is possible. - No unwanted crates:
default-features = false(noserde, nowasm-bindgen, nounstable-locales).chrono 0.4.45was already in the graph as abitty-luadependency (Cargo.lock:667), and the diff adds no[[package]]entry, so nothing new enters the supply chain. CISupply chain (deny/audit)passes. - Only
Local::now()andformat("%H:%M")are used (:209-216), both covered by theclock/stdfeatures already enabled by the workspace.
4. MSRV 1.85 — PASS
- No let-chains. The only compound predicates are a plain
if a || b(:206) andwhile let Some(deadline) = ...(:243,:378).u32::try_fromat:261resolves via the edition-2024 prelude. - Verified with the real toolchain on a clean
git archiveof head (/mnt/data/.../.targets/rev-2901-src, repo checkout untouched):cargo +1.85 check -p bitty-runtime --tests --offline→Finished dev profile ... in 1m 14s, no errors/warnings.cargo +1.85 test -p bitty-runtime --test bar_clock_tick --test plugin_timers --test bar_activation_budget --offline→ 4 passed / 8 passed / 2 passed.
- CI agrees:
MSRV 1.85 checkpass.
5. Close / issue wiring — PASS
- Body references only
#2899and#2900, both in non-closing prose ("Pins the timer model behind the bar clock capsule for bitty#2899. Does not close the issue…", "#2900 tracks the real silent-death defect…"). Noclose(s|d) #N,fix(es|ed) #Norresolve(s|d) #Npattern anywhere in the body. gh pr view 2901 --json closingIssuesReferences→[], so merging closes nothing. Correct: the production defect fix lives outside this PR, and the body says so explicitly.
Nits (non-blocking)
- The fire counts 71/431 encode the pinned bar's chain arithmetic (
:292-296,:330-331). Anybar-pinbump will need these updated in lockstep — worth a line in the pin-bump checklist. - Temp data dirs are only removed on the success path (
:322,:343); a panic leaves abitty-bar-clock-*dir in$TMPDIR. is_live_local_minutewould also accept a literal00:00between 23:59 and 00:01 local. Harmless, and the mutation run showed it does catch a hardcoded00:00at any other time.
20/20 CI checks pass at this SHA.
VERDICT: APPROVE
Priority: P1 | Area: plugins | Labels: fix,P1,area:plugins,area:ui | Milestone: v0.0.33 | RFC: none | Task: CTX-1708
Test-only. Pins the timer model behind the bar clock capsule for bitty#2899. Does not close the issue: the
00:00:00capsule still needs owner capture (see the issue comment).What the test proves
The pinned official bar (
crates/bitty-runtime/tests/bar-pin, byte-identical to the catalog pin) is driven through a fake runtime clock:arm_onceshape, 1 s cadenceSo the pre-armed 32-tick chain plus the callback re-arm never runs dry, and no re-arm is rejected. Caps are 64 live rows and 64 pending deadlines; fired rows are pruned before invoke so an at-cap chain cannot deadlock.
Because the capsule text is
os.date("%H:%M", os.time())(real wall clock, not the runtime clock), the test asserts the rendered minute equals the live local minute at every step - which is exactly what catches an epoch/zero formatting fallback - while the version counter proves oneui.updateper fired callback.Tests
pinned_bar_clock_ticks_past_the_prearmed_chainpinned_bar_clock_ticks_past_four_hundred_ticksbar_arm_shape_rearm_is_never_rejected(fixture mirroringarm_once, countsE_DEF_LIMITrejections)one_shot_timer_control_still_fires_onceAdds
chronoas a dev-dependency only (local-minute assertion).Gates
cargo fmt --all -- --check;RUSTFLAGS="-D warnings" cargo clippy -p bitty-runtime --all-targets;cargo test -p bitty-runtime --test bar_clock_tick-> 4 passed;--test bar_activation_budget2 passed;--test plugin_timers8 passed; fullcargo test -p bitty-runtimegreen including doctests.Related
Active).