cloud-rehearsal install: the wait for the commit's outcome reads payload.trigger.commitOid (#2)
jonas, 2026-11-28 21:32 UTC · aacbc7450ff23fffc9210accd6c881bcf2f08113 · parent cd0b1dd
1 file changed
M scripts/cloud-rehearsal/install.ts
@@ -69,8 +69,17 @@ const before = { "apps/cloud-rehearsal/mind.ts": mind, "apps/cloud-rehearsal/backend.ts": backend, "api.ts": api, "agents.ts": agents }; const changes = Object.entries(files).filter(([path, content]) => before[path] !== content).map(([path, content]) => ({ path, content })); if (changes.length === 0) return "The rehearsal app is installed already, and nothing differs."; +// where the root log ends now: the outcome of the commit lands after it +const head = (await itx.readEvents(Number.MAX_SAFE_INTEGER, 1)).scannedThroughOffset; const { commitOid } = await repo.commitFiles({ message: "apps/cloud-rehearsal: a rehearsal of iterate Cloud's sign-up, with its agent's rows and tools and a fake Cloudflare\\n\\nCopied from iterate/iterate-config apps/cloud.\\n\\nVia: scripts/cloud-rehearsal/install.ts", parent: tip, changes }); -const outcome = await itx.waitForEvent({ type: ["events.iterate.com/mind/worker-updated", "events.iterate.com/mind/worker-update-failed"], payload: { commitOid }, afterOffset: 0, timeoutMs: 120000 }); +// An outcome names its commit in payload.trigger.commitOid, and a payload filter compares +// top-level fields alone: take each outcome after the head until one names this commit. +let outcome; +let after = head; +do { + outcome = await itx.waitForEvent({ type: ["events.iterate.com/mind/worker-updated", "events.iterate.com/mind/worker-update-failed"], afterOffset: after, timeoutMs: 120000 }); + after = outcome.offset; +} while (outcome.payload.trigger?.commitOid !== commitOid); if (outcome.payload.error) throw new Error(outcome.payload.error); return "Installed in commit " + commitOid + ": " + changes.map((change) => change.path).join(", ");`;