Skip to content

Commit 275bff8

Browse files
committed
feat(index-generator): refactor to extract utility functions and ensure schema consistency in search index
1 parent 0c64aee commit 275bff8

13 files changed

Lines changed: 205 additions & 213 deletions

File tree

.ticket/tickets/6d07d610-75c1-448a-afd5-6ae15098ca21/history.ndjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
{"rev":10,"ts":"2026-06-14T20:35:37.330491+00:00","fields":{"component":"ticket-vscode","depends_on":["011563c2-59e7-48f1-a61f-d8fdc80d2f6e","14047b99-41d6-4899-bec6-4a919bffcc2d","362448d4-ccf1-4b9d-90f3-d4577da83a65","6de424b0-68ec-43c7-9d70-eb8d17305ab3","93f7e422-1e41-4145-b8ba-0dcf7fc730ac","bfafde19-ddf7-47ef-966e-a1135be4efd6"],"priority":"high","risk_level":"high","state":"ready","title":"[ticket-vscode] Rust/WASM port track","type":"tracker-improvement"}}
1111
{"rev":11,"ts":"2026-06-14T20:36:32.628613800+00:00","fields":{"component":"ticket-vscode","depends_on":["011563c2-59e7-48f1-a61f-d8fdc80d2f6e","14047b99-41d6-4899-bec6-4a919bffcc2d","6de424b0-68ec-43c7-9d70-eb8d17305ab3","93f7e422-1e41-4145-b8ba-0dcf7fc730ac","bfafde19-ddf7-47ef-966e-a1135be4efd6"],"priority":"high","risk_level":"high","state":"ready","title":"[ticket-vscode] Rust/WASM port track","type":"tracker-improvement"}}
1212
{"rev":12,"ts":"2026-06-14T20:36:35.758370900+00:00","fields":{"component":"ticket-vscode","depends_on":["011563c2-59e7-48f1-a61f-d8fdc80d2f6e","14047b99-41d6-4899-bec6-4a919bffcc2d","362448d4-ccf1-4b9d-90f3-d4577da83a65","6de424b0-68ec-43c7-9d70-eb8d17305ab3","93f7e422-1e41-4145-b8ba-0dcf7fc730ac","bfafde19-ddf7-47ef-966e-a1135be4efd6"],"priority":"high","risk_level":"high","state":"ready","title":"[ticket-vscode] Rust/WASM port track","type":"tracker-improvement"}}
13+
{"rev":13,"ts":"2026-06-15T00:22:55.909399600+00:00","fields":{"component":"ticket-vscode","depends_on":["011563c2-59e7-48f1-a61f-d8fdc80d2f6e","14047b99-41d6-4899-bec6-4a919bffcc2d","362448d4-ccf1-4b9d-90f3-d4577da83a65","694d74b4-028b-4602-8090-d6200d577d4a","6de424b0-68ec-43c7-9d70-eb8d17305ab3","93f7e422-1e41-4145-b8ba-0dcf7fc730ac","bfafde19-ddf7-47ef-966e-a1135be4efd6"],"priority":"high","risk_level":"high","state":"ready","title":"[ticket-vscode] Rust/WASM port track","type":"tracker-improvement"}}

.ticket/tickets/6d07d610-75c1-448a-afd5-6ae15098ca21/ticket.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ created_at = "2026-05-18T10:56:02.378708400+00:00"
33
title = "[ticket-vscode] Rust/WASM port track"
44
state = "ready"
55
component = "ticket-vscode"
6-
depends_on = ["011563c2-59e7-48f1-a61f-d8fdc80d2f6e", "14047b99-41d6-4899-bec6-4a919bffcc2d", "362448d4-ccf1-4b9d-90f3-d4577da83a65", "6de424b0-68ec-43c7-9d70-eb8d17305ab3", "93f7e422-1e41-4145-b8ba-0dcf7fc730ac", "bfafde19-ddf7-47ef-966e-a1135be4efd6"]
6+
depends_on = ["011563c2-59e7-48f1-a61f-d8fdc80d2f6e", "14047b99-41d6-4899-bec6-4a919bffcc2d", "362448d4-ccf1-4b9d-90f3-d4577da83a65", "694d74b4-028b-4602-8090-d6200d577d4a", "6de424b0-68ec-43c7-9d70-eb8d17305ab3", "93f7e422-1e41-4145-b8ba-0dcf7fc730ac", "bfafde19-ddf7-47ef-966e-a1135be4efd6"]
77
priority = "high"
88
risk_level = "high"
99
type = "tracker-improvement"

.ticket/tickets/6de424b0-68ec-43c7-9d70-eb8d17305ab3/history.ndjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
{"rev":7,"ts":"2026-06-14T22:55:43.927310900+00:00","fields":{"component":"ticket-vscode","depends_on":["362448d4-ccf1-4b9d-90f3-d4577da83a65"],"priority":"high","risk_level":"medium","state":"in-implementation","title":"[ticket-vscode] Validate Rust/WASM parity across desktop, web, and remote hosts","type":"tracker-improvement"}}
88
{"rev":8,"ts":"2026-06-14T23:00:30.288971100+00:00","fields":{"component":"ticket-vscode","depends_on":["362448d4-ccf1-4b9d-90f3-d4577da83a65"],"priority":"high","risk_level":"medium","state":"in-implementation","title":"[ticket-vscode] Validate Rust/WASM parity across desktop, web, and remote hosts","type":"tracker-improvement"}}
99
{"rev":9,"ts":"2026-06-14T23:14:52.645345600+00:00","fields":{"component":"ticket-vscode","depends_on":["362448d4-ccf1-4b9d-90f3-d4577da83a65"],"priority":"high","risk_level":"medium","state":"in-implementation","title":"[ticket-vscode] Validate Rust/WASM parity across desktop, web, and remote hosts","type":"tracker-improvement"}}
10+
{"rev":10,"ts":"2026-06-15T00:23:07.043777100+00:00","fields":{"component":"ticket-vscode","depends_on":["362448d4-ccf1-4b9d-90f3-d4577da83a65","694d74b4-028b-4602-8090-d6200d577d4a"],"priority":"high","risk_level":"medium","state":"in-implementation","title":"[ticket-vscode] Validate Rust/WASM parity across desktop, web, and remote hosts","type":"tracker-improvement"}}

.ticket/tickets/6de424b0-68ec-43c7-9d70-eb8d17305ab3/ticket.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ created_at = "2026-05-18T10:56:19.146718300+00:00"
33
title = "[ticket-vscode] Validate Rust/WASM parity across desktop, web, and remote hosts"
44
state = "in-implementation"
55
component = "ticket-vscode"
6-
depends_on = ["362448d4-ccf1-4b9d-90f3-d4577da83a65"]
6+
depends_on = ["362448d4-ccf1-4b9d-90f3-d4577da83a65", "694d74b4-028b-4602-8090-d6200d577d4a"]
77
priority = "high"
88
risk_level = "medium"
99
type = "tracker-improvement"

crates/memory-api/src/index_generator/audit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::model::index_entry::{
1919
};
2020
use crate::model::index_sidecar::IndexSidecar;
2121

22-
use super::ticket::deterministic_uuid;
22+
use super::util::deterministic_uuid;
2323

2424
/// Namespace UUID for deterministic audit root UUIDs.
2525
const AUDIT_NS: Uuid = Uuid::from_bytes([

crates/memory-api/src/index_generator/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
//! if they need deterministic timestamps in tests.
1919
2020
pub mod audit;
21-
pub mod rule;
2221
pub mod spec;
2322
pub mod ticket;
23+
pub mod util;
2424
pub mod workspace;
2525

2626
pub use audit::generate_audit_sidecar;
27-
pub use rule::generate_rule_sidecar;
2827
pub use spec::generate_spec_sidecar;
2928
pub use ticket::generate_ticket_sidecar;
29+
pub use util::{
30+
deterministic_uuid,
31+
to_relative_slash,
32+
};
3033
pub use workspace::generate_workspace_sidecar;

crates/memory-api/src/index_generator/rule.rs

Lines changed: 0 additions & 184 deletions
This file was deleted.

crates/memory-api/src/index_generator/spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::model::index_entry::{
1717
use crate::model::index_sidecar::IndexSidecar;
1818
use crate::storage::indexed::IndexedEntity;
1919

20-
use super::ticket::to_relative_slash;
20+
use super::util::to_relative_slash;
2121

2222
/// Input for the spec sidecar generator.
2323
pub struct SpecIndexInput<'a> {

crates/memory-api/src/index_generator/ticket.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use std::path::Path;
1212

1313
use chrono::Utc;
14-
use uuid::Uuid;
1514

15+
use super::util::to_relative_slash;
1616
use crate::model::index_entry::{
1717
ContentKind,
1818
IndexEntry,
@@ -103,30 +103,12 @@ fn make_ticket_entry(
103103
}
104104
}
105105

106-
/// Convert an absolute path to a workspace-relative string with `/` separators.
107-
pub(super) fn to_relative_slash(
108-
workspace_root: &Path,
109-
abs_path: &Path,
110-
) -> String {
111-
abs_path
112-
.strip_prefix(workspace_root)
113-
.unwrap_or(abs_path)
114-
.to_string_lossy()
115-
.replace('\\', "/")
116-
}
117-
118-
/// Stable synthetic UUID derived from a fixed namespace + slug string.
119-
///
120-
/// Used for workspace summary and agent-hook entries that have no store UUID.
121-
pub(super) fn deterministic_uuid(namespace: Uuid, slug: &str) -> Uuid {
122-
Uuid::new_v5(&namespace, slug.as_bytes())
123-
}
124-
125106
#[cfg(test)]
126107
mod tests {
127108
use super::*;
128109
use std::path::PathBuf;
129110
use chrono::Utc;
111+
use uuid::Uuid;
130112

131113
fn fake_ticket(id: Uuid, title: &str, state: &str, path: PathBuf) -> IndexedEntity {
132114
IndexedEntity {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//! Generic, domain-agnostic helpers shared by every store-index generator.
2+
//!
3+
//! These helpers were promoted out of `index_generator/ticket.rs` so that
4+
//! domain-owned generators (which live in their own crates, e.g. `rule-api`)
5+
//! can reuse them without depending on the ticket generator (decision Q1.1 of
6+
//! the `thin-generator-architecture` spec).
7+
8+
use std::path::Path;
9+
10+
use uuid::Uuid;
11+
12+
/// Convert an absolute path to a workspace-relative string with `/` separators.
13+
///
14+
/// When `abs_path` is not under `workspace_root` the original path is returned
15+
/// (with separators normalized). Output is always `/`-separated so generated
16+
/// artifacts are byte-identical across platforms.
17+
pub fn to_relative_slash(
18+
workspace_root: &Path,
19+
abs_path: &Path,
20+
) -> String {
21+
abs_path
22+
.strip_prefix(workspace_root)
23+
.unwrap_or(abs_path)
24+
.to_string_lossy()
25+
.replace('\\', "/")
26+
}
27+
28+
/// Stable synthetic UUID derived from a fixed namespace + slug string.
29+
///
30+
/// Used for workspace summary and agent-hook entries that have no store UUID.
31+
/// Deterministic: identical inputs always yield the same UUID (UUID v5).
32+
pub fn deterministic_uuid(
33+
namespace: Uuid,
34+
slug: &str,
35+
) -> Uuid {
36+
Uuid::new_v5(&namespace, slug.as_bytes())
37+
}
38+
39+
#[cfg(test)]
40+
mod tests {
41+
use super::*;
42+
use std::path::PathBuf;
43+
44+
#[test]
45+
fn to_relative_slash_strips_root_and_normalizes() {
46+
let root = PathBuf::from("/workspace");
47+
let abs = PathBuf::from("/workspace/.rule/entries/x/rule.toml");
48+
assert_eq!(
49+
to_relative_slash(&root, &abs),
50+
".rule/entries/x/rule.toml"
51+
);
52+
}
53+
54+
#[test]
55+
fn deterministic_uuid_is_stable() {
56+
let ns = Uuid::nil();
57+
assert_eq!(
58+
deterministic_uuid(ns, "shared/agent-rules"),
59+
deterministic_uuid(ns, "shared/agent-rules")
60+
);
61+
assert_ne!(
62+
deterministic_uuid(ns, "a"),
63+
deterministic_uuid(ns, "b")
64+
);
65+
}
66+
}

0 commit comments

Comments
 (0)