Public: anyone can read this; the crew can change it.
forge.json validates a service app's ports and refuses a clash with another app #16778
Check · Review · Land · Live done — Landed and live in production.
A service whose declared port is already held by another running service is now refused at deploy. The refusal names both, for example "port 25565 is already held by mc; proxy cannot declare it".
-
Reviews
Changes requested — before the latest pushTwo things to fix in one round.
- (First) Every preview of a service app is now refused while its production runs. The clash check counts the app's own other environments as holders, so a pull whose branch keeps the same declared ports as production fails deploy with 'port N is already held by <slug>'. A service app can no longer be previewed at all, and a redeploy of a changed branch has the same problem. Skip the app's own other environments (same app id) as holders, or show that previews get their own ports. Add a test through bringUp, or a holder-building helper, where a preview of an app whose production holds the same port is allowed and a different app's holder is refused.
- The cross-app refusal in bringUp is not tested. Only the pure portClash function is. The holder building (env naming, skipping self, skipping envs with no live service) and the error wrapping in bringUp are the part that can go wrong, and nothing would fail if they broke. Pull that loop into a small function next to portClash and test it. The valid, out-of-range and duplicate tests only cover parseService, which was already there. They are fine, but they do not cover this change.
Also: only environments live in this process count as holders, so a stopped or asleep service does not hold its port. That means the check gives the same answer depending on what is awake. State this limit in the README or the docs if you keep it. I did not boot a real deploy on the preview.
ApprovedEarlier asks are met: an app's own previews and production no longer clash (portHolders skips the same app id); the holder loop is a tested function beside portClash; the live-only limit is documented in docs/APPS.md; the
as nevercasts are gone. The refusal names both apps and the env. No page, route or tool changed, so no door or how-to is owed.Next two things I would do: (1) Non-blocking: move the mid-file
import { deployPortRefusal, ... }in test/service-ports.test.ts to the top with the other imports. (2) Non-blocking: the pull page does not yet show the refusal before deploy; surfacing it there would let a person see the clash without reading the deploy log. -
Checks
shipped production is serving it deploy aac12e1
-
History
- Port tests build real records: PortEnv asks only for the ports it reads (#15078) 143326d
- Port holders skip the app's own environments; the holder loop is a tested function beside portClash (#15078) 7482c2c
- A service's declared port held by another app is refused at deploy, naming both (#15078) 38c124d
- The system MCP tool answers `kind: "pages"` with the same page-budget rows /system shows (#16755) df6de28
- Talk on a phone, still wrong after #16552 landed: conversation history loads… (#16768) f2ced5a
- An issue whose body opens "Follow-up to #N" waits for #N on the map, and the page and the terminal say so (#16762) e002bf0
- Next up's pace line wins only when the cost line is unknown: a test shows both (#16763) 8e10c2c
- A pull reading says approval moved in one string: approvedAt reads "head against base" beside the object it carries now (#16761) f788d21
- Every /next decision kind has a test that fails without its 60-second Undo, and the MCP names the same undo (#16758) e78d344
- A 5,000-row deploy_pull prune batch holds the write lock under 50 ms, measured in a test (#16756) b9a4941
- The vendor's own variables (ANTHROPIC_*, CLAUDE_CODE_*) are read only inside the Claude runner's module (#16757) 46e0349
- Revert "LFS door: batch API and locks on the BlobStore" (#16754) 771a2a7
- The pull page answers inside a lower budget, measured (#16748) 9ac08ea
- The forge is a developer's file system: every app's database and the API spec, first-party (web, terminal app, MCP) (#16743) f6d3c84
- Component library: skeleton, toast and confirm dialog as ui.ts parts, each in the gallery (#16683) 6ba9019
- Quarantine untrusted repositories until a Sentinel security review passes (#16709) 92b768e
- A gate's checkout is not removed under it: three gates on #7608 went red on files missing from their own working tree (#16742) bec38a3
- Infrastructure: what runs on your own cloud, what it is for, what it costs and when it ends, and a plan tray that builds it (#16706) d11ea08
- A pull's pairs line counts pages, not pictures, when a page has both a phone and a desktop look (#16747) 0c2baa3
- GET a repository's milestones answers under 50 ms: trevato/forge's `read` phase is 1,365 ms today (#16735) 2816515
2 earlier comments
A service whose declared port is already held by another running service is now refused at deploy. The refusal names both, for example "port 25565 is already held by mc; proxy cannot declare it". I ran bun test test/service-ports.test.ts test/service-run.test.ts (10 pass), bun x tsc --noEmit and bun scripts/gate.ts, all clean. I did not boot the app or try a real deploy.
- Already there:
parseServiceinsrc/apps/service.tsalready refused ports that weren't integers 1024–65535 and any port named twice in one app. I left that alone. - Added:
portClash(mine, ports, holders)insrc/apps/service.tsis a pure function that returns the refusal text ornull.bringUpinsrc/apps/runtime_bringup.tscalls it for service manifests only, before the checkout, against every other environment with a live service. The cell's own port is not touched. - Tests:
test/service-ports.test.tscovers valid ports, out of range (including fractional and non-number), duplicates, and the cross-app clash. - Preview vs production: A preview and its own production also clash, since they share one host. I counted that as a clash on purpose.
- Holders: Only environments live in this process count as holders, not ones that are asleep or stopped. That means the check misses a service that is down at the moment, and it isn't a stored claim on the port.
- Pull page and push check: I did not add the check to the pull page or the push check. It only runs at deploy.
- Docs: No
docs/featuresentry orsrc/tuichange, because no page, API route or tool changed.
To try it, deploy two service apps that declare the same port. The second deploy fails with the refusal above.
🤖 Generated with Claude Code
Both points are fixed and pushed. bun test test/service-ports.test.ts passes (7), bun x tsc --noEmit is clean, and bun scripts/gate.ts printed nothing. I did not boot a real deploy.
- Previews of a service app: the check now skips every environment with the same app id as the one deploying. A preview, or a redeploy of a changed branch, is no longer refused for its own production's ports. Only another app's live service counts as a holder.
- Holder loop moved and tested: it is now
portHoldersanddeployPortRefusalinsrc/apps/service.ts, besideportClash.bringUpjust callsdeployPortRefusaland returns its text as the error.test/service-ports.test.tsnow covers these cases:- A preview whose production holds the same port is allowed.
- A different app's holder is refused, with the exact message and the environment name, for example
mc (pull-9). - A service that is not live, and a web app, hold nothing.
- Valid, out-of-range and duplicate tests: I kept them, and agree they only cover
parseService, which was already there. The new tests are the ones for this change. - Documented limit:
docs/APPS.mdnow says that only services live in this forge process hold ports. A stopped or asleep service holds none, so the answer depends on what is awake.
One thing left as it was: two previews of different apps that declare the same port are still refused while both are live. That matches the issue's cross-app rule.
🤖 Generated with Claude Code
This push fixes the failed gate check: test/service-ports.test.ts no longer uses as never.
The pull itself is unchanged: a service's declared port that another app already holds is refused at deploy, and the message names both apps.
The two casts were in the svc helper and in the web record that has no service. To drop them I narrowed PortEnv.live.manifest.service in src/apps/service.ts to Pick<ServiceSpec, "ports">. The port check only reads ports, so the tests can now build plain records that type-check.
Verification:
bun scripts/gate.tsis clean.bun x tsc --noEmitis clean.bun test test/service-ports.test.tspasses (7 tests).
I didn't run the rest of the suite; the forge runs the full check on this push.
A service whose declared port is already held by another running service is now refused at deploy. The refusal names both, for example "port 25565 is already held by mc; proxy cannot declare it". I ran
bun test test/service-ports.test.ts test/service-run.test.ts(10 pass),bun x tsc --noEmitandbun scripts/gate.ts, all clean. I did not boot the app or try a real deploy.parseServiceinsrc/apps/service.tsalready refused ports that weren't integers 1024–65535 and any port named twice in one app. I left that alone.portClash(mine, ports, holders)insrc/apps/service.tsis a pure function that returns the refusal text ornull.bringUpinsrc/apps/runtime_bringup.tscalls it for service manifests only, before the checkout, against every other environment with a live service. The cell's own port is not touched.test/service-ports.test.tscovers valid ports, out of range (including fractional and non-number), duplicates, and the cross-app clash.docs/featuresentry orsrc/tuichange, because no page, API route or tool changed.To try it, deploy two service apps that declare the same port. The second deploy fails with the refusal above.
🤖 Generated with Claude Code
Closes #15078