Skip to content

[quality] worker.ts scheduled(), queue consumer and deferViaQueue run under no test (unit excludes the file; miniflare suite only drives fetch()) #629

Closed

Description

@hivecommons-hive

Finding

src/server/worker.ts — the Cloudflare Worker entry added in #615 — is left out of the unit coverage run (vitest.config.mjs:21) on the stated premise that "its behaviour is tested there" (__tests__/worker, via miniflare), and the bundle run (vitest.e2e-coverage.config.mjs) excludes src/server/** too. So the src/server/** 100 % per-path gate never looks at this file, and the miniflare suite is the only thing standing behind it.

That suite (__tests__/worker/worker.test.ts) has four cases: /healthz, a bad signature, /close through the pull request lock Durable Object, and redelivery dedupe — all through fetch(). Nothing drives:

  • scheduled() (worker.ts:122-132): the cron trigger that lists installations and enqueues one schedule message per live installation;
  • queue() (worker.ts:134-166): the consumer for both message kinds — schedule (filter to one installation, runScheduledJobs) and deferred (handleDelivery → resumeDeferred) — and its ack() / retry() arms;
  • deferViaQueue (worker.ts:72-80): what platform().defer() does on Workers, i.e. the grace-period path of require-matching-label ending in resumeRequiredLabels (src/plugins/requireMatchingLabel.ts:126).

Evidence (main@ed3bb42, run 40978258545): artifact coverage-ed3bb42… (unit lcov.info) has no SF: record for src/server/worker.ts; artifact coverage-e2e-ed3bb42… has none for any src/server/** file. grep -n "scheduled\|queue\|defer" __tests__/worker/worker.test.ts matches only the Miniflare binding declarations. Priority 1 under the lane's rules: covered by neither suite, and the exclusion comment promises coverage the suite did not provide.

Recommendation

Extend __tests__/worker/worker.test.ts — the fake GitHub, the Miniflare options and three cases — so the Worker is tested as deployed:

  • scheduled() via Miniflare's unsafeTriggerHandlers + GET /cdn-cgi/handler/scheduled: one message per live installation (suspended skipped, two repositories → one message), consumer runs the cron jobs for each unarchived repository under the installation token
  • queue() retry arm via mf.getQueueProducer('PROW_QUEUE'): a schedule message whose run throws (installations listing 500s) is re-delivered, not acknowledged
  • deferViaQueue → delayed deferred message → resumeDeferred: a pull_request opened with grace_period_duration: 1s stops at defer() and the resumed run applies the missing label

The fake GitHub's request log must stop being a single read-modify-write KV key: the org- and repo-tier config probes run concurrently and one of them is lost, which hides exactly the request the deferred case needs to see.

Priority

  • Impact: high — the queue consumer and cron trigger are the App's only non-webhook entry points and are exercised by nothing
  • Effort: low — one test file, no src/ change

Filed by quality agent (hold-gated mode)


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

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

Activity

  1. added
    testingCreated by Hive for agent-filed issue provenance
    agent/qualityCreated by Hive for agent-filed issue provenance
    on Oct 30, 2026
  2. github-actions commented on Oct 30, 2026

    @github-actions
    Contributor

    Please add a kind label with /kind feature, /kind failing-test or /kind cleanup.

  3. hivecommons-hive commented on Oct 30, 2026

    @hivecommons-hive
    ContributorAuthor

    Folded finding. This was filed as a separate issue, but 1 open agent-filed issue (plus 3 closed as completed in the last 14 days) already cite vitest.e2e-coverage.config.mjs, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] wrangler.toml can drift from the bindings src/server/worker.ts reads and nothing goes red: dry-run accepts it, worker.test.ts hard-codes its own bindings

    Finding

    wrangler.toml is the Worker's deployed configuration, but no test reads it, and the two things that do touch it both stay green when it drifts from the code. Verified at main@ed3bb42 (wrangler 4.155.0):

    drift in wrangler.toml wrangler deploy --dry-run npx vitest run __tests__/worker in production
    [[kv_namespaces]] binding = "DELIVERIES" → "WEBHOOK_DELIVERIES" exit 0 (lists env.WEBHOOK_DELIVERIES) 4/4 pass env.DELIVERIES is undefined; kvDeliveryStore(env.DELIVERIES).seen() throws on every webhook (worker.ts:99)
    [[migrations]] block removed exit 0, warning only 4/4 pass deploy of a Durable Object with no migration is refused by the API
    compatibility_date → 2024-01-01 exit 0 4/4 pass the bundle runs under a different runtime than the suite tested
    class_name → PullRequestLocks exit 1 (caught) fails via globalSetup —

    The miniflare worker in __tests__/worker/worker.test.ts:49-62 spells out compatibilityDate, kvNamespaces: ['DELIVERIES'], queueProducers, queueConsumers and durableObjects by hand, so it tests the bindings the test author remembered, not the ones the file declares. globalSetup.ts only runs the dry-run, whose binding validation stops at the Durable Object export check.

    The same names are also hand-written in docs/github-app.md:191-198 (wrangler kv namespace create DELIVERIES, wrangler queues create prow-jobs, three wrangler secret put lines) with nothing holding them to the file or to settingsFromEnv's required(env, …) names — the pattern __tests__/workflows.test.ts and __tests__/configurationDocs.test.ts already apply to action.yml and docs/configuration.md.

    Coverage evidence: this is not a line-coverage gap (src/server/worker.ts is excluded from both lcov runs by vitest.config.mjs:21 and vitest.e2e-coverage.config.mjs; its behaviour is tested only in __tests__/worker), so it is filed as test-infrastructure: a configuration contract with no test.

    Recommendation

    One new file, __tests__/worker/wranglerConfig.test.ts, that reads the committed file through wrangler itself (unstable_getMiniflareWorkerOptions + unstable_readConfig, both already a devDependency):

    • statically: declared KV/Queue/Durable Object bindings equal the env.X reads in src/server/worker.ts; [vars] and the commented # NAME = examples name only variables settingsFromEnv reads; the consumer's queue equals the producer's; every bound Durable Object class appears in a migration; a cron trigger backs the exported scheduled(); main is the file the suite bundles; the kv namespace create / queues create / secret put lines in docs/github-app.md name the same binding, queue and required secrets
    • behaviourally: start miniflare from exactly the options wrangler derives from the file (secrets added) and dedupe a redelivered issue_comment through the KV namespace the file binds, so a renamed binding fails the way it would in production

    worker.test.ts is left alone (held #630 extends it); this is a separate file.

    Priority

    • Impact: medium — a binding rename is a total Worker outage that CI cannot see today
    • Effort: low — one test file, no src/ change

    Filed by quality agent (hold-gated mode)


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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/qualityCreated by Hive for agent-filed issue provenanceneeds-kindtestingCreated by Hive for agent-filed issue provenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions