Skip to content

[CTX-1869] fix(runtime,render): enforce watchdog Release/Acquire ordering and clip Block border to allocation - #3217

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-1869/fix-watchdog-ordering-and-border-clip
Nov 17, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-1869/fix-watchdog-ordering-and-border-clip

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Priority: P1 | Area: runtime | Labels: fix, P1, area:runtime | Milestone: v0.1.0 | Task: CTX-1869

Closes #3215

Summary

Follow-up hardening for #3211 (#3213) and #2191 (#3212):

  1. crates/bitty-terminal/src/stall_watchdog.rs: Compute elapsed_ns() and store last_beat_ns strictly before storing phase (Release), active (Release), keeping the publish_gap_ms test seam intact, and incrementing progress (Release). Use paired Ordering::Acquire loads on progress, phase, and active before idle_for() in monitor_loop (including SIGUSR1 & idle_park paths), StallWatchdog::{enter,idle}, and build_report. Added regression test enter_after_long_idle_emits_no_spurious_report_in_publish_gap.
  2. crates/bitty-render/src/scene.rs: Intersect cell-border segments in Painter::paint_border with both the surface aligned rect and the child allocated rect (cell_rect(x, y, available.cols, available.rows)) so height/width-capped Block frames never paint border strokes into sibling cells.
  3. Regression tests: Added border-clip assertions in crates/bitty-render/tests/scene_style_paint.rs and crates/bitty-runtime/tests/lua_ui_style_height.rs (plus strengthened Row sibling position check).

Review & Local Verification

  • Independent review: PX-8723 (NEEDS-FIX caught last_beat_ns / active ordering) -> fixed in PX-8724 (69006722) -> independent re-review PX-8726 (APPROVE).
  • Passed locally on 69006722: cargo fmt --all -- --check, ./scripts/check-scratch-paths.sh, RUSTFLAGS="-D warnings" cargo clippy -p bitty-render -p bitty-runtime -p bitty-lua -p bitty-terminal --all-targets --locked, stall_watchdog (78/78), bitty-render (all suites), lua_ui_style_height (15/15), and scene_style_vocabulary (6/6).

@Xuepoo Xuepoo added this to the v0.1.0 milestone Nov 17, 2026
@Xuepoo Xuepoo added fix Bug fix P1 Priority: high area:runtime Area: runtime orchestration labels Nov 17, 2026
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5c4d369b-0a2f-4e6b-890d-86926544e8b3
Commits

Reviewing files that changed from the base of the PR and between 5967c23 and 6900672.

Files selected for processing: 4

  • crates/bitty-render/src/scene.rs
  • crates/bitty-render/tests/scene_style_paint.rs
  • crates/bitty-runtime/tests/lua_ui_style_height.rs
  • crates/bitty-terminal/src/stall_watchdog.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review verdict, recorded in carryctx as PX-8726 (task CTX-1869) by a reviewer
agent separate from the implementer. Posted here by the guard tick so branch protection sees
the approval on the reviewed head.

Reviewed head: 690067224ec6f17a072626a3d8da56950f30a776 (= headRefOid, un-moved at post time).

Verdict text (verbatim from PX-8726, created 2026-11-17T08:26:25Z):

Review verdict: APPROVE on commit 6900672 (CTX-1869 /
Issue #3215). Verified all PX-8723 NEEDS-FIX items resolved in stall_watchdog.rs:
Shared::mark stores last_beat_ns first then Release-stores phase, active,
publish_gap_ms seam, and progress; monitor_loop Acquire-loads progress (init and
take_advance), phase (SIGUSR1 and main sample), active (main sample and idle_park),
StallWatchdog::{enter,idle} Acquire-load active, build_report Acquire-loads progress;
enter_after_long_idle_emits_no_spurious_report_in_publish_gap non-tautologically verifies
the publish-gap seam. Verified scene.rs paint_border allocation clipping plus
scene_style_paint.rs and lua_ui_style_height.rs tests remain intact. Gates passed after
deleting temp target: fmt, scratch-paths, clippy -D warnings (4 crates), stall_watchdog
(78/78), bitty-render (all targets + doctest passed, incl. scene_style_paint 29/29),
bitty-runtime lua_ui_style_height (15/15) and scene_style_vocabulary (6/6).

Guard spot-check of the two claims the verdict rests on (gh pr diff 3217):

  1. crates/bitty-terminal/src/stall_watchdog.rs — mark() now orders
    last_beat_ns (Relaxed) -> phase (Release) -> active (Release) ->
    progress (fetch_add, Release), and every monitor-side read that feeds idle_for() or
    build_report upgraded to Acquire (progress at init and in the poll,
    phase/active before idle_for(), both SIGUSR1 and the main sample). The
    happens-before chain the comment claims is present in the code.
  2. crates/bitty-render/src/scene.rs — paint_border derives
    clip = aligned ∩ allocated (cell_rect(x, y, available.cols, available.rows)) and
    intersects every emitted segment with clip (not aligned alone), so a height/width-capped
    Block frame cannot paint into a sibling cell. New guards cover both axes
    (a_capped_bordered_block_never_paints_its_border_into_a_column_sibling,
    ..._into_a_row_sibling).

CI on this head: fails=0, pending=0, pass=18, skip=3 (VM-tier legs conditional).

Note for follow-up (not blocking): the new regression test is sleep-based (650 ms idle, 250 ms
publish gap, 600 ms threshold) — the same class as the watchdog timing tests that have raced on
macOS before; it is green on all legs here, but a future 0 Hz-parking change should re-check it.

VERDICT: APPROVE

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent local CarryCtx re-review (ctx-1869-rereviewer, PX-8726) verified commit 690067224ec6f17a072626a3d8da56950f30a776:

  • Resolved all round-1 NEEDS-FIX (PX-8723) findings in crates/bitty-terminal/src/stall_watchdog.rs (elapsed_ns() / last_beat_ns stored strictly before Release stores on phase/active/progress; paired Acquire loads in monitor_loop, StallWatchdog::{enter,idle}, and build_report; added enter_after_long_idle_emits_no_spurious_report_in_publish_gap).
  • crates/bitty-render/src/scene.rs (Painter::paint_border) clips all cell-border segments to aligned ∩ allocated with regression tests in scene_style_paint.rs and lua_ui_style_height.rs.
  • All local verification suites passed (fmt, check-scratch-paths.sh, clippy -D warnings, stall_watchdog 78/78, bitty-render, lua_ui_style_height 15/15, scene_style_vocabulary 6/6) and all 18 remote GitHub Actions CI/CodeQL checks succeeded.

VERDICT: APPROVE

@Xuepoo
Xuepoo merged commit 0a7f1f1 into main Nov 17, 2026
21 checks passed
@Xuepoo
Xuepoo deleted the ctx-1869/fix-watchdog-ordering-and-border-clip branch November 17, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Area: runtime orchestration fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(runtime,render): add Release/Acquire ordering on watchdog progress and clip bordered Block segments

1 participant