Skip to content

Commit 49269da

Browse files
committed
docs(agent-context): warn against hand-mutating the live DB; make verify --db a done-check
The "schema is generated" principle covered "never hand-write SQL" but not the most common real-world violation: applying a schema change directly to a *running* database — an ad-hoc `psql` ALTER/CREATE to preview a column or unblock a boot. That drifts the live DB from the metadata + migration history and collides at the next migrate/boot ("column already exists") — a state no migration can reproduce. It slips past the metadata-first check precisely because it doesn't feel like a schema change. - always-on scaffold: add a principle — the live DB is a derived artifact too; apply schema only via `meta migrate`; run `meta verify --db` after any DB-touching work. - metaobjects-verify skill: add a section explaining the failure mode + naming the rationalization to catch, and positioning `verify --db` as a done-check, not just a CI gate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmVe7GGW7EPpxEMdGFHZiX
1 parent cfd96cc commit 49269da

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

agent-context/skills/metaobjects-verify/SKILL.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,29 @@ So even in a Java or Python or C# project, schema migration and `verify --db` ru
9898
through the Node `meta` tool. The per-port `gen`/codegen tooling stays native to
9999
the language; only schema crosses to Node.
100100

101+
## Never hand-edit the live database — apply schema only through the tool
102+
103+
The live schema is a derived artifact, exactly like generated code. **Do not mutate a running
104+
database by hand** — no `psql`/console `ALTER TABLE` / `CREATE` / `DROP`, not to preview a column, not
105+
to patch a mismatch, not to "just unblock" a boot. It is the single most common way a database ends up
106+
in a state no migration can reproduce:
107+
108+
- The column now exists but no migration recorded it, so the next `meta migrate` (or a JVM app's
109+
boot-time migrator) tries to add it again and dies on `column ... already exists` — or worse,
110+
silently diverges and the drift only surfaces days later.
111+
- "I'll just add it real quick so I can see it in the tool" is the exact rationalization to catch. It
112+
doesn't *feel* like a schema change, so it skips the metadata-first check — but it is one.
113+
114+
Apply every schema change the same way: change the metadata, then let `meta migrate` (or, for a
115+
project still driving its own migrator, a migration authored *to match* the regenerated schema) apply
116+
it. Want to see a new column in a tool or an app? Apply the migration and re-read — never reach for
117+
`psql`.
118+
119+
**Make `meta verify --db` a done-check, not just a CI gate.** Run it after any work that touched the
120+
database or the schema-shaping metadata, before you consider the task finished — it introspects the
121+
live DB against the metadata and fails on exactly this drift (a hand-added column, a missing index, a
122+
mismatched type), catching a manual poke immediately instead of at the next boot.
123+
101124
## Interpreting conformance / test failures
102125

103126
MetaObjects' behavior is pinned by cross-port **conformance corpora** (metamodel,

agent-context/templates/always-on.md.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ spine; generated code is the disposable artifact. Regenerate with `{{codegenComm
77

88
## Principles
99
- Pattern-derivable from metadata = codegen, never hand-write — FKs, CRUD, validators, finders, and the database schema and migrations. The schema is a disposable, generated artifact: change the metadata and regenerate, never hand-write SQL.
10+
- The **live database** is a derived artifact too — never hand-apply a schema change to a running DB (ad-hoc `psql`/console `ALTER`/`CREATE`/`DROP`), not even to preview a column or unblock a boot. Apply schema only through `meta migrate` (metadata → DDL). A hand-applied change drifts the live DB from the metadata + migration history and collides at the next migrate/boot ("column already exists") — a state no migration can reproduce. Run `meta verify --db` after any DB-touching work to catch that drift early.
1011
- Never hand-edit generated files — change the metadata and regenerate (three-way merge preserves hand-written regions).
1112
- Use the generated constants for any string that names metadata.
1213
- The loaded metadata model is READ-ONLY — never inject nodes or mutate the tree at load time (no "enrich the model on load" hooks). Need an extra field/column? Author it in the metadata, or derive it during codegen (read the metadata, emit output). Mutating the loaded model makes it diverge from what's declared — a bad practice reserved for very rare cases.

0 commit comments

Comments
 (0)