Liking cljdoc? Tell your friends :D

L3.3c-C2 CHAR-SIDE DELETION INVENTORY — FINAL REPORT

Ground Truth Basis

  • Examined: git diff (all uncommitted changes)
  • Examined: git status (staged deletions: mutation_core.rs, prefix_helpers.rs)
  • Examined: rg scans across all src/persistent_artrie_char/
  • Examined: Execution plan at docs/design/slice3-l33c-execution-plan-2026-06-09.md
  • Date: 2026-06-09 (session 14:48—current)

SUMMARY: WHAT'S BEEN DELETED vs WHAT REMAINS

✓ SUCCESSFULLY DELETED:

  1. mod.rs:425self.root: RwLock<CharTrieRoot<V>> field
  2. mod.rs:1666-1707 — owned checkpoint block (capture_snapshot call)
  3. mod.rs:578 — Debug impl .field("root", ...)
  4. mmap_ctor.rs:6 sitesroot: RwLock::new(CharTrieRoot::Empty) from constructors
  5. io_uring_ctor.rs:2 sites — same root field initialization
  6. f5_loader.rs:~85*self.root.get_mut() = CharTrieRoot::Empty;
  7. query_api.rs:~44owned_try_contains()
  8. query_api.rs:~68owned_get()
  9. query_api.rs:~101owned_try_get()
  10. prefix_api.rs:~22-144owned_iter_prefix(), owned_iter_prefix_with_values(), owned-tree branches
  11. atomic_ops.rs:~117try_increment_impl_no_wal()
  12. persist.rs:~244persist_to_disk()
  13. persist.rs:~254persist_to_disk_tracked()
  14. persist.rs:~275capture_snapshot() (123 LOC)
  15. mutation_core.rs — ENTIRE FILE (STAGED FOR DELETION)
  16. prefix_helpers.rs — ENTIRE FILE (STAGED FOR DELETION)
  17. mod.rs — module declarations for mutation_core and prefix_helpers

✗ STILL LIVE (BLOCKERS FOR C2):

1. mod.rs::from_trie (line 983)

  • Status: LIVE, MUST DELETE
  • Called by: SharedCharARTrie::root() (mod.rs:1371)
  • Code:
    fn from_trie<S: BlockStorage>(trie: &PersistentARTrieChar<V, S>) -> Self {
        let faulter: Option<*const dyn CharNodeFaulter<V>> = 
            Some(trie as &dyn CharNodeFaulter<V> as *const dyn CharNodeFaulter<V>);
        let root_node_ptr: Option<*const CharTrieNodeInner<V>> = {
            let guard = trie.root.read();  // ← LINE 999: ERROR — field deleted
            match &*guard {
                types::CharTrieRoot::Empty => None,
                types::CharTrieRoot::Node(node) => Some(node.as_ref() as *const _),
            }
        };
        ...
    }
    
  • Action: Delete from_trie; collapse SharedCharARTrie::root() to overlay-only (§2.1)

2. mod.rs::from_ptr (line 1030)

  • Status: LIVE, called by transition() and edges() (lines 1179, 1185, 1217, 1245+)
  • Used by: Owned node traversal
  • Action: Delete when owned traversal is removed (lines 1164-1187 of transition)

3. mod.rs::CharWalkGuard (line 876)

  • Status: LIVE, created at mod.rs:1364
  • Purpose: Pins epoch + keeps trie alive during owned walk
  • Created in: SharedCharARTrie::root() (now deleted owned arm)
  • Action: Delete when from_trie is deleted

4. mod.rs::PersistentARTrieCharNode owned fields (lines 910-942)

  • Status: PARTIALLY LIVE (overlay arm present; owned arm branches still active)
  • Fields:
    • node: Option<*const CharTrieNodeInner<V>> — owned arm (LIVE in transition/edges)
    • is_root: bool — owned arm (LIVE in transition/edges line 1164)
    • root_empty: bool — owned arm (LIVE in transition/edges line 1164, 1206)
    • faulter: Option<*const dyn CharNodeFaulter<V>> — owned arm (LIVE in transition line 1170+)
    • pin: Option<Arc<CharWalkGuard>> — used by both arms (KEEP)
  • Action: Delete owned-arm branches in transition(), edges(), Debug impl; keep overlay arm

5. types.rs::CharTrieRoot (line 753)

  • Status: LIVE (enum definition still present)
  • Variants: Empty, Node(Box<CharTrieNodeInner<V>>)
  • Used by: from_trie() match (line 1000-1002)
  • Action: DELETE in C2

6. types.rs::get_or_create_child (line 680) / remove_child (line 717)

  • Status: ORPHANED (called by mutation_core, which is staged for deletion)
  • Callers: None outside mutation_core (verified via rg)
  • Action: DELETE in C2 (auto-flagged as dead code by compiler)

7. disk_io.rs::load_root_from_disk (line 36)

  • Status: LIVE (function still present, NOT in diff)
  • Called by: mmap_ctor.rs, io_uring_ctor.rs (reopen path — owned loader)
  • Comment: plan §4 calls for deletion, but diff shows NO change
  • Action: DELETE in C2 (BLOCKER#2)

8. disk_io.rs::resolve_swizzled_ptr (line 1123) / _mut (line 1213)

  • Status: LIVE (functions still present)
  • Used by: owned node traversal (from_ptr → get_child_lazy_u32 → mod.rs line 849)
  • UNSAFE rows: 4-10 (per plan §6)
  • Action: DELETE in C2 (BLOCKER#2)

9. disk_io.rs::load_char_node_from_disk (line 401)

  • Status: LIVE (recursive loader)
  • Called by: mutation_core (now staged for deletion)
  • Action: DELETE in C2 (orphaned)

10. disk_io.rs::load_char_node_from_disk_iterative (line 744)

  • Status: LIVE
  • Called by: load_root_from_disk (to be deleted)
  • Action: DELETE in C2 (orphaned)

11. disk_io.rs::load_char_node_from_disk_with_depth (line 852)

  • Status: LIVE
  • Called by: load_root_from_disk (to be deleted)
  • Action: DELETE in C2 (orphaned)

12. persist.rs::WHITE-BOX TESTS using owned_try_contains

  • Status: LIVE (test code still calls deleted function)
  • Tests:
    • char_append_term_by_term_with_owned_checks (lines ~2400-2580)
    • Calls: trie.owned_try_contains(t) (lines 2420, 2522, 2523, 2560)
  • Action: DELETE/UPDATE test in C2 (BLOCKER#3)

13. mod.rs::transition() (line 1155)

  • Status: LIVE (DictionaryNode impl)
  • Content: Has owned arm branches (lines 1164-1187)
  • Owned code:
    if self.root_empty {
        return None;
    }
    let ptr = self.node?;
    let node_ref = unsafe { &*ptr };
    match self.faulter { ... }  // fault child or resident lookup
    
  • Action: DELETE owned branches; keep overlay arm (lines 1159-1162)

14. mod.rs::edges() (line 1189)

  • Status: LIVE (DictionaryNode impl)
  • Content: Has owned arm branches (lines 1204-1245+)
  • Owned code: Similar to transition() — faults children from owned node
  • Action: DELETE owned branches; keep overlay arm (lines 1193-1203)

15. SharedCharARTrie::root() (line 1355)

  • Status: LIVE
  • Code:
    pub fn root(&self) -> PersistentARTrieCharNode<V> {
        if self.route_overlay() {
            return Self::overlay_root(...);  // ← OVERLAY ARM
        }
        // OWNED ARM (below) — MUST DELETE
        let guard = self.read();
        let pin = Arc::new(CharWalkGuard { ... });
        let mut node = PersistentARTrieCharNode::from_trie(&guard);
        node.pin = Some(Arc::clone(&pin));
        node
    }
    
  • Action: DELETE owned arm; return only overlay arm

CRITICAL BLOCKERS FOR C2

BLOCKER#1 — Recovery Applier (§8.2 of plan)

Status: ✓ SAFE TO DELETE

  • apply_core_recovered_operation_no_wal is NOT DEFINED in char crate (only a comment at mmap_ctor.rs:1101)
  • Comment references mutation_core (which is deleted)
  • Verdict: Recovery applier is already removed/routed elsewhere; try_increment_impl_no_wal deletion is SAFE

BLOCKER#2 — Owned loaders (disk_io.rs)

Status: ✗ NOT YET ADDRESSED

  • Must delete:
    • load_root_from_disk (line 36)
    • resolve_swizzled_ptr* (lines 1123, 1213) — UNSAFE rows 4-10
    • load_char_node_from_disk* (lines 401, 744, 852) — all except lazy (508)
  • Impact: Plan §4 BLOCKER#4 byte ctor fallback depends on char being clean first
  • Action: Must complete in C2

BLOCKER#3 — White-box test cleanup

Status: ✗ NOT YET ADDRESSED

  • Tests call trie.owned_try_contains() (deleted from query_api.rs)
  • Tests: persist.rs lines 2420, 2522, 2523, 2560
  • Action: DELETE/UPDATE these tests in C2

BLOCKER#4 — Module import verification

Status: ✓ VERIFIED

  • No remaining imports of mutation_core or prefix_helpers
  • All module declarations deleted from mod.rs
  • Verdict: SAFE — no orphaned imports

UNSAFE INVENTORY DELTA (§6 of plan)

Rows to PRUNE from UNSAFE_INVENTORY.tsv:

  • Row 4-5: char-disk-swizzled-pointer-resolution
  • Row 6-8: char-disk-node-map-resolution
  • Row 9-10: char-disk-box-ownership
  • Row 11-12: char-walk-guard-faulter-traversal
  • Row 13-16: char-public-node-traversal
  • Row 19: char-mutation-core-traversal
  • Row 20: char-mutation-core-unique-borrow

Rows to KEEP:

  • Row 1-3: char-disk-page-alignment etc.
  • Row 17-18: char-public-node-send-sync
  • Row 21+: later rows

Contract tags to DELETE:

  • All 7 matching tags from UNSAFE_CONTRACTS.tsv

VERIFICATION CHECKLIST FOR C2 AUTHOR

Before committing C2:

  1. [ ] Collapse SharedCharARTrie::root() to overlay-only (delete from_trie/CharWalkGuard call)
  2. [ ] Delete from_trie, from_ptr, CharWalkGuard
  3. [ ] Delete owned-arm branches in transition() and edges()
  4. [ ] Delete CharTrieRoot enum
  5. [ ] Delete get_or_create_child, remove_child from types.rs
  6. [ ] Delete orphaned loaders: load_root_from_disk, resolve_swizzled_ptr*, load_char_node_from_disk* (except lazy)
  7. [ ] Delete/update white-box tests using owned_try_contains (persist.rs ~2420-2560)
  8. [ ] Remove owned-field branches from PersistentARTrieCharNode (Debug impl, etc.)
  9. [ ] Prune UNSAFE_INVENTORY.tsv rows 4-16, 19-20
  10. [ ] Delete 7 matching contract tags from UNSAFE_CONTRACTS.tsv
  11. [ ] Run cargo check --all-features — verify: ZERO errors, dead-code warnings match KEEP list
  12. [ ] Run nextest run — all tests pass
  13. [ ] Run verify-formal-correspondence.sh — ZERO errors
  14. [ ] Run verify-unsafe-boundary-inventory.sh — DELTA matches rows 4-16,19-20 + 7 tags

THE mod.rs:999 ERROR — ROOT CAUSE

Location: from_trie function, line 999 Error: trie.root — field does not exist

Cascade:

  • Field root deleted from struct definition (mod.rs:425)
  • But function from_trie (line 983) still tries to read it
  • from_trie called by SharedCharARTrie::root() (line 1371)
  • SharedCharARTrie::root() is the public API for creating root handles

Fix (§2.1 of plan):

  1. Collapse SharedCharARTrie::root() to return overlay node only
  2. Delete from_trie, from_ptr, CharWalkGuard
  3. Owned arm readers/traversal methods become compile errors
  4. Each error guides incremental cleanup of remaining owned branches

DETAILED REMAINING WORK

Phase 2.1: Collapse public root() (highest priority — unblocks rest)

  • File: mod.rs (line 1355-1375)
  • Action: Delete entire owned arm; keep overlay arm
  • After: from_trie, from_ptr, CharWalkGuard become unused → dead-code warnings

Phase 2.2: Delete owned traversal methods

  • File: mod.rs (transition/edges)
  • Lines: 1155-1245
  • Action: Delete owned-arm branches (lines 1164-1187 in transition; 1204-1245 in edges)
  • Keep: Overlay-arm branches (lines 1159-1162, 1193-1203)

Phase 2.3: Delete orphaned loaders

  • File: disk_io.rs
  • Delete: load_root_from_disk (36), resolve_swizzled_ptr* (1123, 1213), load_char_node_from_disk* (401, 744, 852)
  • Keep: load_char_node_from_disk_lazy (508), load_overlay_node_from_disk (625)

Phase 2.4: Delete owned-only types

  • File: types.rs
  • Delete: CharTrieRoot (753), get_or_create_child (680), remove_child (717)

Phase 2.5: Cleanup test code

  • File: persist.rs
  • Delete: Test char_append_term_by_term_with_owned_checks (or rewrite for overlay)
  • Lines: ~2400-2580

Phase 2.6: UNSAFE inventory

  • Files: formal-verification/UNSAFE_INVENTORY.tsv, UNSAFE_CONTRACTS.tsv
  • Action: Prune rows 4-16, 19-20 + 7 contract tags

SUMMARY STATISTICS

Total lines to DELETE (estimated):

  • mutation_core.rs: ~500 LOC (staged)
  • prefix_helpers.rs: ~300 LOC (staged)
  • from_trie/from_ptr/CharWalkGuard: ~60 LOC
  • transition/edges owned branches: ~80 LOC
  • Owned loaders (disk_io.rs): ~400 LOC
  • CharTrieRoot + helpers (types.rs): ~50 LOC
  • White-box test cleanup (persist.rs): ~200 LOC
  • TOTAL: ~1590 LOC

Owned-arm survivor (currently LIVE, post-C2 cleanup):

  • ~2200 LOC of overlay handling, lock-free operations (KEEP)

RECOMMENDATION FOR C2 AUTHOR

Execute in strict order:

  1. START: Collapse SharedCharARTrie::root() (let compiler flag next errors)
  2. THEN: Delete dead-code warnings in order (from_trie, CharWalkGuard, owned branches)
  3. THEN: Delete loaders + types
  4. THEN: Fix test code + UNSAFE inventory
  5. FINALLY: Verify with full test suite + formal correspondence

This approach ensures the compiler acts as a fail-closed safety net: if any live caller was missed, the build fails immediately.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close