MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / index_inherited_turn

Method index_inherited_turn

atomic-core/src/pristine/txn/write/mod.rs:612–651  ·  view source on GitHub ↗

Index an inherited turn row for a forked session. The immutable turn data comes from the parent; the child derives its own canonical numbering from the complete inherited prefix.

(
        &mut self,
        child_session_id: &str,
        json_path: &str,
        turn: &crate::change::session::SessionTurn,
    )

Source from the content-addressed store, hash-verified

610 /// The immutable turn data comes from the parent; the child derives its
611 /// own canonical numbering from the complete inherited prefix.
612 pub fn index_inherited_turn(
613 &mut self,
614 child_session_id: &str,
615 json_path: &str,
616 turn: &crate::change::session::SessionTurn,
617 ) -> PristineResult<()> {
618 use crate::change::session::SessionRecord;
619
620 let turns = self.load_session_turns_for_write(child_session_id)?;
621 if turns
622 .iter()
623 .any(|existing| existing.provenance_hash == turn.provenance_hash)
624 {
625 return Ok(());
626 }
627
628 let mut record = self
629 .load_session_record_for_write(child_session_id)?
630 .unwrap_or_else(|| SessionRecord {
631 session_id: child_session_id.to_string(),
632 json_path: json_path.to_string(),
633 view_name: None,
634 parent_view: None,
635 first_provenance: None,
636 latest_provenance: None,
637 turn_count: 0,
638 started_at: turn.timestamp,
639 ended_at: None,
640 });
641
642 if record.json_path.is_empty() {
643 record.json_path = json_path.to_string();
644 }
645
646 let mut inherited = turn.clone();
647 inherited.session_id = child_session_id.to_string();
648 inherited.turn_number = 0;
649
650 self.index_session_turn_candidate(record, turns, inherited)
651 }
652
653 /// Create an empty session record (e.g., a fork with no inherited turns).
654 pub fn index_empty_session(

Callers 2

rebuild_session_indexMethod · 0.80
fork_sessionMethod · 0.80

Calls 6

iterMethod · 0.45
is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected