Skip to content

fix(console): complete production data transports - #128

Merged
Travis-Gilbert merged 4 commits into
mainfrom
Travis-Gilbert/console-deploy-finish
Jul 26, 2026
Merged

fix(console): complete production data transports#128
Travis-Gilbert merged 4 commits into
mainfrom
Travis-Gilbert/console-deploy-finish

Conversation

@Travis-Gilbert

@Travis-Gilbert Travis-Gilbert commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • initialize and close authenticated MCP Streamable HTTP sessions before Harness tool calls
  • parse JSON and multiline SSE responses, including heartbeat frames
  • keep Proactivity and Filing on the explicit CommonPlace consumer GraphQL contract
  • fail Railway startup when CONSOLE_DATA_API_URL is absent

Validation

  • 68 Vitest files / 291 tests passed
  • 2 Railway launcher tests passed
  • TypeScript check passed
  • changed-file ESLint passed
  • import fence passed
  • Railway standalone production build passed
  • final peer review found no remaining actionable issues

Live evidence

  • authenticated Models route reproduced the prior MCP-session failure
  • correct initialized MCP flow reached typed GraphQL
  • Railway gRPC/private-network remediation is being validated separately from this source change

Summary by CodeRabbit

  • Configuration

    • Console services now use the configured CommonPlace GraphQL endpoint consistently.
    • Startup now stops with a clear error when the required data API URL is missing.
    • Proactivity’s event stream remains configured separately from the GraphQL endpoint.
  • Reliability

    • Filing and Proactivity connectivity now use tenant-aware request handling.
    • MCP interactions now support session setup, event-stream responses, and clean session shutdown.
  • Documentation

    • Updated configuration guidance and error messaging to reference the correct environment settings.

Copilot AI review requested due to automatic review settings July 26, 2026 20:41
@ecc-tools

ecc-tools Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Travis-Gilbert, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5e266e79-ab9c-48c7-8245-166ef52551c0

📥 Commits

Reviewing files that changed from the base of the PR and between 2a2d5be and ceae0f9.

📒 Files selected for processing (5)
  • apps/console/src/lib/server/consumer-graphql.test.ts
  • apps/console/src/lib/server/consumer-graphql.ts
  • apps/console/src/lib/server/harness-mcp.test.ts
  • apps/console/src/lib/server/harness-mcp.ts
  • apps/console/src/lib/server/proactivity-harness.ts
📝 Walkthrough

Walkthrough

The Console now routes Filing and Proactivity GraphQL requests through THEOREM_GRAPHQL_URL, implements explicit MCP session lifecycle handling, and validates CONSOLE_DATA_API_URL before Railway startup.

Changes

Console runtime contracts

Layer / File(s) Summary
Consumer GraphQL routing
apps/console/src/lib/server/consumer-graphql.ts, apps/console/src/lib/server/filing-harness.ts, apps/console/src/lib/server/proactivity-harness.ts, apps/console/src/views/filing/filing-client.ts, apps/console/...md, railway.console.toml
GraphQL endpoint normalization and adapter wiring now use THEOREM_GRAPHQL_URL; Harness URL fallback and authorization headers were removed, and configuration guidance was updated.
MCP session lifecycle
apps/console/src/lib/server/harness-mcp.ts, apps/console/src/lib/server/harness-mcp.test.ts
MCP calls now initialize sessions, send notifications, invoke tools with principal-bound headers, parse JSON or SSE payloads, and tear down sessions.
Railway startup validation
apps/console/scripts/railway-env.mjs, apps/console/scripts/start-railway.mjs, apps/console/scripts/railway-env.test.mjs, apps/console/package.json
Railway startup now requires a non-blank CONSOLE_DATA_API_URL, with Node test coverage included in the package test script.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Console
  participant PrincipalResolver
  participant HarnessMCP
  Console->>PrincipalResolver: Resolve tenant and principal headers
  Console->>HarnessMCP: initialize
  HarnessMCP-->>Console: Return MCP session ID
  Console->>HarnessMCP: notifications/initialized
  Console->>HarnessMCP: tools/call with tenant and actor arguments
  HarnessMCP-->>Console: Return JSON or SSE payload
  Console->>HarnessMCP: DELETE session
Loading

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and matches the main change: finishing console production data transport paths.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Travis-Gilbert/console-deploy-finish

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

Comment @coderabbitai help to get the list of available commands.

Copilot AI 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.

Pull request overview

This PR hardens the Console’s production transport paths by correctly establishing authenticated MCP Streamable HTTP sessions for Harness tool calls, while keeping Proactivity/Filing on the explicit CommonPlace consumer GraphQL contract and failing fast on incomplete Railway data-plane configuration.

Changes:

  • Add MCP session lifecycle (initialize → notifications/initialized → tools/call → DELETE) plus JSON + SSE (multiline + heartbeat) response parsing for Harness MCP calls.
  • Centralize consumer GraphQL endpoint normalization via consumerGraphqlUrl() and route Proactivity/Filing through it (no fallback to Harness MCP host).
  • Enforce Railway startup configuration by requiring CONSOLE_DATA_API_URL before launching the standalone server, with tests.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
railway.console.toml Updates deploy-time env var guidance, clarifying required vs optional transport configuration.
apps/console/src/views/filing/filing-client.ts Updates Filing’s “missing capability” string to point at THEOREM_GRAPHQL_URL.
apps/console/src/lib/server/proactivity-harness.ts Switches Proactivity GraphQL endpoint selection to the consumer schema helper and removes Harness-token auth.
apps/console/src/lib/server/harness-mcp.ts Implements MCP session initialization/teardown and robust JSON/SSE parsing for tool responses.
apps/console/src/lib/server/harness-mcp.test.ts Adds coverage for MCP session initialization, multiline SSE parsing, and fail-closed behavior.
apps/console/src/lib/server/filing-harness.ts Switches Filing GraphQL endpoint selection to the consumer schema helper and removes Harness-token auth.
apps/console/src/lib/server/consumer-graphql.ts Adds a single, explicit consumer GraphQL URL normalizer (origin or /graphql accepted).
apps/console/src/lib/server/consumer-graphql.test.ts Tests consumer GraphQL URL normalization and the “no Harness fallback” rule.
apps/console/scripts/start-railway.mjs Validates Railway environment before starting the Next standalone server.
apps/console/scripts/railway-env.mjs Introduces Railway startup env assertions (requires CONSOLE_DATA_API_URL).
apps/console/scripts/railway-env.test.mjs Adds node:test coverage for the Railway startup assertion helper.
apps/console/package.json Extends Console test script to include the Railway env assertion tests.
apps/console/CLAUDE.md Updates operational docs to reflect consumer GraphQL ownership for Proactivity/Filing.
apps/console/AGENTS.md Updates agent docs to reflect consumer GraphQL ownership for Proactivity/Filing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/console/src/lib/server/harness-mcp.ts
Comment thread apps/console/src/lib/server/consumer-graphql.ts
Comment thread apps/console/src/lib/server/proactivity-harness.ts
@ecc-tools

ecc-tools Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/console/src/lib/server/harness-mcp.test.ts`:
- Around line 43-58: Update the beforeEach and afterEach hooks in the Harness
test setup to use vi.stubEnv for CONSOLE_HARNESS_URL and CONSOLE_HARNESS_TOKEN,
then call vi.unstubAllEnvs() during cleanup instead of deleting the variables,
so Vitest restores any pre-existing environment values.

In `@apps/console/src/lib/server/harness-mcp.ts`:
- Around line 159-199: Update readMcpPayload and its callers to use the existing
eventsource-parser, consume all SSE events, and return only the JSON-RPC
response whose id matches the outbound request; ignore request-scoped
notifications such as notifications/progress. Pass the request id through the
parsing flow and preserve non-SSE JSON handling. Add a regression test in
apps/console/src/lib/server/harness-mcp.test.ts covering a notification before
the matching response.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9cafa996-ba1e-4f79-844d-0a37f4243e3b

📥 Commits

Reviewing files that changed from the base of the PR and between 560df1c and 2a2d5be.

📒 Files selected for processing (14)
  • apps/console/AGENTS.md
  • apps/console/CLAUDE.md
  • apps/console/package.json
  • apps/console/scripts/railway-env.mjs
  • apps/console/scripts/railway-env.test.mjs
  • apps/console/scripts/start-railway.mjs
  • apps/console/src/lib/server/consumer-graphql.test.ts
  • apps/console/src/lib/server/consumer-graphql.ts
  • apps/console/src/lib/server/filing-harness.ts
  • apps/console/src/lib/server/harness-mcp.test.ts
  • apps/console/src/lib/server/harness-mcp.ts
  • apps/console/src/lib/server/proactivity-harness.ts
  • apps/console/src/views/filing/filing-client.ts
  • railway.console.toml

Comment thread apps/console/src/lib/server/harness-mcp.test.ts
Comment thread apps/console/src/lib/server/harness-mcp.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a2d5be91f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/console/src/lib/server/harness-mcp.ts Outdated
Comment thread apps/console/src/lib/server/harness-mcp.ts Outdated
@ecc-tools

ecc-tools Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@ecc-tools

ecc-tools Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ceae0f9a62

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


const MCP_PROTOCOL_VERSION = '2025-06-18';
const MCP_TEARDOWN_TIMEOUT_MS = 2_000;
const MCP_SSE_MAX_BUFFER_SIZE = 1024 * 1024;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Allow MCP results larger than one MiB

The 1 MiB parser buffer rejects valid large SSE events and parseFailed then makes readMcpPayload return null. This is likely for topicPreviewAsset, whose base64 payload exceeds the limit for images larger than roughly 750 KiB, and for the memory query requesting up to 5,000 items; both routes will report an invalid MCP result despite a successful server response. Remove the arbitrary limit or parse large events without treating their size as malformed.

AGENTS.md reference: AGENTS.md:L25-L27

Useful? React with 👍 / 👎.

@Travis-Gilbert
Travis-Gilbert merged commit 9988fa3 into main Jul 26, 2026
2 of 4 checks passed
@Travis-Gilbert
Travis-Gilbert deleted the Travis-Gilbert/console-deploy-finish branch July 26, 2026 21:25
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.

2 participants