Skip to content

Expectation flags, shared expectations on scenario sets, and per-rule results - #101

Merged
SushantGautam merged 3 commits into
mainfrom
feat/expectation-flags
Nov 13, 2026
Merged

SushantGautam merged 3 commits into
mainfrom
feat/expectation-flags

Conversation

@SushantGautam

Copy link
Copy Markdown
Collaborator

Implements most of #100 (Studio side of SimulaMet/SimpleAudit#157, core PR SimulaMet/SimpleAudit#158). cc @kelkalot

What changes

  • Expectation objects. expected_behavior entries can be plain strings or {"id", "text", "required"}. A non-required item is graded and reported but never changes the severity; the judge model sees only the text. Required items without an id are stored as plain strings, so existing scenarios keep their content and hash. Changing a flag creates a new revision.
  • Shared expectations on set versions. ScenarioSetVersion.shared_expectations (migration 0006), part of the set hash only when non-empty. Publishing carries the latest rules over; saving new rules publishes a version with every scenario's frozen revision; revert restores the old version's rules; version diffs show flag and rule changes.
  • Engine bridge. The worker passes the set's shared rules to infra/engine.py, which merges them via simpleaudit.expectations (source: "shared"). With an engine that lacks expectation objects (0.7.0), only texts are passed and every item counts; nothing breaks.
  • UI. Row editor with a "counts" checkbox for scenario expected behaviour; "Shared expectations" panel on the set page; "Shared checks" panel on the run page (violated / met / n/a / missing per rule, with links to violating scenarios), read from ScenarioResult.list_summary so no transcript is loaded.
  • API / export / import / codegen. The API accepts objects; export uses format_version 3 only when objects or shared rules are present; import accepts 2 and 3; generated scripts apply the shared rules with apply_shared_expectations.
  • Docs. docs/domain-model.md.

Not in this PR

Checks

  • uv run pytest -m "not embedded_hatchet": 1865 passed, 4 skipped.
  • New tests in infra/tests/test_expectation_flags.py and test_codegen.py; also run against the core branch (all pass, including the merge test that is skipped on 0.7.0).
  • uv run ruff check . passes; makemigrations --check reports no changes.
  • Manually checked the set panel and row editor on a local dev instance running the core branch.

Expected behaviour entries can be plain strings or objects
{"id", "text", "required"}. A non-required item is graded and reported
but never changes the severity; the judge model sees only the text.
Required items without an id are stored as plain strings, so scenarios
that use no flags keep their content and hash.

- scenarios/expectations.py: validation, stored form, form parsing.
- ScenarioSetVersion.shared_expectations (migration 0006), included in
  the set hash only when non-empty. Publishing carries the latest rules
  over; set_shared_expectations publishes a new version with every
  scenario's frozen revision. Revert restores the old version's rules,
  and version diffs show flag and rule changes.
- Worker passes the set's shared rules to infra/engine.py, which merges
  them through simpleaudit.expectations. An engine without expectation
  objects gets the texts only.
- Scenario editor: row editor with a "counts" checkbox; set page:
  shared expectations panel.
- Run page: "Shared checks" panel per rule (violated / met / n/a /
  missing, links to violating scenarios), read from list_summary.
- API accepts objects; export uses format_version 3 only when objects or
  shared rules are present; import accepts 2 and 3. Generated scripts
  apply the shared rules.
- docs/domain-model.md documents the fields.

Refs #100, SimulaMet/SimpleAudit#157
Copilot AI balanced review requested due to automatic review settings November 12, 2026 23:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

- demo audit S03 and agentic D-pack: "May ..." lines become
  {"text", "required": false}, since grading no longer reads wording.
- Pack seeding stores expected behaviour in Studio's form.
- Set export takes ?version= (the version being viewed) and records
  set_version; dialog texts mention flags and shared expectations.
- Tests: set export/import round trip with flags and shared rules.
The flags and shared expectations take effect only with an engine that
has simpleaudit.expectations (released in 0.8.0).
@SushantGautam
SushantGautam merged commit 65bffd6 into main Nov 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants