Repository navigation
fix(capacity): valid calibration run IDs and early build-artifact preflight - #248
Merged
Merged
Conversation
…flight Two defects found on a fresh Ubuntu 26.04 host: - The calibration run ID (capacity_calibration_<ms>_<uuid>) was 74 characters, exceeding TEST_RUN_ID_PATTERN (64), so the owned backend refused CAPACITY_TEST_RUN_ID and never started. Generate cap_<ms>_<uuid> (54 characters) via createCalibrationRunId(), which re-checks the central pattern. - The owned backend serves dist/public via serveStatic(), so a missing build killed it deep inside startup. runCalibration() now verifies dist/public/index.html before any probe, Docker control, active or startup measurement and aborts with "run npm run build". It does not build automatically; dry runs start no backend and skip the check. Document the host calibration sequence (npm ci, npm run build, npm run build:sandbox, npm run capacity:calibrate). No capacity policy, limits or production defaults change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two real failures of the capacity-calibration workflow found on a fresh Ubuntu 26.04 / x86_64 install. No change to capacity semantics, limits, policy, or production defaults;
TEST_RUN_ID_PATTERNand the 64-character limit are untouched.1. Invalid
CAPACITY_TEST_RUN_IDscripts/calibrate-capacity.tsgeneratedcapacity_calibration_${Date.now()}_${randomUUID()}, which is 71 characters (21 + 13 + 1 + 36).server/config.tsvalidatesCAPACITY_TEST_RUN_IDagainstTEST_RUN_ID_PATTERN(^[A-Za-z0-9_-]{1,64}$), so the owned backend refused to start.createCalibrationRunId()producescap_<timestamp>_<uuid>(54 characters) and re-checks the result against the centralTEST_RUN_ID_PATTERN, failing loudly in the script rather than inside the backend.2. Missing
dist/publicsurfaced only deep inside backend startupThe calibrator spawns
server/index.tswithNODE_ENV=test, which callsserveStatic(); withoutnpm run buildthe backend died during startup with aserveStaticerror.assertCalibrationBuildArtifacts()is wired intorunCalibration()as the first step, before the host/Docker probes and before any Docker-control, active, or startup measurement. It checksdist/public/index.html, resolved relative to the script (the same locationserveStatic()resolves).Capacity calibration requires a built application (<path> not found); run npm run build.; no probe, backend, or report directory is created.npm run builditself.serveStatic()and theNODE_ENV=testgateway semantics are unchanged.--dry-runstarts no backend and therefore skips the check.verifyBuildArtifacts) so unit tests stay hermetic: the CI unit job runs beforenpm run build.Docs
docs/INSTALL_SERVER.md(calibration section) anddocs/CAPACITY_MODEL.md(host-capacity calibration workflow) now documentnpm ci→npm run build→npm run build:sandbox→npm run capacity:calibrate -- --expected-users <N>, note thatbuild:sandboxequals the existingdocker build -f Dockerfile.sandbox …line, and that theunosim-serverimage is not needed.README.md: one-line note.How the failures were reproduced
Reported on a fresh Ubuntu 26.04 / x86_64 host:
CAPACITY_TEST_RUN_ID: with the build present, the owned backend rejected the generated ID because it exceedsTEST_RUN_ID_PATTERN. Verified locally by computing the old format: 71 characters vs. the 64-character limit (new format: 54).dist/publicbeforenpm run build: on that host nonpm run buildhad been run, sodist/publicdid not exist and the backend died inserveStatic()during startup. The installation doc did not make the build a clear precondition.I did not have access to the Ubuntu host; I verified the fix locally in a detached git worktree without
dist/:npm run capacity:calibrate -- --expected-users 200now exits immediately (exit code 2) with the actionable message above and creates nocapacity-test-results/.Tests
tests/server/calibrate-capacity-cli.test.ts(18 tests, was 9 before this change):TEST_RUN_ID_PATTERN, length ≤INPUT_LIMITS.webSocket.maxTestRunIdChars, longest realistic timestamp stays within the limit, runs are distinguished by timestamp and by UUID (deterministic injected clock/UUID, no random-sampling test), an invalid ID is rejected;npm run buildmessage;runCalibration()aborts before any host/Docker probe, control measurement, backend start, scenario, or report; dry run does not call the check;INSTALL_SERVER.mdandCAPACITY_MODEL.md.Existing calibration tests inject
verifyBuildArtifactsso they do not depend on a build.Local verification:
npm run check, ESLint with--max-warnings=0,npm run check:docs, and the full./run-tests.shpipeline (static analysis, knip, unit, toolchain integration, Docker, Playwright E2E 28 passed, production build, security audit, Sonar gate: 0 violations) were green; the pre-push hook (unit + fresh Sonar scan) passed.Note: the commit message states the old ID length as 74 characters; the correct value is 71 (as above). Not amended, per repo policy.
🤖 Generated with Claude Code