From 950b7877b06210acc84923e0333ac8c33934b078 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sun, 22 Nov 2026 07:54:51 -0500 Subject: [PATCH 1/6] release: openadapt-types 0.24.1 and openadapt-verify 0.2.1; accept Flow 4 openadapt-flow 3.4.0 imports openadapt_types.receipt, which openadapt-types 0.24.0 does not have, so a clean install of 3.4.0 fails on every receipt path. openadapt-types 0.24.1 adds the receipt, receipt callback, run ledger and exception card modules. It stays inside the <0.25.0 range every released Flow 3 accepts, so it also repairs Flow 3.4.0 installs. 0.24.1 keeps every 0.24.0 digest. escalated_after_effect_reward enters RewardContractV1.digest only when it differs from its default, and the pinned contract digest is back to its 0.24.0 value. A fixture of contracts and certificates issued by openadapt-types 0.24.0 from PyPI checks that they hash and verify unchanged. A 0.24.0 contract with verified_reward of 0.5 or less still loads; asking then earns no credit. This is the first of two release PRs. Flow 4.0.0 needs openadapt-types 0.24.1 on PyPI first: its on-prem wheelhouse is built from Flow's lock, which can only pin a types version PyPI serves. So this PR also lifts the caps that would break CI once the in-tree Flow is 4.0.0: - the launcher accepts openadapt-flow >=3.3.0,<5.0.0, in its requirements and in `openadapt doctor`'s supported range; the platform manifest is regenerated with the same component selection so its compatibility block matches. The launcher releases only on dispatch, so nothing ships here. - openadapt-verify 0.2.1 accepts openadapt-flow <5 (#2535). --- CHANGELOG.md | 5 + docs/platform-compatibility-report.md | 2 +- openadapt/cli.py | 7 +- packages/types/CHANGELOG.md | 51 +++++++ packages/types/openadapt_types/reward.py | 54 ++++++- .../schemas/reward-contract-v1.json | 2 +- packages/types/pyproject.toml | 2 +- .../tests/fixtures/reward_issued_0_24_0.json | 139 ++++++++++++++++++ packages/types/tests/test_reward.py | 43 +++++- packages/types/uv.lock | 2 +- packages/verify/CHANGELOG.md | 6 + packages/verify/pyproject.toml | 12 +- .../verify/src/openadapt_verify/__init__.py | 2 +- packages/verify/uv.lock | 12 +- platform-manifest.json | 4 +- pyproject.toml | 18 +-- tests/test_cli_smoke.py | 24 +-- tests/test_flow_floor.py | 5 +- uv.lock | 18 +-- 19 files changed, 345 insertions(+), 63 deletions(-) create mode 100644 packages/types/tests/fixtures/reward_issued_0_24_0.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f917ad8c6..62b0aa0565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ ## Unreleased +### Requirements + +- Accepts openadapt-flow 4: the launcher's Flow requirement and `openadapt + doctor`'s supported range are now `>=3.3.0,<5.0.0` (was `<4.0.0`). + ### Features - **Agent-to-agent handoffs.** diff --git a/docs/platform-compatibility-report.md b/docs/platform-compatibility-report.md index 1bef797137..ef8e68d17a 100644 --- a/docs/platform-compatibility-report.md +++ b/docs/platform-compatibility-report.md @@ -2,7 +2,7 @@ -- Generated: `2026-11-19T21:28:04+00:00` +- Generated: `2026-11-22T12:49:07+00:00` - Selection: `explicit-published` - Compatibility: **dependency-compatible** - Signature: `unsigned (signing infrastructure pending)` diff --git a/openadapt/cli.py b/openadapt/cli.py index 50c9048dd6..866950dda1 100644 --- a/openadapt/cli.py +++ b/openadapt/cli.py @@ -1335,8 +1335,9 @@ def _warn_about_launcher_conflicts() -> None: # public_seal module, and the quickstart's encrypted checkpoints rely on its # key derivation once per store. Launcher 1.23 requires Flow 3.3: the OpenEMR # quickstart's referral program checks its date picker against the run's -# clock (`Postcondition.text_clock`), which Flow 3.2 ignores. -_SUPPORTED_FLOW_RANGE = ">=3.3.0,<4.0.0" +# clock (`Postcondition.text_clock`), which Flow 3.2 ignores. Flow 4.0 +# removed and renamed APIs the launcher doesn't use, so it is accepted too. +_SUPPORTED_FLOW_RANGE = ">=3.3.0,<5.0.0" _RDP_INSTALL_COMMAND = _pip_install("openadapt[rdp]") _CHROMIUM_SYSTEM_LIBS_COMMAND = ( f"{shlex.quote(sys.executable)} -m playwright install-deps chromium" @@ -1346,7 +1347,7 @@ def _warn_about_launcher_conflicts() -> None: def _supported_flow_version(value: str) -> bool: """Return whether a stable Flow version is in the launcher's supported range.""" parsed = _release_tuple(value) - return parsed is not None and (3, 3, 0) <= parsed < (4, 0, 0) + return parsed is not None and (3, 3, 0) <= parsed < (5, 0, 0) # The Python modules each native or remote Flow backend imports when its diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 756eb7271a..4ed63d9012 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -1,6 +1,57 @@ # CHANGELOG +## v0.24.1 (2026-11-22) + +openadapt-flow 3.4.0 imports `openadapt_types.receipt`, which 0.24.0 does not +have. This release adds it and the other modules Flow imports on main +(openadapt-flow 4.0.0 will require it). It stays +within the `<0.25.0` range every released Flow 3 accepts, so upgrading this +package repairs a Flow 3.4.0 install. + +### Features + +- `openadapt_types.receipt`: the `record/run/v1` signed run receipt. It + covers building, signing and verifying the statement, the public card + (`receipt.card.json`) with only allow-listed values opened, private + openings, role keys and a key registry, counterparty confirmation lines, + and follow-up statements. Signing and verifying import `cryptography` only + when called ([#2394](https://github.com/OpenAdaptAI/OpenAdapt/pull/2394), + [#2410](https://github.com/OpenAdaptAI/OpenAdapt/pull/2410), + [#2412](https://github.com/OpenAdaptAI/OpenAdapt/pull/2412), + [#2426](https://github.com/OpenAdaptAI/OpenAdapt/pull/2426)). +- `openadapt_types.receipt_callback`: checks a managed callback's settled + report against its pinned signer and final outcome + ([#2412](https://github.com/OpenAdaptAI/OpenAdapt/pull/2412)). +- `openadapt_types.run_ledger`: `openadapt.run-ledger/v1` (`RunLedgerRowV1`) + and `openadapt.agent-run-summary/v1` (`AgentRunSummaryV1`), one value-free + accounting row per run. Every string field is closed by a pattern or an + enum. The names are exported from `openadapt_types` + ([#2478](https://github.com/OpenAdaptAI/OpenAdapt/pull/2478)). +- `openadapt_types.exception_card`: `openadapt.exception-card/v1` and + `openadapt.exception-answer/v1`, with seven closed kinds and five closed + answers. Import it by its submodule path; it is not exported from + `openadapt_types` ([#2494](https://github.com/OpenAdaptAI/OpenAdapt/pull/2494)). +- Reward contracts: the `escalated_after_effect` outcome, for an episode + whose required effects are all in the system of record but which asked a + person instead of declaring the task done. It scores as partial credit, + `escalated_after_effect_reward` (default 0.5, at least 0 and below 1) + ([#1824](https://github.com/OpenAdaptAI/OpenAdapt/pull/1824)). + +### Fixes + +- A reward scoring policy whose `escalated_after_effect_reward` is at or + above its `verified_reward` is refused, because asking a person would then + pay as much as finishing. The one exception is the default, 0.5: a contract + with a `verified_reward` of 0.5 or less still loads, as in 0.24.0, and + asking then earns no credit (`escalated_after_effect_credit`) + ([#1824](https://github.com/OpenAdaptAI/OpenAdapt/pull/1824)). +- Reward contract digests are unchanged from 0.24.0. + `escalated_after_effect_reward` enters `RewardContractV1.digest` only when + it differs from its default, so every contract and certificate issued + under 0.24.0 hashes and verifies as before. A test checks contracts and + certificates issued by openadapt-types 0.24.0 from PyPI. + ## v0.24.0 (2026-10-20) The models live in this package again, and it depends only on `pydantic>=2.5`; the Python 3.13 cap is gone. `openadapt-flow` 2.3.0 and later depend on it, and `openadapt_flow.contracts` returns the same modules as `openadapt_types` ([#1270](https://github.com/OpenAdaptAI/OpenAdapt/pull/1270)). Upgrade `openadapt-flow` to 2.3.0 together with this package: openadapt-flow 2.2.0 carries its own copy of the models, so with 0.24.0 alone, `isinstance` checks between the two copies fail. diff --git a/packages/types/openadapt_types/reward.py b/packages/types/openadapt_types/reward.py index 391f4a68bc..177c50ec3d 100644 --- a/packages/types/openadapt_types/reward.py +++ b/packages/types/openadapt_types/reward.py @@ -253,6 +253,16 @@ def tier(self) -> OracleTier: return tier_of(self.channel) +#: The credit for asking after the work is done, when a contract declares none. +ESCALATED_AFTER_EFFECT_DEFAULT = 0.5 +#: Scoring fields added in 0.24.1, with the default a contract certified +#: under 0.24.0 implicitly has. RewardContractV1.digest leaves them out at that +#: default, so every 0.24.0 digest stays the same. +_DIGEST_STABLE_SCORING_DEFAULTS: Mapping[str, float] = { + "escalated_after_effect_reward": ESCALATED_AFTER_EFFECT_DEFAULT, +} + + class RewardScoringPolicyV1(_StrictContract): """How each scoring class becomes a scalar. @@ -265,9 +275,12 @@ class RewardScoringPolicyV1(_StrictContract): with verified reward ``v``, wrong-effect reward ``w`` and this value ``x``, declaring done pays more in expectation only when the policy is more than ``(x - w) / (v - w)`` sure the effect is right. With the - defaults (1, -1, 0.5) that is 75%. Zero gives no credit for asking; a - value at or above the verified reward is refused, because asking would - then pay as much as finishing. + defaults (1, -1, 0.5) that is 75%. Zero gives no credit for asking. A + value other than the default 0.5 at or above the verified reward is + refused, because asking would then pay as much as finishing. At 0.5 (the + default, or the same value written out) with a ``verified_reward`` of 0.5 + or less, which 0.24.0 accepted, the contract loads and asking earns no + credit (``escalated_after_effect_credit``). """ verified_reward: StrictFloat = Field( @@ -301,7 +314,7 @@ class RewardScoringPolicyV1(_StrictContract): allow_inf_nan=False, ) escalated_after_effect_reward: StrictFloat = Field( - default=0.5, + default=ESCALATED_AFTER_EFFECT_DEFAULT, ge=0.0, lt=1.0, allow_inf_nan=False, @@ -311,12 +324,27 @@ class RewardScoringPolicyV1(_StrictContract): @model_validator(mode="after") def _partial_credit_below_verified(self) -> RewardScoringPolicyV1: - if self.escalated_after_effect_reward >= self.verified_reward: + if ( + self.escalated_after_effect_reward >= self.verified_reward + and self.escalated_after_effect_reward != ESCALATED_AFTER_EFFECT_DEFAULT + ): raise ValueError( "escalated_after_effect_reward must be below verified_reward" ) return self + @property + def escalated_after_effect_credit(self) -> float: + """The scalar an ``escalated_after_effect`` episode earns. + + The declared value, or zero when the default is not below the + verified reward, so asking never pays as much as finishing. + """ + + if self.escalated_after_effect_reward >= self.verified_reward: + return 0.0 + return self.escalated_after_effect_reward + def scalar_for(self, outcome: RewardOutcomeV1) -> float | None: """Return the declared scalar, or ``None`` for an unscored outcome.""" @@ -327,7 +355,7 @@ def scalar_for(self, outcome: RewardOutcomeV1) -> float | None: RewardOutcomeV1.REJECTED_POLICY: self.rejected_policy_reward, RewardOutcomeV1.WRONG_EFFECT: self.wrong_effect_reward, RewardOutcomeV1.ESCALATED_AFTER_EFFECT: ( - self.escalated_after_effect_reward + self.escalated_after_effect_credit ), } return declared.get(RewardOutcomeV1(outcome)) @@ -390,7 +418,19 @@ def component_names(self) -> tuple[str, ...]: @property def digest(self) -> str: - return _digest_payload(self.model_dump(mode="json")) + """The canonical digest certificates and receipts bind. + + A scoring field added after a contract version shipped enters the + digest only when it differs from its default, so a contract written + before the field existed keeps the digest it was certified under. + """ + + payload = self.model_dump(mode="json") + scoring = payload["scoring"] + for name, default in _DIGEST_STABLE_SCORING_DEFAULTS.items(): + if scoring.get(name) == default: + del scoring[name] + return _digest_payload(payload) class RewardCertificateV1(_StrictContract): diff --git a/packages/types/openadapt_types/schemas/reward-contract-v1.json b/packages/types/openadapt_types/schemas/reward-contract-v1.json index 3dcda5b92f..3481192101 100644 --- a/packages/types/openadapt_types/schemas/reward-contract-v1.json +++ b/packages/types/openadapt_types/schemas/reward-contract-v1.json @@ -113,7 +113,7 @@ }, "RewardScoringPolicyV1": { "additionalProperties": false, - "description": "How each scoring class becomes a scalar.\n\nUncertain episodes and platform failures are fixed to ``unscored`` in\nthis version. A contract cannot declare them to be zero.\n\n``escalated_after_effect_reward`` is the credit for an episode that did\nthe work and then asked a person instead of declaring it done. It sets\nthe confidence a policy needs before it declares done rather than asks:\nwith verified reward ``v``, wrong-effect reward ``w`` and this value\n``x``, declaring done pays more in expectation only when the policy is\nmore than ``(x - w) / (v - w)`` sure the effect is right. With the\ndefaults (1, -1, 0.5) that is 75%. Zero gives no credit for asking; a\nvalue at or above the verified reward is refused, because asking would\nthen pay as much as finishing.", + "description": "How each scoring class becomes a scalar.\n\nUncertain episodes and platform failures are fixed to ``unscored`` in\nthis version. A contract cannot declare them to be zero.\n\n``escalated_after_effect_reward`` is the credit for an episode that did\nthe work and then asked a person instead of declaring it done. It sets\nthe confidence a policy needs before it declares done rather than asks:\nwith verified reward ``v``, wrong-effect reward ``w`` and this value\n``x``, declaring done pays more in expectation only when the policy is\nmore than ``(x - w) / (v - w)`` sure the effect is right. With the\ndefaults (1, -1, 0.5) that is 75%. Zero gives no credit for asking. A\nvalue other than the default 0.5 at or above the verified reward is\nrefused, because asking would then pay as much as finishing. At 0.5 (the\ndefault, or the same value written out) with a ``verified_reward`` of 0.5\nor less, which 0.24.0 accepted, the contract loads and asking earns no\ncredit (``escalated_after_effect_credit``).", "properties": { "escalated_after_effect_reward": { "default": 0.5, diff --git a/packages/types/pyproject.toml b/packages/types/pyproject.toml index 9cd420e743..00ee930196 100644 --- a/packages/types/pyproject.toml +++ b/packages/types/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "openadapt-types" -version = "0.24.0" +version = "0.24.1" description = "Pydantic models for computer-use agents: screen state (ComputerState, UINode), actions (Action), and results (ActionResult)" readme = "README.md" license = "MIT" diff --git a/packages/types/tests/fixtures/reward_issued_0_24_0.json b/packages/types/tests/fixtures/reward_issued_0_24_0.json new file mode 100644 index 0000000000..39680353b0 --- /dev/null +++ b/packages/types/tests/fixtures/reward_issued_0_24_0.json @@ -0,0 +1,139 @@ +{ + "cases": [ + { + "certificate": { + "calibration_corpus_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "calibration_scope": "synthetic", + "certificate_id": "reward.certificate.default", + "checker_configuration_digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "delta": 0.05, + "epsilon": 0.0114, + "expiry_policy_updates": 50, + "issued_at": "2026-09-01T12:00:00Z", + "issued_at_policy_update": 100, + "issuer": "self_signed", + "issuer_key_id": "key.reference.0001", + "reward_contract_digest": "sha256:15844d27bd5d12fe71868b2753a31292c676f878dc379562956176fea8e5246c", + "schema_version": "openadapt.reward-certificate/v1", + "signature": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", + "signature_algorithm": "ed25519", + "threshold": 0.5 + }, + "certificate_digest": "sha256:08f3123efd5a42a90993d5ab34d10b9adcea8accc449f4d260e5d9b5887b9e40", + "certificate_state_at_update_120": "current", + "contract": { + "certificate_policy": { + "calibration_corpus_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "delta": 0.05, + "epsilon": 0.0114, + "expiry_policy_updates": 50, + "threshold": 0.5 + }, + "components": [ + { + "name": "halt_on_uncertainty", + "weight": 0.25 + }, + { + "name": "terminal_effect", + "weight": 1.0 + } + ], + "contract_id": "reward.contract.default", + "contract_version": "reward.contract.default.v1", + "environment_digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "environment_id": "environment.local.0001", + "forbidden_effect_contract_digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "oracle": { + "channel": "file", + "identity_keys": [ + "record_id" + ], + "oracle_contract_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + }, + "required_effect_contract_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "schema_version": "openadapt.reward-contract/v1", + "scoring": { + "halted_before_effect_reward": 0.0, + "platform_failures": "unscored", + "refused_reward": 0.0, + "rejected_policy_reward": 0.0, + "uncertain_episodes": "unscored", + "verified_reward": 1.0, + "wrong_effect_reward": -1.0 + }, + "task_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "task_id": "task.reference.0001" + }, + "contract_digest": "sha256:15844d27bd5d12fe71868b2753a31292c676f878dc379562956176fea8e5246c" + }, + { + "certificate": { + "calibration_corpus_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "calibration_scope": "synthetic", + "certificate_id": "reward.certificate.low-verified", + "checker_configuration_digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "delta": 0.05, + "epsilon": 0.0114, + "expiry_policy_updates": 50, + "issued_at": "2026-09-01T12:00:00Z", + "issued_at_policy_update": 100, + "issuer": "self_signed", + "issuer_key_id": "key.reference.0001", + "reward_contract_digest": "sha256:7ed7ab3a5f17daa0ed06d77e59e21d1fbdd306d1e0cb0c2e16380dd779884650", + "schema_version": "openadapt.reward-certificate/v1", + "signature": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", + "signature_algorithm": "ed25519", + "threshold": 0.5 + }, + "certificate_digest": "sha256:31e200581cd5cb5866affc5f847557b7d4235b198eeb2c1fddb78edf24715d89", + "certificate_state_at_update_120": "current", + "contract": { + "certificate_policy": { + "calibration_corpus_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "delta": 0.05, + "epsilon": 0.0114, + "expiry_policy_updates": 50, + "threshold": 0.5 + }, + "components": [ + { + "name": "halt_on_uncertainty", + "weight": 0.25 + }, + { + "name": "terminal_effect", + "weight": 1.0 + } + ], + "contract_id": "reward.contract.low-verified", + "contract_version": "reward.contract.low-verified.v1", + "environment_digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "environment_id": "environment.local.0001", + "forbidden_effect_contract_digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "oracle": { + "channel": "file", + "identity_keys": [ + "record_id" + ], + "oracle_contract_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + }, + "required_effect_contract_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "schema_version": "openadapt.reward-contract/v1", + "scoring": { + "halted_before_effect_reward": 0.0, + "platform_failures": "unscored", + "refused_reward": 0.0, + "rejected_policy_reward": 0.0, + "uncertain_episodes": "unscored", + "verified_reward": 0.5, + "wrong_effect_reward": -1.0 + }, + "task_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "task_id": "task.reference.0001" + }, + "contract_digest": "sha256:7ed7ab3a5f17daa0ed06d77e59e21d1fbdd306d1e0cb0c2e16380dd779884650" + } + ], + "issued_with": "openadapt-types 0.24.0 from PyPI" +} diff --git a/packages/types/tests/test_reward.py b/packages/types/tests/test_reward.py index b578b6db11..33fdddf39c 100644 --- a/packages/types/tests/test_reward.py +++ b/packages/types/tests/test_reward.py @@ -4,6 +4,7 @@ import json from importlib.resources import files +from pathlib import Path import pytest from pydantic import ValidationError @@ -42,7 +43,7 @@ # Pinned once from the payload below. A change here means the canonical form # changed, which breaks every digest a consumer has stored. _PINNED_CONTRACT_DIGEST = ( - "sha256:52eb5a011dabede8b11fdef0da7b0d34ee52a33e3ca9a231e075ff51f67a84ea" + "sha256:4dd42acff78802d1815798dfe04b95fe27847b972d348dcdafa7bbabc5d6be15" ) @@ -736,13 +737,51 @@ def test_escalated_after_effect_reward_out_of_range_is_refused(value: float) -> def test_escalated_after_effect_reward_must_stay_below_verified() -> None: with pytest.raises(ValidationError, match="below verified_reward"): - _contract_with_scoring(verified_reward=0.5, escalated_after_effect_reward=0.5) + _contract_with_scoring(verified_reward=0.5, escalated_after_effect_reward=0.6) contract = _contract_with_scoring( verified_reward=0.8, escalated_after_effect_reward=0.4 ) assert contract.scoring.escalated_after_effect_reward == 0.4 +def test_the_default_gives_no_credit_when_it_is_not_below_verified() -> None: + # 0.24.0 accepted any positive verified_reward; 0.24.1 still does. + contract = _contract_with_scoring(verified_reward=0.5) + scoring = contract.scoring + assert scoring.escalated_after_effect_reward == 0.5 + assert scoring.escalated_after_effect_credit == 0.0 + assert scoring.scalar_for(RewardOutcomeV1.ESCALATED_AFTER_EFFECT) == 0.0 + assert _contract().scoring.scalar_for(RewardOutcomeV1.ESCALATED_AFTER_EFFECT) == 0.5 + + +_ISSUED_0_24_0 = Path(__file__).parent / "fixtures" / "reward_issued_0_24_0.json" + + +@pytest.mark.parametrize( + "case", + json.loads(_ISSUED_0_24_0.read_text(encoding="utf-8"))["cases"], + ids=lambda case: case["contract"]["contract_id"], +) +def test_contracts_and_certificates_issued_under_0_24_0_verify_unchanged( + case: dict[str, object], +) -> None: + """Contracts and certificates openadapt-types 0.24.0 issued (from PyPI). + + A patch release must not move a stored digest: each one parses, hashes + to the digest 0.24.0 computed, and its certificate still binds it. + """ + + contract = RewardContractV1.model_validate(case["contract"]) + certificate = RewardCertificateV1.model_validate(case["certificate"]) + assert contract.digest == case["contract_digest"] + assert certificate.digest == case["certificate_digest"] + assert certificate.reward_contract_digest == contract.digest + assert ( + certificate_state(certificate, 120).value + == case["certificate_state_at_update_120"] + ) + + def test_escalated_after_effect_reward_is_part_of_the_contract_digest() -> None: half = _contract_with_scoring(escalated_after_effect_reward=0.5) quarter = _contract_with_scoring(escalated_after_effect_reward=0.25) diff --git a/packages/types/uv.lock b/packages/types/uv.lock index ba3d9515a9..e477b27312 100644 --- a/packages/types/uv.lock +++ b/packages/types/uv.lock @@ -346,7 +346,7 @@ wheels = [ [[package]] name = "openadapt-types" -version = "0.24.0" +version = "0.24.1" source = { editable = "." } dependencies = [ { name = "pydantic" }, diff --git a/packages/verify/CHANGELOG.md b/packages/verify/CHANGELOG.md index cfd62ae739..1e7cca7eea 100644 --- a/packages/verify/CHANGELOG.md +++ b/packages/verify/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## v0.2.1 (2026-11-22) + +- Accept openadapt-flow 4: every openadapt-flow requirement is now + `>=3.0.0,<5` (was `<4`), so openadapt-verify installs beside the next Flow + major instead of holding Flow at 3.x (#2535). + ## v0.2.0 (2026-11-14) ### Install without the vision stack diff --git a/packages/verify/pyproject.toml b/packages/verify/pyproject.toml index 373d63930c..e86f2c4729 100644 --- a/packages/verify/pyproject.toml +++ b/packages/verify/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "openadapt-verify" -version = "0.2.0" +version = "0.2.1" description = "Verify an agent's writes through an independent system-of-record read path" readme = "README.md" requires-python = ">=3.10,<3.13" @@ -13,7 +13,7 @@ license = "MIT" # the vision stack (NumPy, OpenCV, Pillow, RapidOCR), which is Flow's `vision` # extra. tests/test_import_boundary.py proves the verify path never imports it. dependencies = [ - "openadapt-flow[receipts]>=3.0.0,<4", + "openadapt-flow[receipts]>=3.0.0,<5", "cryptography>=50.0.0", ] @@ -24,9 +24,9 @@ dependencies = [ # yourself for a PostgreSQL read path. mysql = ["PyMySQL>=1.1,<2"] # Agent frameworks. Each extra is only that framework's SDK. -openai = ["openadapt-flow[openai-agents]>=3.0.0,<4"] -claude = ["openadapt-flow[claude-agent-sdk]>=3.0.0,<4"] -mcp = ["openadapt-flow[agent]>=3.0.0,<4"] +openai = ["openadapt-flow[openai-agents]>=3.0.0,<5"] +claude = ["openadapt-flow[claude-agent-sdk]>=3.0.0,<5"] +mcp = ["openadapt-flow[agent]>=3.0.0,<5"] dev = ["pytest>=8", "ruff>=0.4", "mypy>=1.10", "build>=1.2"] [project.scripts] @@ -78,7 +78,7 @@ ignore_missing_imports = true # package never use, so the overrides also keep it out of the lock (a marker # no environment matches). override-dependencies = [ - "openadapt-flow[receipts,agent,openai-agents,claude-agent-sdk]>=2.6.0,<4", + "openadapt-flow[receipts,agent,openai-agents,claude-agent-sdk]>=2.6.0,<5", "numpy; python_version < '3'", "opencv-python; python_version < '3'", "pillow; python_version < '3'", diff --git a/packages/verify/src/openadapt_verify/__init__.py b/packages/verify/src/openadapt_verify/__init__.py index 5fb1d8a7a0..f718907963 100644 --- a/packages/verify/src/openadapt_verify/__init__.py +++ b/packages/verify/src/openadapt_verify/__init__.py @@ -27,7 +27,7 @@ from openadapt_verify.guard import checked_write, verified -__version__ = "0.2.0" +__version__ = "0.2.1" __all__ = [ "Actor", diff --git a/packages/verify/uv.lock b/packages/verify/uv.lock index ad39d6f1a6..0f77a336aa 100644 --- a/packages/verify/uv.lock +++ b/packages/verify/uv.lock @@ -18,7 +18,7 @@ required-markers = [ [manifest] overrides = [ { name = "numpy", marker = "python_full_version < '3'" }, - { name = "openadapt-flow", extras = ["receipts", "agent", "openai-agents", "claude-agent-sdk"], specifier = ">=2.6.0,<4" }, + { name = "openadapt-flow", extras = ["receipts", "agent", "openai-agents", "claude-agent-sdk"], specifier = ">=2.6.0,<5" }, { name = "opencv-python", marker = "python_full_version < '3'" }, { name = "pillow", marker = "python_full_version < '3'" }, { name = "rapidocr-onnxruntime", marker = "python_full_version < '3'" }, @@ -853,7 +853,7 @@ wheels = [ [[package]] name = "openadapt-verify" -version = "0.2.0" +version = "0.2.1" source = { editable = "." } dependencies = [ { name = "cryptography" }, @@ -885,10 +885,10 @@ requires-dist = [ { name = "build", marker = "extra == 'dev'", specifier = ">=1.2" }, { name = "cryptography", specifier = ">=50.0.0" }, { name = "mypy", marker = "extra == 'dev'", specifier = ">=1.10" }, - { name = "openadapt-flow", extras = ["agent"], marker = "extra == 'mcp'", specifier = ">=3.0.0,<4" }, - { name = "openadapt-flow", extras = ["claude-agent-sdk"], marker = "extra == 'claude'", specifier = ">=3.0.0,<4" }, - { name = "openadapt-flow", extras = ["openai-agents"], marker = "extra == 'openai'", specifier = ">=3.0.0,<4" }, - { name = "openadapt-flow", extras = ["receipts"], specifier = ">=3.0.0,<4" }, + { name = "openadapt-flow", extras = ["agent"], marker = "extra == 'mcp'", specifier = ">=3.0.0,<5" }, + { name = "openadapt-flow", extras = ["claude-agent-sdk"], marker = "extra == 'claude'", specifier = ">=3.0.0,<5" }, + { name = "openadapt-flow", extras = ["openai-agents"], marker = "extra == 'openai'", specifier = ">=3.0.0,<5" }, + { name = "openadapt-flow", extras = ["receipts"], specifier = ">=3.0.0,<5" }, { name = "pymysql", marker = "extra == 'mysql'", specifier = ">=1.1,<2" }, { name = "pytest", marker = "extra == 'dev'", specifier = ">=8" }, { name = "ruff", marker = "extra == 'dev'", specifier = ">=0.4" }, diff --git a/platform-manifest.json b/platform-manifest.json index 8d8881fe95..665be1f848 100644 --- a/platform-manifest.json +++ b/platform-manifest.json @@ -1,7 +1,7 @@ { "manifest_kind": "openadapt-platform-release-manifest", "schema_version": "2.0.0", - "generated_at": "2026-11-19T21:28:04+00:00", + "generated_at": "2026-11-22T12:49:07+00:00", "generation": { "files": [ { @@ -1171,7 +1171,7 @@ ">=0.1.0" ], "openadapt-flow": [ - ">=3.3.0,<4.0.0" + ">=3.3.0,<5.0.0" ], "openadapt-grounding": [ ">=0.1.0" diff --git a/pyproject.toml b/pyproject.toml index c94a17552d..0e9dc01e03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,7 +79,7 @@ dependencies = [ # (tests/test_flow_floor.py). Flow 3 # moved its vision stack to the `vision` extra; its `browser` and other # surface extras include it, and the `flow` extra below names it. - "openadapt-flow[browser,hosted]>=3.3.0,<4.0.0; python_version < '3.13'", + "openadapt-flow[browser,hosted]>=3.3.0,<5.0.0; python_version < '3.13'", # Day-1 partner kit: `pip install openadapt` must expose the # `openadapt-agent` command without a second package. 2.1.0 adds Seal checks; # `--bundles`; the bundle-free tutorial `serve --allow-run` needs a later @@ -94,7 +94,7 @@ browser = [ # launcher now selects this Flow contract because the bundled quickstart # uses the browser. OpenAdapt requests Chromium on first browser use after # the host dependency check passes. - "openadapt-flow[browser]>=3.3.0,<4.0.0; python_version < '3.13'", + "openadapt-flow[browser]>=3.3.0,<5.0.0; python_version < '3.13'", ] # Local human desktop recording. Flow owns the supported capture adapter # contract; the direct floor prevents an already-installed pre-1.0 Capture @@ -102,22 +102,22 @@ browser = [ # separately provisioned executable, not a Python-package dependency. capture = [ "openadapt-capture>=1.2.0,<2.0.0", - "openadapt-flow[capture]>=3.3.0,<4.0.0; python_version < '3.13'", + "openadapt-flow[capture]>=3.3.0,<5.0.0; python_version < '3.13'", ] # Replay substrate dependencies stay separate from capture: recording observes # the human on the local interactive desktop, while replay may target a WAA # agent, a native app, or a remote framebuffer. windows = [ - "openadapt-flow[windows]>=3.3.0,<4.0.0; python_version < '3.13'", + "openadapt-flow[windows]>=3.3.0,<5.0.0; python_version < '3.13'", ] macos = [ - "openadapt-flow[macos]>=3.3.0,<4.0.0; sys_platform == 'darwin' and python_version < '3.13'", + "openadapt-flow[macos]>=3.3.0,<5.0.0; sys_platform == 'darwin' and python_version < '3.13'", ] linux = [ - "openadapt-flow[linux]>=3.3.0,<4.0.0; sys_platform == 'linux' and python_version < '3.13'", + "openadapt-flow[linux]>=3.3.0,<5.0.0; sys_platform == 'linux' and python_version < '3.13'", ] rdp = [ - "openadapt-flow[rdp]>=3.3.0,<4.0.0; python_version < '3.13'", + "openadapt-flow[rdp]>=3.3.0,<5.0.0; python_version < '3.13'", ] ml = [ "openadapt-ml>=0.2.0", @@ -135,13 +135,13 @@ retrieval = [ "openadapt-retrieval>=0.1.0", ] privacy = [ - "openadapt-flow[privacy]>=3.3.0,<4.0.0; python_version < '3.13'", + "openadapt-flow[privacy]>=3.3.0,<5.0.0; python_version < '3.13'", ] # `flow` now ships in the base install (see `dependencies` above). This # extra is kept for backward compatibility so `pip install openadapt[flow]` # and the `all` bundle still resolve. flow = [ - "openadapt-flow[vision]>=3.3.0,<4.0.0; python_version < '3.13'", + "openadapt-flow[vision]>=3.3.0,<5.0.0; python_version < '3.13'", ] # `openadapt-agent` also ships in the base install. Keep the extra so # `pip install openadapt[agent]` still resolves. diff --git a/tests/test_cli_smoke.py b/tests/test_cli_smoke.py index 9a69fe6785..14b357cc7e 100644 --- a/tests/test_cli_smoke.py +++ b/tests/test_cli_smoke.py @@ -391,29 +391,29 @@ def test_launcher_flow_and_substrate_extras_metadata(): assert ( metadata["dependencies"].count( - f"openadapt-flow[browser,hosted]>=3.3.0,<4.0.0; {supported}" + f"openadapt-flow[browser,hosted]>=3.3.0,<5.0.0; {supported}" ) == 1 ) assert ( metadata["dependencies"].count(f"openadapt-agent>=2.1.0,<3; {supported}") == 1 ) - assert extras["flow"] == [f"openadapt-flow[vision]>=3.3.0,<4.0.0; {supported}"] + assert extras["flow"] == [f"openadapt-flow[vision]>=3.3.0,<5.0.0; {supported}"] assert extras["agent"] == [f"openadapt-agent>=2.1.0,<3; {supported}"] - assert extras["browser"] == [f"openadapt-flow[browser]>=3.3.0,<4.0.0; {supported}"] - assert extras["privacy"] == [f"openadapt-flow[privacy]>=3.3.0,<4.0.0; {supported}"] + assert extras["browser"] == [f"openadapt-flow[browser]>=3.3.0,<5.0.0; {supported}"] + assert extras["privacy"] == [f"openadapt-flow[privacy]>=3.3.0,<5.0.0; {supported}"] assert extras["capture"] == [ "openadapt-capture>=1.2.0,<2.0.0", - f"openadapt-flow[capture]>=3.3.0,<4.0.0; {supported}", + f"openadapt-flow[capture]>=3.3.0,<5.0.0; {supported}", ] - assert extras["windows"] == [f"openadapt-flow[windows]>=3.3.0,<4.0.0; {supported}"] + assert extras["windows"] == [f"openadapt-flow[windows]>=3.3.0,<5.0.0; {supported}"] assert extras["macos"] == [ - f"openadapt-flow[macos]>=3.3.0,<4.0.0; sys_platform == 'darwin' and {supported}" + f"openadapt-flow[macos]>=3.3.0,<5.0.0; sys_platform == 'darwin' and {supported}" ] assert extras["linux"] == [ - f"openadapt-flow[linux]>=3.3.0,<4.0.0; sys_platform == 'linux' and {supported}" + f"openadapt-flow[linux]>=3.3.0,<5.0.0; sys_platform == 'linux' and {supported}" ] - assert extras["rdp"] == [f"openadapt-flow[rdp]>=3.3.0,<4.0.0; {supported}"] + assert extras["rdp"] == [f"openadapt-flow[rdp]>=3.3.0,<5.0.0; {supported}"] assert extras["all"] == [ "openadapt[browser,core,grounding,retrieval,privacy,flow,windows,rdp,agent]", "openadapt[macos]; sys_platform == 'darwin'", @@ -451,7 +451,7 @@ def test_launcher_accepts_flow_versions_in_the_supported_range(version): @pytest.mark.parametrize( "version", - ["1.28.9", "1.35.1", "2.1.0", "2.7.1", "3.1.0", "3.2.1", "4.0.0", "invalid"], + ["1.28.9", "1.35.1", "2.1.0", "2.7.1", "3.1.0", "3.2.1", "5.0.0", "invalid"], ) def test_launcher_rejects_flow_versions_outside_the_supported_range(version): assert not _supported_flow_version(version) @@ -824,7 +824,7 @@ def test_deploy_preflight_fails_without_rdp_transport(monkeypatch): @pytest.mark.parametrize( - "flow_version", ["1.35.1", "2.1.0", "4.0.0", "4.1.0", "invalid"] + "flow_version", ["1.35.1", "2.1.0", "5.0.0", "5.1.0", "invalid"] ) def test_deploy_preflight_fails_for_unsupported_flow(monkeypatch, flow_version): monkeypatch.setattr("importlib.util.find_spec", lambda _name: object()) @@ -834,7 +834,7 @@ def test_deploy_preflight_fails_for_unsupported_flow(monkeypatch, flow_version): assert result.exit_code != 0 assert "[UNSUPPORTED]" in result.output - assert ">=3.3.0,<4.0.0" in result.output + assert ">=3.3.0,<5.0.0" in result.output assert "Preflight passed" not in result.output diff --git a/tests/test_flow_floor.py b/tests/test_flow_floor.py index f0561c6759..2a3ee72812 100644 --- a/tests/test_flow_floor.py +++ b/tests/test_flow_floor.py @@ -87,6 +87,7 @@ def test_doctor_and_deploy_accept_the_fixed_release() -> None: assert Requirement(f"openadapt-flow{_SUPPORTED_FLOW_RANGE}").specifier.contains( ACCEPTED ) - # Later Flow 3 releases are accepted; 4 is unknown. + # Later Flow 3 and Flow 4 releases are accepted; 5 is unknown. assert _supported_flow_version("3.99.0") - assert not _supported_flow_version("4.0.0") + assert _supported_flow_version("4.0.0") + assert not _supported_flow_version("5.0.0") diff --git a/uv.lock b/uv.lock index d3b54a112c..23db188f6a 100644 --- a/uv.lock +++ b/uv.lock @@ -3463,15 +3463,15 @@ requires-dist = [ { name = "openadapt-agent", marker = "python_full_version < '3.13' and extra == 'agent'", specifier = ">=2.1.0,<3" }, { name = "openadapt-capture", marker = "extra == 'capture'", specifier = ">=1.2.0,<2.0.0" }, { name = "openadapt-evals", marker = "extra == 'evals'", specifier = ">=0.1.0" }, - { name = "openadapt-flow", extras = ["browser"], marker = "python_full_version < '3.13' and extra == 'browser'", specifier = ">=3.3.0,<4.0.0" }, - { name = "openadapt-flow", extras = ["browser", "hosted"], marker = "python_full_version < '3.13'", specifier = ">=3.3.0,<4.0.0" }, - { name = "openadapt-flow", extras = ["capture"], marker = "python_full_version < '3.13' and extra == 'capture'", specifier = ">=3.3.0,<4.0.0" }, - { name = "openadapt-flow", extras = ["linux"], marker = "python_full_version < '3.13' and sys_platform == 'linux' and extra == 'linux'", specifier = ">=3.3.0,<4.0.0" }, - { name = "openadapt-flow", extras = ["macos"], marker = "python_full_version < '3.13' and sys_platform == 'darwin' and extra == 'macos'", specifier = ">=3.3.0,<4.0.0" }, - { name = "openadapt-flow", extras = ["privacy"], marker = "python_full_version < '3.13' and extra == 'privacy'", specifier = ">=3.3.0,<4.0.0" }, - { name = "openadapt-flow", extras = ["rdp"], marker = "python_full_version < '3.13' and extra == 'rdp'", specifier = ">=3.3.0,<4.0.0" }, - { name = "openadapt-flow", extras = ["vision"], marker = "python_full_version < '3.13' and extra == 'flow'", specifier = ">=3.3.0,<4.0.0" }, - { name = "openadapt-flow", extras = ["windows"], marker = "python_full_version < '3.13' and extra == 'windows'", specifier = ">=3.3.0,<4.0.0" }, + { name = "openadapt-flow", extras = ["browser"], marker = "python_full_version < '3.13' and extra == 'browser'", specifier = ">=3.3.0,<5.0.0" }, + { name = "openadapt-flow", extras = ["browser", "hosted"], marker = "python_full_version < '3.13'", specifier = ">=3.3.0,<5.0.0" }, + { name = "openadapt-flow", extras = ["capture"], marker = "python_full_version < '3.13' and extra == 'capture'", specifier = ">=3.3.0,<5.0.0" }, + { name = "openadapt-flow", extras = ["linux"], marker = "python_full_version < '3.13' and sys_platform == 'linux' and extra == 'linux'", specifier = ">=3.3.0,<5.0.0" }, + { name = "openadapt-flow", extras = ["macos"], marker = "python_full_version < '3.13' and sys_platform == 'darwin' and extra == 'macos'", specifier = ">=3.3.0,<5.0.0" }, + { name = "openadapt-flow", extras = ["privacy"], marker = "python_full_version < '3.13' and extra == 'privacy'", specifier = ">=3.3.0,<5.0.0" }, + { name = "openadapt-flow", extras = ["rdp"], marker = "python_full_version < '3.13' and extra == 'rdp'", specifier = ">=3.3.0,<5.0.0" }, + { name = "openadapt-flow", extras = ["vision"], marker = "python_full_version < '3.13' and extra == 'flow'", specifier = ">=3.3.0,<5.0.0" }, + { name = "openadapt-flow", extras = ["windows"], marker = "python_full_version < '3.13' and extra == 'windows'", specifier = ">=3.3.0,<5.0.0" }, { name = "openadapt-grounding", marker = "extra == 'grounding'", specifier = ">=0.1.0" }, { name = "openadapt-ml", marker = "extra == 'ml'", specifier = ">=0.2.0" }, { name = "openadapt-retrieval", marker = "extra == 'retrieval'", specifier = ">=0.1.0" }, From d37a403a87ed5fd169a907e972fbcdb8acc4b891 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sun, 22 Nov 2026 08:17:50 -0500 Subject: [PATCH 2/6] release: address review of types 0.24.1 and verify 0.2.1 - verify's distribution check asserted the old <4 Flow cap; it now expects <5, so the verify job and its release build pass. - RewardScoringPolicyV1 leaves escalated_after_effect_reward out of its serialization at the default, so a contract file 0.24.1 writes stays readable by 0.24.0 and hashes the same; the digest needs no special case. A test checks the serialized form against the 0.24.0 fixture. - The types notes move the validator change into Features and add a Compatibility section. The verify note names the extras it widens. Verify's suite passes against the Flow 4.0.0 source (91 passed; the 3 installed-CLI tests need an installed openadapt-verify and fail the same way without this change). --- openadapt/cli.py | 2 +- packages/types/CHANGELOG.md | 22 +++++++------ packages/types/openadapt_types/reward.py | 31 +++++++++++++------ packages/types/tests/test_reward.py | 11 +++++++ packages/verify/CHANGELOG.md | 7 +++-- packages/verify/scripts/check_distribution.py | 2 +- 6 files changed, 50 insertions(+), 25 deletions(-) diff --git a/openadapt/cli.py b/openadapt/cli.py index 866950dda1..c24364ab43 100644 --- a/openadapt/cli.py +++ b/openadapt/cli.py @@ -1336,7 +1336,7 @@ def _warn_about_launcher_conflicts() -> None: # key derivation once per store. Launcher 1.23 requires Flow 3.3: the OpenEMR # quickstart's referral program checks its date picker against the run's # clock (`Postcondition.text_clock`), which Flow 3.2 ignores. Flow 4.0 -# removed and renamed APIs the launcher doesn't use, so it is accepted too. +# removes and renames APIs the launcher doesn't use, so it is accepted too. _SUPPORTED_FLOW_RANGE = ">=3.3.0,<5.0.0" _RDP_INSTALL_COMMAND = _pip_install("openadapt[rdp]") _CHROMIUM_SYSTEM_LIBS_COMMAND = ( diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 4ed63d9012..7ee45cf626 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -37,20 +37,22 @@ package repairs a Flow 3.4.0 install. person instead of declaring the task done. It scores as partial credit, `escalated_after_effect_reward` (default 0.5, at least 0 and below 1) ([#1824](https://github.com/OpenAdaptAI/OpenAdapt/pull/1824)). - -### Fixes - - A reward scoring policy whose `escalated_after_effect_reward` is at or above its `verified_reward` is refused, because asking a person would then pay as much as finishing. The one exception is the default, 0.5: a contract - with a `verified_reward` of 0.5 or less still loads, as in 0.24.0, and - asking then earns no credit (`escalated_after_effect_credit`) - ([#1824](https://github.com/OpenAdaptAI/OpenAdapt/pull/1824)). + with a `verified_reward` of 0.5 or less loads, as in 0.24.0, and asking then + earns no credit (`escalated_after_effect_credit`). + +### Compatibility + - Reward contract digests are unchanged from 0.24.0. - `escalated_after_effect_reward` enters `RewardContractV1.digest` only when - it differs from its default, so every contract and certificate issued - under 0.24.0 hashes and verifies as before. A test checks contracts and - certificates issued by openadapt-types 0.24.0 from PyPI. + `escalated_after_effect_reward` is serialized, and so hashed, only when it + differs from its default. Every contract and certificate issued under + 0.24.0 hashes and verifies as before, and a file 0.24.1 writes for such a + contract is one 0.24.0 can read. A test checks contracts and certificates + issued by openadapt-types 0.24.0 from PyPI. +- A contract that sets `escalated_after_effect_reward` to anything but 0.5 + can't be read by 0.24.0, which forbids unknown fields. ## v0.24.0 (2026-10-20) diff --git a/packages/types/openadapt_types/reward.py b/packages/types/openadapt_types/reward.py index 177c50ec3d..86e00de8fb 100644 --- a/packages/types/openadapt_types/reward.py +++ b/packages/types/openadapt_types/reward.py @@ -47,7 +47,9 @@ StrictFloat, StrictInt, StrictStr, + SerializerFunctionWrapHandler, field_validator, + model_serializer, model_validator, ) @@ -256,8 +258,8 @@ def tier(self) -> OracleTier: #: The credit for asking after the work is done, when a contract declares none. ESCALATED_AFTER_EFFECT_DEFAULT = 0.5 #: Scoring fields added in 0.24.1, with the default a contract certified -#: under 0.24.0 implicitly has. RewardContractV1.digest leaves them out at that -#: default, so every 0.24.0 digest stays the same. +#: under 0.24.0 implicitly has. They are not serialized at that default, so +#: every 0.24.0 digest stays the same and 0.24.0 can read what 0.24.1 writes. _DIGEST_STABLE_SCORING_DEFAULTS: Mapping[str, float] = { "escalated_after_effect_reward": ESCALATED_AFTER_EFFECT_DEFAULT, } @@ -333,6 +335,19 @@ def _partial_credit_below_verified(self) -> RewardScoringPolicyV1: ) return self + @model_serializer(mode="wrap") + def _omit_new_defaults( + self, handler: SerializerFunctionWrapHandler + ) -> dict[str, object]: + # A field added in 0.24.1 is written out only when it differs from + # its default, so a file this version writes stays readable by + # 0.24.0 (whose models forbid unknown fields) and hashes the same. + data = handler(self) + for name, default in _DIGEST_STABLE_SCORING_DEFAULTS.items(): + if data.get(name) == default: + del data[name] + return data + @property def escalated_after_effect_credit(self) -> float: """The scalar an ``escalated_after_effect`` episode earns. @@ -420,17 +435,13 @@ def component_names(self) -> tuple[str, ...]: def digest(self) -> str: """The canonical digest certificates and receipts bind. - A scoring field added after a contract version shipped enters the - digest only when it differs from its default, so a contract written + A scoring field added after a contract version shipped is serialized, + and so hashed, only when it differs from its default + (``RewardScoringPolicyV1._omit_new_defaults``). A contract written before the field existed keeps the digest it was certified under. """ - payload = self.model_dump(mode="json") - scoring = payload["scoring"] - for name, default in _DIGEST_STABLE_SCORING_DEFAULTS.items(): - if scoring.get(name) == default: - del scoring[name] - return _digest_payload(payload) + return _digest_payload(self.model_dump(mode="json")) class RewardCertificateV1(_StrictContract): diff --git a/packages/types/tests/test_reward.py b/packages/types/tests/test_reward.py index 33fdddf39c..b03fb53d9d 100644 --- a/packages/types/tests/test_reward.py +++ b/packages/types/tests/test_reward.py @@ -782,6 +782,17 @@ def test_contracts_and_certificates_issued_under_0_24_0_verify_unchanged( ) +def test_a_default_contract_serializes_as_0_24_0_did() -> None: + # 0.24.0 forbids unknown fields, so a file this version writes must not + # carry the new field at its default. + case = json.loads(_ISSUED_0_24_0.read_text(encoding="utf-8"))["cases"][0] + contract = RewardContractV1.model_validate(case["contract"]) + assert contract.model_dump(mode="json") == case["contract"] + assert "escalated_after_effect_reward" not in contract.scoring.model_dump() + custom = _contract_with_scoring(escalated_after_effect_reward=0.25) + assert custom.scoring.model_dump()["escalated_after_effect_reward"] == 0.25 + + def test_escalated_after_effect_reward_is_part_of_the_contract_digest() -> None: half = _contract_with_scoring(escalated_after_effect_reward=0.5) quarter = _contract_with_scoring(escalated_after_effect_reward=0.25) diff --git a/packages/verify/CHANGELOG.md b/packages/verify/CHANGELOG.md index 1e7cca7eea..ec1eeac43b 100644 --- a/packages/verify/CHANGELOG.md +++ b/packages/verify/CHANGELOG.md @@ -2,9 +2,10 @@ ## v0.2.1 (2026-11-22) -- Accept openadapt-flow 4: every openadapt-flow requirement is now - `>=3.0.0,<5` (was `<4`), so openadapt-verify installs beside the next Flow - major instead of holding Flow at 3.x (#2535). +- Accept openadapt-flow 4: the openadapt-flow requirement and the `openai`, + `claude` and `mcp` extras now allow `<5` (was `<4`), so openadapt-verify + installs beside the next Flow major instead of holding Flow at 3.x + (#2535). ## v0.2.0 (2026-11-14) diff --git a/packages/verify/scripts/check_distribution.py b/packages/verify/scripts/check_distribution.py index 5085542e6c..5edb85d23e 100644 --- a/packages/verify/scripts/check_distribution.py +++ b/packages/verify/scripts/check_distribution.py @@ -75,7 +75,7 @@ def check(dist: Path, root: Path) -> dict: if requirement.marker is None } assert base["openadapt-flow"].extras == {"receipts"} - assert base["openadapt-flow"].specifier == SpecifierSet(">=3.0.0,<4") + assert base["openadapt-flow"].specifier == SpecifierSet(">=3.0.0,<5") assert base["cryptography"].specifier == SpecifierSet(">=50.0.0") # Flow 3's base install has no vision stack; nothing here adds one. assert set(base) == {"openadapt-flow", "cryptography"}, set(base) From 465799f58210b497d967b22192ffb23af05622b8 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sun, 22 Nov 2026 08:26:17 -0500 Subject: [PATCH 3/6] fix(types): an undeclared escalation earns nothing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit escalated_after_effect_reward now defaults to 0, not 0.5. A contract written or certified before the escalated_after_effect outcome existed never declared it, so the outcome must not start paying under it. - The field is still left out of serialization at its default, so 0.24.0 contracts and certificates hash, verify and load as before, and 0.24.1 writes files 0.24.0 can read. - The validator no longer needs a default exception: any value at or above verified_reward is refused, and 0 is always below it. - The 0.24.0 fixture now also records how 0.24.0 scored every outcome it knew (tier 2, policy update 120). The test checks 0.24.1 scores them the same and gives the new outcome 0. A declared value is paid as declared. - Flow's synthetic reward bundle declares escalated_after_effect_reward 0.5, so its demo and Harness² tests keep their partial credit. That contract declares it, so it is paid. --- packages/flow/openadapt_flow/reward/bundle.py | 8 +- packages/types/CHANGELOG.md | 28 +++--- packages/types/openadapt_types/reward.py | 30 +++--- .../schemas/reward-contract-v1.json | 4 +- .../tests/fixtures/reward_issued_0_24_0.json | 92 ++++++++++++++++++- packages/types/tests/test_reward.py | 41 ++++++--- 6 files changed, 156 insertions(+), 47 deletions(-) diff --git a/packages/flow/openadapt_flow/reward/bundle.py b/packages/flow/openadapt_flow/reward/bundle.py index fd830417fb..c4feb609e6 100644 --- a/packages/flow/openadapt_flow/reward/bundle.py +++ b/packages/flow/openadapt_flow/reward/bundle.py @@ -148,7 +148,13 @@ def write_bundle( "components": [{"name": "terminal_effect", "weight": 1.0}], # The synthetic banner lie yields 0, not the default -1 penalty: # this fixture demonstrates "no reward", not a tuned penalty. - "scoring": {"wrong_effect_reward": 0.0}, + # Asking a person after the right record landed earns half the + # verified reward. The contract declares it: an undeclared + # escalation earns nothing (openadapt-types 0.24.1). + "scoring": { + "wrong_effect_reward": 0.0, + "escalated_after_effect_reward": 0.5, + }, "certificate_policy": { "epsilon": 0.05, "delta": 0.05, diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 7ee45cf626..087a49660d 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -34,25 +34,25 @@ package repairs a Flow 3.4.0 install. `openadapt_types` ([#2494](https://github.com/OpenAdaptAI/OpenAdapt/pull/2494)). - Reward contracts: the `escalated_after_effect` outcome, for an episode whose required effects are all in the system of record but which asked a - person instead of declaring the task done. It scores as partial credit, - `escalated_after_effect_reward` (default 0.5, at least 0 and below 1) + person instead of declaring the task done. It earns the contract's + `escalated_after_effect_reward`, at least 0 and below its + `verified_reward`; a declared value at or above `verified_reward` is + refused, because asking would then pay as much as finishing. The default + is 0: a contract that doesn't declare it earns nothing for this outcome ([#1824](https://github.com/OpenAdaptAI/OpenAdapt/pull/1824)). -- A reward scoring policy whose `escalated_after_effect_reward` is at or - above its `verified_reward` is refused, because asking a person would then - pay as much as finishing. The one exception is the default, 0.5: a contract - with a `verified_reward` of 0.5 or less loads, as in 0.24.0, and asking then - earns no credit (`escalated_after_effect_credit`). ### Compatibility -- Reward contract digests are unchanged from 0.24.0. - `escalated_after_effect_reward` is serialized, and so hashed, only when it - differs from its default. Every contract and certificate issued under - 0.24.0 hashes and verifies as before, and a file 0.24.1 writes for such a - contract is one 0.24.0 can read. A test checks contracts and certificates +- Contracts written or certified under 0.24.0 behave as before. They load + (including any positive `verified_reward`), hash to the same digest, keep + their certificates, and score every outcome 0.24.0 had the same way. The + new `escalated_after_effect` outcome earns 0 under them, since they never + declared it. A test checks this against contracts and certificates issued by openadapt-types 0.24.0 from PyPI. -- A contract that sets `escalated_after_effect_reward` to anything but 0.5 - can't be read by 0.24.0, which forbids unknown fields. +- `escalated_after_effect_reward` is serialized, and so hashed, only when it + differs from 0, so a file 0.24.1 writes for an undeclared contract is one + 0.24.0 can read. A contract that declares a non-zero value can't be read + by 0.24.0, which forbids unknown fields. ## v0.24.0 (2026-10-20) diff --git a/packages/types/openadapt_types/reward.py b/packages/types/openadapt_types/reward.py index 86e00de8fb..357e386974 100644 --- a/packages/types/openadapt_types/reward.py +++ b/packages/types/openadapt_types/reward.py @@ -124,7 +124,7 @@ class RewardOutcomeV1(str, Enum): and no forbidden effect is, but the policy halted, refused, or was rejected instead of declaring the task done. Partial credit: the contract's ``escalated_after_effect_reward``, at least zero and below the - verified reward.""" + verified reward, and zero when the contract declares none.""" RECONCILIATION_REQUIRED = "reconciliation_required" """Delivery or effect is uncertain. UNSCORED. Never 0.0.""" @@ -256,7 +256,9 @@ def tier(self) -> OracleTier: #: The credit for asking after the work is done, when a contract declares none. -ESCALATED_AFTER_EFFECT_DEFAULT = 0.5 +#: Zero: an outcome added in 0.24.1 never pays under a contract that was +#: written, or certified, without declaring it. +ESCALATED_AFTER_EFFECT_DEFAULT = 0.0 #: Scoring fields added in 0.24.1, with the default a contract certified #: under 0.24.0 implicitly has. They are not serialized at that default, so #: every 0.24.0 digest stays the same and 0.24.0 can read what 0.24.1 writes. @@ -276,13 +278,12 @@ class RewardScoringPolicyV1(_StrictContract): the confidence a policy needs before it declares done rather than asks: with verified reward ``v``, wrong-effect reward ``w`` and this value ``x``, declaring done pays more in expectation only when the policy is - more than ``(x - w) / (v - w)`` sure the effect is right. With the - defaults (1, -1, 0.5) that is 75%. Zero gives no credit for asking. A - value other than the default 0.5 at or above the verified reward is - refused, because asking would then pay as much as finishing. At 0.5 (the - default, or the same value written out) with a ``verified_reward`` of 0.5 - or less, which 0.24.0 accepted, the contract loads and asking earns no - credit (``escalated_after_effect_credit``). + more than ``(x - w) / (v - w)`` sure the effect is right. With + ``v = 1``, ``w = -1`` and ``x = 0.5`` that is 75%. The default is zero: + a contract that doesn't declare it gives no credit for asking, so a + contract certified before this outcome existed never starts paying for + it. A value at or above the verified reward is refused, because asking + would then pay as much as finishing. """ verified_reward: StrictFloat = Field( @@ -326,10 +327,7 @@ class RewardScoringPolicyV1(_StrictContract): @model_validator(mode="after") def _partial_credit_below_verified(self) -> RewardScoringPolicyV1: - if ( - self.escalated_after_effect_reward >= self.verified_reward - and self.escalated_after_effect_reward != ESCALATED_AFTER_EFFECT_DEFAULT - ): + if self.escalated_after_effect_reward >= self.verified_reward: raise ValueError( "escalated_after_effect_reward must be below verified_reward" ) @@ -352,12 +350,10 @@ def _omit_new_defaults( def escalated_after_effect_credit(self) -> float: """The scalar an ``escalated_after_effect`` episode earns. - The declared value, or zero when the default is not below the - verified reward, so asking never pays as much as finishing. + The declared value, zero when the contract declares none. The + validator keeps it below the verified reward. """ - if self.escalated_after_effect_reward >= self.verified_reward: - return 0.0 return self.escalated_after_effect_reward def scalar_for(self, outcome: RewardOutcomeV1) -> float | None: diff --git a/packages/types/openadapt_types/schemas/reward-contract-v1.json b/packages/types/openadapt_types/schemas/reward-contract-v1.json index 3481192101..01e8985d50 100644 --- a/packages/types/openadapt_types/schemas/reward-contract-v1.json +++ b/packages/types/openadapt_types/schemas/reward-contract-v1.json @@ -113,10 +113,10 @@ }, "RewardScoringPolicyV1": { "additionalProperties": false, - "description": "How each scoring class becomes a scalar.\n\nUncertain episodes and platform failures are fixed to ``unscored`` in\nthis version. A contract cannot declare them to be zero.\n\n``escalated_after_effect_reward`` is the credit for an episode that did\nthe work and then asked a person instead of declaring it done. It sets\nthe confidence a policy needs before it declares done rather than asks:\nwith verified reward ``v``, wrong-effect reward ``w`` and this value\n``x``, declaring done pays more in expectation only when the policy is\nmore than ``(x - w) / (v - w)`` sure the effect is right. With the\ndefaults (1, -1, 0.5) that is 75%. Zero gives no credit for asking. A\nvalue other than the default 0.5 at or above the verified reward is\nrefused, because asking would then pay as much as finishing. At 0.5 (the\ndefault, or the same value written out) with a ``verified_reward`` of 0.5\nor less, which 0.24.0 accepted, the contract loads and asking earns no\ncredit (``escalated_after_effect_credit``).", + "description": "How each scoring class becomes a scalar.\n\nUncertain episodes and platform failures are fixed to ``unscored`` in\nthis version. A contract cannot declare them to be zero.\n\n``escalated_after_effect_reward`` is the credit for an episode that did\nthe work and then asked a person instead of declaring it done. It sets\nthe confidence a policy needs before it declares done rather than asks:\nwith verified reward ``v``, wrong-effect reward ``w`` and this value\n``x``, declaring done pays more in expectation only when the policy is\nmore than ``(x - w) / (v - w)`` sure the effect is right. With\n``v = 1``, ``w = -1`` and ``x = 0.5`` that is 75%. The default is zero:\na contract that doesn't declare it gives no credit for asking, so a\ncontract certified before this outcome existed never starts paying for\nit. A value at or above the verified reward is refused, because asking\nwould then pay as much as finishing.", "properties": { "escalated_after_effect_reward": { - "default": 0.5, + "default": 0.0, "exclusiveMaximum": 1.0, "minimum": 0.0, "title": "Escalated After Effect Reward", diff --git a/packages/types/tests/fixtures/reward_issued_0_24_0.json b/packages/types/tests/fixtures/reward_issued_0_24_0.json index 39680353b0..d5c97fa3dc 100644 --- a/packages/types/tests/fixtures/reward_issued_0_24_0.json +++ b/packages/types/tests/fixtures/reward_issued_0_24_0.json @@ -65,7 +65,51 @@ "task_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_id": "task.reference.0001" }, - "contract_digest": "sha256:15844d27bd5d12fe71868b2753a31292c676f878dc379562956176fea8e5246c" + "contract_digest": "sha256:15844d27bd5d12fe71868b2753a31292c676f878dc379562956176fea8e5246c", + "scores_tier_2_update_120": { + "failed_platform": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": null + }, + "halted_before_effect": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": 0.0 + }, + "reconciliation_required": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": null + }, + "refused": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": 0.0 + }, + "rejected_policy": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": 0.0 + }, + "verified": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": 1.0 + }, + "wrong_effect": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": -1.0 + } + } }, { "certificate": { @@ -132,7 +176,51 @@ "task_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_id": "task.reference.0001" }, - "contract_digest": "sha256:7ed7ab3a5f17daa0ed06d77e59e21d1fbdd306d1e0cb0c2e16380dd779884650" + "contract_digest": "sha256:7ed7ab3a5f17daa0ed06d77e59e21d1fbdd306d1e0cb0c2e16380dd779884650", + "scores_tier_2_update_120": { + "failed_platform": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": null + }, + "halted_before_effect": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": 0.0 + }, + "reconciliation_required": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": null + }, + "refused": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": 0.0 + }, + "rejected_policy": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": 0.0 + }, + "verified": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": 0.5 + }, + "wrong_effect": { + "certification_refusals": [], + "certified": true, + "development_only": false, + "scalar": -1.0 + } + } } ], "issued_with": "openadapt-types 0.24.0 from PyPI" diff --git a/packages/types/tests/test_reward.py b/packages/types/tests/test_reward.py index b03fb53d9d..2b55abcc4f 100644 --- a/packages/types/tests/test_reward.py +++ b/packages/types/tests/test_reward.py @@ -705,7 +705,7 @@ def test_default_scalar_for_each_scored_outcome() -> None: contract = _contract() expected = { RewardOutcomeV1.VERIFIED: 1.0, - RewardOutcomeV1.ESCALATED_AFTER_EFFECT: 0.5, + RewardOutcomeV1.ESCALATED_AFTER_EFFECT: 0.0, RewardOutcomeV1.HALTED_BEFORE_EFFECT: 0.0, RewardOutcomeV1.REFUSED: 0.0, RewardOutcomeV1.REJECTED_POLICY: 0.0, @@ -744,14 +744,19 @@ def test_escalated_after_effect_reward_must_stay_below_verified() -> None: assert contract.scoring.escalated_after_effect_reward == 0.4 -def test_the_default_gives_no_credit_when_it_is_not_below_verified() -> None: +def test_an_undeclared_escalation_earns_nothing() -> None: + # A contract written without the field never pays for the new outcome. + escalated = RewardOutcomeV1.ESCALATED_AFTER_EFFECT + assert _contract().scoring.escalated_after_effect_reward == 0.0 + assert _contract().scoring.scalar_for(escalated) == 0.0 # 0.24.0 accepted any positive verified_reward; 0.24.1 still does. - contract = _contract_with_scoring(verified_reward=0.5) - scoring = contract.scoring - assert scoring.escalated_after_effect_reward == 0.5 - assert scoring.escalated_after_effect_credit == 0.0 - assert scoring.scalar_for(RewardOutcomeV1.ESCALATED_AFTER_EFFECT) == 0.0 - assert _contract().scoring.scalar_for(RewardOutcomeV1.ESCALATED_AFTER_EFFECT) == 0.5 + low = _contract_with_scoring(verified_reward=0.5) + assert low.scoring.scalar_for(escalated) == 0.0 + declared = _contract_with_scoring(escalated_after_effect_reward=0.25) + assert declared.scoring.escalated_after_effect_credit == 0.25 + assert declared.scoring.scalar_for(escalated) == 0.25 + with pytest.raises(ValidationError, match="below verified_reward"): + _contract_with_scoring(verified_reward=0.5, escalated_after_effect_reward=0.5) _ISSUED_0_24_0 = Path(__file__).parent / "fixtures" / "reward_issued_0_24_0.json" @@ -780,6 +785,20 @@ def test_contracts_and_certificates_issued_under_0_24_0_verify_unchanged( certificate_state(certificate, 120).value == case["certificate_state_at_update_120"] ) + # Every outcome 0.24.0 knew scores as it did, and the one it didn't + # earns nothing under a contract that never declared it. + for outcome, expected in case["scores_tier_2_update_120"].items(): + scored = score(RewardOutcomeV1(outcome), 2, certificate, 120, contract=contract) + assert scored.scalar == expected["scalar"], outcome + assert scored.certified == expected["certified"], outcome + assert scored.development_only == expected["development_only"], outcome + assert list(scored.certification_refusals) == ( + expected["certification_refusals"] + ), outcome + escalated = score( + RewardOutcomeV1.ESCALATED_AFTER_EFFECT, 2, certificate, 120, contract=contract + ) + assert escalated.scalar == 0.0 def test_a_default_contract_serializes_as_0_24_0_did() -> None: @@ -794,10 +813,10 @@ def test_a_default_contract_serializes_as_0_24_0_did() -> None: def test_escalated_after_effect_reward_is_part_of_the_contract_digest() -> None: - half = _contract_with_scoring(escalated_after_effect_reward=0.5) + zero = _contract_with_scoring(escalated_after_effect_reward=0.0) quarter = _contract_with_scoring(escalated_after_effect_reward=0.25) - assert half.digest == _contract().digest - assert quarter.digest != half.digest + assert zero.digest == _contract().digest + assert quarter.digest != zero.digest def test_receipt_partial_credit_is_never_negative_or_uncertain() -> None: From 3da8f9532479a005f9e9e1407b695d87cd66a725 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sun, 22 Nov 2026 08:38:53 -0500 Subject: [PATCH 4/6] docs: the escalated_after_effect default is 0 everywhere it is described REWARD.md, the reward worker docstring, HARNESS2.md and REWARD_WORKER.md still said the default was 0.5. The types notes and docstring restore the below-1 bound beside the below-verified_reward one. The exported contract schema carries the new docstring. --- packages/flow/docs/HARNESS2.md | 2 +- packages/flow/docs/REWARD_WORKER.md | 2 +- packages/flow/openadapt_flow/reward/worker.py | 3 ++- packages/types/CHANGELOG.md | 4 ++-- packages/types/docs/REWARD.md | 16 +++++++++------- packages/types/openadapt_types/reward.py | 5 +++-- .../schemas/reward-contract-v1.json | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/flow/docs/HARNESS2.md b/packages/flow/docs/HARNESS2.md index 1ea885dc51..738f0a2ab6 100644 --- a/packages/flow/docs/HARNESS2.md +++ b/packages/flow/docs/HARNESS2.md @@ -43,7 +43,7 @@ they are, and turns the outcome into one number for ranking: | `wrong_effect`: reported saved, but no record landed | -0.5 | | A record landed on another patient | -1.0 | | The patient got more than one record | -1.0 | -| `escalated_after_effect`: the record landed as declared, then the agent stopped and asked | the receipt's scalar, the contract's `escalated_after_effect_reward` (default 0.5) | +| `escalated_after_effect`: the record landed as declared, then the agent stopped and asked | the receipt's scalar, the contract's `escalated_after_effect_reward` (0.5 in the synthetic bundle; 0 when a contract doesn't declare it) | | `reconciliation_required` or `failed_platform` | none (a person settles it) | The penalties are the caller's choice (`Penalties`). A write on another diff --git a/packages/flow/docs/REWARD_WORKER.md b/packages/flow/docs/REWARD_WORKER.md index b4e8a9bcb8..37645ecd04 100644 --- a/packages/flow/docs/REWARD_WORKER.md +++ b/packages/flow/docs/REWARD_WORKER.md @@ -111,7 +111,7 @@ this order. | Signal `completed`, every required effect CONFIRMED | `verified` | the declared positive reward | | Signal `completed`, a required effect REFUTED (absent, duplicated, wrong value) | `wrong_effect` | 0 or the declared penalty | | Signal `halted_before_effect`, `refused`, or `rejected_policy`, store shows no required effect | that outcome | 0 or the declared penalty | -| Same signals, and every required effect is present exactly as declared | `escalated_after_effect` | `escalated_after_effect_reward` (default 0.5) | +| Same signals, and every required effect is present exactly as declared | `escalated_after_effect` | `escalated_after_effect_reward` (0 unless the contract declares it; the synthetic bundle declares 0.5) | | Same signals, and a required effect is present but not as declared | `reconciliation_required`, uncertainty `effect_uncertain` | unscored | Unscored is never 0.0. The receipt carries `scalar_reward: null` and the diff --git a/packages/flow/openadapt_flow/reward/worker.py b/packages/flow/openadapt_flow/reward/worker.py index 43991dfce6..30cd36acf9 100644 --- a/packages/flow/openadapt_flow/reward/worker.py +++ b/packages/flow/openadapt_flow/reward/worker.py @@ -140,7 +140,8 @@ def judge_episode( * signal ``halted_before_effect`` / ``refused`` / ``rejected_policy``: no required effect present -> that outcome; every required effect CONFIRMED -> ``ESCALATED_AFTER_EFFECT``, the contract's partial credit - (default 0.5), because the work is done and the policy asked a person + (0 unless the contract declares it; the synthetic bundle declares + 0.5), because the work is done and the policy asked a person instead of declaring it; any other required effect present (a duplicate or wrong write, say) -> ``RECONCILIATION_REQUIRED`` with ``effect_uncertain``, since the runtime and the store disagree and a diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 087a49660d..d7c2990f04 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -35,8 +35,8 @@ package repairs a Flow 3.4.0 install. - Reward contracts: the `escalated_after_effect` outcome, for an episode whose required effects are all in the system of record but which asked a person instead of declaring the task done. It earns the contract's - `escalated_after_effect_reward`, at least 0 and below its - `verified_reward`; a declared value at or above `verified_reward` is + `escalated_after_effect_reward`: at least 0, below 1 and below its + `verified_reward`. A declared value at or above `verified_reward` is refused, because asking would then pay as much as finishing. The default is 0: a contract that doesn't declare it earns nothing for this outcome ([#1824](https://github.com/OpenAdaptAI/OpenAdapt/pull/1824)). diff --git a/packages/types/docs/REWARD.md b/packages/types/docs/REWARD.md index f86ac4f064..0bbddb60b6 100644 --- a/packages/types/docs/REWARD.md +++ b/packages/types/docs/REWARD.md @@ -94,7 +94,7 @@ answer `score()` gave. | `refused` | zero or penalty | `refused_reward` (default 0.0) | | `rejected_policy` | zero or penalty | `rejected_policy_reward` (default 0.0) | | `wrong_effect` | zero or penalty | `wrong_effect_reward` (default -1.0) | -| `escalated_after_effect` | partial credit | `escalated_after_effect_reward` (default 0.5) | +| `escalated_after_effect` | partial credit | `escalated_after_effect_reward` (default 0) | | `reconciliation_required` | unscored | none | | `failed_platform` | unscored | none | @@ -109,17 +109,19 @@ failure this contract exists to stop. `escalated_after_effect` is an episode where every required effect is in the system of record exactly as declared and no forbidden effect is, but the policy halted, refused, or was rejected instead of declaring the task done. It earns -`escalated_after_effect_reward`, default 0.5. The value must be at least 0 and -below 1, and below `verified_reward`; anything else, including NaN and -infinity, makes the contract refuse to load. +`escalated_after_effect_reward`, default 0: a contract that doesn't declare +it earns nothing for this outcome, so a contract written before the outcome +existed never starts paying for it. The value must be at least 0 and below 1, +and below `verified_reward`; anything else, including NaN and infinity, makes +the contract refuse to load. The value sets how sure a policy has to be before it declares done rather than asks a person. Declaring done earns `verified_reward` (v) when the effect is right and `wrong_effect_reward` (w) when it is wrong; asking earns x. Done pays more in expectation only when the policy's confidence p satisfies -p * v + (1 - p) * w > x, that is p > (x - w) / (v - w). With v = 1, w = -1 and -the default x = 0.5, the threshold is 75%. With x = 0 it is 50%, and with -x = 0.25 it is 62.5%. A higher x makes the policy ask more often. +p * v + (1 - p) * w > x, that is p > (x - w) / (v - w). With v = 1 and w = -1, +the default x = 0 gives a threshold of 50%, x = 0.25 gives 62.5%, and x = 0.5 +gives 75%. A higher x makes the policy ask more often. An effect that is present but not as declared (a duplicate or a wrong value) after the policy stopped is still `reconciliation_required` and unscored, and a diff --git a/packages/types/openadapt_types/reward.py b/packages/types/openadapt_types/reward.py index 357e386974..0d49a5199a 100644 --- a/packages/types/openadapt_types/reward.py +++ b/packages/types/openadapt_types/reward.py @@ -282,8 +282,9 @@ class RewardScoringPolicyV1(_StrictContract): ``v = 1``, ``w = -1`` and ``x = 0.5`` that is 75%. The default is zero: a contract that doesn't declare it gives no credit for asking, so a contract certified before this outcome existed never starts paying for - it. A value at or above the verified reward is refused, because asking - would then pay as much as finishing. + it. The value is at least 0 and below 1; a value at or above the + verified reward is refused too, because asking would then pay as much as + finishing. """ verified_reward: StrictFloat = Field( diff --git a/packages/types/openadapt_types/schemas/reward-contract-v1.json b/packages/types/openadapt_types/schemas/reward-contract-v1.json index 01e8985d50..2d65305d63 100644 --- a/packages/types/openadapt_types/schemas/reward-contract-v1.json +++ b/packages/types/openadapt_types/schemas/reward-contract-v1.json @@ -113,7 +113,7 @@ }, "RewardScoringPolicyV1": { "additionalProperties": false, - "description": "How each scoring class becomes a scalar.\n\nUncertain episodes and platform failures are fixed to ``unscored`` in\nthis version. A contract cannot declare them to be zero.\n\n``escalated_after_effect_reward`` is the credit for an episode that did\nthe work and then asked a person instead of declaring it done. It sets\nthe confidence a policy needs before it declares done rather than asks:\nwith verified reward ``v``, wrong-effect reward ``w`` and this value\n``x``, declaring done pays more in expectation only when the policy is\nmore than ``(x - w) / (v - w)`` sure the effect is right. With\n``v = 1``, ``w = -1`` and ``x = 0.5`` that is 75%. The default is zero:\na contract that doesn't declare it gives no credit for asking, so a\ncontract certified before this outcome existed never starts paying for\nit. A value at or above the verified reward is refused, because asking\nwould then pay as much as finishing.", + "description": "How each scoring class becomes a scalar.\n\nUncertain episodes and platform failures are fixed to ``unscored`` in\nthis version. A contract cannot declare them to be zero.\n\n``escalated_after_effect_reward`` is the credit for an episode that did\nthe work and then asked a person instead of declaring it done. It sets\nthe confidence a policy needs before it declares done rather than asks:\nwith verified reward ``v``, wrong-effect reward ``w`` and this value\n``x``, declaring done pays more in expectation only when the policy is\nmore than ``(x - w) / (v - w)`` sure the effect is right. With\n``v = 1``, ``w = -1`` and ``x = 0.5`` that is 75%. The default is zero:\na contract that doesn't declare it gives no credit for asking, so a\ncontract certified before this outcome existed never starts paying for\nit. The value is at least 0 and below 1; a value at or above the\nverified reward is refused too, because asking would then pay as much as\nfinishing.", "properties": { "escalated_after_effect_reward": { "default": 0.0, From 81deab2166eec25856b5244012801b01854070cb Mon Sep 17 00:00:00 2001 From: abrichr Date: Sun, 22 Nov 2026 10:50:09 -0500 Subject: [PATCH 5/6] release(types): keep 0.24.0 enum member names; note #2487 in the 0.24.1 notes #2487 declared the domain-neutral alias before the v1 member in StepClass, ApproverPolicyRefusal and OutcomeSourceV1, so .name, str() and repr() of the v1 member changed (StepClass.CLINICAL_WRITE.name became HIGH_RISK_WRITE). The v1 member now comes first and the new name is the alias, as in 0.24.0. Values, wire bytes and schemas are unchanged. The 0.24.1 notes now list #2487: the managed_job module and schemas, the domain-neutral aliases and accepted input forms, and that output stays byte-identical to 0.24.0. --- packages/types/CHANGELOG.md | 20 +++++++++++++++++++ packages/types/openadapt_types/approval.py | 17 +++++++++------- .../types/openadapt_types/plain_results.py | 7 ++++--- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index d7c2990f04..d247b57f0a 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -40,6 +40,23 @@ package repairs a Flow 3.4.0 install. refused, because asking would then pay as much as finishing. The default is 0: a contract that doesn't declare it earns nothing for this outcome ([#1824](https://github.com/OpenAdaptAI/OpenAdapt/pull/1824)). +- `openadapt_types.managed_job`: domain-neutral inbox, outbox, tool result + and MCP tool contracts (`openadapt.managed-*/v1`), with four new packaged + schemas. `openadapt_types.clinic_job` stays as the compatibility module for + `openadapt.clinic-*/v1` payloads; its exception and enum names are now + aliases of the `Managed*` ones + ([#2487](https://github.com/OpenAdaptAI/OpenAdapt/pull/2487)). +- Domain-neutral names beside the v1 ones: `StepClass.HIGH_RISK_WRITE` + (wire value `clinical_write`), `ApproverPolicyRefusal.HIGH_RISK_WRITE_NEEDS_OPT_IN` + and `OutcomeSourceV1.MANAGED_TOOL_STATUS`. Approval records and policies + also accept the input keys `high_risk_write`, `high_risk_write_opt_in_sha256` + and step class `high_risk_write`; plain outcome inputs accept + `managed_tool_status`, and `plain_outcome()` takes a + `managed_tool_status=` argument beside `clinic_tool_status=`. Each is + stored and written as its v1 form, so + output is byte-identical to 0.24.0. The packaged schemas, and readers + older than 0.24.1, accept only the v1 forms + ([#2487](https://github.com/OpenAdaptAI/OpenAdapt/pull/2487)). ### Compatibility @@ -49,6 +66,9 @@ package repairs a Flow 3.4.0 install. new `escalated_after_effect` outcome earns 0 under them, since they never declared it. A test checks this against contracts and certificates issued by openadapt-types 0.24.0 from PyPI. +- Every 0.24.0 approval record, approver policy and identity, clinic payload + and plain outcome loads and serializes to the same bytes and digests, and + every 0.24.0 name and enum member still exists under its 0.24.0 name. - `escalated_after_effect_reward` is serialized, and so hashed, only when it differs from 0, so a file 0.24.1 writes for an undeclared contract is one 0.24.0 can read. A contract that declares a non-zero value can't be read diff --git a/packages/types/openadapt_types/approval.py b/packages/types/openadapt_types/approval.py index b0e950ec10..d01c35ebcc 100644 --- a/packages/types/openadapt_types/approval.py +++ b/packages/types/openadapt_types/approval.py @@ -281,11 +281,13 @@ class StepClass(str, Enum): REVERSIBLE = "reversible" CONSEQUENTIAL = "consequential" IRREVERSIBLE = "irreversible" - #: An irreversible, high-risk write to a system of record. - #: Wire value remains ``clinical_write`` in v1 for signed-grant and receipt compatibility. - HIGH_RISK_WRITE = "clinical_write" - #: Legacy alias for ``HIGH_RISK_WRITE``. + #: An irreversible, high-risk write to a system of record. Declared + #: first so the member keeps its 0.24.0 name (``.name``, ``str()``, + #: ``repr()``); the wire value stays ``clinical_write`` in v1 for + #: signed-grant and receipt compatibility. CLINICAL_WRITE = "clinical_write" + #: Domain-neutral alias for ``CLINICAL_WRITE``. + HIGH_RISK_WRITE = "clinical_write" @classmethod def _missing_(cls, value: object) -> Optional["StepClass"]: @@ -305,10 +307,11 @@ class ApproverPolicyRefusal(str, Enum): """Closed reasons a policy refuses an approver.""" KIND_NOT_ALLOWED = "approver_kind_not_allowed" - #: Wire value remains ``clinical_write_needs_opt_in`` in v1 for Flow compatibility. - HIGH_RISK_WRITE_NEEDS_OPT_IN = "clinical_write_needs_opt_in" - #: Legacy alias for ``HIGH_RISK_WRITE_NEEDS_OPT_IN``. + #: Declared first so the member keeps its 0.24.0 name; the wire value + #: stays ``clinical_write_needs_opt_in`` in v1 for Flow compatibility. CLINICAL_WRITE_NEEDS_OPT_IN = "clinical_write_needs_opt_in" + #: Domain-neutral alias for ``CLINICAL_WRITE_NEEDS_OPT_IN``. + HIGH_RISK_WRITE_NEEDS_OPT_IN = "clinical_write_needs_opt_in" @classmethod def _missing_(cls, value: object) -> Optional["ApproverPolicyRefusal"]: diff --git a/packages/types/openadapt_types/plain_results.py b/packages/types/openadapt_types/plain_results.py index a2ed1031fd..f7841edf68 100644 --- a/packages/types/openadapt_types/plain_results.py +++ b/packages/types/openadapt_types/plain_results.py @@ -105,10 +105,11 @@ class OutcomeSourceV1(str, Enum): EXECUTION_OUTCOME = "execution_outcome" AGENT_STATUS = "agent_status" CONNECTOR_STATUS = "connector_status" - #: Domain-neutral alias; v1 wire key remains ``clinic_tool_status`` for - #: compatibility with deployed v1 readers and schemas. - MANAGED_TOOL_STATUS = "clinic_tool_status" + #: Declared first so the member keeps its 0.24.0 name; the v1 wire key + #: stays ``clinic_tool_status`` for deployed v1 readers and schemas. CLINIC_TOOL_STATUS = "clinic_tool_status" + #: Domain-neutral alias for ``CLINIC_TOOL_STATUS``. + MANAGED_TOOL_STATUS = "clinic_tool_status" PROGRAM_TERMINAL_STATE = "program_terminal_state" OVERLAY_PHASE = "overlay_phase" From 93cfc328e18f471b412e4a80db648140d06362ee Mon Sep 17 00:00:00 2001 From: abrichr Date: Sun, 22 Nov 2026 18:13:45 -0500 Subject: [PATCH 6/6] release(types): publish the reviewed content as openadapt-types 0.24.2 0.24.1 was stamped on main by #2543 without this PR's reviewed types code and was never published; that tree breaks 0.24.0 contracts. The reviewed content ships as 0.24.2. Only the version (pyproject, uv.lock) and the changelog change; every other types and verify file is byte-identical to the reviewed 45f0cd5. --- packages/types/CHANGELOG.md | 9 ++++++--- packages/types/pyproject.toml | 2 +- packages/types/uv.lock | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index d247b57f0a..9f79909aa7 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -1,7 +1,10 @@ # CHANGELOG -## v0.24.1 (2026-11-22) +## v0.24.2 (2026-11-22) + +0.24.1 was stamped on main but never published. 0.24.2 is the first +published release with this content, and the version to install. openadapt-flow 3.4.0 imports `openadapt_types.receipt`, which 0.24.0 does not have. This release adds it and the other modules Flow imports on main @@ -55,7 +58,7 @@ package repairs a Flow 3.4.0 install. `managed_tool_status=` argument beside `clinic_tool_status=`. Each is stored and written as its v1 form, so output is byte-identical to 0.24.0. The packaged schemas, and readers - older than 0.24.1, accept only the v1 forms + older than 0.24.2, accept only the v1 forms ([#2487](https://github.com/OpenAdaptAI/OpenAdapt/pull/2487)). ### Compatibility @@ -70,7 +73,7 @@ package repairs a Flow 3.4.0 install. and plain outcome loads and serializes to the same bytes and digests, and every 0.24.0 name and enum member still exists under its 0.24.0 name. - `escalated_after_effect_reward` is serialized, and so hashed, only when it - differs from 0, so a file 0.24.1 writes for an undeclared contract is one + differs from 0, so a file 0.24.2 writes for an undeclared contract is one 0.24.0 can read. A contract that declares a non-zero value can't be read by 0.24.0, which forbids unknown fields. diff --git a/packages/types/pyproject.toml b/packages/types/pyproject.toml index 00ee930196..0b5ae956bc 100644 --- a/packages/types/pyproject.toml +++ b/packages/types/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "openadapt-types" -version = "0.24.1" +version = "0.24.2" description = "Pydantic models for computer-use agents: screen state (ComputerState, UINode), actions (Action), and results (ActionResult)" readme = "README.md" license = "MIT" diff --git a/packages/types/uv.lock b/packages/types/uv.lock index e477b27312..84e833960a 100644 --- a/packages/types/uv.lock +++ b/packages/types/uv.lock @@ -346,7 +346,7 @@ wheels = [ [[package]] name = "openadapt-types" -version = "0.24.1" +version = "0.24.2" source = { editable = "." } dependencies = [ { name = "pydantic" },