latticesql 1.16.2 → 1.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2095,13 +2095,24 @@ a parent link, while the reverse side (other entities that point here) plus
2095
2095
  many-to-many junctions become the drill-in sub-folders. Declare `ref:` on your
2096
2096
  foreign-key fields to get the nested file tree.
2097
2097
 
2098
- The header carries the logo, undo/redo, the workspace (database) switcher, and a
2099
- **settings gear** (top-right). The gear opens a slide-over drawer with **Database**,
2098
+ The header carries the logo, undo/redo, the **workspace switcher**, and a
2099
+ **settings gear** (top-right). The gear opens a slide-over drawer with **Workspace**,
2100
2100
  **Lattice**, and **User** settings plus an **Advanced mode** toggle. Turn Advanced
2101
2101
  mode on to switch the object/row views back to the classic editable **table + row**
2102
2102
  interface (below); turn it off for the file-system workspace. The left sidebar is
2103
2103
  slim and collapsible. The assistant rail is unchanged in either mode.
2104
2104
 
2105
+ **One workspace model (v1.16.4+).** A workspace _is_ a Lattice DB. The header has a
2106
+ single workspace switcher listing every database — local or cloud, created or joined —
2107
+ and its "+ New workspace…" button opens the create/join wizard (New local / New cloud /
2108
+ Join existing cloud). The GUI always operates inside a `.lattice` root: opening a bare
2109
+ config adopts it (and its database, referenced in place — nothing is moved) as the
2110
+ active workspace. There is no separate "database mode". The word "database" is reserved
2111
+ for a specific workspace's connection details (the connection panel in Workspace
2112
+ Settings). This applies to the GUI/CLI app only — the `latticesql` library API and the
2113
+ headless `render`/`generate`/`watch` commands still run against a bare config or
2114
+ Postgres URL with no root.
2115
+
2105
2116
  ### Assistant sidebar (v2.0+)
2106
2117
 
2107
2118
  The GUI has a fixed right sidebar with a live **activity feed** — every change
@@ -2142,11 +2153,11 @@ Chat threads, files, and secrets are all stored as native Lattice entities.
2142
2153
 
2143
2154
  The convergence means you don't need to duplicate entity-context definitions in YAML for the GUI to find rendered files.
2144
2155
 
2145
- **Database wizard form (v1.13.2+).** The Postgres connection form (used by Migrate to cloud + Connect to existing cloud) disables browser autocapitalize, autocorrect, and spellcheck on every text input, and trims whitespace on every read. This avoids silent failure modes where macOS Safari / iOS turned a Supabase tenant user `postgres.<ref>` into `Postgres.<ref>` on submit, and where pasted credentials carrying a trailing newline produced opaque "zero-length delimiter identifier" or SCRAM-mismatch errors. `probeCloud` also folds SQLSTATE + `routine` into `result.error` so the GUI's "Unreachable: …" surface is actionable.
2156
+ **Database wizard form (v1.13.2+).** The Postgres connection form (used by Migrate to cloud + the Join-a-team invite flow) disables browser autocapitalize, autocorrect, and spellcheck on every text input, and trims whitespace on every read. This avoids silent failure modes where macOS Safari / iOS turned a Supabase tenant user `postgres.<ref>` into `Postgres.<ref>` on submit, and where pasted credentials carrying a trailing newline produced opaque "zero-length delimiter identifier" or SCRAM-mismatch errors. `probeCloud` also folds SQLSTATE + `routine` into `result.error` so the GUI's "Unreachable: …" surface is actionable.
2146
2157
 
2147
- **Switch vs. migrate (v1.13.2+ wording).** "Connect to existing cloud" _switches_ the project's `db:` line to point at the cloud; the local SQLite file stays on disk and you can switch back by editing the YAML or via the Databases catalog under User Config. Use "Migrate to cloud" only when you want to _push_ the local data into a fresh empty target.
2158
+ **Migrate vs. join (1.16.4).** The standalone "Connect to existing cloud" wizard (which switched a project's `db:` line to a raw cloud on its own) was removed — the two cloud operations are now **Migrate to cloud** (push your local workspace's data into a fresh cloud Postgres; you become the owner) and **Join a team (invite)** (redeem an invite token to join a workspace someone shared with you). The `connect-existing` endpoint still backs the invite‑redeem path for an active cloud that needs an invite.
2148
2159
 
2149
- **Upgrade to team cloud — works against direct Postgres URLs (v1.13.3+).** The "Upgrade to team cloud" action previously HTTP-POSTed to `/api/auth/register` on the cloud URL, which fails with `Request cannot be constructed from a URL that includes credentials` when the cloud URL is a Postgres connection string. v1.13.3 dispatches on URL scheme: `http(s)://` keeps the HTTP path; `postgres(ql)://` calls the new `registerDirectViaPostgres()` helper that drives the same INSERT sequence directly against the cloud Postgres. Same invariants enforced both ways.
2160
+ **Cloud workspaces initialize automatically (v1.16.3+).** A cloud database _is_ a cloud workspace with members — there is no separate "upgrade to team" step. The moment a database is migrated or connected to Postgres, its member/share machinery is created automatically (the workspace name is used as the identity; an existing un-initialized cloud initializes on open, with the opener as owner). The underlying mechanism is the `registerDirectViaPostgres()` helper, which drives the identity/member INSERT sequence directly against the cloud Postgres (the older HTTP `/api/auth/register` path is still used when the cloud URL is `http(s)://`). The standalone "Upgrade to team cloud" action and its `/api/dbconfig/upgrade-to-team` route were removed in 1.16.3.
2150
2161
 
2151
2162
  **Dashboard renders every entity (v1.13.3+).** Previously the dashboard cards filtered through a hardcoded entity list (`meetings`, `people`, `messages`, `projects`, `repositories`, `files`). Installs whose YAML declared different names saw a blank dashboard. Now every first-class entity gets a card; the hardcoded list survives as an ordering preference only.
2152
2163
 
@@ -2160,7 +2171,7 @@ The convergence means you don't need to duplicate entity-context definitions in
2160
2171
  - **Table view** (`#/objects/<entity>`, Advanced mode) — intrinsic columns, `belongsTo` chips, and a column per junction this entity participates in.
2161
2172
  - **Detail view** (`#/objects/<entity>/<id>`, Advanced mode) — read mode by default; `Edit` flips cells into inputs (`Save` PATCHes, `Cancel` reverts).
2162
2173
  - **Settings** (v2.0+) — opened from the header gear (Database / Lattice / User tabs + the Advanced-mode toggle); the legacy `#/settings/*` hashes still resolve and open the drawer.
2163
- - **Data Model** (inside **Database Settings**, v1.14+) — entity-level graph including the native `files`/`secrets` objects, with a per-entity editor. On a team cloud each table you own carries a **Share with team / Unshare** toggle. (Pre-1.14 this was a separate `#/settings/data-model` nav item; that hash still resolves for back-compat.)
2174
+ - **Data Model** (inside **Workspace Settings**, v1.14+) — entity-level graph including the native `files`/`secrets` objects, with a per-entity editor. On a cloud workspace each table you own carries a **Share with workspace / Make private** toggle, and graph nodes are colored by share status (yellow = shared, red = private, green = selected) with a legend. (Pre-1.14 this was a separate `#/settings/data-model` nav item; that hash still resolves for back-compat.)
2164
2175
 
2165
2176
  **Internal tables added on first open**
2166
2177
 
@@ -2176,22 +2187,22 @@ These tables are prefixed with `_lattice_gui_` and are hidden from `/api/entitie
2176
2187
 
2177
2188
  **HTTP surface** (all routes scoped to `http://127.0.0.1:<port>/api`):
2178
2189
 
2179
- | Route | Method | Lattice call |
2180
- | ------------------------------ | ------ | --------------------------------------------------------------- |
2181
- | `/project` | GET | (config + manifest summary) |
2182
- | `/entities` | GET | tables + `db.count` per table |
2183
- | `/graph` | GET | (schema graph for Data Model) |
2184
- | `/tables/:table/rows` | GET | `db.query(table, …)` |
2185
- | `/tables/:table/rows` | POST | `db.insert(table, body)` |
2186
- | `/tables/:table/rows/:id` | GET | `db.get(table, id)` |
2187
- | `/tables/:table/rows/:id` | PATCH | `db.update(table, id, body)` |
2188
- | `/tables/:table/rows/:id` | DELETE | `db.delete(table, id)` |
2189
- | `/tables/:junction/link` | POST | `db.link(junction, body)` |
2190
- | `/tables/:junction/unlink` | POST | `db.unlink(junction, body)` |
2191
- | `/schema/entities` | POST | create a new entity/table |
2192
- | `/schema/entities/:name/share` | POST | share/unshare a table you own with the team (cloud, owner-only) |
2193
-
2194
- On a team cloud, `/entities` and `/graph` (and the queryable `/tables/*` allowlist) are filtered to the tables you own plus tables shared to the team — so the API surface matches exactly what the GUI shows; a table you can't see is not reachable. `/entities` rows carry `shared` / `ownedByMe` flags in that mode.
2190
+ | Route | Method | Lattice call |
2191
+ | ------------------------------ | ------ | ------------------------------------------------------------------- |
2192
+ | `/project` | GET | (config + manifest summary) |
2193
+ | `/entities` | GET | tables + `db.count` per table |
2194
+ | `/graph` | GET | (schema graph for Data Model) |
2195
+ | `/tables/:table/rows` | GET | `db.query(table, …)` |
2196
+ | `/tables/:table/rows` | POST | `db.insert(table, body)` |
2197
+ | `/tables/:table/rows/:id` | GET | `db.get(table, id)` |
2198
+ | `/tables/:table/rows/:id` | PATCH | `db.update(table, id, body)` |
2199
+ | `/tables/:table/rows/:id` | DELETE | `db.delete(table, id)` |
2200
+ | `/tables/:junction/link` | POST | `db.link(junction, body)` |
2201
+ | `/tables/:junction/unlink` | POST | `db.unlink(junction, body)` |
2202
+ | `/schema/entities` | POST | create a new entity/table |
2203
+ | `/schema/entities/:name/share` | POST | share/unshare a table you own with the cloud workspace (owner-only) |
2204
+
2205
+ On a cloud workspace, `/entities` and `/graph` (and the queryable `/tables/*` allowlist) are filtered to the tables you own plus tables shared to the workspace — so the API surface matches exactly what the GUI shows; a table you can't see is not reachable. `/entities` rows carry `shared` / `ownedByMe` flags in that mode.
2195
2206
 
2196
2207
  The server only binds to `127.0.0.1` and has no authentication. See [SECURITY.md](./SECURITY.md) for the threat model — do not expose this port to a non-loopback interface.
2197
2208
 
@@ -2312,7 +2323,7 @@ lattice teams dlq purge --team <name> [--id <id>] # discard without applying
2312
2323
 
2313
2324
  **Per-table ownership + opt-in sharing (v1.14+).** Team members share one physical Postgres, so visibility is enforced at the app layer via a `__lattice_object_owners` table: each table records its creator, and a user sees only the tables they own plus tables explicitly shared to the team. The native `files`/`secrets` objects are owned by the database creator and private by default. Sharing is an explicit, owner-only action (not a side effect of creating a table). The filter gates API access, not just the display.
2314
2325
 
2315
- **Same flows from the GUI (v1.14+).** The local `lattice gui` drives the entire teams lifecycle from **Database Settings**: rename (owner-only), invite by email (owner-only), the inline Members list (the owner is always shown as `creator`; your own row offers Leave/Destroy; non-owners can't kick), share/unshare from the Data Model, and sync status. Member admin is resolved from `GET /api/dbconfig` against the active cloud DB, so it works even when the team cloud itself is the active database. Identity (display name + email) comes from `~/.lattice/identity.json` and is locked in the Join modal. Leaving a team removes the local config + credential and switches you to another database.
2326
+ **Same flows from the GUI (v1.14+).** The local `lattice gui` drives the entire cloud-workspace lifecycle from **Workspace Settings**: rename (owner-only), invite by email (owner-only), the inline Members list with pending invitees (the owner is always shown as `creator`; your own row offers Leave/Destroy; non-owners can't kick), share/unshare from the Data Model, and sync status. Member admin is resolved from `GET /api/dbconfig` against the active cloud DB, so it works even when the cloud workspace itself is the active database. Identity (display name + email) comes from `~/.lattice/identity.json` and is locked in the Join modal. Leaving a workspace removes the local config + credential and switches you to another database.
2316
2327
 
2317
2328
  **Joining via the GUI is one click (v1.13.7+).** When you click "Join via invite" and the redeem succeeds, the team's cloud URL is automatically saved as a switchable database credential and a sibling YAML config is written to your project directory. The new entry shows up in the database dropdown as `<team-name>.config`. Clicking it opens the SPA with the team's shared tables already populated — no YAML editing, no `db.define()` calls.
2318
2329
 
@@ -2327,11 +2338,11 @@ The full architecture, schema, and HTTP surface live in [docs/teams.md](./docs/t
2327
2338
  Lattice Teams + the GUI's Database panel now flow through a state machine:
2328
2339
 
2329
2340
  ```
2330
- LOCAL → CLOUD CONNECTED → TEAM CLOUD
2331
- (migrate) (upgrade)
2341
+ LOCAL → CLOUD WORKSPACE (owner | member | needs-invite)
2342
+ (migrate / connect)
2332
2343
  ```
2333
2344
 
2334
- Each transition is one-way: once on cloud, the panel does not surface a revert-to-local button. Disconnecting from the cloud temporarily is a follow-up; for v1.13 the in-place reconnection happens automatically when the GUI reopens.
2345
+ Migrating or connecting to Postgres produces a cloud workspace directly — its member/share machinery is initialized automatically, with no separate "upgrade" step (the intermediate `cloud-connected` state was removed in 1.16.3). The transition is one-way: once on cloud, the panel does not surface a revert-to-local button. Disconnecting from the cloud temporarily is a follow-up; the in-place reconnection happens automatically when the GUI reopens.
2335
2346
 
2336
2347
  Public API surface (the GUI's `/api/dbconfig/*` routes are thin wrappers):
2337
2348
 
@@ -2368,17 +2379,20 @@ await client.connectToExistingCloud({
2368
2379
  name: 'Bob',
2369
2380
  });
2370
2381
 
2371
- // 4. Upgrade an already-connected cloud DB to a team cloud
2372
- await client.upgradeToTeamCloud({
2382
+ // 4. Initialize the workspace member/share machinery on a cloud DB.
2383
+ // The GUI now does this automatically on migrate/connect/open; the
2384
+ // helper remains for programmatic use (idempotent — a no-op if the
2385
+ // cloud is already a workspace).
2386
+ await client.ensureCloudWorkspaceIdentity({
2373
2387
  label: 'atlas',
2374
2388
  cloudUrl: 'postgres://u:p@host/db',
2375
- teamName: 'Atlas',
2389
+ workspaceName: 'Atlas',
2376
2390
  email: 'alice@example.com',
2377
2391
  displayName: 'Alice',
2378
2392
  });
2379
2393
  ```
2380
2394
 
2381
- GUI consumers don't need to call these directly — the Database panel surfaces them as wizards (`Migrate to cloud →`, `Connect to existing cloud →`, `Upgrade to team cloud →`).
2395
+ GUI consumers don't need to call these directly — the Database panel surfaces `Migrate to cloud →`, and joining a shared workspace goes through `Join a team (invite)`; workspace initialization is automatic. (The standalone "Connect to existing cloud" wizard was removed in 1.16.4.)
2382
2396
 
2383
2397
  HTTP surface (all under `/api/dbconfig/*`, localhost-only, same auth model as the rest of `lattice gui`):
2384
2398
 
@@ -2388,10 +2402,9 @@ HTTP surface (all under `/api/dbconfig/*`, localhost-only, same auth model as th
2388
2402
  | POST | `/api/dbconfig/probe` | `probeCloud(url)` |
2389
2403
  | POST | `/api/dbconfig/migrate-to-cloud` | `migrateLatticeData` + `archiveLocalSqlite` |
2390
2404
  | POST | `/api/dbconfig/connect-existing` | `TeamsClient.connectToExistingCloud` |
2391
- | POST | `/api/dbconfig/upgrade-to-team` | `TeamsClient.upgradeToTeamCloud` |
2392
2405
  | POST | `/api/dbconfig/save` / `connect` / `test` | unchanged from v1.12 |
2393
2406
 
2394
- The `state` field on `GET /api/dbconfig` is one of: `local`, `cloud-connected`, `team-cloud-creator`, `team-cloud-member`, `team-cloud-needs-invite`. The SPA badge color-codes them; the routes use them only for response shape.
2407
+ The `state` field on `GET /api/dbconfig` is one of: `local`, `team-cloud-creator`, `team-cloud-member`, `team-cloud-needs-invite` (the `cloud-connected` state was removed in 1.16.3). The SPA badge color-codes them (labeled "CLOUD · OWNER / MEMBER / NEEDS INVITE"); the routes use them only for response shape.
2395
2408
 
2396
2409
  ---
2397
2410