Skip to content

feat(v2): records — schema-version-pinned rows, validated bulk-upsert, references view (Phase 2)#225

Merged
JonnyTran merged 13 commits into
feat/v2-schema-registryfrom
feat/v2-records
Jul 7, 2026
Merged

feat(v2): records — schema-version-pinned rows, validated bulk-upsert, references view (Phase 2)#225
JonnyTran merged 13 commits into
feat/v2-schema-registryfrom
feat/v2-records

Conversation

@JonnyTran

Copy link
Copy Markdown
Member

Stacked on #219 (Phase 1: schema registry). Implements Phase 2 of the schema-centric data model — spec §5 (record row), §6 (validated write flow), §7 (records/references endpoints): docs/superpowers/specs/2026-06-27-schema-centric-data-model-design.md. Plan: docs/superpowers/plans/2026-07-03-v2-records.md.

What's included

  • v2_records table + V2Record ORM model (class named V2Record because a second Record breaks v1's string-based relationship lookups in the shared declarative registry) + Alembic migration 8136bc88ee3a (upgrade/downgrade round-trip verified)
  • V2RecordStatus enum (pending|completed|discarded) with its own PG type; v1 untouched
  • Validated bulk-upsert POST /api/v2/schemas/{id}/records:bulk-upsert: resolves each item's pinned or current schema version, fetches each distinct version's Pandera body from the object store once per request, validates all items via Phase 1's validate_record_fields before any write (all-or-nothing 422 with per-item detail), then merges v1-style on (schema_id, external_id); metadata/status are patch-like on update (documented)
  • GET /schemas/{id}/records (offset/limit 50/1000, status/reference filters, exact total) and DELETE /schemas/{id}/records?ids= (cap 100, 204)
  • GET /api/v2/references/{reference:path} — cross-schema document view grouped per schema; :path converter so DOI references (containing slashes) resolve; workspace-scoped + authorized; unknown reference returns an empty 200 view
  • SchemaPolicy.{upsert_records,list_records,delete_records}: reads = workspace member, writes = owner/admin member; member/non-member negative tests
  • 55 v2 tests green; roborev findings from jobs 64/68/70/71 addressed in-branch (see plan doc)

Out of scope (later phases)

LanceDB search/sync (Phase 3); questions/suggestions/responses (Phase 4).

Accepted caveat

Concurrent bulk-upserts racing on (schema_id, external_id) can surface an IntegrityError (500) — same class as v1's bulk behavior and Phase 1's accepted publish race; to be hardened when record writes move to the job queue.

@JonnyTran JonnyTran requested a review from a team as a code owner July 3, 2026 18:28
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
extralit-frontend Ignored Ignored Preview Jul 7, 2026 6:09am

JonnyTran added 2 commits July 6, 2026 19:05
…itions and record write process

- Clarified table names and purposes for `schemas`, `schema_versions`, and `v2_records`.
- Enhanced the description of the record write process, emphasizing validation and error handling.
- Updated API endpoint descriptions for schemas, schema versions, and records to reflect recent changes.
@JonnyTran JonnyTran merged commit 065a48d into feat/v2-schema-registry Jul 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant