Repository navigation
refactor(scripts): compute worktree slots and ports in one place - #3248
Conversation
The slot formula (cksum of the folder name, mod 100) was copied into dev-env.sh, test-e2e.sh, the Makefile and seed-alerts.ts. The dev portal used a different formula, so it picked the wrong slot. Add scripts/slots.sh (hdx_dev_ports, hdx_ci_ports, hdx_e2e_ports) as the only place slots and ports are computed. It has no side effects. Add scripts/with-slots.sh for tools that need the dev ports. Every caller now uses them. Default ports are unchanged. Add HDX_SLOT_FROM=path, which hashes the worktree's full path instead of its folder name, for worktrees that share a name (a/hyperdx, b/hyperdx)
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Additional context: 1 file(s) in private internal-tooling packages, excluded from the line count Review process: Full human review — logic, architecture, edge cases. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
4 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 4 minor 1 posted as inline comment(s) on the changed lines. 3 listed below. Findings outside the changed lines3 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
|
Deep Review✅ No critical issues found. This is a dev-tooling refactor (shell, Makefile, Node portal, one TS script). Nothing touches production runtime, auth, or persisted product data. The core promise — default slots/ports byte-for-byte unchanged from 🟡 P2 — recommended
🔵 P3 nitpicks (4)
Reviewers (8): correctness, testing, maintainability, project-standards, adversarial, performance, kieran-typescript, previous-comments. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
E2E Test Results✅ All tests passed • 389 passed • 1 skipped • 1571s
Tests ran across 4 shards in parallel. |
- Makefile: compute the integration test slot and ports in one shell instead of six. The block runs on every make invocation; an empty target drops from ~190ms to ~78ms. - slots.test.mjs: scan tracked files only, so a local scratch file that mentions cksum no longer fails `make ci-unit`.
Why
Each worktree gets a slot (0-99), and every service's port is a fixed base number plus that slot. The slot formula,
cksumof the folder name mod 100, was copied intodev-env.sh,test-e2e.sh, theMakefileandseed-alerts.ts, and the port numbers were repeated alongside it. The copies could drift, and one already had: the dev portal added up character codes instead of usingcksum, so it computed the wrong slot for its own worktree.Tools that only needed the ports had a second problem. hdx-eval got them by sourcing
dev-env.sh, which also clearspackages/app/.nextand registers the stack with the dev portal. Doing that whileyarn devis running disrupts the running stack.Separately, worktrees that share a folder name (
a/hyperdx,b/hyperdx) always got the same slot, so their stacks clashed.What changed
scripts/slots.shis now the only place slots and ports are computed:hdx_dev_ports,hdx_ci_ports,hdx_e2e_ports. Sourcing it only sets and exports variables. It writes, starts and prints nothing.scripts/with-slots.sh <command>runs a command with this worktree's dev ports set.seed:alertsnow uses it.slots.sh:dev-env.sh,test-e2e.sh, theMakefile, hdx-eval'senv.sh, and the dev portal. This fixes the portal's wrong slot, and hdx-eval no longer touches a running stack.HDX_SLOT_FROM=pathis a new opt-in setting that hashes the worktree's full path instead of its folder name. Set it in your shell profile if your worktrees share a folder name. Without it, nothing changes.Default ports are unchanged
With
HDX_SLOT_FROMunset, every slot and port value is the same as onmain, so existing stacks and their.volumes/*_<slot>data folders keep working. One small difference: the slot is now hashed from the repo's top folder name, not the name of whatever folder the command runs in. From the repo root, whereyarn devandmakerun, both are the same name (hyperdx→ slot 96). Run from a subfolder likepackages/api,mainwould have hashedapiand picked the wrong slot; this branch still hasheshyperdx.