Skip to content

fix(cli): name the socket a running core is actually bound to - #3715

Merged
joelteply merged 1 commit into
canaryfrom
fix/name-the-socket-a-core-is-bound-to
Sep 4, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/name-the-socket-a-core-is-bound-to

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

The server takes argv[1] over the shared resolver, so a core launched with an
explicit path serves where the client's default never looks. Every client-side
diagnostic then reports the CLIENT's socket as though it were the core's — which
is TRUE, and names the one path that is not the answer.

Measured on the Intel Mac 2026-09-04: pid 83712 served
~/.continuum/intelmac-core.sock for an hour while ping said "1 core
process(es) are running (pid(s) 83712) but NONE is answering on
/tmp/continuum-core.sock". Four commands and one wrong "the core is wedged"
hypothesis to find a core that was healthy the whole time. The bound path was
readable from the process's own argv throughout — and the guard had already
enumerated that very pid to print it.

start's doc comment already names this state ("bound where this CLI cannot
reach"); this makes the message say it too, and separates it from the wedged
case it is currently indistinguishable from:

• NOT wedged — bound elsewhere: pid 83712 → /Users/joel/.continuum/intelmac-core.sock.
This CLI is looking at /tmp/continuum-core.sock. Reach it with
CONTINUUM_CORE_SOCKET=... continuum <command>, or continuum stop ...

Both Occupied refusals (autostart guard + start) share one hint builder.
Reads argv via the same sysinfo command-line refresh processes_with_cmdline
already uses, so it works on Windows too rather than shelling to a Unix tool.

A core that passed no positional resolved from ITS environment at launch, which
this process cannot read afterwards — that reports as unknown, never as the
default. A diagnostic that confidently names the wrong socket is the whole
defect being fixed here; the fix must not reintroduce it one layer up.

5 tests in a nested bound_socket mod: the socket is the first non-flag arg
(not argv[1] — --mode=full-citizen must never be reported as a socket path),
no-positional reports unknown, no hint fires when the core is on the socket we
asked for (the ordinary wedged case keeps its message unchanged), the hint
carries the core's path in the remedy, and a mixed fleet lists only the
unreachable core.

Co-Authored-By: Claude Opus 5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

The server takes `argv[1]` over the shared resolver, so a core launched with an
explicit path serves where the client's default never looks. Every client-side
diagnostic then reports the CLIENT's socket as though it were the core's — which
is TRUE, and names the one path that is not the answer.

Measured on the Intel Mac 2026-09-04: pid 83712 served
`~/.continuum/intelmac-core.sock` for an hour while `ping` said "1 core
process(es) are running (pid(s) 83712) but NONE is answering on
/tmp/continuum-core.sock". Four commands and one wrong "the core is wedged"
hypothesis to find a core that was healthy the whole time. The bound path was
readable from the process's own argv throughout — and the guard had already
enumerated that very pid to print it.

`start`'s doc comment already names this state ("bound where this CLI cannot
reach"); this makes the message say it too, and separates it from the wedged
case it is currently indistinguishable from:

  • NOT wedged — bound elsewhere: pid 83712 → /Users/joel/.continuum/intelmac-core.sock.
    This CLI is looking at /tmp/continuum-core.sock. Reach it with
    `CONTINUUM_CORE_SOCKET=... continuum <command>`, or `continuum stop` ...

Both `Occupied` refusals (autostart guard + `start`) share one hint builder.
Reads argv via the same `sysinfo` command-line refresh `processes_with_cmdline`
already uses, so it works on Windows too rather than shelling to a Unix tool.

A core that passed no positional resolved from ITS environment at launch, which
this process cannot read afterwards — that reports as unknown, never as the
default. A diagnostic that confidently names the wrong socket is the whole
defect being fixed here; the fix must not reintroduce it one layer up.

5 tests in a nested `bound_socket` mod: the socket is the first non-flag arg
(not argv[1] — `--mode=full-citizen` must never be reported as a socket path),
no-positional reports unknown, no hint fires when the core is on the socket we
asked for (the ordinary wedged case keeps its message unchanged), the hint
carries the core's path in the remedy, and a mixed fleet lists only the
unreachable core.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply merged commit 6f5213c into canary Sep 4, 2026
5 checks passed
@joelteply
joelteply deleted the fix/name-the-socket-a-core-is-bound-to branch September 4, 2026 23:27
joelteply added a commit that referenced this pull request Sep 5, 2026
…ving it (#3720)

* fix(cli): the socket parser calls main.rs's parser instead of re-deriving it

`socket_from_core_argv` re-implemented "skip the flags, take the positional"
as `find(|a| !a.starts_with('-'))`. `main.rs` does something different: it
strips the `--mode` tokens via `extract_boot_mode` — which accepts the SPACE
form as well as the equals form (`boot_mode.rs:113-119`, with a test pinning
it) — and then takes the first remaining positional.

The two disagree on `--mode VALUE`:

    continuum-core-server --mode fail-fast /tmp/x.sock
      heuristic → Some("fail-fast")     ← a boot mode, reported as a socket
      main.rs   → Some("/tmp/x.sock")

so the operator was told their core is bound to `fail-fast`, with a
copy-pasteable `CONTINUUM_CORE_SOCKET=fail-fast` to make it worse. That is
strictly worse than the message it replaced, and it is precisely what the
helper's own doc comment said it existed to prevent. Found by adversarial
review of #3715 and proven by mutation before it was reported.

Root cause worth keeping: the rule was encoded from the binary's HELP TEXT
(`[--mode=<MODE>] <socket-path>`), and the help text is an incomplete
description of the parser. Calling `extract_boot_mode` — already `pub` and
re-exported at `runtime/mod.rs:69` — makes the CLI correct by construction
against `main.rs` forever instead of by a re-derivation that had already
drifted on its first commit. One decision, one place.

Also from that review:

- `running_core_sockets` → `running_core_sockets_for(&pids)`: takes the pids
  the bind guard already resolved instead of re-scanning, so the hint can
  never name a process the refusal did not list nor miss one it did. They
  were two independent `System` snapshots matched by different predicates —
  and on Linux the divergence is real, not theoretical: `/proc/pid/stat`'s
  comm is capped at 15 chars, so a name-only match on the 21-char
  `continuum-core-server` never fires.
- "NOT wedged" is no longer asserted unconditionally. In a mixed fleet the
  core on OUR socket genuinely is wedged, and the old headline denied the
  operator's real problem while correctly listing the other one.
- `describe_running_core` — `deploy-verify`'s mismatch path, the third site —
  now says when a listed core is bound somewhere other than the socket the
  CLI resolved, instead of printing the client's path as though it were the
  core's.
- Test fixtures no longer carry `/Users/joel/...` absolute paths.

Tests: the space form is now covered on both the positive and the unknown
path. The previous test stated the right invariant and then picked the one
flag spelling that passes it either way, which is why it went green against
a parser that was already wrong.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(cli): refresh only the pids we were handed, and pin the malformed-mode decision

Adversarial review of #3720 caught that `running_core_sockets_for` refreshed the
WHOLE process table and then filtered by pid. Reading a command line costs a
syscall per process (`KERN_PROCARGS2` / `/proc/<pid>/cmdline`), and
`describe_running_core` runs on `deploy-verify`'s SUCCESS path — where
`deploy_verdict`'s Ok arm never interpolates the string it builds. So every clean
deploy paid the most expensive of three process scans to produce a discarded
value.

`ProcessesToUpdate::Some(&wanted)` is the idiom already used elsewhere in this
file. The refresh becomes the filter, and the linear membership scan stops
mattering at any fleet size.

Also adds the test the review said was missing: the `.ok()?` on `extract_boot_mode`
is a DECISION (a malformed `--mode` reports unknown), and it was defended only in
a comment. `main.rs` prints its error and `exit(2)`s before resolving a socket, so
such a process provably bound nothing — unknown is the correct answer rather than
a swallowed error, and the pid still reaches the operator via `running_core_pids`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant