context-sharing.ts 994 B

123456789101112131415161718192021
  1. // The context relation. `shared` is one actor asked at two sites -> a context edge
  2. // between those asks (exact: same singleton actor). Two independent actors asked
  3. // separately share no actor -> no context edge between them. An actor passed into a
  4. // helper that asks it relates via the summary's actor taint.
  5. // The helper `interrogate` is declared first, so its ask is ask#1; the direct
  6. // `shared` asks are ask#2/ask#3. Context edges: ask#1 -> ask#2, ask#1 -> ask#3, ask#2 -> ask#3.
  7. function interrogate(who: Agent, topic: string): Node<string> {
  8. return who.ask<string>(`about ${topic}`);
  9. }
  10. const shared = agent("shared");
  11. const first = await shared.ask<string>("one");
  12. const second = await shared.ask<string>("two");
  13. const loner = agent("loner");
  14. const alone = await loner.ask<string>("solo");
  15. const soloTwo = await agent("ephemeral").ask<string>("throwaway");
  16. const viaHelper = await interrogate(shared, "delegated");
  17. return `${first} ${second} ${alone} ${soloTwo} ${viaHelper}`;