Skip to content

fix(contracts): emit predefinedExpectations from availableExpectations (#309)#310

Merged
SamuelHassine merged 2 commits into
mainfrom
fix/contracts-predefined-expectations
Jul 19, 2026
Merged

fix(contracts): emit predefinedExpectations from availableExpectations (#309)#310
SamuelHassine merged 2 commits into
mainfrom
fix/contracts-predefined-expectations

Conversation

@SamuelHassine

@SamuelHassine SamuelHassine commented Jul 18, 2026

Copy link
Copy Markdown
Member

Closes #309

Summary

Predefined Detection / Prevention (and other) expectations stopped pre-filling when creating an atomic testing or inject: the expectations picker no longer proposed any defaults.

Commit 3ca50c3 (#306) renamed ContractExpectations.predefinedExpectations to availableExpectations and introduced a per-expectation expectation_is_predefined flag. But the OpenAEV platform pre-fills expectations from the field-level predefinedExpectations array (the frontend inject form reads predefinedExpectations for the defaults and availableExpectations for the picker); the per-expectation flag is not consumed. After #306 pyoaev emitted only availableExpectations, so predefinedExpectations was always empty and nothing was pre-filled.

This is on unreleased main (not in 2.260717.0), so it would ship as a regression on the next release and break predefined expectations for every Python injector.

Change

  • ContractExpectations now carries both availableExpectations (the full selectable set) and predefinedExpectations (the defaults the platform pre-fills).
  • predefinedExpectations defaults to None as the "not provided" sentinel: when the caller does not pass it, __post_init__ derives it from the expectations flagged expectation_is_predefined=True, so the existing single-list API keeps working end-to-end. Passing an explicit list (including an empty one) overrides the derivation, and the serialized contract always emits an array.
  • Added unit tests under test/contracts/ covering the derivation, an explicit predefined list, the explicit-empty-list override, and the no-flag case.

Test plan

  • pytest test/contracts/ passes (4 tests).
  • black / isort clean.
  • Verified serialization via EnhancedJSONEncoder emits a predefinedExpectations array matching the flagged expectations.

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.

Pull request overview

Restores ContractExpectations.predefinedExpectations emission (alongside availableExpectations) so the OpenAEV platform can pre-fill default expectations again after the earlier rename to availableExpectations.

Changes:

  • Added predefinedExpectations back to ContractExpectations and derive it in __post_init__ from expectation_is_predefined=True when not explicitly provided.
  • Added unit tests validating derivation behavior, explicit predefined lists, and the no-flag case.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
pyoaev/contracts/contract_config.py Reintroduces predefinedExpectations and adds derivation logic in ContractExpectations.__post_init__.
test/contracts/test_contract_expectations.py Adds unit tests covering predefined expectation derivation and serialization.
test/contracts/__init__.py Package marker for the new test.contracts test module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyoaev/contracts/contract_config.py Outdated
Comment thread test/contracts/test_contract_expectations.py Outdated
…#309)

Derive predefinedExpectations from the expectation_is_predefined flags only
when the caller did not provide the list, so an explicit empty list can
suppress pre-fill. Also drop a needless getattr fallback, add a test for the
explicit-empty override and normalize the test file to LF.
@SamuelHassine

Copy link
Copy Markdown
Member Author

Review-and-fix pass complete:

  • Independent review done against the platform consumers: InjectorContractContentUtils.java reads the field-level predefinedExpectations array (PREDEFINED_EXPECTATIONS constant) and the frontend inject form pre-fills from it, so emitting the field again is the correct fix for fix(contracts): predefined expectations no longer emitted after availableExpectations rename #309.
  • Addressed the Copilot review: predefinedExpectations now defaults to None as the "not provided" sentinel (98a7222). Derivation from expectation_is_predefined flags only runs when the list is not passed; an explicit empty list suppresses pre-fill, and the serialized contract always emits an array.
  • Dropped the needless getattr fallback (Expectation always defines the flag), added test_explicit_empty_list_overrides_flags (4 tests total) and normalized the test file to LF.
  • pytest test/contracts/, black and isort pass locally; all CI checks are green on the new commit; both review threads are replied to and resolved.

Note: I cannot approve this PR since I am its author - it needs an approving review from another maintainer to unblock merge.

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.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

@SamuelHassine
SamuelHassine merged commit 179f3fa into main Jul 19, 2026
16 checks passed
@SamuelHassine
SamuelHassine deleted the fix/contracts-predefined-expectations branch July 19, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team Item from the Filigran team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(contracts): predefined expectations no longer emitted after availableExpectations rename

3 participants