Skip to content

test: close the five highest-value gaps from the test audit - #857

Merged
tt-a1i merged 16 commits into
mainfrom
cursor/test-value-audit-fixes-4e29
Oct 16, 2026
Merged

tt-a1i merged 16 commits into
mainfrom
cursor/test-value-audit-fixes-4e29

Conversation

@tt-a1i

@tt-a1i tt-a1i commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Five tests were protecting the right failures, but the way they checked those failures was brittle or never reached the failure.

Value

Each check still fails the original bad result, and the false failures stop blocking the measurement or the recovery they exist to protect. The performance suite can run. Provenance accepts the real checkout and still rejects zero, foreign, or multiple OpenPI roots. Lock recovery reads a Windows start time from WMI only. A missing time stays unknown and the 5s lock expires without taking the lock.

Approach

  • The performance snapshot sets currentSessionId and currentSessionPath to the same synthetic session, and assertPerformanceSessionIdentity throws before the route is fulfilled when those disagree with the session list or the selected session. An identity error is not swallowed by the route abort path. The suite is not added to CI.
  • Windows start time comes from one cscript.exe //Nologo query of Win32_Process.CreationDate, read as the CIM datetime string and truncated to unix milliseconds. Redirected cscript output is decoded as UTF-16 LE when it has a BOM or NUL-padded ASCII; a UTF-8 misread stays unparseable. The script path is resolved when the query runs, so Vitest can import setup config without a file URL. The JScript has no trailing commas, writes a failure token and quits outside try, and is not launched with //B. The query budget stays 1s. There is no PowerShell fallback and no second query command. A non-zero exit, timeout, or unparseable value is unknown ownership, and the lock deadline stays 5s. Linux still uses ps. The existing execFile failure injection still covers the fail-closed path, and on Windows that injection must be cscript.exe only.
  • The product still applies timeoutMs to both Antigravity deadlines. The lifetime test holds Date.now until the metadata event has been parsed, then moves the clock on the third body pull (the response prefetches one chunk before that parse). A sibling test advances the clock before any payload is parsed and still expects "first SSE event".
  • Session-worktree index checks use git ls-files --stage -z. The fork test still compares git status --porcelain=v1 -z.
  • Provenance dedupes reported paths with realpath, counts a path as OpenPI when it is this checkout or its package.json name is @tt-a1i/openpi, and matches only when that set is exactly the checkout. Importing the module no longer runs pi list. The foreign-package test compares realpathSync.native of that package, so a Windows 8.3 temp path is not treated as a different source.

Validation

Linux x64, Node v22.23.3, Bun 1.3.14. Chrome 154 for the performance suite.

  • bun run lint and tsc --noEmit passed after removing the PowerShell fallback. tests/extensions/shared/setup-config.test.ts passed on Linux: reused-PID recovery, the mocked query-failure lock wait (about 5.5s, no mutation, no PowerShell command), and the live WMI test skipped off Windows.
  • bun run test passed on d00476b: Node 2639 passed / 9 skipped / 0 failed (2648 tests), Vitest 1520 passed / 98 files.
  • Performance suite, not in CI: 11 passed in 16.8s. Bundle SHA-256 unchanged: 99577ba28cb347d38db1008979c9b30e08befa5baa34e0dfb09530afd2b4ecfe.
  • Head ea256c6 removed the PowerShell fallback but the WMI script was invalid JScript (a trailing comma, hidden by //B). Windows CI on that head failed the live WMI read in 54ms and then the reused-PID recovery at the 5s deadline. Head fe57ee4 fixes the script. CI run 38865595760 on that head succeeded. Windows parallel 2/2 recorded Windows reads this process start time from WMI alone and a reused PID does not impersonate the dead lock owner as passing, and the query-failure case still waited out the deadline (ok 458 about 6.5s after ok 457).

No speedup versus PowerShell is claimed. Heartbeat liveness (#862) is out of scope.

Impact

  • User-visible behavior: none for a normal session. A Windows config-lock recovery reads the process creation time through WMI only. A failed read does not take the lock.
  • Model-visible context/tools: none.
  • Runtime/lifecycle: setup-config lock ownership and the provenance gate. The performance suite remains opt-in.
  • Persisted config/data: lock owner files still store processStartedAt. No config schema change.
  • Compatibility or risk: the Windows start-time command is cscript only. The 5s fail-closed deadline and the 1s query budget did not change.

Fixes #840. Related to #829.

Open in Web Open in Cursor 

cursoragent and others added 5 commits October 16, 2026 03:11
The synthetic snapshot kept the host session path while replacing the id, so
the UI stayed on reconnect and the suite never reached its measurements.
Require one id and path, and fail that mismatch before the UI wait. The
suite stays outside required CI.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
Lock recovery still treats a failed or unparseable start-time query as
unknown and keeps the 5s fail-closed deadline. Windows now asks cscript for
the WMI creation time instead of paying for a PowerShell cold start.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
…dline

timeoutMs still bounds both waits. The lifetime test now parses the metadata
event before moving the clock onto that deadline, so a later stall is the
next event. A deadline that expires before any payload stays the first event.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
Index bytes change when fsmonitor or untracked-cache extensions are enabled.
Compare staged entries with git ls-files --stage, and keep porcelain status
on the fork. A real staged-content change still fails that comparison.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
A directory name containing openpi is not a source. Keep the single reported
path whose realpath is this checkout, including duplicate and symlink lines,
and still reject zero, foreign, or multiple OpenPI package roots.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
@github-actions github-actions Bot added the area:setup OpenPI setup, configuration, or setup documentation label Oct 16, 2026
cursoragent and others added 8 commits October 16, 2026 03:16
The response body pulls a second chunk before the first read is parsed.
Advancing the clock on that prefetch still reports the first SSE event.
The third pull is the read after the metadata event.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
… typed

Typecheck requires a declaration for the provenance module, matching the
other script exports. The missing-path case builds the snapshot without
that field instead of deleting a required property.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
Vitest imports setup config without a file URL. Building that path at
module load threw before any test in the settings catalog could start.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
Redirected cscript output is UTF-16, so the CIM timestamp never matched
and a reused PID stayed unknown until the 5s lock expired. Decode the
pipe, keep the 1s query cap, and still fail closed on a bad result.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
Windows temp paths can be 8.3 names while pi list reports the long
path. The matcher already rejected that foreign package.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
The branch cannot be force-pushed. Bring in main, including the
contributor test-value skill, with a merge commit.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
cscript still produced no usable CreationDate on the Windows runner, so
a reused PID waited out the 5s lock. Keep the 1s WMI query, then allow
one PowerShell read of at most 3.5s. A failed or non-integer result
stays unknown and does not recover the lock.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
The b03b1df Windows shard passed. UI ubuntu Node 22.19.0 timed out in
composer-context-navigation, and rerunning failed jobs was not permitted.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
Bring in the CI flake fixes from #861 (db114bb): workflow sandbox
watchdog, sidebar post-drag click, and composer source menu.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
cursoragent and others added 2 commits October 16, 2026 07:01
Drop the PowerShell fallback. One cscript query decodes UTF-16 and
stays inside the 1s budget. A missing time is unknown ownership, so
the 5s lock expires without taking the lock.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
A trailing comma in the cscript query is a syntax error. //B hid it,
so the query exited in milliseconds with empty output and the lock
waited out the 5s deadline. Drop //B, pass //Nologo verbatim, and
leave a failed read non-zero.

Co-authored-by: tt-a1i <tt-a1i@users.noreply.github.com>
@tt-a1i
tt-a1i marked this pull request as ready for review October 16, 2026 07:19
@tt-a1i
tt-a1i merged commit d6a996a into main Oct 16, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:setup OpenPI setup, configuration, or setup documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(web): 修复性能 fixture 的 Session 路径身份,恢复性能测量入口

2 participants