Skip to content

Concept Supply Chain Discipline

Reese Hodge edited this page Nov 1, 2026 · 10 revisions

Supply Chain Discipline

Supply-chain discipline is constitution principle P6. The project has no security team, so dependency hygiene is the substitute.

The constitutional hard rules are:

  • Pin exact SDK versions.
  • Do not use ^ or ~ on pre-1.0 dependencies.
  • Commit pnpm-lock.yaml.
  • Never delete pnpm-lock.yaml.
  • pnpm audit must be clean before merging dependency changes.
  • New dependencies must be reviewed before adding, including maintainer, publish date, and downloads.

The repo has several known traps that belong to this principle.

pnpm overrides live in one place

pnpm 11 reads dependency overrides only from overrides: in pnpm-workspace.yaml. A top-level overrides key in package.json is npm-only, and pnpm.overrides in package.json is silently ignored by pnpm 11.

If an override is needed, put it in pnpm-workspace.yaml and explain why. The current workspace file carries exactly one, zod, which is a deliberate single-version pin from research.md R1 rather than an advisory fix.

An advisory override is a nudge, not a fix

When pnpm audit goes red on a transitive dependency, an override is usually the only lever that moves it. pnpm will not re-resolve a dependency the lockfile already satisfies, and both pnpm update <pkg> -r and pnpm update --depth Infinity <pkg> no-op on a transitive package because name filters match direct dependencies only — the latter cheerfully reports "Already up to date" while leaving the vulnerable version in place.

But the override's job ends the moment the lockfile carries the patched version. Parent ranges are usually permissive — express-rate-limit asks for ip-address: ^10.2.0 — and pnpm resolves to the highest satisfying version, so the patch then sticks on its own.

So remove the nudge once it has landed. Seven overrides added this way (fast-uri, qs, hono, js-yaml, ip-address, body-parser, undici) were each verified inert: removing them changed no resolved version and left pnpm audit clean. Inert overrides are not free — each is a floor someone must revisit by hand, they hide whether the upstream graph actually recovered, and they can hold a dependency back once its range moves on, which is the opposite of what they were added for.

The standing protection is the Audit job, which runs pnpm audit on every pull request against the live advisory database. It catches a regression in review instead of pre-empting it with a pin nobody re-reads. Since 2026-10-31 Dependabot alerts cover the lockfile too, but at a different threshold — see below, and do not read a green Audit as an empty alert list.

Dependabot PRs do not prove security updates are on

Dependabot has two halves, configured in different places, and they fail independently:

Half Configured by Produces
Version updates .github/dependabot.yml, committed to the repo The weekly "Bump the dependencies group with N updates" PRs
Security updates A repo setting, which requires Dependabot alerts enabled first A PR targeting one advisory, as soon as a fix exists

This repo ran the first without the second until 2026-09-30. Nine Dependabot PRs had merged by then — every one a version update — so the protection looked healthy from the PR list while the half that reacts to advisories had never run once. Both were enabled on 2026-09-30 after the brace-expansion burst exposed the gap.

The reading to avoid: "we get Dependabot PRs, so we are covered." Check the settings, and check the alert list separately:

gh api /repos/quattro004/Agent004/vulnerability-alerts          # 204 = on, 404 = off
gh api /repos/quattro004/Agent004 --jq '.security_and_analysis.dependabot_security_updates'
gh api /repos/quattro004/Agent004/dependabot/alerts             # [] only when nothing is open

Both settings are free on a public repository, so there is no cost reason to leave them off.

The lockfile gap closed on its own, 2026-10-25 → 2026-10-31

GitHub's static parser dropped our pnpm 11 lockfile until it silently began parsing it: /dependency-graph/sbom returned 54 packages on 2026-10-25 (PR #72) and 743 by 2026-11-01, when alert #1 arrived with manifest_path: pnpm-lock.yaml. Re-verify a platform limitation rather than inheriting it, and probe with the SBOM — GraphQL dependencyGraphManifests still reports the lockfile with a bogus dependenciesCount: 0.

The two checks now disagree by design: alerts report every severity, while Audit runs pnpm audit --audit-level=moderate and exits 0 on a low, so a green build is not an empty alert list. Alert #1 is that case — deepmerge <= 4.3.1 (GHSA-gcqx-w48m-w2h4), low, first_patched_version: null, so nothing can bump it and merging PR #74 could not have. It reaches us only via packages/infra's jest devDependency though GitHub labels its scope runtime: establish reach with pnpm why <pkg> -r, never scope. With no patch, choose accept, dismiss, or drop the parent, and record which — for #1, accept: low and dev-only.

A lasting override needs a parent that still requires a vulnerable version or major. express-rate-limit@8.2.1 pinned ip-address: 10.0.1 exactly; 8.6.2 relaxed to ^10.2.0, and the override became redundant that day. Record the parent and its constraint in the comment, so the next reader can tell whether it still holds. The unpatched-major case below is exceptional: scope that override to the parent and prove its API compatibility.

Two major lines at once need selector overrides

pnpm 11.13 added the convergence override — "pkg@": <exact version> — which rewrites a dependency edge only when the version satisfies the range that edge declares, and warns when the pin goes stale. That makes it the better tool for the ordinary single-line case.

It cannot express the two-line case. The value must be one exact version per key, and a package name is a single key, so there is no way to say "2.1.7 for the 2.x consumers, 5.0.12 for the 5.x ones". brace-expansion needed exactly that on 2026-09-30: minimatch@9.0.9 declares ^2.0.2 and minimatch@10.2.6 declares ^5.0.8, and 2.1.7 does not satisfy ^5.0.8. A range value is rejected outright with ERR_PNPM_INVALID_CONVERGENCE_OVERRIDE.

Use one selector override per line instead, then remove both once they land:

overrides:
  'brace-expansion@^2.0.2': ^2.1.7
  'brace-expansion@^5.0.8': ^5.0.12

Both were verified inert the same day and removed before the PR was opened, so the change reaching main was lockfile-only.

A red audit with no code change is news, not a regression

pnpm audit queries the live advisory database, so an untouched commit can go from green to red because an advisory was published between two runs. Read it as new information about the world rather than something the last change broke, and check publication dates before hunting through a diff.

On 2026-09-30 the gap was 41 minutes. The docs/external-fact-verification PR run was green at 23:03 UTC; three brace-expansion advisories and one for fast-uri were published between 23:44 and 23:54; the identical tree failed on merge to main at 14:16 the next morning. No code and no lockfile entry changed in between.

Check when the fix was published, not just the advisory. All four patched releases — brace-expansion 2.1.7 and 5.0.12, fast-uri 3.1.8 — had been on npm since 2026-09-14/15, a fortnight before disclosure. That is the common shape: the maintainer ships the fix quietly and the advisory catches up later. It means the repo was carrying the vulnerable version the whole time, so the red build reports exposure you already had rather than exposure you just acquired — and a routine dependency refresh would have pre-empted it.

An unpatched advisory may sit on a package you never needed

On 2026-10-03 the Audit check went red on every open PR for braces ≤3.0.3 (GHSA-vfj7-8cjw-p6xm, high). The advisory has no patched release, so no override can nudge anything, and the question becomes whether we need the package at all.

The only path to it was @strands-agents/sdk → @tobilu/qmd → fast-glob → micromatch → braces.

  • @tobilu/qmd is an optional peer of the SDK. The SDK loads it only through a dynamic import() inside QmdSearchStrategy, which the agent never uses.
  • pnpm's autoInstallPeers installs only non-optional peers. Under the repo's pnpm 11.24.0, a fresh pnpm add @strands-agents/sdk@1.19.0 --lockfile-only in an empty directory resolves no qmd at all.

It was a stale lockfile entry, present since the 2026-09-06 Dependabot bump and kept alive because pnpm reuses whatever the lockfile already satisfies. It carried 129 packages, among them node-llama-cpp (local LLM inference), better-sqlite3 and five tree-sitter grammars. The seven allowBuilds denials added the next day existed only to stop their native builds.

These attempts did not work:

  • A - removal override ('@strands-agents/sdk>@tobilu/qmd': '-'). The pnpm docs say it removes a peer, but here it only rewrote the peer range to '*', and the package stayed.
  • pnpm update @strands-agents/sdk. It re-resolved and kept qmd.
  • Removing and re-adding the SDK. It dropped qmd, but it re-resolved the SDK's whole subtree, pulling in @modelcontextprotocol/sdk 1.32.0, which had been published the day before.
  • A plain pnpm install on a partly edited lockfile. It re-resolved broadly, the Node runtime included.

What did work:

  1. Strip the qmd peer from the SDK's snapshot.
  2. Prune every entry no longer reachable from an importer. The script asserted that the result is an exact subset: every surviving entry byte-identical and reachability unchanged.
  3. Prove the lockfile in a clean git worktree:
    • pnpm install --frozen-lockfile passes, which is what CI runs;
    • a plain install leaves the lockfile unchanged;
    • pnpm audit is clean;
    • pnpm run validate passes.

This is the one kind of hand-edit we accept: removing unreachable entries. Never hand-edit a version into the lockfile (see the minimumReleaseAge section below).

An unpatched advisory in a required major line

The remaining advisory behind #65 and #68 on 2026-10-11 was sprintf-js GHSA-hp3w-g68c-fv3c: all published versions through 1.1.3 are affected, with no patched release. Unlike the optional peer above, this is a required development dependency: Jest 30.5.2 → babel-plugin-istanbul → @istanbuljs/load-nyc-config@1.1.0 → js-yaml@3.15.2 → argparse@1.0.10 → sprintf-js@1.0.3.

The coverage loader's code only calls require('js-yaml').load(...), an API still present in js-yaml@4.3.2. The rule is to move only the parent edge, not every YAML consumer. PR #69 added '@istanbuljs/load-nyc-config>js-yaml': 4.3.2 to pnpm-workspace.yaml. A real .nycrc.yaml probe exercised the loader's load() path, the infra Jest coverage suite passed, and pnpm run validate passed. The override must stay until the Istanbul loader accepts the maintained major itself; unlike a patched-version nudge, removing this one would restore js-yaml@3 and the unpatched dependency.

Current state: PR #69 merged on 2026-10-11. main no longer resolves sprintf-js; its post-merge CI and Audit jobs both passed.

minimumReleaseAge fails before resolution

The repo records that pnpm 11.24 verifies minimumReleaseAge against the lockfile before resolution. When that trips, do not hand-edit the lockfile to force a version through. Restore the committed lockfile with:

git checkout -- pnpm-lock.yaml

Then reinstall under the pinned pnpm version. The point is to re-resolve from a known committed state, not patch around the policy.

GitHub Actions are pinned by immutable SHAs

.github/workflows/ci.yml pins every uses: action to a full 40-character commit SHA and keeps the human-readable version as a trailing comment such as # v7.0.1.

packages/infra/test/workflow-pins.test.ts enforces this by reading workflow files and rejecting any uses: reference that is not pinned to a 40-character commit SHA. Tags are mutable; full commit SHAs are not.

External facts go stale

Package names, versions, and service limits recorded in specs/ were true when written, but they are not permanent facts. Before acting on an external package, install command, deploy mechanism, or service limit from a spec, verify current reality and update the source artifact in the same change when it has drifted.

For day-to-day work, treat dependency changes as security-sensitive changes: review the package, keep the lockfile committed, run the audit path, and use Guide-Validation-Gate before calling the work done.

A pin freezes the version, not always the capability

Exact pins assume a version bump changes code we review. That fails for a pre-1.0 package whose own policy lets a patch add behavior that is on by default. The Strands harness is the worked example: its versioning page counts "adding new built-in tools or plugins" as non-breaking, and every built-in defaults on (Source-Strands-Harness-Docs). Its docs also advise @strands-agents/harness@~0.1.0, which this principle forbids.

An exact pin holds until the next bump, and our grouped Dependabot version updates make that bump routinely. For such a package, the review of a bump is a capability review, not a changelog skim. The durable defence is configuration that does not depend on the version — for the harness, explicit builtinTools and builtinPlugins lists.

See also: Gotchas, Source-Constitution.

Clone this wiki locally