Skip to content

test(server,app): execute src/server's entry point and bundle, pin #614's cron arms, and gate src/adapters/app/** + src/server/** at 100% (main.ts, node.ts:24/67/82, webhook.ts:65, cron.ts:85, vitest.config.mjs) - #611

Merged
jeefy merged 3 commits into
mainfrom
quality/test-server-entry-and-bundle
Oct 29, 2026

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Test Improvement

Seven test files and one test-config change; nothing under src/, dist/ or docs touched.

From the original PR (main@282b8e0):

  • __tests__/server/main.test.ts — loading src/server/main.ts calls main() once with no arguments.
  • __tests__/server/node.test.ts — with buildReceiver's default background, a signed issue_comment is answered 202 while its dispatch is still pending (node.ts:24).
  • __tests__/adapters/app/webhookNonErrorThrow.test.ts — receiveWebhook answers 400 unusable delivery and logs the thrown value when appPlatform throws a non-Error (webhook.ts:65).
  • __tests__/server/bundle.test.ts — builds src/server/main.ts with ncc into a temp directory outside the repository, boots it, checks the require() list is builtins only, /healthz, a signed ping and an unsigned one.

Added after #614 landed (branch rebased onto main@1ce22f0), for the finding folded into #610:

  • __tests__/server/main.test.ts — also: node dist-server/index.js cron runs runCronOnce() once and sets process.exitCode to its result (main.ts:6-7).
  • __tests__/server/cronInterval.test.ts — a PROW_CRON_INTERVAL tick whose scheduled run rejects (real GET /app/installations → 500 through octokit) is logged as { level: 'error', event: 'schedule' } with no repo, /healthz keeps answering and the next tick still polls (node.ts:82); with PROW_CRON_INTERVAL unset, a day of fake time schedules nothing.
  • __tests__/server/cronIntervalNonErrorRejection.test.ts — the String(error) arm of the same catch, with runScheduledJobs mocked to reject with a plain object (octokit only ever throws Errors, same approach as webhookNonErrorThrow.test.ts).
  • __tests__/server/portDefault.test.ts — env.PORT ?? 8080 observed through a mocked @hono/node-server serve, so nothing binds :8080 on the runner (the arm the first revision left unpinned).
  • __tests__/adapters/app/cron.test.ts — one more case: a scheduled handler that throws a non-Error is reported as [object Object] and counted in report.failed (cron.ts:85).
  • vitest.config.mjs — per-path thresholds 'src/adapters/app/**' and 'src/server/**' at 100 % lines/branches/functions/statements, next to the global 99 floor.

Added after review (rebased onto main@9643326, after #615/#616/#618):

Why. vitest.e2e-coverage.config.mjs:45-47 excludes src/adapters/app/** and src/server/** from the bundle run because "unit coverage holds them to 100%". Nothing enforced that premise — the global floor is 99 and the rest of src/ absorbs whole uncovered arms in the App adapter — and #614 was the first time it bit: cron.ts:85, both arms of node.ts:82 and main.ts:6-7 landed with zero hits. The thresholds make the exclusion's premise a check on every run; the tests are what lets the check pass today.

Files / cluster claimed — src/server/**, src/adapters/app/webhook.ts:65, src/adapters/app/cron.ts, and the thresholds block of vitest.config.mjs (#605 edits that file's setupFiles line, a separate hunk). Disjoint from every other held PR: #591/#593/#597 (plugins, dispatcher, labels), #595 (setup.ts, config), #596 (bundle scenario for sweep), #598 (testUtils.ts), #599 (tsconfig.test.json), #601 (coverageIgnoreHints.test.ts), #603 (runtime.test.ts), #609 (src/platform/index.ts), #612 (receiveWebhook refusal texts), #613 (decodeContent).

Testing

At 447b98c (rebased onto main@9643326):

  • npm run test:coverage (whole suite, with the per-path thresholds) — 222 files, 2646 passed; 100 / 99.77 / 100 / 100, exit 0, no threshold error; src/adapters/app and src/server absent from the uncovered table
  • npx vitest run --coverage --coverage.include='src/server/**' --coverage.include='src/adapters/app/**' __tests__/server __tests__/adapters/app — 12 files, 66 passed, "8 files fully covered"
  • npm run typecheck — clean; npx eslint vitest.config.mjs __tests__/adapters/app/platform.test.ts __tests__/server/cronInterval.test.ts — clean
  • each new test fails without its arm: deferInPlace returning 'deferred', or await sleep(delayMs) → void delayMs, both fail the new platform.test.ts case; replacing the node.ts:82 sink call with void error fails both interval tests; ?? 8080 → ?? 3000 fails portDefault.test.ts; removing the cron branch from main.ts fails the new main.test.ts case; String(error) → "" in cron.ts:85 fails the new cron.test.ts case

Related Issue

Closes #610 — every box of the original finding and of the one folded onto it (cron.ts:85, node.ts:67/82, main.ts cron arm, per-path thresholds) is in this PR.


Filed by quality agent (hold-gated mode). Human review required.

@hivecommons-hive
hivecommons-hive Bot requested a review from jpmcb as a code owner October 29, 2026 04:28
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@hivecommons-hive hivecommons-hive Bot 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.

Read the diff against the tree at d8f3f5b (sources: src/server/main.ts, src/server/node.ts, src/adapters/app/webhook.ts, helpers in __tests__/adapters/app/testApp.ts). The four tests pin real, currently-untested behavior, and each assertion matches what the source actually does:

  • webhookNonErrorThrow.test.ts — src/adapters/app/webhook.ts:60-67: the catch around appPlatform(...) logs error instanceof Error ? error.message : String(error) and returns 400 unusable delivery with no handled key, so the expected sink line message: 'not an error object', handled undefined, and empty dispatched are all exactly what the code produces. Mocking appPlatform is the only way to reach this arm, as the body says.
  • node.test.ts — src/server/node.ts:23-25: the default background is void work (fire-and-forget), and receiveWebhook builds handled, hands it to background, and returns 202 synchronously (webhook.ts:70-80), so asserting dispatched === 0 at response time and 1 after release is a correct pin of the default arm — which, I confirmed, no existing test exercises (testApp.ts:52 always records into backgrounded).
  • main.test.ts — src/server/main.ts:3 is a bare main() at module load; mocking ./node and asserting one zero-arg call is the right shape.
  • bundle.test.ts — mirrors the Dockerfile's ncc build src/server/main.ts; the listening on :${port} JSON line and rejected: bad signature log both exist at node.ts:54 and webhook.ts:40. Building into an os.tmpdir() dir so a leaked require can't resolve against the repo's node_modules is a nice touch. Port-collision risk (random 18000–18999) fails loudly via the exit rejection rather than hanging, which is acceptable.

The body's claims match the diff, the file set is disjoint from the held PRs it lists, and CI (build-test, e2e-coverage, DCO) is green. Looks correct to me — a maintainer can take this at face value.

One non-blocking suggestion: vitest.mutation.config.mjs:41 excludes only __tests__/bundle/**, so Stryker runs will now execute __tests__/server/bundle.test.ts, paying the ~15 s ncc build per sandbox (and the dry run). Worth adding __tests__/server/bundle.test.ts to that exclude in a follow-up; not a defect in this PR.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot force-pushed the quality/test-server-entry-and-bundle branch from d8f3f5b to be96c79 Compare October 29, 2026 15:10
@hivecommons-hive hivecommons-hive Bot changed the title test(server): execute src/server's entry point, default background arm and the dist-server bundle (src/server/main.ts:3, node.ts:24, webhook.ts:65) test(server,app): execute src/server's entry point and bundle, pin #614's cron arms, and gate src/adapters/app/** + src/server/** at 100% (main.ts, node.ts:24/67/82, webhook.ts:65, cron.ts:85, vitest.config.mjs) Oct 29, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Head moved d8f3f5b → be96c79 (rebased onto main@1ce22f0 after #614, plus one commit). #614 added src/adapters/app/cron.ts and the PROW_CRON_INTERVAL / cron argv arms in src/server/, and landed with cron.ts:85, both arms of node.ts:82 and main.ts:6-7 at zero unit hits; that finding was folded onto #610 (the issue this PR closes), so the drivers and the per-path 100 % thresholds for src/adapters/app/** and src/server/** are in this PR rather than a second one. Title and body updated to name the full file set. Still hold-gated; needs fresh human review.


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: be96c79

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

@hivecommons-hive hivecommons-hive Bot 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.

Read the diff against merge-base and the cited sources at origin/main (src/server/main.ts:5-9, src/server/node.ts:67 and :78-86, src/adapters/app/cron.ts:85). The nine test files are correctly grounded: the diff touches only __tests__/ plus the thresholds hunk of vitest.config.mjs, exactly as the body claims, and the bundle test builds into a tmpdir outside the repo as described.

One blocking defect — the required build-test check is red because of this PR's own hunk:

  • vitest.config.mjs:23-26 — adding the quoted glob keys 'src/adapters/app/**' / 'src/server/**' into the same thresholds object as the unquoted lines/branches/functions/statements trips ESLint style/quote-props ("Inconsistently quoted property … found", 4 errors, run 40898950182). Mechanism: the rule enforces consistent quoting within one object literal, and the glob keys must be quoted. Consequence: npm run lint exits 1, so build-test fails and the PR cannot merge. Fix is mechanical — quote the four existing keys in that object (or eslint --fix); the local Testing section ran eslint only on __tests__/, which is why it was missed.

Everything else looks correct to me: per-path thresholds are the right vitest mechanism to enforce the premise vitest.e2e-coverage.config.mjs states for excluding these trees, and the body's claims match the code at every line I checked.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@jeefy jeefy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two blockers and one policy question.

  1. build-test is red: eslint style/quote-props on the four threshold keys in vitest.config.mjs (quote all or none, matching the surrounding object).
  2. The branch predates #615, which added src/server/worker.ts and excluded it from unit coverage (it only executes inside workerd via tests/worker). A 100% gate on 'src/server/**' will fail the moment this is rebased unless coverage.exclude is honoured for the per-path threshold — please rebase onto main and verify locally with npm run test:coverage.
  3. Per-path 100% thresholds for the App adapter and server are a project policy choice (they make every future change to those directories fail CI on a single uncovered arm). Leaving that call to a maintainer — see the summary comment I am posting on #610.

@jeefy

jeefy commented Oct 29, 2026

Copy link
Copy Markdown
Member

Policy answer from the maintainer side: yes to the per-path 100 % gates for src/adapters/app/** and src/server/**, with src/server/worker.ts (and worker-env.d.ts) staying excluded from unit coverage as #615 set it — the Worker only executes inside workerd and is covered by __tests__/worker. So: rebase onto main (#616 just fixed build-test there), fix the quote-props lint, and make sure the per-path threshold respects coverage.exclude; then this can land.

hivecommons-hive Bot and others added 3 commits October 29, 2026 14:46
…d the dist-server bundle

Unit coverage at 282b8e0 reports src/server/main.ts at 0% lines and
src/server/node.ts missing the default background arm (line 24), while
vitest.e2e-coverage.config.mjs excludes src/server/** on the grounds that
unit coverage holds it to 100%. Nothing executes the server as the
Dockerfile ships it either: dist-server/ is built by npm run pack but no
test reads or runs it.

- __tests__/server/main.test.ts mirrors __tests__/main.test.ts: loading
  the entry point calls main() once with no arguments.
- __tests__/server/node.test.ts pins buildReceiver's default background:
  a signed delivery is answered 202 while its dispatch is still pending.
- __tests__/adapters/app/webhookNonErrorThrow.test.ts pins the arm of
  receiveWebhook that reports a thrown non-Error (webhook.ts:65).
- __tests__/server/bundle.test.ts builds src/server/main.ts with ncc into
  a directory outside the repository, boots it there with no node_modules
  in reach, and checks the require() list, the json listening line,
  /healthz, a signed ping and an unsigned rejection.

The env.PORT ?? 8080 default (node.ts:47) stays unpinned: it can only be
reached by binding 8080.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
…nd src/server/** at 100% unit coverage

vitest.e2e-coverage.config.mjs leaves the App adapter and its server out of
the bundle run because the unit suite holds them at 100%, but nothing
enforced that: the global floor is 99, and #614 landed with the String(error)
arm of the scheduler's per-repository log (cron.ts:85), both arms of the
PROW_CRON_INTERVAL tick's catch (node.ts:82) and the cron argv arm of the
entry point (main.ts:6-7) never executed. Each gets a driver, the PORT
default is observed through a mocked serve() so nothing binds :8080, and
vitest.config.mjs now holds the two excluded trees at 100% so the premise
of the exclusion is checked on every run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
…Place, spy typing

The four pre-existing threshold keys are quoted so style/quote-props is
consistent with the two glob keys beside them. #615 added deferInPlace as
appPlatform's default DeferStrategy and left it at zero unit hits, which the
new 'src/adapters/app/**' gate turns into a failure, so platform.test.ts now
drives it under fake timers: nothing resolves before the full delay, then
'continue'. tsconfig.test.json (#599) rejects ReturnType<typeof vi.spyOn> as
an implicit any for the destructured chunk; the helper takes the structural
mock shape instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive
hivecommons-hive Bot force-pushed the quality/test-server-entry-and-bundle branch from be96c79 to 447b98c Compare October 29, 2026 19:18
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Thanks — all three addressed at 447b98c (head moved be96c79 → 447b98c; still hold-gated, needs fresh review).

  1. build-test / quote-props — the four pre-existing threshold keys are now quoted to match the glob keys. npx eslint vitest.config.mjs is clean.
  2. feat(app): run on Cloudflare Workers; Platform.defer() for the grace period #615 / worker.ts — rebased onto main@9643326 (clean, no conflicts). The per-path threshold is evaluated over what coverage.exclude leaves in, so 'src/server/**' passes at 100 % with worker.ts / worker-env.d.ts excluded exactly as feat(app): run on Cloudflare Workers; Platform.defer() for the grace period #615 set them — nothing in the exclude line changed. What the rebase did surface is deferInPlace (platform.ts:26-29, also from feat(app): run on Cloudflare Workers; Platform.defer() for the grace period #615) at zero unit hits, which the src/adapters/app/** gate turned into 98.58 % lines; platform.test.ts now drives it under fake timers (no resolution before the full delay, then 'continue'). Both mutants — returning 'deferred', dropping the sleep — fail that case.
  3. Policy — taking your answer on [quality] src/server (GitHub App server) is never executed: entry point at 0 % lines, default background arm unpinned, dist-server bundle never built-and-run by any test #610 as the decision: gates kept at 100 % for both directories, Worker excluded.

Also: npm run typecheck (#599, now in build-test) rejected one ReturnType<typeof vi.spyOn> in cronInterval.test.ts as an implicit any; replaced with the structural mock shape.

Whole suite at 447b98c: npm run test:coverage → 222 files, 2646 passed, 100 / 99.77 / 100 / 100, exit 0, no threshold error. PR body updated with the new file set.


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 447b98c

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

@hivecommons-hive hivecommons-hive Bot 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.

Read the tree at 447b98c, not just the diff. This looks correct to me.

Verified against the sources, not the PR body:

  • Every arm the new tests claim to pin exists and is otherwise unhit by name: the String(error) fallbacks at src/adapters/app/webhook.ts:65 and src/adapters/app/cron.ts:85, the catch sink in the PROW_CRON_INTERVAL timer at src/server/node.ts:82-84, the cron argv branch at src/server/main.ts:5-9, env.PORT ?? 8080 at src/server/node.ts:69, and deferInPlace at src/adapters/app/platform.ts:26-29.
  • __tests__/server/main.test.ts relies on call counts clearing between tests; vitest.config.mjs:13-15 sets clearMocks/mockReset/restoreMocks, so the not.toHaveBeenCalled() assertions are sound.
  • The per-path thresholds make vitest.e2e-coverage.config.mjs's "unit coverage holds them to 100%" exclusion an enforced premise rather than a comment — that is the actual point of the PR, and build-test + e2e-coverage are green at this head, so the gate passes on today's main.
  • The quoted threshold keys in vitest.config.mjs are the minimal style/quote-props fix for the earlier red build-test; no behavior change.

One low-severity note, not a blocker: __tests__/server/bundle.test.ts:44 picks a port in 18000–18999, the same range __tests__/adapters/app/e2e.test.ts:75 already uses. Vitest runs test files in parallel, so there is a ~0.1% chance per run the two collide and one fails to bind. A disjoint range (as cronInterval/cronIntervalNonErrorRejection chose with 20000/21000) would eliminate it.

This PR is hold-gated and carries an earlier CHANGES_REQUESTED review; the head commit ("address review…") responds to it and checks are green. A maintainer needs to dismiss or refresh that review — I cannot approve. From my read, the change does what it says and is confined to tests plus the thresholds block.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@jeefy jeefy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All three points addressed at 447b98c; the per-path gate correctly respects coverage.exclude (worker.ts stays out), and catching deferInPlace at zero hits is exactly what the gate is for. Policy per #610: adopted.

@jeefy

jeefy commented Oct 29, 2026

Copy link
Copy Markdown
Member

/kind cleanup

@jeefy jeefy removed the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2026
@jeefy
jeefy merged commit cb70165 into main Oct 29, 2026
15 checks passed
@jeefy
jeefy deleted the quality/test-server-entry-and-bundle branch October 29, 2026 21:23
@github-actions github-actions Bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind labels Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

1 participant