[GH-ISSUE #5878] [Feature]: Let capability packages register and persist their own file tables #3244

Closed
opened 2026-10-21 06:01:02 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Gunterlie on GitHub (Sep 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5878

Originally assigned to: @Gunterlie on GitHub.

What problem does this solve?

The Slurp capability package needs package-owned storage. Slurp declares its own file tables and cannot persist them.

The file-backed store builds all table metadata once, at module load, from a hardcoded allowlist of the Engine's own tables. Any table name outside that list has no metadata, so getMeta() throws:

[file-storage] Unsupported table: <name>

A downloaded capability package therefore has no supported way to persist its own data. Its only option is to borrow an Engine table that was designed for something else, which means writing package rows into a schema the package does not own, sharing a flush and manifest entry with unrelated Engine data, and having those rows travel in profile export/import as if they were Engine data.

This is an Engine-side gap. The package side already declares tables; the store simply has no entry point to accept them.

Proposed solution

Add a storage-side API on the live store that registers package-supplied file tables.

Packages activate after the store's initialize(), so registration has to work against an already-running store rather than at boot. A registered table should end up with everything a boot-loaded table gets, or it would accept writes and silently lose them: validated metadata, a row container, its existing rows read off disk, membership in the flush loop, and an entry in the snapshot manifest.

Required properties:

  • Idempotent, so a package reload re-registering the same table does not reset it.
  • Cannot shadow an Engine table; the existing definition wins.
  • Failures are per table and logged, not thrown, so one malformed package table definition cannot abort host startup.

Security is the load-bearing part. Table names become filesystem paths (tables/<name>.json, tables/<name>/) with no escaping anywhere in the store. That was safe only while every name came from the Engine's own hardcoded list. An unvalidated package-supplied name such as ../../.ssh/authorized_keys would be an arbitrary-write primitive outside the data directory, so a package-supplied name must be validated before it reaches any path join or any registry.

Two further constraints follow from how the store already works:

  • Registered tables must be sharded. SHARDED_TABLES aliases the file-backed table list, so a name added to that list becomes sharded by array identity whether or not that was intended. The sharded-table lookup set must be kept in step with the list rather than remaining a module-load snapshot, or the load, flush and delete paths would each classify the same table differently.
  • A table with no primary key must be refused at registration. Registered tables shard by primary key, so a keyless table would register cleanly and then fail on its first insert with no stable shard key, long after a package author could connect that failure to the table definition.

Profile export/import should deliberately exclude registered tables. A profile snapshot is portable user data that may be restored into a different install, where the owning package may not exist; importing those rows would fail at restore time or leave silent orphans with no schema to validate against. Package data still persists normally and is captured by a full data-directory backup, which is scoped to one install.

Alternatives considered

  • Add Slurp's tables to the Engine's hardcoded list. Rejected: it makes the Engine carry schema for an optional downloadable package, and it does not generalise to the next package. It also puts package rows into profile export, which is the wrong portability boundary.
  • Let packages borrow an existing Engine table. This is the status quo. It stores package rows under a schema the package does not own and gives the package no control over its own data lifecycle.
  • A separate storage mechanism just for packages. Rejected: it duplicates the crash-safe shard pipeline, the flush scheduling, the manifest and the corruption recovery that the file-backed store already has, and it is the parts that are hard to get right that would be duplicated.
  • Per-store instance registries instead of process-global ones. This is the cleaner design, but the Engine's table metadata is already process-global and reached through module-level lookups, so instance registries would mean threading a store instance through getMeta() and the whole lookup surface. That is a much larger change than the gap warrants while production runs a single store per process.

Additional context

The Engine currently has no caller that loads package-supplied table objects, so the first change here is the storage-side API only. Wiring a package loader to it is separate work.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Gunterlie on GitHub (Sep 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5878 Originally assigned to: @Gunterlie on GitHub. ## What problem does this solve? The Slurp capability package needs package-owned storage. Slurp declares its own file tables and cannot persist them. The file-backed store builds all table metadata once, at module load, from a hardcoded allowlist of the Engine's own tables. Any table name outside that list has no metadata, so `getMeta()` throws: ``` [file-storage] Unsupported table: <name> ``` A downloaded capability package therefore has no supported way to persist its own data. Its only option is to borrow an Engine table that was designed for something else, which means writing package rows into a schema the package does not own, sharing a flush and manifest entry with unrelated Engine data, and having those rows travel in profile export/import as if they were Engine data. This is an Engine-side gap. The package side already declares tables; the store simply has no entry point to accept them. ## Proposed solution Add a storage-side API on the live store that registers package-supplied file tables. Packages activate after the store's `initialize()`, so registration has to work against an already-running store rather than at boot. A registered table should end up with everything a boot-loaded table gets, or it would accept writes and silently lose them: validated metadata, a row container, its existing rows read off disk, membership in the flush loop, and an entry in the snapshot manifest. Required properties: - Idempotent, so a package reload re-registering the same table does not reset it. - Cannot shadow an Engine table; the existing definition wins. - Failures are per table and logged, not thrown, so one malformed package table definition cannot abort host startup. Security is the load-bearing part. Table names become filesystem paths (`tables/<name>.json`, `tables/<name>/`) with no escaping anywhere in the store. That was safe only while every name came from the Engine's own hardcoded list. An unvalidated package-supplied name such as `../../.ssh/authorized_keys` would be an arbitrary-write primitive outside the data directory, so a package-supplied name must be validated before it reaches any path join or any registry. Two further constraints follow from how the store already works: - Registered tables must be sharded. `SHARDED_TABLES` aliases the file-backed table list, so a name added to that list becomes sharded by array identity whether or not that was intended. The sharded-table lookup set must be kept in step with the list rather than remaining a module-load snapshot, or the load, flush and delete paths would each classify the same table differently. - A table with no primary key must be refused at registration. Registered tables shard by primary key, so a keyless table would register cleanly and then fail on its first insert with no stable shard key, long after a package author could connect that failure to the table definition. Profile export/import should deliberately exclude registered tables. A profile snapshot is portable user data that may be restored into a different install, where the owning package may not exist; importing those rows would fail at restore time or leave silent orphans with no schema to validate against. Package data still persists normally and is captured by a full data-directory backup, which is scoped to one install. ## Alternatives considered - **Add Slurp's tables to the Engine's hardcoded list.** Rejected: it makes the Engine carry schema for an optional downloadable package, and it does not generalise to the next package. It also puts package rows into profile export, which is the wrong portability boundary. - **Let packages borrow an existing Engine table.** This is the status quo. It stores package rows under a schema the package does not own and gives the package no control over its own data lifecycle. - **A separate storage mechanism just for packages.** Rejected: it duplicates the crash-safe shard pipeline, the flush scheduling, the manifest and the corruption recovery that the file-backed store already has, and it is the parts that are hard to get right that would be duplicated. - **Per-store instance registries instead of process-global ones.** This is the cleaner design, but the Engine's table metadata is already process-global and reached through module-level lookups, so instance registries would mean threading a store instance through `getMeta()` and the whole lookup surface. That is a much larger change than the gap warrants while production runs a single store per process. ## Additional context The Engine currently has no caller that loads package-supplied table objects, so the first change here is the storage-side API only. Wiring a package loader to it is separate work. ## Template check - [ ] I DID NOT read this template and provide the requested details.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3244
No description provided.