Skip to content

fix(reaper): exclude 'dolt' built-in system DB from database discovery#1812

Open
jonathanpberger wants to merge 2 commits intogastownhall:mainfrom
jonathanpberger:fix/reaper-exclude-dolt-system-db
Open

fix(reaper): exclude 'dolt' built-in system DB from database discovery#1812
jonathanpberger wants to merge 2 commits intogastownhall:mainfrom
jonathanpberger:fix/reaper-exclude-dolt-system-db

Conversation

@jonathanpberger
Copy link
Copy Markdown

@jonathanpberger jonathanpberger commented May 7, 2026

Summary

  • Dolt SQL server exposes a built-in dolt system schema via SHOW DATABASES
  • is_user_database() excluded other system schemas (mysql, dolt_cluster, etc.) but missed dolt
  • Reaper iterated dolt as a user database, queried dolt.wisps, hit table-not-found (Error 1146), and mailed spurious ESCALATION anomalies to mayor on every run

Fix

Add dolt to the exclusion pattern in is_user_database():

dolt|information_schema|mysql|dolt_cluster|performance_schema|sys|__gc_probe|...

Test plan

  • dolt excluded from is_user_database() — verified by code change
  • User DBs (hq, td_core) still processed — exclusion is pattern-matched, not a broad filter
  • Reaper dry-run: no anomaly for dolt DB

Closes core-0ozp / tc-zlpa.

🤖 Generated with Claude Code


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

jonathanpberger and others added 2 commits May 7, 2026 15:47
Two causes of height jiggle:
1. renderCityScopeBanner rendered 2 stats (no overseer) vs 5 stats
   (overseer present), making the right side change visual width.
2. The Activity stat timestamp could wrap at narrower viewports, making
   that stat taller and the banner grow.

Fix: always render all 5 stats; use "—" placeholders when no overseer is
active. Add white-space: nowrap to .scope-stat-value to prevent wrapping.

Closes gastownhall#1804.

Co-Authored-By: RubyBear (<synthetic>) <noreply@anthropic.com>
…ase discovery.

Dolt's SHOW DATABASES output includes the 'dolt' internal system database, which lacks
the wisps/issues/dependencies tables. The is_user_database exclusion list covered mysql,
dolt_cluster, information_schema, etc., but not 'dolt' itself — causing table-not-found
anomalies on every reaper run.

Closes core-0ozp / tc-zlpa.

Co-Authored-By: MistyCrane (claude-sonnet-4-6) <noreply@anthropic.com>
@github-actions github-actions Bot added the status/needs-triage Inbox — we haven't looked at it yet label May 7, 2026
@randy-release-manager randy-release-manager Bot added kind/bug Broken behavior priority/p2 Medium — real problem, workaround exists and removed status/needs-triage Inbox — we haven't looked at it yet labels May 7, 2026
julianknutsen pushed a commit that referenced this pull request May 8, 2026
…ema (#1819)

## Summary

Fixes #1816. Both `reaper.sh` and `jsonl-export.sh` iterate user
databases discovered via `SHOW DATABASES` and run per-DB queries
(`<db>.wisps` / `<db>.issues` / `<db>.dependencies`) without checking
whether the database actually has bd schema. Any database that exists on
the server without bd schema (orphan `CREATE DATABASE`, partial
migration, system schemas not on the `is_user_database` blocklist)
produces `Error 1146: table not found` on every query — which becomes
spurious `ESCALATION: Reaper anomalies detected` mail (4 anomalies × N
orphan DBs per cycle, every 30 minutes) and inflated `failed: <db>`
entries in the `jsonl-export` summary.

## Changes

- **`examples/gastown/packs/maintenance/assets/scripts/dolt-target.sh`**
- New `has_wisps_table()` helper that probes `SHOW TABLES FROM \`<db>\`
LIKE 'wisps'` and reports whether the database is bd-managed. Wisps acts
as a proxy for bd schema; every bd-managed schema has a wisps table.
- Fail-closed-toward-processing on probe error: if the SHOW TABLES call
itself errors (dolt unreachable, connection dropped), the helper returns
success so the caller falls through to its normal queries — those will
fail in the same way and surface the dolt-side problem through the
script's regular error-handling path. This matches the rest of the
script's error semantics rather than silently skipping a real bead store
on a transient blip.
- **`examples/gastown/packs/maintenance/assets/scripts/reaper.sh`**
- Per-DB iteration loop calls `has_wisps_table` right after the existing
`valid_database_identifier` guard. Schemaless DB → `continue` silently,
no anomaly recorded.
-
**`examples/gastown/packs/maintenance/assets/scripts/jsonl-export.sh`**
- Same precheck applied. `TOTAL_DBS=$((TOTAL_DBS - 1))` decrement on
skip so the DOG_DONE summary's `exported N/M` denominator reflects only
bd-managed databases.
- **`examples/gastown/maintenance_scripts_test.go`**
- New `TestMaintenanceDoltScriptsSkipDatabasesWithoutWispsTable`
(table-driven over both scripts). Asserts (a) the SHOW TABLES precheck
actually ran for `empty_db`, (b) no `empty_db` table queries were
issued, (c) no escalation surfaces `empty_db` to gc/mayor.
- New `DOLT_DBS_WITHOUT_WISPS` env var on the shared
`writeMaintenanceDoltStub` helper — space-separated DB names that report
no wisps row. Defaults to empty (every DB has wisps), preserving
backward compatibility with all 16+ existing tests that use this stub.
- 17 inline raw-string dolt stubs and 3 Go-string-concatenated stubs
(`writeIssuesPayloadDoltStub` and siblings) get a one-line SHOW TABLES
case prepended so the new precheck doesn't spuriously skip their target
DBs.

## Verification

- `make build` clean
- `make check` clean (~4m28s, fmt + lint + vet + test)
- `go test ./examples/gastown/...` clean (13.6s, all maintenance tests
green)
- Sanity-verified: each script's precheck disabled independently makes
the corresponding subtest of
`TestMaintenanceDoltScriptsSkipDatabasesWithoutWispsTable` fail, with
clear error messages naming the un-skipped query
- `gofmt -l` clean, `go vet ./...` clean

## Multi-model review

5-reviewer panel (Claude × 3 lenses + Codex `gpt-5.4` + Copilot
`gpt-5.3-codex`) iterated twice:
- Iteration 1 flagged `jsonl-export.sh` as a major sibling-site bug
(Codex + Copilot agreed independently). Addressed.
- Iteration 2 clean across all reviewers; Codex independently
sanity-verified the fix by removing each precheck and confirming subtest
failure.

## Out of scope

- "Why are orphan databases being created in the first place" — separate
investigation. The `gascity_packs` orphan I observed was created today
during normal city operation with no trace in supervisor.log, suggesting
a different bug worth tracking down.
- The `is_user_database()` blocklist itself — left unchanged. The
precheck is additive, handles both system schemas and orphans uniformly,
and is self-healing for future cases.
- PR #1812 partially overlaps (adds `dolt` to the `is_user_database`
blocklist). This PR's `SHOW TABLES` precheck strictly subsumes that
change — `dolt` lacks a `wisps` table and would be skipped silently
regardless. Maintainer's call which to land first.

Closes #1816

<!-- codesmith:footer -->
---
<a
href="https://app.blacksmith.sh/gastownhall/codesmith/gascity/pr/1819"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-in-codesmith-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-in-codesmith-light.svg"><img
alt="View in Codesmith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/view-in-codesmith-dark.svg"></picture></a>
<sup>Need help on this PR? Tag <code>@codesmith</code> with what you
need.</sup>

- [ ] Let Codesmith autofix CI failures and bot reviews
<!-- /codesmith:footer -->

---------

Co-authored-by: sjarmak <sjarmak@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Broken behavior priority/p2 Medium — real problem, workaround exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant