Summary
doc(store, name) on a name already cataloged as a relational table bypasses schema validation. Rows written via doc() can violate the table schema; LibreDB Studio and catalog "faithful view" break.
Audit ID: Section 2 Med — Wave 2
Root cause
doc() calls assertUserName(collection) but does not check catalog kind. Relational tables register via recordRelational() in catalog.ts.
Fix
In doc() (after assertUserName), if catalog has kind === "relational" for name → throw:
libredb: "${name}" is a relational table; use table() instead of doc()
Mirror inverse guard on table() if missing.
Tests
- Create table →
doc(db, sameName) throws.
- Uncataloged collection still works.
Acceptance criteria
Verification
Summary
doc(store, name)on a name already cataloged as a relational table bypasses schema validation. Rows written viadoc()can violate the table schema; LibreDB Studio and catalog "faithful view" break.Audit ID: Section 2 Med — Wave 2
Root cause
doc()callsassertUserName(collection)but does not check catalog kind. Relational tables register viarecordRelational()incatalog.ts.Fix
In
doc()(afterassertUserName), if catalog haskind === "relational"forname→ throw:libredb: "${name}" is a relational table; use table() instead of doc()Mirror inverse guard on
table()if missing.Tests
doc(db, sameName)throws.Acceptance criteria
doc().bun run gategreen.Verification