Skip to content

fix(pi): confirm the session registered its MCP handoff - #22400

Closed
leonlaiyc wants to merge 2 commits into
kirodotdev:mainfrom
leonlaiyc:claude/pi-mcp-registration-19774
Closed

leonlaiyc wants to merge 2 commits into
kirodotdev:mainfrom
leonlaiyc:claude/pi-mcp-registration-19774

Conversation

@leonlaiyc

@leonlaiyc leonlaiyc commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A pi session's MCP report says, before its first prompt, which handed-off Crew servers its own pi process confirmed it did not register (failed, with the cause it named) and which nobody confirmed either way (unconfirmed, never failed), instead of listing them all available.

On pi, Crew's MCP servers reach the session only through the gate extension's per-session handoff file (#19760), because pi-acp drops the session/new array. The host never confirmed that registration happened. If the handoff file is missing or unreadable, or carries the wrong nonce, the extension registers nothing, and the session runs with none of Crew's tools while the card says they are available. The routing read-back cannot answer this: it runs a separate pi child without the handoff, because it must not start Crew's servers.

Why it matters

Every Crew capability on pi (send_message, memory, cron, crew tools) is an MCP tool. A silent registration failure leaves the agent without them while the dashboard claims they are there, so the user sees an agent that "ignores" its tools with no named cause. Only the session's own process can say what it registered.

Not a goal

What changed (motivation → approach → change)

Root cause. Registration happens inside the pi process that pi-acp starts during session/new. Nothing travelled back from that process to the host.

Why a receipt, beside the mount check. pi is in ACP_BACKENDS_SESSION_MCP_ARRAY, so mcp_mount_check already runs for every pi session. It answers a narrower question, and it answers it later:

  • It checks only pooled broker stubs. _stub_server returns nothing for an element whose argv lacks the broker's STUB_MODULE. pi's handoff is session._session_mcp_servers() (the agent's own spec servers, exec'd directly or remote) plus _pooled_mcp_servers() (harness/pi.py, resolve_spawn). The mount check cannot see the first half, so the receipt is the only signal for those servers.
  • It cannot say why a stub never arrived. A handoff that never opened and a name shadowed by pi's mcp.json both look like "not mounted".
  • It reports up to MOUNT_WINDOW_SECS (30 s) after the session opens. A subagent reads the report once, at spawn (_warn_unusable_mcp_servers), so it never sees that row. The receipt is read before the first prompt.

The two compose: the receipt records first, and record_not_mounted leaves any server already in a bucket alone. An unconfirmed server is recorded nowhere, so a later mount-check row or frame for it is recorded as usual.

Ordering is read from source, not live. In @earendil-works/pi-coding-agent 0.99.2 (the floor PI_MIN_VERSION), RPC mode awaits bindExtensions (modes/rpc/rpc-mode.js:289). That awaits every session_start handler (core/agent-session.js:2556, core/extensions/runner.js:813) before it attaches its stdin reader (rpc-mode.js:644). pi-acp's session create awaits get_state on that stdin before it returns. No live run pins this, and PI_MIN_VERSION is a floor rather than a pin. So a missing receipt proves nothing, and no outcome refuses the session.

Three outcomes per handed-off server. The failed bucket is final to every reader, not only the card. _spawn_mcp_notice tells a subagent "will not appear later -- do not retry it", and task_executor.py and dashboard/handlers/hooks.py print it as "MCP servers unusable in this run". So only a confirmed refusal goes there:

Receipt says Recorded
server registered nothing; its own frames and the mount check speak for it
handoff none / unreadable / malformed / unsealed (seal does not open under this session's nonce and key) every server failed, reason naming that handoff cause, never mcp.json
per-server cause mcp_json / mcp_json_unreadable / refused / replaced that server failed, reason naming that cause
no scratch window, no valid receipt, or silent on a server a WARNING log naming the cause, and nothing on the report; the card shows it as not reported

Change.

  • kiro_crew_tool_gate.ts: readMcpHandoff returns a status beside the servers. The extension tracks a cause per shadowed name and writes a version-2 receipt: {marker: 2, nonce, handoff, registered, unregistered: {name: cause}}. It still uses mode 0600 and exclusive create, in the session's scratch window. Gating behaviour is unchanged. PI_GATE_EXTENSION_SHA256 updated.
  • acp/mcp_session_report.py: a new unregistered_omitted count for failed rows past the cap, kept apart from pruned_omitted ("left out as unstartable"), which these are not, and named in problem_summary and payload(). No other report field is added: an unconfirmed outcome gets no bucket, because nothing outside tests would read one (First Principles on 5624fea754), and the card already renders a server in no bucket as no_report.
  • acp/pi_mcp_registration.py: read_registration validates the v2 shape. A wrong version, nonce, status or cause, a non-string name, or a name both registered and unregistered all read as unknown. The receipt is removed either way. verify_registration applies the table above and logs one warning per outcome.
  • harness/pi.py: apply_spawn_env points KIROCREW_PI_MCP_RECEIPT at a nonce-named file in the session's scratch window, dropping an inherited value first.
  • client_start._initialize_session calls it and discards the handoff in a finally. client_mcp_array._republish_pi_mcp_handoff clears the previous child's receipt on a load-to-new retry.
  • harness-parity.md documents the receipt, its statuses and causes, the three outcomes and their readers, and what it adds beyond the mount check.

The frontend is unchanged. A server in no bucket already renders as no_report on the card, which is the honest state for an unconfirmed one.

Backwards compatibility

Compatible: no pi session is refused, and the report payload only gains one key, unregistered_omitted. Writer sweep on origin/main @ b92a9c3: the receipt has exactly one writer, the sealed gate extension shipped in this same PR and verified by digest at every spawn. Sessions with no handed-off servers, and every non-pi harness, are unaffected.

Reader: src/kiro_crew/acp/client_start.py:_initialize_session -- chat, cron, subagent, app, crew page (every pi session start) -- every session opens as before, confirmed or not; test_session_start_opens_once_the_child_confirms, test_session_start_without_a_receipt_opens_and_reports_before_the_first_prompt
Reader: src/kiro_crew/subagent_manager/run.py:_warn_unusable_mcp_servers / _spawn_mcp_notice -- subagent -- an unconfirmed server never reaches the "do not retry" notice; a confirmed refusal does; test_unconfirmed_never_reaches_an_unusable_reader, test_a_confirmed_refusal_reaches_the_subagent_notice
Reader: src/kiro_crew/agent_sdk/mcp_problems.py:session_mcp_problems (task_executor.py, dashboard/handlers/hooks.py) -- task, webhook -- silent for unconfirmed, names a confirmed refusal; same two tests
Reader: src/kiro_crew/acp/mcp_mount_check.py:run_mount_check -- every session-array harness -- skips a server already in a bucket; an unconfirmed server is in none, so its row is recorded as before
Reader: website/src/pages/chat/McpToolsPanel.tsx -- chat MCP card -- ignores the new key; an unconfirmed server renders no_report, a confirmed refusal renders failed with its cause

Tests

  • test/test_pi_mcp_registration.py (rewritten, 30 cases):
    • registered: a full receipt records nothing, sends no request, and is removed.
    • partial registration: one row per cause (mcp_json, mcp_json_unreadable, refused, replaced). Only the unregistered server is failed, with that cause's reason.
    • confirmed zero registration: every server failed with its cause.
    • handoff never opened (none, unreadable, malformed, unsealed): every server failed with that handoff reason, and no reason mentions mcp.json.
    • report limits: 65 refused servers fill 64 failed rows. unregistered_omitted == 1 while a pre-existing pruned_omitted == 2 stays 2, and the summary carries both "+N" clauses.
    • receipt missing or invalid: a v1 receipt, a non-list, an unknown status, an unknown cause, a name both registered and unregistered, a non-string name, a non-object, unparseable JSON, another nonce, or no receipt at all. Each gives no failed row, no unconfirmed field in the payload, a warning naming no valid receipt, and the receipt removed.
    • silent receipt: a valid receipt that omits a server records no row for it and warns that the receipt does not account for it.
    • no scratch window: no row, and a warning naming no scratch window.
    • downstream readers: with only unconfirmed servers, problem_summary() (with and without reasons), session_mcp_problems, _warn_unusable_mcp_servers and _spawn_mcp_notice are all empty. A confirmed refusal reaches the subagent notice with just that server's name.
    • session retry / load: a load-to-new retry deletes the previous child's receipt before republishing. _initialize_session opens with or without a receipt and removes the handoff either way.
    • the spawn env names the allocated scratch window, not an inherited value.
  • test/test_pi_gate_extension_mcp.py: the real .ts runs under Node 22.23 and writes the v2 receipt:
    • registered for a clean handoff;
    • unregistered: {kirocrew-core: mcp_json} for a shadow, and mcp_json_unreadable for a broken mcp.json;
    • handoff: unsealed with empty causes for another key or nonce;
    • handoff: malformed for a non-handoff file.
  • test/test_mcp_session_report.py, test/test_mcp_session_report_wiring.py: exact-payload pins gain the four new keys.
  • Negative control: I made the unconfirmed path write failed rows (the previous head's behaviour) and 13 tests went red, including test_unconfirmed_never_reaches_an_unusable_reader, whose failure shows "failed to start: kirocrew-core (...)" reaching the subagent reader.

Local gates on 2f7e92b794: black, isort, flake8, mypy (changed modules), subprocess-encoding, comment-history, brand, file-line cap (0 failures), test_flake_pattern_ratchet.py (60 passed). Related suites on 5624fea754 (test_acp_pi_backend*.py, test_acp_pi_crew_tools.py, test_pi_*.py, test_subagent_mcp_report_visibility.py, test_mcp_session_report*.py, test_acp_mcp_startable.py): 376 passed, 13 skipped; on 2f7e92b794 the registration, report, subagent-notice and extension files: 151 passed. check_harness_parity.py against this branch's base reports ACP_BACKENDS_MEMBER_CAPABILITIES [claude]: allowlisted but now proven, an entry this diff does not touch.

Manual verification

Not performed: pi and pi-acp are not installed on the verification host, so no live pi-acp session/new or session/load was driven, and none is claimed. The receipt ordering is a reading of the published pi-acp@0.0.34 and @earendil-works/pi-coding-agent@0.99.2 sources (line references above). The design does not depend on it: if a pi version answers before session_start finishes, the cost is servers shown unconfirmed in the report and a warning in the log. No failed row, no "do not retry" subagent notice, no refused session. The extension's receipt writing is exercised by the real .ts under Node in test_pi_gate_extension_mcp.py, which is not a pi run.

Related Issues

Closes #19774
Builds on #19760 / #19761.

Pattern harvest

Rule candidate: review-prompt
Pattern: an "unknown" outcome recorded in a bucket whose other readers treat membership as final (here the MCP report's failed bucket, read by the subagent "do not retry" notice). Before adding a row to a shared status bucket, enumerate every reader of that bucket, not only the UI that motivated the change.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

🤖 Generated with Claude Code

@leonlaiyc
leonlaiyc requested review from a team and KiroCrewCaptain as code owners October 20, 2026 04:10
@leonlaiyc
leonlaiyc requested a review from CrysisDeu October 20, 2026 04:11
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 2f7e92b794df5826c530309a684630643a5ec447 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 2f7e92b794df5826c530309a684630643a5ec447 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check one live pi 0.99.2 session to confirm the receipt exists before session/new returns. If it doesn't, every session logs "unconfirmed" and the feature does nothing, with no error.

[DESIGN-REVIEWED] 2f7e92b

Description read

[DESCRIPTION-READ] 30da85fb21f8c58e7ede87d16fa16d020f02d32a3cecafd259baa56e945195df

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — 🟡 CONCERNS

Premise-level review of 2f7e92b794df5826c530309a684630643a5ec447 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The defect has no evidence behind it, and the description contradicts itself: the Goal says servers are listed "available", but it also says unreported servers already render no_report.

Not justified as shipped

  • Item 1 — inherited: the defect is asserted ("the card says they are available") with no linked issue or base reproduction, yet the description also says "A server in no bucket already renders as no_report". On base, a handoff that registered nothing already shows no_report, and the mount check fails its stubs after 30 s. What is actually missing is the named cause and the spawn-time reading.
    Clears when: a linked issue or a base reproduction shows a pi server listed as started when it was not registered, or the Goal is corrected by a human.
  • Item 4 — oversized: unregistered_omitted has 0 non-test payload consumers (grepped _omitted in website/src/pages/chat: only no_tools_omitted is read). Its one consumer is summary text that only appears past 64 refused pi servers. record_not_mounted, the closest sibling, drops overflow without a counter.
    Subtraction: delete unregistered_omitted, record_unregistered_omitted, its payload key and its summary clause, and let _record_failed drop overflow the way record_not_mounted does.
    Clears when: the counter is removed, or a consumer that reads the payload key is counted.

What this change ships

Inventory (6 items) — 4 justified

Intent: when pi did not register Crew's MCP servers, say so with the cause before the first prompt. This is a FIX.

  1. The MCP card names each server pi confirmed it refused, with the cause — inherited
  2. A handoff that did not load (none, unreadable, malformed, unsealed) marks every handed-off server failed with that cause — justified
  3. An unconfirmed server only gets a warning log; it stays no_report — justified
  4. A new report key unregistered_omitted plus a summary clause — oversized
  5. The gate extension writes a receipt file into scratch, pointed to by a new KIROCREW_PI_MCP_RECEIPT env var — justified
  6. A load-to-new retry clears the previous child's receipt — justified

[FIRST-PRINCIPLES-REVIEWED] 2f7e92b

Description read

[DESCRIPTION-READ] 5e8f28ec12b973fc776a1b799c76f09d66e118476c39ab1a84747ce8aad8a19c

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 2f7e92b794df5826c530309a684630643a5ec447 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 2f7e92b

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 2f7e92b794df5826c530309a684630643a5ec447 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2f7e92b

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 20, 2026
@leonlaiyc

Copy link
Copy Markdown
Contributor Author

Pushed c2d235d0cd and edited the Goal: line, which the operator directed. Reason: Design and First Principles both blocked the fail-closed refusal on 81d342cb11, because the receipt-before-session/new ordering was read from source and never run live. No pi/pi-acp install was available for a legitimate live run, so this takes Design's other clearing condition: the missing-receipt path no longer refuses. The goal said "refused before its first prompt", which no longer matches the code. The new wording is still inside #19774's acceptance criterion ("reported or refused before its first prompt").

What changed:

  • No outcome refuses the session. Missing/invalid receipt → every handed-off server failed as unconfirmed. No scratch window → its own cause (Opus advisory 1). Valid receipt → each server it omits failed as unregistered.
  • GPT BLOCK: rows the 64-row failed bucket rejects are counted into pruned_omitted through record_pruned_omitted. Regression test: 1 registered + 65 shadowed → 64 rows, pruned_omitted 2 → 3, "+3 more" in problem_summary().
  • Opus advisory 2 (transient/user_worded): moot, because no AcpError is raised any more, so there's no respawn and no generic channel reply.

Live pi evidence: none. The description says so under Manual verification, and the design no longer depends on it.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 20, 2026
@leonlaiyc
leonlaiyc force-pushed the claude/pi-mcp-registration-19774 branch from c2d235d to 5624fea Compare October 20, 2026 13:22
@leonlaiyc

Copy link
Copy Markdown
Contributor Author

Pushed 5624fea754 (second commit replaced; still two commits). It answers the CONCERNS on c2d235d0cd, and the Goal line was edited to match, at the contributor's explicit request.

Why the Goal changed. The old Goal promised "each unconfirmed server as failed". Design Review showed that recording an unknown in the failed bucket is the harm this PR exists to remove. _spawn_mcp_notice turns a failed row into "do not retry it" for a subagent, and the webhook and task paths print it as "unusable". The new Goal keeps the same outcome (the report names the cause before the first prompt) but separates confirmed-unregistered (failed) from unconfirmed (never failed). ## Why it matters and ## Not a goal are unchanged.

Clearing conditions, one by one

  • Design Review ("unconfirmed rows stay off the failed bucket that _spawn_mcp_notice and session_mcp_problems read"): unconfirmed servers now go to a new unconfirmed report bucket that problem_summary omits. test_unconfirmed_never_reaches_an_unusable_reader pins all four readers empty. Routing that path back to record_pruned turns it red, along with two others.
  • First Principles, Item 3 (handoff failure reported with the mcp.json reason): the extension now writes the handoff status (none / unreadable / malformed / unsealed) and a per-server cause. A handoff that never opened gets its own reason. test_a_handoff_the_extension_could_not_load_is_not_blamed_on_mcp_json covers the host side; the real .ts under Node covers the extension side (handoff: unsealed, empty causes).
  • First Principles, Item 1 (duplicate of mcp_mount_check): its clearing condition was "some handed-off server isn't a broker stub". _stub_server returns nothing unless the element's argv carries STUB_MODULE. pi's handoff is _session_mcp_servers() (the agent's own spec servers, exec'd directly or remote) plus _pooled_mcp_servers(), so the first half is invisible to the mount check. It also reports up to 30 s after open, after a subagent's one spawn-time read. The two compose: a mount-check row moves an unconfirmed server to failed (test_later_evidence_moves_a_server_out_of_unconfirmed).

Not claimed. No live pi-acp session/new or session/load was run, because pi isn't installed on the verification host. If the source-read ordering is wrong, the cost is now an unconfirmed row and a log warning. No failed row, no subagent notice, no refused session.

Previous head's backend reds. These are not from this diff:

@leonlaiyc
leonlaiyc force-pushed the claude/pi-mcp-registration-19774 branch from 5624fea to 2f7e92b Compare October 20, 2026 14:17
@leonlaiyc

Copy link
Copy Markdown
Contributor Author

Pushed 2f7e92b794 (still two commits), answering the First Principles BLOCK on 5624fea754.

Item 2 (zero consumers): I took the clearing condition as written. The unconfirmed bucket, its three fields, record_unconfirmed, the _record move-out hunk and the two reason strings are gone. An unconfirmed outcome is now a WARNING log naming the cause (no scratch window, no valid receipt, or "receipt does not account for N"), and nothing on the report. The card already renders a server in no bucket as no_report. Confirmed refusals still get failed rows with their cause. unregistered_omitted (item 3, judged justified) stays.

Design Review's condition still holds: nothing unconfirmed reaches the failed bucket. As a negative control, writing failed rows on that path turns 13 tests red, including test_unconfirmed_never_reaches_an_unusable_reader.

Goal wording. The frozen Goal says the report names unconfirmed servers "unconfirmed, never failed". After this reduction the report does not name them at all; the log does. "Never failed" is unchanged. I have not edited the Goal again and will only if a maintainer asks.

Item 1 (no linked reproduction) is a fact about #19774, not about this diff. I can't produce a live pi reproduction on this host, and the description already says so.

Backend Tests (3.12, 2) on 5624fea754: its only failure is the test_facade_mirror_guards tree-scan 120 s timeout, open flake #22004 / #22007 / #22281.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 20, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at 2f7e92b: reserved for a human reviewer, and the current First Principles CONCERNS have no reply.

The PR changes the sealed pi tool-gate extension and re-pins its digest. The new extension adds handoff statuses, per-name causes, and a receipt file that the agent process writes into its scratch window (kiro_crew_tool_gate.ts L196-L343). Every pi spawn also gets a new env var (pi.py L938-L948). The repository's review policy reserves gate and sandbox-write changes for a human.

Open on this head:

  • First Principles Item 1: the Goal still says unconfirmed servers are named "unconfirmed, never failed". The code now puts nothing on the report for them, and the base already renders them no_report. Correct the Goal to match the code, or have a maintainer rule on it.
  • First Principles Item 4: unregistered_omitted (mcp_session_report.py L580-L582) has no non-test consumer. Remove it, or reply with the consumer.
  • Cross-Platform Portability and Screenshot Evidence ended CANCELLED on this head with no newer run. A re-run would settle them.

I found no concrete defect in the gate logic. The receipt is written with exclusive create and mode 0600, and a missing receipt only logs a warning.

— crew-pr-reviewer (r116)

@iamwhatever
iamwhatever enabled auto-merge (squash) October 21, 2026 21:14
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 21, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

This branch now conflicts with main. A recent merge changed client_mcp_array.py in the acp package, which this PR also edits. Could you rebase onto the current main and resolve the conflict? Thanks.

leonlaiyc and others added 2 commits November 1, 2026 19:51
On pi, Crew's MCP servers reach the session only through the gate
extension's handoff file. The host never confirmed the extension
registered them, so a missing, unreadable or wrong-nonce handoff left
a session with none of Crew's tools while the card said they were
available. The routing read-back cannot answer this: it is a separate
pi child that never sees the handoff.

The session's own pi process now answers it. During session_start the
extension writes the names it registered (minus any shadowed by pi's
own mcp.json) to a nonce-bound receipt in the session's scratch
window. pi finishes session_start handlers before it reads its first
RPC command, so the receipt exists before pi-acp answers session/new
or session/load. The host reads and removes it before the first
prompt, without submitting one:

- no handed-off servers: nothing to confirm
- receipt missing, malformed, for another nonce, naming a server not
  handed off, or confirming none: the session is refused
- confirming only some: each missing server is recorded as failed on
  the session's MCP report, so the card never lists it available

The handoff file is discarded whether or not the check passes, and a
load-to-new retry clears the previous child's receipt.

Closes kirodotdev#19774

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
That the receipt lands before pi-acp answers session/new or
session/load was read from the published sources, never pinned by a
live run, and PI_MIN_VERSION is a floor, not a pin. A missing receipt
therefore proves nothing about registration, and must not be recorded
where readers take it as final: the failed bucket feeds the subagent
spawn notice ("do not retry it") and the webhook and task "unusable"
lines, not only the MCP card.

Three outcomes per handed-off server:

- registered: the receipt names it; nothing is recorded
- confirmed unregistered: the receipt says the handoff did not load
  (none, unreadable, malformed, or a seal that does not open under
  this session's nonce), or names a per-server cause (pi's mcp.json,
  an unreadable mcp.json, a refused or replaced registration); a
  failed row naming that cause
- unconfirmed: no scratch window, no valid receipt, or a receipt
  silent on the server; a warning log naming the cause and nothing on
  the report, so the card shows the server as not reported

The extension writes a version-2 receipt carrying the handoff status
and per-server causes, so a handoff that never opened is no longer
reported as mcp.json shadowing. Failed rows past the bucket cap are
counted in unregistered_omitted, apart from pruned_omitted. No outcome
refuses the session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
auto-merge was automatically disabled November 1, 2026 11:59

Head branch was pushed to by a user without write access

@leonlaiyc
leonlaiyc force-pushed the claude/pi-mcp-registration-19774 branch from 2f7e92b to 79e53a9 Compare November 1, 2026 11:59
@leonlaiyc

Copy link
Copy Markdown
Contributor Author

Rebased onto main c1f8bdce61, as @bolichen97 asked. The new head is 79e53a9255, still two commits. Scope is unchanged, and the human-review HOLD still stands.

Conflicts, all additive:

  • acp/client_start.py: kept main's Copilot/Strands config discard after the PR's verify_registration → _discard_pi_mcp_handoff try/finally.
  • acp/harness/pi.py and acp/client_mcp_array.py: union of imports, and both main's _steer and the PR's _session attributes.
  • kiro_crew_tool_gate.ts: main's feat: move small Crew MCP servers' usage text into MCP instructions #24869 added MCP instructions to readMcpHandoff, and this PR added a handoff status. The merged function returns {status, servers, instructions?}, keeping main's openSeal(..., MCP_KEY_ENV) and instruction filter and the PR's status returns. before_agent_start reads handoffInstructions. PI_GATE_EXTENSION_SHA256 is re-pinned to 67848bf1… for the merged bytes.
  • harness-parity.md: main's steer paragraph, then this PR's receipt paragraph. Main had already moved Mid-turn steer out of the unavailable list, so the lead-in reads "One card line".
  • test_pi_gate_extension_mcp.py: _run takes both elements/base_prompt and handoff_bytes, and keeps main's instruction tests next to the PR's receipt-status tests.

Local checks (Windows, Python 3.13, Node 22):

  • The pi/MCP suites (test_acp_pi_backend*, test_mcp_session_report*, test_pi_*) give 422 passed. The Node-driven gate tests ran rather than skipped (28 passed).
  • One failure, test_pi_steer.py::test_a_steer_at_the_text_bound_fits_the_size_the_extension_reads (cp950 decode), fails the same way on main on this host.
  • black gate, isort, flake8, mypy, harness-parity, file-line-cap, comment-history and brand checks are all clean.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 1, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Continuing this in #31121; thanks for the start.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 6, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Thank you @leonlaiyc! Your commits landed on main through the in-repo copy #31121 (authorship kept), which ran CI on in-repo runners. Closing this one as merged via #31121.

@iamwhatever iamwhatever closed this Nov 8, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pi: confirm the gate extension registered Crew's MCP servers

3 participants