Skip to content

fix: create parent dir before writing state files - #2030

Open
abseg wants to merge 1 commit into
danielmiessler:mainfrom
abseg:fix/mkdir-before-write
Open

fix: create parent dir before writing state files#2030
abseg wants to merge 1 commit into
danielmiessler:mainfrom
abseg:fix/mkdir-before-write

Conversation

@abseg

@abseg abseg commented Aug 30, 2026

Copy link
Copy Markdown

Problem

Nine tools and hooks write to paths under LIFEOS/MEMORY/STATE and LIFEOS/OBSERVABILITY whose parent directory git cannot carry, because git does not track empty directories. On a fresh clone — or any install where the directory has not happened to be created by some other code path first — the write throws ENOENT and the feature silently does nothing.

SessionRename is the clearest case: every rename lands nowhere because MEMORY/STATE/ does not exist yet.

Fix

Each write site calls mkdirSync(dirname(path), { recursive: true }) immediately before the write. The call is a no-op when the directory already exists, so existing installs see no behaviour change.

Files

DoctrineReplay · GenerateKnowledgeSchemaDoc · MemoryRestore · ProposalGC · SessionProgress · SessionRename · UpdateModels · UsageAggregator · hooks/handlers/UpdateCounts

Verification

All nine parse-check clean (bun build --target=bun). Imports are merged into each file's existing fs/path import lines, matching that file's own quote and specifier style rather than adding a second import group.

+28 / -17 across 9 files. No behaviour change beyond the directory creation.

Nine tools and hooks write to paths under LIFEOS/MEMORY/STATE and
LIFEOS/OBSERVABILITY that git cannot carry, because git does not track
empty directories. On a fresh clone, or any install that has not yet
happened to create them by another route, the parent is missing and the
write throws ENOENT.

Each site now calls mkdirSync(dirname(path), { recursive: true }) before
the write. The call is a no-op when the directory already exists, so
existing installs are unaffected.

Files: DoctrineReplay, GenerateKnowledgeSchemaDoc, MemoryRestore,
ProposalGC, SessionProgress, SessionRename, UpdateModels,
UsageAggregator, hooks/handlers/UpdateCounts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant