fix(cli): create the Maple home before first-run startup touches its siblings - #446
Open
JeremyFunk wants to merge 1 commit into
Open
fix(cli): create the Maple home before first-run startup touches its siblings#446JeremyFunk wants to merge 1 commit into
JeremyFunk wants to merge 1 commit into
Conversation
…siblings On a machine with no `~/.maple`, `maple start` fails with a bare `ENOENT … mkdir '~/.maple/data.maple-maintenance-lock'`: startup reconciles checkpoint recovery under the maintenance lock before it creates any directory, and the lock — like the PID file, the `--background` log, the restore/reset transactions and the migration journal — is a *sibling* of the data dir, so it lands in a parent that does not exist yet. `acquireMaintenance` has created that parent since v0.0.15, which is why the crash only reproduces on older builds. Make the precondition explicit instead of leaving it to whichever helper happens to run first: create the data dir's parent as `start`'s first filesystem step, and lock the invariant with two regression tests (lock acquisition and recovery reconciliation, both against a data dir whose parent is absent). Both fail with the reported ENOENT when the parent creation is removed. The data dir itself is still created where it was, after recovery reconciliation, so restore/reset reconciliation keeps seeing the tree exactly as it left it.
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.
Reported from a fresh install: the first
maple starton a machine with no~/.mapledies with a bare filesystem error.Why it happens
startreconciles checkpoint recovery before it creates any directory — deliberately, so a restore or reset transaction is settled before reset/compatibility/dirty-store logic runs. That reconciliation takes the maintenance lock, and the lock — like the PID file, the--backgroundlog, the restore/reset transactions and the migration journal — is a sibling of the data dir. On first run its parent (~/.maple) does not exist, so themkdirfails.acquireMaintenancehas created that parent since v0.0.15 (9b5ea73), so the crash only reproduces on older builds — the report is from a Homebrew install still on 0.0.13. There was no test holding the invariant, and it was an emergent property of one helper rather than a stated precondition of startup.Change
startcreates the data dir's parent as its first filesystem step. The data dir itself is still created where it was, after recovery reconciliation, so restore/reset reconciliation keeps seeing the tree exactly as it left it.acquireMaintenancemakes both fail with the reported ENOENT.Verification
bun run testinapps/cli— 434 pass, 0 fail.bun typecheckinapps/cli— clean.HOME=<empty dir> maple startfrom source: creates~/.maple/dataand reaches chDB open (which then stops onlibchdb not found, expected in a source checkout — release bundles ship it). Before the fix the same run on 0.0.13's code path stops at the lockmkdir.Note for the reporter: the Homebrew tap is still serving 0.0.13, several tags behind.
brew upgradewill only pick this up once the tap formula is bumped.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.