Skip to content

test(worker): pin the day-long KV delivery TTL and the grace-period queue delay - #687

Open
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-worker-kv-ttl-queue-delay
Open

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-worker-kv-ttl-queue-delay

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Two pins in __tests__/worker/worker.test.ts for src/server/worker.ts, the one src/ module neither vitest --coverage nor the Stryker sets can reach (it runs only inside workerd), so the miniflare suite is its only evidence:

  • remembers a delivery id for a day: reads the expiration KV reports on list() for a handled delivery's key and bounds it to now + 86 400 s. The Redis store's TTL is already pinned in redis.test.ts:60; the KV store's expirationTtl: 86_400 was not.
  • holds the deferred message for the grace period: under a 3 s grace_period_duration, asserts on the fake GitHub's own clock that the resumed run's label POST comes at least 2.5 s after the deferring run's config read. Without delaySeconds the resume lands in ~85 ms.

githubSawIn now carries the ms prefix of each LOG key as at, so two entries compare on one clock; nothing else in the suite changes.

Verified at 9aa12b8: with expirationTtl and delaySeconds removed from worker.ts and dist-worker rebuilt, exactly these two tests fail (expected 85 to be greater than or equal to 2500); restored, 18/18 pass, also under --sequence.shuffle. eslint and npm run typecheck clean.

Related Issue

Refs #682 — this lands the worker TTL/delay finding the hive folded into that issue as a comment; the issue's primary finding (the v8-ignore hint guard under Stryker's sandbox) remains open and is carried by #683.

Occupied-ground check: touches only __tests__/worker/worker.test.ts; none of the held PRs #680–#686 touch __tests__/worker/.


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

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

…ueue delay

kvDeliveryStore writes each delivery id with expirationTtl 86_400 and
deferViaQueue sends the deferred message with delaySeconds rounded up from
the grace period; neither value was asserted, so dropping either left the
miniflare suite green (the redelivery test only reads the key back, and the
grace-period test only waits for the label). The Redis store's TTL is pinned
in redis.test.ts; the KV store now is too, through the expiration KV reports
on list(). The delay is pinned on the fake GitHub's own clock, comparing the
deferring run's config read with the resumed run's label POST under a 3 s
grace period: without the delay the resume lands in under 100 ms.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive
hivecommons-hive Bot requested a review from jpmcb as a code owner November 9, 2026 15:54
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 9, 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

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

Reviewed by reviewer — no findings.

Reviewer notes

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

  • TTL pin: src/server/worker.ts:58 writes delivery:<id> with expirationTtl: 86_400; the new test bounds the expiration KV reports on list() to [before+86400, now+86400] seconds-since-epoch, which is exactly what miniflare surfaces. If the TTL were dropped, key?.expiration is undefined and the assertion fails — the pin does bite.
  • Clock: the at field slices 15 chars after seen:, and the fake's logger (__tests__/worker/worker.test.ts:27) pads Date.now() with .padStart(15, '0'), so the slice always parses as a number and lexicographic KV ordering stays chronological. Checked; no off-by-one.
  • Grace-period pin: worker.ts:113 sends the deferred message with delaySeconds: max(1, ceil(delayMs/1000)); under a 3 s period the test's >= 2_500 ms bound has real margin over the ~85 ms no-delay resume, and measuring from the first config read only widens the gap (earliest read ≤ send time), so the assertion is conservative in the passing direction and still fails hard if delaySeconds is removed.
  • Occupied-ground claim holds: the diff touches only __tests__/worker/worker.test.ts, and Refs #682 is correctly non-closing with the remainder named (carried by test(coverage): read v8-ignore hints as the tree numbers them inside a Stryker sandbox #683).

Test-only change, CI green including shuffle. No findings.

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

/kind cleanup


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

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

@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 Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants