luplo.core.import_pipeline.finalize¶
Phase 3 — receive agent results, validate, write items.
Defense-in-depth strips code blocks even if the agent followed the rule; cross-project guard ensures bundle_id belongs to the current project.
Functions¶
|
Apply agent results to the bundle's work_unit and return a summary. |
Module Contents¶
- async luplo.core.import_pipeline.finalize.finalize_import(*, backend: luplo.core.backend.protocol.Backend, project_id: str, actor_id: str, results: luplo.core.import_pipeline.results.ImportResults) dict[str, Any]¶
Apply agent results to the bundle’s work_unit and return a summary.
Validates that
results.bundle_idreferences an in-progress import work unit inproject_id, defensively strips any fenced code blocks from each item body, and persists eachResultItemas a luplo item attached to the bundle’s work unit.- Parameters:
backend – The luplo
Backend(Local or Remote).project_id – Project owning the bundle; cross-project guard rejects mismatches.
actor_id – Caller’s actor UUID; recorded as the item author and as the closer if
results.close_work_unitis set.results – Envelope produced by the agent (bundle id + result items).
- Returns:
A summary dict with keys
status,bundle_id,items_created, andwarnings(a list of human-readable strings, possibly empty).- Raises:
ValueError – When the bundle id is unknown, belongs to a different project, or is not in the
in_progressstate.