Repository navigation
pm-console: run queue and GitHub operations at the edge while the laptop is away - #12579
Conversation
…top is away The edge runs the real Ops and Work classes in the Durable Object once the laptop has been quiet for 60s, through a new edge run translator (edge/src/direct.ts): fleet gh api argv become GitHub REST calls, fleet secrets get becomes a Worker secret, and the queue store is already reached by fetch. Laptop-only verbs answer needs the laptop. Direct reads: board, prs, priorities, asks. Direct writes: ask.send, ask.reply, ask.close, issue.comment, need.comment, issue.rank, task.move. A new prompt files its issue at the edge and holds only prompt.enqueue for the laptop, which runs ops.enqueue on return; a reply posts its comment once at the edge and is never repeated. The no-twice rule stands: an action relayed with no answer is only ever resolved by the laptop. EdgeConfig gains queueDbUrl, queueTokenName, promptLabel, needsRepos. scripts/expose.py gains --edge-direct (off by default, remembered like --edge) provisioning GITHUB_TOKEN, QUEUE_TOKEN and EDGE_DIRECT; health reports the capability and an hourly self-check of one read of each kind. This supersedes the approach of PR #12548 for the PR read: its dedicated readOpenPullRequests/freshRead is replaced by Ops.prs() through the same run/fetch, so the PR read shares the one path. Tests: bun test 130 pass (was 110) — 13 direct translator tests, 6 new edge integration tests, 1 enqueue-hook test. The edge bundles: wrangler deploy --dry-run, 126.87 KiB. Refs #12518
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9caf45bfd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- direct.ts: send an explicit User-Agent with GitHub REST requests; Workers supplies none and GitHub requires it. - edge-proto.ts: accept configs stored or reported before direct mode (new direct fields empty); gate direct capabilities on the config carrying them instead of refusing the whole config. - edge.ts: hydrate the durable mirror before a first direct read, so a failed read after a restart keeps last-good data; keep notification refreshes from reloading the mirror over freshly read sections. - actions.ts: a failed deferred prompt.enqueue throws, so the held action is reported failed instead of recorded done with no queue task. - expose.py: remember the direct-mode choice only after the Worker has it, so a failed run retries instead of assuming the mode is set. Tests: 134/134 console tests (bun test), 19/19 expose tests; each new test fails against the pre-fix code.
The remaining accepted scope of #12518: board/ranked-issue/prompt fresh reads, one-call writes, and the queue-task contract for new prompts, following the #12548 pattern (real PM console classes, stand-ins only for GitHub and queue-store boundaries).
What it does
The edge runs the real
OpsandWorkclasses in the Durable Object once the laptop has been quiet for 60s, through a new edge run translator (pm-stack/console/edge/src/direct.ts):fleet gh api [-X M] <path> [--input -]argv become GitHub REST calls (method, path,-f k=vpairs as query or JSON body, stdin JSON); non-2xx returns code 1 with the error body on stderr, soalready_existsis still found.fleet secrets get <queueTokenName>returns the Worker secret.needs the laptop.fetch.Direct reads: board, prs, priorities, asks. Direct writes: ask.send, ask.reply, ask.close, issue.comment, need.comment, issue.rank, task.move. Sections the laptop already serves (sessions, census, questions, agents, services, more) stay laptop-only, as do
task.unblock/task.cancelandpr.merge.A new prompt files its issue at the edge and holds only
prompt.enqueuefor the laptop (a new held action inHOLDABLE+actions.ts, runningops.enqueue(promptPacket(...))on return). A reply posts its comment once at the edge and is never repeated when the laptop returns. The no-twice rule stands: an action relayed with no answer is only ever resolved by the laptop.Wiring
EdgeConfiggainsqueueDbUrl,queueTokenName,promptLabel,needsRepos(validated inedgeConfig(), carried through the EdgeLink config callback).scripts/expose.pygains--edge-direct on|off(default off, remembered like--edge): on uploadsGITHUB_TOKEN(Bitwardengithub.developing-today-code-automation),QUEUE_TOKEN(Bitwarden queue-token name) andEDGE_DIRECT=on; off putsEDGE_DIRECT=offand the tokens stay inert./console/healthreportsdirectEnabled,githubTokenConfigured,queueTokenConfigured,directReadyand a self-check (one direct read of each kind, cached 1h).ops.ts/work.tsare Worker-compatible: the node:fs/node:os/node:path imports are dynamic (laptop-only paths), andask/askReplytake an optional enqueue hook defaulting toops.enqueue— that hook is what the edge's recorder uses.Supersedes #12548's approach
This PR is from main, so it includes the PR read too — and it supersedes #12548's approach for the PR read: its dedicated
readOpenPullRequestsinedge/src/github.ts+freshReadhook duplicatesOps.prs(). This PR runs the PR read through the same run/fetch as everything else, so there is one path. #12548 can be closed once this lands. Its tests still pass unchanged.Verification
bun testin pm-stack/console: 130 pass, 0 fail (was 110). New: 13 translator tests (test/direct.test.ts), 6 edge integration tests (fresh reads after 60s silence; reply posted once, not repeated on laptop return; new prompt files the issue once and holds only the enqueue; close/rank/need-comment/move run at the edge; health + self-check; no-switch/before-quiet falls back to the host), 1 enqueue-hook test intest/work.test.ts.node build.mjs && wrangler deploy --dry-run— 126.87 KiB, Durable Object + Assets bindings listed.What remains for #12518
Live verification: deploy (the workflow provisions no secrets), run
scripts/expose.py --edge-direct on, then the acceptance's 5-minute stopped-service check against the real laptop-away state, and one real reply + one real new prompt end to end. The code for all of it is in this PR; the live run needs the deploy + secrets, which this seat cannot do from here.Refs #12518
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.