Repository navigation
fs: treat std::errc::permission_denied as EPERM error - #64698
Merged
nodejs-github-bot merged 2 commits intoAug 20, 2026
Merged
Conversation
jasnell
reviewed
Jul 23, 2026
jasnell
reviewed
Jul 23, 2026
jasnell
approved these changes
Jul 23, 2026
PickBas
force-pushed
the
win-rmsync-eperm-retry-test
branch
from
July 23, 2026 13:23
092d380 to
b5441d9
Compare
jasnell
approved these changes
Jul 23, 2026
PickBas
force-pushed
the
win-rmsync-eperm-retry-test
branch
2 times, most recently
from
July 23, 2026 13:39
977185e to
7cf7983
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64698 +/- ##
==========================================
- Coverage 90.29% 90.28% -0.01%
==========================================
Files 759 759
Lines 247754 247754
Branches 46721 46718 -3
==========================================
- Hits 223708 223694 -14
+ Misses 15521 15518 -3
- Partials 8525 8542 +17
🚀 New features to boost your workflow:
|
PickBas
force-pushed
the
win-rmsync-eperm-retry-test
branch
from
July 24, 2026 08:40
7cf7983 to
ab0dc83
Compare
StefanStojanovic
approved these changes
Jul 28, 2026
Collaborator
Collaborator
Collaborator
In the thrown exception, `std::errc::permission_denied` is already treated as an `EPERM` error, but it is not included in one of the omittable errors when retrying the `RmSync` operation. This commit includes it. This also fixes the `retryDelay` calculation on Windows where the `retryDelay` is divided by `1000` but the win32's `Sleep` function takes the argument as an `ms` unit, dividing the supplied `ms` unit further to a much smaller delay. Signed-off-by: louiellan <louie.lou.llaneta@gmail.com>
Fixes: nodejs#64016 Signed-off-by: PickBas <sayed.kirill@gmail.com>
PickBas
force-pushed
the
win-rmsync-eperm-retry-test
branch
from
August 6, 2026 11:37
ab0dc83 to
abb551f
Compare
StefanStojanovic
approved these changes
Aug 6, 2026
Contributor
|
@jasnell can you reapprove this? GH says |
jasnell
approved these changes
Aug 17, 2026
Collaborator
This comment was marked as duplicate.
This comment was marked as duplicate.
Collaborator
Collaborator
|
Landed in 5a9fd82 |
aduh95
pushed a commit
that referenced
this pull request
Aug 25, 2026
In the thrown exception, `std::errc::permission_denied` is already treated as an `EPERM` error, but it is not included in one of the omittable errors when retrying the `RmSync` operation. This commit includes it. This also fixes the `retryDelay` calculation on Windows where the `retryDelay` is divided by `1000` but the win32's `Sleep` function takes the argument as an `ms` unit, dividing the supplied `ms` unit further to a much smaller delay. Signed-off-by: louiellan <louie.lou.llaneta@gmail.com> PR-URL: #64698 Fixes: #64016 Refs: #64017 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
aduh95
pushed a commit
that referenced
this pull request
Aug 25, 2026
In the thrown exception, `std::errc::permission_denied` is already treated as an `EPERM` error, but it is not included in one of the omittable errors when retrying the `RmSync` operation. This commit includes it. This also fixes the `retryDelay` calculation on Windows where the `retryDelay` is divided by `1000` but the win32's `Sleep` function takes the argument as an `ms` unit, dividing the supplied `ms` unit further to a much smaller delay. Signed-off-by: louiellan <louie.lou.llaneta@gmail.com> PR-URL: #64698 Fixes: #64016 Refs: #64017 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
aduh95
pushed a commit
that referenced
this pull request
Aug 27, 2026
In the thrown exception, `std::errc::permission_denied` is already treated as an `EPERM` error, but it is not included in one of the omittable errors when retrying the `RmSync` operation. This commit includes it. This also fixes the `retryDelay` calculation on Windows where the `retryDelay` is divided by `1000` but the win32's `Sleep` function takes the argument as an `ms` unit, dividing the supplied `ms` unit further to a much smaller delay. Signed-off-by: louiellan <louie.lou.llaneta@gmail.com> PR-URL: #64698 Fixes: #64016 Refs: #64017 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
aduh95
pushed a commit
that referenced
this pull request
Sep 7, 2026
In the thrown exception, `std::errc::permission_denied` is already treated as an `EPERM` error, but it is not included in one of the omittable errors when retrying the `RmSync` operation. This commit includes it. This also fixes the `retryDelay` calculation on Windows where the `retryDelay` is divided by `1000` but the win32's `Sleep` function takes the argument as an `ms` unit, dividing the supplied `ms` unit further to a much smaller delay. Signed-off-by: louiellan <louie.lou.llaneta@gmail.com> PR-URL: #64698 Fixes: #64016 Refs: #64017 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
aduh95
pushed a commit
that referenced
this pull request
Sep 7, 2026
In the thrown exception, `std::errc::permission_denied` is already treated as an `EPERM` error, but it is not included in one of the omittable errors when retrying the `RmSync` operation. This commit includes it. This also fixes the `retryDelay` calculation on Windows where the `retryDelay` is divided by `1000` but the win32's `Sleep` function takes the argument as an `ms` unit, dividing the supplied `ms` unit further to a much smaller delay. Signed-off-by: louiellan <louie.lou.llaneta@gmail.com> PR-URL: #64698 Fixes: #64016 Refs: #64017 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
ken-jo
added a commit
to ken-jo/ave
that referenced
this pull request
Oct 24, 2026
radix-ui 1.5+ ships @radix-ui/react-slot 1.2.5, whose stable ref callbacks stop the extra re-render that used to cover the workspace tree's async load. The ChatSidePanel keyboard tests now wait for the initial tab stop before they send keys, and also assert real DOM focus. Electron 44.9 embeds Node 24.22, and since Node 24.21 rmSync honors its retry budget on Windows EPERM (nodejs/node#64698). The foreign-lock test now holds the lock for the whole retry window. It asserts that the locked tree survives, not that the removal fails within 200 ms. Its fixture waits for the child's explicit "locked" signal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks done
YishenTu
added a commit
to YishenTu/claudian
that referenced
this pull request
Nov 12, 2026
Node 24's native rmSync does not retry std::errc::permission_denied and truncates the Windows retry sleep to ~0ms (fixed upstream in nodejs/node#64698), so maxRetries/retryDelay never covered the briefly locked copied node.exe. Async rm retries EPERM with real backoff.
6 of 10 tasks
davgor
added a commit
to davgor/DarkMechanicus
that referenced
this pull request
Nov 25, 2026
…ving its scratch folder - Unawaited git that the code under test starts (the record-status background git status, Forge reads) could outlive a forgeService fixture. - On Windows a running git holds the scratch folder. Since Node 24.22 (nodejs/node#64698), rmSync really sleeps between its EPERM retries, so removeScratch blocked the event loop for up to 21 s. On CI (Node 24.22.3) three tests ran 15-19 s and timed out. - The fixture now tracks every git run (the runner's onExit, and the workspace's git adapter), and close() waits until all have exited.
davgor
added a commit
to davgor/DarkMechanicus
that referenced
this pull request
Nov 26, 2026
…ving its scratch folder - Unawaited git that the code under test starts (the record-status background git status, Forge reads) could outlive a forgeService fixture. - On Windows a running git holds the scratch folder. Since Node 24.22 (nodejs/node#64698), rmSync really sleeps between its EPERM retries, so removeScratch blocked the event loop for up to 21 s. On CI (Node 24.22.3) three tests ran 15-19 s and timed out. - The fixture now tracks every git run (the runner's onExit, and the workspace's git adapter), and close() waits until all have exited.
davgor
added a commit
to davgor/DarkMechanicus
that referenced
this pull request
Nov 26, 2026
* DM-965: Stop the Skitarii extension from piling up get_project CLI calls - projectStandards: one in-flight get_project shared by every context event, a 60 s cache of the last successful read, and a fallback to a successful read under 10 minutes old when a refresh fails; injected text and shape unchanged. - dmClient: run() takes an optional absolute lifetimeMs that writer-contention renewals never extend; the standards read uses 30 s, agent dm_call keeps DM_RUN_LIMITS unchanged. - worldMessaging: project clients pass run options through. - Tests: 20-event single flight and 60 s cache, stale-on-failure, and a DM_WRITER_BUSY child killed at the 30 s lifetime. * perf(storage): serve record-file git status from a stamp-keyed cache (DM-966) getStorageStatus now returns the uncommitted record-file count from a per-workspace cache keyed by the index stamp and HEAD, refreshing it in the background when they change or it is older than 10 s; only the first call waits for git. Adds GitAdapter.indexStamp. * DM-959: add Db write-lock hold observer and slow workspace operation log - OpenDatabaseOptions.onTransaction reports each depth-0 write transaction (tag, outcome, acquireMs, holdMs); default none, no timing - tagTransactions(reconcile|flush|command) attributes holds via AsyncLocalStorage only while an observed connection is open - Workspace tags reconcile, flush and command execution; desktop pool logs operations over 1 s with name, queue wait and run ms * Show a validated Forge member at once during its reconcile, with a Syncing badge (DM-967) - forgeService: before a member reconciles, ask its owner (queued ahead of the reconcile) whether the local database holds a validated import (hasValidatedRepositoryCache); if so and the identity still matches, mark it prepared, so memberStatus reports ready + syncing while the reconcile runs. A member with no local import keeps today's gate. - workspaceOperations: add the read-only hasValidatedCache owner operation; workspaceOwnerRuntime defers the open-time import for it like reconcileMember. - ForgeOpen: a ready + syncing member renders its view under a small 'Syncing…' badge in the forge-status bar. - Tests: restart scenario and cold gate in forgeService.test.ts; badge states in ForgeOpen.test.tsx; test pool fixture opens member stores like the production owner. * DM-960: git diffPaths/statusPaths, trackedChanges, reconcile marker meta keys * feat(db): schema v30 adds outbox.next_attempt_at for flush backoff (DM-964) * perf(finalizer): stage record files outside the write lock and back off failed exports (DM-964) Each repo-mode outbox entry is planned in a read transaction (a save is previewed and rolled back), its temp files are written, fsynced and read back under local/staging/ without the write lock, and one short BEGIN IMMEDIATE re-runs the export, requires the same changes, renames the temps into place pointer last, records the export and completes the entry. A change committed meanwhile drops the temps and leaves the entry pending. Failed entries get next_attempt_at (15 s doubling, 5 min cap); safeFlush honors it, an explicit flush ignores it. * DM-963: Schedule reconcile on a per-project sync lane in the workspace pool At most one lane reconcile runs per project with one pending; heartbeats join the pending one and skip within 15 s of the last. Background admission never retires an owner that served a foreground request in the last 60 s. Untrack drops the pending reconcile, waits for the running one and fences its late result. * test(flush): cover db-mode backoff and adapt workspace tests to staged renames and backoff (DM-964) * docs(architecture): describe staged flush and outbox backoff (DM-964) * test(flush): flush_portable_state retries an export still in its backoff (DM-964) * DM-959: add revamp mode to the Forge performance harness - Plan view, ticket panel and Kanban board loads idle and during a changed-epic sync plus heartbeat, via the production renderer load functions over IPC - CDP click-to-paint split into pool queue wait, utility run, IPC payload bytes and render time; real-store temp copy via read-only VACUUM INTO - Write-lock holds by caller and unchanged-reconcile counters from the Db hold observer; built-CLI wall times and 12 agents for 60 s counted by error code - Sink tests for latency, outcome, hold and CPU records * DM-963: Reconcile on a worker-thread sync lane inside the project utility Forge member, heartbeat and open-time reconciles, and the explicit reconcile_repository command, run on the owner's sync lane: a worker_threads Worker with its own SQLite connection. The owner admits each lane reconcile on its queue (binding, session, capability), keeps serving reads and writes while the lane imports, and finishes it on its queue (binding re-check, flush). Heartbeat and member reconciles keep DM-957's fingerprint gate; the explicit reconcile stays ungated and full. Close waits for the lane before closing the owner's connection; store-moving work waits for the lane and releases its connection first. * DM-960: statusPaths reports branch; gitChanges, meta and git adapter tests * DM-963: Let a blocked lane reconcile open one process beyond the screen's slots With both owners protected by recent foreground use (as during a Forge conversion), a member reconcile waited 60 s for the protection to lapse and forgeService force-recovery tests timed out. Background work now opens the one process beyond the two screen slots instead of waiting, and still never retires an owner the screen used in the last 60 s. Foreground admission retires the least recently used idle owner. Splits pool methods for the complexity limit. * DM-959: fix the revamp harness's native click-to-paint and add a smoke scale - Reload the shell before click to paint so a picked folder is listed, and reveal the epic row by its imported title (read via getEpic), expanding collapsed buckets until it shows. - Hit-test click targets (the sidebar footer overlays lower rows) and scroll them into view. - Keep the occluded profiler window producing frames (Chromium occlusion/backgrounding off). - Bound each paint wait at 30 s and report what the page shows when it fails. - DM_REVAMP_SMOKE=1: 100-ticket fixture, 3 samples, a 10 s agent run. * DM-959: pass a click to timedClick as one object (oxlint max-params) * DM-959: click only ticket nodes a click reaches (header overlays the graph edge) * DM-960: split status parser and trackedChanges for lint limits; test describes split * DM-959: reinstall the renderer liveness sink after click to paint reloads the shell The first full revamp run failed on the second fixture: its cold-open liveness probe called window.dmPerfRead, which the previous fixture's renderer reloads had dropped. * DM-959: record the performance-revamp baseline Full revamp matrix (100/1,000/10,000-ticket fixtures and a temp copy of the DarkMechanicus store) measured at 2065b5b = epic start 4d3486b plus instrumentation and harness only. * DM-963: Measure the sync lane with the revamp harness and add a packaged-build probe - Harness taps name the lane's explicit sync reconcileRepository; a cold open lasts until the epics are listed (the import runs on the lane); a sync sample starts from a settled lane so the trailing heartbeat cannot import its change. - revamp-DM-963.jsonl: full revamp matrix at 29fd146. 10,000 tickets during a changed-epic sync, p95 plan 86.1 / ticket 27.6 / Kanban 18.2 ms (baseline 484.4 / 465.8 / 442.9); 30/30 syncs imported the change. - scripts/sync-lane-probe.mjs drives a packaged build over CDP with a private profile and homes. - architecture.md: the desktop sync lane. * DM-963: Record the packaged-build GO for the worker-thread sync lane sync-lane-probe-DM-963.jsonl: electron-builder --win --dir of 3ad59e1 (Electron 42.11.18, app.asar with out/main/syncLaneWorker.js), private profile and homes, 10,000-ticket fixture. 120/120 explicit reconciles succeeded in the packaged app; every plan, ticket, Kanban load and card creation finished while one was running. p95 during sync: plan 49, ticket 15, Kanban 8, card creation 116 ms. Verdict GO: no second utility process is needed. * DM-961: targeted reconcile scope, marker write, recheck from the database; sync git path queries * fix(finalizer): put replaced files back inside the commit transaction (DM-964) A rename or completion failure now restores the tracked files before the transaction rolls back, while BEGIN IMMEDIATE is still held, so another process exporting the same entry cannot commit in between and be overwritten. Only a failing COMMIT restores after the lock. recordFailure leaves an entry another process completed meanwhile done. Test: a second connection flushes the entry the moment the first one's write transaction ends. * DM-969: open an epic in one parallel round and skip an unchanged draft The workspace load reads the epic, then everything else whose input is known in one parallel round; only the checkpoint and a pinned revision wait for the run. A draft equal to the saved plan (draftChanged false) is not read unless the draft view is shown or chosen; View draft reads it on demand. * DM-969: View draft reads a skipped draft without reloading; editor tests wait for the draft The on-demand draft read is a read: it marks the workspace busy but does not reload. Tests that open the editor after View draft wait for the Draft view, which now arrives after its read. * DM-969: optional ticketId filter on listEvents; History tab reads only its ticket listEvents takes an optional ticketId (schema, service, domain API); without it a read is unchanged. The ticket History tab pages listEvents {epicId, ticketId} instead of the whole epic log. No index: on the real store copy the query uses events_epic (epic_id=? AND seq>?) and reads 217 of 4,180 events in 0.6 ms. * DM-961: importer.targeted tests (equivalence seeds, counting FsAdapter, fallback, conflict/rejection recheck); lint splits; cached work-tree prefix * DM-961: storage-migration child git fake answers statusPaths * DM-961: reconcileScope unit tests; document unsettled paths in reconcile_dirty_paths * DM-969: owner identity reuses an unchanged project.json and binding by file stamp identity() still realpaths the folder, stats it and the database (hard links), resolves the storage mode and checks containment on every request. It reuses the parsed project id and the Forge binding epoch while each file's stamp (size, mtime, ctime, device, inode) is unchanged and was not written in the last 2 s (racy-stamp rule); a stamp that moves during the read is not kept. * DM-961: c3 built-CLI list_kanban_cards rows on the 10,000-ticket fixture * DM-969: record before/after click-to-paint and view-load measurements * fix(flush): a reconcile that imports an entry's records releases its backoff (DM-964) reconcileRepository clears next_attempt_at, in its own transaction, for every waiting entry whose epic, run, comment, profile or card it imported, and for every waiting entry once it acknowledges a branch change. A condition failure the reconcile clears (records not in this checkout, unimported records) is then retried by the reconcile's own scheduled flush and no longer holds back later records. Records found unchanged keep their backoff. comments.test.ts is restored to its original guarantee: the reconcile after checking the epic's branch out again exports the waiting comment. * DM-962: guardTransactions checks the Forge binding at depth 0 only * DM-962: test guardTransactions checks only at depth 0 * perf(finalizer): commit checks staged files instead of re-running the export; re-stage on a concurrent write (DM-964) Staging runs in a read transaction only; the preview write transaction is gone. A save stages its state from previewSavedRevision (title, new backlog tickets, pinned standards, read-only) and runs completeSavedRevision once, at the commit. The snapshot record and text are built once per entry (staging) and reused at the commit; a snapshot file staging found holding the revision is not read again while its stamp is unchanged. Image bytes are loaded, sha256-checked and written only at staging (listing queries no longer select the blob); an image already in place is checked by stamp at the commit. The commit collects the entry's changes again from the current rows and requires each write to be staged with the same content. When a concurrent write changed them, it stages exactly the changed files and commits again, at most twice more, so a race never surfaces as pending/save_pending; past that the entry stays pending without an error for the next flush. * DM-963: Admit a lane sync whole under the request's Forge authority (B1) admitSync opened the session (ctx(), isInitialized()) and started the lane outside withForgeOwnerAuthority, so a conversion's explicit source reconcile and a forced conversion's member sync failed the transfer-idle check. The whole admission now runs under the request's authority. The runtime test helper now delivers requests without the sender's async context, as a utility does, and a test drives explicit and member syncs through serveWorkspaceOwner under a live move reservation. * DM-963: Keep a failed lane reconcile from rejecting the owner's tracking copy (M2) this.syncing was reconciled.finally(...), a second promise that rejected unhandled whenever the lane failed with no close or exclusive job awaiting it, which can stop the utility. It now settles without rejecting. A test fails a lane reconcile through serveWorkspaceOwner: the sync replies with the error, no unhandled rejection occurs, and the owner keeps serving. * perf(plans): index a saved revision's tickets with one search-index DELETE; test the 1,000-ticket save hold (DM-964) Profiling the commit of a 1,000-ticket epic save with the hold observer showed 216 ms held, 201 ms of it in indexRevision: FTS5 cannot index doc_id, so each per-ticket DELETE scanned the whole index. indexDocuments deletes every ticket document of the revision in one statement (json_each), then inserts each; the hold drops to about 30 ms. finalizer.test.ts: a 1,000-ticket save on a file database with the DM-959 observer (openDatabase onTransaction, tagTransactions('flush')) and the real completeSavedRevision/previewSavedRevision hooks commits in one write transaction, runs the hook once, holds for less than one 200 ms fsync, and no write, fsync or temp read-back happens inside it. * DM-963: Carry a joining request's reservation, skip heartbeats while a reconcile runs, and treat the screen's reconcile as foreground (M1, m1, m2) One commit because the three fixes change the same requestSync, lane job and admission code. - M1: a request joining the pending reconcile carries its Forge transfer authority into it, so a conversion's reconcile that joins a heartbeat queued outside the conversion runs under the reservation. Test: a member reconcile pending behind the open-time one, joined by an explicit reconcile under a reservation, runs with that reservation's lease (fails without the fix). - m1: a heartbeat with nothing to join is skipped while a reconcile runs, as well as within 15 s of the last. The coalescing test now asserts 5 heartbeats during a run queue nothing, and requests with waiters still coalesce into one pending reconcile. - m2: the screen's reconcileRepository (not the background client's) makes its lane job foreground. It is admitted through foreground admission, sets usedAt and holds the idle deadline off, and is logged as 'command reconcileRepository' when slow. Test: it takes a screen slot by retiring the LRU idle owner (never a third process), logs when slow, and is then protected from background retirement. * docs(architecture): describe the check-only commit, in-lock restore, re-stage and backoff release (DM-964) * docs(reports): DM-964 revamp harness run on d33e507 (flush write-lock holds) * DM-963: Observe the sync lane's write-lock holds and under-lock re-prepares in the revamp harness (m4) The lane tags its reconcile 'reconcile' (DM-959's tagTransactions). With DM_LANE_OBSERVE_FILE set (measurement only; unset, nothing is observed), it opens its connection with onTransaction and counts the file bodies each reconcile reads before and under its writer lock; a read under the lock means the lock-free preparation was re-run inside the transaction. The harness sets the variable and reports, per view-during-sync row and for the 12-agent CLI stage, the lane's holds by caller, its reconciles by mode, and how many re-prepared under the lock. * fix(finalizer): a repo flush removes staged temps of processes that died before their commit (DM-964) Temps are named after the staging process id; at flush start, entries under local/staging/ whose process is no longer running are removed (EPERM counts as running). A live process's temps, this one's included, stay. Best effort. * DM-963: Revamp harness rows with lane holds after the review fixes Full matrix at f27dadd (sprint 3a46602 merged), exit 0. 10,000 tickets during a changed-epic sync, end-to-end p95: plan 73.6, ticket 19.6, Kanban 15.8 ms (baseline 484.4 / 465.8 / 442.9). Every explicit lane reconcile re-prepared under the writer lock (30/30 per row); lane reconcile hold p95 333-420 ms on 10k (baseline owner changed-epic hold 104 ms). 12-agent CLI stage: 115 calls, all ok (baseline 221); lane reconcile hold p95 1.35 s, acquire max 1.94 s; host CPU mean 61% (baseline 46%). * perf(reconcile): read and verify observations, recovered archives and attachment images before the writer lock; apply each in its own short transaction (DM-962) * perf(agent-mail): fence a mailbox poll once per transaction; run the thousand-poll test in its own group - A mailbox poll checked the Forge/storage fence 9 times (117 of its 120 fs calls): on every nested savepoint and on each ctx() inside its own fenced transaction. Its guard now fires only at depth 0 (guardTransactions 'outermost'), and executePoll gives the command's ctx() the store it already required. Ordinary sessions still check on every transaction. - Per poll alone (memoryFs harness, 1000 polls): 4.0-6.4 ms before, 3.0 ms after; fence checks 9 -> 2. - The rest of the cost is opening the WAL connection: under the broad run's parallel filesystem load a bare node:sqlite open costs 10.6 ms against 2.4 ms alone. agentMail.test.ts therefore runs in its own vitest project (mail-poll-load, maxWorkers 1, groupOrder 3). Test body, assertions, poll count and timeout unchanged. * perf(reconcile): a reconcile that would change nothing takes no write transaction (DM-962 c1) Decided in a read snapshot after prepare: nothing staged, no conflict to store or clear, no observation, recovered archive or attachment image to apply, the problems digest, validated-cache proof, marker and fingerprint already as an apply would leave them. last_reconcile_at stays persisted and only advances inside a write, so reconcileScope's export window only grows (safe). * refactor(reconcile): split the no-op check to keep each function under the complexity limit (DM-962) * perf(reconcile): check each planned record's own state under the lock, not the database revision; re-prepare outside the lock (DM-962 step 2a) A commit by another connection to an unrelated row no longer re-runs the whole prepare under BEGIN IMMEDIATE. Prepare reads its files and the stamps of the records it plans (sync_state, pending exports, open transfer and pending revisions) in one read snapshot (recordGuard.ts). Under the lock: HEAD, the files read and those stamps must hold; otherwise the lock is released and prepare runs again outside it, at most twice, before a last prepare under the lock. databaseRevision is gone. * perf(reconcile): apply each changed epic, run and Kanban card in its own short transaction (DM-962 step 2b) Each record's depth-0 BEGIN IMMEDIATE first checks HEAD, the record's own files and its stamp (sync_state, pending exports, transfer); a record another connection moved writes nothing and is prepared again alone, outside the lock, at most twice, then left unsettled for the next reconcile. Epics before runs; a run or comment of a stale epic waits with it. Observation folders, recovered archives and attachment images are read in the prepare snapshot; attachments are registered with the record that names them. One final short transaction stores conflicts, pauses runs on a branch change, records one repository.reconciled event with every changed epic, advances the marker and releases backoff. * test(reconcile): atomicity mid-epic and the 1,000-ticket changed-epic holds (DM-962 c2 c4) A failure while applying epic 2 of 3 leaves it all-old (row, sync record, statuses), commits 1 and 3, reports the rejection, and records one repository.reconciled event listing 1 and 3. A changed 1,000-ticket epic applies in two short transactions (the epic, then the finish). * perf(reconcile): check the checkout by project.json's stamp, not its body, under the lock; count lane body reads only inside write transactions (DM-962) A record transaction re-read project.json to rebuild the checkout identity; it now compares the prepared project and the file's observed stamp, so no file body is read under the writer lock. The sync lane's under-lock read counter counted reads in prepare's read snapshot as locked. * docs(perf): DM-962 revamp harness rows: lane re-prepares under lock 0 (was 19), lane reconcile hold max 56.9 ms (was 1347), 10k changed-epic hold max 33.8 ms (baseline 276.9), unchanged explicit reconcile 0 write tx * Drop dead exports flagged by ts-prune gate Unexport module-local symbols; delete unused observationsPending. * docs(architecture): describe the git-targeted, lock-light reconcile, staged export, sync lane and Forge cached view (DM-968) Read from the integrated sprint branch 55e5506: storage lock-hold expectations and hold observer; reconcile prepare / no-op check / per-record apply with the all-old-or-all-new contract; git change set, fallbacks and marker; finalizer staging, commit, restore, re-stage and backoff; sync lane modes, coalescing and owner protection; Forge cached view; storage-status cache, one-pass epic open, Skitarii get_project cache. Merges DM-963 and DM-964's lines into one description. * docs(decisions): 0007 git-targeted, lock-light reconcile on SQLite; Postgres and same-thread async rejected (DM-968) Context from the 2026-11-24 measurements in the epic intent and the DM-959 baseline; the delivered decision (fingerprint gate, git change set, per-record transactions, staged export, sync lane, Skitarii cache); rejected alternatives; consequences, including the recorded risks and that the desktop explicit Reconcile is git-targeted as merged. * docs(reports): integrated-branch columns and run section for the acceptance node; per-ticket harness summary from committed rows (DM-968) Adds Integrated branch columns to the fixture, changed-reconcile and 12-agent tables (the view, click-to-paint, holds, counters and CLI tables already had them), an empty Integrated branch run section, and a per-ticket table copied from dm964, revamp-DM-963-at3, dm962, dm961 and sync-lane-probe rows. No number is estimated. * fix(desktop): explicit lane reconcile reads every record - Pass { full: true } for an explicit sync-lane reconcile (desktop Reconcile, Forge validateSource), as Workspace.reconcile() does. - Test: an explicit lane reconcile re-reads every record body; member and heartbeat read none (DM-961). - Docs: architecture and decision 0007 say every explicit reconcile is full. * perf(spike): CLI phase-timing preload and fixed-rate CLI-agent stage for the revamp harness - DM_REVAMP_CLI_PHASES=1 runs each harness CLI call with scripts/spike/cli-phase-timing.cjs: open, reconcile, flush, command, close wall time, git runs and SQLite writer waits per phase - DM_REVAMP_SYNC_EVERY_MS paces the agent stage's desktop syncs on a fixed schedule; DM_REVAMP_ONLY=cli-agents runs only that stage on 10,000 tickets * perf(lane): keep the observed sync lane's file-hash cache across reconciles; CLI-friction harness runs - syncLaneCore: with DM_LANE_OBSERVE_FILE set, the counting db/fs wrapper was rebuilt per reconcile, which re-scoped the lane's file-hash cache and made every observed lane reconcile a cold full read (~1.2 s vs ~0.27 s on 10k tickets). The wrapper is now made once per connection. Measurement-only path; unobserved lanes are unchanged. - syncLaneCore.test: warm observed lane reconciles read no cached record body again (fails before the fix: 4 vs 3 reads). - Harness: revamp fixtures are committed by default (DM_REVAMP_COMMIT_FIXTURE=0 keeps the unborn-HEAD mode); the CLI preload traces each fingerprint gate's answers; the summary counts gate outcomes and CLI imports. - docs/reports/forge-performance-data/cli-friction: fixed-rate (one sync every 3.5 s) 12-agent stage rows, interleaved base/integrated in both fixture modes. * test(desktop): prove explicit lane reconcile is full by records visited - Assert imported + unchanged: explicit covers every record the cold import did; member and heartbeat with nothing changed visit none. Body reads no longer prove a full read once the lane's file-hash cache stays warm. * test: TSX-safe generic in the equivalence test so Fireguard's AST gate sees its assertions * perf(spike): footer-idle stage counts git runs (GIT_TRACE) and checkout stamp changes for c8 (DM-958) * perf(spike): footer-idle stage attaches its own CDP session; keep the failed first final-matrix rows (DM-958) * docs(report): integrated-branch measurement matrix, c2 targeted-reconcile rows and c8 footer counter (DM-958) * fix(storage): footer git status only on index, HEAD or flush change; correct c10 docs - Record-status cache keyed by index stamp, HEAD and last_flush_at; age-based refresh removed (c8) - architecture.md: listEvents filters walk events by primary key; reconcile spawns 2 or 4 git processes - ADR 0007: rev-parse counted; automatic reconcile at open is git-targeted * test(perf): cover sync lane, owner entry and reconcile scope branches; drop unreachable gitChanges fallbacks - syncLane: worker lane start/reuse, execArgv, domain-error replies, crash, exit and close rejections (real worker script) - syncLaneWorker/workspaceOwner entries: parentPort/argument refusals, release and error-shape replies, observer file - syncLaneCore: no-database refusal, heartbeat skip after branch change vs member reconcile - reconcileScope: metric_observation recheck by epic / project observations, unknown outbox kinds skipped - owner runtime: heartbeat on uninitialized folder, sync after close; operations: missing/unknown attachment bytes - renderer: setTicketBudget, createCorrections, setEpicBranch, draft_loaded before load, unreadable overview plan - gitChanges: changes() narrows status/dirtyPaths once, removing unreachable ?? / ok fallbacks * perf(reconcile): ask each folder's real path once per scan; split each equivalence seed into tests of 10 steps Profiling one equivalence seed (50 steps, two databases): about 16k realpath calls per seed, from assertContained checking every folder above every record each read, cost ~3.9 s of ~11 s; git status (one per targeted step) ~1.2 s. The observed scan filesystem now answers a path's real path from its first answer within one scan: the writer lock still rechecks it with every other observation, and isSymlink is still asked on every use. The equivalence test keeps the same seeds, the same 50 steps per seed in the same order and the same comparisons after every step; each seed's world carries across five tests of 10 steps, so no single test runs long. * test(forge): wait for the fixture's git processes to exit before removing its scratch folder - Unawaited git that the code under test starts (the record-status background git status, Forge reads) could outlive a forgeService fixture. - On Windows a running git holds the scratch folder. Since Node 24.22 (nodejs/node#64698), rmSync really sleeps between its EPERM retries, so removeScratch blocked the event loop for up to 21 s. On CI (Node 24.22.3) three tests ran 15-19 s and timed out. - The fixture now tracks every git run (the runner's onExit, and the workspace's git adapter), and close() waits until all have exited. * perf(forge): a sync reuses its own checkout checks instead of asking git again One Forge World sync re-asked git what it had just established: the repository root and origin (ensureForgeWorld, ForgeGit.sync and verifyForgeCheckout each asked), HEAD's tree (ls-tree of the same commit up to five times) and the index (ls-files -u, --stage and --cached --others before each commit). - ensureForgeWorld returns what it checked (origin URL, commits whose trees were inspected); ForgeService.syncWorld passes it to ForgeGit.sync, which skips its own root/origin/main check, and the sync passes what it established after the merge to the validation's ensure. ensureMain still runs on every check. - A commit's tree is inspected once per sync (keyed by full commit id); HEAD is still resolved and its tree inspected whenever it moved. - commitRepository reads the index and untracked paths in one `ls-files -t --stage --others` (unmerged stages refused, every index entry inspected, private state never staged), then inspects the index again after `add` as before. - verifyForgeCheckout takes the world origin when the caller has just read it. forgeResolver.test.ts (quiet, git processes / duration): conflicting forge-world.json 204 / 4.06 s -> 146 / 3.05 s; conflicting README.md 204 / 4.05 s -> 146 / 3.00 s; queued real conflicts 168 / 3.98 s -> 136 / 3.43 s. * test(forge): forgeService fixtures skip power-loss flushes and report where a slow test spends its time - The fixture's stores open with TEST_STORAGE (no fsync, synchronous off) and its git with GIT_TEST_FSYNC=0, like every other test that opens workspaces itself; a forced sync per write and per commit is what stalls on a Windows CI runner's disk. - ForgeFixtureTiming now samples worker and machine CPU, event-loop stalls, GC and memory, and takes SQLite lock waits and holds. It prints its spans on failure, when a test passes in 8 s or longer, and again when a timed-out test's body finally disposes it. - forgeService fixtures time IPC calls, Forge and core git runs, the crash child, owner close, git exits and scratch cleanup.
davgor
added a commit
to davgor/DarkMechanicus
that referenced
this pull request
Nov 26, 2026
…n into durable guardrails (Sprint 1) (#95) * Sprint learnings: rejection-aware retries and post-sprint codification into durable guardrails (Sprint 1) Squashed sprint 1 increment of epic ep_01m877qfj5nej49ysp94ank0td (run rn_01m878vacn8sa165fkxx76jf0p) from learnings/sprint-1 @ 62d5dd27. Accepted: DM-926..929, 931, 933..938, 943..956 (required) + DM-949; integration fixes; origin/main v0.83.0 merged. Full Definition of Done green at 62d5dd27 (coverage branches 95.27%). * Fix PR #95 CI: close test workspaces before repository removal; compare named columns across upgrades - Windows hook timeouts: Node 24.21+ makes rmSync's retryDelay real milliseconds (24.16 slept 0 ms). removeScratch (maxRetries 20, retryDelay 100) on a repository whose open workspace database is still inside it now sleeps about 23 s before giving up, past the 15 s hook. Before 24.21 the same removal failed in 0 ms and silently leaked the folder. Harness.closeWorkspaces() releases every database. Tests that open a workspace on a real repository register it after the repository's cleanup, so it runs first. - v31/v32 upgrade tests: Node 24.20+ reads the column count after stepping, so a cached SELECT * now returns columns added by v33/v35. Assert the real invariant instead: every pre-existing column keeps its values, and the only new columns are the documented ones, at their defaults. * Fix PR #95 flake: a cancel never kills the learning transition's owned worktree write - Cause: on cancel the caller's signal reached the runner, which SIGTERMed `git read-tree -m -u` mid-write. Git's signal handler removes index.lock, but a kill between creating a file and writing it, or before the lock is registered/unlinked, leaves a 0-byte GUARDRAILS.md (neither side -> dirty_worktree) or a stale .git/index.lock (recovery's read-tree -> index_locked). Recovery cannot prove it caused either, so it rightly refuses. - ownedWrite now runs to completion: the cancel is checked in the runner's beforeStart (no git starts after it) and once git has exited (interrupted). Only the transition deadline still kills a hung write; locks are still released only after git exits. - The test no longer fakes a runner that rejects on abort; it asserts the read-tree never saw an aborted signal, that the worktree holds exactly newHead's bytes after the cancel, and that recovery completes. - New transition test: a cancel just before git would start the write starts nothing and changes nothing. * test(forge): wait for the fixture's git processes to exit before removing its scratch folder - Unawaited git that the code under test starts (the record-status background git status, Forge reads) could outlive a forgeService fixture. - On Windows a running git holds the scratch folder. Since Node 24.22 (nodejs/node#64698), rmSync really sleeps between its EPERM retries, so removeScratch blocked the event loop for up to 21 s. On CI (Node 24.22.3) three tests ran 15-19 s and timed out. - The fixture now tracks every git run (the runner's onExit, and the workspace's git adapter), and close() waits until all have exited. * test(forge): forgeService fixtures skip power-loss flushes and report where a slow test spends its time - The fixture's stores open with TEST_STORAGE (no fsync, synchronous off) and its git with GIT_TEST_FSYNC=0, like every other test that opens workspaces itself; a forced sync per write and per commit is what stalls on a Windows CI runner's disk. - ForgeFixtureTiming now samples worker and machine CPU, event-loop stalls, GC and memory, and takes SQLite lock waits and holds. It prints its spans on failure, when a test passes in 8 s or longer, and again when a timed-out test's body finally disposes it. - forgeService fixtures time IPC calls, Forge and core git runs, the crash child, owner close, git exits and scratch cleanup. * perf(forge): a sync reuses its own checkout checks instead of asking git again One Forge World sync re-asked git what it had just established: the repository root and origin (ensureForgeWorld, ForgeGit.sync and verifyForgeCheckout each asked), HEAD's tree (ls-tree of the same commit up to five times) and the index (ls-files -u, --stage and --cached --others before each commit). - ensureForgeWorld returns what it checked (origin URL, commits whose trees were inspected); ForgeService.syncWorld passes it to ForgeGit.sync, which skips its own root/origin/main check, and the sync passes what it established after the merge to the validation's ensure. ensureMain still runs on every check. - A commit's tree is inspected once per sync (keyed by full commit id); HEAD is still resolved and its tree inspected whenever it moved. - commitRepository reads the index and untracked paths in one `ls-files -t --stage --others` (unmerged stages refused, every index entry inspected, private state never staged), then inspects the index again after `add` as before. - verifyForgeCheckout takes the world origin when the caller has just read it. forgeResolver.test.ts (quiet, git processes / duration): conflicting forge-world.json 204 / 4.06 s -> 146 / 3.05 s; conflicting README.md 204 / 4.05 s -> 146 / 3.00 s; queued real conflicts 168 / 3.98 s -> 136 / 3.43 s. * test(bootstrap): startup approval recovery expects main's open-time sync-lane reconcile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
std::errc::permission_deniedis already treated as anEPERMerror when an exception is thrown, but it is not included among the omittable errors retried by theRmSyncoperation. This commit adds it.This also fixes the
retryDelaycalculation on Windows where theretryDelayis divided by1000but the win32's Sleep function takes the argument as an ms unit, dividing the supplied ms unit further to a much smaller delay.Fixes: #64016
Refs: #64017 - This PR adds a test for the referenced PR.