Skip to content

P1 HOLD fixes: streaming caps, absolute deadline, JSON errors, ack-gated receipts - #43

Merged
ScriptedAlchemy merged 5 commits into
mainfrom
cursor/potato-p1-bridge-d857
Sep 15, 2026
Merged

ScriptedAlchemy merged 5 commits into
mainfrom
cursor/potato-p1-bridge-d857

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Why: PR #40 (first revision) was merged while the HOLD fixes were in flight. This follow-up from the same branch lands the six GPT-6 Pro hold items on top of current main (incl. the history feature), plus the two remaining contract gaps from the #43 review. Same potato-mode rules: shortest diffs, no new deps, no approval flips.

Hold fixes (vs the merged rev-1 content):

  • Gateway reads count true bytes through a streaming reader that cancels on overflow (no more res.text()-then-pretend).
  • Codex transport: absolute handshake deadline immune to trickled bytes; size caps applied to terminated headers and complete frames before decoding; guaranteed socket destruction on close(); malformed RPC (incl. JSON null) routed through failAll.
  • CLI --json failures emit structured stderr JSON with error, delivery, threadId/turnId/targetId.
  • Sends stay unknown without a confirmed string receipt — never a silent accept; gbot_send reflects the gateway verdict.
  • MCP full reads add a 200k aggregate budget with truthful truncated/fullLength metadata; remainder retrievable via gbot thread --full/--json. Route-schema bound ceiling documented with ponytail: (zod still enforces 1–200).
  • Merge note: resolved on the history feature by reusing its hasFlag helper and keeping its saveHistory calls; transcript keeps the preview-last tweak.

Contract gaps fixed in this revision:

  • Trailing --json is parsed before dispatch/backend init: codex send peels a trailing --json only (mid-message tokens stay content; -- protects the rest), structured subcommands and thread/send/history honor it, so early auth failures also emit JSON. Both placements tested with the transmitted prompt asserted free of --json.
  • MCP aggregate budget now counts metadata too: id/kind/role capped at 200 chars each, text shrunk against the remaining total, requested count enforced locally so a limit-ignoring gateway cannot inflate output. Fixtures for overflow, count enforcement, and metadata caps.

Correlation IDs: sendPrompt reuses the existing clientNonce/replyToId; the full send/execution correlation envelope stays in #37 and is not claimed here.

Verification: root npm test 108/108 green; plugin npm run check green (validate, build, artifact, typecheck, 11 route-unit tests).

Closes #34 #35 #36 as the remainder of the P1 follow-ups. Out of scope: #37 correlation envelope, #38 native queue, #39 status diagnostics, Desktop private pipes. No approval_policy changes; public app-server JSON-RPC only.

Open in Web Open in Cursor 

cursoragent and others added 4 commits September 15, 2026 02:51
…read reads

Closes #34 (delivery states: rejected/accepted/unknown, IDs preserved),
#35 (idempotent shutdown, handshake/fragmentation/budgets, no leaks),
#36 (truncation metadata, bounded full reads, safe normalize, 1-200 limits).

Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
… errors, ack validation, bounded full reads

Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3fda090

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
grok-bot-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ScriptedAlchemy
ScriptedAlchemy marked this pull request as ready for review September 15, 2026 03:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-15T03:28:36.154834Z 85b212a Draft marked ready
ℹ️ 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.

@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

grok-bot-cli/src/cli.js

Lines 534 to 535 in 85b212a

if (json) print({ id: out.target.id, name: out.target.name, kind: out.target.isGroup ? "group" : "bot", result: out.result, delivery: out.delivery || "accepted", ...(out.messageId ? { messageId: out.messageId } : {}) });
else print("Sent to " + (out.target.isGroup ? "group" : "bot") + " " + out.target.name + " (" + out.target.id + ")" + receipt);

P2 Badge Warn plain-text users when send delivery is unknown

When sendPrompt receives a successful response without a messageId, it now correctly returns delivery: "unknown", but non-JSON gbot send still unconditionally prints Sent to ... with no no-receipt warning. Users of the default output therefore cannot distinguish a confirmed send from an unknown delivery and are not told to inspect the thread before retrying, unlike MCP callers. Include the unknown-delivery guidance in the plain-text branch.

ℹ️ 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 src/cli.js
if (cmd === "send") {
const ref = sub;
if (hasFlag(rest, "--json")) json = true;
if (hasFlag(rest, "--json")) { json = true; jsonErrors = true; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Parse trailing JSON mode before opening the backend

When callers use the supported command-local form gbot send ... --json or gbot thread ... --json, this flag is not processed until after openBackend() has run. If backend initialization fails—for example, because the agents directory is missing or the app gateway session is unusable—jsonErrors remains false and the CLI emits plaintext instead of the promised structured JSON error. Parse these command-local flags before opening the backend.

Useful? React with 👍 / 👎.

Comment thread src/gateway.js
Comment on lines +100 to +102
if (bytes > maxBytes) {
try { await reader.cancel(); } catch { /* already closed */ }
throw new GatewayError("Gateway response too large (over " + maxBytes + " bytes)");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve HTTP rejection status on capped response errors

If sendPrompt receives a definite 4xx response whose body exceeds the new cap, this throw creates a GatewayError without the already-known HTTP status. The send error classifier consequently treats it as delivery: "unknown" rather than "rejected", even though the server explicitly rejected the request. Propagate res.status when capped reading fails, or classify using the response status before reading its body.

Useful? React with 👍 / 👎.

Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
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.

[P1] Preserve send receipts and distinguish rejected, accepted, and unknown delivery

2 participants