Skip to content

fix: verify reviews containing escaped control examples - #2054

Merged
vincentkoc merged 1 commit into
mainfrom
fix/comment-publication-diagnostics
Oct 17, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/comment-publication-diagnostics

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes completed review comments being reported as unpublished when their text contains literal Unicode escape examples or control characters.

User Impact

Review publication can confirm the original stored comment and finish successfully. Wrong comment IDs, authors, and bodies still fail verification. No operator configuration change is required.

Why This Change Was Made

The GitHub CLI sanitizes JSON string content for terminal display, including literal escape examples. The mutation can therefore succeed while its response and a normal CLI readback fail exact body comparison.

Keep writes on the existing transport. When a write response cannot establish the receipt, read original bytes through a GET-only path within the existing credential, retry, deadline, circuit, and telemetry owner. PATCH reads the known ID; POST paginates and selects the newest trusted exact match. Receipt reads bypass sanitized ETag bodies. Same-origin redirects preserve the selected credential boundary.

The transport follows the selected CLI host, API-host override, credentials, and Unix-socket settings.

Documentation Impact

Updated the active publication contract in docs/scheduler.md. Owner: ClawSweeper maintainers. Source of truth: the publication and GitHub runtime modules. Verified scope: receipt verification on 290584f through the controlled transport proof below. Update when receipt, authentication, retry, or publication behavior changes. Added one changelog fragment.

Evidence

  • Focused publication, raw transport, telemetry, and paired-issue provenance checks: 61 passed on the final source; paired-issue provenance also passed in the full suite..
  • Full pnpm run check: passed in CI run 39042054544: all four test shards, combined coverage, static checks, builds, lint, and formatting..
  • Fresh precommit and committed-branch Codex reviews: precommit and committed-branch reviews clean (no actionable P0–P2 findings)..
  • Production LOC: +341 lines (+422/-81); tests and executable proof +651 (+666/-15); added capability is byte-preserving receipt transport with canonical accounting. Test and proof code is counted separately.
  • Upstream contract: GitHub CLI sanitizer, default host and credentials, API routing.

Real Behavior Proof

  • Claim: valid stored reviews containing escape examples are confirmed without changing their bytes or issuing a second mutation.
  • Surface: built production publication and GitHub runtime, stock GitHub CLI 2.102.0, and real curl against a controlled HTTP peer over the production Unix-socket path.
  • Scenarios: baseline and candidate, ordinary text, literal escapes, actual controls, empty write receipts, same-origin redirects, configured enterprise default host, API-host override, POST pagination, and wrong body/author/ID rejection.
  • Command: node scripts/e2e/review-publication-bytes.mjs <baseline-dist> dist <empty-output-dir>.
  • Environment: Node 24.22.0, Daytona Linux; lease cbx_33ba58ec3508; image crabbox-daytona-2x4x10-20260803-3907a63. Baseline 7bcab824b1493fbb2eda8aa71835d36759095410; candidate 290584f4e3bce062a8db6c842e4570ba374565da; source fingerprint a3977adcd42388992480d9bd929d97f62a35a89482616d638391a334e9ccdadd.
  • Observed: 24/24 expected outcomes (12 baseline and 12 candidate); nine valid candidate cases accepted and all three invalid candidate cases rejected.. Every scenario made exactly one mutation. Valid candidate receipts match the stored and expected body hashes; all three wrong-receipt controls remain rejected.
  • Artifact: https://gist.github.com/vincentkoc/4843b1b19295d75164d6af98b4128cdf.
  • Limits: controlled transport peer, not a live production comment write. The original incident's mutation response was not retained. This reproduces the sanitizer failure class; it does not claim a captured original HTTP receipt or production recovery.

Redirect Credential Boundary Proof

The forbidden-origin proof request and matching rank-up move are addressed by five real-transport cases. Production code and the reviewed head remain unchanged.

  • Surface: the built production receipt transport with real curl 8.14.1, a real HTTPS source, and independent HTTPS and HTTP destinations. No curl adapter or Unix socket is used. Only a synthetic token and temporary local certificate authority are supplied.
  • Command: node redirect-boundary-proof.mjs dist redirect-boundary-proof.json; the executable script is in the same artifact.
  • Environment: Node 24.22.0, Daytona lease cbx_dfc3c1cd7b08, image crabbox-daytona-2x4x10-20260803-3907a63; candidate 290584f4e3bce062a8db6c842e4570ba374565da, source fingerprint a3977adcd42388992480d9bd929d97f62a35a89482616d638391a334e9ccdadd.
  • Observed: all five expected outcomes passed. The allowed same-origin redirect made two source requests and preserved the body hash. Unrelated-host, changed-port, HTTP-downgrade, and credential-bearing redirects each stopped after one source request. Every forbidden case recorded zero destination TCP connections, zero destination requests, and zero destination credential headers.
  • Control: both destination listeners first accepted a direct probe: two connections and two requests, with no credentials. Counters were reset before each production-path case.
  • Limit: controlled local TLS peers, not a live production comment mutation. The existing 24-case publication proof covers the production publisher and stock gh; this added proof isolates the credential-bearing curl boundary.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@vincentkoc
vincentkoc marked this pull request as ready for review October 17, 2026 14:51
@vincentkoc
vincentkoc requested a review from obviyus October 17, 2026 14:52
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds byte-preserving GitHub comment readback when sanitized CLI responses cannot verify a published review.

Example: A published review contains the literal example \u001b.

  • Before: CLI sanitization changes the returned text, so exact verification reports publication failure.
  • After: A fresh GET confirms the unchanged stored body without another mutation.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused repair with real-transport controlled proof and no identified defect; proof exercises production modules rather than the full shipped CLI.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The current body records production publication/runtime execution with stock gh and real curl on Daytona Linux, Node 24.22.0, head 290584f: lease cbx_33ba58ec3508 covers 24 publication outcomes, and cbx_dfc3c1cd7b08 covers five TLS redirect outcomes using image crabbox-daytona-2x4x10-20260803-3907a63. Valid receipts retain body hashes and one mutation; wrong receipts remain rejected; forbidden redirect destinations receive zero connections, requests, or credentials. This addresses the prior authority-proof request. Linked artifact retrieval was blocked by reviewer infrastructure, so assessment relies on the detailed recorded results and inspected source rather than independently viewed traces.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A completed review can remain reported as unpublished despite its comment being stored successfully.
Reason: The maintainer-authored direction repairs a defined exact-receipt contract without adding configuration or changing mutation authority.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR fixes a source-verifiable publication failure that remains on main, and no actionable introduced defect was identified.

Priority: P2
Reviewed head: 290584f4e3bce062a8db6c842e4570ba374565da

Before merge

None.

Findings

None.

Agent review details

How this fits together

The publication owner submits review comments through the existing mutation transport and verifies receipts; the new read path retrieves original JSON bytes through the shared credential, retry, deadline, and telemetry owners.

flowchart TD
  A[Review body] --> B[Existing mutation transport]
  B --> C[Receipt verification]
  C --> D[Byte preserving GET]
  D --> E[GitHub comment API]
  E --> F[Exact body and trusted author checks]
  F --> G[Confirmed publication]
Loading

Technical review

Best possible solution:

Retain exact receipt verification and recover original comment bytes through the narrowly scoped GET transport.

Do we have a high-confidence way to reproduce the issue?

Current-main exact comparison consumes sanitized CLI output, and upstream sanitizer source establishes the failing escape inputs; the PR records controlled baseline failures and candidate success, but no target code was executed during this review.

Is this the best way to solve the issue?

The focused fallback addresses the response-byte owner without weakening receipt checks; upstream source confirms jq receives already-sanitized JSON, supporting the separate read transport.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 96e800e74056.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced patch and current-main behavior: The pinned introduction adds lossless receipt reads; fetched main still uses sanitized ghPaged readback. PATCH remains identity-bound, and POST retains newest trusted exact-match selection. (src/clawsweeper-review-comment-state.ts:404, 290584f4e3bc)
  • Credential boundary: The transport accepts only relative comment GET routes, supplies credentials through stdin, and rejects changed origins or credential-bearing redirects before the next curl invocation. (src/github-raw-json-read.ts:233, 290584f4e3bc)
  • Updated proof and previous review disposition: The current PR body records 24 baseline/candidate publication outcomes and five additional real-curl TLS redirect cases. Forbidden destinations recorded zero connections, requests, and credential headers, addressing the previous review's specific request. Gist API access returned 403 and gist hosts were blocked here; linked traces were not independently inspected. (290584f4e3bc)
  • Original receipt and runtime contracts: fix(review): publish exact merge readiness state #1059 requires exact receipts and permits fresh readback; perf(github): add durable ETag read broker #1164 preserves authoritative wire validation; refactor: own GitHub runtime state per command #1898 owns command-scoped runtime state. The patch retains those boundaries. (src/clawsweeper-github-runtime.ts:547, 290584f4e3bc)
  • Authoritative sanitizer contract: The PR executes stock gh and relies on its sanitizer and authentication contracts, establishing dependency relevance. The sanitizer explicitly transforms JSON Unicode control escapes before consumers receive the response. (pkg/asciisanitizer/sanitizer.go:75, 37aa5bbaf1a5)
  • Host routing and existing-capability check: The proof executes gh 2.102.0 and the transport reproduces its host selection. Source confirms JSON is sanitized before jq processing; host and API-gateway documentation requires preserving selected destinations and credential precedence. Relevant dependency policy and guides were read. (pkg/cmd/api/api.go:341, fc4b137cdef0)

Review metrics

Metric Value Why it matters
Production and validation growth Production +422/-81; tests and executable proof +666/-15 Most production growth implements the byte-preserving transport; validation covers byte fidelity, host selection, pagination, and rejection paths.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Valid review comments can fail publication confirmation for specific escape/control content, with limited scope and no demonstrated destructive effect.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-17T15:05:53.969Z sha 290584f :: needs real behavior proof before merge. :: none

Reviewed October 17, 2026, 11:14 AM ET / 15:14 UTC (Revision 2).

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@vincentkoc
vincentkoc merged commit 2000d96 into main Oct 17, 2026
66 of 69 checks passed
@vincentkoc
vincentkoc deleted the fix/comment-publication-diagnostics branch October 17, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant