within-fanout.ts 918 B

1234567891011121314
  1. // Static fan-out containment (`within`, item 7). Two judge idioms in one script:
  2. // A) `agent("judgeA")` is created INSIDE the first fan-out body -> a lane family:
  3. // both the actor (actor#1) and its ask (ask#1) carry within=fan-out#1 (a fresh
  4. // actor per element).
  5. // B) `judgeB` is created OUTSIDE any fan-out and asked inside the second fan-out ->
  6. // the actor (actor#2) has NO within (one shared, serialized lane), while its ask
  7. // (ask#2) still carries within=fan-out#2 (per-element instances of the ask).
  8. // `within` is purely lexical containment in a PROMOTED candidate's body; the two
  9. // maps both reach an ask, so both promote (fan-out#1, fan-out#2).
  10. const findings = await files.glob("*.log");
  11. const a = findings.map((f) => agent("judgeA").ask<string>(`triage ${f}`));
  12. const judgeB = agent("judgeB");
  13. const b = findings.map((f) => judgeB.ask<string>(`triage ${f}`));
  14. return [...a, ...b];