order-shared-helper-residual-cycle.ts 957 B

12345678910111213141516171819
  1. // A shared helper issued BEFORE the loop (baseline) and INSIDE it (gate): under the
  2. // phase-1 one-step-per-site rule both occurrences quotient onto world-read#1, so
  3. // read -> ask (baseline feeds the first prompt) and ask -> read (the gate re-runs the
  4. // helper after every ask) are BOTH forward facts — a residual 2-cycle no carry lift
  5. // removes. Regression guard for the reducer: on this shape the old
  6. // batch-remove-then-restore pass over-restored (the jsonl-db symptom: 66 forward
  7. // edges, 55 of them implied by the rest); the reduction must stay irredundant here.
  8. async function bench(): Promise<string> {
  9. const result = await world.run("./bench", []);
  10. return result.stdout;
  11. }
  12. const optimizer = agent("optimizer");
  13. let best = await bench();
  14. for (let round = 0; round < 3; round++) {
  15. const idea = await optimizer.ask<string>(`beat this baseline: ${best}`);
  16. await world.run("cargo", ["test", idea]);
  17. best = await bench();
  18. }
  19. return best;