Skip to content

[P2][lens] Block doc() on cataloged relational tables #30

Description

@cevheri

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

  • Cataloged relational names blocked from doc().
  • Clear error message.
  • bun run gate green.
  • Changeset required.

Verification

bun run gate

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions