Skip to content

pm-console: run queue and GitHub operations at the edge while the laptop is away - #12579

Merged
dezren39 merged 2 commits into
mainfrom
xaltha/pm-console-edge-r2
Nov 22, 2026
Merged

dezren39 merged 2 commits into
mainfrom
xaltha/pm-console-edge-r2

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

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 Ops and Work classes 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=v pairs as query or JSON body, stdin JSON); non-2xx returns code 1 with the error body on stderr, so already_exists is still found.
  • fleet secrets get <queueTokenName> returns the Worker secret.
  • Every other verb (fleet queue enqueue, systemctl, fleet bridge) answers needs the laptop.
  • The queue store was already reached by 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.cancel and pr.merge.

A new prompt files its issue at the edge and holds only prompt.enqueue for the laptop (a new held action in HOLDABLE + actions.ts, running ops.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

  • EdgeConfig gains queueDbUrl, queueTokenName, promptLabel, needsRepos (validated in edgeConfig(), carried through the EdgeLink config callback).
  • scripts/expose.py gains --edge-direct on|off (default off, remembered like --edge): on uploads GITHUB_TOKEN (Bitwarden github.developing-today-code-automation), QUEUE_TOKEN (Bitwarden queue-token name) and EDGE_DIRECT=on; off puts EDGE_DIRECT=off and the tokens stay inert.
  • /console/health reports directEnabled, githubTokenConfigured, queueTokenConfigured, directReady and a self-check (one direct read of each kind, cached 1h).
  • ops.ts/work.ts are Worker-compatible: the node:fs/node:os/node:path imports are dynamic (laptop-only paths), and ask/askReply take an optional enqueue hook defaulting to ops.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 readOpenPullRequests in edge/src/github.ts + freshRead hook duplicates Ops.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 test in 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 in test/work.test.ts.
  • Edge bundles: 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


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…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
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 14:19
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6a796fa-0e0f-499c-8b67-d1f2bbefd00f
Commits

Reviewing files that changed from the base of the PR and between d8fe781 and d59a57f.

Files selected for processing: 21

  • .github/workflows/pm-console-edge-deploy.yml
  • pm-stack/console/edge/README.md
  • pm-stack/console/edge/src/direct.ts
  • pm-stack/console/edge/src/edge.ts
  • pm-stack/console/edge/src/worker.ts
  • pm-stack/console/edge/wrangler.jsonc
  • pm-stack/console/scripts/edge-demo.ts
  • pm-stack/console/scripts/edge-smoke.ts
  • pm-stack/console/scripts/expose.py
  • pm-stack/console/scripts/test_expose.py
  • pm-stack/console/src/actions.ts
  • pm-stack/console/src/docs.ts
  • pm-stack/console/src/edge-proto.ts
  • pm-stack/console/src/notify.ts
  • pm-stack/console/src/ops.ts
  • pm-stack/console/src/server.ts
  • pm-stack/console/src/work.ts
  • pm-stack/console/test/console.test.ts
  • pm-stack/console/test/direct.test.ts
  • pm-stack/console/test/edge.test.ts
  • pm-stack/console/test/work.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T16:11:25.291604Z d59a57f New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread pm-stack/console/edge/src/direct.ts Resolved
Comment thread pm-stack/console/src/edge-proto.ts Resolved
Comment thread pm-stack/console/scripts/expose.py Resolved
Comment thread pm-stack/console/src/actions.ts Resolved
Comment thread pm-stack/console/edge/src/edge.ts Resolved
Comment thread pm-stack/console/edge/src/edge.ts Resolved
- 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.
@dezren39
dezren39 merged commit 27c78ba into main Nov 22, 2026
2 checks passed
@dezren39
dezren39 deleted the xaltha/pm-console-edge-r2 branch November 22, 2026 16:54
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