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
21 changes: 18 additions & 3 deletions packages/flow/openadapt_flow/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,18 @@ def _undo_run_target_problem(args: argparse.Namespace, workflow) -> Optional[str
)


def _print_terminal_receipt(
run_dir: Path, report, *, require_opt_in: bool = False
) -> None:
from openadapt_flow.receipt_record import receipt_after_run

note = receipt_after_run(
run_dir, require_opt_in=require_opt_in, expected_report=report
)
if note:
print(note, file=sys.stderr)


def _finish_replay(
run_dir: Path,
report,
Expand Down Expand Up @@ -1176,6 +1188,8 @@ def _finish_replay(
print("\n" + "\n".join(rolled))
_maybe_report_break(run_dir, report)
_maybe_report_run(run_dir, report, args, backend_kind=backend_kind)
if args is not None:
_print_terminal_receipt(run_dir, report)
_maybe_attest_run(run_dir, report, args)
if getattr(report, "execution_profile", None) in {"standard", "regulated"}:
return 0 if outcome == "VERIFIED" else 1
Expand Down Expand Up @@ -5176,6 +5190,7 @@ def _resume_with(backend: "Backend") -> "RunReport":
backend_kind=_report_backend_kind(backend_cfg.kind),
)
_maybe_attest_run(run_dir, report, args)
_print_terminal_receipt(run_dir, report, require_opt_in=True)
if getattr(report, "execution_profile", None) in {"standard", "regulated"}:
return 0 if outcome == "VERIFIED" else 1
return 0 if report.success else 1
Expand Down Expand Up @@ -14276,12 +14291,12 @@ def main(
args._record_check_proof_source = record_check_proof_source
code = args.func(args)
if getattr(args, "command", None) in ("run", "replay"):
# The run's receipt, and the older offline Seal for one release.
# Neither changes the run's exit code.
# Terminal handlers sign receipts. Keep the old Seal here for one release.
from openadapt_flow.receipt_record import after_run_notes

run_dir = getattr(args, "run_dir", None)
for note in after_run_notes(Path(run_dir) if run_dir else None):
folder = Path(run_dir) if run_dir else None
for note in after_run_notes(folder, include_receipt=False):
print(note, file=sys.stderr)
return code
except (sealed_set.SealedSetError, at_rest.AtRestRefused) as exc:
Expand Down
11 changes: 8 additions & 3 deletions packages/flow/openadapt_flow/cli_worklist_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def run_item(self, idx: int, row: dict[str, Any], item_dir: Path) -> ItemRun:
prepare_ws_guard(self._page)
self._page.goto(self.entry_url)
report = self.run_item_on_page(self._page, idx, row, item_dir, self._pipeline)
return _item_run(report, self._pipeline)
return _item_run(report, self._pipeline, item_dir)

def clean_after_halt(self, cleanup_dir: Path) -> Any:
if self.clean is None:
Expand Down Expand Up @@ -346,18 +346,23 @@ def run_item(self, idx: int, row: dict[str, Any], item_dir: Path) -> ItemRun:
report = self.run_item_on_backend(
self.backend, idx, row, item_dir, self._pipeline
)
return _item_run(report, self._pipeline)
return _item_run(report, self._pipeline, item_dir)

def close(self) -> None:
if self._pipeline is not None:
self._pipeline.close()


def _item_run(report: Any, pipeline: Optional[ReadbackPipeline]) -> ItemRun:
def _item_run(
report: Any, pipeline: Optional[ReadbackPipeline], item_dir: Path
) -> ItemRun:
state = item_state_from_report(report)
detail = item_detail_from_report(report)
handoff = pipeline.take() if pipeline is not None else None
if handoff is None:
from openadapt_flow.receipt_record import receipt_after_run

receipt_after_run(item_dir, require_opt_in=True, expected_report=report)
if pipeline is not None and pipeline.inline_reason:
detail["readback"] = f"inline ({pipeline.inline_reason})"
return ItemRun(state=state, detail=detail)
Expand Down
Loading
Loading