fix(launcher): restore network address startup logging (#2619)
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
---
|
||||
spec: "../../specs/go-dev-launcher/spec.md"
|
||||
created: 2026-08-13
|
||||
status: implemented
|
||||
---
|
||||
|
||||
# Implementation Plan: Restore dev network address logging
|
||||
|
||||
## Overview
|
||||
|
||||
Restore the startup-banner behavior that the Node launcher provided before the
|
||||
`make dev` migration. Add a small Go network-address helper, feed its filtered
|
||||
addresses into the existing shared `logStartup` path, and cover formatting,
|
||||
filtering, and enumeration failures with focused launcher tests. This keeps the
|
||||
behavior shared by `dev`, `start`, and `run` without exposing the internal Vite or
|
||||
agentctl ports.
|
||||
|
||||
---
|
||||
|
||||
## Backend
|
||||
|
||||
### Host address discovery and startup banner
|
||||
|
||||
- Add `apps/backend/internal/launcher/network.go` with best-effort enumeration of
|
||||
active, non-loopback host addresses, deduplication, link-local filtering,
|
||||
IPv4-first ordering, IPv6 URL formatting, and filtering against an explicit
|
||||
bind host.
|
||||
- Update `apps/backend/internal/launcher/start.go` so `logStartup` prints the
|
||||
filtered network URLs for `portConfig.BackendPort` between the localhost URL and
|
||||
the existing MCP/DB/log-level lines.
|
||||
- Keep interface-enumeration errors non-fatal and leave the existing localhost
|
||||
startup path unchanged.
|
||||
|
||||
---
|
||||
|
||||
## Tests
|
||||
|
||||
- **What:** LAN and Tailscale-style IPv4 addresses are listed, duplicates and
|
||||
loopback/link-local addresses are omitted, IPv6 URLs are bracketed, and IPv4 is
|
||||
listed before IPv6.
|
||||
**File:** `apps/backend/internal/launcher/network_test.go`.
|
||||
**How:** Deterministic table-driven unit tests over representative interface
|
||||
address fixtures.
|
||||
- **What:** The shared startup banner emits the network URLs and still emits the
|
||||
localhost URL when interface enumeration fails.
|
||||
**File:** `apps/backend/internal/launcher/network_test.go`.
|
||||
**How:** Assert the generated startup output with injected address-discovery
|
||||
results and an enumeration-error case.
|
||||
- **What:** Down interfaces are not advertised, and explicit bind hosts only
|
||||
advertise reachable interface addresses.
|
||||
**File:** `apps/backend/internal/launcher/network_test.go`.
|
||||
**How:** Use active/down interface fixtures and loopback, wildcard, and
|
||||
specific-bind cases.
|
||||
|
||||
## Documentation
|
||||
|
||||
- Update `docs/public/cli.md` so the public CLI reference describes the optional
|
||||
`network:` lines and keeps the network-exposure warning clear. This page is a
|
||||
reference document.
|
||||
|
||||
## Verification Results
|
||||
|
||||
- `cd apps/backend && go test -run TestLogStartupPrintsNetworkAddress ./internal/launcher` —
|
||||
failed before the fix with the expected missing `network:` assertion.
|
||||
- `cd apps/backend && go test -run 'Test(ListHostNetworkAddresses|NetworkURLsForPort|LogStartup)' ./internal/launcher` —
|
||||
passed, 4 tests.
|
||||
- `cd apps/backend && go test ./internal/launcher` — passed, 196 tests.
|
||||
- `cd apps/backend && go test -run TestLogStartupSuppressesNetworkAddressesForLoopbackBind ./internal/launcher` —
|
||||
failed before the fix, then passed after bind-host filtering was added.
|
||||
- `cd apps/backend && go test -run 'Test(NetworkAddressesForBindHost|LogStartupSuppressesNetworkAddressesForLoopbackBind)' ./internal/launcher` — passed.
|
||||
- `cd apps/backend && go test -run TestListHostNetworkAddressesSkipsDownInterfaces ./internal/launcher` — passed.
|
||||
- `rtk git diff --check` — passed.
|
||||
- `node --test scripts/validate-public-docs.test.mjs` — passed, 61 tests.
|
||||
- `node scripts/validate-public-docs.mjs` — passed, 41 published docs pages.
|
||||
- Platform risk: native interface enumeration is covered by injected fixtures on this
|
||||
Linux runner; non-Linux native enumeration remains unverified.
|
||||
|
||||
## Implementation Waves And Parallel Candidates
|
||||
|
||||
Wave 1, sequential:
|
||||
|
||||
- [x] [task-01-restore-network-logging](task-01-restore-network-logging.md)
|
||||
|
||||
The implementation and its tests share the launcher output contract, so the task
|
||||
is intentionally sequential and is not a delegation authorization.
|
||||
|
||||
## Open Questions
|
||||
|
||||
None.
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: "01-restore-network-logging"
|
||||
title: "Restore network startup logging"
|
||||
status: done
|
||||
wave: 1
|
||||
depends_on: []
|
||||
plan: "plan.md"
|
||||
spec: "../../specs/go-dev-launcher/spec.md"
|
||||
---
|
||||
|
||||
# Task 01: Restore network startup logging
|
||||
|
||||
Implement the startup-banner contract added to the Go dev-launcher spec.
|
||||
|
||||
## Acceptance
|
||||
|
||||
- `dev`, `start`, and `run` print a `network:` URL for each unique non-loopback,
|
||||
non-link-local host address on the backend port.
|
||||
- IPv4 addresses appear before IPv6 addresses, and IPv6 URLs use brackets.
|
||||
- Interface enumeration errors do not prevent startup or remove the localhost URL.
|
||||
- Explicit loopback or specific bind hosts do not advertise unrelated interfaces.
|
||||
- Internal Vite and agentctl ports remain absent from the network-address lines.
|
||||
|
||||
## Verification
|
||||
|
||||
Run from the repository root:
|
||||
|
||||
```bash
|
||||
cd apps/backend && go test -run 'Test(ListHostNetworkAddresses|NetworkURLsForPort|LogStartup)' ./internal/launcher
|
||||
```
|
||||
|
||||
## Files likely touched
|
||||
|
||||
- `apps/backend/internal/launcher/network.go`
|
||||
- `apps/backend/internal/launcher/network_test.go`
|
||||
- `apps/backend/internal/launcher/start.go`
|
||||
- `docs/public/cli.md`
|
||||
|
||||
## Dependencies
|
||||
|
||||
None.
|
||||
|
||||
## Parallelism
|
||||
|
||||
Sequential. The helper, shared logger, and regression tests define one output
|
||||
contract.
|
||||
|
||||
## Inputs
|
||||
|
||||
- `docs/specs/go-dev-launcher/spec.md`, startup output section and scenarios.
|
||||
- The previous Node behavior in `apps/cli/src/shared.ts` at the pre-migration
|
||||
revision, especially `listHostNetworkAddresses`, `networkUrlsForPort`, and
|
||||
`logStartupInfo`.
|
||||
- The current shared Go logger in `apps/backend/internal/launcher/start.go`.
|
||||
|
||||
## Output contract
|
||||
|
||||
Summarize the changed files, exact test command and result, any remaining
|
||||
platform-specific risk, and synchronize this task and `plan.md` status.
|
||||
|
||||
## Results
|
||||
|
||||
- `cd apps/backend && go test -run TestLogStartupPrintsNetworkAddress ./internal/launcher` —
|
||||
failed before the fix with the expected missing `network:` assertion.
|
||||
- `cd apps/backend && go test -run 'Test(ListHostNetworkAddresses|NetworkURLsForPort|LogStartup)' ./internal/launcher` —
|
||||
passed, 4 tests.
|
||||
- `cd apps/backend && go test ./internal/launcher` — passed, 196 tests.
|
||||
- `cd apps/backend && go test -run TestLogStartupSuppressesNetworkAddressesForLoopbackBind ./internal/launcher` —
|
||||
failed before the bind-host fix, then passed after the fix.
|
||||
- `cd apps/backend && go test -run 'Test(NetworkAddressesForBindHost|LogStartupSuppressesNetworkAddressesForLoopbackBind)' ./internal/launcher` — passed.
|
||||
- `rtk git diff --check` — passed.
|
||||
- `gofmt -w apps/backend/internal/launcher/network.go apps/backend/internal/launcher/network_test.go apps/backend/internal/launcher/start.go` — completed successfully.
|
||||
- `node --test scripts/validate-public-docs.test.mjs` — passed, 61 tests.
|
||||
- `node scripts/validate-public-docs.mjs` — passed, 41 published docs pages.
|
||||
- Platform risk: native interface enumeration is covered by injected fixtures on this
|
||||
Linux runner; non-Linux native enumeration remains unverified.
|
||||
- Cleanup: no temporary files, processes, or external runtime state created.
|
||||
+3
-1
@@ -225,7 +225,9 @@ Supported actions are `install`, `uninstall`, `start`, `stop`, `restart`, `statu
|
||||
|
||||
There is no separate web-server port in an installed release: the backend serves embedded assets. For the `run`, `start`, and development launcher flows, if `--port`, `KANDEV_BACKEND_PORT`, or `KANDEV_PORT` specifies a port, the launcher checks it before declaring the backend ready, does not substitute another one, and fails startup if the configured listen address cannot bind it. `kandev service install --port` remains the separate installer behavior described above.
|
||||
|
||||
The launcher prints `http://localhost:<port>`, but the backend's default `server.host` is `0.0.0.0`. That can expose Kandev to other machines on the network, and the current local product path is not an authenticated multi-user boundary. Bind it to loopback unless remote access is deliberately protected:
|
||||
The launcher prints `http://localhost:<port>`. When it can enumerate non-loopback interfaces, it also prints `network:` URLs for each unique non-loopback, non-link-local address on the same port, including local-network and Tailscale addresses. IPv6 addresses are shown in brackets. If `KANDEV_SERVER_HOST` restricts the listener, the launcher only prints matching addresses. These lines are informational and are omitted if interface discovery is unavailable.
|
||||
|
||||
The backend's default `server.host` is `0.0.0.0`. That can expose Kandev to other machines on the network, and the current local product path is not an authenticated multi-user boundary. Bind it to loopback unless remote access is deliberately protected:
|
||||
|
||||
```bash
|
||||
KANDEV_SERVER_HOST=127.0.0.1 kandev
|
||||
|
||||
@@ -104,6 +104,19 @@ require the launcher health token — Vite is not a Kandev process and does not
|
||||
If either child exits, the launcher shuts the whole tree down and exits with the child's
|
||||
code, matching current behavior.
|
||||
|
||||
### Startup output advertises network addresses
|
||||
|
||||
The startup banner for `dev`, `start`, and `run` prints the localhost backend URL and
|
||||
then one `network:` URL for each unique non-loopback, non-link-local host address on the machine. This
|
||||
includes addresses from local-network and Tailscale interfaces so that a user running
|
||||
Kandev on a remote VM can identify an address to open from another machine.
|
||||
|
||||
The banner lists IPv4 addresses before IPv6 addresses, omits link-local addresses, and
|
||||
wraps IPv6 hosts in brackets. Network-address discovery is best effort: if the host
|
||||
cannot enumerate its interfaces, the launcher still starts and prints the localhost
|
||||
URL. When `KANDEV_SERVER_HOST` restricts the backend to loopback or specific addresses,
|
||||
the banner omits unreachable interface addresses and only advertises matching binds.
|
||||
|
||||
### Backend restart from the UI still rebuilds
|
||||
|
||||
The restart supervisor (ADR 0019) writes a launch manifest and listens on a control
|
||||
@@ -187,6 +200,7 @@ them: building and serving the web app (Vite), the published npm shim, and repo
|
||||
| Either child exits | Shut down the tree; exit with that child's code, or 0 if it was signalled. |
|
||||
| `pnpm` missing | Surface the spawn error rather than hanging on the readiness probe. |
|
||||
| Ctrl-C | Whole tree terminates, including on Windows, without winjob. |
|
||||
| Network interface enumeration fails | Continue startup and omit `network:` lines; keep the localhost URL. |
|
||||
|
||||
## Persistence guarantees
|
||||
|
||||
@@ -196,3 +210,18 @@ them: building and serving the web app (Vite), the published npm shim, and repo
|
||||
never prune other backup families.
|
||||
- The supervisor manifest and control socket live under
|
||||
`<KANDEV_HOME_DIR>/supervisor/` at mode `0600`, unchanged from `start`.
|
||||
|
||||
## Scenarios
|
||||
|
||||
- **GIVEN** a host with non-loopback LAN and Tailscale IPv4 addresses, **WHEN** the
|
||||
`dev`, `start`, or `run` launcher prints its startup banner, **THEN** it prints one
|
||||
`network:` URL for each address using the backend port.
|
||||
- **GIVEN** a host with duplicate addresses, loopback addresses, or link-local
|
||||
addresses, **WHEN** the startup banner is printed, **THEN** duplicate, loopback, and
|
||||
link-local addresses are omitted.
|
||||
- **GIVEN** a host with an IPv6 address, **WHEN** the startup banner is printed, **THEN**
|
||||
the address is rendered as `http://[<address>]:<port>`.
|
||||
- **GIVEN** interface enumeration returns an error, **WHEN** the launcher starts,
|
||||
**THEN** it continues startup and prints the localhost URL without a `network:` line.
|
||||
- **GIVEN** `KANDEV_SERVER_HOST` is a loopback or specific bind address, **WHEN** the
|
||||
startup banner is printed, **THEN** it omits unrelated network addresses.
|
||||
|
||||
Reference in New Issue
Block a user