Skip to content

bin/ proxies: systemd socket activation so restarts never refuse connections #1821

Closed

Description

@dezren39

Origin

Follow-up to #437 (closed by Drew's decision, 2026-10-28): fixed ports + port-file publication is the standing design for the four bin/ proxies, AND option (e) from that issue — systemd socket activation — is approved.

What

Today each proxy (clef 18742, agy 18743, codex 18744, antigravity-ls 18745) binds its own port. When the service restarts or crash-loops, anything connecting in that window is refused, and a previous instance still holding the port crash-loops the new one.

With socket activation, systemd owns the listener from boot and hands the socket to the service: connections queue instead of being refused while the service restarts, and the port can never be double-bound. OpenChamber already works this way (systemd.user.sockets.openchamber, home/common/default.nix) — this extends the proven pattern.

Scope

  • One systemd.user.sockets unit per proxy, holding its existing fixed port (ports do not change — Local proxy discovery: port files, sockets, or a registry instead of fixed ports? #437 KEEP ruling).
  • Each proxy's .mjs accepts the handed-off socket (LISTEN_FDS protocol, server.listen({ fd: 3 })) and still binds the port itself when launched outside systemd, so manual runs keep working.
  • Services become socket-activated (no longer need to bind on start).

Acceptance criteria

  • Socket units + service changes land in the flake and evaluate in the amd host config.
  • After the NixOS switch on the laptop: restarting a proxy service mid-flight no longer refuses a client connection (it queues and completes once the service is back) — demonstrated for at least one proxy.
  • Launching a proxy by hand (no systemd) still works exactly as today.
  • A still-running previous instance can no longer crash-loop its replacement on the port.

Activity

  1. developing-today commented on Oct 28, 2026

    @developing-today
    Contributor
  2. added
    kind/infrastructureInfrastructure / host-portability work
    source/humanFiled directly by a human
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    area/nixosNixOS modules and machine configuration
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Oct 28, 2026
  3. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    Intake review

    Fleet monitor intake pass (protocol §5), 2026-10-28.

  4. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    Status — owner order 2026-10-28, stalled, re-queued 2026-10-31.

    Drew approved socket activation (option (e)) for the bin/ proxies on #437 on 2026-10-28, but this issue was never queued — no task row existed.

    Remediation (2026-10-31): enqueued into repo-health-code-pilot as task 4719 (small_fix, priority 50, queued, attempts 0/3), verified by direct queue read; queue signal refreshed. Ports stay fixed per the #437 KEEP ruling.

  5. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 1, 2026
  6. 33 remaining items

  7. added
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 3, 2026
  8. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  9. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 3, 2026
  10. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

  11. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

  12. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — task 4719 parked again (lane code-n, 2026-11-04T10:31Z).

    Fresh verification: PR #4845 is MERGED (b910a59b0316257b46c8575640a0e5fba5d92e74); issue #1821 remains OPEN. The only remaining step is the amd host switch/restart verification for the clef + codex proxies, which the task packet places behind separate explicit authorization — no such authorization has been recorded, so task 4719 is parked 6h with that resume condition (third park for this gate; prior parks 2026-11-03T21:46Z and 2026-11-04T03:48Z).

  13. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Verified on amd — closing. The amd host switch landed this morning (2026-11-04, generation nixos-system-amd-26.11.20261102.f9887a8), which deployed PR #4845's socket units via home-manager. The switch alone left the sockets enabled-but-inactive (the same sd-switch limitation that left the new opencode unit unstarted), with the proxies still holding their ports directly from boot. That last step is now done and verified for both proxies:

    • clef-proxy (127.0.0.1:18742): service stopped → clef-proxy.socket started and holding the port → HTTP probe returned 200 and socket activation started the service on demand. A second probe issued during an explicit systemctl restart of the service also returned 200 — the connection was held by the socket, never refused.
    • codex-proxy (127.0.0.1:18744): same sequence — service stopped, socket armed, cold probe returned 200, service auto-started.

    All four units (both sockets, both services) are active. Restarts no longer refuse connections, as designed. Queue task 4719 is completed with this evidence; the earlier parks were only waiting on the host switch authorization, which Drew granted this morning.

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

Metadata

Metadata

Assignees

Labels

area/nixosNixOS modules and machine configurationeffort/sSmall: expected under 2 hours of workkind/infrastructureInfrastructure / host-portability workmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)queue/parkedQueue task is parked (waiting on CI, time, or an event)source/humanFiled directly by a humanstatus/parkedDeliberately paused with a recorded resume conditionstatus:donetask/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