update: SessionId / SessionStart / SessionOrigin 等を Segment 系名称へ

- Type/Function/Variantを Segment* 系へ統一
  - SessionId/SessionStart/SessionOrigin/SessionStartState/SessionState/SessionLogSink/SessionLockInfo
  - new_session_id / session_id / create_session* / list_sessions / lookup_session / update_session / find_by_session
  - protocol Event::SessionRotated → SegmentRotated、CompactDone.new_session_id → new_segment_id
- Module: session_log → segment_log / session → segment (file mv 含む)
  pod 側の session_log_sink → segment_log_sink も同様
- crate 名 (session-store)、CLI flag (--session)、ResumeWithSession (CLI tied) は据え置き
- session-tests/session_metrics_test 等の Store impl も追従
This commit is contained in:
2026-05-20 05:06:04 +09:00
parent de549812ab
commit 22f5d02385
55 changed files with 611 additions and 610 deletions
+1 -1
View File
@@ -243,7 +243,7 @@ mod tests {
let (_id, _) = write_staging(
&layout,
SourceRef {
session_id: "s".into(),
segment_id: "s".into(),
range: [0, 1],
},
ExtractedPayload::default(),
+2 -2
View File
@@ -260,7 +260,7 @@ mod tests {
let (id_a, _) = write_staging(
&layout,
SourceRef {
session_id: "s".into(),
segment_id: "s".into(),
range: [0, 0],
},
ExtractedPayload::default(),
@@ -269,7 +269,7 @@ mod tests {
let (id_b, _) = write_staging(
&layout,
SourceRef {
session_id: "s".into(),
segment_id: "s".into(),
range: [1, 1],
},
ExtractedPayload::default(),
+2 -2
View File
@@ -94,9 +94,9 @@ mod tests {
ExtractedPayload::default()
}
fn source(session_id: &str, range: [u64; 2]) -> SourceRef {
fn source(segment_id: &str, range: [u64; 2]) -> SourceRef {
SourceRef {
session_id: session_id.into(),
segment_id: segment_id.into(),
range,
}
}
+1 -1
View File
@@ -305,7 +305,7 @@ mod tests {
fn flags_sources_overflow() {
let (dir, layout) = workspace();
let many_sources: String = (0..15)
.map(|i| format!(" - session_id: s{i}\n range: [{i}, {i}]\n"))
.map(|i| format!(" - segment_id: s{i}\n range: [{i}, {i}]\n"))
.collect();
write(
&dir.path().join(".insomnia/memory/decisions/big.md"),
+1 -1
View File
@@ -13,7 +13,7 @@
//! session-store の `LogEntry::Extension`、domain `"memory.extract"`)は
//! Pod 側が責務を持つ。
//!
//! 出力 JSON の wrap は [`write_staging`] が `source: { session_id, range }`
//! 出力 JSON の wrap は [`write_staging`] が `source: { segment_id, range }`
//! を機械付与する形で担当し、LLM には source を推論させない。
mod input;
+1 -1
View File
@@ -78,7 +78,7 @@ pub struct RequestEntry {
/// staging に書き出される 1 ファイル分のレコード。
///
/// `source` は Pod 側ラッパーが session_id と log entry range を
/// `source` は Pod 側ラッパーが segment_id と log entry range を
/// 機械付与する。LLM はこのフィールドを見ない / 推論しない。
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StagingRecord {
+3 -3
View File
@@ -71,7 +71,7 @@ mod tests {
let layout = WorkspaceLayout::new(tmp.path().to_path_buf());
let source = SourceRef {
session_id: "sess-1".into(),
segment_id: "sess-1".into(),
range: [3, 7],
};
let payload = ExtractedPayload {
@@ -93,7 +93,7 @@ mod tests {
let written: StagingRecord =
serde_json::from_str(&fs::read_to_string(&path).unwrap()).unwrap();
assert_eq!(written.source.session_id, "sess-1");
assert_eq!(written.source.segment_id, "sess-1");
assert_eq!(written.source.range, [3, 7]);
assert_eq!(written.payload.decisions.len(), 1);
}
@@ -103,7 +103,7 @@ mod tests {
let tmp = tempfile::TempDir::new().unwrap();
let layout = WorkspaceLayout::new(tmp.path().to_path_buf());
let source = SourceRef {
session_id: "sess".into(),
segment_id: "sess".into(),
range: [0, 0],
};
let (_, path) = write_staging(&layout, source, ExtractedPayload::default()).unwrap();
+1 -1
View File
@@ -10,7 +10,7 @@ pub use lint_common::Frontmatter;
/// `last_sources` arrays for traceability back to raw session logs.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SourceRef {
pub session_id: String,
pub segment_id: String,
/// `[start_entry, end_entry]` inclusive range of session-store entry indices.
pub range: [u64; 2],
}
+4 -4
View File
@@ -60,7 +60,7 @@ impl Tool for ReadTool {
})?;
let text = String::from_utf8_lossy(&bytes).into_owned();
if let Some(session_id) = self.usage_session_id.as_deref() {
if let Some(segment_id) = self.usage_session_id.as_deref() {
let usage_slug = params.slug.as_deref().unwrap_or("summary");
let snapshot = usage::snapshot_record_from_bytes(
params.kind.record_kind(),
@@ -69,7 +69,7 @@ impl Tool for ReadTool {
);
if let Err(err) = usage::append_use_event(
&self.layout,
session_id.to_string(),
segment_id.to_string(),
UsageSource::MemoryRead,
vec![snapshot],
) {
@@ -140,9 +140,9 @@ pub fn read_tool(layout: WorkspaceLayout) -> ToolDefinition {
pub fn read_tool_with_usage(
layout: WorkspaceLayout,
session_id: impl Into<String>,
segment_id: impl Into<String>,
) -> ToolDefinition {
read_tool_inner(layout, Some(session_id.into()))
read_tool_inner(layout, Some(segment_id.into()))
}
fn read_tool_inner(layout: WorkspaceLayout, usage_session_id: Option<String>) -> ToolDefinition {
+7 -7
View File
@@ -64,7 +64,7 @@ impl UsageRecordSnapshot {
pub struct UsageEvent {
pub id: Uuid,
pub occurred_at: DateTime<Utc>,
pub session_id: String,
pub segment_id: String,
pub event: UsageEventKind,
pub source: UsageSource,
pub records: Vec<UsageRecordSnapshot>,
@@ -72,7 +72,7 @@ pub struct UsageEvent {
impl UsageEvent {
pub fn new(
session_id: impl Into<String>,
segment_id: impl Into<String>,
event: UsageEventKind,
source: UsageSource,
records: Vec<UsageRecordSnapshot>,
@@ -80,7 +80,7 @@ impl UsageEvent {
Self {
id: Uuid::now_v7(),
occurred_at: Utc::now(),
session_id: session_id.into(),
segment_id: segment_id.into(),
event,
source,
records,
@@ -144,7 +144,7 @@ pub fn append_usage_event(layout: &WorkspaceLayout, event: &UsageEvent) -> io::R
/// Convenience for a successful explicit record read.
pub fn append_use_event(
layout: &WorkspaceLayout,
session_id: impl Into<String>,
segment_id: impl Into<String>,
source: UsageSource,
records: Vec<UsageRecordSnapshot>,
) -> io::Result<()> {
@@ -153,14 +153,14 @@ pub fn append_use_event(
}
append_usage_event(
layout,
&UsageEvent::new(session_id, UsageEventKind::Use, source, records),
&UsageEvent::new(segment_id, UsageEventKind::Use, source, records),
)
}
/// Convenience for resident model-invocation exposure cost telemetry.
pub fn append_resident_exposure_event(
layout: &WorkspaceLayout,
session_id: impl Into<String>,
segment_id: impl Into<String>,
records: Vec<UsageRecordSnapshot>,
) -> io::Result<()> {
if records.is_empty() {
@@ -169,7 +169,7 @@ pub fn append_resident_exposure_event(
append_usage_event(
layout,
&UsageEvent::new(
session_id,
segment_id,
UsageEventKind::ResidentExposure,
UsageSource::ResidentInjection,
records,