ktg-plugin-marketplace/plugins/ms-ai-architect/scripts
Kjell Tore Guttormsen 4a615b10ce feat(ms-ai-architect): add lib/atomic-write for crash-safe state files [skip-docs]
Foundation lib for status-fil + lock-fil writes in v1.12.0 cron rewrite.
Pattern: writeFileSync to <path>.tmp.<pid>.<random> then renameSync to
target. Defends against half-written files; readers either see the
previous version or the new one, never a partial.

- atomicWriteSync(path, content) — string or Buffer
- atomicWriteJson(path, obj) — 2-space indent, trailing newline
- Windows EEXIST/EPERM defensive fallback (unlink target + rename)
- Best-effort tmp cleanup on writeFileSync failure
- crypto.randomInt(0, 2**32) two-arg form (unambiguous across Node)

9/9 tests pass including 50-way concurrent-write fuzzer (async-aware
withTmp helper).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 10:32:13 +02:00
..
kb-update feat(ms-ai-architect): add lib/atomic-write for crash-safe state files [skip-docs] 2026-05-05 10:32:13 +02:00
skill-gen chore(ms-ai-architect): sanitize all private references for open-source 2026-04-07 17:27:10 +02:00
build-demo-state.mjs feat(ms-ai-architect): release v1.11.0 — design-system 100%-adoption + visual upgrade 2026-05-04 17:41:36 +02:00
export-pdf.py feat(ms-ai-architect): add plugin to open marketplace (v1.5.0 baseline) 2026-04-07 17:17:17 +02:00
kb-staleness-check.sh feat(ms-ai-architect): add plugin to open marketplace (v1.5.0 baseline) 2026-04-07 17:17:17 +02:00