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

Method index_empty_session

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

Create an empty session record (e.g., a fork with no inherited turns).

(
        &mut self,
        session_id: &str,
        json_path: &str,
        view_name: Option<String>,
        parent_view: Option<String>,
    )

Source from the content-addressed store, hash-verified

851
852 /// Create an empty session record (e.g., a fork with no inherited turns).
853 pub fn index_empty_session(
854 &mut self,
855 session_id: &str,
856 json_path: &str,
857 view_name: Option<String>,
858 parent_view: Option<String>,
859 ) -> PristineResult<()> {
860 use crate::change::session::SessionRecord;
861
862 let mut sessions = self.txn.open_table(SESSIONS)?;
863 if sessions.get(session_id)?.is_some() {
864 return Ok(());
865 }
866 let record = SessionRecord {
867 session_id: session_id.to_string(),
868 json_path: json_path.to_string(),
869 view_name,
870 parent_view,
871 first_provenance: None,
872 latest_provenance: None,
873 turn_count: 0,
874 started_at: chrono::Utc::now().timestamp_millis(),
875 ended_at: None,
876 status: crate::change::session::SessionStatus::Active,
877 };
878 let bytes = record.to_bytes();
879 sessions.insert(session_id, bytes.as_slice())?;
880 drop(sessions);
881 self.emit_session_node(&record)
882 }
883
884 /// Reconcile lifecycle metadata for a session record.
885 ///

Callers 2

rebuild_session_indexMethod · 0.80
fork_sessionMethod · 0.80

Calls 6

timestamp_millisMethod · 0.80
emit_session_nodeMethod · 0.80
getMethod · 0.65
to_bytesMethod · 0.45
insertMethod · 0.45
as_sliceMethod · 0.45

Tested by

no test coverage detected