Skip to content

gemdb starts the database safely (#115, #126, #134 items 1–3) - #148

Merged
jgfoster merged 4 commits into
mainfrom
mfernandez/gemdb-safe-start
Oct 21, 2026
Merged

jgfoster merged 4 commits into
mainfrom
mfernandez/gemdb-safe-start

Conversation

@MatiasFernandez

@MatiasFernandez MatiasFernandez commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #115
Fixes #126
Part of #134 (items 1–3; 4–6 remain, so not auto-closed)

What changes

When the stone is down, gemdb file.py / -c / -m used to start it from ~130 lines of bash that had drifted from ensureProcesses, skipped assertSafeToStart (a pin move ended in a raw 4045), and treated external databases differently from the window and the Shell. It also ran against a database Grail was never filed into.

Now the wrapper keeps only a stamp test and an ok fast path. Everything else runs gemdb-shell.js --ensure-stone, which goes through the same ensureProcesses + guards as the Shell.

Commits

  1. One external-database check. assertExternalDatabaseUp replaces the two copies (window, Shell). Waits for a stone still at Startup; says "the administrator runs it" instead of "start it again"; names no GemDB log.
  2. Wrapper hands starts to Node. ensureProcesses({ listener: false }): the CLI starts the stone only (file mode is a linked topaz and never uses NetLDI). withStoneLock now reports that it is waiting, so a CLI run behind a window's start isn't silent for up to 150 s. Argument checks (-c with no code, missing file) run before anything starts. Bash lock/start/wait block deleted.
  3. Refuse without Python. New GRAIL_NOT_INSTALLED ("Run GemDB: Start GemDB…") for wrapper, Shell and --ensure-stone. GRAIL_MISSING is untouched: it now means "stamp present, Python gone", which only Reinstall repairs.

Review focus

  • src/cli.ts template: the fast path / --ensure-stone </dev/null logic and the moved argument checks. The post-run $STATUS is renamed RUN_STATUS to keep it apart from STONE_STATUS.
  • Accepted cost: a cold start needs the staged bundle and a Node (recorded execPath, else PATH). A missing one refuses with the Shell's messages; there is no bash fallback.
  • Lock name/format must not change until 1.8.0-and-earlier wrappers (1.8.0 still generates the bash lock) (which still take it in bash) are gone; comments in lock.ts/processes.ts now say so.
  • Integration fixtures now call recordGrailInstalled, otherwise every own-database test gets the new refusal.

Verification

  • Manual testing

Known and left alone (pre-existing or minor, found in review): the fast path takes only ok, so frozen/exe deleted now go through Node; a bare gemdb -m still starts the stone before failing; external "stopped while starting" wording.

Related, not in this PR: #143 (activation doesn't start the MCP server when the stone is up and NetLDI is down).

🤖 Generated with Claude Code

@MatiasFernandez
MatiasFernandez force-pushed the mfernandez/gemdb-safe-start branch 2 times, most recently from 477e1a0 to dce7f80 Compare October 20, 2026 16:27
@MatiasFernandez
MatiasFernandez force-pushed the mfernandez/gemdb-safe-start branch 2 times, most recently from 1254ee3 to ea641b1 Compare October 20, 2026 19:21
@MatiasFernandez
MatiasFernandez marked this pull request as ready for review October 20, 2026 19:24
MatiasFernandez and others added 3 commits October 20, 2026 18:53
The window and the GemDB Shell each had their own copy of "is the external
database up", and neither waited for a stone still at Startup. Both now call
assertExternalDatabaseUp, which waits as waitForStoneReady does for a database
of our own.

For an external database the messages no longer name GemDB's own stone log
(which has nothing of it) and no longer tell the user to start it again: the
administrator runs it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A file, -c or -m run that found the stone down started it from ~130 lines of
bash that duplicated ensureProcesses' lock, start and wait, had drifted from
it, skipped assertSafeToStart (so a pin move ended in a raw 4045), and treated
an external database differently from the window and the Shell.

The wrapper now keeps only the fast path for a stone that reads `ok`. Every
other case runs `gemdb-shell.js --ensure-stone`, which goes through bringUp:
the same ensureProcesses and guards as the Shell, starting the stone only,
since a file run is a linked topaz and never uses NetLDI
(ensureProcesses takes a `listener` option for this).

- The stone lock now reports that it is waiting, so a CLI run behind a
  window's start says so instead of printing nothing for up to 150 s.
- A mistyped file or a -c with no code fails before anything starts.
- The comments that said bash takes the lock now say that only wrappers from
  1.7.0 and earlier do, which is why the lock's format must stay as it is.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A database Grail had not been filed into yet answered a file, -c, -m or Shell
start with driver compile errors, or a 4051 when there was no account yet.
The wrapper now tests the Grail stamp for an own database, before the fast
path, and the Shell and --ensure-stone do the same in bringUp. All three say
GRAIL_NOT_INSTALLED, which points at "GemDB: Start GemDB".

GRAIL_MISSING keeps its own wording: it now only meets a database whose stamp
is present and whose Python is gone, which "Start GemDB" does not repair.
The message holds double quotes, so the wrapper writes it through shellQuote.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@MatiasFernandez
MatiasFernandez force-pushed the mfernandez/gemdb-safe-start branch from ea641b1 to 9f1b613 Compare October 20, 2026 21:53
@jgfoster
jgfoster added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 21, 2026
@jgfoster
jgfoster added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 62acabe Oct 21, 2026
5 checks passed
@jgfoster
jgfoster deleted the mfernandez/gemdb-safe-start branch October 21, 2026 02:06
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.

The wrapper gives up on a live stone lock after 10 s gemdb refuses to start a database without Python support

2 participants