Durably persist one incomplete refusal on the session (first writer wins) and index it in the repository session ledger (review R3: the JSON refusal is the crash-safe minimum; the index is best-effort). Returns the authoritative persisted refusal.
(
&self,
session: &mut AgentSession,
incomplete: &IncompleteSession,
)
| 728 | /// JSON refusal is the crash-safe minimum; the index is best-effort). |
| 729 | /// Returns the authoritative persisted refusal. |
| 730 | pub(crate) fn persist_incomplete_refusal( |
| 731 | &self, |
| 732 | session: &mut AgentSession, |
| 733 | incomplete: &IncompleteSession, |
| 734 | ) -> IncompleteSession { |
| 735 | let persisted = session.mark_incomplete(incomplete.clone()).clone(); |
| 736 | match atomic_repository::Repository::open_existing(&self.repo_root).and_then(|repo| { |
| 737 | repo.mark_session_incomplete( |
| 738 | &session.session_id, |
| 739 | Some(session.view_name.clone()), |
| 740 | session.parent_view.clone(), |
| 741 | &persisted, |
| 742 | ) |
| 743 | }) { |
| 744 | Ok(indexed) => { |
| 745 | if session.incomplete() != Some(&indexed) { |
| 746 | session.status = SessionStatus::Incomplete(indexed); |
| 747 | } |
| 748 | } |
| 749 | Err(error) => { |
| 750 | log::warn!( |
| 751 | "Could not index incomplete agent session {}: {}; \ |
| 752 | JSON refusal remains durable", |
| 753 | session.session_id, |
| 754 | error |
| 755 | ); |
| 756 | } |
| 757 | } |
| 758 | session.incomplete().cloned().unwrap_or(persisted) |
| 759 | } |
| 760 | |
| 761 | // ── Main dispatch ────────────────────────────────────────────── |
| 762 |
no test coverage detected