feat: generalize supervisor registry to TaskHandle enum with job scaffolding, kill discipline, and max_concurrent_jobs config
Implements T1 of plans/background-jobs-design.md (§6, R7/R8/R9): - Supervisor.handles is now HashMap<String, TaskHandle> where TaskHandle = Agent(AgentHandle) | Job(JobHandle); agent-facing accessors (active_count, effective_active_count, is_finished, take, inbox, abort_signal_for, list_agents) match only Agent variants, preserving all existing external behavior byte-for-byte. - New JobHandle/JobState/JobStatus/JobResult types with pgid-guarded process-group kill discipline: Drop and cancel_all/cancel_recursive kill the group only while state.pgid is still set (pid-reuse guard), via libc::killpg on unix and JoinHandle::abort elsewhere. - Per-kind job capacity: Supervisor carries max_concurrent_jobs (builder-set, default 0); job registration rejects at capacity. - Cross-kind teaching errors at the four agent-lookup miss sites (agent__check/collect/cancel/send_message) when the id is a registered job or job_-prefixed; genuinely-unknown ids keep their existing messages. - Supervisor init condition is now can_spawn_agents || jobs_enabled in use_agent and both child-agent spawn paths, with agent capacity 0 in jobs-only contexts; use_agent cancels the old supervisor recursively before replacing it. - max_concurrent_jobs config plumbing: global Config field, AgentConfig override + accessor, all four AppConfig touch points including the COYOTE_MAX_CONCURRENT_JOBS env override; shared effective_max_concurrent_jobs/jobs_enabled predicates (agent override -> global -> default 5; 0 disables). - Stage dependency-free RingBuf (64 KiB default) in src/function/jobs.rs for the upcoming job output pump. - New sanctioned dependency: libc 0.2 under cfg(unix).
This commit is contained in:
@@ -561,6 +561,10 @@ impl Agent {
|
||||
self.config.max_tool_result_chars
|
||||
}
|
||||
|
||||
pub fn max_concurrent_jobs(&self) -> Option<usize> {
|
||||
self.config.max_concurrent_jobs
|
||||
}
|
||||
|
||||
pub fn compression_keep_last(&self) -> Option<usize> {
|
||||
self.config.compression_keep_last
|
||||
}
|
||||
@@ -735,6 +739,8 @@ pub struct AgentConfig {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub max_tool_result_chars: Option<usize>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub max_concurrent_jobs: Option<usize>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub compression_keep_last: Option<usize>,
|
||||
#[serde(default)]
|
||||
pub description: String,
|
||||
|
||||
Reference in New Issue
Block a user