Skip to content

test(pkarr-worker): RETENTION_SECONDS guard is never exercised through the real Durable Object alarm path — invalid values only reach a mock that re-implements it (PR #4352) #10818

Closed

Description

@dezren39

Finding

Merged PR #4352 guarded the pkarr-worker's retention alarm: malformed, non-positive, or out-of-range RETENTION_SECONDS values now fall back to seven days instead of scheduling a deletion alarm at/before now (or NaN). The guard itself (retentionMilliseconds) is well unit-tested — but the invalid-value cases never exercise the real Durable Object path they protect:

  • The parameterized RETENTION_SECONDS tests drive worker.fetch with a mock PKARR_STORE whose putPacket re-implements the production alarm computation inline (now + retentionMilliseconds(retentionSeconds, now)). The real PkarrStore.putPacket — the code that reads this.env.RETENTION_SECONDS and calls this.ctx.storage.setAlarm — is never invoked for any invalid or valid non-default value.
  • The only assertion against a real Durable Object alarm is in the pre-existing publish test, which uses the default environment (no RETENTION_SECONDS set) and expects the seven-day default.

So the seam the fix exists for — env value → retentionMilliseconds → setAlarm inside the real DO — is unpinned: if the wiring in src/index.ts regressed (wrong env field, alarm computed from a stale now, guard bypassed), every retention test would still pass, because the mock copies the intended wiring instead of using it.

Evidence

Why it matters

#3261 was a data-loss bug: a bad env value made stored packets vanish right after a 204, or never expire. The regression suite for it should fail if the protection stops being wired into the real object — today it cannot, because the tests substitute a hand-copied version of the wiring for the thing itself.

Acceptance criteria

  • At least the invalid-value cases (e.g. 0, 7d, out-of-range) and one valid non-default value (e.g. 3600) are exercised through the real PkarrStore Durable Object (e.g. runInDurableObject / SELF with per-test env bindings), asserting the alarm the DO actually scheduled via state.storage.getAlarm().
  • The mock-based cases are removed or reduced so the alarm expectation is not computed by re-implementing the production expression in the test.
  • Existing pkarr-worker tests keep passing (npm test in pkgs/pkarr-worker).

Shadow verdict (PoC)

Stage A window already closed (summary on #2313) — no shadow verdict recorded.

Activity

  1. added
    kind/testTest coverage, test infrastructure, or test-only fixes
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/lowNice to have; do when convenient
    on Nov 16, 2026
  2. developing-today commented on Nov 16, 2026

    @developing-today
    Contributor
  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 16, 2026
  4. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: picked_up
    task: 17517
    lane: code-g
    date: 2026-11-16

    Picked up triage task 17517 (openchamber scheduled lane code-g, worker repo-worker-code). Revalidated: issue OPEN, PR #4352 MERGED 2026-11-02, no held/Drew-owned restriction. Verifying the coverage gap on current main next, then posting findings.

  5. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: triaged
    task: 17517
    lane: code-g
    date: 2026-11-16

    Triage verdict: CONFIRMED — real coverage gap, routed to small_fix (queue task 17521).

    Verified on current main a20e223 (fresh fetch):

    Scope for the fix (test-only): add real-DO cases for invalid values + one valid non-default value asserting state.storage.getAlarm(); drop/shrink the mock-computed expectations at :174. Do not change retentionMilliseconds semantics or src/index.ts wiring.

  6. 12 remaining items

  7. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: parked
    task: 17521
    lane: code-g
    date: 2026-11-16

    PR opened: #10824 (branch queue/17521-10818-real-do-alarm, pushed to origin; 2 files: new test/worker.retention.test.ts + vitest.config.ts projects). Test-only change for #10818: real-DO PUT via SELF + getAlarm readback per RETENTION_SECONDS value (0/7d/out-of-range/3600 via per-project miniflare vars). tsc clean except pre-existing TS2688 (missing @cloudflare/vitest-pool-workers types package, untouched by this change).

    NOT yet verified: the vitest suite was never executed (no CI workflow runs on the branch — only CodeRabbit NEUTRAL; mergeStateStatus CLEAN). Resume: in worktree ~/git/fleet/17521-10818-real-do-alarm, run npm test in pkgs/pkarr-worker (deps already installed) — all 5 projects must pass — then merge under standing criteria, complete task 17521 with bookkeeping deferred to fleet reconciliation. If miniflare.vars is not honored by the plugin version, rework to per-file env selection before merging.

  8. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 16, 2026
  9. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: picked_up
    task: 17521
    lane: code-j
    date: 2026-11-16

    Picked up small_fix task 17521 (openchamber scheduled lane code-j, worker repo-worker-code; resume from pr_opened checkpoint). Revalidated: issue OPEN, PR #10824 OPEN (branch queue/17521-10818-real-do-alarm), no competing PR, no held/Drew-owned restriction. Resuming: verify vitest suite in worktree ~/git/fleet/17521-10818-real-do-alarm then merge under standing criteria.

  10. added 2 commits that reference this issue on Nov 16, 2026
  11. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: done
    task: 17521
    lane: code-j
    date: 2026-11-16

    Done — merged PR #10824 (merge 96efa28) for #10818.

    Resume found the PR already open (prior lane code-g, branch queue/17521-10818-real-do-alarm). Two defects in the pushed state blocked verification, both fixed and committed (e47a0d0):

    • vitest 4 ignores top-level projects:[] — moved under test.projects. Without this the cloudflareTest plugin never applied (cloudflare:test unresolvable).
    • miniflare.vars is silently dropped by the plugin V4 schema parse (V4 shape carries plain-text vars as bindings) — switched per-project override to miniflare.bindings, which merges over wrangler-derived values per key. Verified: all 4 retention projects saw their own setting (previously all read 604800).
    • Default project include now covers test/deploy-*.test.ts so the suite still runs every file main runs.

    Verification: npm test in pkgs/pkarr-worker — 9 files / 68 tests pass (default: worker.test.ts + 4 deploy files; 4x worker.retention.test.ts at 0/7d/out-of-range/3600 asserting real-DO getAlarm() literals). tsc clean except pre-existing TS2688. PR mergeState CLEAN, no failing checks, test-only diff, no held/Drew-owned restriction. Note: pkarr-worker-tests.yml runs on push to main only, so its post-merge run is outside this task.

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

    app/pkarr-workerpkgs/pkarr-workerkind/testTest coverage, test infrastructure, or test-only fixespriority/lowNice to have; do when convenientsource/pr-diff-reviewFiled by the pr-diff-review jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions