diff --git a/packages/flow/tests/test_one_ladder.py b/packages/flow/tests/test_one_ladder.py index e064ad8f8b..8c1981b624 100644 --- a/packages/flow/tests/test_one_ladder.py +++ b/packages/flow/tests/test_one_ladder.py @@ -71,7 +71,8 @@ def test_path_tables_are_derived_from_check_level() -> None: def test_each_basis_names_one_level() -> None: assert level_for_basis("separate_session") is CheckLevel.SEPARATE_SESSION - for basis in BASES[1:]: + assert level_for_basis("fresh_reload") is CheckLevel.SEPARATE_SESSION + for basis in BASES[2:]: assert level_for_basis(basis) is CheckLevel.SYSTEM_OF_RECORD with pytest.raises(ValueError): level_for_basis("screen") @@ -85,6 +86,9 @@ def test_each_basis_names_one_level() -> None: (CheckLevel.SYSTEM_OF_RECORD, "system_api", True, False, "VERIFIED"), (CheckLevel.SYSTEM_OF_RECORD, "activity_log", True, False, "VERIFIED"), (CheckLevel.SEPARATE_SESSION, "separate_session", True, False, "VERIFIED"), + # A proven fresh reload (cache bypassed, request kept) is level 3. + (CheckLevel.SEPARATE_SESSION, "fresh_reload", True, False, "VERIFIED"), + (CheckLevel.SEPARATE_SESSION, "fresh_reload", False, False, "RECORDED"), # No basis: a level 3 or 4 read is never VERIFIED. (CheckLevel.SYSTEM_OF_RECORD, None, True, False, "RECORDED"), (CheckLevel.REOPENED, None, True, False, "SHOWN"), @@ -412,3 +416,22 @@ def test_stopped_run_receipt_is_recorded() -> None: assert predicate["outcome"] == "STOPPED" assert predicate["evidence_scope"]["word"] == "RECORDED" assert "basis" not in predicate["evidence_scope"] + + +def test_a_fresh_reload_is_never_level_2_or_4() -> None: + # A reopen without the reload proof has no basis and stays SHOWN; the + # reload basis can't be claimed for a reopen or a system-of-record read. + assert outcome_word(CheckLevel.REOPENED, None) == "SHOWN" + with pytest.raises(ValueError): + outcome_word(CheckLevel.REOPENED, "fresh_reload") + with pytest.raises(ValueError): + outcome_word(CheckLevel.SYSTEM_OF_RECORD, "fresh_reload") + # A run that requires a system-of-record read doesn't accept it. + assert ( + outcome_word( + CheckLevel.SEPARATE_SESSION, + "fresh_reload", + minimum=CheckLevel.SYSTEM_OF_RECORD, + ) + == "RECORDED" + ) diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index b832b3076f..5dd8d6485f 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,10 @@ ## Unreleased +- `check_level`: a `fresh_reload` basis at level 3. It is a new navigation in + the acting session that is proven to have fetched from the server (cache + bypassed, the request kept as evidence). With it a level 3 check is + `VERIFIED`; a reopen without that proof stays level 2, `SHOWN`. - Test vectors only, no code change: six `record/run/v1` vectors (`evidence-scope-null`, `evidence-scope-null-basis`, `evidence-scope-null-read-back-at`, `evidence-scope-null-recheck-window`, diff --git a/packages/types/openadapt_types/check_level.py b/packages/types/openadapt_types/check_level.py index fc594ab91d..7600808b43 100644 --- a/packages/types/openadapt_types/check_level.py +++ b/packages/types/openadapt_types/check_level.py @@ -41,7 +41,11 @@ from the level and the basis (who produced the evidence, not its type): - ``VERIFIED``: levels 3 and 4 only, always with a basis. Level 3 has basis - ``separate_session``. Level 4 has ``system_api`` (a cache-bypassed, + ``separate_session`` or ``fresh_reload`` (a new navigation in the acting + session that is proven to have fetched from the server: the request was + sent with the cache bypassed and the response shows no cache, with the + request kept as evidence). A reopen without that proof is level 2, + ``SHOWN``. Level 4 has ``system_api`` (a cache-bypassed, version-checked API read), ``activity_log`` (the system's own log), ``db_frame`` (a database read of the record and its frame) or ``owned_connection`` (a connection the verifier owns, such as its own SQL @@ -242,6 +246,7 @@ def to_effect_strength(level: CheckLevel) -> Optional[str]: #: Who produced the evidence for a ``VERIFIED`` read-back. Basis = Literal[ "separate_session", + "fresh_reload", "system_api", "activity_log", "db_frame", @@ -249,6 +254,7 @@ def to_effect_strength(level: CheckLevel) -> Optional[str]: ] BASES: tuple[Basis, ...] = ( "separate_session", + "fresh_reload", "system_api", "activity_log", "db_frame", @@ -256,6 +262,7 @@ def to_effect_strength(level: CheckLevel) -> Optional[str]: ) _BASIS_LEVEL: dict[str, CheckLevel] = { "separate_session": CheckLevel.SEPARATE_SESSION, + "fresh_reload": CheckLevel.SEPARATE_SESSION, "system_api": CheckLevel.SYSTEM_OF_RECORD, "activity_log": CheckLevel.SYSTEM_OF_RECORD, "db_frame": CheckLevel.SYSTEM_OF_RECORD,