ToolsのTracker実装

This commit is contained in:
2026-04-13 04:26:27 +09:00
parent 5bc4a6d6d6
commit 9b9e37cc84
14 changed files with 442 additions and 358 deletions
+7 -3
View File
@@ -164,13 +164,17 @@ impl PodController {
// Edit / Glob / Grep) when the manifest declares a scope.
//
// `ScopedFs` carries the pod-lifetime write boundary (derived
// from the manifest scope). `ReadTracker` is session-scoped —
// from the manifest scope). `Tracker` is session-scoped —
// a fresh instance per controller spawn ensures state from a
// previous process lifetime cannot be reused after a resume.
// The tracker is also handed to the Pod itself so Pod-level
// operations (e.g. context compaction) can ask which files
// the agent has been touching.
if let Some(scope) = scope_for_tools {
let fs = tools::ScopedFs::new(scope);
let tracker = tools::ReadTracker::new();
worker.register_tools(tools::builtin_tools(fs, tracker));
let tracker = tools::Tracker::new();
worker.register_tools(tools::builtin_tools(fs, tracker.clone()));
pod.attach_tracker(tracker);
}
}
+21
View File
@@ -53,6 +53,11 @@ pub struct Pod<C: LlmClient, St: Store> {
manifest_dir: Option<PathBuf>,
/// Shared compaction state (present when compact_threshold is configured).
compact_state: Option<Arc<CompactState>>,
/// Session-lifetime file-operation tracker from the builtin `tools`
/// crate. Populated by the Controller when it registers the builtin
/// tools so that Pod-owned operations (e.g. compaction) can consult
/// the recency of touched files.
tracker: Option<tools::Tracker>,
}
impl<C: LlmClient, St: Store> Pod<C, St> {
@@ -80,6 +85,7 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
interceptor_installed: false,
manifest_dir: None,
compact_state: None,
tracker: None,
})
}
@@ -112,6 +118,7 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
interceptor_installed: false,
manifest_dir: None,
compact_state: None,
tracker: None,
})
}
@@ -148,6 +155,19 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
&self.store
}
/// Attach the session-scoped file-operation tracker from the builtin
/// `tools` crate. Called by the Controller immediately after it
/// registers the builtin tools on the Worker. Overwrites any
/// previously attached tracker.
pub fn attach_tracker(&mut self, tracker: tools::Tracker) {
self.tracker = Some(tracker);
}
/// The attached session-scoped file-operation tracker, if any.
pub fn tracker(&self) -> Option<&tools::Tracker> {
self.tracker.as_ref()
}
// --- Hook registration ---
fn assert_hooks_open(&self) {
@@ -577,6 +597,7 @@ impl<St: Store> Pod<Box<dyn LlmClient>, St> {
interceptor_installed: false,
manifest_dir,
compact_state: None,
tracker: None,
})
}