Skip to content

pm-console edge: do queue and GitHub operations from Cloudflare while the laptop is away #12518

Open

Description

@dezren39

Where it stands

The app is served from the Worker pm-console-edge (pm-stack/console/edge). With the laptop away it still opens, shows the last state the laptop reported (marked with its age), holds twelve kinds of action for the laptop's return, and sends notifications. It cannot read anything fresh or act at once: every read and write of the queue store and of GitHub still happens on the laptop.

What is wanted

While the laptop has not reported for about a minute, the edge reads and acts by itself where nothing on the laptop is needed:

  • reads: the board (queue store), pull requests, ranked issues, the owner's prompts and their replies (GitHub);
  • writes that are one call: reply to or close a prompt, comment, rank an issue, move a task;
  • a new prompt: the issue is one call, but its queue task goes through fleet queue enqueue, which is the fleet binary. Either the edge writes the task by the queue's documented contract, or the issue is filed and marked so the laptop enqueues it on return. Decide from pkgs/fleet/crates/fleet-queue and doc/agents/one-queue-claiming-work.md, not by copying SQL blind.

Design already worked out

  • Ops and Work (pm-stack/console/src) take a run function and a fetch. Ops.gh only ever runs fleet gh api [-X M] <path> [--input -], and the queue store is already reached by fetch. An edge run that turns those argv into GitHub REST calls, and fleet secrets get <queue token name> into a Worker secret, lets both classes run unchanged in the Durable Object. Laptop-only calls (fleet queue enqueue, systemctl, fleet bridge) answer "needs the laptop".
  • Rule against doing anything twice: an action that was relayed and got no answer is only ever resolved by the laptop (it has the action's name). The edge acts by itself only on requests that arrive while the laptop is already known to be quiet, which never went to the laptop.
  • Sections read directly are written into the edge's mirror; when the laptop returns its report replaces them.
  • Credentials: the Worker needs the repository automation token and the queue store token as Worker secrets. pkgs/queue-transport-alert/worker/deploy.mjs is the existing pattern (Bitwarden name -> Worker secret, nothing printed or written). Make it an explicit switch in scripts/expose.py (off by default, remembered like --edge), and have the Worker say in /console/health whether it has each, so nothing is uploaded on every run.
  • A self-check the Worker runs when it gets its secrets (one direct read of each kind, result in /console/health) proves the path without taking the laptop down.

Done when

With the console service stopped on the laptop for five minutes, the app shows a board, pull requests and prompts newer than the stop, and a reply to a prompt appears on GitHub once and is not repeated when the laptop returns. Tested the way test/edge.test.ts tests the rest: the real classes, stand-ins only for GitHub and the queue store.

Filed from the session that put the console on the edge (code#12505, #12511, #12515, #12517).

Activity

  1. developing-today commented on Nov 22, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Picked up for triage under queue task 21029. Revalidating the issue and related edge work before choosing a bounded implementation slice or routing it for implementation.

  3. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Triage: this is a substantial edge capability, not a small local defect. #12505/#12511 are merged and the architecture note explicitly leaves fresh GitHub/queue reads, direct safe actions, and laptop-away prompt handling unimplemented. The requested behavior crosses pm-stack/console/edge, Ops.gh REST adaptation, queue-store access, Worker secrets, and idempotent host/edge reconciliation. Follow-up task 21047 is queued to implement it in reviewable slices. Keep new prompt queue-task creation on the documented fleet queue contract (or explicitly defer enqueue to the laptop); do not copy SQL blindly. Acceptance remains the five-minute laptop-offline check and one-time prompt reply after laptop return.

  4. added
    kind/featureNew feature or capability request
    task/triageQueue packet kind: verify, reproduce, and route this item
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    source/queue-workerFiled or worked by the queue/worker pilot
    on Nov 22, 2026
  5. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Triage disposition complete: the issue is open, the implementation follow-up is live as queue task 21047, and the request is sized effort/l. No local fix was made because this spans the edge Worker, queue/GitHub adapters and replay safety.

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 22, 2026
  7. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Picked up implementation task 21047. Issue #12518 is open; related PRs #12505 and #12511 are merged and no competing live PR was named in the packet. I am taking a bounded, reviewable implementation slice from the accepted scope.

  8. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Progress: opened PR #12548 for the first read-only slice: refresh open pull requests from GitHub after the laptop has been silent for 60 seconds. Evidence: 112 console tests pass, the edge build passes, and diff check is clean. Remaining issue scope is still open; this PR does not add fresh board/ranked-issue/prompt reads or direct actions. Next slice: add the next safe fresh read with an observable boundary and test, without enabling writes.

  9. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Queue task 21047 — the remaining accepted scope is in PR #12579 (branch xaltha/pm-console-edge-r2, commit a9caf45bf, OPEN / MERGEABLE).

    Landed: the edge runs the real Ops/Work classes in the Durable Object once the laptop has been quiet for 60s, through a new run translator (pm-stack/console/edge/src/direct.ts): fleet gh api argv become GitHub REST calls, fleet secrets get becomes a Worker secret, the queue store is reached by fetch, and every other verb answers 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 (new held action, runs ops.enqueue(promptPacket(...)) on return — the queue-task contract); a reply posts once and is never repeated on return. expose.py --edge-direct on|off (default off) provisions GITHUB_TOKEN/QUEUE_TOKEN/EDGE_DIRECT; health reports the capability and an hourly self-check.

    Supersedes #12548's approach: this PR is from main so it includes the PR read, and it replaces #12548's dedicated readOpenPullRequests/freshRead with Ops.prs() through the one run/fetch path. #12548 can be closed once this lands.

    Verification: bun test in pm-stack/console 130 pass, 0 fail (was 110) — 13 translator tests, 6 edge integration tests (fresh reads after 60s silence; reply once, not repeated on return; prompt files once, holds only the enqueue; close/rank/need-comment/move at the edge; health + self-check; no-switch/before-quiet falls back), 1 enqueue-hook test. Edge bundles: wrangler deploy --dry-run, 126.87 KiB.

    Remains: live verification — deploy (the workflow provisions no secrets), scripts/expose.py --edge-direct on, then the 5-minute stopped-service check and one real reply + one real new prompt end to end. That needs the deploy + secrets, which this seat cannot do from here.

  10. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Codex review on PR #12579 answered — all six threads fixed, replied to, and resolved.

    Fixes (commit d59a57f, branch xaltha/pm-console-edge-r2):

    1. P1 User-Agent: ghApi now sends user-agent: pm-console-edge on GitHub REST requests (edge/src/direct.ts:94).
    2. P1 old edge configs: edgeConfig() accepts configs missing the four new direct fields (defaults empty); direct capability is gated separately via Edge.directConfigReady, so an old stored config or old host report keeps serving the offline app instead of relaying.
    3. P2 persist direct choice after applying: ensure_edge_direct writes the edge-direct marker only after the wrangler secret puts succeed, both directions — a failed run no longer suppresses retries.
    4. P2 failed deferred enqueue: prompt.enqueue now throws OpError 502 on nonzero exit, so heldRunner records it failed and EdgeLink.take() acks ok: false instead of dropping the held command.
    5. P2 notification refresh overwrite: Notifier.tick(skip) skips reloading the sections just read directly; directRefresh/directAct pass them.
    6. P2 hydrate mirror before initial failure: directReadSection loads the durable mirror first when there is no in-memory good value, so a failed first read after a restart keeps last-good data.

    Verification: bun test 134/134 (was 130, +4 new tests), scripts/test_expose.py 19/19 (+1); all 6 new tests failed pre-fix in a scratch copy and pass with the fix. No deploy attempted — live laptop-away verification still needs a deploy with secrets and the wrangler dry-run approval that timed out twice before. PR is mergeable at the new head. Nothing merged.

  11. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Status after #12579 and #12712.

    Done

    Left on this issue

    • The switch has not been turned on. It hands the Worker the repository automation token and the queue store token, so it is the owner's to turn; the session that wrote feat(pm-console): the owner's switch for Cloudflare acting while the laptop is away #12712 also had no way left to run anything on the laptop.
    • Once it is on, the Worker checks one read of each kind by itself and the result shows on the same screen and in /console/health (selfCheck). That covers reads with the real credentials.
    • The five-minute laptop-away check in the description (fresh board, pull requests and prompts with the console stopped; one reply posted once and not repeated on return) is still to be done, by someone who can stop the console on the laptop and look at the app as the owner.

    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lLarge: multi-day or open-ended; expect staged check-inskind/featureNew feature or capability requestqueue/claimedQueue worker lifecycle statesource/queue-workerFiled or worked by the queue/worker pilotstatus/in-progressQueue worker lifecycle statetask/triageQueue packet kind: verify, reproduce, and route this itemwork/assignedQueue worker lifecycle state

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions