Skip to content

fix(gateway): honor canonical If-Modified-Since validators - #117133

Merged
steipete merged 1 commit into
mainfrom
codex/qa-gateway-http-if-modified-since
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-gateway-http-if-modified-since

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Authenticated assistant-media and managed-media responses publish Last-Modified but ignored every If-Modified-Since request. Browser caches therefore re-downloaded unchanged images, audio, and video instead of receiving a bodyless 304 Not Modified; ranged requests could also transfer bytes before evaluating the date validator.

Independent real bearer-authenticated production HTTP against frozen main e857d8e5c690814ebd0d5e4e84d32174a537fdfa reproduced 24 incorrect responses across both routes, GET, HEAD, all three valid HTTP-date formats, range precedence, and future-dated files.

Why This Change Was Made

The canonical Gateway byte-response owner already controlled ETags, Last-Modified, Range, If-Range, and descriptor lifetimes. Its private request contract omitted If-Modified-Since, and both route callers duplicated incomplete header selection.

This refactor gives that existing owner one canonical Node HTTP-request contract and removes the duplicated three-header extraction from both callers. It obtains If-Modified-Since exclusively from Node's authoritative headersDistinct collection: Node silently discards duplicate singleton fields from normalized headers, so a date is accepted only when exactly one wire field exists. Its file-private HTTP-date parser strictly accepts IMF-fixdate, obsolete RFC 850, and ANSI C asctime; validates weekday, real calendar date, UTC, minimum four-digit year, leap seconds, and RFC 850's rolling 50-year rule. It compares against the actual second-precision, future-clamped Last-Modified emitted by that same response.

If-None-Match always takes precedence whenever present, including empty or nonmatching values. Invalid/multiple dates are ignored. Existing ETags, strong/date If-Range, range outcomes, 304 metadata, 401, 416, authentication, and descriptor ownership remain unchanged.

The full repair stays within three existing private production files. The two oversized route owners each become two lines shorter; there is no public API, protocol, configuration, authentication, security, persistent-state, SDK, AI/package dependency, fallback, or compatibility-shim change.

Protocol: RFC 9110 §5.6.7, HTTP-date, RFC 9110 §13.1.3, If-Modified-Since, and Node.js IncomingMessage.headersDistinct.

User Impact

  • Unchanged assistant and managed media now return metadata-only 304 responses for valid conditional GET and HEAD, avoiding duplicate transfers.
  • Legacy intermediaries using RFC 850 or ANSI C date formats interoperate correctly.
  • ETag-aware clients preserve authoritative ETag precedence, even when the ETag does not match.
  • Future-skewed filesystem clocks, resumed ranges, malformed dates, unauthorized access, and unsatisfiable ranges retain their existing correct behavior.

Evidence

Frozen current-main base: e857d8e5c690814ebd0d5e4e84d32174a537fdfa.

Final immutable candidate: de6e3fa773cc768b1614c7000c4a316055974b09.

Regression-first and focused owner/sibling suites

  • Exact frozen-main tests first produced 16 authentic failures across the shared owner and both private HTTP routes.
  • Independent review then caught two subtle date-parser defects before publication; each was reproduced with new failing regressions and repaired: four-digit years accidentally entering the RFC 850 two-digit century rule, and a leap second crossing the exact 50-year RFC 850 boundary.
  • Genuine whole-branch autoreview caught an additional real transport-boundary defect: Node silently discarded duplicate singleton date fields before the private owner saw them. Actual authenticated raw-TCP requests reproduced false 304 responses on both routes; the final canonical request contract uses authoritative headersDistinct and exact-one validation, with mixed-case duplicate-wire regressions.
  • The corrected immutable candidate passes all existing and new shared-owner, assistant-route, and managed-route tests:
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs \
  src/gateway/http-byte-range.test.ts \
  src/gateway/control-ui.http.test.ts \
  src/gateway/managed-image-attachments.test.ts

Test Files  3 passed (3)
     Tests  271 passed (271)
  • Focused oxlint --type-aware --type-check on all six changed files, targeted oxfmt --check, and git diff --check passed.

Real authenticated production HTTP

An independently owned proof started actual loopback TCP servers and exercised the unmocked assistant-media and managed-media production handlers with real bearer-authenticated requests, real files, past/future mtimes, full/ranged GET, and HEAD.

{"candidate":"de6e3fa773cc768b1614c7000c4a316055974b09","actualProductionAssertions":301,"strictIndependentDateOracleAssertions":74,"totalIndependentAssertions":375,"routes":["assistant-media","managed-media"],"baselineIncorrectResponses":24,"conditionalStatuses":[304,200,206,416,401],"validDateFormats":["IMF-fixdate","RFC850","asctime"],"bodyless304":true,"futureClampedLastModified":true,"etagPresencePrecedence":true,"duplicateRawWireFieldsIgnored":true}

All 301 actual production HTTP assertions and 74 independent adversarial HTTP-date oracle assertions passed. Genuine bearer-authenticated raw net.Socket requests exercised mixed-case, identical, triple, reversed, and comma-folded duplicate wire headers against both production routes and both methods; duplicate values never produced a false 304. Every legitimate 304 omitted body, Content-Length, and Content-Range while retaining ETag and the authoritative emitted Last-Modified. Invalid dates, 0000/0025/0099 years, wrong weekdays, impossible dates, rolling 2050/1977, and leap-second boundary cases were independently checked.

Review

Two independently acting agents reviewed the entire exact immutable owner, both complete route callers, sibling ETag/range implementations, direct Node/file/descriptor dependency behavior, scoped guidance, current main, and current RFC semantics. Both returned zero P0/P1/P2/P3 findings, confidence 0.99; the first personally reran the complete 271/271 suites, a 26/26 adversarial oracle, and 10/10 real mixed-case raw HTTP assertions.

Genuine complete-branch autoreview --mode branch --base e857d8e5c690814ebd0d5e4e84d32174a537fdfa --max-priority P3: zero P0/P1/P2/P3 findings, TruffleHog clean, verdict patch is correct, confidence 0.98.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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 Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 8:52 PM ET / August 1, 2026, 00:52 UTC.

ClawSweeper review

What this changes

The PR adds canonical If-Modified-Since handling to Gateway assistant-media and managed-media responses, returning bodyless 304 responses before range processing when the shared file validator is current.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main still evaluates only If-None-Match before range handling, so valid If-Modified-Since requests for authenticated media cannot produce 304 Not Modified. The branch centralizes the new validator in the shared byte-response owner used by both media routes, carries strong focused and real HTTP proof in its body, and has no concrete review finding. The maintainer label requires explicit owner review before landing.

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

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong real HTTP proof, focused regression coverage, and a canonical owner-boundary repair support a high-confidence patch-quality rating.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides after-fix authenticated production HTTP evidence for both routes, including GET/HEAD, ranges, duplicate raw headers, and bodyless 304 responses; redact any private endpoint or credential material if that proof is reposted.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides after-fix authenticated production HTTP evidence for both routes, including GET/HEAD, ranges, duplicate raw headers, and bodyless 304 responses; redact any private endpoint or credential material if that proof is reposted.
Evidence reviewed 6 items Current-main behavior remains incomplete: Current main computes Last-Modified and returns 304 only for a matching If-None-Match; it does not read or evaluate If-Modified-Since before range handling.
Canonical owner repair: The proposed shared planner reads one authoritative headersDistinct if-modified-since field, preserves If-None-Match precedence, compares against the emitted second-precision Last-Modified, and performs the validator decision before range processing.
Both production callers use the shared owner: The assistant-media and managed-media routes pass their real IncomingMessage to the shared response planner rather than independently selecting range and conditional headers.
Findings None None.
Security None None.

How this fits together

Gateway HTTP handlers authenticate assistant-media and managed outgoing-media requests, then pass the opened file and request validators to a shared byte-response planner. That planner selects a full, partial, unsatisfiable, or not-modified response before the descriptor-backed stream writes bytes.

flowchart LR
  A[Authenticated media request] --> B[Assistant or managed media route]
  B --> C[Verified local file]
  C --> D[Shared byte response planner]
  A --> D
  D --> E[Validator and range decision]
  E --> F[304 metadata response]
  E --> G[Descriptor-backed byte stream]
Loading

Decision needed

Question Recommendation
Should the Gateway owner accept this private canonical HTTP-date parser and conditional-response behavior for both authenticated media routes? Approve the canonical repair: Accept the shared planner change after the exact candidate head finishes its required checks; this preserves existing ETag and range behavior while adding standard date revalidation.

Why: The implementation is narrowly scoped and evidence-backed, but the protected maintainer label requires an explicit owner decision for the Gateway HTTP behavior change.

Before merge

  • Complete next step (P2) - The patch is a viable repair, but its protected maintainer label requires explicit Gateway-owner acceptance rather than automated repair or closure.
Agent review details

Security

None.

PR surface

Source +82, Tests +341. Total +423 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 99 17 +82
Tests 3 370 29 +341
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 469 46 +423

Review metrics

None.

Stored data model

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

Technical review

Best possible solution:

Keep one canonical conditional-response decision in src/gateway/http-byte-range.ts, land the focused repair after Gateway-owner approval and exact-head checks, and retain the paired route regressions as the compatibility boundary.

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

Yes, from source: current main emits Last-Modified but only recognizes If-None-Match, so a valid If-Modified-Since cannot select the existing not-modified plan. The PR body also supplies a concrete authenticated HTTP reproduction across both routes, although this read-only sandbox could not open a loopback listener to rerun it.

Is this the best way to solve the issue?

Yes. Moving request-header selection and conditional evaluation into the existing shared byte-response owner repairs both callers through one canonical flow and avoids route-specific validator policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The defect causes unnecessary authenticated media transfers on cache revalidation but does not break message delivery, authentication, or core runtime availability.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix authenticated production HTTP evidence for both routes, including GET/HEAD, ranges, duplicate raw headers, and bodyless 304 responses; redact any private endpoint or credential material if that proof is reposted.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • 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 authenticated production HTTP evidence for both routes, including GET/HEAD, ranges, duplicate raw headers, and bodyless 304 responses; redact any private endpoint or credential material if that proof is reposted.

Label justifications:

  • P2: The defect causes unnecessary authenticated media transfers on cache revalidation but does not break message delivery, authentication, or core runtime availability.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • 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 authenticated production HTTP evidence for both routes, including GET/HEAD, ranges, duplicate raw headers, and bodyless 304 responses; redact any private endpoint or credential material if that proof is reposted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix authenticated production HTTP evidence for both routes, including GET/HEAD, ranges, duplicate raw headers, and bodyless 304 responses; redact any private endpoint or credential material if that proof is reposted.

Evidence

What I checked:

  • Current-main behavior remains incomplete: Current main computes Last-Modified and returns 304 only for a matching If-None-Match; it does not read or evaluate If-Modified-Since before range handling. (src/gateway/http-byte-range.ts:85, 89394978e0a6)
  • Canonical owner repair: The proposed shared planner reads one authoritative headersDistinct if-modified-since field, preserves If-None-Match precedence, compares against the emitted second-precision Last-Modified, and performs the validator decision before range processing. (src/gateway/http-byte-range.ts:159, de6e3fa773cc)
  • Both production callers use the shared owner: The assistant-media and managed-media routes pass their real IncomingMessage to the shared response planner rather than independently selecting range and conditional headers. (src/gateway/control-ui.ts:731, de6e3fa773cc)
  • Regression coverage and real behavior proof: The branch adds shared-owner and both-route coverage for GET/HEAD revalidation, range precedence, ETag precedence, malformed dates, and duplicate wire fields. Its PR body records 301 production HTTP assertions across both authenticated routes plus 74 independent date-oracle assertions, with focused suites reported passing. (src/gateway/http-byte-range.test.ts:220, de6e3fa773cc)
  • Feature provenance: The current shared byte-response owner and its original ETag/range ordering appear to date to the recent Gateway work in this commit, making the same recent area contributor the clearest routing contact. (src/gateway/http-byte-range.ts:85, 7453dc714d4e)
  • Release provenance: The latest supplied release, v2026.7.1, points to a July 13 commit and predates this August 1 unmerged candidate; this repair is neither released nor already present on current main. (2d2ddc43d0dc)

Likely related people:

  • steipete: Peter Steinberger introduced the current shared byte-response implementation and most recently maintained both affected Gateway route surfaces on current main. (role: feature owner and recent area contributor; confidence: high; commits: 7453dc714d4e, afa8fffab882; files: src/gateway/http-byte-range.ts, src/gateway/control-ui.ts, src/gateway/managed-image-attachments.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.

@steipete
steipete merged commit a5d89e1 into main Aug 1, 2026
131 of 140 checks passed
@steipete
steipete deleted the codex/qa-gateway-http-if-modified-since branch August 1, 2026 00:56
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to pacocartones/openclaw that referenced this pull request Aug 1, 2026
* origin/main: (217 commits)
  fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909)
  fix(slack): let durable ingress retry transient thread lookups (openclaw#117135)
  refactor(doctor): consolidate shipped state migration ownership (openclaw#117142)
  fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966)
  fix: guard every migrated session accessor path (openclaw#117140)
  fix(terminal): measure unicode display width consistently (openclaw#117062)
  fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123)
  fix(mistral): reject incomplete streamed tool terminals (openclaw#117137)
  fix(ai): preserve structured chat content and refusals (openclaw#117136)
  fix(doctor): persist normalized agent roster (openclaw#117115)
  fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134)
  fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899)
  fix(gateway): honor HTTP If-Modified-Since media validators (openclaw#117133)
  fix(config): delete one array element per config patch delete (openclaw#116463)
  fix(plugins): report installed dependency health authoritatively (openclaw#117029)
  fix(ui): recover moving sessions across paged gateway rosters (openclaw#117016)
  fix(ui): clear hidden session selection before bulk deletion (openclaw#117015)
  fix(discord): avoid replaying ambiguous voice deliveries (openclaw#117127)
  fix(ui): scope Gateway reconnect lineage to its target (openclaw#117125)
  fix(models): expose runtime provider catalogs in browse views (openclaw#116857)
  ...
vincentkoc added a commit to yetval/openclaw that referenced this pull request Aug 1, 2026
* commit 'c41f033b87545b658215a9c3bbe03f88fbaa867d': (347 commits)
  refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146)
  fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909)
  fix(slack): let durable ingress retry transient thread lookups (openclaw#117135)
  refactor(doctor): consolidate shipped state migration ownership (openclaw#117142)
  fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966)
  fix: guard every migrated session accessor path (openclaw#117140)
  fix(terminal): measure unicode display width consistently (openclaw#117062)
  fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123)
  fix(mistral): reject incomplete streamed tool terminals (openclaw#117137)
  fix(ai): preserve structured chat content and refusals (openclaw#117136)
  fix(doctor): persist normalized agent roster (openclaw#117115)
  fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134)
  fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899)
  fix(gateway): honor HTTP If-Modified-Since media validators (openclaw#117133)
  fix(config): delete one array element per config patch delete (openclaw#116463)
  fix(plugins): report installed dependency health authoritatively (openclaw#117029)
  fix(ui): recover moving sessions across paged gateway rosters (openclaw#117016)
  fix(ui): clear hidden session selection before bulk deletion (openclaw#117015)
  fix(discord): avoid replaying ambiguous voice deliveries (openclaw#117127)
  fix(ui): scope Gateway reconnect lineage to its target (openclaw#117125)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
* commit '31f24547a94a8bd74a32e42cde1783591c5804d9': (347 commits)
  refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146)
  fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909)
  fix(slack): let durable ingress retry transient thread lookups (openclaw#117135)
  refactor(doctor): consolidate shipped state migration ownership (openclaw#117142)
  fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966)
  fix: guard every migrated session accessor path (openclaw#117140)
  fix(terminal): measure unicode display width consistently (openclaw#117062)
  fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123)
  fix(mistral): reject incomplete streamed tool terminals (openclaw#117137)
  fix(ai): preserve structured chat content and refusals (openclaw#117136)
  fix(doctor): persist normalized agent roster (openclaw#117115)
  fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134)
  fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899)
  fix(gateway): honor HTTP If-Modified-Since media validators (openclaw#117133)
  fix(config): delete one array element per config patch delete (openclaw#116463)
  fix(plugins): report installed dependency health authoritatively (openclaw#117029)
  fix(ui): recover moving sessions across paged gateway rosters (openclaw#117016)
  fix(ui): clear hidden session selection before bulk deletion (openclaw#117015)
  fix(discord): avoid replaying ambiguous voice deliveries (openclaw#117127)
  fix(ui): scope Gateway reconnect lineage to its target (openclaw#117125)
  ...
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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L 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