WIP: feat: database backbone idea - #6274
Draft
404Wolf wants to merge 1 commit into
Draft
Conversation
The first draft of the databases system: Postgres migration, a hexagonal
crates/databases with domain models/ports/service, and the SQL-first API
surface (POST /exec, GET /{id}/sqlite, structured schema ops). Every
implementation is a documented todo!(); the crate compiles warning-free
with all features.
Columns bind to models_properties definitions; cells are PropertyValue
JSONB per row; user SQL runs against per-request in-memory SQLite
materializations (rusqlite, pinned to share sqlx's libsqlite3-sys) with
session-changeset write-through. databases-plan/ holds the full design.
Contributor
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords (3)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
The first-draft skeleton of Macro Databases — user-facing tables of typed rows where SQL is the only public read/write verb. Everything compiles warning-free; every implementation is a documented
todo!(). The point of this PR is to agree on the shape before filling anything in.Full design docs live in
databases-plan/(start withsketch.md); interactive UX mock: https://claude.ai/code/artifact/635f0600-3d70-4a70-8564-f37af63042aaThe architecture in one paragraph
Postgres stores it,
entity_accessguards it, a per-request ephemeral in-memory SQLite runs it. Columns are bindings tomodels_propertiesproperty definitions (options, colors, tags, and promotion machinery reused, not copied); cells are the existingPropertyValuetagged-union JSONB, one dense object per row. User SQL executes against a permission-scoped materialization of exactly the tables it references, with the property model compiled into SQLite constraints (STRICT,CHECKfrom select options, FKs) so SQLite itself validates writes; the session-extension changeset is then translated into typed domain commands and applied to Postgres — the single write path.What's in the PR
20260908204308_add_databases):databases,database_tables(with aversioncounter for liveness/caching),database_columns(placement overproperty_definitions),database_rows(JSONB cells),database_row_links(junction for relations).crates/databases, hexagonal per the house guard (crates/remindersas template):domain/models.rs— the full vocabulary: entities, schema commands, and the exec pipeline types (Catalog,TableDeps,MaterializedTable,RowChange,ExecOutcome).domain/ports.rs—DatabasesRepo,ColumnDefinitionStore(wraps properties),MagicTables(permission-scoped platform data:people,documents,tasks, …),SqlExecutor(analyze via authorizer → deps; sandboxed execute → results + changeset),TableEventPublisher, and theDatabasesServicetrait.domain/service.rs—DatabasesServiceImplwith the 10-step exec pipeline documented at thetodo!(). The catalog build is the authorization boundary for SQL: unreadable tables don't exist at prepare time.outbound/— Postgres repo,RusqliteExecutor(rusqlite pinned to 0.32 so its libsqlite3-sys unifies with sqlx-sqlite's — cargo allows onelinks = sqlite3), magic-table registry, Redis event publisher. All stubs.inbound/axum_router.rs— the tiny surface:POST /exec,GET /{id}/sqlite(takeout snapshot),POST /+ table/column schema ops (structured because definitions carry config DDL can't express). Handlers are thin; receipted routes aretodo!()pendingEntityType::Database+ a receipt extractor.Deliberately NOT here yet
EntityType::Databaseplumbing (~26-file blast radius), the entity_access extractor,PropertyOwner::Databasemigration, DSS wiring, AI tools, SDK, frontend. Each is specced indatabases-plan/backend-implementation.mdwith a phased plan.Open questions to review
base_versionsopt-in compare-and-swap, otherwise cell-level LWW.GET /{id}/sqliteis read-only takeout in v1; changeset upload is a possible later tier sharing the same applier.