feat: persist experience records in PostgreSQL - #1
Merged
Merged
Conversation
Add the ExperienceRecord contract and IExperienceRecordStore port, optional authority bounds on AuthorizationContext, and the AgentExperience.Storage.Postgres package: plain Npgsql store with authorization checked before database access, exact scope predicates in SQL, adapter-owned payload versioning, and an embedded schema script. The migration runner is deferred. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
3 tasks
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
Story 2.1: the first durable Experience Record store.
ExperienceRecord, a canonical, immutable record.IExperienceRecordStore, with create-only save, get by ID and scoped query. Results are typed:Created,Found,NotFound,Denied,InvalidandConflict. Infrastructure failures throwExperienceStoreException.AuthorizationContextgains optionalApplicationId,ProjectId,TeamId,AgentIdandUserIdbounds, plusPermits(Scope). The tenant must always match, and a non-null bound must match exactly.AgentExperience.Storage.Postgres(plain Npgsql 10.0.3, pinned exactly)payload_versioncolumn, so domain types carry no version field. Reading an unknown version throws.Migrations/0001_create_experience_records.sqlis embedded in the package and exposed throughPostgresExperienceRecordSchema.Not in this PR
Notes
CreatedAtandUpdatedAtare truncated to microseconds, becausetimestamptzstores nothing finer. Timestamps nested inside the payload keep full precision.AuthorizationContexthas noApplicationIdorProjectId. It now asserts the new nullable bounds.Test plan
dotnet build --configuration Release: 0 warnings, 0 errorsdotnet test --configuration Release: 303 of 303 pass, including 40 store tests against apgvector/pgvector:pg16container. Locally I usedTESTCONTAINERS_RYUK_DISABLED=true.🤖 Generated with Claude Code