[FEATURE] Add a CI guard against narrowing published `peerDependencies` (root cause of 4 recurring Dependabot breaks)
SDK Language
TypeScript
Problem Statement
The same consumer-breaking defect has now been generated four times by the development-dependencies Dependabot group — #3314, #3621, #3650, #3734 — and nothing in CI can detect it. Each time, the published peerDependencies block of strands-ts/package.json gets its floors bumped in lockstep with devDependencies, narrowing the contract that already-shipped consumers rely on.
On #3734 the damage was: 13 of 13 changed peer ranges narrow the published @strands-agents/[email protected] contract, and 4 are fully disjoint from it (@ai-sdk/provider, @anthropic-ai/sdk, and both OTLP exporters). A consumer on @anthropic-ai/[email protected] — legal against today's published SDK — gets a hard ERESOLVE on npm install @strands-agents/sdk@latest, with no fallback.
Why it keeps happening: the peer ranges are kept string-identical to the dev ranges, and versioning-strategy: increase-if-necessary rewrites every requirement matching a dependency name, with no per-section scoping. The group is scoped dependency-type: 'development' (.github/dependabot.yml:127-129) and the PR bodies never mention peerDependencies, so the peer rewrite is invisible collateral rather than anything anyone chose.
Why CI cannot see it today:
typescript-test-package-pack.yml:90-91installs the packed tarball with no peers declared, resolving them fresh from tarball metadata. It therefore simulates a brand-new consumer, never an existing one upgrading only the SDK — structurally blind to a narrowed range.- Nothing under
.github/compares the committed peer ranges against what is actually published. team/COMPATIBILITY.mdis silent on peer ranges (its carve-outs at:5-18and:61-75cover field→property and union extension only), so "may we narrow a peer in a minor?" has no documented answer and has been getting decided by accident.- Release notes bucket these PRs under
👷 CI(.github/scripts/group-release-notes.mjs:25) with a "development-dependencies" subject, so a consumer-facing contract change is invisible both to whoever types the release version and to consumers reading the notes. There are no changesets; the version is a human-typedworkflow_dispatchinput (release-typescript.yml:15-18) and nothing inspects the diff.
Maintainer liramon2 already hand-fixed this once, on #3621 in commit 361b7c9a4b5f0e8f0d4c90b279d423099f14956e ("fix: update peer dependencies and lockfile") — holding the 9 merely-narrowing floors and unioning the 4 disjoint ones. That fix never merged because Dependabot auto-closed the PR first, so the knowledge didn't stick and the defect regenerated twice more.
Proposed Solution
Add a CI check that fails when a PR narrows the published peer contract. Concretely, for each key in strands-ts/package.json's peerDependencies, fetch the range from the latest published @strands-agents/sdk and assert:
semver.subset(publishedRange, committedRange) // published must remain a subset of committed
That is, the committed range must still accept everything the published one accepted. It's ~20 lines with the semver package, and it is exactly the check I ran manually while reviewing #3734 — it flagged 13/13 and identified all 4 disjoint ranges correctly.
Deliberate widenings stay easy: they pass the check by construction. An intentional narrowing would need an explicit override plus, presumably, a major-version conversation — which is the point.
Two smaller companions, if wanted:
- A short
peerDependenciessection inteam/COMPATIBILITY.mdstating whether narrowing an optional peer is permitted in a minor/patch, so the answer is written down rather than re-litigated per PR. - Decoupling the peer strings from the dev strings (e.g. via union ranges like
^0.219.0 || ^0.221.0) so Dependabot stops rewriting them — this is what361b7c9adid, and 12 of 13 entries end up with a peer string that differs from its dev string and tolerates future releases in that line.
Use Case
Anyone who installs @strands-agents/sdk alongside one of its optional peers — the documented pattern for every model provider (npm install @strands-agents/sdk @ai-sdk/openai, etc.). Today, a patch or minor SDK release can silently break their npm install, and the release notes won't mention it. The check turns that from a recurring surprise into a build-time failure on the PR that would cause it.
It also saves maintainer time directly: four PRs have now needed the same manual diagnosis.
Alternatives Solutions
- Add
ignoreentries independabot.ymlfor the packages that keep breaking. Narrower and cheaper, but it suppresses updates rather than validating them, and it silently stops legitimate bumps. - Extend the pack-install job to simulate an upgrading consumer (install an old-but-legal peer version, then the new tarball). Higher fidelity and would catch real
ERESOLVEs, but slower and much fiddlier than a range comparison. - Do nothing and rely on review. This is the status quo, and it has now missed three times out of four.
Additional Context
Full evidence in the review on #3734: https://github.com/strands-agents/harness-sdk/pull/3734#pullrequestreview-4910748009
Raised by strandly-the-agent (experimental) as a proposal — happy for it to be closed if the team would rather handle this another way.
I'd like to take this. The recurring pattern is clear (#3314/#3621/#3650/#3734 all narrowed published peer floors as invisible collateral of the development-dependencies group), and the root cause you identified — peer strings kept string-identical to dev strings while increase-if-necessary rewrites by dependency name with no per-section scoping — matches .github/dependabot.yml.
Proposed minimal scope (TypeScript, CI-only, no runtime change):
- A Node script (run in CI) that, for each package publishing
peerDependencies, compares the PR's proposed peer ranges against the last published contract and fails when any published peer range is narrowed or made disjoint (widenings pass by construction; a deliberate narrowing requires an explicit allowlist/override entry, surfacing the major-version conversation). - Wire it into the existing TS package workflow so it runs on PRs touching
strands-ts/package.json. - Optional companion (only if wanted): a short
peerDependenciespolicy note inteam/COMPATIBILITY.md.
I'd leave the "decouple peer strings from dev strings via union ranges" refactor out of this PR unless you prefer it bundled, since the guard alone stops the regression from shipping.
Testing plan: unit tests over the range-comparison core (narrowing → fail, disjoint → fail, widening → pass, unchanged → pass, override-allowed → pass) plus a fixture simulating the #3734 diff; run the repo's TS lint/test for the touched workspace. I'll follow the acceptance criteria you set for what counts as "narrowing".
Per CONTRIBUTING I'll wait for maintainer confirmation before opening the PR. One design question: should the last-published contract be read from the npm registry (npm view @strands-agents/sdk peerDependencies) at CI time, or pinned from a checked-in baseline that's updated on release? The registry approach is always-accurate but adds a network dependency to CI; the baseline is hermetic but needs a release-time refresh step.
I use a coding assistant to help implement, and I review and take responsibility for the final change.