Skip to content

feat(packs): durable pack document store (T1) - #435

Merged
johnnyelwailer merged 3 commits into
mainfrom
feature/seam-t1-finish-pack-document-store-continue-80b02c7a
Oct 7, 2026
Merged

johnnyelwailer merged 3 commits into
mainfrom
feature/seam-t1-finish-pack-document-store-continue-80b02c7a

Conversation

@johnnyelwailer

Copy link
Copy Markdown
Owner

Packs get a durable, keyed document store (seam S3, slice T1): a pack can insert-or-get, compare-and-set, increment and list its own documents, and a client can subscribe to them live. Pack A can never see pack B's documents.

What it adds

  • Migration 105 PackDocuments (t3team_pack_documents; highest prior id was 104).
  • T3TeamPackDocumentStore.forPack(packId) → get / list / insertOrGet / put(ifVersion, ttlMs) / increment; every SQL statement is bound to the pack id in the closure. Writes are serialized and run in a transaction, then published.
  • t3team.subscribePackDocuments { packId, collection, key? | prefix? } → snapshot | upsert | removed; subscribes to the PubSub before reading the snapshot. Read scope; unregistered pack ids are refused. capabilities.t3team.packStore.
  • client-runtime atoms (state/pack-documents), gated on the capability.
  • contents.persistence + store:v1 read at boot (runtime packs and compiled distributions); defineCollections / mergePackCollectionsDefinitions in @t3team/pack-api.

Tests

insert-or-get race (one winner), CAS conflicts, subscribe-then-snapshot buffering, pack isolation (reads, lists, subscriptions), counters/pagination/validation, manifest loading, client reducer, migration ledger.

Not in T1 (per plan row T1)

Retention and quota eviction, remove/touch, t3team.packStore.put for views, script-context store (S4). expires_at is stored but reads do not filter on it yet; that lands with retention.

Reviewed by Cursor and Copilot (Codex was out of budget); no code findings beyond the items above.

🤖 Generated with Claude Code

Phil J and others added 3 commits October 7, 2026 14:32
…istribution persistence test

The isolation test only asserted event count, so a leaked pack-B upsert would have passed.
The distribution persistence test lived under apps/server/scripts, which vitest does not
include, so it never ran; it now lives in src/.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XL labels Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

⚠️ The latest CI run did not produce a thread transfer result for 4d48cba.

This comment will update automatically after the next completed run.

@johnnyelwailer
johnnyelwailer marked this pull request as ready for review October 7, 2026 13:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T13:58:58.608418Z 4d48cba Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@johnnyelwailer
johnnyelwailer merged commit b5d2a3b into main Oct 7, 2026
26 of 27 checks passed
@johnnyelwailer
johnnyelwailer deleted the feature/seam-t1-finish-pack-document-store-continue-80b02c7a branch October 7, 2026 13:57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d48cba331

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +13 to +15
if (existing !== undefined) {
if (stableStringify(existing) === stableStringify(definition)) continue;
throw new Error(`Duplicate pack persistence: ${id}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Allow runtime persistence to override compiled definitions

When a packaged distribution registers a pack and T3TEAM_PACKS_DIR resolves a higher-precedence version of that same pack with changed collection metadata, this duplicate check throws. runT3TeamServerCommand catches that error for the entire runtime registration map, so the updated pack keeps the stale compiled definition and unrelated runtime packs lose their stores as well. Preserve the normal compiled-baseline/runtime-override behavior instead of treating this expected cross-source replacement as a duplicate.

AGENTS.md reference: AGENTS.md:L51-L56

Useful? React with 👍 / 👎.

Comment on lines +103 to +106
if (
options.ttlMs !== undefined &&
(!Number.isSafeInteger(options.ttlMs) || options.ttlMs < 1)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject TTLs outside the representable date range

A TTL such as Number.MAX_SAFE_INTEGER passes this validation, but adding it to the current epoch exceeds the ECMAScript date range, so the subsequent DateTime.formatIso defects instead of returning the store's declared typed error. A trusted pack can therefore terminate its operation fiber simply by supplying a large otherwise-valid integer; validate that the computed expiration is representable before formatting it.

Useful? React with 👍 / 👎.

johnnyelwailer added a commit that referenced this pull request Oct 8, 2026
…ition (#442)

* test(packs): a runtime pack's persistence must override the compiled definition

Fails today with "Duplicate pack persistence" (#435 review, Codex P1).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(packs): a runtime pack's persistence overrides its compiled definition

Compiled-in and runtime persistence shared one registry that treated any differing definition
for the same pack id as a duplicate. When T3TEAM_PACKS_DIR held a newer version of a compiled
pack, runtime registration threw, the boot catch dropped the whole runtime map, and every
runtime pack lost its store. Each source now registers into its own layer (conflicts within one
source still fail atomically) and the effective map is the compiled baseline overlaid by the
runtime layer, matching how the other compiled-in content is overridden.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Phil J <philip.jonientz@nexplore.ch>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant