Multiplayer agent harness for work.
Exercise runtime discovery and correct dev socket diagnostics (#1084)
Regan Bell5e13a3271758
diff --git a/.codex/skills/dev-instance/SKILL.md b/.codex/skills/dev-instance/SKILL.mdindex fb6d90cf1..fb421a47c 100644--- a/.codex/skills/dev-instance/SKILL.md+++ b/.codex/skills/dev-instance/SKILL.md@@ -45,10 +45,11 @@ heartbeat so slot reclaim can tell "actively in use" from "abandoned".**`up` only prints success after proving the bot is reachable**: the Slack socket must bethe app's _only_ connection (`num_connections == 1`, read from the hello frame) and — whenthe slot has a `CANARY_CHANNEL` — a posted canary message must arrive back over that same-socket. If another machine/worktree holds a connection to the app (the classic "boots LIVE-but deaf" failure), `up` detects it, flags the slot for 30 minutes, and auto-rotates to the-next one, reporting the thief's hello host. A canary that never returns on a clean socket-means a stale Slack app; `up` flags and rotates past that too.+socket. If Slack reports multiple connections, `up` flags the slot for 30 minutes and+auto-rotates to the next one. The count is a snapshot from the last hello frame, not+a continuously refreshed inventory. Its `debug_info.host` identifies Slack's server,+not another client's machine; it cannot locate a competing instance. A canary that+never returns leaves delivery unverified; `up` flags and rotates past that too.**Re-running `up` on a live instance is a reload, not a no-op**: it re-reads your shellenv, dev.env, and `.env`, diffs against what the children are running, and does a rolling@@ -185,20 +186,26 @@ port squatters, machine-wide token orphans, Docker daemon — and prints a rankewith a remedy per finding. `doctor --fix` applies the safe ones (child restarts).**Bot never replies to a DM (silent bot).** The new `up` catches the two big causes at-boot: another live connection to the same app (auto-rotates, names the thief's host) and a-stale Slack app whose events never arrive (canary fails → flags the slot and rotates). If-deafness appears mid-session, the 10s health probe logs `DEGRADED: num_connections=N` in-`supervisor.log` and the periodic canary flags delivery loss; `dev canary` gives you an-on-demand proof either way. `dev up --rotate` moves to a fresh slot.--For a slot flagged `canary-failed`, the app itself is stale and needs rebuilding (~5 min):-at api.slack.com **signed into the example workspace** (the dev console is+boot: multiple reported connections to the same app (flags the slot and auto-rotates)+and a Slack app whose events never arrive (canary fails → flags the slot and rotates).+Check local processes and other deployments before attributing a connection count to+a live competitor. After cleanup, reconnect to obtain a fresh hello count; rereading+health alone returns the previous snapshot. The 10s health probe logs+`DEGRADED: num_connections=N` in `supervisor.log` when it observes a count transition+above one, but cannot detect a new competitor while the hello snapshot is unchanged.+Periodic canaries can detect delivery loss; `dev canary` tests delivery on demand.+A successful canary does not establish exclusivity. `dev up --rotate` moves to a fresh slot.++For a slot flagged `canary-failed`, check networking, event subscriptions, permissions,+and competing connections first. If the app configuration needs rebuilding, use+api.slack.com **signed into the example workspace** (the dev console isper-workspace-identity — use "Sign in to another workspace" if it lists the wrong one):Create New App → From a manifest → paste `src/slack/manifest.json` (give it a unique`name` and bot `display_name`; old handles stay taken) → Install to Workspace → BasicInformation → App-Level Tokens → Generate with the `connections:write` scope. Write the Bottoken (`xoxb-…`) and app-level token (`xapp-…`) into `poolN.env`, delete `poolN.flag.json`,-then run `up` again. (If you own the existing app, just reinstalling it also works.)+then run `up` again to verify the replacement. Reinstalling an existing app may also+resolve configuration drift; verify delivery afterward.Two smaller gotchas: a freshly-created bot isn't in Slack's "New message" people search for aminute or two — open its DM deterministically via `conversations.open` (bot token + your userdiff --git a/scripts/dev/cli.ts b/scripts/dev/cli.tsindex 9c4e5ae5f..2ecc2c3ed 100644--- a/scripts/dev/cli.ts+++ b/scripts/dev/cli.ts@@ -403,12 +403,12 @@ async function cmdUp(): Promise<number> {{reason: "stolen",at: nowEpoch(),- detail: `num_connections=${result.numConnections} host=${result.helloHost ?? "?"}`,+ detail: `num_connections=${result.numConnections} slack_server=${result.helloHost ?? "?"}`,},store,);out(- `[!] slot ${slot} is STOLEN: ${result.numConnections} connections open to its Slack app (another machine/worktree holds one; hello host: ${result.helloHost ?? "?"}).`,+ `[!] slot ${slot}: Slack reported ${result.numConnections} connections at the last hello; exclusivity is unverified (Slack server: ${result.helloHost ?? "?"}, not a client host).`,);out(` flagged ${slot} for 30min and rotating to the next slot...`);excluded.add(slot);diff --git a/scripts/dev/commands/doctor.ts b/scripts/dev/commands/doctor.tsindex 7c760e855..956d5d936 100644--- a/scripts/dev/commands/doctor.ts+++ b/scripts/dev/commands/doctor.ts@@ -99,9 +99,11 @@ export async function runDoctor(opts: { json: boolean; fix: boolean; store: stridetail:conns === null? "num_connections unknown (introspection tap degraded)"- : `num_connections=${conns}${slack?.helloHost ? ` (hello host ${slack.helloHost})` : ""}`,+ : `num_connections=${conns} at last hello${slack?.helloHost ? ` (Slack server ${slack.helloHost})` : ""}`,remedy:- conns !== null && conns > 1 ? "another live connection is stealing events: dev up --rotate" : undefined,+ conns !== null && conns > 1+ ? "check for other instances; reconnect and verify with dev up --rotate"+ : undefined,});const canary = (await supervisorRequest(sock, "POST", "/canary", {}, 40_000)).body as {ok: boolean;diff --git a/scripts/dev/supervisor/main.ts b/scripts/dev/supervisor/main.tsindex cb36a74d0..0ac399604 100644--- a/scripts/dev/supervisor/main.ts+++ b/scripts/dev/supervisor/main.ts@@ -534,7 +534,7 @@ function startLoops(): void {}if ((slackHealth.numConnections ?? 1) > 1 && (lastSlackHealth?.numConnections ?? 1) <= 1) {log(- `DEGRADED: num_connections=${slackHealth.numConnections} -- another connection to this Slack app is stealing events (host: ${slackHealth.helloHost ?? "?"})`,+ `DEGRADED: num_connections=${slackHealth.numConnections} at last hello -- Slack socket exclusivity is unverified (Slack server: ${slackHealth.helloHost ?? "?"}, not a client host)`,);}lastSlackHealth = slackHealth;diff --git a/test/live-slack/scenarios.ts b/test/live-slack/scenarios.tsindex 653353004..0fb4badc6 100644--- a/test/live-slack/scenarios.ts+++ b/test/live-slack/scenarios.ts@@ -28,7 +28,7 @@ export const scenarios: Scenario[] = [const ch = await ctx.freshChannel();const marker = ctx.marker();const root = await ch.mention(- `Use the runtime tool to inspect your active runtime and available models, then switch to a different available Anthropic model for this task only. Keep the pi harness, set effort to auto and fastMode to false. After the handoff, inspect runtime again and calculate 17 × 23. Only after completing these steps, reply with the exact token ${marker}, your active model and the answer.`,+ `Can you switch your model to a different available Anthropic model for this request and then calculate 17 × 23? Keep using pi with automatic reasoning effort and fast mode off. Once you have switched, verify which model you are actually running on. Include ${marker}, that model and the answer in your final reply.`,);const reply = await ch.waitForBotReply(root, { match: new RegExp(marker), timeoutMs: 4 * 60_000 });assert.match(reply.text ?? "", /\b391\b/);