/cso helper: run mutation lease validation rejects Windows NTFS inodes > 2^53, wedging all mutating commands
/cso helper: run mutation lease validation rejects Windows NTFS inodes > 2^53, wedging all mutating commands
Summary
On Windows, every mutating gstack-cso helper command (start, read, inspect, resume, submit, finish) fails deterministically with:
{"ok":false,"error":{"code":"UNSAFE_PATH","message":"Run mutation lease decision is malformed"}}or, on other paths:
{"ok":false,"error":{"code":"PERSISTENCE_FAILED","message":"Run mutation lease decision changed before cleanup"}}The cause is the lease decision validator in lib/cso/state.ts: it requires the candidate lock file's dev/ino to pass Number.isSafeInteger(Number(...)). NTFS issues 64-bit file reference numbers that routinely exceed Number.MAX_SAFE_INTEGER (2^53 − 1), so validation fails closed on affected volumes and the run mutation lease can never be taken.
Environment
- gstack
1.87.6.0(skills checkout commit636175d3), CSO helper{"version":"3.0.0","abi":3} - Windows 11 (10.0.26200), NTFS system volume
- Helper built via
./setupfrom Git Bash (VS 2022 Build Tools, MSVC probe passes; bun 1.3.11) - Launcher itself works:
gstack-cso-launcher.exe --versionexits 0 and executes the core correctly
Evidence
A lease decision recorded by the helper itself (from a stale lease, owner PID long dead):
{"schemaVersion":1,"kind":"ticket","ticket":"0000000000000001","candidateDev":"33913025","candidateIno":"9288674232468104","ownerPid":40092,...}candidateIno= 9,288,674,232,468,104 >Number.MAX_SAFE_INTEGER(9,007,199,254,740,991).Direct measurement on the state volume with bun:
fs.lstatSync(newFile).ino = 153403862307322300 Number.isSafeInteger(thatValue) = falseThis volume's NTFS file reference numbers are ~1.5e17 — roughly 17× above the safe-integer ceiling. Every newly created file gets one.
After clearing all stale lease artifacts (stale lease from a dead PID was not reclaimed automatically — secondary observation), a fresh
gstack-cso-launcher start --repo <different-repo>against a pristine state tree still fails with the sameUNSAFE_PATHerror. So the failure is deterministic, not corruption from concurrent access.
Root cause
Producer (lib/cso/state.ts, ~line 564):
candidateDev: String(identity.dev), candidateIno: String(identity.ino)Validator (lib/cso/state.ts, ~lines 335–336, inside validateLeaseDecision):
typeof decision.candidateDev!=='string' || !/^\d+$/.test(decision.candidateDev) || !Number.isSafeInteger(Number(decision.candidateDev)) ||
typeof decision.candidateIno!=='string' || !/^\d+$/.test(decision.candidateIno) || !Number.isSafeInteger(Number(decision.candidateIno)) ||The wire format already carries dev/ino as decimal strings, but the validator round-trips them through Number and demands safe-integer range. On NTFS, fs.Stats.ino is a 64-bit file reference number; large, long-lived volumes exceed 2^53, so Number.isSafeInteger is false and the validator throws UNSAFE_PATH ("Run mutation lease decision is malformed") on every lease acquisition. (The same numeric assumption likely needs review anywhere else dev/ino are compared as JS numbers across the lease code, e.g. readOwner / identity comparisons.)
Note: Number conversion also rounds (153403862307322300 is already an approximation of the true 64-bit value), though rounding is deterministic per value, so equality comparisons still hold across processes — the hard failure is the safe-integer gate, not precision.
Suggested fix
Compare dev/ino as exact 64-bit values end-to-end instead of Number:
- Stat with
fs.lstatSync(path, { bigint: true })(or equivalent) and carrydev/inoasBigIntor decimal strings; and/or - In
validateLeaseDecisionand the identity comparisons, validate/^\d+$/+ compare as strings/BigInt rather than requiringNumber.isSafeInteger.
Repro
On a Windows 11 machine whose NTFS volume issues file reference numbers > 2^53 (check with fs.lstatSync(path).ino on a newly created file):
./setup(CSO helper builds successfully;--versionworks)gstack-cso-launcher start --repo <any repo>- Any subsequent mutating command (
read,inspect,submit,finish), or a freshstart→UNSAFE_PATH: Run mutation lease decision is malformed
Impact
/cso is entirely unusable for audits on affected Windows machines: the launcher and core execute fine, but no run can be created or mutated, so the skill can only report not assessed. Static-only Windows hosts (the documented configuration) are exactly the ones that need the helper's state writes to work.
Source: garrytan/gstack