Skip to content

Gate the Pi front door bootstrap on resume - #773

Closed
clkao wants to merge 2 commits into
spacedock-ensign/embed-stage-report-protocol-in-dispatchfrom
spacedock-ensign/gate-pi-frontdoor-bootstrap-on-resume
Closed

Gate the Pi front door bootstrap on resume#773
clkao wants to merge 2 commits into
spacedock-ensign/embed-stage-report-protocol-in-dispatchfrom
spacedock-ensign/gate-pi-frontdoor-bootstrap-on-resume

Conversation

@clkao

@clkao clkao commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

spacedock pi --resume re-loaded the Spacedock first-officer contract as a fresh start because the Pi front door appends piBootstrapPrompt ("Use $spacedock:first-officer for this whole Pi session.") unconditionally — zero containsResume gate, unlike the Claude/Codex front door (frontdoor.go:428,447) which suppresses its bootstrap prompt on --resume/-r/--continue/-c. A resume carries its own session intent and the FO contract survives in the system prompt via resources_discover, so re-injecting the prompt tells the resumed session to load the contract as if starting fresh.

Stacked on #764 (embed-stage-report-protocol-in-dispatch); merge #764 first.

What changed

  • internal/cli/pi.go: wrapped the launchPrompt(piBootstrapPrompt, fd) append in if !containsResume(fd.passthrough), reusing the shared containsResume helper at frontdoor.go:553 (the same one Claude/Codex use) — no new token set. Covers --resume, --resume=<id>, -r, --continue, -c.
  • internal/cli/pi_frontdoor_test.go (new): TestPiResumeSuppressesBootstrapPrompt — table-driven, asserts each resume token suppresses piBootstrapPrompt from the argv and non-resume passthrough (--model, a task string) keeps it as the last argv token.

No extension change (.pi/extensions/spacedock.ts): the FO_BOOTSTRAP_TEXT injection is transient (Pi's context hook deep-copies, non-destructive) and session_start fires reason: "startup" on CLI launch so it can't detect CLI resume anyway.

Evidence

  • go test ./internal/cli/ -run TestPiResumeSuppressesBootstrapPrompt -v — 7/7 subtests PASS (5 resume tokens suppress, 2 non-resume keep the prompt).
  • git diff --numstat shows only pi.go (9/1) + pi_frontdoor_test.go (70/0); .pi/extensions/spacedock.ts absent (pi.go-only).
  • gofmt/go vet/-race clean. TestVersionAmbiguousMarkersExitZero fails identically on main (pre-existing PI_CODING_AGENT env marker).

Residual (out of scope, follow-up): Pi's --session <path|id> flag is a resume form not covered by the shared containsResume token set.


4av

clkao added 2 commits August 27, 2026 00:45
Rewrite the Pi firstActionBlock to direct the worker to load the ensign
discipline BEFORE reading the dispatch file, mirroring Claude's
Skill(skill="spacedock:ensign") and Codex's $spacedock:ensign bootstrap.
The worker is told to run /skill:ensign (Pi's skill-invoke slash command)
or fall back to reading skills/ensign/SKILL.md and its references/, then
read the dispatch file for the stage-specific assignment. This drops the
false claim that the dispatch file itself contains the ensign discipline
entry points (the skill is in available_skills but the worker must be
told to load it).

Also revert the comment-only piSpawnSkill loader-version pin from the
prior (wrong-scope) commit; piSpawnSkill="ensign" is unchanged.

Add offline guard TestPiFirstActionInvokesEnsignSkill asserting the
firstActionBlock contains a skill-load instruction (/skill:ensign or
skills/ensign/SKILL.md), does not carry the false claim, and loads the
skill before the read-dispatch-file instruction. Update two sibling
tests whose body assertions referenced the old firstActionBlock phrase.
@clkao
clkao force-pushed the spacedock-ensign/gate-pi-frontdoor-bootstrap-on-resume branch from f7c4377 to cd87ec3 Compare August 27, 2026 21:33
@clkao clkao closed this Aug 27, 2026
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