Repository navigation
Commit c095314
committed
fix(tests): stop asserting POSIX modes Windows cannot produce
Six tests in the Codex write substrate assert `statSync(path).mode & 0o777`
equals 0600. On Windows that can never hold: `chmodSync` moves the read-only
flag and nothing else, so `statSync` keeps reporting 0o666 however the file was
written. Two of them fail on their own setup line, before reaching the behavior
they exist to check.
The restriction they are guarding is real, but on Windows it is an ACL rather
than a mode. All three call sites here reach it: the catalog writer hardens
through `hardenSecretPath`, the shared claim through `hardenSecretPathAsync`,
and the DSH settings write through `atomicWriteFile`, which the journal header
already describes as "0600 plus Windows ACL hardening". So the assertion is
scoped to the platform whose semantics it is written in, and the ACL half stays
where it can be observed, in tests/windows-secret-acl.test.ts.
Scoping alone would have weakened the catalog-writer cases, which is where the
mode was the only evidence that the writer restricted anything. Those now assert
the `harden:` effect instead — the half of the contract that holds on every
platform, and a stricter check than the mode was: deleting `io.harden` from
`publishCatalogBackup` and `atomicWriteFile` turns all four red, while the old
mode assertion could not see that regression on Windows at all.
`native-main-claim` is skipped rather than scoped because its own comment
already states the split — "On POSIX that is the mode; the Windows branch is
proven separately" — and every line of it, setup included, is written in mode
terms.
One neighbouring failure is deliberately left alone. `codex-transition-state`'s
"a coordinator found group-readable is narrowed back to owner-only" fails the
same way, but `src/codex/transition-state.ts` does not import
`windows-secret-acl` at all — nor do `catalog-write-serialization.ts` or
`history-lock.ts`, which carry the same `/* Windows applies ACLs in WP11. */`
comment on a bare `chmodSync`. If that work is still outstanding, those
coordinator databases are genuinely not narrowed on Windows and the red test is
honest signal, not a platform artifact. Silencing it would have hidden that.
Measured on Windows 11 against dev:
- tests/codex-catalog-writer.test.ts: 5 pass/4 fail -> 9 pass/0 fail
- the ten files carrying mode assertions: 171 pass/5 fail -> 172 pass/3 fail
Refs #10591 parent 02da6cc commit c095314
3 files changed
Lines changed: 30 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
241 | 255 | | |
242 | 256 | | |
243 | 257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
171 | 179 | | |
172 | 180 | | |
173 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
172 | 177 | | |
173 | | - | |
| 178 | + | |
174 | 179 | | |
175 | 180 | | |
176 | 181 | | |
| |||
0 commit comments