-
Notifications
You must be signed in to change notification settings - Fork 0
docs: schema-version claiming and rt-client publish footguns #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,41 @@ When adding a new command module referenced by `cli.ts` (any file with a `module | |
|
|
||
| Every registry value is a thunk β `() => import("../commands/x.ts")` with the path spelled out literally β not an eagerly-evaluated namespace import. That's what keeps `rt --version` and every other dispatch from paying for the whole command surface: the bundler still statically discovers all 30 modules, but none of them evaluate until a command actually dispatches to it. Adding a static (non-thunked) `import` of a command module to `lib/module-registry.ts`, or a static value import of `lib/rt-render.tsx`/`ink` to `lib/command-tree.ts`, is a startup regression β `scripts/bench-startup.ts` gates this in the release workflow (`.github/workflows/release.yml`), and `lib/__tests__/no-eager-tui.test.ts` gates the command-tree and command-module cases directly. | ||
|
|
||
| ### `SCHEMA_VERSION` is claimed across sessions, not chosen per branch | ||
|
|
||
| Several agents work this repo at once, and `runMigrations` only replays when | ||
| `user_version < SCHEMA_VERSION`. So the first branch whose daemon opens | ||
| `~/.mattstack/rt/state.db` stamps the new number, and every *other* branch's | ||
| schema for that same number then silently never applies β its tables are | ||
| simply absent on that machine, with no error anywhere. This has already | ||
| happened once: two lanes both wrote a v4, one lane's daemon migrated the | ||
| real db minutes before the other merged, and the second lane's tables | ||
| never appeared. | ||
|
|
||
| Announce the version you are taking to the other sessions before you merge, | ||
| and renumber if you are second. To repair a db stamped by a schema that is | ||
| not the one on disk: stop the daemon, `PRAGMA user_version = <the previous | ||
| version>`, start it, and diff `sqlite_master` before and after to confirm | ||
| the other lane's tables survived (the replay is IF NOT EXISTS, so it is | ||
| data-preserving). | ||
|
|
||
| **Nothing but `IF NOT EXISTS` statements may appear in a `V*_SCHEMA` block.** | ||
| The runner execs `V1 + β¦ + Vn` as one statement on *every* bump, so an | ||
| `ALTER TABLE β¦ ADD COLUMN` that succeeded once throws `duplicate column | ||
| name` on the next bump, rolls the migration back, and makes every later | ||
| `openStateDb` call throw. Add a column by creating the table with it | ||
| (`IF NOT EXISTS`), or guard the add behind a `PRAGMA table_info` check. | ||
|
Comment on lines
+115
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ποΈ Data Integrity & Integration | π Major | β‘ Quick win π Supported by static analysisπ Script executed: #!/bin/bash
set -euo pipefail
python - <<'PY'
import sqlite3
db = sqlite3.connect(":memory:")
db.execute("CREATE TABLE t (id INTEGER)")
db.execute("CREATE TABLE IF NOT EXISTS t (id INTEGER, added TEXT)")
columns = {row[1] for row in db.execute("PRAGMA table_info(t)")}
assert "added" not in columns
print("CREATE TABLE IF NOT EXISTS does not add columns")
PYRepository: m4ttstack/rt Length of output: 198 π Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- repository convention scopes ---'
find /tmp/coderabbit-repo-knowledge/m4ttstack-rt-b8e6f495 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- applicable convention headers ---'
for f in /tmp/coderabbit-repo-knowledge/m4ttstack-rt-b8e6f495/*/*.md; do
[ -f "$f" ] || continue
printf '\n### %s\n' "$f"
head -40 "$f"
done
printf '%s\n' '--- CLAUDE.md relevant section ---'
cat -n CLAUDE.md | sed -n '90,135p'
printf '%s\n' '--- lib/state/db.ts migration definitions and callers ---'
rg -n -C 8 'V[0-9]+_SCHEMA|user_version|openStateDb|ALTER TABLE|CREATE TABLE' lib/state/db.tsRepository: m4ttstack/rt Length of output: 20634 Clarify the column-migration boundary If an existing table needs a new column, do not add it only to π€ Prompt for AI Agents |
||
|
|
||
| ### Publishing `@mattstack/rt-client` is release-class, from `main` only | ||
|
|
||
| `0.5.0` reached npm with fresh `.d.ts` files over a stale `index.js`: its | ||
| types promised verbs its runtime bundle did not contain, so consumers | ||
| type-checked and then got `undefined` at call time. Publish only from a | ||
| checkout on `main`, never from a branch, never with `--ignore-scripts` | ||
| (`prepack` is what rebuilds `dist/`), and grep the built bundle for your own | ||
| verbs before you publish. The package version is a shared resource like | ||
| `SCHEMA_VERSION`: announce the bump, and let whoever merges second renumber. | ||
|
|
||
| ### `packages/rt-client/dist/` goes stale without warning | ||
|
|
||
| `dist/` is gitignored, but `file:` consumers (mr-board, gitq, the console) copy it **verbatim** at install time rather than building from source. So any change or merge that touches rt-client's source leaves every consumer installing the previous build β the source is right, the shipped artifact is not, and nothing about the working tree looks wrong. Run `bun run build` in `packages/rt-client` after touching it, and after any merge that does. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ποΈ Data Integrity & Integration | π Major | β‘ Quick win
π Supported by static analysis
π Script executed:
Repository: m4ttstack/rt
Length of output: 7968
π Script executed:
Repository: m4ttstack/rt
Length of output: 50369
π Script executed:
Repository: m4ttstack/rt
Length of output: 35116
π Script executed:
Repository: m4ttstack/rt
Length of output: 19409
Prevent the repair from re-running legacy imports.
If
<the previous version>is0,runMigrationscalls each registered legacy importer. Thebranch-cacheimporter uses an upsert, so stale JSON can overwrite currentbranch_cacherows. Restrict the documented repair to versions greater than0, or provide a DDL-only path that skips legacy imports.π€ Prompt for AI Agents