Skip to content

test: temp-directory diffs count other processes' directories (turn-data-tree, relay probe) #4252

Closed

Description

@schlessera

What happens

Some tests prove that a directory was created or removed by listing the shared temp directory, readdirSync(tmpdir()), and filtering it by a name prefix. Concurrent test processes create directories with the same prefixes there. So a diff can see another process's directory, or an exact count can include it.

That is how main run 44219495479 failed autonomous-envelope.test.ts "finishing the turn stops its relay" (expected 1 new relay directory, received 2). Its fix is the declared fix for #4250: that file gets a private TMPDIR. The same pattern remains in:

  • packages/ui-server/tests/turn-data-tree-placement.test.ts:70: tmpTrees diffs brain-turn-data-* before and after.
  • packages/ui-server/tests/turn-data-tree.test.ts:454: bases() counts brain-private-index-base-* and expects exactly one ("ONE_BASE_SEALED").
  • packages/ui-server/tests/turn-data-tree.test.ts:547: left() compares brain-turn-data-* and brain-private-index-* before and after ("AN_ABORTED_COPY_LEAVES_NOTHING").
  • packages/ui-backend-claude/tests/fixtures/server-host-relay-probe.ts:199: compares brain-inference-* before and after a native release failure.

private-index-cache.test.ts already avoids this by filtering on process.pid.

Acceptance criteria

  • Each listed test counts only directories its own process created: a private TMPDIR for the file or the probe, a pid-scoped name, or the path the code under test returns.
  • A contention receipt for each: with a loop creating matching directories in the shared temp directory, the test fails before the change and passes after.
  • No other test under packages/*/tests or tests/ diffs or counts the shared temp directory by a prefix that is not process-scoped.

Activity

  1. added
    type: testCoverage, harness or proof work with no behaviour change.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p3Someday. Needs a driving use case before it starts.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 18, 2026
  2. self-assigned this
    on Nov 18, 2026
  3. schlessera commented on Nov 18, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-38a36a5d. Branch: test/4247-4249-4252-test-races.

    Worked together with #4247, #4249 and #4252 in one test-only PR. Collisions: closure-level only with long-lived drafts, no path collision.

  4. added this to the 0.45.0 milestone on Nov 18, 2026
  5. schlessera commented on Nov 18, 2026

    @schlessera
    OwnerAuthor

    Delivered in #4254 (squash bd751d4 on main).

    • turn-data-tree-placement.test.ts now lists its trees in a private TMPDIR (usePrivateTmpdir, which asserts the directory being listed). Contention receipt: with a loop creating matching directories in /tmp, main failed 3 of 3 runs on NO_TEMPORARY_COPY and the branch passed 3 of 3.
    • turn-data-tree.test.ts (bases(), left()) was already isolated: its fixture (packages/ui-server/tests/turn-data-tree.test.ts:60-63) gives each test its own TMPDIR. Both cases passed 3 of 3 runs on main under the same loop, so the file is unchanged.
    • server-host-relay-probe.ts only runs under bwrap with --tmpfs /tmp, or one step at a time inside a docker run --rm container, so its temp directory is private by construction. A comment now records that.
    • Audit: no other test under packages/*/tests or tests/ lists the shared temp directory by a prefix that is not process-scoped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p3Someday. Needs a driving use case before it starts.type: testCoverage, harness or proof work with no behaviour change.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions