Skip to content

feat(pm-stack): pm-dispatch — launch/track OpenCode sessions from GitHub Actions - #2650

Merged
dezren39 merged 1 commit into
mainfrom
feat/pm-dispatch
Oct 30, 2026
Merged

dezren39 merged 1 commit into
mainfrom
feat/pm-dispatch

Conversation

@dezren39

@dezren39 dezren39 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

What

New pm-stack service pm-dispatch (pm-stack/dispatch/), per Drew's 2026-10-30 request: an authenticated HTTP service on the laptop that ferries prompts to the laptop's OpenCode server and/or into the Supabase repo-health queues — always tracked, never fire-and-forget.

  • POST /v1/sessions — launch now. Creates the tracking GitHub issue (default on), enqueues a repo-task/v1 queue task, creates an OpenCode session on the standing laptop server (127.0.0.1:13420) in the repo's primary directory with the requested model, sends the prompt (prefixed with the task/issue/repo ids), and marks the task claimed immediately (worker_id: dispatch-opencode, session id in progress) so no queue worker double-books it. wait:false answers 202 after the enqueue and finishes the launch asynchronously; a failed launch cancels the task and notes the issue.
  • POST /v1/tasks — enqueue only. Same packet machinery (kind, priority incl. name mapping, model hint, optional issue, canonical or caller-supplied dedupe keys) without launching a session.
  • GET /health — unauthenticated {ok, version}, aggregator-style.

Auth

  • GitHub Actions OIDC: RS256 verified against GitHub's JWKS (cached), aud: pm-dispatch; the token's repository claim must be allowlisted and equal the request body's repo — a workflow can only dispatch for its own repo.
  • Static bearer secret (DISPATCH_API_TOKEN), constant-time compared — the shape a repo stores as an Actions secret.

Caller identity is recorded in every task payload. examples/dispatch-workflow.yml shows both styles (marked as an example; not installed anywhere).

Tracking / queue notes

  • Packets mirror repo-queue.py: issue-backed packets validate clean under repo-queue.py validate; enqueue uses the same RPC selection it does (enqueue_repo_task for code, enqueue_repo_task_fleet for the fleet).
  • "Assign immediately" is a direct PostgREST PATCH on the created row — claim_repo_task claims the next task in a queue, not a specific one. Rationale documented in the README.
  • Issue creation uses the pm-stack GitHub App (installed on code/opencode/openchamber), with the laptop's gh CLI as fallback. dezren39/nix is not app-installed: issue creation is skipped there with a warnings entry; the task is the tracking record.
  • The no-issue dispatch dedupe shape (…:triage:<repo>:dispatch:<rand8>) was probe-verified against the live enqueue RPC (created + cancelled a probe task).

Deploy

Aggregator pattern: install.sh copies to ~/pm-stack/dispatch, renders .env from ~/secrets/pm-stack.sops.yaml (GitHub App keys by name), ensures ~/secrets/dispatch.env (mode 600: SUPABASE_SERVICE_ROLE_KEY, generated DISPATCH_API_TOKEN), installs pm-stack/systemd/pm-dispatch.service, restarts only on change, and fails unless /health reports the deployed commit. Port 4879, loopback + tailnet only.

Remaining (Drew's step, documented in the README): add dispatch.security.cab → http://localhost:4879 to the remotely-managed Cloudflare tunnel amd-6-pm-stack so GitHub Actions runners can reach it. Until then, tailnet callers can use it with either auth form.

Tests

28 bun tests pass on the laptop (auth incl. stubbed-JWKS OIDC signing + repo-binding, priority mapping, model parsing, request validation, packet building); tsc --noEmit clean. Post-merge: deploy + live smoke tests (tasks enqueue, session launch with issue, 401 negative).

Fixes #2648


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…Hub Actions

New pm-stack service (port 4879, loopback + tailnet) mirroring the
aggregator pattern: Bun + TypeScript, install.sh + user systemd unit.

- POST /v1/sessions: creates the tracking issue, enqueues a
  repo-task/v1 queue task, launches an OpenCode session on the laptop
  server with the prompt, and PATCHes the task to claimed immediately
  (worker dispatch-opencode, session id in progress). wait=false
  answers 202 after the enqueue and finishes the launch async.
- POST /v1/tasks: enqueue-only, optional issue, caller-supplied or
  canonical/dispatch dedupe keys.
- Auth: GitHub Actions OIDC (RS256 vs GitHub JWKS, aud pm-dispatch,
  repository claim must equal the request repo) or a constant-time
  static bearer secret. Caller identity recorded in the task payload.
- Issue creation via the pm-stack GitHub App (code/opencode/
  openchamber), gh CLI fallback; dezren39/nix skipped with a warning
  (app not installed there).

28 bun tests (auth incl. stubbed-JWKS OIDC + repo binding, priority
mapping, model parsing, validation, packets); issue-backed packets
validate clean under repo-queue.py; the no-issue dispatch packet shape
was probe-verified against the enqueue RPC.

Fixes #2648
@dezren39
dezren39 requested a review from a team as a code owner October 30, 2026 09:12
@coderabbitai

coderabbitai Bot commented Oct 30, 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 53 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: 7ae14471-6f5b-4c8b-bc35-b2352f9fc740
Commits

Reviewing files that changed from the base of the PR and between 06be46d and 19f12cb.

Files ignored due to path filters: 1
  • pm-stack/dispatch/bun.lock is excluded by !**/*.lock
Files selected for processing: 17
  • pm-stack/dispatch/README.md
  • pm-stack/dispatch/examples/dispatch-workflow.yml
  • pm-stack/dispatch/install.sh
  • pm-stack/dispatch/package.json
  • pm-stack/dispatch/src/auth.ts
  • pm-stack/dispatch/src/config.ts
  • pm-stack/dispatch/src/github.ts
  • pm-stack/dispatch/src/opencode.ts
  • pm-stack/dispatch/src/packet.ts
  • pm-stack/dispatch/src/queue.ts
  • pm-stack/dispatch/src/server.ts
  • pm-stack/dispatch/src/validate.ts
  • pm-stack/dispatch/test/auth.test.ts
  • pm-stack/dispatch/test/packet.test.ts
  • pm-stack/dispatch/test/validate.test.ts
  • pm-stack/dispatch/tsconfig.json
  • pm-stack/systemd/pm-dispatch.service
  • 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

Comment @coderabbitai help to get the list of available commands.

@dezren39
dezren39 merged commit d6a9ab2 into main Oct 30, 2026
@dezren39
dezren39 deleted the feat/pm-dispatch branch October 30, 2026 09:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T09:13:23.075195Z 19f12cb PR opened
ℹ️ 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.

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.

feat(pm-stack): dispatch service — launch/track OpenCode sessions from GitHub Actions

1 participant