Skip to content

feat(gateway): inspect HTTP headers without buffering responses - #157457

Merged
vincentkoc merged 6 commits into
mainfrom
split/ios-access-http-probes-20260925
Sep 25, 2026
Merged

vincentkoc merged 6 commits into
mainfrom
split/ios-access-http-probes-20260925

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Related: #147238

What Problem This Solves

Native ingress detection needs response headers without downloading a complete sign-in page. URLSession AsyncBytes still waits for a refused redirect's response body, so a stalled sign-in page can stall that probe.

User Impact

This shared Apple transport prerequisite enables header inspection through the existing certificate and redirect policy. Browser setup and reauthorization remain in later app PRs; this PR does not activate them.

Why This Change Was Made

GatewayTLSPinningSession.response(for:) creates a data task on the existing session. A request-owned delegate completes from ordinary response headers or the refused-redirect callback, then cancels the unused body. Redirect decisions and unimplemented authentication callbacks retain the existing session owner. No additional session or trust policy is introduced.

Two files: +73 production lines and +209 test lines. The private delegate is necessary to return refused redirect headers before their body finishes; the bounded-data reader remains intact.

Staging decision approved by @vincentkoc on September 25, 2026: retain the one declaration-specific periphery:ignore on the public response method for this prerequisite. Remove it when the first production app caller lands. The redundant private-delegate ignore was removed because Periphery retains references of ignored declarations. This approval is limited to this method; scanner policy and global exclusions do not change.

Evidence

  • Current head: a604a2c9c82dfa030aa2b6a2fdcd44ed366f0723, rebased onto main 19379a17f9f499cc031768b4f63d0282f8f3426d, which includes fix(gateway): restore native lint after transport changes #157516. That separate +22/-22 move repaired the inherited GatewayChannel file-length failure. This PR also moves its retention comment above the API documentation to fix the orphaned-doc-comment failure.
  • SwiftFormat 0.63.0 with the target configuration, focused strict SwiftLint 0.65.0 on the production file with the target iOS configuration, and git diff --check pass. Current-head hosted CI passed after removing unnecessary suite serialization. ClawSweeper revision 7 found no actionable code or security findings; its sole owner decision is approved above. Each case owns its listener, ephemeral port, session, streams, and cleanup; fixture mutation stays MainActor-isolated. No shared pin or Keychain state is used.
  • Four test methods exercise six real loopback URLSession cases: incomplete 200/302 bodies, refusal of a grant-bearing redirect, an explicitly enabled redirect, an oversized body, and cancellation of both the header probe and bounded reader. The incomplete fixtures send one of ten advertised body bytes and keep the connection open; headers must arrive within three seconds. Readiness, request receipt, cancellation, and teardown are bounded.
  • Current-head native proof: package job passed 1,796 tests across 142 suites in 33.917 seconds. All six probe cases passed concurrently in 7.158 seconds; the complete package job took 542 seconds including setup, compilation, and other packages. CI tested merge 9170ec01 of this head into main 1a7ba53b45ed87ba93b5ee7bf986861b4068ddfe. Required CI and security gates passed; native iOS/macOS and Android checks passed.
  • Main drift checked through 04fb3c8e35b3e1cb88630c797ac3ce4e50f38735: neither changed file, its timeout owner, Swift package contract, nor formatter configuration changed. Nearby shared changes add unrelated protocol fields and advance the native SQLite reader version ceiling. No transport conflict or new implementation input requires rewriting the reviewed head.
  • A separate Foundation diagnostic using the exact method/delegate with a stub redirect owner returned incomplete 200 in 0.009s, refused 302 in 0.001s, and enabled 302-to-200 in 0.001s, before body completion. Transport error -1005 and CancellationError propagated. This proves the Foundation boundary, not a complete-module TLS handshake.
  • Inspected Apple's installed NSURLSession.h:314-322 task-delegate forwarding/lifetime contract and Periphery 3.8.0 comment-command/reference-retention behavior. Existing iOS/macOS media and source-resource callers were inspected; desktop application production files do not change.
  • Known main-baseline finding: current-head shared Periphery intersection reports only the staged GatewayExternalAuthorizationError introduced by feat(gateway): preserve browser sign-in requirements before connecting #157454, before its app producer lands. That separate retention/activation decision is tracked in fix(gateway): restore native lint after transport changes #157516; this PR does not alter that type.

Before app activation: prove pinned HTTPS behavior, isolate typed HTTP trust diagnostics per request, and complete the app's browser/upgrade/UI proof and separately requested security review. Plain HTTP loopback tests do not prove a real TLS handshake or cancellation after the bounded reader has entered its body loop.

@vincentkoc vincentkoc self-assigned this Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 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 September 24, 2026 17:54
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 25, 2026, 3:24 AM ET / 07:24 UTC (Revision 8).

ClawSweeper review

What this changes

The branch adds a shared Apple transport method that returns HTTP response headers before an unfinished body completes, with native loopback tests for redirects, size limits, and cancellation.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main and the latest release lack the header-only transport behavior, and the paired iOS work has not landed. The prior review’s temporary scanner-exception decision is now recorded in the member-authored PR body; no introduced correctness defect is evident.

Priority: P2
Reviewed head: a604a2c9c82dfa030aa2b6a2fdcd44ed366f0723

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused implementation and real transport evidence support a good PR; the staged method has a documented scanner exception and no app caller yet.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed OpenClawKit response method ran through real loopback URLSession requests on the native CI host: incomplete 200 and refused-302 bodies returned headers before completion, with redirect and cancellation cases passing. The separate Foundation diagnostic supports the same boundary; pinned HTTPS remains for app activation. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed OpenClawKit response method ran through real loopback URLSession requests on the native CI host: incomplete 200 and refused-302 bodies returned headers before completion, with redirect and cancellation cases passing. The separate Foundation diagnostic supports the same boundary; pinned HTTPS remains for app activation. No stored-data contract changes.
Evidence reviewed 8 items Current main still needs the capability: The current-main transport has the bounded body reader and redirect policy but no response-only method.
Introduced transport behavior: The pinned merge-base-to-head diff adds a data task on the existing session and a response delegate that completes from headers and cancels the unused body.
Redirect ownership: The request delegate consults the existing session redirect decision and returns refused-redirect headers before canceling the task.
Findings None None.
Security None None.

How this fits together

OpenClawKit supplies network transport to OpenClaw’s Apple apps. App requests pass through its URLSession certificate and redirect policy; this new method returns response headers to a future ingress probe and cancels the unused body.

flowchart LR
A[Apple app request] --> B[Shared Apple transport]
B --> C[Certificate policy]
C --> D[URLSession task]
D --> E{Redirect allowed?}
E --> F[Response headers]
F --> G[Cancel unused body]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Other +282. Total +282 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 282 0 +282
Total 2 282 0 +282

Review metrics

Metric Value Why it matters
Production versus test growth production +73, tests +209 The request delegate explains the production growth, while the tests exercise the unfinished-body transport contract.
Staged public method 1 added, 0 production callers The temporary declaration-specific scanner exception has a recorded removal point at app activation.

Technical review

Best possible solution:

Let the iOS ingress owner consume this method in its activation PR, remove the targeted scanner exception then, and verify pinned HTTPS and credential isolation at that boundary.

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

Not applicable to a current-main bug report: this PR adds a transport capability. Its native loopback fixture does reproduce the unfinished-body condition that motivates the method.

Is this the best way to solve the issue?

Yes. A request-owned delegate on the existing pinned session is a focused way to return refused-redirect headers early while retaining the established certificate and redirect policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fc3b2dca233a.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded Apple transport prerequisite without activated app behavior.
  • merge-risk: 🚨 automation: The accepted Periphery exception suppresses dead-code reporting for one staged public method until its first production caller lands.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed OpenClawKit response method ran through real loopback URLSession requests on the native CI host: incomplete 200 and refused-302 bodies returned headers before completion, with redirect and cancellation cases passing. The separate Foundation diagnostic supports the same boundary; pinned HTTPS remains for app activation. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed OpenClawKit response method ran through real loopback URLSession requests on the native CI host: incomplete 200 and refused-302 bodies returned headers before completion, with redirect and cancellation cases passing. The separate Foundation diagnostic supports the same boundary; pinned HTTPS remains for app activation. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Gio Della-Libera: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-24T17:58:27.522Z sha e2c216a994577600a45a9e73950758dd490d10d4 :: needs changes before merge. :: [P2] Keep the body unfinished in the header-only test
  • reviewed 2026-09-24T18:27:09.642Z sha b424eec167dab81857a27d705bbfa32b569b3e02 :: needs changes before merge. :: none
  • reviewed 2026-09-24T19:14:42.400Z sha 57e04417518cffeb0edf9f9a370d81552a832112 :: blocked before merge. :: none
  • reviewed 2026-09-24T19:23:12.568Z sha 57e04417518cffeb0edf9f9a370d81552a832112 :: blocked before merge. :: none
  • reviewed 2026-09-24T19:54:18.678Z sha 43e3790 :: blocked before merge. :: [P3] Remove the new serialized suite setting
  • reviewed 2026-09-24T20:08:38.290Z sha a604a2c :: blocked before merge. :: none
  • reviewed 2026-09-24T20:15:46.937Z sha a604a2c :: blocked before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 3e400916985f21f2cd0ecb33ef6bf5dd0afed3d1. Both 200 and 302 probe cases now send only headers, advertise ten body bytes, and keep the connection open. The probe must return within three seconds, proving it does not await even the first body byte. The production addition remains eleven lines. Current-head native CI is pending.

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review current head b424eec167dab81857a27d705bbfa32b569b3e02. Native CI exposed an actual declined-redirect body stall; the request-owned delegate now completes from the redirect callback while retaining the session owner for redirect decisions and authentication. The incomplete-body 200/302 regression remains, and cancellation now covers header probes as well as bounded reads. The PR body records the native Foundation diagnostic, its limits, and fresh CI status.

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 24, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Current head: 57e04417518cffeb0edf9f9a370d81552a832112. The only change since the reviewed b424eec167dab81857a27d705bbfa32b569b3e02 is two repository-standard per-declaration retention comments for the intentionally staged public ingress probe and its private response owner. No runtime or test behavior changes. The PR body records the previous complete native CI proof, the Periphery finding and its scope, and pending fresh checks.

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 24, 2026
@vincentkoc
vincentkoc force-pushed the split/ios-access-http-probes-20260925 branch from 57e0441 to 43e3790 Compare September 24, 2026 19:46
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 43e3790bc3954c1d0ca5db6c5632be142f259c47. Rebased onto main containing the separately landed file-length repair in #157516; moved the public retention comment above its documentation and removed the redundant private-delegate ignore. The PR body records one pending staged-API exception decision and the separate inherited external-authorization-type Periphery finding. Fresh native CI is running; prior proof is explicitly marked historical.

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head a604a2c9c82dfa030aa2b6a2fdcd44ed366f0723. Removed the unnecessary suite serialization identified in revision 5: fixtures own separate listeners, ephemeral ports, sessions, streams, and cleanup; MainActor protects fixture mutation. No production change since the previous review. Fresh native CI will verify concurrent execution. The PR body retains the explicit pending decision for the one temporary public-method Periphery ignore and the separate inherited external-authorization-type finding.

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc
vincentkoc merged commit 96c05e6 into main Sep 25, 2026
89 of 91 checks passed
@vincentkoc
vincentkoc deleted the split/ios-access-http-probes-20260925 branch September 25, 2026 07:25
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…claw#157457)

* feat(gateway): inspect HTTP headers without buffering responses

* test(gateway): leave probe response bodies incomplete

* fix(gateway): return refused redirect headers before body completion

* fix(gateway): retain public HTTP probe for ingress callers

* fix(gateway): keep probe documentation attached to its API

* test(gateway): allow independent HTTP probes to run concurrently

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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