Repository navigation
Conversation
Migration 00028 adds person_offline_tokens (with refreshing_until for the later refresh lease), person_offline_revocations and person_agent_blocks. store.OfflineTokens keeps one sealed token per person and the admins' blocks: Put, Get, Rotate (compare-and-swap on rev, keeps gen, clears the lease), Delete, DeleteRev, DeleteGen, List, Expired, Block, Unblock and Blocked. Block moves the token row it deletes into person_offline_revocations in the transaction that sets the block, and Put for a blocked person stores no live row and adds the token it was given there instead, answering ErrBlocked. Every write for one person runs through mutatePerson, which takes a per-person lock as the transaction's first statement: on Postgres pg_advisory_xact_lock on an FNV-1a key of the person's name, on SQLite nothing (its write transactions are already serialised). mutate and inTxAnnounce now route through helpers that take an optional first statement; with none they behave as before. Open also picks each engine's statement-time clock in Unix ms for the lease. Postgres-only tests race a sign-in against a block 200 times and check that every write method waits for, and takes first, the person lock. The contracts and patterns registries describe the tables, the lock and the two audit actions; the plan records the slice's evidence, checkpoint review, six approved deviations and a merge-order note.
This branch has not been deployed
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.
Slice 6: Offline token tables and the per-person lock
internal/storekeeps one sealed offline token per person and admin blocks, every write for one person is serialised on both engines, and a sign-in racing a block never leaves a blocked person a live token.Spec: nebari-dev/tapas/docs/superpowers/specs/2026-11-30-agent-token-broker-design.md
Plan: nebari-dev/tapas/docs/superpowers/plans/2026-12-01-agent-tokens-and-frames.md (Slice 6)
Contracts touched: Tables
person_offline_tokens,person_offline_revocationsandperson_agent_blocks, andstore.OfflineTokens, Per-person write lock and the lease's database clock ininternal/store, Audit actionagent_access.revoke, Audit actionagent_access.unblockDepends on: #44
00028: the three tables, withrefreshing_untilfor the later refresh lease.store.OfflineTokens:Put,Get,Rotate,Delete,DeleteRev,DeleteGen,List,Expired,Block,Unblock,Blocked.Blockmoves the token row it deletes (DELETE ... RETURNING) intoperson_offline_revocationsin the transaction that sets the block;Putfor a blocked person adds its token there instead of storing it, and answersErrBlocked.mutatePersontakes a per-person lock as the transaction's first statement:pg_advisory_xact_lockon Postgres, nothing on SQLite (already serialised).mutateandinTxAnnounceroute through helpers with an optional first statement and behave as before without one.Reviewer note:
write.goandopen.gochanges touch every store write; the task review checked the no-first-statement path is unchanged.Validation
go test -count=1 -race ./internal/store/...make test-postgresmake generate-sql && git diff --exit-code internal/store/sqlcgenmake test-local