pmacs/src
Levi Neuwirth 29ad746b78 atomic save: preserve mode, fsync the dir, retry temp collisions (F-006)
Audit F-006. `save_atomic` wrote a temp sibling, synced it, and renamed
over the target — but dropped three durability/correctness properties:

1. Mode not preserved: the temp was created with default perms, so saving
   over an existing file replaced its mode — a 0755 script silently
   dropped to 0644. Now snapshot the target's permissions and apply them
   to the temp before the rename (new files still get the default).
2. Parent dir not fsync'd: the file bytes were synced but the rename (a
   directory operation) wasn't durable, so a crash right after rename
   could lose it. Now fsync the parent directory after rename on Unix,
   best-effort (the rename already succeeded; some FSes reject dir fsync).
3. Temp-name collision failed the save: the pid+subsec-nanos name relied
   on `create_new` erroring, with no retry, so a stale temp from a crashed
   run (recurring pid+nanos) surfaced as a spurious save failure. Now a
   process-global atomic sequence makes same-process names unique, and the
   open retries a bounded number of times on collision.

Tests: 0755 mode survives a save (unix); temp names disambiguate by
sequence; 50 back-to-back saves never collide.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014TXbAwk27agwhrNNrhLi2U
2026-07-03 11:35:20 -04:00
..
audit V0.2-prerequisite pull-forward + M10.11 clean audit round 2026-05-18 10:31:31 -04:00
bin Render inline adornments in pmacs-gpu 2026-05-27 10:24:20 -04:00
packages Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
ansi.rs protocol v6: per-severity diagnostic underline colors (SGR 58) 2026-06-10 19:16:42 -04:00
async_runtime.rs T M4.5 async bridge: LSP requests settle async-runtime jobs 2026-05-18 19:36:17 -04:00
attach.rs T M11.6 — DispatchIdle signal closes optimistic-apply blindness (#45) 2026-05-21 13:49:48 +00:00
attach_dispatch.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
attach_reconnect.rs Pin toolchain to 1.95.0 + mechanical clippy/rustc fixes 2026-05-18 11:38:57 -04:00
buffer.rs CUA type-over is a single undo step (Q#U1) 2026-06-15 20:00:53 -04:00
buffer_mirror.rs M10.10: complete optimistic-apply keystroke path + Day-5 corrections 2026-05-15 16:40:46 -04:00
buffer_registry.rs T M4.5 L1: cross-file nav foundations — per-buffer file_path, jump ring, x-file go-to-def 2026-05-19 09:53:29 -04:00
builtin_packages.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
cell.rs session 1 commit 2/4: cell wire types moved to pmacs-protocol 2026-05-20 09:20:24 -04:00
code_action.rs T M4.5 L4: WorkspaceEdit resource ops (create/rename/delete file) 2026-05-19 12:31:35 -04:00
command.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
completion.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
completion_framework.rs Pin toolchain to 1.95.0 + mechanical clippy/rustc fixes 2026-05-18 11:38:57 -04:00
config.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
crdt.rs optimistic-apply daemon support — Loro text-delta hot path for remote inserts 2026-06-10 10:45:23 -04:00
daemon.rs pmacs GPU minibuffer: wire v12 + band prompt + candidate dropdown (Q#MB1) 2026-06-30 21:03:32 -04:00
daemon_attach.rs CI fixes v2 2026-05-18 13:12:10 -04:00
definition.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
diag.rs search: render matches in both frontends (Q#SR3/SR4) 2026-06-27 10:48:06 -04:00
document_highlight.rs T M4.5: documentSymbol / workspace symbol / documentHighlight 2026-05-18 22:15:03 -04:00
editor.rs pmacs context menu: protocol v11 + dispatch + TUI/GPU surfaces (Q#CM1/Q#CM5) 2026-06-27 22:19:00 -04:00
editor_core.rs pmacs context menu: core clipboard + menu methods + Lua surface (Q#CM1/Q#CM3/Q#CM6) 2026-06-27 22:03:58 -04:00
file_io.rs atomic save: preserve mode, fsync the dir, retry temp collisions (F-006) 2026-07-03 11:35:20 -04:00
formatting.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
frontend.rs pmacs GPU minibuffer: wire v12 + band prompt + candidate dropdown (Q#MB1) 2026-06-30 21:03:32 -04:00
fs.rs CI fixes v2 2026-05-18 13:12:10 -04:00
help.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
highlight.rs Fix stale TUI styling after edits 2026-05-26 11:15:23 -04:00
hook.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
hover.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
inlay_hint.rs Close pmacs-gpu phase A audit 2026-05-28 12:49:23 -04:00
instance_buffer.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
instance_render.rs M10.10 ship gate 2026-05-13 16:28:46 -04:00
key.rs Fix PTY final-output drain race 2026-05-04 09:44:30 -04:00
keymap_stack.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
keymap_tree.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
lib.rs pmacs context menu: registry + open-menu state types (Q#CM1/Q#CM2) 2026-06-27 21:42:28 -04:00
locations.rs T M4.5: nav requests — references/declaration/typeDefinition/implementation 2026-05-18 21:39:02 -04:00
lockfile.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
lsp.rs LSP didChange debounce + queued process stdin writer (typing perf) 2026-06-10 10:49:51 -04:00
lsp_status.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
lua.rs pmacs context menu: core clipboard + menu methods + Lua surface (Q#CM1/Q#CM3/Q#CM6) 2026-06-27 22:03:58 -04:00
lua_bindings.rs pmacs context menu: core clipboard + menu methods + Lua surface (Q#CM1/Q#CM3/Q#CM6) 2026-06-27 22:03:58 -04:00
lua_isolation.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
main.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
mcp.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
menu.rs pmacs context menu: registry + open-menu state types (Q#CM1/Q#CM2) 2026-06-27 21:42:28 -04:00
message_bus.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
minibuffer.rs minibuffer: Escape cancels session (#44) 2026-05-21 01:35:02 +00:00
optimistic.rs M10.11 fixes 2026-05-15 22:04:42 -04:00
overlay.rs protocol v6: per-severity diagnostic underline colors (SGR 58) 2026-06-10 19:16:42 -04:00
overlay_color.rs M10.10 ship gate 2026-05-13 16:28:46 -04:00
overlay_paint.rs Pin toolchain to 1.95.0 + mechanical clippy/rustc fixes 2026-05-18 11:38:57 -04:00
prepare_rename.rs T M4.5: textDocument/prepareRename (backlog item 3) 2026-05-19 14:23:57 -04:00
presence.rs M11.1: semantic-frontend protocol scaffolding (wire + capability) 2026-05-18 19:39:07 -04:00
process.rs style: cargo fmt over the optimistic-editing arc 2026-06-10 11:53:50 -04:00
project.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
project_index.rs T M4.5 L1: cross-file nav foundations — per-buffer file_path, jump ring, x-file go-to-def 2026-05-19 09:53:29 -04:00
protocol.rs pmacs GPU minibuffer: wire v12 + band prompt + candidate dropdown (Q#MB1) 2026-06-30 21:03:32 -04:00
rename.rs T M4.5 L4: WorkspaceEdit resource ops (create/rename/delete file) 2026-05-19 12:31:35 -04:00
rope.rs session 1 commit 3/4: CrdtOp moved to pmacs-protocol 2026-05-20 09:32:09 -04:00
search.rs regex-search: TUI regex mode + multi-line wash (Q#RX3/RX4/RX5) 2026-06-27 14:46:33 -04:00
semantic_client.rs T M4.5: documentSymbol / workspace symbol / documentHighlight 2026-05-18 22:15:03 -04:00
semantic_render.rs pmacs GPU minibuffer: wire v12 + band prompt + candidate dropdown (Q#MB1) 2026-06-30 21:03:32 -04:00
semantic_tokens.rs Fix stale TUI styling after edits 2026-05-26 11:15:23 -04:00
signature.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
socket_path.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
symbol.rs T M4.5: documentSymbol / workspace symbol / documentHighlight 2026-05-18 22:15:03 -04:00
syntax.rs optimistic-apply daemon support — Loro text-delta hot path for remote inserts 2026-06-10 10:45:23 -04:00
text_view.rs optimistic-apply daemon support — Loro text-delta hot path for remote inserts 2026-06-10 10:45:23 -04:00
transport.rs session 3 commit 1/N: move transport codec to pmacs-protocol 2026-05-20 12:07:32 -04:00
view.rs M9 ship gate 2026-05-09 15:04:23 -04:00
window.rs M10.10 ship gate 2026-05-13 16:28:46 -04:00
worker.rs test: deflake stress_10k on loaded runners 2026-06-12 09:49:53 -04:00
workers_buffer.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00