strand-fanout-awaited-per-phase.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // The control for strand-fanout-two-phases-join: the same three fan-outs, but each phase
  2. // awaits its own work before the next marker. This script really is sequential, and the two
  3. // fixtures' goldens must DIFFER — under the old single settled set they were byte-identical,
  4. // which is what made the defect invisible to every downstream view.
  5. //
  6. // Expected:
  7. // core — the same `strand` flags on the three fan-out regions, but two separate barriers:
  8. // `settle ask#1 in=seq#1 joins=fanout#1` before B's marker and
  9. // `settle ask#2 in=seq#1 joins=fanout#2` before C's.
  10. // causality — `ask#1 -> ask#2 seq` and `phase#1 -> phase#2 seq` survive: A's answers were
  11. // awaited before B issued, so the ordering is real and the arrow is earned.
  12. // cfg — NO `alongside` on any mark or phase line, because nothing was ever parked across
  13. // a marker; A's exits join at B's mark and B's at C's.
  14. const ids = [1, 2, 3];
  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. const a = await Promise.all(aWork);
  21. phase("B");
  22. const bWork = ids.map(async (i) => {
  23. const r = await agent(`b-${i}`).ask<string>(`probe ${i}`);
  24. return r;
  25. });
  26. const b = await Promise.all(bWork);
  27. phase("C");
  28. const merged = await Promise.all(
  29. ids.map(async (i) => {
  30. const r = await agent(`c-${i}`).ask<string>(`${a.join(",")} / ${b.join(",")} #${i}`);
  31. return r;
  32. }),
  33. );
  34. return merged;