Skip to content

feat(showcase): fix --isolate slot picker (pinning, port probe, slot 0 reservation, bin/showcase slots) - #5543

Merged
jpr5 merged 5 commits into
mainfrom
fix/showcase-slot-picker
Jun 18, 2026
Merged

jpr5 merged 5 commits into
mainfrom
fix/showcase-slot-picker

Conversation

@jpr5

@jpr5 jpr5 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the --isolate slot picker in showcase/scripts/cli/_common.sh and adds a new bin/showcase slots inspector subcommand. Resolves five compounding bugs that made multi-agent local testing unreliable.

Bugs fixed

  1. SHOWCASE_ISO_SLOT=<N> env var was ignored. The picker walked 0→N regardless. Now: validates input (positive integer, 1 ≤ N ≤ 45, slot 0 rejected as base stack), tries exactly that slot, fails loudly on conflict.
  2. No port-probe before commit. Picker mkdir'd a slot dir without checking whether the slot's host ports were free. A slot whose dir was absent but whose ports were taken (foreign Docker project, host service like macOS AirPlay on 5000) was picked then failed at docker compose up. Now: lsof-probe every candidate port before committing the claim; rmdir + try next on conflict.
  3. Slot 8 / port 5000 collision on macOS. Base dashboard port 3200 + slot 8 offset +1800 = 5000, permanently bound by macOS Control Center's AirPlay Receiver. Shifted dashboard base port 3200 → 3210 across docker-compose.local.yml and showcase/harness/src/cli/*.ts so slot 8 → port 5010 (free).
  4. Slot ownership desync across 3+ independent owners. Picker checked only the dir; sweeper checked dir+pid+containers; neither checked foreign ports. New unified _slot_state returns all 4 axes (dir/pid/liveness/ports/offset/project); new bin/showcase slots exposes the state via table / --json / --free --brief filters.
  5. Parallel pre-claim deadlock dissolved by bugs 1+2+4 — per-session pinning via env var + accurate port-probe + atomic mkdir lock self-resolves contention.

Implementation

  • New helpers in _common.sh: _slot_offset_ports, _slot_liveness (extracted from sweeper), _slot_ports_free (with own-project docker-listener filter), _slot_state (composite axis report).
  • Rewritten _claim_isolate_slot: pinned-path (validate / try / die loudly) and auto-pick-path (1..MAX_SLOT, rmdir + skip on port-held). Slot 0 reserved with explicit die message.
  • ISOLATE_MAX_SLOT=45 centralized as a constant.
  • Dashboard host port shift 3200 → 3210 across 6 files (compose + 4 harness TS + comment updates).
  • New cmd-slots.sh plugin (auto-discovered by bin/showcase): default table, --json (JSONL), --free (filter to claimable slots), --brief (numeric IDs only).

Tests

Bats — 54/54 GREEN in showcase/scripts/__tests__/isolate.bats:

  • 12 pre-existing tests updated for slot-0-reservation contract (reap-evidence assertions preserved; only slot-number / port-offset expectations updated).
  • 11 new tests added:
    • lsof stub + foundation smoke (test #0)
    • Pinning behavior tests WIP: almost usable v0.1 #1-3 (success, live-die, validation incl. 0/foo/99)
    • Port-probe tests first working beta version #4-7 (stale-reap, _slot_offset_ports 8 → 5010 ≠ 5000, foreign-process skip, own-project no-skip)
    • Composite tests autosuggestions #8-10 (_slot_state 5 axes, bin/showcase slots output, concurrent claim distinct slots)
    • lsof-graceful test (insert edit text mvp #54): _slot_state emits ports=? when lsof is unavailable

Vitest — 17/17 GREEN in showcase/harness/src/cli/control-plane-run.test.ts (port-shift stub consistency).

Value-test (live local, plan §6 scenarios) — all 3 PASS:

  • Scenario A: On the test host Docker was holding slot 9's ports, so the picker correctly REFUSED SHOWCASE_ISO_SLOT=9 with per-port diagnostics (proving the fail-loud half of the contract). Re-ran with SHOWCASE_ISO_SLOT=15 (first free slot) and the pin was honored cleanly: ISOLATE_SLOT=15, OFFSET=3200. Both halves of the pin contract verified.
  • Scenario B: Slots 1-7 pre-occupied with live pids + Python listener on 127.0.0.1:5010 (slot 8's dashboard port) → picker logged "Slot N ports held" + "trying next" for each conflict, walked past 9..13 (Docker-held), and landed on slot 14 with OFFSET=3000. No silent collision.
  • Scenario C: bin/showcase slots matches reality: slot 0 → OFFSET=+0 PROJECT=showcase (base); pre-claimed slot 5 → DIR=present PID=<pid> LIVE=live PORTS=held OFFSET=+1200 PROJECT=showcase-iso5-test. --free --brief outputs only fully-claimable slot IDs (44 in this run, slot 5 excluded).

Code review

Full 7-agent cr-loop with pr-review-toolkit reviewers (Round 1 + confirmation round). 4 subject-scope load-bearing findings fixed:

  • _reap_isolate_slot arg shape in pinned-path retry
  • _slot_state base-stack offset (slot 0 → +0, not +200)
  • TESTING.md item 8/9 column-name accuracy (matches actual SLOT DIR PID LIVE PORTS OFFSET PROJECT header)
  • bin/showcase slots lsof-graceful degradation (inspector reports PORTS=? instead of dying when lsof is missing)

Plus 1 trivial comment-phrasing fix (race-comment wording). ~50 pre-existing harness/compose findings partitioned out-of-subject and deferred to follow-up PRs (see below). Procedure 3 bucket-(c) promotion audit returned zero PROMOTE_TO_A items — full convergence.

Follow-up PRs (out-of-subject, separate subjects)

These coherent subjects surfaced during CR but belong to distinct PRs (the diff merely brushed against them for the 3200→3210 shift):

  • d1 — Harness up() / doctor should health-check harness-control-plane (port 8081). _slot_offset_ports includes 8081; INFRA_PORTS in doctor.ts / lifecycle.ts does not.
  • d2 — doctor.ts port + image diagnostic loud-failure pass (checkStaleImages, checkPorts, isPortListening, checkDepotInterception swallow errors).
  • d3 — lifecycle.ts error-surfacing pass (broad catches in loadPortsFile, isRunning, compose, healthCheck, diffLogs, etc.).
  • d4 — docker-compose.local.yml healthcheck error visibility (.catch(() => process.exit(1)) swallows; dashboard / returns 307).
  • d5 — apply_isolation Python rewriter fail-loud pass (no re.subn count checks, hand-rolled YAML demos parser).
  • d6 — Centralize infra port literals (currently duplicated in 4 places).
  • d7 — lifecycle.ts:11-13 stale ops/ path comment (file lives at harness/).
  • d8 — cmd_slots --json pid field typing (string vs number) — settle when first JSON consumer appears.

Test plan

  • bats showcase/scripts/__tests__/isolate.bats → 54/0
  • pnpm vitest run src/cli/control-plane-run.test.ts (in showcase/harness/) → 17/0
  • pnpm exec tsc --noEmit (in showcase/harness/) → clean
  • oxfmt --check showcase/ → clean
  • docker compose -f showcase/docker-compose.local.yml config → valid YAML
  • Local value-test scenarios A/B/C from plan §6 → PASS

jpr5 added 5 commits June 17, 2026 16:44
… probe, and slot 0 reservation

- Centralize ISOLATE_MAX_SLOT=45 constant
- Add helpers: _slot_offset_ports, _slot_liveness, _slot_ports_free, _slot_state
- Rewrite _claim_isolate_slot to reserve slot 0, honor SHOWCASE_ISO_SLOT, port-probe via lsof
- Document benign mkdir/rmdir race in auto-pick path
- Shift dashboard host port 3200 → 3210 in apply_isolation / restore_isolation
- Pass slot entry path + project to _reap_isolate_slot in pinned-path retry
- _slot_state reports offset=0 for the base stack (slot 0)
- _slot_state degrades gracefully to ports=? when lsof is missing
- docker-compose.local.yml: host port mapping
- harness/src/cli/doctor.ts: dashboard probe
- harness/src/cli/lifecycle.ts: dashboard URL
- harness/src/cli/config.ts: default port
- harness/src/cli/control-plane-run.test.ts: test expectations
…command, and lsof-graceful inspector

- Update 12 slot-0-assumption tests for slot-0 reservation contract
- Add lsof stub and foundation smoke for isolate.bats
- Tests #1-#3: slot pinning behavior
- Tests #4-#7: port-probe and stale-reap behavior
- Tests #8-#10: slot state, slots subcommand, concurrent claim
- New test for _slot_state ports=? when lsof unavailable
…n in TESTING.md

- Update items 8/9 for slot pinning and conflict detection
- Correct item 8/9 column names to match bin/showcase slots header
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat-with-your-data Ready Ready Preview, Comment Jun 18, 2026 5:03pm
docs Ready Ready Preview, Comment Jun 18, 2026 5:03pm
form-filling Ready Ready Preview, Comment Jun 18, 2026 5:03pm
research-canvas Ready Ready Preview, Comment Jun 18, 2026 5:03pm
travel Ready Ready Preview, Comment Jun 18, 2026 5:03pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📣 Social Copy Generator

Generate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.

  • Generate social media copies

@github-actions

Copy link
Copy Markdown
Contributor

Production Digest-Pinning Audit

12 of 41 service(s) not digest-pinned.

Service Source.image Status
starter-adk ghcr.io/copilotkit/starter-adk:latest mutable-tag
starter-agno ghcr.io/copilotkit/starter-agno:latest mutable-tag
starter-crewai-crews ghcr.io/copilotkit/starter-crewai-crews:latest mutable-tag
starter-langgraph-fastapi ghcr.io/copilotkit/starter-langgraph-fastapi:latest mutable-tag
starter-langgraph-js ghcr.io/copilotkit/starter-langgraph-js:latest mutable-tag
starter-langgraph-python ghcr.io/copilotkit/starter-langgraph-python:latest mutable-tag
starter-llamaindex ghcr.io/copilotkit/starter-llamaindex:latest mutable-tag
starter-mastra ghcr.io/copilotkit/starter-mastra:latest mutable-tag
starter-ms-agent-framework-dotnet ghcr.io/copilotkit/starter-ms-agent-framework-dotnet:latest mutable-tag
starter-ms-agent-framework-python ghcr.io/copilotkit/starter-ms-agent-framework-python:latest mutable-tag
starter-pydantic-ai ghcr.io/copilotkit/starter-pydantic-ai:latest mutable-tag
starter-strands-python ghcr.io/copilotkit/starter-strands-python:latest mutable-tag

Run 2026-06-18 10:04:31 PDT — 12 finding(s).

@jpr5
jpr5 merged commit baf355e into main Jun 18, 2026
30 checks passed
@jpr5
jpr5 deleted the fix/showcase-slot-picker branch June 18, 2026 17:25
jpr5 added a commit that referenced this pull request Jun 18, 2026
…_ISO_SLOT (#5547)

## Summary

Follow-up to #5543. Adds `--isolate=<N>` CLI form so users don't need to
set `SHOWCASE_ISO_SLOT=<N>` as an env var prefix.

## Before

```
SHOWCASE_ISO_SLOT=9 bin/showcase test agno --d5 --isolate
```

## After (both forms work)

```
bin/showcase test agno --d5 --isolate=9
# OR
SHOWCASE_ISO_SLOT=9 bin/showcase test agno --d5 --isolate
```

## Implementation

~10 lines in `showcase/scripts/cli/cmd-test.sh` arg parser: a new
`--isolate=*` case sets `use_isolate=true` and exports
`SHOWCASE_ISO_SLOT=<N>`. The existing picker (`_claim_isolate_slot` in
`_common.sh`) handles all validation, slot-0 rejection, port-probe,
liveness, etc. — no logic duplication.

Help text in `cmd-test.sh` and the existing `SHOWCASE_ISO_SLOT`
references in `showcase/TESTING.md` now show both forms as equivalent.

## Tests

Four new bats tests in `showcase/scripts/__tests__/isolate.bats`:

- `--isolate=<N> arg form exports SHOWCASE_ISO_SLOT and pins the slot
through the picker` — replays the parser branch, verifies env export +
picker pinning.
- `--isolate=0 arg form drives the picker's reserved-slot rejection` —
proves `--isolate=0` flows through the same `slot 0 is reserved` die as
the env-var form.
- `--isolate=99 arg form drives the picker's out-of-range rejection` —
proves `--isolate=99` flows through the same `exceeds
ISOLATE_MAX_SLOT=45` die as the env-var form.
- `cmd-test.sh --isolate=<N> actually wires the arg through to
SHOWCASE_ISO_SLOT` — drift guard that sources the REAL `cmd-test.sh`,
stubs `apply_isolation`, and snapshots `SHOWCASE_ISO_SLOT` to catch any
future regression of the parser branch.

All 58 bats tests in `isolate.bats` pass locally (54 pre-existing + 4
new).

## Docs

`showcase/TESTING.md` items 8 and 9 updated to show both forms.
Repo-wide grep confirmed TESTING.md is the only doc that references
`SHOWCASE_ISO_SLOT`.

## Test plan

- [x] `bats showcase/scripts/__tests__/isolate.bats` → 58/58 green
- [x] `--isolate=9` → `SHOWCASE_ISO_SLOT` exported, slot 9 claimed
- [x] `--isolate=0` → picker dies "slot 0 is reserved"
- [x] `--isolate=99` → picker dies "exceeds ISOLATE_MAX_SLOT=45"
- [x] `shellcheck showcase/scripts/cli/cmd-test.sh` → no new warnings
(only the pre-existing SC2034 on `CMD_TEST_DESC`, consumed by dispatcher
parallel arrays)
- [x] `oxfmt --check showcase/` → clean

This branch was successfully deployed

5 active deployments
Preview – docs — 78231669 Deployed Jun 17, 2026 by vercel[bot]
Preview – research-canvas — 78231669 Deployed Jun 17, 2026 by vercel[bot]
Preview – travel — 78231669 Deployed Jun 17, 2026 by vercel[bot]
Preview – chat-with-your-data — 78231669 Deployed Jun 17, 2026 by vercel[bot]
Preview – form-filling — 78231669 Deployed Jun 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant