test(cli): shared-files journey + .gitignore + docs (§11.6 files C5)

- collections.rs: shared_files_collection_is_read_write_across_the_subtree
  — a group declares kv+docs+files in one string-or-table manifest; authed
  app A creates a blob via files::shared_collection("assets").create(...),
  app B lists + gets the SAME bytes back across the subtree, a
  sibling-subtree app gets CollectionNotShared, collections ls shows all
  three kinds. Live-verified the bytes land under
  files/groups/<group_id>/assets/<id[0:2]>/<id>.
- .gitignore: ignore /crates/picloud-cli/data (the CLI journey harness
  spawns the server from that dir; the files journey is the first CLI test
  to write blobs).
- docs: design §11.6 (KV+DOCS+FILES shipped; topics/queue still deferred),
  sdk-shape (files::shared_collection), CLAUDE.md current-focus.

Full journey suite 117/117; schema blessed (55 migrations); workspace
clippy -D clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-30 19:56:47 +02:00
parent 17221a2683
commit 9c6d690792
5 changed files with 179 additions and 30 deletions

View File

@@ -1044,31 +1044,38 @@ Resolved items now live inline next to their topic. What genuinely remains:
real shared-scope authz model. Optionally, trigger/route **templates** (§4.5) if cardinality
demands.
> **Shipped — §11.6 KV + DOCS slices (full shared read/write).** A group declares a collection
> group-shared (`[group]` manifest `collections = [...]`, owner-polymorphic marker table
> **Shipped — §11.6 KV + DOCS + FILES slices (full shared read/write).** A group declares a
> collection group-shared (`[group]` manifest `collections = [...]`, owner-polymorphic marker table
> `0052_group_collections` with a `kind` discriminator); the data lives in a per-kind store keyed by
> the owning `group_id` (NOT app — a shared row belongs to the group): `0053_group_kv_entries`
> (`kind='kv'`) and `0054_group_docs` (`kind='docs'`, the queryable-JSON store). Scripts read/write
> via the **explicit** `kv::shared_collection("catalog")` / `docs::shared_collection("articles")`
> handles (distinct `GroupKvHandle`/`GroupDocsHandle`; `shared` alone is a Rhai reserved word, hence
> `shared_collection`). The service resolves the owning group from `cx.app_id`'s ancestor chain
> **filtered by kind**, nearest-group-wins — **that walk is the isolation boundary**: a foreign
> app's chain never contains the owning group, so the name returns `CollectionNotShared`; a `kv` and
> a `docs` collection of the same name are distinct stores. **Trust model:** reads are open to any
> subtree script (anonymous public HTTP included — the declaration *is* the grant); **writes require
> an authenticated editor+** on the owning group (`GroupKvWrite`/`GroupDocsWrite`, fail closed on an
> anonymous principal). The docs slice reuses the `docs_filter` DSL — `build_find_query` was
> generalized on its owner column (`docs`/`app_id` vs `group_docs`/`group_id`), both compile-time
> literals, so the find SQL has one source. Declarative authoring uses the **string-or-table** form:
> `collections = ["catalog", { name = "articles", kind = "docs" }]` (bare string = `kv`). CASCADE on
> group delete; an app delete leaves the shared data. Live- + journey-validated for both kinds (app
> A writes, app B reads/finds; a sibling-subtree app gets `CollectionNotShared`).
> (`kind='kv'`), `0054_group_docs` (`kind='docs'`, the queryable-JSON store), and `0055_group_files`
> (`kind='files'`, the blob store — metadata in Postgres, bytes on disk under
> `<root>/files/groups/<group_id>/...`, a `groups/` infix disjoint from the per-app `files/<app_id>/`
> subtree so the existing recursive orphan sweeper covers both). Scripts read/write via the
> **explicit** `kv::shared_collection("catalog")` / `docs::shared_collection("articles")` /
> `files::shared_collection("assets")` handles (distinct `GroupKvHandle`/`GroupDocsHandle`/
> `GroupFilesHandle`; `shared` alone is a Rhai reserved word, hence `shared_collection`). The service
> resolves the owning group from `cx.app_id`'s ancestor chain **filtered by kind**, nearest-group-wins
> — **that walk is the isolation boundary**: a foreign app's chain never contains the owning group, so
> the name returns `CollectionNotShared`; a `kv`, a `docs`, and a `files` collection of the same name
> are distinct stores. **Trust model:** reads are open to any subtree script (anonymous public HTTP
> included — the declaration *is* the grant); **writes require an authenticated editor+** on the
> owning group (`GroupKvWrite`/`GroupDocsWrite`/`GroupFilesWrite`, fail closed on an anonymous
> principal). The docs slice reuses the `docs_filter` DSL — `build_find_query` was generalized on its
> owner column (`docs`/`app_id` vs `group_docs`/`group_id`), both compile-time literals, so the find
> SQL has one source; the files slice likewise generalized the atomic-write + checksum-on-read path
> helpers on an owner-relative dir, so the security-sensitive disk mechanics have one source.
> Declarative authoring uses the **string-or-table** form: `collections = ["catalog", { name =
> "articles", kind = "docs" }, { name = "assets", kind = "files" }]` (bare string = `kv`). CASCADE on
> group delete; an app delete leaves the shared data. Live- + journey-validated for all three kinds
> (app A writes, app B reads/finds/gets the same bytes; a sibling-subtree app gets
> `CollectionNotShared`).
>
> **Deferred (documented gaps):** write-triggers/events on shared collections (the "group trigger
> has no app to watch" problem); **files/topics/queue** shared collections (the `kind` column
> generalizes — files needs group-keyed disk paths); per-group total-size quotas + write-rate
> limits; CAS/`set_if`; app-declared collections. Multi-node tree-apply leans on the runtime
> backstop for no-op edges, as elsewhere.
> has no app to watch" problem); **topics/queue** shared collections (trigger-centric, same gap);
> per-group total-size quotas + write-rate limits; CAS/`set_if`; an operator admin API for shared
> blobs (scripts use the SDK; `pic collections ls` shows the marker — matches KV/docs); app-declared
> collections. Multi-node tree-apply leans on the runtime backstop for no-op edges, as elsewhere.
### 11.1 Re-sequencing review (post-Phase-3)

View File

@@ -99,14 +99,18 @@ script. **Reads** are open to any subtree script (including anonymous
public endpoints — declaring the collection *is* the grant); **writes**
require an authenticated principal with editor+ on the owning group.
**Docs too.** The same handle exists for the queryable-JSON store:
`docs::shared_collection("articles")` returns a shared-docs handle with the
full `create`/`get`/`find`/`find_one`/`update`/`delete`/`list` surface (same
trust model + isolation boundary as the KV one). A `[group]` declares a
**Docs and files too.** The same handle exists for the queryable-JSON store
and the blob store: `docs::shared_collection("articles")` returns a shared-docs
handle with the full `create`/`get`/`find`/`find_one`/`update`/`delete`/`list`
surface, and `files::shared_collection("assets")` returns a shared-files handle
with `create`/`head`/`get`/`update`/`delete`/`list` (Blob in/out) — both with
the same trust model + isolation boundary as the KV one. A `[group]` declares a
collection's store with a kind: `collections = ["catalog", { name =
"articles", kind = "docs" }]` — a bare string is `kv`, a `{ name, kind }`
table sets it. A `kv` and a `docs` collection of the same name are distinct
stores. (Files/topics/queue shared collections are not yet implemented.)
"articles", kind = "docs" }, { name = "assets", kind = "files" }]` — a bare
string is `kv`, a `{ name, kind }` table sets it (`kv`/`docs`/`files`). A `kv`,
a `docs`, and a `files` collection of the same name are distinct stores; group
blobs live on disk under `<root>/files/groups/<group_id>/...`. (Topics/queue
shared collections are not yet implemented.)
## Error convention