Repository navigation
factory: --port has no upper bound: b4 start --port 70000 crashes with Node's ERR_SOCKET_BAD_PORT instead of Invalid port - #1050
b4dotrun[bot] wants to merge 1 commit into
Conversation
… with Node's `ERR_SOCKET_BAD_PORT` instead of `Invalid port` Refs #1047 Work order wo-f5fea70dc61c255a, bundle 6b8ed3e4e23fb662dd635c901ec9975c8b872ebab93a22389166f4252fedaa13.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
…→ PR #1050) (#1051) * fix(software-factory): the cli target's promotion set is pin-specific, and the builder searches only its package The first live run at pin c221ce0 found two things. The cli target's Dockerfile hard-codes the nested dependencies it promotes over the root's; the lockfile at this pin nests a different set (ag-ui now nests the TypeScript 6 compiler core also nests, and axe-core; commander and hono no longer nest), so the image build failed. The set is now this pin's, the comment says it is pin-specific, and a name two packages nest at the same version is promoted once instead of failing the build. The builder then ran a recursive grep over .., which followed the node_modules links into the image's install and returned 1.7 MB in one tool result; the model refused the next call at 513k input tokens. The working rules now confine searches to the package's own directories and cap what a search prints. Co-Authored-By: Claude Fable 5.1 <[email protected]> * feat(software-factory): pre-check refuses a built path no source compiles to, and the CLI entry Today's live run spent both intake attempts on guessed build paths: a check importing packages/cli/dist/output.js (the file is dist/lib/output.js), then one importing dist/index.js, the CLI entry, whose proof hung. Each cost a two-minute oracle proof. Rule (f) built-source: a location (static, import()/require()/new URL(), or a path held in a variable built from join/resolve/process.cwd()/pathToFileURL) under a target build prefix (snapshotIgnore entries ending dist/) must mirror a source the pin holds: <pkg>/src/<file>.ts|.tsx|.js|.jsx (.mjs/.cjs likewise), or <file>/index.ts|.tsx for an extensionless import. The refusal names the path, the source looked for, and a same-named module under src/ or the nearest directory's listing. Rule (g) bin-entry: a location naming the built file a package bin runs (read at the pin from package.json bin and the bin script's ../dist imports) is refused. The drafter prompt's target line now says the built path mirrors src/, to verify with listDir/readFile under repo/<pkg>/src/, and never to import a bin entry. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(software-factory): the drafter finds a built file by its source, and the cli target test names this pin's promotion set Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(software-factory): the cli target pins today's main and captures the test helper its tests import At pin 765e6e1 the captured cli tests did not import test/helpers/header-auth.ts; at main's tip eight of them do, and the explicit capture omitted it, so the builder's visible suite failed to load and the builder spent its turn hunting a helper that was never in its workspace. The target now pins 84063ae, captures the helper, and the generator's build order at that pin puts sdk before ag-ui. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(software-factory): a candidate never includes the framework's offloaded tool outputs B4 spills an oversized tool result to tool-outputs/ in the thread's workspace. The reader's observed set now leaves that prefix out, as it does the target's build output: the first live run's correct repair was refused as a scope violation for the one file the offload had written. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(software-factory): the #714 task re-seeds its defect by patch, now that the cli pin carries the fix `cli-runs-wait-undefined` was repaired forward: its defect was the pinned bytes at 765e6e1. The cli target now pins 84063ae, where #718's fix has landed, so the task ships a defect.patch that reverses it and a reference regenerated at that pin (same body, new offsets). The inspection test names `tool-outputs/` as part of the ignored set. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs: record the rung 4 live run as landed Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
|
Adopted as #1062: the delivered commit cherry-picked onto |
…e's `ERR_SOCKET_BAD_PORT` instead of `Invalid port` (#1047) (#1062) * factory: `--port` has no upper bound: `b4 start --port 70000` crashes with Node's `ERR_SOCKET_BAD_PORT` instead of `Invalid port` Refs #1047 Work order wo-f5fea70dc61c255a, bundle 6b8ed3e4e23fb662dd635c901ec9975c8b872ebab93a22389166f4252fedaa13. * `--port` has no upper bound: `b4 start --port 70000` crashes with Node's `ERR_SOCKET_BAD_PORT` instead of `Invalid port` (#1047) Adopted from the factory's draft PR #1050 (work order wo-f5fea70dc61c255a): the delivered commit, cherry-picked, plus a changeset (.changeset/factory-wo-f5fea70dc61c255a.md) and the factory's independent check as packages/cli/test/port-parse.test.ts. Closes #1047 --------- Co-authored-by: b4dotrun[bot] <344497757+b4dotrun[bot]@users.noreply.github.com>
blove
left a comment
There was a problem hiding this comment.
Maintainer review of the factory's delivered commit 05141c76 (pinned at 84063ae1). This PR was already closed and adopted as #1062, merged to main as a2d2ca32. This review is a retrospective record of the factory's first real output. It is not a merge gate.
Correctness: sound
- Integer parsing. In both parsers,
/^\d+$/runs beforeNumber(). That rejects1e3,0x1f90,+80," 80", a trailing newline, negatives, and non-ASCII digits (\dwithout theuflag matches only ASCII). I checked each of these against the patched logic. Leading zeros are still accepted (08080→ 8080, and in start00000→ 0), which is harmless. - 65535 bound.
port > 65535is correct in both files.65535is accepted, and65536and70000are rejected. A 400-digit string becomesInfinityand is rejected too. - The two parsers are consistent.
parse-port.tskeeps<= 0andstart.tskeeps< 0, as the task required. The comments explaining that difference are kept in both files, and the diffs are otherwise identical. CliErrorusage matches the surrounding code:new CliError(\Invalid port: ${rawPort}`, 2), with the same message and exit code as the existing branch. The existingstart-command.test.tsassertion ("Invalid port: not-a-number"`) still holds.
Nits (non-blocking, fine to leave)
- The
Number.isIntegercheck is now redundant. After/^\d+$/,Number()can only return a non-negative integer orInfinity, and the range check already rejectsInfinity. Keeping it is defensible as belt-and-braces, but folding both checks into oneifwould read more simply. - The error message doesn't say what's valid.
Invalid port: 70000keeps the existing contract, which is the right call for a scoped fix. A later polish could append the range, for example(expected 1–65535)for dev/inspect and(expected 0–65535)for start. - The start.ts comment "Unlike dev.ts's parsePort" was already stale before this PR: the shared parser lives in
lib/dev/parse-port.ts. Not the factory's to fix under its two-file allowance. - Behavior change worth naming in the changeset:
--port " 80"and--port +80used to be accepted and are now rejected. That is the intended tightening, but it is user-visible.
Scope: what a human would add
- Changeset. Required, since this is a user-facing
@b4run/clichange. The factory doesn't write changesets by design, sochangesetsis the only red check. Belongs in the adopting PR (#1062 added.changeset/factory-wo-f5fea70dc61c255a.md). - Unit test. The PR adds none, because the factory's independent check stays hidden from the builder. Neither parser has a direct test at the PR head: only the
-1/not-a-numbercase instart-command.test.tsexists. A human would add the boundary cases (65535, 65536, 70000, 1e3, 0x1f90, and 0 for each parser). Belongs in the adopting PR (#1062 promoted the check topackages/cli/test/port-parse.test.ts). - Docs. Nothing needed.
apps/web/content/docs/cli.mdxdocuments--port <number>without claiming a range, and rejecting out-of-range values is the expected behavior. - The
PORTenv path is a sibling gap and out of scope here. At the pin,resolveServePortinserve-runtime.tsdoesNumber(envPort)with only anisFinitecheck, soPORT=70000 b4 startwould still crash withERR_SOCKET_BAD_PORT. That is a separate defect, already handled by #1066.
Local verification on 05141c76
-
pnpm lint: pass (exit 0). -
pnpm build: pass. -
pnpm --filter @b4run/cli test: 2768 passed, 12 failed, 3 skipped. None of the failures is caused by this PR. I reverted the two files to the pin and reran the failing files: they still failed (11 at the pin, versus 6 on the head rerun after a full build). They fall into three groups:dev-commandandvercel-target: timeouts and lifecycle races. The set of failing tests changed from run to run.api-reference-compatibility: my worktree sat under the macOS/private/tmp→/tmpsymlink, so the guard's emitted module paths didn't match. This is environmental.pending-interrupts-endpoint: my first run used a filtered build that skippedpostgres-storage/dist. It passed after the full build.
CI's
source-validate, which runs the fullpnpm teston this head, passed. -
start-command.test.tsandinspect-command.test.ts: pass. I also ran main's promotedpackages/cli/test/port-parse.test.ts(from #1062) against this head's code: pass, 13/13 across the three files.
CI on the PR: every validation lane passed (source-validate, release-controller, pack-smoke, harness-verify, testing-windows). Only changesets failed, as expected.
Recommendation
Merge as-is after adding a changeset (plus the promoted boundary test). No code changes requested. That is what happened via #1062, so closing this draft was the right disposition.
…ers' checks (#1075) Follow-up polish to #1062 from the review of #1050: - Fold the digits-only check and the range check into one condition in both parsers. After `/^\d+$/`, Number() can only return a non-negative integer or Infinity, so the separate `Number.isInteger` guard was redundant. - An invalid `--port` now says what is accepted: `1 to 65535` for b4 dev and b4 inspect, `0 to 65535` for b4 start. - Fix the stale "dev.ts's parsePort" comment in start.ts; the shared parser lives in lib/dev/parse-port.ts. - Update the message assertions and cover `parsePort("0")`. Co-authored-by: Claude Opus 5.5 <[email protected]>
Refs #1047
Produced by the B4.run software factory from issue #1047 and approved by a person
(recorded actor: operator) on 2026-10-21T00:25:11.293Z. This is a draft. The factory never merges.
Pin and drift
Branched at 84063ae. main was at 84063ae when delivered, 0 commits ahead of the pin.
No file this change touches changed on main in between.
Approved task
Digests and receipts
task d7d558a2c33a0204de36cfa33ea6130b9a24af832a20c88379a61d13bebacabc · bundle 6b8ed3e4e23fb662dd635c901ec9975c8b872ebab93a22389166f4252fedaa13 · candidate 0dbfd2e637bea14550da98fa24f7252a8b3832fb37e01da48d45845306468247
oracle receipt rc-12e47229-31ec-45e3-ad4e-20d2eb0f0597 · verification receipt rc-6be47ec5-38cd-4276-8f26-5fea54e4d863 · re-verification at approval rc-25c2f6f8-20a5-461c-877d-bc97e1795a69
policy 524e28ea232f0f605c1afc3fdf0f73b36b666b4b5d55a28122687b036668b5ed · environment b55af4c0a42e71485017db422dc6da02e46b8b291619b56d756415835bb80593