Skip to content

🌱 test(diagnostics): pin period, uptime and clearInterval to a mocked clock - #424

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-diagnostics-timing
Oct 31, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-diagnostics-timing

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Why

The advisory nightly Stryker report (run 41171362594 on f2b3df9) lists 7 surviving mutants in src/diagnostics.ts. Four of them are real assertion gaps, not equivalent mutants:

  • L32 seconds / 1000 — a user-supplied --diagnostics 2 could schedule the report every ~1 ms and the suite would not notice.
  • L39 (Date.now() - startedAt) * 1000 and Date.now() + startedAt — uptime_s could be wildly wrong; the suite only checked typeof uptime_s === 'number'.
  • L53 dropped clearInterval(timer) — stop() could leave the interval running and the suite would still pass, because every existing test resets the mock timers before calling stop().

The remaining three (L31 flag === 'true' ? NaN vs Number('true'), and timer.unref()) are equivalent or unobservable from a unit test and are left alone.

What

One new test in src/diagnostics.test.ts that drives setInterval and Date through node:test mock timers from a non-zero epoch and asserts the exact 2000 ms tick boundary, the exact uptime_s values (2, 4, 4), and that nothing fires after stop(). Verified each of the four mutants above now fails the suite when applied by hand to dist/diagnostics.js.

npm run lint, npm run test:coverage (438 pass; 99.76 / 97.12 / 100) green locally.


Filed by quality agent (ACMM L4/L6 — full mode)

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

…ed clock

The nightly Stryker report (run 41171362594 on f2b3df9) shows the
interval maths and the stop() clearInterval in startDiagnostics surviving
mutation: seconds/1000, uptime*1000, Date.now()+startedAt and a dropped
clearInterval all pass the suite, because the existing tests only check
that some periodic line arrives and that uptime_s is a number.

Drive the interval and Date through node:test mock timers from a non-zero
epoch and assert the exact tick boundary, the exact uptime_s values and
that nothing fires after stop().

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 31, 2026
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 31, 2026
@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 31, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 64f83e5 into main Oct 31, 2026
16 of 17 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the quality/test-diagnostics-timing branch October 31, 2026 08:44
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#424cedaea9` sha256:68a0ff1e8dbc9c59d6ce2fbbc55592e93dd0b2a9d96f6c42461fb2a1e2789971 — download from the dashboard or `hivectl review evidence #424`.

@github-actions

Copy link
Copy Markdown

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants