You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(agent-context): brownfield-adoption direction doctrine + hardened UUID rule
The metaobjects-* skills were framed greenfield-only ("metadata is the spine,
generated code is disposable"), which licensed a backward migration loop: change
metadata → regenerate → treat the resulting compile/type errors in existing code
as bugs to fix. On an adoption onto existing working code / a live DB the
direction is the reverse — metadata FOLLOWS the code.
- authoring: new "Adopting onto an existing codebase — metadata FOLLOWS the code"
section (conditional on the brownfield predicate, reconciled with model-first):
author metadata + tune codegen to reproduce the existing native types, names,
and nullability; minimize churn to code the generator isn't replacing; ask on
ambiguity, default to least existing-code change. Hardened the UUID row + a
smell callout: NEVER field.string + @dbColumnType:uuid (generates a String over
a uuid column, forcing coercions; verify --db can't see it). field.uuid is the
match-the-code choice.
- audit: promoted UUID-as-string from non-failing advisory (axis I) to a real
correctness-adjacent finding (axis H2) with blast-radius counting; added an
adoption-direction guardrail on every proposed cutover.
- codegen: "make codegen match the code, not the code match codegen" — customize
owned generators / outputPattern / naming to reproduce the existing shape before
editing working call sites.
- always-on: one concise direction bullet (within the 120-line size gate).
- verify: "what verify can't catch — semantic mismodeling" + a project-local CI
ratchet lint (grep-fail on field.string paired with @dbColumnType:uuid) as the
migration's completion criterion and a permanent backstop.
Goldens regenerated across all four stacks; agent-context conformance, size-gate,
and capability-grounding suites green (42/42). The SDK agent-context bundle is a
build-time artifact (gitignored) and is not committed.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VXidfNN755CyTZTg1w8UV
Copy file name to clipboardExpand all lines: agent-context/templates/always-on.md.mustache
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ MetaObjects is a metadata standard: typed metadata in `metaobjects/` is the dura
6
6
spine; generated code is the disposable artifact. Regenerate with `{{codegenCommand}}`.
7
7
8
8
## Principles
9
+
- **Adopting onto existing code? Metadata FOLLOWS the code.** On a migration (existing working code / live DB), author metadata + tune codegen to *reproduce* what the code already is — native types (`field.uuid` when the code uses `UUID`, not `field.string`), names, nullability — so regen changes as little existing code as possible. The only existing code that should change is the hand-written layer codegen replaces; ask when a modeling choice is ambiguous. (Greenfield: model-first, below.)
9
10
- 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
11
- 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.
11
12
- Never hand-edit generated files — change the metadata and regenerate (three-way merge preserves hand-written regions).
0 commit comments