Repository navigation
Proposal: Fix Win32 FlushFileBuffers EPERM failure in transaction copyTree (SEC-WIN-001) #2400
Closed
KatkamKoushik
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Context & Note
Problem Statement
During an exhaustive Windows runtime audit of
sickn33/agentic-awesome-skillsagainst upstreammainat commit12c0d66d3c007b8109edb0e7211812119be09d84(v20.11.0), executing the AAS v1 transaction test suite on Windows reproduces 6 test failures:Observed Test Failure Output:
In total, 6 core transaction lifecycle tests fail with
AAS_TRANSACTION_APPLY_ROLLED_BACKcaused byEPERM: operation not permitted, fsyncinsidecopyTree:apply commits managed state last, preserves unmanaged bytes, and is idempotenta post-commit cleanup failure is surfaced and completed by approved recoveryalreadyApplied verifies final bytes and refuses a completed state with drift or recovery artifactstarget lock is held before materialization and preflight, preventing concurrent stale plansmanaged local edits block unless the immutable plan carries an explicit backed-up overridefault after promotion rolls back bytes and requires approved cleanup before reuseRoot Cause Analysis
In
tools/lib/aas-v1/transaction/runtime.js:371-372,copyTreecreates a new file and prepares to sync its contents:On Windows, Node's
fs.fsyncSync(descriptor)delegates to the Win32 APIFlushFileBuffers(HANDLE hFile). The official Microsoft documentation states:Because
fs.openSyncspecifiesfs.constants.O_RDONLY, the underlying file handle lacksGENERIC_WRITE. On Windows, this raises Win32 error code 5 (ERROR_ACCESS_DENIED), which libuv translates toEPERM: operation not permitted, fsync.Proposed Minimal Patch
Modify
tools/lib/aas-v1/transaction/runtime.js:371to open the file descriptor withO_RDWR:Validation & Test Evidence
1. Executed Windows Test Suite (
aas_v1_transaction.test.js)We evaluated the patch in an isolated local worktree on Windows against commit
12c0d66d3c007b8109edb0e7211812119be09d84:fsyncSyncEPERMincopyTree(tests 2, 3, 12, 14, 15, 16)tree digest is deterministic and rejects symlinksat line 144)layout cleanup postcondition detects a dangling symlink artifactat line 351 (skipped with# symlink unavailable: EPERM)copyTreefsyncSyncfailures are resolved.2. Linux / POSIX Compatibility Analysis (Static & Spec Analysis)
On Linux and macOS, POSIX
fsync(int fd)functions on any valid file descriptor regardless of whether it was opened withO_WRONLYorO_RDWR. Because the file was just created viacopyFileSyncwith permissions0600, the current process is the owner with full read/write rights. Live Linux test execution was not conducted in this session; this evaluation is based on standard POSIX specification analysis.3. Expected Boundary Behaviors (Unexecuted Expectations)
copyFileSyncis expected to throwENOENTprior to reachingopenSync.copyFileSyncis expected to throwEACCESbefore descriptor opening.try...finallyblock guaranteesfs.closeSync(descriptor)executes even iffsyncSyncraises an exception.4. Remaining Test Gaps
fs.constants.O_RDWRmight fail duringopenSyncremain unverified.Reason for Maintainer Sponsorship
Under
workflow-contract.jsand repository policy (CONTRIBUTING.md),tools/lib/aas-v1/**is classified as a protected core runtime path. Ordinary fork pull requests cannot modify runtime tooling.We respectfully submit this finding and reproduction for maintainer review, and request an owner-sponsored PR through the documented intake process to land this fix into upstream
main.All reactions