Skip to content

Commit 45d30ce

Browse files
committed
feat: scope materialization to one agent
1 parent 379592c commit 45d30ce

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/main.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ enum Command {
5353
/// Materialize every local agent's render block and exit without reconciling or spawning.
5454
#[arg(long, conflicts_with = "once")]
5555
materialize_only: bool,
56+
/// Limit materialization/reconciliation to one declared agent identity.
57+
#[arg(long)]
58+
agent: Option<String>,
5659
/// Seconds between timer-driven reconcile passes when looping (folder changes reconcile
5760
/// immediately regardless).
5861
#[arg(long, default_value_t = 30)]
@@ -519,9 +522,10 @@ fn main() -> Result<()> {
519522
once,
520523
materialize_only,
521524
interval,
525+
agent,
522526
} => {
523527
let root = catalog_arg(root)?;
524-
up(&root, host, once, materialize_only, interval)
528+
up(&root, host, once, materialize_only, interval, agent)
525529
}
526530
Command::Message(cmd) => message_cmd(cmd),
527531
Command::Context(cmd) => context_cmd(cmd),
@@ -992,9 +996,9 @@ fn doctor_cmd(root: &Path, host: Option<String>, require_supervisor: bool) -> Re
992996
.unwrap_or_else(|| format!("{bus_id}.{}", task.name))
993997
})
994998
.filter_map(|id| {
995-
present.get(&id).map(|alive| {
996-
format!("{id} ({})", if *alive { "alive" } else { "dead" })
997-
})
999+
present
1000+
.get(&id)
1001+
.map(|alive| format!("{id} ({})", if *alive { "alive" } else { "dead" }))
9981002
})
9991003
.collect::<Vec<_>>();
10001004
report_check(
@@ -1683,6 +1687,7 @@ fn up(
16831687
once: bool,
16841688
materialize_only: bool,
16851689
interval: u64,
1690+
agent: Option<String>,
16861691
) -> Result<()> {
16871692
// An st2-SPEC path (a `*.kdl` file, or a folder with one top-level spec `*.kdl`) supervises its
16881693
// top-level team directly — no catalog discovery. Otherwise, the classic catalog reconcile loop.
@@ -1699,7 +1704,12 @@ fn up(
16991704
let catalog_root = root.canonicalize().unwrap_or_else(|_| root.to_path_buf());
17001705

17011706
if materialize_only {
1702-
let found = discover(&catalog_root);
1707+
let mut found = discover(&catalog_root);
1708+
if let Some(identity) = agent.as_deref() {
1709+
found
1710+
.specs
1711+
.retain(|spec| spec.identity == identity || spec.bus_id(&this_host) == identity);
1712+
}
17031713
for warning in &found.warnings {
17041714
eprintln!("warning: {warning}");
17051715
}

0 commit comments

Comments
 (0)