Skip to content

[Bug]: usage_statistics_environment tests fail when the checkout lives under a temp root (macOS /private/tmp worktrees) #8337

Open

Description

@LIHUA919

Preflight

  • I searched existing issues and discussions for this behavior.
  • This report is not an unpatched security vulnerability.
  • The report and attachments contain no credentials or private/internal material.

Issue origin

Observed or reproduced in a real environment

LoopX version or commit

21013c0c1 (current main); also reproduced at 87a153d4d.

Host or runtime surface

macOS (any host whose checkout/worktree resolves under a temporary root, e.g. /tmp → /private/tmp). Not OS-version-specific; the same class would apply on Linux under /tmp checkouts where /tmp is on tmpfs.

LoopX area

Tests / usage statistics environment classification

Problem

Two tests in tests/control_plane_ts/usage_statistics_environment.test.ts build their "persistent" fixture with resolve(".local", ...), i.e. CWD-relative:

  • "persistent machine routes retain notice-before-default-on without an enable flag" (:56) — mkdtemp(join(resolve(".local"), ...))
  • "temporary roots, filesystem aliases and path-component boundaries are local eligibility facts" (:78) — persistent = resolve(".local", "usage-policy-persistent")

When the repository checkout (or a git worktree used for development) lives under a directory the classifier itself defines as a temporary root — on macOS /tmp resolves to /private/tmp, and /private/tmp is in the classifier's temporary prefix list (:100) — every "persistent" fixture path is also under a temporary root. The classifier then answers by its own correct rules:

not ok - persistent machine routes retain notice-before-default-on without an enable flag
  expected: 'notice_required'  actual: 'temporary_path'
not ok - temporary roots, filesystem aliases and path-component boundaries are local eligibility facts
  expected: false  actual: true   (the `configured + "-persistent"` case, :88)

The production classifier is behaving correctly; the tests assume the checkout is at a persistent location, which CI guarantees (/home/runner/work/...) but local contributor worktrees commonly do not (git worktree add /tmp/...).

Minimal reproduction

git worktree add /tmp/loopx-repro origin/main && cd /tmp/loopx-repro
npm ci --ignore-scripts
LOOPX_TEST_PYTHON=python3 PYTHONPATH=. node --no-warnings --experimental-sqlite \
  --experimental-strip-types --test tests/control_plane_ts/usage_statistics_environment.test.ts
# 2 fail — with the checkout moved to a persistent path, the same command passes 3/3

Verified on macOS arm64, Node 22.22.3: 2 failures from /private/tmp/... worktrees, 3/3 pass from a persistent-path worktree at the same commit.

Expected behavior

The suite passes regardless of where the checkout lives: the tests should anchor their persistent fixture to a location that is persistent by construction (not CWD-relative), or explicitly skip with a stated reason when the checkout itself resolves under a temporary root.

Actual behavior

Two deterministic failures whose cause is the checkout location, not the code under test — which misleads contributors into reporting false main regressions (it mislead me for an hour of triage today).

Sanitized diagnostics

+ actual - expected
+ 'temporary_path'
- 'notice_required'

Additional context

Related environment notes filed in case they help other contributors: root npm ci is required in fresh worktrees or ~12 test files fail whole-file with Cannot find package 'typescript'; browser scenarios spawning a Python backend need the package installed (pip install -e .) like CI. This report only claims the CWD/temp-root sensitivity, verified at two commits with both failing and passing controls.

Activity

  1. LIHUA919 commented on Nov 8, 2026

    @LIHUA919
    ContributorAuthor

    Claiming this (filed after triaging it live). Plan: anchor both fixtures to a persistent-by-construction root instead of CWD-relative .local — the natural owner is os.homedir()-adjacent (e.g. mkdtemp(join(homedir(), ".loopx-test-persistent-"))) or os.tmpdir()'s real sibling if the platform guarantees persistence — and add a negative twin documenting that a checkout under a temp root still classifies correctly by production rules (the classifier keeps its authority; only the fixture location changes). Will validate from BOTH a /tmp worktree and a persistent worktree before the PR.

  2. LIHUA919 commented on Nov 8, 2026

    @LIHUA919
    ContributorAuthor

    Fix PR opened: #8338. Note the diagnosis refined while implementing: the classifier intentionally weighs the running module's own location (fileURLToPath(import.meta.url) is one of its candidates), so from a temp-root checkout a persistent route genuinely cannot be constructed — the fix anchors fixtures to a classified-persistent base and skips with that stated reason in the temp-checkout case, rather than trying to force the scenario. Both layouts validated (3/3 persistent; 1 pass + 2 reasoned skips under /private/tmp).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions