Skip to content

fix(gateway): preserve static HEAD representation metadata - #117049

Merged
steipete merged 1 commit into
mainfrom
codex/qa-gateway-static-head-metadata
Jul 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-gateway-static-head-metadata

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Control UI static assets returned correct representation bytes for GET, but their HEAD responses omitted Content-Length. This affected the uncompressed asset and both precompressed Brotli/gzip sidecars, so clients probing the selected representation could not discover its actual size.

Why This Change Was Made

The existing safe-open owner already captures the authoritative pinned descriptor stat. Preserve that size through canonical representation selection and let the existing static-response owner emit the exact selected descriptor size for HEAD. Dynamic HTML remains deliberately untouched: its response is rewritten or compressed, and HEAD must not start reading or generating a body merely to manufacture a length.

User Impact

  • Static HEAD responses now report the same representation length as the equivalent GET for identity, gzip, and Brotli.
  • Content-Encoding, cache headers, and empty HEAD bodies stay correct.
  • Dynamic index HEAD retains its existing no-body/no-content-generation fast path.
  • No authentication, security, public protocol, configuration, SDK, or persistent-state behavior changes.

Evidence

Exact root cause and dependency contracts

src/gateway/control-ui.ts discarded opened.stat.size even though installed @openclaw/fs-safe obtains that stat directly from the opened descriptor (node_modules/@openclaw/fs-safe/dist/root-file.js:48 and node_modules/@openclaw/fs-safe/dist/pinned-open.js:37). Node's HTTP implementation suppresses HEAD bodies and cannot infer the representation length; the installed send implementation explicitly sets Content-Length before ending a HEAD response (node_modules/send/index.js:582).

Real production route and TCP, before/after

On exact base e4568f6bdddfc38d0f8dfe8cd22bde155adac5dd, actual loopback TCP requests through handleControlUiHttpRequest observed:

{"encoding":"identity","getLength":"19","headLength":null,"getEncoding":null,"headEncoding":null}
{"encoding":"gzip","getLength":"39","headLength":null,"getEncoding":"gzip","headEncoding":"gzip"}
{"encoding":"br","getLength":"23","headLength":null,"getEncoding":"br","headEncoding":"br"}

Exact immutable candidate e58b1861129d1fe7fe03aa97d8188ae46986bc8d:

{"encoding":"identity","getLength":"19","headLength":"19","getEncoding":null,"headEncoding":null}
{"encoding":"gzip","getLength":"39","headLength":"39","getEncoding":"gzip","headEncoding":"gzip"}
{"encoding":"br","getLength":"23","headLength":"23","getEncoding":"br","headEncoding":"br"}
{"route":"dynamic-index","headLength":null,"empty":true}
  • Regression-first run failed on all nine identity/gzip/Brotli cases across the three gateway Vitest projects before the fix.
  • Exact candidate owner suite: node scripts/run-vitest.mjs src/gateway/control-ui.http.test.ts --project gateway-core — 119 passed, 0 failed.
  • Exact candidate type-aware focused node scripts/run-oxlint.mjs ... --tsconfig config/tsconfig/oxlint.core.json, targeted oxfmt --check, and git diff --check: all passed.
  • Production delta +11/-7, net +4, necessary to carry the already-owned descriptor size and emit the genuinely missing response metadata; no fallback, compatibility shim, extra filesystem stat, or dynamic-body generation.
  • Fresh genuine whole-branch autoreview --mode branch --base e4568f6bdddfc38d0f8dfe8cd22bde155adac5dd --max-priority P3: zero P0/P1/P2/P3 findings, verdict “patch is correct”, confidence 0.97.
  • A separate strict immutable-candidate reviewer independently reproduced baseline/candidate real TCP behavior for all three encodings, configured roots, dynamic rewritten index and SPA routes, 404/406, hidden sidecars, outside symlinks, and configured hardlinks: zero P0/P1/P2/P3 findings, confidence 0.99.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Jul 31, 2026
@steipete
steipete marked this pull request as ready for review July 31, 2026 21:40
@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 5:46 PM ET / 21:46 UTC.

ClawSweeper review

What this changes

The PR preserves the pinned static file size through Control UI representation selection so static HEAD responses report the selected identity, gzip, or Brotli representation’s Content-Length.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This is a focused, correct-looking gateway fix with credible after-fix loopback TCP evidence for identity, gzip, and Brotli static assets. It remains open only for the protected maintainer review path and a final review of the clean three-way merge against current main; no patch defect was found.

Priority: P2
Reviewed head: e58b1861129d1fe7fe03aa97d8188ae46986bc8d
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary fix with direct static-route proof and regression coverage; only protected human merge review remains.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides after-fix loopback TCP output showing matching GET and HEAD lengths for identity, gzip, and Brotli, plus an empty dynamic-index HEAD response; redact any sensitive endpoint details if further proof is posted.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides after-fix loopback TCP output showing matching GET and HEAD lengths for identity, gzip, and Brotli, plus an empty dynamic-index HEAD response; redact any sensitive endpoint details if further proof is posted.
Evidence reviewed 6 items Current-main defect path: Current main returns only { path, fd } from the safe-open helper, representation selection retains only that shape, and the static HEAD branch calls the header helper without a length; therefore the selected static representation size is unavailable at the response owner.
Candidate owner-boundary repair: The hydrated PR diff adds opened.stat.size at the safe-open boundary, preserves it on the selected representation, and passes it only to the static HEAD response helper; dynamic index and SPA HEAD paths remain outside that new length argument.
Regression coverage: The candidate test exercises GET and HEAD for identity, gzip, and Brotli assets, asserts that HEAD uses the selected GET byte length, preserves Content-Encoding behavior, and confirms the HEAD body remains empty.
Findings None None.
Security None None.

How this fits together

The gateway serves Control UI static assets from a safely opened file descriptor, optionally selects a precompressed sidecar, then emits headers and either a body for GET or an empty response for HEAD. This change carries descriptor metadata from safe opening to the static HEAD response without changing dynamic HTML handling.

flowchart LR
  Client[HTTP client] --> Request[Control UI asset request]
  Request --> SafeOpen[Safe file open and descriptor stat]
  SafeOpen --> Select[Select identity or compressed representation]
  Select --> Head[Static HEAD response]
  Select --> Get[Static GET response]
  Head --> Headers[Representation headers and length]
  Get --> Body[Selected asset bytes]
Loading

Decision needed

Question Recommendation
Should this protected gateway fix be approved after reviewing its clean merge result against current main? Approve after merge refresh: Review the clean merge result against current main and land if the static-only boundary and dynamic HTML fast path remain unchanged.

Why: The patch has no supported correctness finding and the supplied real behavior proof covers the claimed static representations, but the maintainer label requires an explicit human merge decision.

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as mergeable but behind current main; protected maintainer review should confirm the final three-way merge keeps the focused static-only behavior.
Agent review details

Security

None.

PR surface

Source +4, Tests +32. Total +36 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 11 7 +4
Tests 1 33 1 +32
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 44 8 +36

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/control-ui.http.test.ts, vector/embedding metadata: src/gateway/control-ui.http.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the descriptor-metadata propagation after protected maintainer review confirms the clean merge result still sets Content-Length only for selected static representations and preserves dynamic HTML HEAD’s no-generation path.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the descriptor-metadata propagation after protected maintainer review confirms the clean merge result still sets Content-Length only for selected static representations and preserves dynamic HTML HEAD’s no-generation path.

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

Yes—current main is source-reproducible: the selected static representation retains only its path and descriptor, then the HEAD branch ends the response without any Content-Length source. Direct execution was not run in this read-only checkout because its dependency installation is absent, while the PR supplies matching before/after loopback TCP output.

Is this the best way to solve the issue?

Yes—the patch repairs the owner boundary by carrying the already-pinned descriptor size rather than reopening or restatting files, and it deliberately leaves dynamic HTML HEAD responses on their existing no-body path.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The change corrects static HTTP representation metadata with limited user and operator blast radius.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix loopback TCP output showing matching GET and HEAD lengths for identity, gzip, and Brotli, plus an empty dynamic-index HEAD response; redact any sensitive endpoint details if further proof is posted.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix loopback TCP output showing matching GET and HEAD lengths for identity, gzip, and Brotli, plus an empty dynamic-index HEAD response; redact any sensitive endpoint details if further proof is posted.

Label justifications:

  • P2: The change corrects static HTTP representation metadata with limited user and operator blast radius.
  • 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 (live_output): The PR body provides after-fix loopback TCP output showing matching GET and HEAD lengths for identity, gzip, and Brotli, plus an empty dynamic-index HEAD response; redact any sensitive endpoint details if further proof is posted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix loopback TCP output showing matching GET and HEAD lengths for identity, gzip, and Brotli, plus an empty dynamic-index HEAD response; redact any sensitive endpoint details if further proof is posted.

Evidence

What I checked:

  • Current-main defect path: Current main returns only { path, fd } from the safe-open helper, representation selection retains only that shape, and the static HEAD branch calls the header helper without a length; therefore the selected static representation size is unavailable at the response owner. (src/gateway/control-ui.ts:884, 383363e36233)
  • Candidate owner-boundary repair: The hydrated PR diff adds opened.stat.size at the safe-open boundary, preserves it on the selected representation, and passes it only to the static HEAD response helper; dynamic index and SPA HEAD paths remain outside that new length argument. (src/gateway/control-ui.ts:1214, e58b1861129d)
  • Regression coverage: The candidate test exercises GET and HEAD for identity, gzip, and Brotli assets, asserts that HEAD uses the selected GET byte length, preserves Content-Encoding behavior, and confirms the HEAD body remains empty. (src/gateway/control-ui.http.test.ts:2753, e58b1861129d)
  • Safe-open metadata is an established contract: Current gateway and adjacent runtime code already consume opened.stat.size; carrying that authoritative descriptor stat avoids a second filesystem lookup and follows the existing metadata ownership pattern. (src/gateway/control-ui.ts:889, 383363e36233)
  • Feature provenance: The current HEAD helper traces to Peter Steinberger’s control-UI work, while the candidate commit is a direct follow-up by the same area contributor on July 31, 2026. (src/gateway/control-ui-static.ts:236, e58b1861129d)
  • Current-main and release status: The candidate is not on the checked-out current main, which still lacks the length propagation. It is therefore not fixed in the supplied latest release provenance and needs normal PR landing rather than an implemented-on-main close. (src/gateway/control-ui-static.ts:236, 383363e36233)

Likely related people:

  • steipete: Peter Steinberger introduced the current Control UI HEAD helper, recently refactored gateway descriptor ownership in commit f47542c59206046cefba5a88ecbbff51bbca19bb, and authored this follow-up candidate. (role: feature owner and recent area contributor; confidence: high; commits: 51a78a4411bf, f47542c59206, e58b1861129d; files: src/gateway/control-ui.ts, src/gateway/control-ui-static.ts, src/gateway/control-ui.http.test.ts)

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 (1 earlier review cycle)
  • reviewed 2026-07-31T21:38:54.339Z sha e58b186 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P2 Normal backlog priority with limited blast radius. labels Jul 31, 2026
@steipete
steipete merged commit 4bbcee0 into main Jul 31, 2026
187 of 194 checks passed
@steipete
steipete deleted the codex/qa-gateway-static-head-metadata branch July 31, 2026 21:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 31, 2026
…odels-20260729

* origin/main:
  fix(tui): canonical terminal outcomes, cancellation, and error privacy (#117044)
  fix(cron): avoid phantom message tool guidance (#116908)
  fix(test): avoid macOS release gate deadlocks (#116972)
  fix(openai): canonical Chat cache-hit and billing accounting (#117043)
  fix(memory-wiki): salvage human Notes before pruning imported source pages (#102294)
  fix(memory): suggest reindex, not --fix, for a missing qmd index (#116958)
  chore(msteams): add private Gateway QA adapter
  fix(ui): make session controls and failures accessible (#117019)
  docs: fix tilde paths in CLI output examples (#114595)
  fix(plugins): canonical discovery diagnostics and deterministic lifecycles (#117025)
  fix(ui): honor Gateway readiness abort and subscription ownership (#117048)
  fix(updater): harden launchd replacement timing (#117030)
  fix(gateway): preserve static asset HEAD representation metadata (#117049)
  fix(gateway): abort embeddings when clients disconnect (#116146)
  fix(googlechat): retain fallback thread continuity (#117053)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR 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: S 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