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

Method index_inherited_turn

atomic-core/src/pristine/txn/write/mod.rs:611–650  ·  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

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