Skip to content

test(orchestration): split dispatch-liveness tests out of db.test.ts - #14889

Closed
Tauri-EPO wants to merge 2 commits into
stablyai:mainfrom
Tauri-EPO:test/split-dispatch-liveness-tests
Closed

Tauri-EPO wants to merge 2 commits into
stablyai:mainfrom
Tauri-EPO:test/split-dispatch-liveness-tests

Conversation

@Tauri-EPO

@Tauri-EPO Tauri-EPO commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

db.test.ts is nearly at the 800-line lint ceiling, so there is no room to add coverage to it. This moves one coherent group of tests into their own file. Nothing else changes.

What Changed

Moved the recordHeartbeat and getStaleDispatches tests out of src/main/runtime/orchestration/db.test.ts into a new src/main/runtime/orchestration/db-dispatch-liveness.test.ts.

The dispatch-context CRUD coverage stays where it is — that is a different concern from "is this dispatched task still alive", which is what the moved tests are about.

No assertions, test names, or fixture behaviour changed. This is a file move.

Why

db.test.ts sits a handful of lines under the max-lines budget of 800. AGENTS.md forbids both adding an eslint-disable max-lines and bumping a per-file budget, so the only way to add coverage near it is to split first. Recent commits on main (refactor(daemon,runtime): split daemon, pty and rpc modules under the max-lines budget, and its sibling) do exactly this, so this follows the direction the repo is already moving.

Splitting by domain rather than by line count keeps the result meaningful: the new file is everything about detecting whether a dispatched task is still alive.

Linked Issue

Prerequisite for #14907 — it unblocks adding dispatch-liveness coverage without tripping the lint budget. Not Fixes, because this PR is only the split; it implements none of that issue.

Visual Proof

N/A — test file reorganisation, no runtime code and no user-visible behaviour.

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orchestration/db.test.ts src/main/runtime/orchestration/db-dispatch-liveness.test.ts → 61 passed, which is the same count and the same tests as before the move.
  • pnpm exec oxlint src/main/runtime/orchestration/ → clean.
  • pnpm run lint, pnpm typecheck and pnpm build → all pass locally.

Tested on Windows 11.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

No tests added or changed — every assertion is byte-identical to its previous form, including the #8452 regression comments.

AI Disclosure

Written with Claude Opus 5 via Claude Code. The decision to split and the choice of grouping were made in collaboration with the author; the mechanical move and the verification runs were agent-assisted.

Review

  • Security: none — test-only change.
  • Cross-platform: no platform-specific code touched.
  • Remote SSH / Mobile: unaffected.
  • Backwards compatibility: no production code changed.
  • Performance: unaffected.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Note on the last box: pnpm lint and pnpm typecheck pass locally. The full pnpm test suite cannot start on Windows from a clean install of this repo — see #14918. Briefly: windows-native-registry@3.2.2 installs with an empty build/, so the Windows branch of ensure-native-runtime refuses to run the suite. Not specific to this branch, and not a Node version problem (reproduced identically on Node 22 and 24).

Running vitest directly, bypassing that wrapper, the suite has pre-existing failures on this Windows machine that are unrelated to this change (missing POSIX shell, spawnSync … EINVAL, assertions expecting / and receiving \). I verified attribution by running the whole suite on the merge base and on this branch: both fail the same set, and this branch adds none.

Author

  • X / Twitter: @EnricoPin

@coderabbitai

coderabbitai Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ae1117a-df05-4d4b-a316-bdbe15c62fca

📥 Commits

Reviewing files that changed from the base of the PR and between e613a60 and af48f71.

📒 Files selected for processing (2)
  • src/main/runtime/orchestration/db-dispatch-liveness.test.ts
  • src/main/runtime/orchestration/db.test.ts
💤 Files with no reviewable changes (1)
  • src/main/runtime/orchestration/db.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/runtime/orchestration/db-dispatch-liveness.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Added a dedicated OrchestrationDb test suite for dispatch liveness. The tests cover heartbeat updates, stale-dispatch status filtering, grace windows, deterministic timestamps, mixed SQLite and ISO timestamp formats, UTC-midnight boundaries, and fresh heartbeats. Removed the corresponding tests and fixture helper from db.test.ts.

Merge Risk: ⚪ Minimal · up to af48f

This change only reorganizes existing dispatch-liveness tests without changing production behavior or assertions; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: moving dispatch-liveness tests into a separate test file.
Description check ✅ Passed The description is complete and relevant. It explains the change, reason, linked issue, testing, platform limitations, review considerations, and checklist status. The missing Agent skill upstream bou…
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: Description check

Explanation

The description is complete and relevant. It explains the change, reason, linked issue, testing, platform limitations, review considerations, and checklist status. The missing Agent skill upstream boundary section is non-critical for this test-only change.

  • Fix all pre-merge checks with AI

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

Comment @coderabbitai help to get the list of available commands.

@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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dade61aa-9bd9-41f8-82e9-d53424b88d39

📥 Commits

Reviewing files that changed from the base of the PR and between e4e54a1 and ffd2794b1063d52605e6f537df3430593573e29e.

📒 Files selected for processing (2)
  • src/main/runtime/orchestration/db-dispatch-liveness.test.ts
  • src/main/runtime/orchestration/db.test.ts
💤 Files with no reviewable changes (1)
  • src/main/runtime/orchestration/db.test.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.

@nwparker

Copy link
Copy Markdown
Contributor

Cross-linking for context, @Tauri-EPO: I landed your #15165 assertion fix on an internal branch (#15869) so it could run full CI, which means src/main/runtime/orchestration/db.test.ts is now at exactly 800 effective lines — the max-lines ceiling for **/*.test.ts. I measured it: one more code line errors.

That makes this split more useful, not less. It's still on my list. Nothing needed from you here; just flagging that db.test.ts is effectively closed to additions until this merges, and that this should rebase cleanly over #15869 (that PR touched two lines inside the straggler test you're relocating, plus a comment).

nwparker added a commit that referenced this pull request Aug 22, 2026
db.test.ts landed at exactly 800 effective lines — the max-lines ceiling
for **/*.test.ts — which closed the file to any further addition until
#14889 splits it, and forced the failDispatch sibling of this same
invariant into dispatch-failure-idempotency.test.ts where its name does
not fit.

Move both straggler cases into db-heartbeat-straggler-guard.test.ts. The
assertions and the seeded-heartbeat fixture are unchanged; db.test.ts
drops to 790 effective lines (10 of headroom) and this PR no longer has
a merge-order dependency on #14889.

Co-authored-by: Tauri-EPO <enrico.pin@gmail.com>
@Tauri-EPO
Tauri-EPO force-pushed the test/split-dispatch-liveness-tests branch from ffd2794 to 70b0f8b Compare August 22, 2026 23:49
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Tauri-EPO
Tauri-EPO force-pushed the test/split-dispatch-liveness-tests branch from 70b0f8b to 29383c8 Compare August 29, 2026 21:09
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

db.test.ts sits just under the 800-line max-lines budget, leaving no
room for new coverage. Move the recordHeartbeat and getStaleDispatches
tests into a new db-dispatch-liveness.test.ts — a coherent unit around
detecting whether a dispatched task is still alive — and leave the
dispatch-context CRUD coverage behind, which is a different concern.

No assertions or fixture behaviour changed; only file location.
@Tauri-EPO
Tauri-EPO force-pushed the test/split-dispatch-liveness-tests branch from 29383c8 to e613a60 Compare August 29, 2026 21:11
@Tauri-EPO

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (post-#15869). Two content notes from the conflict resolution:

  • The relocated tests are the current main versions (they had since moved to the createRootDispatch fixture), not the pre-split copies.
  • The weak straggler test this branch originally relocated was dropped instead of moved: its stronger replacement already lives in db-heartbeat-straggler-guard.test.ts from #15869, so relocating the old copy would have reintroduced the can't-fail variant.

db.test.ts drops to 879 physical lines; the split file, db.test.ts, and the straggler guard all pass locally (60 tests), tsc -p config/tsconfig.node.json and oxlint clean.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR moves dispatch-liveness tests from the near-limit orchestration database test file into a dedicated test module without changing production behavior.

  • Relocates recordHeartbeat and getStaleDispatches coverage into db-dispatch-liveness.test.ts.
  • Keeps the #8452 regression rationale alongside the relocated tests, resolving the previous review thread.
  • Removes the relocated helper and test cases from db.test.ts.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/main/runtime/orchestration/db-dispatch-liveness.test.ts Adds the extracted dispatch-liveness test suite with its fixture helper and regression rationale intact.
src/main/runtime/orchestration/db.test.ts Removes the relocated dispatch-liveness tests while retaining the unrelated orchestration database coverage.

Reviews (2): Last reviewed commit: "test(orchestration): move the #8452 rati..." | Re-trigger Greptile

…heir tests

Review follow-up (Greptile): the regression comments stayed behind in
db.test.ts, orphaned above an unrelated thread-message test; each block
now precedes the exact relocated test it documents.
@Tauri-EPO

Copy link
Copy Markdown
Contributor Author

Closing: the premise no longer holds. #24043 retired redundant cases and brought db.test.ts from 886 to 790 lines, under the 800-line limit, so new dispatch-liveness coverage can land there without this split.

@Tauri-EPO Tauri-EPO closed this Oct 2, 2026
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.

4 participants