design: take the port from the sidecar binding #76
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "land/design/sidecar-binding"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The manifest pinned
port = 4290and4287, andvite/config.tsreadSIDECAR_PORTout of the environment and validated it by hand. Both existedbecause the binding did not, and both are exactly what
perish.code/sidecar-closed-loopdeclared as its acceptance test.What
sidecar.toml: both targets lease withport = 0. The trailing--in eachargument list is gone with the flag it used to guard.
packages/design/src/vite/config.ts:client.connect()from@perish/sidecar, thenheld.control.port(). The range check leaves with theparsing, because a caller of a binding does not restate the grant's own rules.
packages/design/src/vite/lib.ts:connect()is async, so the plugin'sconfighook awaits it once and every later hook reads the resolved value.Vite runs
configbeforeconfigResolved,buildStart,configureServerand
generateBundle, so nothing observes the placeholder..npmrc: the@perishscope resolves from the Forgejo registry.Tests
pnpm check,pnpm typecheck,pnpm test(28 design, 11 docs),pnpm build,plumb doctor .,ectropy .— all green.Verified against the published binding rather than a local build:
port = 0leased 33259, sidecar announced it, the binding read it, vite pinnedit,
health_urlresolved against it, andstart --waitreturned only after thetarget answered. No
process.env.SIDECAR_PORTremains anywhere.Compatibility
Anyone who relied on the docs dev server answering on 4290, or preview on 4287,
now reads the port sidecar leased.
sidecar status --format jsonreports it,and the
{port}template resolves it inside the manifest.## Why The manifest pinned `port = 4290` and `4287`, and `vite/config.ts` read `SIDECAR_PORT` out of the environment and validated it by hand. Both existed because the binding did not, and both are exactly what `perish.code/sidecar-closed-loop` declared as its acceptance test. ## What - `sidecar.toml`: both targets lease with `port = 0`. The trailing `--` in each argument list is gone with the flag it used to guard. - `packages/design/src/vite/config.ts`: `client.connect()` from `@perish/sidecar`, then `held.control.port()`. The range check leaves with the parsing, because a caller of a binding does not restate the grant's own rules. - `packages/design/src/vite/lib.ts`: `connect()` is async, so the plugin's `config` hook awaits it once and every later hook reads the resolved value. Vite runs `config` before `configResolved`, `buildStart`, `configureServer` and `generateBundle`, so nothing observes the placeholder. - `.npmrc`: the `@perish` scope resolves from the Forgejo registry. ## Tests `pnpm check`, `pnpm typecheck`, `pnpm test` (28 design, 11 docs), `pnpm build`, `plumb doctor .`, `ectropy .` — all green. Verified against the published binding rather than a local build: ``` preview -> grants {broker: tcp://127.0.0.1:41761, port: "33259"} pid 2492265 (host), target 2492266 curl http://127.0.0.1:33259/health -> 200 ``` `port = 0` leased 33259, sidecar announced it, the binding read it, vite pinned it, `health_url` resolved against it, and `start --wait` returned only after the target answered. No `process.env.SIDECAR_PORT` remains anywhere. ## Compatibility Anyone who relied on the docs dev server answering on 4290, or preview on 4287, now reads the port sidecar leased. `sidecar status --format json` reports it, and the `{port}` template resolves it inside the manifest. Land-Source: design/sidecar-binding@3032c6fb0c9786f6cee44c98f85271