Skip to content

fix(dashboard): build the image from the lockfile and compare it in CI - #499

Merged
Alajmah merged 1 commit into
masterfrom
fix/dashboard-image-lockfile-v4
Nov 23, 2026
Merged

Alajmah merged 1 commit into
masterfrom
fix/dashboard-image-lockfile-v4

Conversation

@Alajmah

@Alajmah Alajmah commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Status

Create only. Merge and deployment are on hold until the diff and the build test are reviewed.

This supersedes #498, which superseded #495. It is the same change with one addition: the correction the maintainer asked for on #498. A branch cannot be updated here, so the correction is in a new branch.

What this changes

The dashboard image was not built from the lockfile. packages/web-dashboard/Dockerfile copied only package.json into its build context and ran npm install, which resolves dependency ranges on the day of the build. This PR makes the image install from package-lock.json, the way the app image does, and adds a CI check that compares the packages inside the built image with the lockfile.

The correction asked for on #498

The maintainer found that scripts/compare-image-deps.mjs treated a directory it could not list as an empty one. So the check could pass without having seen the packages under that directory. That was correct, and it is closed here.

Failure while examining the image Before (#498) Now
A directory cannot be listed treated as empty; the walk went on the walk stops, the check exits 2 and names the directory and the error code
A directory's own status cannot be read treated as "not a directory"; skipped the same explicit failure
A directory's real path cannot be resolved the child crashed; the check reported a stack trace the same explicit failure, with the code
A package's package.json is there and cannot be read reported, without saying why the same explicit failure, with the path and the code
The workspace's own package.json cannot be read reported as a version mismatch (exit 1) an explicit failure (exit 2)

Three cases are still passed over, on purpose, because nothing is hidden by them: a directory without a package.json is not a package, and an entry that is not a directory or that does not exist is skipped.

How it works: list() no longer returns an empty list on failure. It records the path and the error code and raises a signal that stops the walk. The listing reports what it recorded, and the script exits 2 with it. The result is never a pass.

The tests for it

Test How the failure is brought about Runs on
4 cases: a directory cannot be listed (inside a package, a scope directory, the top-level node_modules, a directory on the way down from the root) the listing runs in a child Node process; a module it loads first makes readdirSync fail with EACCES for that path every platform
The error code is named the same, with EIO every platform
A directory's status cannot be read statSync fails with EACCES every platform
A real path cannot be resolved realpathSync fails with ELOOP every platform
A package's package.json cannot be read readFileSync fails with EACCES every platform
The workspace's own package.json cannot be read the same every platform
A process without permission cannot list a node_modules directory inside a package real permission bits (chmod 000) POSIX, as a plain user
A process without permission cannot read a package directory real permission bits POSIX, as a plain user
A symbolic link that points at nothing is passed over a real dangling link POSIX
--image: a directory cannot be listed the injected failure, through the fake docker of the existing test POSIX

Fails before the correction, passes after

The same test file was run against the script as it is in #498, then against the corrected script. Windows, Node 22:

On the script of #498 On the corrected script
The 9 tests that run on every platform 9 fail 9 pass
Whole file 9 failed, 22 passed, 5 skipped 31 passed, 5 skipped

What the script of #498 answered, test by test:

Test Script of #498 Corrected script
A node_modules directory inside a package cannot be listed exit 0, result PASS exit 2, the directory is named
A scope directory cannot be listed exit 0 exit 2
A directory on the way down from the root cannot be listed exit 0 exit 2
The error code is named exit 0 exit 2, (EIO)
A directory's own status cannot be read exit 0 exit 2
The top-level node_modules cannot be listed exit 2, for another reason ("no packages were listed") exit 2, the directory is named
A real path cannot be resolved exit 2, with a stack trace in place of the path exit 2, (ELOOP)
A package's package.json cannot be read exit 2, without the path and the code exit 2, with both
The workspace's own package.json cannot be read exit 1, as a version mismatch exit 2

Five of the nine are the case the maintainer described: the check passed.

The five POSIX-only tests could not run before the correction on this Windows machine. They ran once, after it, in the Linux CI run below.

What the current build holds

I listed every package in the running production dashboard container (read-only, 2026-11-22 before this change) and checked each against the lockfile on master. The container held 16 packages. Three versions were in no lockfile entry:

Package In the production container In the lockfile before this PR
@next/env 16.4.6 16.3.3 only
semver (top level) 6.3.2 not present
semver (under sharp) 7.8.6 not present

The Dockerfile as it was reproduces this: a local rebuild of it, compared with the old lockfile by the new check, reports the same three.

Root cause of the @next/env difference

The lockfile entry for the dashboard's next 16.4.6 recorded the dependency ranges of 16.3.3, and the @next/env entry beside it was still 16.3.3. npm ci and npm ls accept that, because they compare the recorded ranges with the lockfile and not with the registry.

Lockfile change

Two entries repaired from npm's own resolution of the same versions, on a scratch copy:

  • packages/web-dashboard/node_modules/next: @next/env and the eight @next/swc-* ranges move from 16.3.3 to 16.4.6, and sharp from ^0.35.3 to ^0.35.5.
  • packages/web-dashboard/node_modules/@next/env: 16.3.3 to 16.4.6 (version, resolved, integrity).

The lockfile keeps its 1018 entries. Nothing is added or removed. One installed version changes: @next/env for the dashboard, from 16.3.3 to 16.4.6, which is the version next 16.4.6 declares.

Recorded ranges against the published manifests (registry audit of the dashboard's production tree, 76 entries compared): 10 ranges differed from the published manifest before this PR, 0 after.

Why not a full regeneration

Approach Entries Changed Added / removed
A. npm install --package-lock-only on the old lockfile 1018 → 1018 0 in the dashboard, 1 elsewhere (packages/demo-dashboard) 0 / 0
B. The same, after removing the stale dashboard entries 1018 → 1017 1 elsewhere 11 / 12
C. This PR 1018 → 1018 2, both under packages/web-dashboard 0 / 0

A repairs nothing: npm trusts the lockfile. B relocates the whole Next family from the dashboard's node_modules to the repository root, which changes the tree shape for every workspace, so it is wider than this unit. C changes only the two stale entries.

Build change

  • Build context is the repository root, because the dashboard's dependencies are locked in the root package-lock.json.
  • Install: npm ci --workspace=packages/web-dashboard --ignore-scripts. One workspace is installed and no lifecycle script runs. The lockfile is satisfied with only the root manifests and the dashboard manifest present, so the other workspaces are not copied into the builder.
  • Dockerfile.dockerignore (new, next to the Dockerfile): an allowlist that admits only what the Dockerfile copies. With the context at the repository root, the repository's .dockerignore would otherwise apply; it excludes *.svg, the public assets the image serves.
  • Three checks run before the install and fail the build when the ignore file is not honoured: no node_modules and no .next from a local checkout, and the svg assets present.
  • next.config.ts: outputFileTracingRoot is the repository root. Next drops every traced file outside that root, and the dependencies now come from the repository root's node_modules.
  • docker-compose.build.yml and the dashboard README describe the same build context.

What changes inside the image

Before With this PR
Entry point /app/server.js /app/packages/web-dashboard/server.js
Build output and public assets /app/.next, /app/public /app/packages/web-dashboard/.next, /app/packages/web-dashboard/public
Packages with a package.json (Linux) 16 20
React versions listed 19.2.4 19.2.4 and 19.2.8

Nothing outside the image depends on those paths: the production compose service sets no command or working directory, and the deploy script checks the dashboard over HTTP.

The second React version comes from the root lockfile and predates this PR: demo-dashboard resolves react to 19.2.8 at the repository root, while the dashboard pins 19.2.4 in its own node_modules. Next's standalone output copies fragments of both. In a local build the root react has 3 files and the root react-dom only its manifest. The only package in the output at the root that requires react is styled-jsx, a dependency of next that this dashboard does not use.

Next loads one React instance. Its build maps every react import to the copy inside the next package for the browser, and the server output reaches React only through one module of its own. I checked this at runtime on a local build: all 25 static pages render server-side with status 200 and no hook error, and two pages hydrate in a browser with no React error.

CI change

  • The three dashboard builds (docker-build-dashboard, release-tooling-validation, publish-release-images) use the repository root as context.
  • The image is compared with the lockfile in all three jobs. In publish-release-images the comparison runs before the image is pushed.
  • scripts/compare-image-deps.mjs lists every package.json under node_modules in the image and fails when a version is in no lockfile entry. A version the lockfile pins only for another workspace is a warning. A package.json that is there and is not a JSON object stops the check with exit 2. A directory that cannot be examined stops the check with exit 2.
  • The check compares package name and version. It does not compare where a package sits in the tree, and it does not compare the lockfile with the registry. Those are limits of the check as designed, not claims it makes.

Verification

Manual CI run on this branch, commit 537599f: https://github.com/Octo-Lex/GitWire/actions/runs/45075555290. All 16 jobs passed; publish-release-images is skipped on a manual run by design.

docker-build-dashboard, on Linux:

Step Result
Build context 1.01 MB
Three checks pass
npm ci 48.5 s
next build 13.7 s
Packages listed in the image 20
Pinned by the lockfile and in the dashboard tree 19
@next/env in the image 16.4.6, pinned
next in the image 16.4.6, pinned
sharp in the image 0.35.5, pinned
Warning semver@6.3.1 at the root: pinned by the lockfile for another workspace; a lone package.json with no code, which Next's standalone output also wrote into the old image (as 6.3.2)
Boot /dashboard responded

These are the results of run 45068276144 on #498, and they are unchanged.

release-tooling-validation, which installs dependencies at the repository root before building: the three checks pass there too, and the comparison gives the same 20 packages, 19 of them pinned and in the tree.

core-tests ran 97 tests on Linux. 36 of them are for the comparison script, and none was skipped.

docker-build-dashboard works on a clean checkout, so its checks show that the ignore file is honoured and nothing more. release-tooling-validation shows that a checkout's installed dependencies stay out of the build context.

The validator image is not touched by this PR.

Earlier attempts

Branch Commit Run Outcome
fix/dashboard-image-lockfile 0365a92 45062066337 Failed at a check of mine that I had placed after npm ci, which creates the directory the check looks for
fix/dashboard-image-lockfile-v2 (#495, closed) 8def80f 45063731937 Passed. Superseded for a correct review finding: a package.json that could not be read was left out silently
fix/dashboard-image-lockfile-v3 (#498, closed) d1d684c 45068276144 Passed. Superseded for the maintainer's finding: a directory that could not be listed counted as empty

The three branches are left in place until this PR is merged.

Not verified

  • The image was built on Linux only in CI. I did not run Docker locally.
  • The production dashboard's pages behind the login were exercised against no API backend, so they rendered their empty and error states.
  • publish-release-images does not run on a manual CI run. Its dashboard build and comparison first run after the merge.

Review record

Review Finding Answer
Automated review on #495 The lockfile repair is not among the changed files Not so. package-lock.json is one of the nine changed files, and the comparison run on the built image lists @next/env@16.4.6 as pinned
Automated review on #495 The script skips a package whose package.json cannot be read Correct. Fixed in #498 and kept here
Automated review on #495 Native optional dependencies may be missing from the lockfile Not so. The lockfile holds @next/swc-linux-x64-musl 16.4.6, @img/sharp-linuxmusl-x64 0.35.5 and lightningcss-linux-x64-musl 1.32.0. The Linux build log has no message about a WebAssembly fallback
Automated review on #495 The root lockfile pulls every workspace into the image Not so. One workspace is installed, lifecycle scripts do not run, and the runner stage copies only the standalone output, the static files and public. The comparison lists 20 packages
Automated review on #495 The new gate ships without tests Not so. The tests are in the PR, and the core-tests job ran them
Automated review on #498 The lockfile repair is missing from the diff Not so, as above. That review counted 8 changed files; there are 9
Automated review on #498 The check compares name and version only, not placement Correct, and stated as the check's limit
Maintainer, on #498 A directory that cannot be listed counts as empty Correct. Fixed in this PR

Found while working, outside this PR

  • packages/demo-dashboard has the same kind of stale entry: next 15.5.28 with the ranges of 15.5.24. Its 10 recorded ranges differ from the published manifest, unchanged by this PR. Its image also installs with npm install.
  • The bot, docs and plugin-sandbox images install with npm install as well. Of the three images the release pipeline publishes, the app image was already lock-pinned and the executor image has no dependencies.
  • In release-tooling-validation the app image's build context transfers 596 MB, also on master (run 45047105326). The job installs dependencies at the repository root before building. I did not check whether the rehearsal image differs from the published one because of it.

The dashboard image ran `npm install` inside packages/web-dashboard with
only that package.json in the build context. It resolved dependency
ranges on build day and ignored package-lock.json. The image now in
production holds three package versions that appear in no lockfile
entry: @next/env 16.4.6, semver 6.3.2 and semver 7.8.6.

Why @next/env differed: the lockfile entry for the dashboard's next
16.4.6 recorded the dependency ranges of 16.3.3, and the @next/env entry
beside it was still 16.3.3. `npm ci` and `npm ls` accept that, because
they compare the recorded ranges with the lockfile, not with the
registry.

package-lock.json: two entries repaired from npm's own resolution of
the same versions. In the next 16.4.6 entry, @next/env and the eight
@next/swc-* ranges go from 16.3.3 to 16.4.6 and sharp from ^0.35.3 to
^0.35.5. The @next/env entry goes from 16.3.3 to 16.4.6. The lockfile
keeps its 1018 entries; nothing is added or removed. A full
regeneration was not used: with the stale entries removed, npm moves the
whole Next family from the dashboard's node_modules to the repository
root (11 entries added, 12 removed).

packages/web-dashboard/Dockerfile: the build context is the repository
root and the dependencies are installed with
`npm ci --workspace=packages/web-dashboard --ignore-scripts`. The source
is copied before the install, and three checks that run in between fail
the build when the ignore file is not honoured: the repository's
.dockerignore drops the svg public assets and keeps a local checkout's
node_modules and .next in. The standalone output is read from the
workspace directory.

packages/web-dashboard/Dockerfile.dockerignore: an allowlist holding
only what the Dockerfile copies. It replaces the root .dockerignore,
which excludes the svg files under public that the image serves.

packages/web-dashboard/next.config.ts: outputFileTracingRoot is the
repository root. Next drops every traced file outside that root, and
the dashboard's dependencies are installed from the repository root's
node_modules.

scripts/compare-image-deps.mjs and its tests: list every package.json
under node_modules in the built image and fail when a version is in no
lockfile entry. A version the lockfile pins only for another workspace
is reported as a warning. A package.json that is there and cannot be
read as a JSON object stops the check; its package is never left out in
silence.
A directory that must be examined and cannot be listed, read or
resolved stops the walk; the check then fails with its path and the
error code. Before, a directory that could not be listed counted as
empty, so the check could pass without having seen the packages under
it.

.github/workflows/ci.yml: the three dashboard builds use the root
context. The image is compared with the lockfile in
docker-build-dashboard, in release-tooling-validation, and in
publish-release-images before the image is pushed.

docker-compose.build.yml and the dashboard README describe the same
build context.

Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T22:12:52.835841Z 537599f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gitwire-hq gitwire-hq Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Code Review — ✅ Approved

Confidence: high · Findings: 0
AI judgment: APPROVE · Evidence: COMPLETE · Authority: advisory
Evidence complete · 9/9 changed files accounted for

GitWire AI Review Gate (bundle-driven v2) · Structured schema · Scope-validated · AI recommendation — maintainers and repository policy retain authority

@Alajmah

Alajmah commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

CI record: one failed check and its re-run

The CI run of this pull request (45076346183) failed on its first attempt in release-tooling-validation. The second attempt passed. The commit is the same, 537599f.

What failed. The step Smoke-test app (fail-closed) ended with PG not ready. The whole step lasted five seconds, 22:16:31Z to 22:16:36Z.

Why. The step starts a PostgreSQL container and tests readiness twice in a row. The first test succeeded against the temporary server that the PostgreSQL image starts during its own initialization. The second test ran a moment later, while that temporary server was being replaced, and got no response. The log shows exactly that pair: accepting connections, then no response.

What it is not. It is not this change. The step is not touched by this pull request, and the same job passed on the same commit in the manual run 45075555290. The steps before it had passed in the failed run too, including the comparison of the dashboard image: 20 packages, 19 pinned and in the tree.

Where the same pattern is. publish-release-images has the same two readiness tests in Smoke-test app image (fail-closed). That job runs on a master push, so the race can fail a release publication there as well. Testing readiness over TCP would avoid it, because the temporary server listens on the Unix socket only. That is a change outside this pull request; I did not make it.

State now. 21 checks successful; publish-release-images is skipped on a pull request by design.

@Alajmah
Alajmah merged commit 4e45982 into master Nov 23, 2026
55 of 56 checks passed
@Alajmah

Alajmah commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Merged, deployed, and verified in production: operational closure (2026-11-23)

Merged under the maintainer's approval of 2026-11-23, after the protection of the 2026-11-21 archive was proven (PR #464, comment 7091788017) and after the head was re-confirmed: head 537599f, 21 checks successful, merge state clean, master unchanged at ad45e16, no deploy in progress.

Merge. Squash-merged at 04:42:26Z as 4e45982ebfae63473d722166acf6afccf1b5908b, 9 files, with the sign-off.

The publish path built the dashboard from the lockfile

CI run 45113452130, job publish-release-images, all steps successful on the first attempt (the PostgreSQL readiness race of #501 did not occur).

Step in the job Result
Build context the repository root; COPY package.json package-lock.json; COPY packages/web-dashboard; the three checks; npm ci --workspace=packages/web-dashboard --ignore-scripts, 664 packages in 41 s; npm run build
Comparison, before the push 20 packages listed; 19 pinned by the lockfile and in the workspace tree; @next/env 16.4.6 and next 16.4.6 pinned; one warning, semver@6.3.1 outside the workspace tree; result PASS
Push dashboard digest sha256:7e707f5a…, with the app sha256:71a15962… and the executor sha256:5e9bb0f9…
Smoke test /dashboard responded

The deployment

Deploy run 45114141099: success. Exact tested SHA checked out; manifest validated against run 45113452130; infrastructure healthy; the validator image already present at digest e2c10a61…, unchanged; executor gate, app gate, then the dashboard recreated and started.

Check in production Result
SHA /health through the tunnel: status ok, git_sha 4e45982ebfae63473d722166acf6afccf1b5908b, migrations current. The revision labels of the three release images and GITWIRE_COMMIT_SHA in the app carry the same value. The dashboard container runs the image by the digest that was pushed
Ten services 10 containers running, 9 report healthy, the tenth is the tunnel, which defines no health check
Release and rollback images 4e45982, ad45e16, 3847171, f56b86f keep 3 images each. Release record: current → 4e45982
Retention decision remove=3, kept=24, protected=13; removal 3 succeeded, 0 failed. The three images of a1b3665, the oldest outside the window, are gone. Nothing else was removed

The packages of the running container

The listing of scripts/compare-image-deps.mjs was run inside the running dashboard container, read-only, and its answer was compared with the lockfile of 4e45982 by the same tool: 20 packages, 19 pinned and in the workspace tree, the same one warning, result PASS, exit 0. No unreadable manifest, no directory that could not be examined.

Before this change the production container held three versions that were in no lockfile entry. It now holds none.

The protected pages, after login, in a real browser

One session was created by the login endpoint inside the app container, where the key already lives. The key was never read out of the container and never shown: the script that talks to the endpoint runs in the container and prints the session token only, into a local file, which the browser used and which was deleted afterwards. After the check the session was ended by the logout endpoint; production Redis holds no session key of this test (count 0).

Headless Chromium, 1366×900, the site through the tunnel:

Page HTTP Heading Table rows
/dashboard 200 Dashboard 77
/dashboard/repos 200 Repositories 20
/dashboard/issues 200 Issue triage 0
/dashboard/pull-requests 200 Pull requests 0
/dashboard/ci 200 Self-healing CI 0
/dashboard/activity 200 Activity 0
/dashboard/insights 200 Multi-repo insights 77
/dashboard/intelligence 200 Intelligence & compliance 0

No page was redirected to the login. Interaction: the search box of the repositories page filtered 20 rows to 1 on gitwire and returned to 20 when cleared.

No error of any kind: no console error, no page error, no response of 400 or above, and no React error (nothing matching React, hydration, Minified React error, or Warning:).

After logout, /dashboard/repos redirects to the login page, as it should.

Not covered by this check

  • One engine, Chromium, headless, one viewport. Not Firefox, not WebKit, not a phone.
  • The browsing was read-only: pages load, the search box filters. No button that changes anything was pressed.
  • Page speed was not measured.

What stays open

Automatic validation of .gitwire.yml on push is not an active capability; only its unproductive enqueue was removed (#496). The readiness race of #501 and the backup file modes of #502 are recorded. The semver@6.3.1 warning keeps its meaning: one lone manifest, pinned by the lockfile for another workspace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant