Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion packages/flow/tests/test_one_ladder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"),
Expand Down Expand Up @@ -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"
)
4 changes: 4 additions & 0 deletions packages/types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
9 changes: 8 additions & 1 deletion packages/types/openadapt_types/check_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -242,20 +246,23 @@ 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",
"owned_connection",
]
BASES: tuple[Basis, ...] = (
"separate_session",
"fresh_reload",
"system_api",
"activity_log",
"db_frame",
"owned_connection",
)
_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,
Expand Down
Loading