(
root: &Path,
budget: ReconcileEffectBudget,
notice: Option<&WatchNoticeSink<'_>>,
)
| 945 | |
| 946 | #[tracing::instrument(name = "reconcile", skip_all, fields(budget = ?budget))] |
| 947 | pub(crate) fn reconcile_transaction_budgeted( |
| 948 | root: &Path, |
| 949 | budget: ReconcileEffectBudget, |
| 950 | notice: Option<&WatchNoticeSink<'_>>, |
| 951 | ) -> CliResult<()> { |
| 952 | // The Git-to-Atomic arm may create a detached view before invoking the |
| 953 | // importer. Until span-aware incremental synthesis exists, refuse before |
| 954 | // opening writable state or appending reconciliation effects. Keep the |
| 955 | // lock for the whole boundary so span capability cannot race this check. |
| 956 | let _span_preflight = |
| 957 | Repository::try_lock_git_import_without_span(root, budget.is_metadata_only()) |
| 958 | .map_err(|error| git_error(format!("Git shim preflight refused: {error}")))?; |
| 959 | let emit_notice = |kind: WatchNoticeKind, detail: &str| { |
| 960 | if let Some(notice) = notice { |
| 961 | notice(kind, detail); |
| 962 | } |
| 963 | }; |
| 964 | // CB-13C observability: one journal per reconcile run; every terminal |
| 965 | // outcome below records a stable `reconcile` event (review R5: including |
| 966 | // the entry/observation failures that previously bypassed the sink). |
| 967 | // Emission is lossy; reconcile is an explicit shim command boundary. |
| 968 | let journal = BridgeEventJournal::new( |
| 969 | &Repository::canonical_dot_dir(root).map_err(CliError::from)?, |
| 970 | None, |
| 971 | ); |
| 972 | let refused_run = |direction: ReconcileDirectionCode, refusal_class: RefusalClass| { |
| 973 | journal.emit_lossy(BridgeEventKind::Reconcile { |
| 974 | direction, |
| 975 | outcome: EventOutcome::Refused, |
| 976 | refusal_class: Some(refusal_class), |
| 977 | }); |
| 978 | }; |
| 979 | |
| 980 | // Entry boundary. Both budgets enter the same shared workspace |
| 981 | // transaction path the reconcile command uses (RFC §11.2 rule 3: the |
| 982 | // watch daemon has no entry/mutation logic of its own). That boundary |
| 983 | // tolerates an unanchored baseline — a moved HEAD is reconciled by the |
| 984 | // §7.3 import path below, which for the daemon is exactly the |
| 985 | // RFC-sanctioned metadata-only ImportGitHead work (rule 4) — while |
| 986 | // still refusing Git-owned sequence operations, index locks, and |
| 987 | // diverged operation heads. The budgets differ in the effects granted: |
| 988 | // the metadata-only budget refuses bound HEAD adoption (shelf/WIP/ref |
| 989 | // effects), refuses pending recovery work at the writable open, and |
| 990 | // revalidates Git quiescence under the entry lease, so export-classified |
| 991 | // and effect-bearing runs become notices (review R1/R2). |
| 992 | let mut repo = match Repository::open_with_budget(root, budget) { |
| 993 | Ok(repo) => repo, |
| 994 | Err(atomic_repository::RepositoryError::ReactiveDeferred { detail }) => { |
| 995 | // Review R1: the writable open refused pending recovery work |
| 996 | // before any of it executed; surface the deferral instead of |
| 997 | // acting. |
| 998 | refused_run( |
| 999 | ReconcileDirectionCode::Unknown, |
| 1000 | RefusalClass::MetadataOnlyRecoveryDeferred, |
| 1001 | ); |
| 1002 | emit_notice( |
| 1003 | WatchNoticeKind::UnsafeState, |
| 1004 | &format!("reactive reconcile deferred: {detail}"), |
no test coverage detected