feat: finalize captured runs into durable experience - #5
Merged
Merged
Conversation
Add ExperienceFinalizationService: one call that loads a completed captured run, evaluates its own closed verification round, checks host authorization and the host's storage decision, reflects, creates the record as Candidate, and commits its initial lifecycle event to Validated or Quarantined. Record, reflection and event IDs derive from the run, so a retry re-derives them and converges instead of duplicating. Required checks can now name the evaluator kind that may satisfy them, and Core and Storage.Postgres each expose a service-registration extension. The MAF adapter finalizes a fully captured run through the host's resolver. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.5. Capture, verification, reflection and persistence become one call, so the library now does end to end what it is for.
ExperienceFinalizationService.FinalizeAsyncruns the stages in order and stops at the first one that ends the call:Load → Evaluate → Authorize + storage decision → Reflect → Create record → Commit initial event
IExperienceReflector, the documented seam for a model-backed reflector.Candidate, and its initial lifecycle event performs the real transition toValidated(reuse confidence 2/3) orQuarantined(no lesson). A commit that never lands leaves aCandidate, which retrieval never reuses — not a reusable record with no history.AlreadyFinalized, and a record whose create landed but whose commit did not has that same commit finished.RequiredCheck(CheckId, ExpectedKind?)— a human approval can no longer satisfy a test-result check by ID collision. (Settles a decision deferred from Story 1.5.)AddAgentExperienceCoreandAddAgentExperiencePostgresStore, bothTryAdd-based so a host's own implementations win. The MAF adapter finalizes a fully captured run through a host-supplied resolver.Review
Three reviewers raised 31 findings. Two were intent-level and resolved as deliberate changes to the story's intent — the gate ordering and Candidate-first above. 30 fixed, 1 deferred (whether derived record IDs should include the scope, so an ID cannot be squatted from another scope).
Test plan
dotnet build --configuration Release: 0 warnings, 0 errorsdotnet test --configuration Release: 446 of 446 pass (Core 256, Postgres 99, MAF 49). Locally withTESTCONTAINERS_RYUK_DISABLED=true.🤖 Generated with Claude Code