strand-overlap-chain.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Overlapping, not nested: A's work is joined before C is entered, B's only before D. The
  2. // live intervals are A ∥ B, B ∥ C, and A → C — the shape a timeline must colour onto two
  3. // tracks, because no single band holds all three.
  4. //
  5. // Expected:
  6. // cfg — `phase phase#2 "B" alongside=phase#1` (B entered while A ran),
  7. // `phase phase#3 "C" alongside=phase#2` (C entered while B still ran), and phase#4 with
  8. // NO alongside: both fan-outs were joined by then. A's asks land on C's marker
  9. // (`ask#1@1 -> phase#3@1 join via=return`) and B's on D's
  10. // (`ask#2@1 -> phase#4@1 join via=return`), because a strand's exits reconnect at the
  11. // barrier that joins it and flow on to the next node.
  12. // causality — no edge between ask#1 and ask#2, and no forward `phase#1 -> phase#2` edge:
  13. // A and B are incomparable, which is what makes `alongside` and the quotient agree.
  14. const ids = [1, 2];
  15. phase("A");
  16. const aWork = ids.map(async (i) => {
  17. const r = await agent(`a-${i}`).ask<string>(`survey ${i}`);
  18. return r;
  19. });
  20. phase("B");
  21. const bWork = ids.map(async (i) => {
  22. const r = await agent(`b-${i}`).ask<string>(`probe ${i}`);
  23. return r;
  24. });
  25. const a = await Promise.all(aWork);
  26. phase("C");
  27. const c = await agent("c").ask<string>(`compare ${a.join(",")}`);
  28. const b = await Promise.all(bWork);
  29. phase("D");
  30. const d = await agent("d").ask<string>(`${c} + ${b.join(",")}`);
  31. return d;