fix(cli): stop recording expected outcomes as errors, enable checkpoints by default - #455
Merged
Conversation
…nts by default
Triaging the CLI's error stream was impossible: expected outcomes dominated it,
and every install reported `deployment.environment=development`, so customers,
local dev and CI runners were indistinguishable.
Telemetry hygiene:
- Split the `maple start`/`stop`/`reset`/`restore` precondition guards out of
`ServerError` into `ServerStateError`, and recover them — plus `--help` and
mode-resolution failures — inside the root `maple` span. They were the top
error sources by volume (~24k events for the already-running guard alone).
The outcome is annotated as `maple.cli.outcome` rather than dropped, so the
question "how often do people hit this?" is still answerable. Genuine
failures (bind failure, dirty store, incompatible store) stay uncaught and
still close the span `Error`.
- Mode resolution reaches `bin.ts` as a `WarehouseConfigError` (remapped in
core/warehouse.ts); `pipeName === "mode"` discriminates the expected case, so
real query failures are re-raised.
- Skip span creation for the `/health` readiness probes via
`TracerDisabledWhen`. Polling until the server binds emitted ~10 `Error`
spans per `maple start` inside an otherwise-`Ok` root span. `orElseSucceed`
could not help — it runs after the client span has already closed.
- Report `environment` as `cli`, or `ci` when `CI` is set, instead of
defaulting to `development`.
Checkpoints:
- `maple start` now generates a backups-enabled chDB config when
`--chdb-config-file` is absent. `BACKUP … TO Disk('default', …)` needs
`<backups>` in the *running* connection's config, and chDB allows one
connection per process, so `maple checkpoint` — a separate process — could
never supply it. Checkpoints were unusable out of the box, which also made
the dirty-store recovery advice (`maple restore --yes`) point at a checkpoint
that could not exist. `writeBackupConfig` already existed and was only used
for a throwaway scratch file during restore.
- Reword the missing-backups-config error, now only reachable with a custom
config lacking the stanza.
Verified end to end: `maple start` + `maple checkpoint` with no flags now
succeeds; `--help` exits 0; the guards keep their messages and exit 1.
The probe asserted the behaviour this branch deliberately removes: that a server started without `--chdb-config-file` cannot checkpoint. With the default now generated at `maple start`, that case succeeds. Replaced with two assertions covering both halves of the new contract: - A server started with no config flag generates a backups-enabled chDB config beside the data dir and can take a checkpoint that publishes state. This is the guarantee that makes the dirty-store recovery advice (`maple restore --yes`) reachable at all. - The narrow, actionable missing-backups error still fires — now only through a custom config that omits the `<backups>` stanza, which is the one way left to reach it. Both use their own data dir so the main scenario still starts from a fresh store. Verified locally against a compiled bundle: probe passes end to end, shellcheck clean.
🍁 Maple PR previewNote Preview resources were removed when this pull request closed. Final commit |
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.
Why
Triaging the
maple-clierror stream via the Maple MCP turned up two structural problems before any individual bug:maple-clierror span carriesdeployment.environment=development— the SDK's fallback, since none ofMAPLE_ENVIRONMENT/RAILWAY_ENVIRONMENT_NAME/DEPLOYMENT_ENVexist on a laptop. Separating CI runners from humans meant reading filesystem paths out of error strings./healthreadiness polling (9k), andmaple --help.The three loudest remaining issues turned out to be already fixed at HEAD, with old binaries still reporting them (
Error {}onPOST /v1/tracesfrom failing a span with a bareResponse, fixed in v0.0.13; the maintenance-lockENOENT, fixed 2026-08-07;max_query_size, fixed 2026-07-20). Those need binaries to age out, not code.What changed
Telemetry hygiene
start/stop/reset/restoreprecondition guards out ofServerErrorinto a newServerStateError, and recover them — plus--helpand mode-resolution failures — inside the rootmaplespan, the same placementArchiveErroralready used. The outcome is annotated asmaple.cli.outcomerather than dropped, so "how often do people hit this?" is still answerable. Genuine failures (bind failure, dirty store, incompatible store) stay uncaught and still close the spanError.WarehouseConfigError(remapped incore/warehouse.ts);pipeName === "mode"discriminates the expected case so real query failures are re-raised.TracerDisabledWhenon the/healthprobes.orElseSucceedcould never have fixed these — it runs after the client span has already closed. Scoped per-request, not layer-wide, so other/healthcalls stay traced.environmentis nowcli, orciwhenCIis set.Checkpoints work out of the box
BACKUP … TO Disk('default', …)needs<backups>in the running connection's config. chDB allows one connection per process, held for the process lifetime, andmaple checkpointis a separate process talking over HTTP — it can never supply that config after the fact. Without--chdb-config-file, checkpoints were simply impossible, which also made the dirty-store recovery advice (maple restore --yes) point at a checkpoint that could not exist.maple startnow generates the config when the flag is absent.writeBackupConfig()already existed and was only used for a throwaway scratch file during restore.Verification
bun run testinapps/cli(Bun runner): 437 pass, incl. 5 new.tsc --noEmitclean;oxfmt+oxlintclean.maple startthenmaple checkpointwith no flags → checkpoint created (impossible before this change).maple --help→ exit 0, empty stderr.maple startwhile running →maple is already running (PID …), exit 1, message unchanged.maple services --remote --local→ single clean line, exit 1 (previously a full Effect error render).Deliberately not included
deployment.commit_shaonisCommitSha. The CLI stamps its semver (0.0.18) into a commit-SHA field, which is wrong — but the fix sits in sharedeffect-sdkcode used by the browser/client SDKs, and dropping the attribute for non-SHA values could break customer dashboards that group by it. Worth doing deliberately, not as a side effect of CLI triage.WarehouseSchemaDriftError/WarehouseConfigError, indistinguishable from real cloud warehouse drift (44 events).trace_resource_attribute_values_mvUnknown identifier 'key'(4 events) — a chDB analyzer difference onARRAY JOIN mapKeys/mapValues, not local/remote SQL divergence; the definition is byte-identical to the canonical one.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.