Repository navigation
fix(windows): repair the 8.3-alias abort, the trash shim's module type, Chinese prose in math, and the assumptions a POSIX host hides - #14
Merged
UncleMoc merged 10 commits intoNov 10, 2026
Conversation
Collaborator
Author
antianqi
force-pushed
the
fix/windows-process-and-trash-defects
branch
from
November 10, 2026 02:55
9ef8dd8 to
3f22ac5
Compare
…cess Windows reports a changed file under its long name, and libuv compares that name against the directory string the watch was given. A directory reached through its 8.3 short alias -- which is how a temp directory under a short-named home directory spells itself -- therefore fails libuv's own !_wcsnicmp(filename, dir, dirlen) assertion, and that assertion takes the process down instead of raising an error. realpathSync.native resolves the alias to the long path; the JavaScript implementation of realpathSync does not, so the native one is the one that matters here. A directory that cannot be resolved falls back to the path it was given. The test runs the watcher in a child process on purpose: the assertion is not catchable, so isolating it turns a regression into a failed assertion instead of a dead test worker. The child watches the 8.3 alias and writes through the long path, which is the pair that used to abort. (cherry picked from commit 21b8ea65d9b7e79e319f2f848ffcc95a8893c1a3)
The plugin directory watcher had the same defect the skills watcher had: Windows reports a changed file under its long name, and libuv compares that name against the directory string the watch was given. A directory reached through its 8.3 short alias — which is how the plugin directory under a short-named home directory spells itself — therefore fails libuv's own !_wcsnicmp(filename, dir, dirlen) assertion, and that assertion takes the process down instead of raising an error. realpathSync.native resolves the alias to the long path; the JavaScript implementation of realpathSync does not. A directory that cannot be resolved is watched under the path it was given. (cherry picked from commit 841a9a032780286b78f6794c829ba4399c76ce78)
The shim is a CommonJS script, but it was seeded as `mavis-trash.js`, and Node reads the module type of a `.js` file from the nearest ancestor `package.json`. An ancestor that says `"type": "module"` — a user's home directory can easily hold one — makes Node parse the shim as ESM, where `require` is not defined, and the shim never runs. The consequence was not cosmetic. The permission pipeline rewrites `rm` to `mavis-trash` so that a deletion stays recoverable; with the shim dead the rewrite had nothing to run, and a Windows deletion fell back to a hard one. The runtime's own probe reported `mavis-trash is not callable` on every startup. The shim is seeded as `mavis-trash.cjs` now. `.cjs` is CommonJS whatever the nearest ancestor says, and the `.cmd` launcher names the same file. The executor's name guard accepts the old `.js` name as well. It answers "does this path look like the trash script", and whether the script actually runs is decided by the probe, not by its name. The Windows contract test states the invariant: a data directory under an ancestor that declares ESM still gets a shim the runtime can call. (cherry picked from commit ca5a4d386f94d61c921b341eb78beba0a302ffcd)
The inline math tokenizer matched any two dollars on a line. A shell variable in prose therefore paired with a later dollar and swallowed the paragraph between them, and KaTeX then complained about every Chinese character it found there. Math is not written in Chinese, so a body that carries Chinese characters or the punctuation that comes with them is not a formula. A real formula between two dollars still renders as one. (cherry picked from commit fb3aca1bcfef843a464957031a5da5861cb06941)
Two checks could not pass on Windows. The marketplace-version check compared a path.relative() result against POSIX-shaped literals, so the shared module it is meant to exclude never matched and was reported as a second declaration. The same relative path fed the test-file filter, whose pattern also expects a forward slash, so test files were counted as offenders too. Normalizing the separator once at the source fixes both. The locale check asserted that the child's ICU locale is en-US. The runner does pin LANG, LANGUAGE, LC_ALL and LC_MESSAGES, and on POSIX Node derives its default locale from those. Windows has no POSIX locale variables: Node reads the OS user default locale, and LC_ALL, LANG, NODE_ICU_DATA and ICU_DEFAULT_LOCALE were each measured to leave it unchanged. The child is a real process on this host whatever the simulated platform says, so the assertion is now keyed on the host platform and only demands a pinned locale where pinning is possible. (cherry picked from commit edfa52d5d1d18c76e356b238298825e1144992b5)
The new watcher test is a reviewed source path, so the inventory names it.
The case boots the real host and calls an operation over the loopback service, exactly as the four cases after it do, and all four of those run on 120s. This one alone fell back to Vitest's 5s default, which a cold Windows runner does not always clear: the host boot, the service start and the catalog read all have to fit inside it, and the runner that failed it was visibly loaded. The assertions are unchanged, and the deadline is the file's own.
Both files assert something the host's own spelling made unreachable. The observability directory is a filesystem path, so it carries the host's separator, but the assertions compared it against POSIX-shaped literals. On Windows the directory is `\data\v2\observability\mcode` and the literal never matched. The Bash tool runs PowerShell on Windows — the runtime prefers it, because it is system-native and has no MSYS path problems — and the commands in the output suite were written for `sh`: `printf` does not exist there, and a quoted executable is a string expression to PowerShell rather than a program to run, so `"C:\...\node.exe" -e "..."` is a ParserError. The commands are now spelled for the shell that will run them, and PowerShell carries the native exit code over explicitly, because it reports it in $LASTEXITCODE and exits with its own status otherwise. The POSIX commands are unchanged, so a POSIX host runs exactly what it ran before.
antianqi
force-pushed
the
fix/windows-process-and-trash-defects
branch
from
November 10, 2026 03:45
2296ad8 to
c8000a3
Compare
Both compared a path the host spells its own way against a POSIX-shaped literal, and one ran a POSIX command on a host whose shell is PowerShell. The sandbox backend joins the git template dir onto the sandbox temp dir, so the path carries the host's separator; on Windows the directory is `\tmp\session-1\git-templates-empty` and the literal never matched. The mcode-tools acceptance read the host keys back with `env | grep`, which is POSIX shell syntax — on the Windows runtime the shell is PowerShell, where `env` does not exist and the command does not parse. Node reads the same environment the child was given and prints it in the same shape on both, so what the case measures is unchanged.
…rite does Windows refuses a rename while another process holds the file open for a moment — an indexer, a scanner, a concurrent reader — and the refusal is transient. The SSH connection store wrote its document by renaming a sibling file over the real one, so the store failed at random on Windows and nowhere else. Every other atomic write in the repository already retries that refusal: the TUI's auth and identity stores, the update service, the local runtime's auth context, the provider-presets repository. The SSH store was the one path that did not, because the helper it needed did not exist yet — the helper was synchronous, and the store's rename is a promise. The shared helper gains an asynchronous sibling. Its wait is a timer rather than a blocking sleep, so a server process does not stall its event loop while a locked file is retried. The rename stays awaited: the commit must not return before the document is in place, and the suite has a case that says so. The new helper has its own cases: a refusal is retried on Windows and gives up after the budget, it is not retried off Windows, it is not retried for an error that does not mean "held file", and the wait between attempts lets other work run.
This was referenced Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Seven defects a Windows host exposes, each reproduced before the fix and verified after it. This branch carries only what #11 (
fix/webui-ci-baseline) does not already have; #11 has since merged, and this branch is rebased ontomain.An 8.3 alias aborted the process.
fs.watchis given the path the event carries, and a Windows event can carry the short form (C:\Users\ADMINI~1\...\) of a directory that is watched by its long form. libuv then asserts that the two agree and the whole process aborts with0xC0000409— not an exception, so nothing can catch it. Both watchers now resolve the directory throughrealpathSync.native, which resolves the alias; the JavaScriptrealpathSyncdoes not. The test watches a short path and writes through the long one, in a child process, because an abort kills the worker that ran it.The trash shim could not run. It is a CommonJS script seeded as
mavis-trash.js, and Node reads the module type of a.jsfile from the nearest ancestorpackage.json. An ancestor that says"type": "module"— one normal package in a home directory is enough — makes Node parse the shim as ESM, whererequireis not defined. It is seeded asmavis-trash.cjsnow. The consequence was not cosmetic: the permission pipeline rewritesrmtomavis-trashso that a deletion stays recoverable, and with the shim dead the rewrite had nothing to run and a Windows deletion fell back to a hard one. The runtime's own probe reportedmavis-trash is not callableon every startup — 21 times in onetest:capabilitiesrun, 42 in onetest:webuirun.Chinese prose was read as math. A dollar-delimited run that carries Chinese is prose, not a formula:
用 $state 读取,结果是 $x^2$。opened at the first dollar and swallowed the paragraph into the formula, and KaTeX then complained about every Chinese character in it. Math is not written in Chinese, so a body that carries it is not math.Two suites could not run on Windows at all. The observability directory is a filesystem path, so it carries the host's separator, but the assertions compared it against POSIX-shaped literals — on Windows the directory is
\data\v2\observability\mcodeand the literal never matched. The Bash output suite ran commands written forsh:printfdoes not exist in PowerShell, and a quoted executable is a string expression to PowerShell rather than a program to run, so"C:\... ode.exe" -e "..."is a ParserError. The commands are now spelled for the shell that will run them, and PowerShell carries the native exit code over explicitly. The POSIX commands are unchanged, so a POSIX host runs exactly what it ran before.The SSH store's atomic write could fail at random on Windows. It renamed a sibling file over the real one, and Windows refuses a rename while another process holds the file open for a moment — an indexer, a scanner, a concurrent reader. Every other atomic write in the repository already retries that refusal (the TUI's auth and identity stores, the update service, the local runtime's auth context, the provider-presets repository); the SSH store was the one path that did not. The shared helper needed for it did not exist yet — it was synchronous, and this rename is a promise — so it gains an asynchronous sibling whose wait is a timer rather than a blocking sleep. The rename stays awaited: the commit must not return before the document is in place, and a suite case says so.
Two more suites could not run on Windows at all. The sandbox backend joins the git template dir onto the sandbox temp dir, so the path carries the host's separator, and the assertion compared it against a POSIX-shaped literal. The mcode-tools acceptance read the host keys back with
env | grep, which is POSIX shell syntax — on the Windows runtime the shell is PowerShell, whereenvdoes not exist and the command does not parse.The native PTY acceptance host stayed alive after it was done. Node-pty's Windows console-list helper is forked on every terminal kill to enumerate the processes attached to the shell's console; a shell hosted by ConPTY has a pseudo-console rather than a console, so the helper's
AttachConsolealways fails there, it dies without answering, and node-pty falls back to a five-second timer to resolve the promise. That timer lives in the process that killed the terminal, so every kill left the host five seconds of work it had not asked for — measured at 720ms of real work inside a 5.74s process. The acceptance host now exits once it has reported, in the send callback, which runs after the message has been flushed. The case says so: the host has to be gone within two seconds of reporting that it closed, and a shutdown that does not arrive carries the host's own trace of where it was. The alternative — node-pty'suseConptyDlloption, which skips the helper entirely — was measured and is worse: the process did not exit at all.Two release-tool checks could not pass on a Windows host and now do. The marketplace-version check compared a
path.relative()result against POSIX-shaped literals, so the shared module it is meant to exclude never matched. The locale check asserted anen-USICU locale that Windows cannot be made to report —LC_ALL,LANG,NODE_ICU_DATAandICU_DEFAULT_LOCALEwere each measured to leave it alone.Validation
Windows 11 (10.0.26100), Node 24.18.0, Chrome and Edge installed.
check:source(6110 paths),typecheck:webui,check:webui-dependency,check:webui-presentation,check:webui-motion,check:webui-overlays,check:webui-feedback,build:webui,check:webui-boundary,test:release-toolstest:windowstest:webuitest:webui-browsertest:capabilitiesRed before, green after, for each change:
3221226505(0xC0000409); with the fix reverted the same child aborts again. On the base, the abort also takes the Vitest worker with it:real-host-mcode-tools-bash-environmentfails withWorker exited unexpectedlyon the base and only with the assertion on this branch.available = falsewithrequire is not defined in ES module scope; it answersavailable = truenow, and through the installed launcher both a file and a Chinese-named file reach the Recycle Bin.Failures that are not this branch's:
test:webui-browserfailures are screenshot comparisons against the*-win32.pngbaselines fix(webui): repair baseline CI across Linux, macOS and Windows #11 recorded. They fail identically on fix(webui): repair baseline CI across Linux, macOS and Windows #11's head without this branch's changes, on this host: those baselines do not match this machine's rendering. fix(webui): repair baseline CI across Linux, macOS and Windows #11's own Windows CI passes them.test:capabilitiesfailures are the set this branch started from, less the seven this branch fixes.test:webuiis now clean on Windows;test:status-contract,test:release-tools,test:sandboxandtest:webui-packageall pass here too.test:capabilitieswas compared change-for-change againstorigin/mainand the failing sets are identical. That test's command (env | grep ...) is POSIX-only, and it passes on the CI runner only because Git-for-Windows' bash is on PATH there.test:policyfails 15 cases on Windows because the POSIX branch of the trash check asks for an execute bit, which Windows does not have.test:policyis restricted to Linux and macOS, so this never reaches CI. Left alone here.The Windows CI run on the first push
The first Windows run failed in
test:webui, onreal-host-loopback.test.ts→ "lists builtin models on first boot without runtime environment or a remote catalog", withTest timed out in 5000ms. That case boots the real host and calls an operation over the loopback service — exactly what the four cases after it do, and all four of those run on 120s. This one alone fell back to Vitest's 5s default, which a cold, loaded Windows runner does not always clear. It passes on this host, on this branch and on the base alike, so it is the deadline rather than the behaviour: the case now carries the file's own 120s, and the assertions are unchanged.test:windowsis not part of any workflow at the moment, so the new trash contract test is not exercised by CI. Whether to put it back into the platform verification is a maintainer call.Publication and contribution checks
release/public-source.json; new tests are declared intest/vitest-suites.jsonwhere applicable.Maintainer handoff
Publication scope or license changes (if any): none.
Shared-source port: not needed / pending / complete. Record public PR references only; keep private links and review material out of this PR.
Note on the branch location: the account that owns this branch has read-only access to this repository, so it lives on a fork and this pull request is opened against
main. Cherry-picking the seven commits is equivalent.