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
29 changes: 27 additions & 2 deletions packages/flow/openadapt_flow/hooks/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,19 @@ def _run_folder(
effect = {"VERIFIED": True, "REFUTED": False}.get(label)
sent = label != "BLOCKED"
name = ".".join(x for x in (system, write or "undeclared") if x)
contract_hash = f"sha256:{_sha(contract or 'undeclared')}"
evidence: list[dict[str, Any]] = []
if sent and effect is not None:
evidence.append(
{
"effect_contract_hash": contract_hash,
"substrate": "api",
"initial_verdict": "confirmed" if effect else "refuted",
"final_verdict": "confirmed" if effect else "refuted",
"observed_effect": "present" if effect else "absent",
"verification_tier": 1,
}
)
report: dict[str, Any] = {
"schema_version": REPORT_SCHEMA,
"workflow_name": name[:48],
Expand All @@ -528,8 +541,11 @@ def _run_folder(
"system": system,
"write": write,
"hold_sha256": digest,
"change_ledger": [],
"results": [
{
"step_id": write_id,
"intent": f"hook {name}",
"ok": label == "VERIFIED",
"actuation": "api",
**(
Expand All @@ -539,15 +555,24 @@ def _run_folder(
# says effect_not_declared. A declared write whose
# read-back didn't settle says approved_unverified
# (record/run/v1 has no read-back-failed code).
"effect_contract_hashes": [_sha(contract or "undeclared")],
"effect_contract_hashes": [contract_hash],
"effect_evidence": evidence,
"effect_approved_unverified": bool(contract)
and effect is None,
}
if sent
else {}
),
**(
{"effect_field_checks": ["delta"]}
{
"effect_field_checks": [
{
"field": "delta",
"matched": True,
"verification_tier": 1,
}
]
}
if result is not None
and (result.checked or {}).get("delta") == "held"
else {}
Expand Down
6 changes: 5 additions & 1 deletion packages/flow/tests/test_hooks_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,11 @@ def test_claude_code_allowed_blocked_and_uncertain(project: Path, api: str) -> N
assert verified.ok and verified.outcome == "UNKNOWN"
line = verified.statement["predicate"]["lines"][0]
assert line["check"] == "not_checked" and line["strength"] == "none"
assert line["not_checked"] == ["approved_unverified", "postconditions"]
assert line["not_checked"] == [
"approved_unverified",
"field_values",
"postconditions",
]
assert verified.statement["predicate"]["checks"]["effects"] == {
"required": 1,
"confirmed": 0,
Expand Down
Loading