Add unlisted records — enumeration without permissions - #209
Merged
Conversation
Closes #202. StackRecord.unlistedAt is a native field, orthogonal to permissions: it says nothing about who may read a record, only whether it's enumerable. An unlisted record is reachable by get() for anyone who may already read it, and excluded from an unfiltered query() and the change feed by default — the same posture soft delete already has. - create({ unlisted: true }) creates a record already unlisted, so there's no window where it exists and is briefly enumerable. - setUnlisted(id, unlisted) toggles it on an existing record, gated exactly like setPermissions() under ScopedStack. - RecordFilter.includeUnlisted and SubscribeOptions.includeUnlisted opt back in, refused to everyone but the stack owner acting alone under ScopedStack — enumeration standing rests on nothing but ownership. - The feed matches query()'s exclusion, with one exception: the unlist transition emits a dedicated op (kind 'deleted') so a subscriber that already knows the record is told to drop it; relisting emits 'list' (kind 'changed'), an ordinary upsert like undelete. Wires the field and filter through every adapter (sqlite-shared, record-adapter-sqlite, adapter-local, the in-memory test double, and the adapter-api wire client), extends the conformance fixtures, and updates the spec docs (access-control.md, events.md, wire-format.md, data-model.md, versioning.md). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RZ3v68CDeYsFRHRPDnsU2k
🦋 Changeset detectedLatest commit: 3c28fbe The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…ementation-o2vtlc # Conflicts: # packages/core/src/stack.ts
Merged
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.
Summary
Adds an
unlistedstate for records that withholds them from enumeration while keeping them readable by ID. This is orthogonal to permissions:unlistedAtsays nothing about who may read a record, only whether it is discoverable without already holding its ID.New APIs:
stack.create(typeId, content, { unlisted: true })— create a record already unlisted, with no window where it's briefly enumerablestack.setUnlisted(id, unlisted)— toggle unlisted state on an existing recordRecordFilter.includeUnlistedandSubscribeOptions.includeUnlisted— opt back into seeing unlisted records (owner-only underScopedStack)Behavior:
query()and the change feed by default, matching the posture of soft-deleted recordsget()still resolves unlisted records for anyone who may read themunlisttransition emits as kinddeleted/ opunlist(so subscribers already holding the record are told to drop it), whilelistemits as kindchanged/ oplist(the publish moment)ScopedStack,setUnlisted()is gated exactly likesetPermissions()— both decide discoverability, not readability.includeUnlistedis refused to everyone but the stack owner acting alone, since enumeration standing rests on nothing but ownershipSpec
Updated:
docs/spec/access-control.md— new § Unlisted records, explaining the three-tier enumeration model (enforced, defaulted, advisory) and the owner-onlyincludeUnlistedgatedocs/spec/events.md— documentsunlistandlistops and their kind mappings; explains whyunlistreaches default subscribers despite the post-change state being excludeddocs/spec/data-model.md— addsunlistedAt?: Datefield toStackRecorddocs/spec/wire-format.md— wire format guidance for the new field and query parameterVerification
includeUnlisted, and three change feed scenarios (unlist transition, list transition, silent edits while unlisted)stack.test.tscovering version bumping, no-op idempotence, permission preservation, and query filteringScopedStacktests verifying access control (creator/owner only, stranger gets StackNotFoundError, delegated apps cannot useincludeUnlisted)unlist/listop kinds, and owner-with-includeUnlisted seeing all eventshttps://claude.ai/code/session_01RZ3v68CDeYsFRHRPDnsU2k