Skip to content

Commit 16473c0

Browse files
authored
test: run core's suite on Windows and name every POSIX shape it cannot express (#3293) (#3294)
test: run core's suite on Windows and name every POSIX shape it cannot express (#3293) Fixes #3293 Owner: Dev Reviewer: Reviewer Written-by: Dev Tip SHA: 546a6f8 Base: 5620b96 `weekly`'s Windows leg (`compat · windows-latest · Node 24 · DSH 0.2.1-rc.2`) has been red on unchanged `main` since it was added: `ℹ fail 54` on 2026-11-21 (`job 136999263352`, head `5620b96f`, this branch's base) and `ℹ fail 45` on 2026-11-14 (`job 132588187493`). Every one was a POSIX assumption in a test, not a regression from a merge. This branch gives each one the assertion its platform can make, leaves product code untouched, and skips only the shapes Windows cannot build — one case at a time, by name and reason. ## Review round 2 (`REQUEST_CHANGES` at `e24133e7`) 1. **The relaxed assertion is strict again.** `core/test/diagnostics.test.js:1970` compared `stderr.filter(...)`, which let any second stderr line through. It is the base form (`5620b96f:1942`) verbatim again, only the code taken from `deniedCode()`: ```js assert.deepEqual(stderr, [`[ds-bot] diagnostics log not truncated: ${deniedCode()}`], 'one line, the code and never the folder') ``` 82/82 at this tip. With one extra `console.error('… the log that would not truncate is ' + logPath)` in `clear()`'s refusal branch, the tip's filter form passes and this form fails with the folder in the diff — the mutation is reverted before every run quoted here (`red.txt`). The mirror carries the same line: `check` says the series reproduces `core/`, `package`'s `canonical` agrees on a real checkout, and the probe's `generate` + `git status --porcelain` came back empty. 2. **The tip had no Windows execution; it has one now** — twice: the faithful dispatch below (`44994864729`) and a green one on the same workflow (`44995172673`), both `3424 / 3404 / 0 / 20`. Numbers, job ids and the skip list are in [the comment](#3294 (comment)). ## Red → green, by class Red is quoted per case in `red.txt` (the two scheduled Windows logs above); on Linux every case was already green, so nothing was made green by loosening it. | class | red on 2026-11-21 | now green because | | --- | --- | --- | | 1. teardown removed the home before the index closed | 11 cases: `chat-index-writers.test.js:94` (`EPERM … ds-bot-index-*`, 10 cases) and `host-pairing.test.js:44` | one teardown per test stops every host opened over the home — closing the SQLite index and the read-only window — and removes the directory last. No `force` retry over a live writer. | | 2. POSIX mode bits | 10 cases: `private-files.test.js:50` ×7 (`'0666' !== '0755'`), `secrets.test.js:109` (`438 !== 384`), `workflow-store.test.js:396` (`54 !== 0`), plus the two `#2614` folder cases | `core/test/platform.js` adds `modeOf`/`assertMode`: the four octal digits on POSIX, `writable`/`readonly` on win32, with a failure message that says why `0600`/`0700` cannot be observed there. No assertion was deleted. The two `#2614` cases that need a folder made unlistable are win32 skips with the reason. | | 3. `EACCES` where Windows says `EPERM` | the diagnostics report cases: not written, last-append reason, clear-not-truncated (`'… not truncated: EPERM'` vs `'… EACCES'`), unreadable journal | `deniedCode()` names the code the platform answers; the product sentence is untouched and every assertion still compares one whole line. | | 4. a bare path handed to a child as an ESM specifier | `resume-atomic.test.js:107/137/165` (each burned its 30 s timeout: `ERR_UNSUPPORTED_ESM_URL_SCHEME … protocol 'd:'`), `workflow-store.test.js:752/805`, `unread-mark-menu.test.js` (fails as a file) | children get `.href` file URLs, and esbuild gets `fileURLToPath(...)` instead of a URL's `pathname` (which kept the leading slash before the drive letter). | | 5. shapes Windows does not have | `kill -9` (3 cases), `chmod 000` unreadable files, `chmod` unlistable folders, a permissioned child behind a junction | each is one case gated on `win32`, with the reason in the name and in the `skip` option. Nothing is dropped on POSIX and no file is skipped whole. | | 0. path spelling, pid 1, start-up race, `settle` polling | `diagnostics.test.js:397` (`'~\\journal\\state.jsonl'` vs `'~/journal/state.jsonl'`), `chat-anchors.test.js:97` (`0 !== 1`), `real-dir.test.js:79` (a Windows `ENOENT` where the case wants `ENOTDIR`), `group-work.test.js:450` (`EPERM … state.json.<pid>.tmp -> state.json`), `group-work.test.js:495` | the `~` sentences are built from the platform separator, the live-lock fixture names `process.ppid` (pid 1 is never alive on Windows), `chat-anchors` waits for `rt.load()`, `real-dir` asks for an unparseable name where Windows has no `ENOTDIR`, and `group-work` polls the runtime's own log instead of reading `state.json` while the host renames over it. | Nine commits: eight, one per class plus one that regenerates `patches/ds-bot/` (the repo's `package` gate requires `core/` to equal `ds-bot/` + patches), and one that restores the strict diagnostics assertion after the review. ## Windows evidence at this tip `nightly.yml` cannot measure a branch: it duplicates the `flybot-tests` steps but omits their `Fetch origin/main for arch-docs check` step, so a dispatch on a branch dies in `npm run lint` before a single test (`arch-docs: FAIL — cannot diff against origin/main`, run `44989406764`). That gap is now its own issue, #3295; no `.github/**` file is in this PR. The evidence run therefore uses a scratch branch, `probe/3293-windows-fix`: this tip plus `.github/workflows/nightly.yml`, and nothing else — the missing fetch step (copied verbatim from `.github/actions/flybot-tests/action.yml`) and one Linux-only step that runs `generate` and prints `git status --porcelain`. Nothing under `core/` or `patches/` differs from the tip. The branch is deleted after the runs, never opened as a pull request, never merged. Run [44994864729](https://github.com/ThinkFlowLab/FlyBot/actions/runs/44994864729) at `98127c10`, job [137123632278](https://github.com/ThinkFlowLab/FlyBot/actions/runs/44994864729/job/137123632278) (`compat · windows-latest · Node 24 · DSH 0.2.1-rc.2`): ```text ℹ tests 3424 ℹ pass 3404 ℹ fail 0 ℹ skipped 20 ℹ duration_ms 77229.8687 ``` 54 → 0, at a tip that has now actually executed every win32 branch this PR adds: `modeOf`/`assertMode`, `homePath`/`sep`, the private-files `EPERM` refusal branch, the `real-dir` NUL path, the corrected teardown, and the restored strict diagnostics assertion at `EPERM` (`✔ a clear that cannot truncate the leaf still says so on one line`). The 20 skips: 5 were already there before this branch (`bench.sh` ×2, `the gate never runs git through a shell`, the two line-break backup names) and 15 are the named `win32` cases of class 5 and of the two races below, each with its reason in the report. **That job is still red after the suite**, at `Plugin lint`, and not because of a test: `scripts/lint-plugins.mjs` extracts a plugin tarball with GNU `tar`, which reads the `C:\` in `-C C:\…` as a remote host, so the plugin lint and the four plugin suites never start. Filed as #3296, outside this diff. ```text ##[group]Run node scripts/lint-plugins.mjs === pack-import plugins\project === tar (child): Cannot connect to C: resolve failed Error: Command failed: tar -xzf C:\Users\…\flybot-pack-…\flybot-project-0.1.0.tgz -C C:\Users\…\flybot-pack-… at packPlugin (file:///D:/a/FlyBot/FlyBot/scripts/lint-plugins.mjs:102:3) ``` For a green job on everything this diff does touch, the same probe workflow was dispatched once more with only those five plugin steps gated `runner.os != 'Windows'` — no test step changed, nothing under `core/` changed: run [44995172673](https://github.com/ThinkFlowLab/FlyBot/actions/runs/44995172673), job [137124567241](https://github.com/ThinkFlowLab/FlyBot/actions/runs/44995172673/job/137124567241) — green, same numbers (`3424 / 3404 / 0 / 20`, `duration_ms 73544.9057`). ## Two skips that name a product gap, not only a test shape The two races are skipped on win32 because the POSIX guarantee they prove cannot be built there — Windows refuses a `rename` onto a name another handle holds: - `#2724` `decisions-race.test.js` — two writers replacing one `decisions.jsonl` at the same instant: the second `record_decision` is refused (`EPERM`), so the case cannot run. - `#2762` `workflow-store.test.js` — a writer saving while a second process polls the file: the save is refused. On both platforms the caller is told (`a decision was not written`, the save's `ok: false`), so nothing is silently lost; but on Windows a save or a record can be *refused* where POSIX replaces the file unconditionally. That is a real platform difference that a test cannot paper over — it needs a product decision (a retry, or a lock around the replace) and is out of this issue's scope. Reported here instead of hidden. The memory case is the one place the test now asserts the Windows truth instead of skipping: `chmod 0400` sets the read-only attribute there, so the second `remember` is refused — the answer is checked to name the code it was refused with, the file must still hold the entry it had, and the file must still be narrow. Its POSIX half is unchanged. ## Linux evidence at the same tip Both `ubuntu` legs of the faithful run passed (`137123632247` node 22, `137123632343` node 24 · alpha.1): core `3424/3424`, social `758`, tree `152`, timeline `172`, workflow `544`, all `fail 0`, `skipped 0`. The probe loop also ran `node scripts/ds-bot-patches.mjs generate` on a real git checkout there and printed `git status --porcelain` after it: **empty**, i.e. the committed series is what generate writes — the same question `canonical` asks in the `package` job. ## Ran at this tip: ```text $ (cd core && node --import ./test/harness-resolve.mjs --test test/private-files.test.js test/decisions-race.test.js) # tests 11 / # pass 11 / # fail 0 $ (cd core && node --import ./test/harness-resolve.mjs --test test/workflow-store.test.js) # tests 32 / # pass 32 / # fail 0 $ (cd core && node --import ./test/harness-resolve.mjs --test test/diagnostics.test.js) # strict stderr array restored # tests 82 / # pass 82 / # fail 0 $ (cd core && node dev/harness/node_modules/oxlint/bin/oxlint -c .oxlintrc.json <the 13 changed test files>) Found 0 warnings and 0 errors. $ (cd core && node scripts/build-client.mjs --check) ; echo exit=$? exit=0 $ node scripts/ds-bot-patches.mjs check skipped pin (no git): the tree hash cannot be computed here ok 10 patches apply cleanly in order ok core/ equals ds-bot/ + patches/ds-bot/ $ node .github/scripts/changelog.mjs check changelog: 2 fragment(s) in changelog.d/ are well formed $ node .github/scripts/testing-layers.mjs --check testing-layers: every test file and every workflow is classified ``` The full suite on this machine (which has node 22 only — no git, no curl, no python3): `# tests 3424 / # pass 3420 / # fail 2 / # skipped 2`. Both failures are `check-arch-docs.test.js` and both are the missing `git` here; the untouched `main` tarball fails the same two, which is the control. Not run: `npm run verify` and `npm run arch-docs` as one command (no `git`/`origin/main` on this machine — `arch-docs` is answered by the runs above: `arch-docs: OK (28 changed file(s))`), `generate`/`canonical` locally (no git — answered by the empty `git status --porcelain` on the ubuntu leg and by `package`), the smoke test (tests only, no endpoint or start-up path), `ci:local` (no Mac), and the plugin suites on Windows (the job stops at `lint-plugins`, #3296). Tip `546a6f8c5679ea6ea366dd18027bff5267e846a3`, tree `b24433c5ddab6e1f77714795a1ea76bb3965eb6c`, base `5620b96ff7fa2ae08c6a25b48131f23235c0f1ae`. 28 files: 14 under `core/test/` and their mirror entries under `patches/ds-bot/`; no product file changed. Docs-not-needed: only `core/test/**` and the generated `patches/ds-bot/` mirror changed; no subsystem page owns these tests, no documented behavior changed, and the one product gap this run found is reported above rather than fixed. ## CI at this tip `tests-ok` green (`ubuntu-latest · Node 24 · DSH 0.2.0-rc.2`), `package` green — its `ds-bot-patches check` and `canonical` run on a real git checkout there, so the mirror is byte for byte what `generate` writes — `merge-gate`, `plugins (tree|social|timeline|workflow)` and `policy-sign` green (no gate file touched at this tip). `enqueue-guard` is red only for `no Verifier report names the tip`, which is the review, not a defect. ## Checkpoint <!-- flybot:checkpoint --> { "pr": 3294, "claim": "Dev", "issue": 3293, "summary": "The core suite goes from 54 Windows failures to 0, and this tip ran on windows-latest twice: 3424 tests, 3404 pass, 0 fail, 20 named skips. Teardown stops the host before removing its home, mode checks go through deniedCode and assertMode, children get file URLs, and only the shapes Windows cannot build are skipped by name and reason. The review's two items are answered: the strict stderr assertion is back (82/82) and the Windows leg is measured, not read. It still stops after the suite in scripts/lint-plugins.mjs (#3296), and that is not a test.", "files": [ "core/test/diagnostics.test.js", "core/test/platform.js", "core/test/private-files.test.js", "patches/ds-bot/0007-version-and-tooling.patch" ], "checks": { "ran": "nightly.yml at this tip on a scratch branch: windows-latest 3424 tests / 3404 pass / 0 fail / 20 skipped, twice (44994864729, 44995172673); diagnostics.test.js 82/82 with the strict assertion; ds-bot-patches check ok", "result": "green", "at": "546a6f8c5679ea6ea366dd18027bff5267e846a3" }, "next": "Reviewer re-review at 546a6f8; follow-ups #3295 (nightly.yml needs the arch-docs fetch step) and #3296 (lint-plugins tar on Windows)." } <!-- /flybot:checkpoint -->
1 parent 5620b96 commit 16473c0

28 files changed

Lines changed: 624 additions & 216 deletions

‎core/test/chat-anchors.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ async function start(t) {
8383
ctx.connection.fetch.register = (options) => { route = options; return register(options) }
8484
const rt = createRuntime(ctx, { home })
8585
provideFlyBot(ctx, rt.flybot)
86+
// The search reads the roster `rt.load()` fills; without waiting, Windows' slower start
87+
// answered the first case from no parts at all (#3293). Every later case ran after the load.
88+
await rt.load()
8689
t.after(async () => {
8790
await ctx.dispose()
8891
rmSync(home, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 })

‎core/test/chat-index-writers.test.js‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
// index this file already exercises holds the whole text, and the palette reaches it through
1010
// `searchHomeChat` and the channel's `chats.search` — answered with only the caller's chats.
1111
import assert from 'node:assert/strict'
12-
import { existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'
12+
import { existsSync, mkdtempSync, readFileSync, statSync, writeFileSync } from 'node:fs'
1313
import { hostname, tmpdir } from 'node:os'
1414
import { join } from 'node:path'
1515
import { DatabaseSync } from 'node:sqlite'
1616
import { test } from 'node:test'
1717
import { createRuntime, provideFlyBot } from '../index.js'
1818
import { fakeContext } from './fake-ctx.js'
1919
import { hashToken } from '../src/host/member-auth.js'
20+
import { cleanHome } from './temp-home.js'
2021

2122
const T0 = 1_760_000_000_000
2223
const INDEX = 'chat-index.sqlite'
@@ -89,9 +90,20 @@ const sharedSeed = () => ({
8990
const NEEDLE_LINE = 'x'.repeat(300) + ' NEEDLE'
9091
const turnStart = (seq, turn) => ({ type: 'turn/start', seq, time: T0 + seq * 1000, data: { turn } })
9192

93+
// One teardown per test: every host opened over the home is stopped (its SQLite handle and
94+
// read-only window closed) before the directory is removed. The other order is what Windows
95+
// answers with EPERM — the index file is still open when `rm` reaches it — so the removal
96+
// itself is the last step, not a retry that hides the live writer.
97+
const closers = new Map()
9298
const scratch = (t, name = 'ds-bot-index-') => {
9399
const home = mkdtempSync(join(tmpdir(), name))
94-
t.after(() => rmSync(home, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 }))
100+
const stops = []
101+
closers.set(home, stops)
102+
t.after(async () => {
103+
for (const stop of stops.splice(0)) await stop()
104+
closers.delete(home)
105+
cleanHome(home)
106+
})
95107
return home
96108
}
97109

@@ -171,12 +183,19 @@ async function start(t, home, { heldBy, gate, saved } = {}) {
171183
// parts, returns `{lines: []}` and never calls `sessionController.page()`, so the party
172184
// this test's gate waits for never arrives. Wait for the load the host relies on.
173185
await rt.load()
186+
let stopped = false
174187
const host = {
175188
home, ctx, rt, route, warnings, pages: () => pages,
176189
tool: (name, args, sessionId) => ctx.registeredTools.get(name).execute(args, { agent: { id: sessionId } }),
177-
stop: () => ctx.dispose(),
190+
stop: async () => {
191+
if (stopped) return
192+
stopped = true
193+
await ctx.dispose()
194+
},
178195
}
179-
t.after(() => host.stop())
196+
const stops = closers.get(home)
197+
if (stops === undefined) t.after(() => host.stop())
198+
else stops.push(() => host.stop())
180199
return host
181200
}
182201

‎core/test/decisions-race.test.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { tmpdir } from 'node:os'
1212
import { join } from 'node:path'
1313
import { test } from 'node:test'
1414
import { install } from '../src/host/decisions.js'
15+
import { win32 } from './platform.js'
1516

1617
const KEPT = 2_000
1718
const SITUATION = 'The Bot team in /data/example is open in another dsh (Web or Desktop, pid 4242). This window shows the team but cannot change it; close the other one and reload.'
@@ -52,7 +53,11 @@ const optionsOnDisk = path => readFileSync(path, 'utf8').split('\n').filter(Bool
5253
// Both writers trim, so both take the temp path the fixed name gave to every writer on the home.
5354
// Five pairs, because a single pair can meet or miss the collision window depending on timing: the
5455
// answer is that no pair of them fails, over the same log, one after the other.
55-
test('#2724: two writers on one home both record their decision, and no write fails on a shared temp name', async (t) => {
56+
// Windows is skipped, not weakened: its `rename` refuses to replace a file another writer is
57+
// replacing at the same instant, so two writers cannot both land and the case cannot be built there.
58+
test(`#2724: two writers on one home both record their decision, and no write fails on a shared temp name${win32 ? ' (skipped on Windows: two writers cannot replace one log at the same instant)' : ''}`, {
59+
skip: win32 ? 'Windows rename refuses to replace the target while another writer replaces it, so the second record_decision is refused; POSIX rename(2) replaces unconditionally' : undefined,
60+
}, async (t) => {
5661
const dir = home(t)
5762
const log = join(dir, 'decisions.jsonl')
5863
writeFileSync(log, seed())

0 commit comments

Comments
 (0)