Repository navigation
fix(store): activation refuses stored balances outside the declaration; principals are principal ids (#1015) - #1020
Merged
Merged
Conversation
…n; principals are principal ids (#1015) On a collection declaring transfers, activation now holds rows written under an earlier declaration or release to the rules every write under the current one keeps: a whole-number amount property, maxRecordBytes with the amounts at their widest, and stored balances that cannot together grow past 2^53 - 1. The check runs in the transaction that records the declaration fence, so no write through the previous declaration lands in between; a refused activation records nothing. StoreExports and host transactions refuse a principal whose id is not a principal id (core's principalIdPattern) with 401 principal_required before anything is read, stamped or recorded; the collection checks stamped and audited actors again and a stamped value against its property. The 503 for a stored record the declaration cannot serve names that cause instead of a reload. Fixes #1015 Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
enabled auto-merge (squash)
September 30, 2026 00:35
…ate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Activation refuses stored balances outside the declaration. On a collection declaring
transfers, activation now holds rows written under an earlier declaration, or by an earlier release, to the rules every write under the current declaration already keeps. It refuses while:maxRecordByteswith its amounts at their widest;min, plus thatmin's magnitude for every recordmaxRecordsstill allows.The error names the record (or the property and the bound) and the fix. The check (
Collection.balancesHeld) runs inside theBEGIN IMMEDIATEtransaction that records the declaration fence:recordDeclarationstakes acheckcallback. So no write through the previous declaration lands between the check and the switch, and a refused activation records nothing.Principals are principal ids (#1015). Every
StoreExportsand host-transaction call refuses a principal whoseidis not a principal id (core'sprincipalIdPattern: 1 to 128 ASCII characters, so no lone surrogate or over-long id). The refusal is401 principal_required, on shared collections too, before anything is read, stamped or recorded. As defense in depth, the collection also:503 text. A stored record the declaration cannot serve now answers
503 storage_unavailablewithA stored record does not match this collection's declaration. The old text, "This collection was redeclared by a reload; try again", was wrong for a bad row, which no retry fixes.Every write stays in
BEGIN IMMEDIATE. The declaration fence and lease checks are unchanged. HTTP statuses are unchanged, so the OpenAPI is unchanged.Docs
RIM-STORE-PERSIST-001now covers the check that runs in the recording transactionTests
transfers.test.ts: redeclares a collection over existing rows in three cases: a balance added to records stored without one, a smallermaxRecordBytes, and a raised issuerminwith a largermaxRecords. Each case covers the refusal, the fix, the accepted redeclaration, and a refused activation that leaves the previous one serving.transitions.test.ts: tries a lone surrogate, a 200-character id,x y, an empty id and a non-ASCII id on the export's transition, create, update, get and list, and on a host transaction's transition and remove. Each is refused with nothing written; restart still works. Also checks the new 503 message on GET, list and PATCH.test/direct.ts:open(next)reactivates with another declaration.npm run verifyandnpm run test:packagepass locally (macOS, Node 26). Passing CI is not an independent security review.Fixes #1015
🤖 Generated with Claude Code