order-loop-head-await-tail-issue.ts 1.4 KB

12345678910111213141516171819202122
  1. // The regression guard for phase 2's repetition demotion: a loop whose HEAD awaits the
  2. // promise its TAIL issued. Iteration k+1's `await box` settles iteration k's ask, so the
  3. // oracle admits ask#1 by repetition even though the walk has not issued it yet — but that
  4. // settle must be a MAY-claim, never certain, because the claim fails at both ends of the
  5. // loop. The first iteration awaits the initial (empty) value and settles nothing, and the
  6. // LAST iteration issues ask#1 and then exits: the head await of iteration k+1 never runs,
  7. // so that instance is still pending when ask#2 issues. A certain settle here would emit
  8. // `ask#1 -> ask#2 seq always`, asserting a post-loop ordering the final instance violates.
  9. //
  10. // The loop is a literal-bounded `for` ON PURPOSE. Edges inherit the weaker certainty of
  11. // their endpoints, so inside a `while` (never provably entered) ask#1 would be `maybe` and
  12. // drag the edge to `maybe` whatever the settle claimed — the fixture would pass either way
  13. // and guard nothing. A positive literal bound makes ask#1 `always` (finding (a)), so the
  14. // edge's certainty is decided by the SETTLE, which is exactly what this pins.
  15. // Expect: ask#1 -> ask#2 seq MAYBE (plus the loop's own carry self-edge).
  16. let box: Node<string> | undefined;
  17. for (let round = 0; round < 3; round++) {
  18. const prev = await box;
  19. box = agent("refiner").ask<string>(`refine ${prev}`);
  20. }
  21. const final = await agent("wrapper").ask<string>("wrap up");
  22. return final;