MCPcopy Index your code
hub / github.com/douglance/devsql / transcripts_metadata_columns

Function transcripts_metadata_columns

crates/ccql/src/sql/composite_storage.rs:853–919  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

851
852 #[tokio::test]
853 async fn transcripts_metadata_columns() {
854 let temp = tempfile::tempdir().expect("temp");
855 let root = temp.path();
856 let slug = "-Users-douglance-Developer-lv-devsql";
857
858 write(
859 &root.join("projects").join(slug).join("sess-top.jsonl"),
860 r#"{"type":"user","content":"hi"}"#,
861 );
862 write(
863 &root
864 .join("projects")
865 .join(slug)
866 .join("sess-parent")
867 .join("subagents")
868 .join("agent-abc123.jsonl"),
869 r#"{"type":"assistant","content":"sub"}"#,
870 );
871 write(
872 &root.join("transcripts").join("ses_legacy1.jsonl"),
873 r#"{"type":"user","content":"old"}"#,
874 );
875
876 let storage = CompositeStorage::new(config_for(root)).expect("storage");
877 let rows = storage.scan_transcripts().expect("scan");
878
879 let get = |needle: &str| -> &BTreeMap<String, Value> {
880 rows.iter()
881 .find_map(|(_, r)| match r {
882 DataRow::Map(m) => {
883 if matches!(m.get("_source_file"), Some(Value::Str(s)) if s == needle) {
884 Some(m)
885 } else {
886 None
887 }
888 }
889 _ => None,
890 })
891 .unwrap_or_else(|| panic!("row {} not found", needle))
892 };
893
894 let top = get("sess-top.jsonl");
895 assert_eq!(top.get("_session_id"), Some(&Value::Str("sess-top".into())));
896 assert_eq!(top.get("_project"), Some(&Value::Str(slug.into())));
897 assert!(top.get("_agent_id").is_none());
898
899 let sub = get("agent-abc123.jsonl");
900 assert_eq!(
901 sub.get("_session_id"),
902 Some(&Value::Str("sess-parent".into())),
903 "subagent session id is parent dir name"
904 );
905 assert_eq!(sub.get("_project"), Some(&Value::Str(slug.into())));
906 assert_eq!(
907 sub.get("_agent_id"),
908 Some(&Value::Str("agent-abc123".into()))
909 );
910

Callers

nothing calls this directly

Calls 4

config_forFunction · 0.85
pathMethod · 0.80
scan_transcriptsMethod · 0.80
writeFunction · 0.70

Tested by

no test coverage detected