Skip to content

fix(mcp): close bounded discovery audit gaps - #253

Merged
khaliqgant merged 7 commits into
mainfrom
fix/armi11-audit-residuals
Nov 19, 2026
Merged

khaliqgant merged 7 commits into
mainfrom
fix/armi11-audit-residuals

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Closes three exact-head MCP audit residuals after #252.

Changes:

  • Amp discovery requests a 101st lookahead row so a bounded 100-thread page reports truncated truthfully.
  • describe_capabilities keeps list_relay_agents and get_relay_agent_card available while listing actor-dependent relay calls in restricted_tools when a managed Desktop identity cannot be verified.
  • check_relay_inbox gives optional sender-address enrichment a one-second abort budget, logs one redacted warning on degradation, and returns pending messages with sender_address null when the lookup fails or stalls.

Cross-repo contract:

  • restricted_tools matches the hosted edition exactly: an array of { name: string, reason: string } entries.
  • The generated Amp provider pins landed RelayHistory main commit 703d9f115a31551e70a9f7207be1ede9fe2f0c74, with verified sha256 e04b19806ce728976feb4a8f06fc84ac54a101255b29c2f45ebfad4c5d9d5853.
  • The separate managed hosted_launch identity-reporting gap is not part of this follow-up; it belongs to that distinct capability group.

Verification:

  • npm run typecheck (pass at merged-main head 5bbd73c)
  • node --import tsx --test --test-concurrency=2 test/amp.test.ts test/messaging.test.ts test/mcp.test.ts (108/108 at 5bbd73c)
  • npm test (2,071 tests: 1,962 pass, 109 skipped, 0 fail on earlier merged-main head 088d3d8)
  • replacement exact-head GitHub CI run 44596824799 is pending.

No deploy, release, migration, credential, image, or flag action is included.

@khaliqgant khaliqgant added the merge-train:hold Do not merge until the owner gives the go label Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

AMP discovery now requests one lookahead thread. Relay capability reports identify individual tools restricted by missing native identity. Inbox sender-address enrichment has a one-second bound and can fail without preventing the inbox result.

Changes: AMP Thread Discovery

Layer / File(s) Summary
AMP discovery lookahead
src/amp/provider.ts, src/amp/provider-origin.json, test/amp.test.ts, CHANGELOG.md
AMP discovery requests 101 threads instead of 100. The test checks the CLI limit, and the changelog documents lookahead-based truncation detection. Generated-source metadata is updated.

MCP Capability Reporting

Layer / File(s) Summary
Capability availability and restrictions
src/mcp/catalog.ts, src/mcp/capabilities.ts, test/mcp.test.ts, CHANGELOG.md
When native authority is unavailable, relay messaging remains available for directory reads. Other tools are listed in restricted_tools with reasons. The description, tests, and changelog reflect this reporting.

Inbox Sender Enrichment

Layer / File(s) Summary
Bounded sender-address lookup
src/messaging/relaycast.ts, src/mcp/relay-participants.ts, test/messaging.test.ts, test/mcp.test.ts, CHANGELOG.md
Sender-name lookups accept an abort signal. Inbox enrichment is limited to one second; failures are logged, and messages can be returned with a null sender address. Tests cover lookup failure, timeout, and later acknowledgment.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant check_relay_inbox
  participant Relaycast
  Caller->>check_relay_inbox: Request inbox
  check_relay_inbox->>Relaycast: Look up sender names with a 1000 ms bound
  alt Lookup succeeds
    Relaycast-->>check_relay_inbox: Return sender agents
    check_relay_inbox-->>Caller: Return inbox messages with enriched addresses
  else Lookup fails or times out
    Relaycast-->>check_relay_inbox: Return error or abort
    check_relay_inbox-->>Caller: Return messages with null sender addresses
  end
Loading

Possibly related PRs

Suggested reviewers: kjgbot, miyaontherelay

Merge Risk: Minimal · up to 5bbd7

The change requests one extra Amp thread to detect truncation, reports per-tool restrictions in describe_capabilities instead of restricting the whole relay-messaging group, and bounds inbox sender-address lookup to one second. No concrete defect was found at the current head. Before merging, confirm exact-head CI and finish the pending provenance refresh.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(mcp): close bounded discovery audit gaps" names the main change: it closes the MCP audit gaps for bounded discovery. The changeset covers Amp discovery lookahead, describe_capabilities …
Description check Passed The description is directly related to the changeset. It lists the three changes: the Amp 101-row lookahead, the describe_capabilities restricted_tools behavior, and the check_relay_inbox sender-addre…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(mcp): close bounded discovery audit gaps" names the main change: it closes the MCP audit gaps for bounded discovery. The changeset covers Amp discovery lookahead, describe_capabilities restricted_tools handling, and the one-second sender-enrichment budget in check_relay_inbox. The title is specific to the MCP area and summarizes the primary change, though it does not name any one of the three fixes.

Full details: Description check

Explanation

The description is directly related to the changeset. It lists the three changes: the Amp 101-row lookahead, the describe_capabilities restricted_tools behavior, and the check_relay_inbox sender-address enrichment budget. It also covers the cross-repo contract, provenance pin, and verification results.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the inbox flow,
One second gives the lookup room to go.
If names stay hidden, messages arrive,
And directory reads remain alive.
One extra thread helps spot the end,
Then off the rabbit hops, content.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 55b4e63a-3a71-476a-a170-1adac9b0b81c
Commits

Reviewing files that changed from the base of the PR and between 3329171 and 5bbd73c.

Files selected for processing: 10

  • CHANGELOG.md
  • src/amp/provider-origin.json
  • src/amp/provider.ts
  • src/mcp/capabilities.ts
  • src/mcp/catalog.ts
  • src/mcp/relay-participants.ts
  • src/messaging/relaycast.ts
  • test/amp.test.ts
  • test/mcp.test.ts
  • test/messaging.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T17:21:41.576070Z 3ca319a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

@agent-relay-code agent-relay-code Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 3ca319a. The three changes are the right ones and small; requesting changes for four items, all quick.

Required

  1. The Amp pin points at an unmerged upstream commit. src/amp/provider-origin.json and the header now name 7c9ef71c…, which is the head of an open upstream pull request, not a commit on the upstream main branch. I checked the bytes: the upstream file at that commit hashes to the recorded e04b1980… and the vendored file below the header matches it, so the copy itself is faithful. But the pin is this repository's provenance record, and a pull request head can change or be squashed into a different commit. This part can merge only after the upstream change is on its main branch, with commit set to that commit (the sha256 stays the same if the file does). Either keep it here and this PR waits for upstream, or move the Amp commit to its own PR so the other two fixes do not wait. Your choice; say which.

  2. The inbox fallback is silent and the comment above it is now wrong (src/mcp/relay-participants.ts, inbox). .catch(() => []) drops every failure of the sender lookup, including a rejected credential, without a trace, so an operator cannot tell a slow relay from a broken one. Log one fixed console.warn line with the operation and the error class (the same pattern as ownerEnrichmentFailed; no names, no tokens). And update the comment that says every fallible read finishes before any acknowledgement and that a failed enrichment leaves deliveries pending: the required reads still do, the sender address lookup is now optional and bounded. Assert the warning line in the new test.

  3. Say where a client finds the restriction. The group now answers available, and a client that reads only status sees no restriction. Add restricted_tools to the describe_capabilities tool description (it currently speaks of unavailable or restricted groups only), and confirm in the PR description that the hosted edition's change uses the same field name and the same { name, reason } shape. If the two differ, align them before either merges.

  4. PR description. It carries an internal tracker id in two places, and the generated summary below it repeats it. Please remove it from the description; this repository is public. The commit message is fine.

Requested

  1. A test at the inbox level where the lookup never resolves: the call returns within the budget with sender_address: null and the deliveries are acknowledged once on the following call. The client-level abort test and the 503 inbox test each cover half of this.

  2. The same gap exists one group over: on a managed connection without a verified chat identity, spawn_relay_agent needs that identity for the requester and is refused, while hosted_launch reports available with nothing restricted. Fine as a follow-up; say in the description whether you take it here or not.

Checked and sound: the actor-dependent list is right (every tool in it resolves the managed chat identity first, and the two directory reads go through a path that does not); the one-second signal covers all chunks of the lookup together; a lookup that fails after the response headers is caught by the same fallback; sender_address is already nullable for clients; the CHANGELOG bullets describe the unreleased behaviour as it will ship.

Not run locally at this head, since a new head follows; the required check on 3ca319a was still running when I wrote this. I run typecheck and the amp, messaging and mcp suites on the head that answers these items.

@agent-relay-code agent-relay-code Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at da055ad. Read of the diff only; I run the local checks on the head that contains main and the final pin.

Answered:

  • Inbox sender enrichment now writes one fixed warning line (operation and error class) on a failed or timed-out lookup, the comment above the read states which reads are required and which is optional, and the test asserts the exact warning.
  • The describe_capabilities description names restricted_tools and its { name, reason } entries, with an assertion on the advertised description.
  • The inbox-level test with a lookup that never resolves returns within the budget, leaves the delivery pending, and acknowledges it once on the following call.
  • The tracker id is out of the description, and hosted_launch is stated as a separate follow-up.

Still open, so my changes-requested review stays:

  1. Description: remove the hosted pull request number in the "Cross-repo contract" section. "Matches the hosted edition exactly: an array of { name: string, reason: string } entries" says everything a reader of this repository needs.
  2. Merge main. The branch conflicts with main (CHANGELOG). Merge, do not rebase, and keep every Unreleased entry.
  3. Amp provenance. Agreed as you describe it: this stays held until the upstream change is on its main branch, then src/amp/provider-origin.json names that main commit and the header hash is re-checked. I verify the hash against the upstream file at that commit before approving.

Send the exact head once 2 and 3 are in; 1 can be edited now.

@khaliqgant

Copy link
Copy Markdown
Member Author

Addressed review 5979951270 at da055ad.

  1. Chosen dependency path: keep this PR held until RelayHistory #594 lands, then refresh provider-origin.json to the landed main SHA before merge.
  2. Sender enrichment now writes one fixed redacted warning with operation and error class; the comment distinguishes required reads from optional enrichment; the rejection test asserts the log.
  3. describe_capabilities now documents restricted_tools as { name, reason }. Cloud #6430 uses the same field and shape.
  4. The public description no longer contains the internal tracker id.
  5. Added the inbox-level never-resolving lookup test: it returns inside the one-second budget with null address, leaves the delivery pending, then the following call acknowledges it exactly once.
  6. managed hosted_launch reporting is explicitly left to that distinct capability group.

Local verification on this head: npm run typecheck; test/mcp.test.ts 57/57. Exact-head CI is expected to rerun; merge-train:hold remains.

@khaliqgant

Copy link
Copy Markdown
Member Author

Reviewer follow-up: the public description no longer names the hosted PR. Current main is merged without rebasing at exact head 088d3d854de255993527a1f4b642b1f5970dfb39; the two conflicts preserved every Unreleased bullet and both enrichment helpers. On that tree, npm run typecheck passes and npm test reports 2,071 total / 1,962 pass / 109 skipped / 0 fail. GitHub CI is now running on this exact head. The PR remains held pending the upstream main landing and final provenance-manifest refresh, after which I will send the new immutable head for hash verification.

@agent-relay-code agent-relay-code Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 088d3d8 (merge of main into the branch).

Merge resolution: correct. The combined diff touches only CHANGELOG.md and src/mcp/relay-participants.ts as conflicts. Both warning helpers are kept (inboxSenderEnrichmentFailed and sessionEnrichmentFailed), the roster's synced-session lookup from main is intact, and every Unreleased bullet from main is still present next to this PR's entries. Nothing else from main was altered.

Local checks on this exact head (run serially, separate from CI):

  • tsc --noEmit: clean
  • test/amp.test.ts: 16/16
  • test/messaging.test.ts: 33/33
  • test/mcp.test.ts: 59/59

Exact-head CI: the import verifier is green; "Typecheck and test" was still running when I wrote this.

Still open before I approve:

  1. The description's "Cross-repo contract" section still names a pull request number from the hosted repository. Please replace it with plain wording, for example "restricted_tools matches the hosted edition exactly: an array of { name, reason } entries."
  2. src/amp/provider-origin.json still names the head of the open upstream pull request (relayhistory #594). As agreed, this waits until that change is on the upstream main branch and the pin names that main commit. If the file content is unchanged the sha256 stays e04b1980…; I check it against the upstream file at the pinned commit.

No source change is requested beyond the pin. My earlier change request stays in place until 1 and 2 are done.

@agent-relay-code agent-relay-code Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 5bbd73c. This replaces my earlier changes-requested review.

Checked on this exact head:

  • Amp provenance. src/amp/provider-origin.json now names the upstream main commit 703d9f115a31551e70a9f7207be1ede9fe2f0c74, the merge commit of AgentWorkforce/relayhistory#594. I fetched sdk-ts/src/amp-source.ts at that commit: its sha256 is e04b19806ce728976feb4a8f06fc84ac54a101255b29c2f45ebfad4c5d9d5853, the value in the manifest and in the generated header of src/amp/provider.ts.
  • Main merge. The head is a two-parent merge with current main (no rebase). src/mcp/relay-participants.ts keeps both the inbox sender-lookup bound from this PR and the session-enrichment reason from main; src/mcp/relay-messaging.ts equals main; the CHANGELOG keeps main's wording of the session-summaries entry and this PR's three entries.
  • Scope. Ten files differ from main, the same set as at the previously reviewed head.
  • Local, serial: tsc --noEmit clean; test/amp.test.ts 16/16, test/messaging.test.ts 33/33, test/mcp.test.ts 59/59.
  • CI on this head: Typecheck and test, and the import verifier harness, both succeeded. No unresolved threads.

The hold label stays; merging waits for the repository owner's OK.

@khaliqgant khaliqgant removed the merge-train:hold Do not merge until the owner gives the go label Nov 19, 2026
@khaliqgant
khaliqgant merged commit f655932 into main Nov 19, 2026
4 checks passed
@khaliqgant
khaliqgant deleted the fix/armi11-audit-residuals branch November 19, 2026 19:32
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