Skip to content

Take the sidecar's git SHA from git, not a stale lockfile - #3

Merged
stuffbucket merged 1 commit into
mainfrom
build/sidecar-provenance-from-git
Aug 18, 2026
Merged

stuffbucket merged 1 commit into
mainfrom
build/sidecar-provenance-from-git

Conversation

@stuffbucket

Copy link
Copy Markdown
Owner

First of a series splitting up the build/dependency cleanup. Independent of the rest.

What was wrong

packages/maximal/client/scripts/build-core.ts read package-lock.json to find the git URL maximal-core was once installed from, and baked that URL's SHA into the compiled sidecar as __MAXIMAL_GIT_SHA__.

In a workspace that is wrong twice over:

  • pnpm installs from the root lockfile; packages/maximal/client/package-lock.json describes an install that never happens.
  • The SHA it carried, c44284be, named a commit that is not what gets compiled. coreRoot resolves to node_modules/@stuffbucket/maximal-core, a workspace symlink to packages/maximal-core — so the code comes from this checkout, not from that git ref.

What changed

git rev-parse HEAD — the commit that actually produced the binary. Falls back to an empty string where git is unavailable, exactly as the old parse did.

Deleting the lockfile is then safe; a grep confirms nothing else reads it.

Why it is worth doing now

Three independent reasons converge on the same file:

  1. SOURCES.md rule: "Do not add per-package lockfiles. The root lockfile is the only one that applies; a second implies a pinning that is not in effect."
  2. The stale __MAXIMAL_GIT_SHA__ — this is the "silent fall-back to the stale git pin" the deleted macOS job used to catch.
  3. 11 of the repo's 31 dependabot alerts are keyed to that manifest (extract-zip, tar, tmp). They describe an install that never happens, and go away with the file.

Verification

sidecar contains HEAD (eea6ebf…)        1 occurrence
sidecar contains stale pin (c44284be…)  0 occurrences
sidecar --version                       0.6.3
pnpm install --frozen-lockfile          clean, lockfile unchanged
turbo run build typecheck --force       8/8
oxlint scripts/build-core.ts            clean

Not in this PR

  • packages/maximal/site/bun.lock — same class, 3 more phantom alerts.
  • The 17 real alerts on pnpm-lock.yaml. All transitive build tooling; [email protected] has no patch at all. Worth doing after sidecar-version verification is restored, since nothing currently notices if packaging breaks.

build-core.ts parsed packages/maximal/client/package-lock.json for the git URL
maximal-core was once installed from, and baked the SHA in that URL into the
compiled sidecar as __MAXIMAL_GIT_SHA__. That is wrong twice over in a
workspace: pnpm does not install from that lockfile, and the SHA it carried
(c44284be) named a commit that is not what gets compiled -- coreRoot is a
symlink to packages/maximal-core, so the code comes from this checkout.

git rev-parse HEAD is the commit that actually produced the binary, and falls
back to an empty string where git is unavailable, as the old parse did.

Deleting the lockfile is then safe -- nothing else reads it -- and it removes a
SOURCES.md violation plus 11 dependabot alerts raised against an install that
never happens (extract-zip, tar, tmp, keyed to that manifest).

Verified: the sidecar carries HEAD once and the stale pin zero times, still
reports 0.6.3, and build+typecheck pass 8/8 after a --frozen-lockfile install.
@stuffbucket
stuffbucket merged commit 035fdf4 into main Aug 18, 2026
5 checks passed
@stuffbucket
stuffbucket deleted the build/sidecar-provenance-from-git branch August 18, 2026 08:37
stuffbucket added a commit that referenced this pull request Aug 18, 2026
**Stacked on #3** — base is `build/sidecar-provenance-from-git`, not
`main`. The SHA assertion only means something once `build-core.ts`
bakes `git rev-parse HEAD`, which is #3. Merge #3 first and this
retargets to main automatically.

## What this restores

The macOS packaging job removed in `f1e1d04` asserted that the packaged
app's sidecar reported the *workspace* maximal-core version — the one
check that would catch the client silently falling back to the stale git
pin it ships with upstream. `ci.yml` has carried a comment since then
saying *"That check has no replacement yet."* This is the replacement.

## Why it does not need a Mac

The old check ran `maximal-core --version` inside the `.app`. The
sidecar is compiled `--target=bun-darwin-arm64` and cannot execute on
`ubuntu-latest` — but it can be **read**:

1. `packages/maximal/client/node_modules/@stuffbucket/maximal-core`
resolves to `packages/maximal-core` → the dependency is the workspace
copy, not a git tarball.
2. The compiled sidecar embeds `HEAD` → it was built from that copy in
this run, not restored stale from a cache.

Together those are the property the old job proved, minus the packaging
step.

## Both negative cases exercised

A check that cannot fail is not a check, so I broke it deliberately:

```
HEAD moved one commit on   -> sha assertion FAILS   (binary predates HEAD)
sidecar removed            -> existence assertion FAILS
normal build               -> both PASS
```

## What is still not covered

This proves the sidecar's provenance, not that `electron-forge` produces
a working `.app`. That genuinely needs a Mac and belongs with
`stuffbucket/macos-builder` at release time, per AGENTS.md.
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