(path: &Path, budget: ReconcileEffectBudget)
| 575 | } |
| 576 | |
| 577 | fn open_once(path: &Path, budget: ReconcileEffectBudget) -> Result<Self, RepositoryError> { |
| 578 | if let Some((working_root, canonical, view)) = sandbox::detect_sandbox(path) { |
| 579 | if budget.is_metadata_only() { |
| 580 | database::require_current_database(&Self::canonical_dot_dir(&canonical)?)?; |
| 581 | } |
| 582 | // CB-13D ::24 R1: the sandbox open passes the SAME budget gate |
| 583 | // as the ordinary open — it must not return before the |
| 584 | // recovery fence (a metadata-only sandbox open refuses unsafe |
| 585 | // pending recovery instead of replaying it). |
| 586 | let mut sandbox = Self::open_sandbox(working_root, canonical, &view)?; |
| 587 | let working_copy = sandbox.require_working_copy_id()?; |
| 588 | sandbox.fence_recovery_for_budget(working_copy, budget)?; |
| 589 | return Ok(sandbox); |
| 590 | } |
| 591 | |
| 592 | let mut layout = working_copy::discover_layout(path)?; |
| 593 | let root = layout.working_root.clone(); |
| 594 | let dot_dir = layout.common_dot_dir.clone(); |
| 595 | |
| 596 | // PATH_CLAIMS migration still needs a view name. Prefer an existing |
| 597 | // working-copy record; consult legacy compatibility files only when no |
| 598 | // record owns this canonical location yet. |
| 599 | let legacy_view = |
| 600 | Self::read_legacy_current_view(&layout.working_copy_dot_dir, &layout.common_dot_dir)?; |
| 601 | |
| 602 | // Legacy consolidation validates capabilities before moving files; |
| 603 | // Pristine::open repeats the check before additive table initialization. |
| 604 | // Pointer creation, path-claim migration, and recovery remain after |
| 605 | // capability validation. |
| 606 | let pristine_path = if budget.is_metadata_only() { |
| 607 | database::require_current_database(&dot_dir)? |
| 608 | } else { |
| 609 | ensure_database(&dot_dir)? |
| 610 | }; |
| 611 | let pristine = Pristine::open(&pristine_path).map_err(RepositoryError::from)?; |
| 612 | |
| 613 | working_copy::ensure_repository_pointer(&layout)?; |
| 614 | layout.pointer_needs_write = false; |
| 615 | let change_store = ChangeStore::new(dot_dir.join("changes"), DEFAULT_CACHE_CAPACITY) |
| 616 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 617 | let migration_view = |
| 618 | working_copy::registered_view_name(&pristine, &layout)?.unwrap_or(legacy_view); |
| 619 | let pristine = migration::migrate_path_claims_if_required( |
| 620 | &pristine_path, |
| 621 | pristine, |
| 622 | &change_store, |
| 623 | &migration_view, |
| 624 | )?; |
| 625 | let (working_copy_id, current_view) = |
| 626 | working_copy::migrate_identity(&pristine, &layout, &migration_view)?; |
| 627 | let pristine = Arc::new(pristine); |
| 628 | |
| 629 | let mut repository = Self { |
| 630 | root, |
| 631 | dot_dir, |
| 632 | current_view, |
| 633 | pristine, |
| 634 | change_store, |
nothing calls this directly
no test coverage detected