Score: persist full versioned ScoringExpectation (Phase 3, PR A) - #2556
Open
Richard Lundeen (rlundeen2) wants to merge 7 commits into
Open
Score: persist full versioned ScoringExpectation (Phase 3, PR A)#2556Richard Lundeen (rlundeen2) wants to merge 7 commits into
Richard Lundeen (rlundeen2) wants to merge 7 commits into
Conversation
Every Score now durably records the complete versioned ScoringExpectation it was judged against (objective + typed conditions) in a new scored_expectation field/column. Score.objective becomes a read-only, derived compatibility view over scored_expectation.objective. A one-way-reversible Alembic migration folds the legacy objective column into a serialized scored_expectation and restores it (dropping condition-only data) on downgrade. Scorers stamp the expectation they used onto returned scores before persistence. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Convert Condition/MatchesObjective/ScoringExpectation from frozen dataclasses to Pydantic BaseModels so they serialize natively (model_dump/model_validate), stay consistent with the rest of pyrit.models, and are reusable in REST/frontend payloads. The open condition hierarchy keeps a stable 'condition_type' discriminator (a per-subclass Literal field) plus a registry, and ScoringExpectation carries conditions as SerializeAsAny so subclass fields survive a round trip. Score now nests ScoringExpectation natively, removing the custom field validator/serializer and the bespoke to_dict/from_dict helpers. Net -180 lines. Also revert the overly specific framework.md note. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: acca9c84-99f3-447d-93e5-37575f07e45d
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: acca9c84-99f3-447d-93e5-37575f07e45d
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: acca9c84-99f3-447d-93e5-37575f07e45d
…ation-persistence
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: acca9c84-99f3-447d-93e5-37575f07e45d
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
PR A of a two-PR split of Phase 3 scoring work. It makes every
Scoredurably record the complete, versionedScoringExpectationit was judged against (objective and typed conditions), instead of only anobjectivestring.Design context: Phase 3 scoring persistence and replay design.
What changes
Score.scored_expectationstores the full versioned expectation.Score.objectiveis a read-only compatibility view derived fromscored_expectation.objective; conflicting explicit values are rejected.Conditiondeclares a stable single-valuecondition_typeLiteraland is registered independently of its import path.Condition.model_validate(...)dispatches tagged dictionaries to the registered concrete subtype, which then uses normal Pydantic validation.Conditioninstances, missing or unknown discriminators, and invalid discriminator declarations are rejected.oneOf.ScoringExpectationuses strict persisted schema-version validation and provides a stable canonical fingerprint for PR B.ScoreEntries.objectivecolumn with JSONscored_expectation;ScoreEntry.to_dict()still exposes a derivedobjective.1b3d5f7a9c2e, down revision0f2e4d6c8b1a) backfills non-null objectives into{schema_version: 1, objective, conditions: []}in bounded keyset batches of 500. Downgrade restores only the objective and intentionally drops conditions that the old schema cannot represent.MessageScorer.Not in scope
Observations, replay,
score_observation_async, response-handler fingerprints,Score.observation_ids,json_retrychanges, and observation tables follow in PR B.Testing
Scoremocks pass.ruff,ty, frontend lint, and frontend TypeScript checks pass.ScenarioRunPagedialog test now waits for asynchronous portal rendering.