Skip to content

render: make the semaphore order test distinguish FIFO from LIFO #2968

Closed

Description

@schlessera

Context

Part of #2963. Source-verified finding from the 2026-10-25 multi-agent test-value audit at c670449d3bf1b0639e50ce554d728961f4313add. Broad inventory screening was followed by detailed inspection of this finding; this is not a claim of exhaustive manual review or measured CI savings.

Classification: Confirmed fixture blindness for the FIFO clause, not a wholly tautological test.

Evidence / production

bounds concurrency and wakes queued waiters in order (packages/ui-render-puppeteer/tests/renderer.test.ts:29-51) acquires two slots, queues only one additional waiter (34-38), releases one slot and asserts that waiter wakes (42-44). A queue with one member has the same removal order under FIFO and LIFO. Production explicitly declares a FIFO semaphore (packages/ui-render-puppeteer/src/semaphore.ts:1) and implements it with queue push (29) and shift (47-49). Changing shift to pop would preserve every assertion in this named test.

Surviving tests inspected

double-release is a no-op (renderer.test.ts:53-68) also has only one waiter and protects capacity, not order. queue expiry rejects while the slot is held and removes the expired waiter (packages/ui-render-puppeteer/tests/phase-budgets.test.ts:239-259) removes the expired request before queuing one survivor (251-255). Shared-launch tests use multiple active slots, not a two-waiter FIFO observation (313-335), and shutdown cases assert cancellation. No alternative inspected test supplies the missing FIFO proof. Do not confuse the scrape package's unrelated rate-limiter ordering test with a test of this Semaphore.

What can pass while broken

A LIFO renderer queue could pass the named FIFO test and the single-survivor capacity tests. This is a precise ordering blind spot, not evidence that the production implementation is currently wrong.

Safe plan / acceptance

Rewrite the existing test to occupy all slots, queue at least two labeled waiters, release one slot, and assert only the oldest has entered. Release it and assert the second enters next. Explicitly observe the pending state before each release; use controlled promises/event-loop drains rather than introducing a fixed real wait. Retain maximum concurrent capacity and final slot recovery assertions. Preserve the independent double-release and expiry tests. Target invocation reduction: zero; stronger proof at the existing cheap layer.

Verification/mutation proposal and baseline

The existing named test passed in 5.49 ms. Run rtk bun run test ./packages/ui-render-puppeteer/tests/renderer.test.ts ./packages/ui-render-puppeteer/tests/phase-budgets.test.ts. In an isolated implementation checkout, mutate this.queue.shift() to .pop(): require the rewritten test to fail specifically on the first granted waiter, restore and rerun. This mutation was not performed in the shared audit checkout.

Scope

Strengthen the existing queue test with at least two labeled blocked waiters and controlled release ordering, retaining capacity recovery.

Out of scope

Changing product behavior, public contracts, required proof gates, offline guards, runtime pins or unrelated tests. Every distinct native, security, lifecycle and adapter obligation identified above remains. This issue does not authorize deleting the surviving owner named by another audit issue.

Acceptance criteria

  • The first release grants only the oldest queued waiter; the next grants the next waiter. Pending states are observed without adding a fixed wall-clock wait.
  • Changing queue.shift() to queue.pop() fails the intended order assertion; maximum capacity, double-release and expiry proof remain.
  • Record an assertion-to-owner mapping for every moved or removed case, including shared-helper obligations; do not count matching test names as proof of equivalence.
  • Run the proposed focused production mutation(s), observe failure on the intended assertion, restore, and record passing focused proof. A module-load error is not a behavioral receipt.
  • Any performance claim separates scenario/body cost, setup and total elapsed time and uses comparable observations; structural counts alone are not a speedup.

Verification

bun run test ./packages/ui-render-puppeteer/tests/renderer.test.ts ./packages/ui-render-puppeteer/tests/phase-budgets.test.ts
bun run check:pr --base origin/main

Preserve the existing offline/keyless harness. Browser/native commands require the documented real runtime and OS-offline prerequisites; missing prerequisites are not passing or skipped proof. The mutation proposals and retained boundary checks are detailed above.

Contract impact

No integration-contract or product-behavior change is selected. This is test/proof maintenance; retain the current CLI/MCP/wire/schema/frontmatter envelopes. No release-content change is selected.

Activity

  1. added
    type: test
    area: render
    on Oct 25, 2026
  2. added
    priority: p2
    agent-ready
    on Oct 25, 2026
  3. schlessera commented on Oct 25, 2026

    @schlessera
    OwnerAuthor

    2026-10-26 triage at main c670449d3bf1b0639e50ce554d728961f4313add: verified the cited current test/production boundary and native #2963 parent. The scope names the retained proof, exclusions, checkable acceptance criteria, focused verification and mutation requirements; no unresolved design, decision, access or reproduction prerequisite prevents starting this test-maintenance task. Set priority p2 for wanted, unscheduled work and add agent-ready. Keep native/browser/SDK qualification required by the brief as implementation proof; this source/readiness review supplies no completed repair, post-change equivalence or measured CI saving.

  4. added this to the 0.44.0 milestone on Oct 29, 2026
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-readyarea: renderpriority: p2type: test

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions