Skip to content

fix(gateway): avoid preview errors during worker metadata updates - #157943

Merged
steipete merged 1 commit into
mainfrom
codex/portal-stream-ci-20260924
Sep 25, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/portal-stream-ci-20260924

Conversation

@steipete

@steipete steipete commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Related: #154069

What Problem This Solves

Fixes intermittent “Waiting for app” responses when a session preview opens while unchanged worker metadata is being published.

User Impact

Session previews remain available during metadata reconciliation. Attachment replacement, closure, activity changes, and session revocation retain their existing fences. No configuration, schema, or migration changes are required.

Why This Change Was Made

The worker inventory fenced attachment reads for every pending environment write. The existing native commit admission now includes equality evidence for the complete attachment record, including its activity timestamp. The projection permits the read only when that record is unchanged and keeps the digest within its existing publication and disposal lifecycle.

Evidence

  • Reproduced the original 27-file CI partition failure on Linux, then made the actual Gateway → node → HTTP regression deterministic by holding an unchanged metadata commit before publication. It fails on the original owner and passes with this fix.
  • The original partition, HTTP regression, and 129 owning/sibling tests passed. Coverage includes unknown/missing facts, attachment replacement and movement, provider revocation, and stale idle cleanup behind a pending touch.
  • Managed independent P2 review: scoped-clean, no actionable findings.
  • Changed formatting, core and test typechecks, lint, and repository guards passed.

Single-worker costs on Linux / Node 24.21.0, measured with node scripts/run-vitest.mjs <file> --maxWorkers=1 (wall time includes preparation and verification):

Expanded test file Cases Wall time
src/gateway/server.portals.session.test.ts 1 12.58 s
src/gateway/worker-environments/store-projection.test.ts 13 6.16 s
src/gateway/worker-environments/store-worker.test.ts 18 25.49 s

Ready-event product CI passed for this head in 872 seconds of total workflow wall time, including its parallel jobs. The skipped draft run is excluded. All runtime proof used synthetic state and temporary listeners.

@clawsweeper

clawsweeper Bot commented Sep 25, 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.

@steipete
steipete marked this pull request as ready for review September 25, 2026 05:50
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Sep 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: f0133582a13f3e03f1eba8716edc9ab51d7d316f
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/worker-environments/store-commit-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 25, 2026, 2:11 AM ET / 06:11 UTC (Revision 2).

ClawSweeper review

What this changes

Allows Gateway session previews during worker metadata commits when the conversation attachment is unchanged, and adds regression tests and storage documentation.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still has the reported preview fence, and this branch is a viable focused fix. The prior request for measured test costs has been addressed.

Priority: P2
Reviewed head: f0133582a13f3e03f1eba8716edc9ab51d7d316f

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused commit-boundary repair with a real transport regression, changed-authority controls, measured test costs, and no actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR reports a before-fix failure and after-fix pass for a held worker commit through the production Gateway, node WebSocket, and HTTP preview path; the changed projection is exercised while publication is delayed, and the test observes the streamed app response. The digest is process-local projection state, so no stored-data migration applies.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports a before-fix failure and after-fix pass for a held worker commit through the production Gateway, node WebSocket, and HTTP preview path; the changed projection is exercised while publication is delayed, and the test observes the streamed app response. The digest is process-local projection state, so no stored-data migration applies.
Evidence reviewed 8 items Current main retains the failure: Current main excludes attachment reads from the unchanged-authority exception during a pending worker mutation.
Introduced equality fence: The proposed projection permits a pending attachment read only when the worker's postcommit attachment digest equals the published digest; publication replaces that digest with the new fact.
Worker fact provenance: The owning SQLite transaction reads affected postimage facts before requesting commit admission; the new digest covers the complete attachment record. The attachment table allows one attachment per environment.
Findings None None.
Security None None.

How this fits together

Gateway session previews route an authorized browser request through a node to a worker's HTTP app. The Gateway reads worker attachment facts from a projection published after SQLite worker commits.

flowchart LR
A[Browser preview request] --> B[Gateway session access]
C[SQLite worker commit] --> D[Attachment projection]
B --> D
D --> E{Attachment unchanged?}
E -->|Yes| F[Node and app stream]
E -->|No| G[Read fenced until publication]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +34, Tests +183, Docs +4. Total +221 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 38 4 +34
Tests 3 210 27 +183
Docs 1 5 1 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 253 32 +221

Review metrics

Metric Value Why it matters
Expanded test wall times 12.58 s, 6.16 s, 25.49 s The PR body now measures each expanded test file, resolving the prior review finding.

Technical review

Best possible solution:

Keep the complete attachment-record comparison in worker commit admission and projection publication, while retaining live session, environment, lease, and node checks before preview dispatch.

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

Yes. Hold an unchanged worker metadata commit before projection publication and fetch its existing session preview; current-main source shows the read fence. This read-only review did not execute the test.

Is this the best way to solve the issue?

Yes. Comparing the worker's complete attachment postimage is a narrow repair, and existing live checks still govern the final preview connection.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Intermittent preview errors affect a bounded Gateway workflow.
  • merge-risk: 🚨 security-boundary: The patch relaxes a preview attachment-read fence, so its complete-record comparison and final live-authority checks merit explicit review.
  • 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 (terminal): The PR reports a before-fix failure and after-fix pass for a held worker commit through the production Gateway, node WebSocket, and HTTP preview path; the changed projection is exercised while publication is delayed, and the test observes the streamed app response. The digest is process-local projection state, so no stored-data migration applies.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports a before-fix failure and after-fix pass for a held worker commit through the production Gateway, node WebSocket, and HTTP preview path; the changed projection is exercised while publication is delayed, and the test observes the streamed app response. The digest is process-local projection state, so no stored-data migration applies.

Evidence

What I checked:

  • Current main retains the failure: Current main excludes attachment reads from the unchanged-authority exception during a pending worker mutation. (src/gateway/worker-environments/store-projection.ts:98, c1051da16eff)
  • Introduced equality fence: The proposed projection permits a pending attachment read only when the worker's postcommit attachment digest equals the published digest; publication replaces that digest with the new fact. (src/gateway/worker-environments/store-projection.ts:188, f0133582a13f)
  • Worker fact provenance: The owning SQLite transaction reads affected postimage facts before requesting commit admission; the new digest covers the complete attachment record. The attachment table allows one attachment per environment. (src/gateway/worker-environments/store.worker.ts:137, f0133582a13f)
  • Current authorization remains in the path: Attachment projection also reads the environment record, and the portal handler rechecks session and attachment authority before opening and serving the node stream. (src/gateway/worker-environments/session-attachment-service.ts:107, f0133582a13f)
  • Production-boundary regression: The test holds a completed worker metadata operation before projection publication, then requests a streamed preview through the Gateway, node transport, and HTTP destination; the same test includes a denied caller and later revocation checks. The PR body reports a before-fix failure and after-fix pass. (src/gateway/server.portals.session.test.ts:390, f0133582a13f)
  • Prior feedback resolved: The captured PR body now gives single-worker wall times of 12.58, 6.16, and 25.49 seconds for the three expanded test files, plus 872 seconds for the ready-event CI workflow. This addresses the earlier ClawSweeper cost finding.

Likely related people:

  • Peter Steinberger: Raw commit c768bd1 adds src/gateway/worker-environments/store-projection.ts:97 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c768bd125a14; files: src/gateway/worker-environments/store-projection.ts)
  • Vincent Koc: Raw commit c7bab50 adds src/gateway/server-methods/portals.session.ts:104 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c7bab50e6ed7; files: src/gateway/server-methods/portals.session.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-09-25T05:57:23.051Z sha f013358 :: needs changes before merge. :: [P3] Record the cost of each expanded test file

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 25, 2026
@steipete
steipete merged commit c911a70 into main Sep 25, 2026
290 of 291 checks passed
@steipete
steipete deleted the codex/portal-stream-ci-20260924 branch September 25, 2026 06:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 25, 2026
…4-prep

* commit '8fe893da516ebdc817692fb2d272e27bc3c88376': (31 commits)
  fix(test): wait for reload admission before restart polling (#157964)
  refactor(mattermost): reuse DM retry option selection (#157800)
  chore(i18n): refresh native locales (#157850)
  perf(sessions): reuse current participants across transcript appends (#157622)
  refactor(signal): share pending transport migration results (#157777)
  fix(tui): open model pickers without waiting for the Gateway (#157839)
  fix(gateway): apply config despite delayed file notifications (#157906)
  fix(auth): clear deleted account selections and support account recovery (#157745)
  fix: plugin reloads lose tool results and strand subagent settlement (#157339)
  fix(gateway): avoid preview errors during worker metadata updates (#157943)
  refactor(diffs): reuse native promisify for compression (#157835)
  fix(models): keep current choices on the first picker page (#157869)
  fix(plugins): retain existing quarantine across unrelated reloads (#157907)
  fix(openai): prioritize ChatGPT sign-in and clarify auth choices (#157792)
  chore(ui): refresh control ui locales (#157955)
  fix(ui): refresh connected accounts after auth changes (#157950)
  fix(scripts): avoid redundant npm version process in package checks (#157809)
  refactor(usage): capture hosted pricing once per operation (#157838)
  refactor(ui): share slash-command failure results (#157649)
  fix(cron): announce runs miss the channel's formatting rules (#157877)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. security-sensitive-changed 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