nested-fanout-reach.ts 1.4 KB

1234567891011121314151617181920212223242526
  1. // Reachability across nested regions (fix #2). `deepen` asks; `viaMap` maps with a
  2. // callback that CALLS `deepen` (not asks directly) — so the ask never marks
  3. // `fn@viaMap` reachable via the facade, only the propagated call graph can. The
  4. // top-level `seeds.map(...)` callback calls `viaMap`. Because a call is now recorded
  5. // against EVERY enclosing region (not just the innermost `cand@N`), `fn@viaMap`
  6. // becomes reachable through `deepen`, so BOTH iteration candidates promote to
  7. // fan-out nodes: fan-out#1 = the `map` inside `viaMap` (source-order first),
  8. // fan-out#2 = the top-level `seeds.map`. Before the fix the top-level map failed to
  9. // promote (a dropped fan-out).
  10. //
  11. // Expected edges:
  12. // source -> world-read#1 (glob drives the loops)
  13. // world-read#1 -> fan-out#2 (seeds iterated by the top map)
  14. // world-read#1 -> fan-out#1, fan-out#2 -> fan-out#1 (the top element [s] is what
  15. // viaMap's inner map iterates)
  16. // world-read#1 -> ask#1, fan-out#1 -> ask#1, fan-out#2 -> ask#1 (element into ask)
  17. // world-read#1 -> sink, fan-out#1 -> sink, fan-out#2 -> sink, ask#1 -> sink
  18. const seeds = await files.glob("*.md");
  19. function deepen(topic: string): Node<string> {
  20. return agent("worker").ask<string>(topic);
  21. }
  22. function viaMap(topics: string[]): Node<string>[] {
  23. return topics.map((t) => deepen(t));
  24. }
  25. const out = seeds.map((s) => viaMap([s]));
  26. return out;