#2974·gstack

/cso helper: run mutation lease validation rejects Windows NTFS inodes > 2^53, wedging all mutating commands

Author: alanportugalCreated Sep 25, 2026Updated Sep 25, 2026

/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 commit 636175d3), CSO helper {"version":"3.0.0","abi":3}
  • Windows 11 (10.0.26200), NTFS system volume
  • Helper built via ./setup from Git Bash (VS 2022 Build Tools, MSVC probe passes; bun 1.3.11)
  • Launcher itself works: gstack-cso-launcher.exe --version exits 0 and executes the core correctly

Evidence

  1. A lease decision recorded by the helper itself (from a stale lease, owner PID long dead):

    json
    {"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).

  2. Direct measurement on the state volume with bun:

    fs.lstatSync(newFile).ino        = 153403862307322300
    Number.isSafeInteger(thatValue)  = false

    This volume's NTFS file reference numbers are ~1.5e17 — roughly 17× above the safe-integer ceiling. Every newly created file gets one.

  3. 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 same UNSAFE_PATH error. So the failure is deterministic, not corruption from concurrent access.

Root cause

Producer (lib/cso/state.ts, ~line 564):

typescript
candidateDev: String(identity.dev), candidateIno: String(identity.ino)

Validator (lib/cso/state.ts, ~lines 335–336, inside validateLeaseDecision):

typescript
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 carry dev/ino as BigInt or decimal strings; and/or
  • In validateLeaseDecision and the identity comparisons, validate /^\d+$/ + compare as strings/BigInt rather than requiring Number.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):

  1. ./setup (CSO helper builds successfully; --version works)
  2. gstack-cso-launcher start --repo <any repo>
  3. Any subsequent mutating command (read, inspect, submit, finish), or a fresh start → 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.