Skip to content

fix(test-as-self): harness never ran — wrong init invocation + teardown env#662

Open
JKHeadley wants to merge 1 commit into
mainfrom
echo/test-as-self-init-fix
Open

fix(test-as-self): harness never ran — wrong init invocation + teardown env#662
JKHeadley wants to merge 1 commit into
mainfrom
echo/test-as-self-init-fix

Conversation

@JKHeadley

Copy link
Copy Markdown
Owner

What

The instar test-as-self throwaway-deploy harness (Track F) was shipped but never actually run end-to-end — so it failed at step 3 on every invocation. Found by running the never-executed "feature alive" validation. Two bugs in src/commands/test-as-self.ts:

  1. Wrong init invocation — step 3 called init --standalone --dir <target>, but init --standalone requires a positional name and routes to ~/.instar/agents/<name> (ignoring --dir). Result: init exited with "A name is required for standalone agents" → VERDICT: FAIL (step 3) every run.
  2. Teardown's server stop refused — it inherited the caller's INSTAR_SESSION_ID, tripping the "don't start/stop/restart the server from inside a managed session" guard. Step 4's spawn already stripped those markers; teardown didn't.

Fix

Two pure, exported, unit-tested helpers:

  • buildInitArgs(target)['init', '--dir', target] — non-standalone init honors --dir, allocates a port, writes <target>/.instar/config.json. Verified live: init --dir /tmp/fresh created a runnable home with port 4041.
  • sanitizedSpawnEnv(env) → env minus INSTAR_SESSION_ID/INSTAR_JOB_SLUG. Used by the step-4 spawn (replacing the inline delete) AND the teardown's server stop.

No flags added/removed; init/server untouched — only how the harness invokes them.

Tests

tests/unit/testAsSelfInit.test.ts (5): buildInitArgs uses init --dir and never --standalone; sanitizedSpawnEnv strips both markers, preserves all other vars, doesn't mutate input. tsc --noEmit clean; full pre-commit + pre-push ship-gate green.

Scope

Independent of #661 (touches only test-as-self.ts); keeps #661 single-purpose. This makes the Track-F harness actually work — a prerequisite for the Track-E two-machine bring-up. Step-4 server-start remains subject to the usual node-ABI matching (a runtime property, orthogonal to this fix). Opened for review (not auto-merged).

🤖 Generated with Claude Code

…wn env

The Track-F throwaway-deploy harness was shipped but never executed end-to-end,
so it failed at step 3 every run: it called `init --standalone --dir <target>`,
but `init --standalone` requires a positional NAME and routes to
~/.instar/agents/<name> (ignores --dir). And teardown's `server stop` inherited
INSTAR_SESSION_ID → tripped the "don't manage the server from inside a managed
session" guard.

Fix: two pure unit-tested helpers — buildInitArgs(target)=['init','--dir',target]
(non-standalone init honors --dir, allocates a port; verified live) and
sanitizedSpawnEnv(env) (strips INSTAR_SESSION_ID/INSTAR_JOB_SLUG), used by the
step-4 spawn AND the teardown server-stop. No flags changed; init/server untouched.

Spec: MULTI-MACHINE-BOOTSTRAP-ROBUSTNESS Track F. Tests: testAsSelfInit.test.ts (5); tsc clean.

(orphan-deferral override: the gate flagged a pre-existing, non-prescriptive
"deferred" at spec line 27 describing the already-resolved Playwright→Bot-API
substitution — not introduced by this change.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 1, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
instar Ready Ready Preview, Comment Jun 1, 2026 7:58am

Request Review

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