Skip to content

test(hosts): wait for the daemon's channel overflow instead of a fixed sleep - #367

Merged
andrebrait merged 3 commits into
ompweb-dev:mainfrom
andrebrait:fix/daemon-resync-flake
Nov 2, 2026
Merged

andrebrait merged 3 commits into
ompweb-dev:mainfrom
andrebrait:fix/daemon-resync-flake

Conversation

@andrebrait

@andrebrait andrebrait commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The Windows CI run on #361 failed once in lib/hosts/daemon.test.mjs: "output beyond the channel buffer while the uplink is down is dropped, then resync" timed out waiting for the resync. The overflow tests paused the uplink, then slept a fixed 1.5 s on the assumption that the daemon had read past the channel buffer by then. A slow runner had not, so no overflow and no resync followed.

  • lib/hosts/daemon.ts: the daemon logs one line when it drops a channel's backlog: channel <ch>: dropped N bytes of output the server has not taken; resync. Each drop is a separate overflow of the 32 MiB channel buffer, so a flood logs at most a few lines. Only the channel id and a byte count are logged.
  • lib/hosts/daemon.test.mjs: the overflow tests wait for that line, summing the dropped bytes against a threshold derived from the fixture's output size, instead of sleeping. The bytesAhead test also waits for the last flood line instead of a fixed 300 ms settle. The one test that expects no overflow keeps its sleep: nothing observable marks "the daemon has read everything" there, and a short stall there can only weaken its no-resync assertion, not fail it.

Verification

  • bun test --timeout 30000 lib/hosts/daemon.test.mjs: 47/47, five runs in a row.
  • Under CPU contention (taskset -c 0 with four busy loops on that core): the old fixed sleeps failed 2 of 5 overflow tests, reproducing the CI failure; this version passes all six touched tests.

Summary by CodeRabbit

  • Tests
    • Improved the reliability of channel-overflow tests by waiting for logged dropped-byte totals and expected output instead of relying on fixed delays.
    • Added shared test data for flood and echo scenarios. These changes affect automated test timing and do not change runtime behavior.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews 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: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6313c320-55e8-42b8-bcbe-eda72bd2b503
Commits

Reviewing files that changed from the base of the PR and between daa6739 and d7b02ca.

Files selected for processing: 3
  • graphify-out/graph.json
  • lib/hosts/daemon.test.mjs
  • lib/hosts/daemon.ts
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2bfd6161-2537-488e-af40-004f492a24bc
Commits

Reviewing files that changed from the base of the PR and between 5bfc86b and daa6739.

Files selected for processing: 3
  • graphify-out/graph.json
  • lib/hosts/daemon.test.mjs
  • lib/hosts/daemon.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

Recent review details
Context from checks skipped due to timeout: 4
  • GitHub Check: CodeRabbit
  • GitHub Check: Verify (ubuntu-latest)
  • GitHub Check: Verify (windows-latest)
  • GitHub Check: Kilo Code Review
Additional context used
Code guidelines: 4
docs/specs/2026-10-29-local-daemon-design.md — auto-discovered
docs/specs/2026-10-31-websocket-link-design.md — auto-discovered
docs/specs/2026-10-28-remote-hosts-design.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 3
Applicability reference: AGENTS.md: # omp-web - Development Notes Source excerpt: **The local daemon is required.**

CodeRabbit inference engine (docs/specs/2026-10-29-local-daemon-design.md)

Files:

  • lib/hosts/daemon.ts
  • lib/hosts/daemon.test.mjs
Applicability reference: AGENTS.md: # omp-web - Development Notes **Link = one WebSocket per host, dialled by the daemon** (`/api/hosts/link`; design `docs/specs/2026-10-31-websocket-link-design.md`).

CodeRabbit inference engine (docs/specs/2026-10-31-websocket-link-design.md)

Files:

  • lib/hosts/daemon.ts
  • lib/hosts/daemon.test.mjs
Source excerpt: **Daemon-loaded modules must not import `@/` or use Bun APIs.**

CodeRabbit inference engine (AGENTS.md)

Files:

  • lib/hosts/daemon.ts
Walkthrough

Selected daemon overflow tests replace fixed sleeps with waits based on logged dropped-byte totals or observed output. The fake omp fixture uses shared flood and echo sizes. The daemon comment notes that the test parses the overflow log.

Changes: Daemon overflow test synchronization

Layer / File(s) Summary
Define dropped-output measurements
lib/hosts/daemon.test.mjs, lib/hosts/daemon.ts
The fake omp output uses shared flood and echo sizes. A helper waits for logged dropped-byte totals to reach a target. A comment notes that the test parses the overflow log.
Use drop-aware waits
lib/hosts/daemon.test.mjs
Selected overflow tests wait for logged drop thresholds or the final flood line instead of fixed sleeps. The stalled-echo helper uses the logged drops when given a log; otherwise, it retains the timed wait.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: Low · previous review daa67

The synchronization changes have one bounded diagnostic issue: stalled overflow tests reach the test runner's timeout before reporting the helper's specific failure message. Aligning the deadlines is a small follow-up; no production behavior regression is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: replacing fixed sleeps with log-based waiting for daemon channel overflow in host tests.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • 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

I’m a rabbit by the test log,
Counting bytes as they fall.
No fixed nap to mark the overflow,
I wait for the measured call.
The last flood line arrives,
And I hop back to my burrow.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread lib/hosts/daemon.test.mjs Resolved
@kilo-code-bot

kilo-code-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Code Review Roast 🔥

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything, but the diff since the last review is just the author applying the CodeRabbit suggestion verbatim — 60_000 → 25_000 in two wait sites, plus a comment explaining why. Nothing left to roast.

📊 Overall: Like showing up to a surprise party and finding it already cleaned up — awkward, but I guess the work did itself.

Files Reviewed (3 files)
  • lib/hosts/daemon.test.mjs — 2 timeout caps aligned to the 30 s suite budget; the added comment even names the rationale.
  • lib/hosts/daemon.ts — one log line added so the test can wait on it; comment cross-references the parser.
  • graphify-out/graph.json — regenerated binary, no reviewable content.
Previous Review Summaries (2 snapshots, latest commit c1321b2)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit c1321b2)

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything, but the only diff since the last review is the author applying the CodeRabbit suggestion verbatim — 60_000 → 25_000 in two wait sites, plus a comment explaining why. Nothing left to roast.

📊 Overall: Like showing up to a surprise party and finding it already cleaned up — awkward, but I guess the work did itself.

Files Reviewed (1 file)
  • lib/hosts/daemon.test.mjs — 2 timeout caps aligned to the 30 s suite budget; the added comment even names the rationale.

Previous review (commit daa6739)

Verdict: No New Issues Found | Recommendation: Merge

Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are.

Files Reviewed (2 files)
  • lib/hosts/daemon.test.mjs
  • lib/hosts/daemon.ts

Reviewed by free · Input: 357.1K · Output: 15.2K · Cached: 556K

…d of a fixed sleep

The daemon now logs each time it drops a channel's backlog on overflow. The overflow tests waited a fixed 1.5 s for the daemon to read a flood past the channel buffer; a slow runner missed that window, the uplink resumed before the overflow, and no resync followed.
@andrebrait
andrebrait force-pushed the fix/daemon-resync-flake branch from c1321b2 to d7b02ca Compare November 2, 2026 09:17
@andrebrait
andrebrait merged commit f5c724e into ompweb-dev:main Nov 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant