Runs borrow browser sessions: materialize, exclusive persist, stale parking - #243
Open
czpython wants to merge 1 commit into
Open
Runs borrow browser sessions: materialize, exclusive persist, stale parking#243czpython wants to merge 1 commit into
czpython wants to merge 1 commit into
Conversation
…arking A workflow declares browser_session (a name; get_browser_session() for per-run resolution) and optionally persist_session. The run's sandboxes become browser-flavored, and around each agent call's workspace construction druks decrypts the active payload, stages it under /work/session/ with its meta, and scrubs it again before the agent starts — the deterministic extension script is the only thing that ever drives the logged-in browser, and a reused warm host is scrubbed even when the run never borrowed. Read-only borrows run in parallel and close the launcher without exporting. A persisting borrow holds the session's Redis writer lock — owner token, TTL renewed while the sandbox lives, compare-and-delete release so a stale holder can never free the new holder's lock — and writes back only when a browser actually ran: session-export in the sandbox, then the vault's envelope + compare-and-set pointer move. A pointer that moved since the borrow raises the typed conflict, which lands as the run's terminal failure and survives restart; the session stays ready. workflow.browser_session_invalid() marks the borrowed session stale and parks the run on the ordinary review() gate; the operator reconnects and answers approve. Payload-sized crypto runs off the event loop under one memory slot, plaintext staging files are 0600 and reaped at boot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Third phase of browser sessions as a druks primitive (stacked on #242). The borrow contract: a run gets a logged-in browser materialized from the vault, with read-only parallelism, exclusive persistence, and first-class staleness.
browser_session(a name; overrideget_browser_session()to resolve per run) andpersist_sessionon the Workflow — the same declaration pattern assteps_reuse_sandbox. Declaring a borrow makes the run's sandboxes browser-flavored via the P1 client flag, both for the warm host and for per-call ephemeral VMs./work/session/withstate.meta.json, and scrubs/work/session/again before the agent starts — the extension's deterministic script (which itself invokessession-launch) is the only thing that ever drives the logged-in browser; the agent sees extracted data only. A warm host is also scrubbed for runs that never borrowed, so a host left dirty by a dead worker is clean before its next use. Staging temp files are removed infinallyand the boot reaper sweeps stragglers.browser_session:<id>, shared with the future login window. Owner token, TTL renewed by a background holder task, atomic compare-and-delete release (Lua) — a stale holder cannot delete the new holder's lock. Read-only borrows never lock and overlap freely.session-exportcloses the browser and produces the archive in-sandbox, then the vault's envelope + compare-and-set pointer move — the same path P2 uploads take. A pointer that moved since the borrow raises the typed conflict, which lands as the run's terminal failure (durably, visible after restart); the session stays ready. Read-only borrows close the launcher without exporting.workflow.browser_session_invalid()marks the borrowed session stale (as a replay-safe step) and parks the run on the ordinaryreview()gate; the operator reconnects in settings and answers approve. No auto-resume.last_used_atbumps per borrow; docs gain a borrow section in the extension guide.Testing
profile_dir.workflow.failedevent after the session cache is dropped; the newer version stays active./work/session/empty after a dead worker left state behind.