emission-graph-join-index-write-original.ts 1.1 KB

123456789101112131415161718
  1. // Write through a static index of a BOUND Promise.all result, read back through the
  2. // ORIGINAL variable that was passed as that join element. Runtime: res[1] === box, so
  3. // `res[1].note = res[0]` makes box.note carry ask#1's output; ask#2 reads box.note.
  4. // Required may-flow: ask#1 -> ask#2. (The shipped fixture
  5. // tests/graphs/join-element-alias-write-through.ts writes AND reads through res[k];
  6. // this probes the other direction: write via the join result, read via the source.)
  7. // The graph also carries SOUND additive over-approximations: res[0] is a join output, so
  8. // writing it into box gives box the join#1 label AND ask#1; box is itself join input port 1
  9. // (flow-insensitively), producing `ask#1 -> join#1 port=1`, a `join#1 -> join#1 port=1`
  10. // self-loop, and `join#1 -> ask#2` — all inexact, over-approximations rather than drops.
  11. interface Box {
  12. note: string;
  13. }
  14. const box: Box = { note: "plain" };
  15. const secret = agent("spy").ask<string>("fetch");
  16. const res = await Promise.all([secret, box]);
  17. res[1].note = res[0];
  18. return agent("reader").ask<string>(`report on ${box.note}`);