You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes main CI failure (flow core unit (shard 4/4): test_hooks_e2e.py::test_claude_code_allowed_blocked_and_uncertain and test_codex_asks_by_denying_until_a_person_approves) introduced when #2410 merged right after #2411.
receipt_record.build_statement() now validates each step via StepResult.model_validate(), requires change_ledger, and requires sha256:-prefixed effect_contract_hashes + effect_evidence + valid EffectFieldCheck dicts. hooks/engine.py was still emitting pre-#2410 step dicts, causing write_receipt_record() to fail with ReceiptRecordError: invalid_write_evidence and leave no receipt.json.
Changes
packages/flow/openadapt_flow/hooks/engine.py: emit change_ledger: [], step_id, intent, sha256:-prefixed effect_contract_hashes, effect_evidence when read-back settled, and a valid EffectFieldCheck dict when delta == "held".
Unique delta versus parent e754d569 is the two-file hooks receipt fix. I reviewed that delta, not the already-merged trees on this branch.
The StepResult.model_validate failure is addressed. Hook reports now include required step_id and intent, an empty change_ledger, effect_contract_hashes with the sha256: prefix the evidence schema requires, effect_evidence when a write was sent and judged VERIFIED or REFUTED, and EffectFieldCheck objects instead of the bare "delta" string. write_receipt_record can therefore emit receipt.json again after #2410 landed on main.
The new fields are consistent with the existing hooks e2e contract, not a strength upgrade invented here. verification_tier: 1 is system-of-record, which matches verify_write (it reads the system of record against the pre-write snapshot) and the already-asserted VERIFIED line (check: confirmed, strength: read_back). effect_field_checks with matched: True is emitted only when result.checked.delta == "held" (the verifier's term for "the declared records were written with the declared values"). The failed-read-back UNCERTAIN path still has no evidence and no field checks; not_checked correctly gains field_values alongside approved_unverified and postconditions. BLOCKED still omits the sent-write effect block.
Residual, not a blocker: REFUTED evidence always sets observed_effect to "absent". That does not let a receipt line become confirmed, but it can over-state absence when the verifier refuted a present-but-wrong record. Expected and observed field values are also omitted from the new EffectFieldCheck (both are optional).
This source review traced hooks/engine.py, receipt_record._line / StepResult validation, verify_write, and the e2e assertions. I did not rerun pytest or CI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
mainCI failure (flow core unit (shard 4/4):test_hooks_e2e.py::test_claude_code_allowed_blocked_and_uncertainandtest_codex_asks_by_denying_until_a_person_approves) introduced when #2410 merged right after #2411.receipt_record.build_statement()now validates each step viaStepResult.model_validate(), requireschange_ledger, and requiressha256:-prefixedeffect_contract_hashes+effect_evidence+ validEffectFieldCheckdicts.hooks/engine.pywas still emitting pre-#2410 step dicts, causingwrite_receipt_record()to fail withReceiptRecordError: invalid_write_evidenceand leaveno receipt.json.Changes
packages/flow/openadapt_flow/hooks/engine.py: emitchange_ledger: [],step_id,intent,sha256:-prefixedeffect_contract_hashes,effect_evidencewhen read-back settled, and a validEffectFieldCheckdict whendelta == "held".packages/flow/tests/test_hooks_e2e.py: expectfield_valuesinnot_checkedon the failed-readback UNCERTAIN path (matching Receipts: counterparty confirmations in record/run/v1 #2410's receipt line contract).Verification
ruff check openadapt_flow/hooks/engine.py— passedruff format --check openadapt_flow/hooks/engine.py tests/test_hooks_e2e.py— passedmypy openadapt_flow/hooks/engine.py— 0 issuespytest -q tests/test_hooks_e2e.py— 4 passedGenerality & Durability
StepResult/EffectFieldCheckfields for any declared system.hooksreceipt producer with Receipts: counterparty confirmations in record/run/v1 #2410's sharedStepResultvalidation contract (matching the sibling fix in feat(plan, proxy): dry-run diff, idempotent apply, verified undo and receipts for agent writes to external systems #2428 fortxplan).test_hooks_e2e.pysuite.