Skip to content

feat(session-ingest): route fenced browser providers - #5648

Open
iscekic wants to merge 4 commits into
browser-task-0787-s2from
browser-task-0787-s3
Open

feat(session-ingest): route fenced browser providers#5648
iscekic wants to merge 4 commits into
browser-task-0787-s2from
browser-task-0787-s3

Conversation

@iscekic

@iscekic iscekic commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

No new behavior — this change prepares browser tasks but does not add controls that people can use.


Summary

browserJobsV1 now negotiates authenticated BrowserRequest and BrowserProviderOutboundMessage routing through heartbeat_ack and pong; legacy clients retain unchanged responses.
WSAttachment and BrowserProviderBinding preserve parent-authorized delivery, provider generations, and dispatch acknowledgement through hibernation and subscription races; reconnects alone cannot transfer authority.
The ledger enforces approval, cancellation, and recovery without dispatch replay; one composed alarm preserves browser deadlines, retention, and legacy alarms.

Files
  • services/session-ingest/src/dos/UserConnectionDO.ts — Source; modified (M); 608 changed lines (+506/−102). Routes list, invoke, status, cancel, and recover. Missing capabilities and failed acknowledgements disable browser traffic. Roles separate requests from provider updates; parent proofs, not heartbeats or connection identifiers, authorize access. Discovery lists labels, identifiers, availability, and queue counts separately from command-line interface (CLI) instances. Registration binds one provider and generation per socket; replies, progress, results, lease acknowledgements, and bounded snapshots remain private. Serialized commits precede sends; acceptance precedes dispatch. Each invocation needs tab approval; only quiescence advances the queue. Cancellation settles before forwarding and rejects late success; uncertain cancellation interrupts queued jobs. Provider loss, replacement, revocation, disablement, or shutdown settles jobs without clearing uncertain execution fences. Provider recovery requires proof plus confirmation of tab closure and drained locks. CLI loss preserves jobs; proven lookup or recovery rebinds delivery. Hibernation preserves acknowledged work, resends pending cancellations, and interrupts unacknowledged dispatch without replay. Heartbeats preserve socket identity; reconstruction ignores replaced sockets, and CLI lookups select open, unreplaced sockets. Delayed subscriptions reload attachments to preserve negotiation, registration, dispatch acknowledgement, and close or replacement markers. The scheduler replaces competing writers and combines queue, approval, execution, lease, and retention deadlines with heartbeats, commands, and ready pushes. It restores ready pushes, includes completed commands, ignores malformed deadlines, schedules overdue work now, and deletes empty alarms. Legacy dispatch does not wait for alarm reads. Browser errors preserve retryability and omit proofs; provider errors retain the legacy response envelope.
  • services/session-ingest/src/dos/UserConnectionDO.test.ts — Test; modified (M); 1,421 changed lines (+1,411/−10). Adds coverage for negotiation, private discovery, parent isolation, provider generations, approval, cancellation, recovery, deadlines, hibernation, reconnects, and delayed subscriptions. The mocks clone attachments, track closed sockets, serialize atomic transactions, and expose alarm state. The helpers accept authenticated CLI identities; legacy assertions await scheduling, and a regression case checks command dispatch during delayed alarm reads.

The default suite restricts UserConnectionDO alarm writes to scheduleNextAlarm through a TypeScript abstract syntax tree (AST) inventory.
setAlarm and deleteAlarm aliases count as writers; unrelated text and other Durable Objects do not.
Independent writers, a missing target class, and an empty inventory fail the check, so new scheduling code must use the composed scheduler.

Files
  • services/session-ingest/src/dos/browser-alarm-inventory.test.ts — Test; added (A); 187 changed lines (+187/−0). Adds the inventory and synthetic checks for direct, computed, destructured, bound, chained, and class-field aliases. Checks reject missing or empty inventories and exclude other Durable Object classes.

Tests: 2 files changed — UserConnectionDO.test.ts modified and browser-alarm-inventory.test.ts added; 1,598 insertions and 10 deletions.
Generated: 0 files changed.


Visual Changes

Visual Changes: N/A

Verification

  • Manual verification: pending on the stack tips. Client integration follows in later levels, and the handoff attaches no end-to-end (E2E) report.

Reviewer Notes

Human steps

  • before merge — After all section pull requests receive human-ready, merge each repository's levels from bottom to top.
  • This level requires no additional environment value, secret, or migration.

Automated evidence

  • The initial round passed 321 tests; the repair added four regression cases that failed before the fix.
  • The supplied repair evidence records 5/5 checks passed: formatting, format verification, lint, the focused tests, and whitespace verification.
  • Both focused suites passed with pnpm --filter cloudflare-session-ingest exec vitest run --no-cache --configLoader runner src/dos/UserConnectionDO.test.ts src/dos/browser-alarm-inventory.test.ts.
  • The supplied evidence does not establish continuous integration (CI) or live verification.

Scope and dependencies

Notes

Runtime verification remains pending on the stack tips. Browser traffic requires explicit capability negotiation; client integration follows in later levels.

Stacked PRs — merge bottom to top. Each level shows only its own diff.

Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.

  1. browser-task-0787feat(browser-task): define negotiated job contracts #5638
  2. browser-task-0787-s2feat(session-ingest): persist owned browser jobs #5644
  3. browser-task-0787-s3feat(session-ingest): route fenced browser providers #5648 ← this PR
  4. browser-task-0787-s4feat(cloud-agent-sdk): support browser provider jobs #5653
  5. browser-task-0787-s7fix(extension): expose honest browser runner outcomes #5681 (tip)

this.ensureState();

const now = Date.now();
await this.runBrowserOperation(async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Browser expire/cleanup failures abort the entire alarm() handler

expire() / cleanup() (and restoreBrowserState() inside runBrowserOperation) can throw BrowserJobStoreError on parse failure, a deadline row whose job is missing, or capacity. That rejection skips expirePendingCommands, stale-CLI eviction, and scheduleNextAlarm.

Cloudflare retries a throwing alarm(), so a persistent ledger fault becomes a poison pill: heartbeat timeouts and pending-command TTLs never run. fireReadyPushes and the durable pending-command sweep in this same handler already isolate failures; this new block should too.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/session-ingest/src/dos/UserConnectionDO.ts 926 Browser expire/cleanup failures abort the entire alarm handler, blocking heartbeat timeouts and pending-command TTLs
Files Reviewed (3 files)
  • services/session-ingest/src/dos/UserConnectionDO.ts - 1 issue
  • services/session-ingest/src/dos/UserConnectionDO.test.ts - 0 issues
  • services/session-ingest/src/dos/browser-alarm-inventory.test.ts - 0 issues

Fix these issues in Kilo Cloud

Previous Review Summary (commit 431610a)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 431610a)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/session-ingest/src/dos/UserConnectionDO.ts 897 Browser expire/cleanup failures abort the entire alarm handler, blocking heartbeat timeouts and pending-command TTLs
Files Reviewed (3 files)
  • services/session-ingest/src/dos/UserConnectionDO.ts - 1 issue
  • services/session-ingest/src/dos/UserConnectionDO.test.ts - 0 issues
  • services/session-ingest/src/dos/browser-alarm-inventory.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 94.3K · Output: 13.5K · Cached: 446.3K

Review guidance: REVIEW.md from base branch browser-task-0787-s2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant