Skip to content

design: repo-queue + secrets brokers on the laptop behind the session proxy #5362

Open

Description

@dezren39

Design: queue-secrets-brokers-design-2026-11-04 (goal files). Drew's decision 2026-11-04: port repo-queue to the laptop as a queue broker plus a secrets broker pool (two Rust binaries); all fleet instructions connect only to the session proxy; the Supabase service key is fetched once by the secrets broker instead of a 10-40s Bitwarden fetch per repo-queue.py call. Build as nix pkgs first, then bake into dezren39/nix. Companion to #5343 (laptop-agent).

Acceptance criteria

  • The design of record (queue-secrets-brokers-design-2026-11-04, goal files) is linked from this issue and the companion laptop-agent design (issue design: laptop-agent — resident execution agent on the laptop (replace per-command SSH spawns) #5343) is cross-referenced.
  • A decision is recorded on broker placement and protocol: fleet instructions connect only to the session proxy; no direct Supabase access from fleet instruction code.
  • The queue broker and secrets broker are implemented as nix packages first, then baked into dezren39/nix, per the stated rollout order.
  • The per-call Bitwarden fetch in repo-queue.py is eliminated (service key fetched once by the secrets broker), with repo-queue call latency measured before and after.
  • Implementation issue(s) are filed and linked from this design issue in the same pass — a design with no implementation link is not finished work.

Activity

  1. added
    kind/performancePerformance problem or optimization
    kind/infrastructureInfrastructure / host-portability work
    kind/designA design proposal (design-architect): multi-step, phased, decision-bearing
    on Nov 4, 2026
  2. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Build status 2026-11-04 ~03:00 CST: all three binaries built and the two brokers are deployed as systemd user services on the laptop (secrets-broker holding 134 cached secrets; queue-broker up). End-to-end verification is blocked by a Supabase data-path stall that is not caused by the brokers: authenticated PostgREST requests (valid service-role key) hang with 0 bytes from BOTH the laptop and the sandbox, on every client (curl, python, ureq), while unauthenticated/invalid-key requests return 401 in ~1-2 s and the Management API + direct SQL respond instantly (pg_stat_activity: DB idle, no queue of active queries). Signature matches a wedged Supavisor shared-pooler path for this project: valid-key requests never reach Postgres. The legacy repo-queue.py path is affected identically, so fleet queue access is degraded right now independent of this work. Probing has been stopped (each hung request may hold a pooler slot). Client cutover (shim) is held until the backend recovers and the canary can be verified. Nix packaging + flake bake proceed meanwhile (no backend dependency).

  3. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Nix packaging + flake bake done (2026-11-04 ~03:05 CST), while the Supabase pooler stall continues (valid-key PostgREST still timing out at last probe; legacy fleet path equally affected):

    • pkgs: dezren39/nix pkgs/fleet-brokers — one buildRustPackage with the vendored workspace (all three binaries), plus a home-manager module. nix build .#fleet-brokers verified on the laptop: queue-broker, repo-queue, secrets-broker all in the output.
    • Bake: flake exports homeManagerModules.fleet-brokers (options services.fleet-brokers.enable/package; renders both systemd user services against the flake package, Linux-only) and packages.fleet-brokers via mkPackages. A check modeled on the mcpx module check (checks.x86_64-linux.fleet-brokers-home-manager-module) builds green, asserting both ExecStart paths and WantedBy. Same posture as mcpx in this repo: module exported and check-covered; machine configs enable it when amd's home config is next rebuilt. Changes are staged in the laptop's nix checkout for the repo's normal PR flow.
    • Interim runtime remains the hand-installed systemd user services (same unit shapes the module renders).
    • Home-repo sources committed as b4e18cef3.

    Still held: shim cutover + instruction updates + end-to-end canary — all gated on the Supabase data path answering again.

  4. added
    priority/highImportant and time-sensitive
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    source/humanFiled directly by a human
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Nov 4, 2026
  5. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Intake review

    Related: issue #5343 (companion laptop-agent design, filed today, same directive); issue #4875 (live PostgREST hang — the pain this design removes); issue #4903 (queue split-brain project resolution).
    Notes: Filed by Drew today with the design of record in the goal files. Still live — no merged PR implements brokers; the queue read path is actively degraded this run (see issue #4875), which raises, not lowers, its priority.
    Risks: Broker becomes a single point of failure for all fleet queue traffic; secrets broker concentrates the service key — its auth/bind posture needs the same tailnet-only + token discipline as the laptop-agent design.
    Suggested approach: Land the design decision record first, then file implementation issues for (1) queue broker, (2) secrets broker, (3) repo-queue.py client migration, in that order; measure repo-queue latency before/after as the acceptance evidence.

    🤖 Agent note · filed

    • Agent: fleet monitor (repo-fleet-monitor)
    • Session / ID: repo-fleet-monitor run 2026-11-04 02:12 CST
    • Found via: monitor reconciliation (intake enrichment, protocol §5)
    • Task: intake pass — acceptance criteria appended, labels normalized, this review posted
    • Expectation: done looks like the criteria section above; no queue state changed by this pass
  6. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — state: cutover complete (2026-11-04 ~04:15 CST)

    The brokers are live and the fleet is on them:

    • Recovery first: the muse-dev2 PostgREST wedge (onset ~02:22 CST, tracked on infra: repo-queue Supabase PostgREST outage — PGRST002 schema-cache failures and 60s timeouts block all queue verbs (2026-11-04) #5370) was cleared by restarting the project services via the Management API. The queue-broker resolves the namespaced supabase.muse-dev2.* credentials from the secrets broker.
    • Read-path verification: Rust client health through the session proxy returns a table identical to the legacy tool (code pilot at first read: queued 241 / claimed 6 / parked 61 / blocked 157 / done 4157).
    • Validation comparison: known-good packet → exit 0, identical JSON + warnings from both implementations; known-bad packet → exit 2, identical error.
    • Shadow-queue canary: task 9343 enqueue → claim → checkpoint → complete (done); task 9344 enqueue → claim → park → cancel. Every write verb exercised through the queue-broker at ~1s per call (vs 10–50s per-call Bitwarden fetch before).
    • Shim cutover: ~/tools/repo-queue.py now execs the Rust client and falls back to ~/tools/repo_queue_legacy.py only on exit 3 or REPO_QUEUE_VIA_BROKER=0; legacy names re-exported for module importers (fleet monitor). Verified: broker path ~3.1s health, forced-legacy ~9.2s, import surface intact. Home-repo commit d37929fa0.
    • Instructions updated: the queue-worker instruction file and ~/TOOLS.d/laptop.md state that sandbox code connects only to the session proxy, and that the queue and secret tools live on the laptop. Design doc carries a completion section.
    • Nix: pkgs/fleet-brokers + home-manager module in dezren39/nix are built and check-verified, staged for that repo's PR flow; no machine config enables the module yet, so the interim hand-installed laptop units (identical shape) remain live.

    Remaining known gap: none for the queue path. The one wart carried from the build: the Rust client's per-subcommand --help is not wired (argparse help exists only on the legacy fallback).

  7. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Addendum (2026-11-04 ~04:57 CST): binary-direct end state, per Drew's direction.

    • repo-queue is called directly everywhere: PATH entry
      (~/tools/bin/repo-queue → the Rust client), all 45 cron job bodies,
      the four worker instruction files, lane helper scripts, and the hook
      definitions. Grep-verified: zero repo-queue.py references remain in
      any cron projection, tool script, or hook definition.
    • The Python layer is gone from the sandbox: ~/tools/repo-queue.py
      (the shim), ~/tools/repo_queue_legacy.py, the shim source, and the
      two module-borrowing probe scripts are removed. No direct-PostgREST
      fallback remains on the sandbox; a down broker path surfaces as the
      client's exit 3.
    • The session proxy is now autostarted by init: ~/tools/init-ensure.sh
      (the prelude every fleet job runs) ensures the laptop-agent broker,
      no-op when already running — verified live (pid stable across
      ensures; a killed broker restarted by the next ensure; health green
      through it, ~0.5s).
    • Post-removal check: repo-queue health --queue repo-health-code-pilot
      exit 0 in 0.47s with the Python files deleted.

    Commits: home repo 03874b238, hatch-personal 8b00765e7. The nix
    packaging / module enablement remains the only open thread on this
    issue.

  8. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Nix packaging completed (2026-11-04 ~09:21 CST): dezren39/nix PR #1476 merged to main as 5b0167a3d14ea03e8110338bddc8064de15fd6dc, re-landing the packaging from #1459 with its review findings addressed.

    • pkgs/fleet-brokers (secrets-broker, queue-broker, repo-queue) and pkgs/laptop-agent are in the flake package set.
    • homeManagerModules.fleet-brokers launches the three services as systemd user units when enabled.
    • Verified locally on x86_64-linux: laptop-agent tests (6 passed), workspace Rust tests (4 passed), and Nix builds for both packages plus the laptop-agent and home-manager checks.

    Remaining: amd's home configuration imports/enables the module at its next activation; the hand-installed units continue unchanged until then.

  9. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Agent note — task 9344 handed off to opencode execution lane

    • Lane: code-v (repo-worker-code), claimed 2026-11-04T12:34Z
    • Execution-lane assignment (repo-queue lane task 9344): opencode
    • Per worker instruction §1b, this lane does not work the task directly and creates no worktree. The laptop opencode-claimant polls for claimed, opencode-assigned, unbound tasks and launches a session bound to task 9344 to drive it to a terminal state.
    • Checkpointed as handed_off. If the claimant has not launched by lease expiry, task 9344 returns to the queue.
  10. added
    queue/queuedHas a queued task in the Supabase agent queue
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 4, 2026
  11. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Missed-consumer follow-up to the binary-direct migration: the migration sweep missed the opencode claimant (pm-stack/opencode-claimant), which imported ~/hatch/tools/repo-queue.py for its polling and named the Python path in its prompt for every queue verb. Every claimant fire failed closed from ~04:43 CST until the repair under #5414 (direct queue-broker transport added to the repo-queue client; claimant patched in PR #5419). A second missed consumer set — 12 OpenChamber "Queue lane (scheduled) - code" tasks still naming the Python path — is tracked separately on #5422.

    Verified end state 2026-11-04T12:52Z: claimant launching and binding sessions again (15 bound at first check). The durable lesson is recorded in the fleet ops notes: migration sweeps must grep the code repo's pm-stack and the OpenChamber task store, not just the fleet bookkeeping tree.

  12. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Agent note — triage: design is implemented and running; the only open thread is the dezren39/nix packaging, and its PR is now closed unmerged

    • Task: 9344 (triage, queue repo-health-code-pilot), lane c29174f1-48e0-4b13-b4ff-9b73ab67e9ab, claimed 2026-11-04T14:04Z.
    • Verified at current main + live host state, not from the packet.

    What the design asked for, checked one by one

    Acceptance criterion State (verified 2026-11-04T14:10Z)
    Design of record linked Yes — named in this issue body; not present as a file in this repo (lives in the goal files, as the body says).
    Decision recorded: fleet instructions connect only to the session proxy; no direct Supabase from instruction code Implemented in the client: repo-queue now carries direct queue-broker transport (#5414). The queue/secrets brokers are live behind the local proxy.
    Queue broker + secrets broker as nix packages, then baked into dezren39/nix Not landed. dezren39/darwin-nix#1459 is CLOSED, unmerged (mergedAt: null, closed 2026-11-04T12:13:40Z, branch fleet-services-flake @ 3daf3b8). What runs today is the hand-installed pair of units.
    Per-call Bitwarden fetch eliminated, latency measured Eliminated: secrets-broker.service is active and ~/.cache/repo-queue/service-key is the resident cache the client reads instead of calling Bitwarden per invocation.
    Implementation issues filed and linked Yes — #5412 (fleet multicall epic), #5414 (direct transport repair), #5419 (claimant patch), companion design #5343.

    Live host state (this laptop, same host the queue lanes run on)

    queue-broker.service    active  /nix/store/mhjkhyw8d8pmvd39awm6z05h81r00g29-fleet-0.1.0/bin/fleet serve queue-broker
    secrets-broker.service  active  /nix/store/mhjkhyw8d8pmvd39awm6z05h81r00g29-fleet-0.1.0/bin/fleet serve secrets-broker
    

    Both are hand-installed units; the pre-flip rollback copies are still on disk at
    ~/.config/systemd/user/{queue,secrets}-broker.service.pre-fleet-step2.

    Scoped remainder (the fix path)

    1. Re-land the nix packaging that ops(dashboard): daily backups of dashboard/orchestration logs + stores — laptop, Google Drive, R2 #1459 carried: pkgs/fleet-brokers (secrets-broker, queue-broker, repo-queue) + homeManagerModules.fleet-brokers that launches all three as user units. Branch fleet-services-flake (3daf3b8) still exists in dezren39/nix; rebase it on current main and open a fresh PR (the old one is closed, so a new PR is required, not a reopen-and-pray).
    2. Wire it into the laptop's home configuration and activate, so the units come from the module instead of the hand-installed files.
    3. Only after the module is active, delete the .pre-fleet-step2 rollback unit copies and the ~/fleet-brokers/bin rollback symlink target (~/.local/bin/repo-queue still points at the pre-fleet build; it works, but it is the rollback artifact, not the packaged path).
    4. Re-measure repo-queue latency (design criterion 4) once the packaged path is in use, and record before/after here.

    Everything else in this design is done and verified; the design should stay open only for step 1-4, which is cross-repo (dezren39/nix) and belongs with #5412's packaging track.

    Note on tooling encountered during the claim — repo-queue claim returned the all-null "no task" sentinel on two attempts and a real task on the third from the same queue; this matches #5444's narrowed report (sentinel indistinguishable from a malformed row) and is not evidence of a broken claim path.

  13. removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

effort/lLarge: multi-day or open-ended; expect staged check-inskind/designA design proposal (design-architect): multi-step, phased, decision-bearingkind/infrastructureInfrastructure / host-portability workkind/performancePerformance problem or optimizationmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivesource/humanFiled directly by a humantask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions