fix: create parent dir before writing state files - #2030
Open
abseg wants to merge 1 commit into
Open
Conversation
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.
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.
Problem
Nine tools and hooks write to paths under
LIFEOS/MEMORY/STATEandLIFEOS/OBSERVABILITYwhose 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 throwsENOENTand the feature silently does nothing.SessionRenameis the clearest case: every rename lands nowhere becauseMEMORY/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/UpdateCountsVerification
All nine parse-check clean (
bun build --target=bun). Imports are merged into each file's existingfs/pathimport 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.