Repository navigation
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
Conversation
|
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 Hive will keep the |
There was a problem hiding this comment.
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 aroundappPlatform(...)logserror instanceof Error ? error.message : String(error)and returns 400unusable deliverywith nohandledkey, so the expected sink linemessage: 'not an error object',handledundefined, and emptydispatchedare all exactly what the code produces. MockingappPlatformis the only way to reach this arm, as the body says.node.test.ts—src/server/node.ts:23-25: the defaultbackgroundisvoid work(fire-and-forget), andreceiveWebhookbuildshandled, hands it tobackground, and returns 202 synchronously (webhook.ts:70-80), so assertingdispatched === 0at response time and1after release is a correct pin of the default arm — which, I confirmed, no existing test exercises (testApp.ts:52always records intobackgrounded).main.test.ts—src/server/main.ts:3is a baremain()at module load; mocking./nodeand asserting one zero-arg call is the right shape.bundle.test.ts— mirrors the Dockerfile'sncc build src/server/main.ts; thelistening on :${port}JSON line andrejected: bad signaturelog both exist atnode.ts:54andwebhook.ts:40. Building into anos.tmpdir()dir so a leakedrequirecan't resolve against the repo'snode_modulesis a nice touch. Port-collision risk (random 18000–18999) fails loudly via theexitrejection 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
d8f3f5b to
be96c79
Compare
|
Head moved d8f3f5b → be96c79 (rebased onto main@1ce22f0 after #614, plus one commit). #614 added 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
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 samethresholdsobject as the unquotedlines/branches/functions/statementstrips ESLintstyle/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 lintexits 1, sobuild-testfails and the PR cannot merge. Fix is mechanical — quote the four existing keys in that object (oreslint --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
left a comment
There was a problem hiding this comment.
Two blockers and one policy question.
- 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).
- 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.
- 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.
|
Policy answer from the maintainer side: yes to the per-path 100 % gates for |
…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>
be96c79 to
447b98c
Compare
|
Thanks — all three addressed at 447b98c (head moved be96c79 → 447b98c; still hold-gated, needs fresh review).
Also: Whole suite at 447b98c: 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
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 atsrc/adapters/app/webhook.ts:65andsrc/adapters/app/cron.ts:85, thecatchsink in thePROW_CRON_INTERVALtimer atsrc/server/node.ts:82-84, thecronargv branch atsrc/server/main.ts:5-9,env.PORT ?? 8080atsrc/server/node.ts:69, anddeferInPlaceatsrc/adapters/app/platform.ts:26-29. __tests__/server/main.test.tsrelies on call counts clearing between tests;vitest.config.mjs:13-15setsclearMocks/mockReset/restoreMocks, so thenot.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, andbuild-test+e2e-coverageare green at this head, so the gate passes on today's main. - The quoted threshold keys in
vitest.config.mjsare the minimalstyle/quote-propsfix for the earlier redbuild-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
|
/kind cleanup |
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— loadingsrc/server/main.tscallsmain()once with no arguments.__tests__/server/node.test.ts— withbuildReceiver's defaultbackground, a signedissue_commentis answered 202 while its dispatch is still pending (node.ts:24).__tests__/adapters/app/webhookNonErrorThrow.test.ts—receiveWebhookanswers 400unusable deliveryand logs the thrown value whenappPlatformthrows a non-Error (webhook.ts:65).__tests__/server/bundle.test.ts— buildssrc/server/main.tswith ncc into a temp directory outside the repository, boots it, checks therequire()list is builtins only,/healthz, a signedpingand 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 cronrunsrunCronOnce()once and setsprocess.exitCodeto its result (main.ts:6-7).__tests__/server/cronInterval.test.ts— aPROW_CRON_INTERVALtick whose scheduled run rejects (realGET /app/installations→ 500 through octokit) is logged as{ level: 'error', event: 'schedule' }with norepo,/healthzkeeps answering and the next tick still polls (node.ts:82); withPROW_CRON_INTERVALunset, a day of fake time schedules nothing.__tests__/server/cronIntervalNonErrorRejection.test.ts— theString(error)arm of the same catch, withrunScheduledJobsmocked to reject with a plain object (octokit only ever throwsErrors, same approach aswebhookNonErrorThrow.test.ts).__tests__/server/portDefault.test.ts—env.PORT ?? 8080observed through a mocked@hono/node-serverserve, 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 inreport.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):
__tests__/adapters/app/platform.test.ts— one more case:appPlatform's defaultDeferStrategy(deferInPlace,platform.ts:26-29, added by feat(app): run on Cloudflare Workers; Platform.defer() for the grace period #615 with zero unit hits) waits the whole delay under fake timers and then answers'continue'. Without it the newsrc/adapters/app/**gate fails on main at 98.58 % lines.vitest.config.mjs— the four pre-existing threshold keys quoted sostyle/quote-propsagrees with the glob keys (the redbuild-test).__tests__/server/cronInterval.test.ts—stdoutLinestakes the structural mock shape instead ofReturnType<typeof vi.spyOn>, whichtsc -p tsconfig.test.json(test(typecheck): type-check __tests__/ with tsc -p tsconfig.test.json and fix the 29 errors it finds #599) rejects as an implicitany.src/server/worker.ts/worker-env.d.tsstay out of unit coverage as feat(app): run on Cloudflare Workers; Platform.defer() for the grace period #615 set them: the per-path threshold is evaluated over the filescoverage.excludeleaves in, so'src/server/**'passes at 100 % with the Worker excluded (verified by the whole-suite run below).Why.
vitest.e2e-coverage.config.mjs:45-47excludessrc/adapters/app/**andsrc/server/**from the bundle run because "unit coverage holds them to 100%". Nothing enforced that premise — the global floor is 99 and the rest ofsrc/absorbs whole uncovered arms in the App adapter — and #614 was the first time it bit:cron.ts:85, both arms ofnode.ts:82andmain.ts:6-7landed 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 thethresholdsblock ofvitest.config.mjs(#605 edits that file'ssetupFilesline, 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 (receiveWebhookrefusal 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/appandsrc/serverabsent from the uncovered tablenpx 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— cleandeferInPlacereturning'deferred', orawait sleep(delayMs)→void delayMs, both fail the newplatform.test.tscase; replacing thenode.ts:82sink call withvoid errorfails both interval tests;?? 8080→?? 3000failsportDefault.test.ts; removing thecronbranch frommain.tsfails the newmain.test.tscase;String(error)→""incron.ts:85fails the newcron.test.tscaseRelated 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.