Your tests pass, Dependabot says the upgrade is fine, you merge it, and a week
later customers are reading 12/05/2026 as 12 May instead of 5 December.
Nothing crashed. A library simply started behaving differently behind the
same function name.
shadow-upgrade records how your app actually calls its dependencies,
replays those exact calls against the new version, and shows you every call
that now behaves differently, with the line of your code that made it.
Real output from examples/quickcart. src/checkout.js
passes an explicit format, is unaffected, and is correctly not reported.
Why this exists
| The problem |
What happens today |
What shadow-upgrade does |
| Tests miss most library usage. Tests exercise only about 58% of direct and 20% of transitive dependency calls (arXiv:2109.11921). |
The upgrade PR is green because the changed path was never tested. |
Records the calls your app really makes, from tests, scripts or a staging server. |
| Static tools cannot see behaviour. |
API-diff tools catch renamed or removed functions, but not a function that returns something different. |
Runs the old and new versions on the same inputs and diffs the results. |
| Record-and-replay works, but only in research. GILESI reports 96% recall on seeded behavioural breaks. |
The published tools are Java research prototypes. |
Brings the idea to Node.js as a CLI and a GitHub Action you can run today. |
How it works
- Record.
shadow-upgrade record -- npm test preloads a tiny hook. When
your code requires or imports a tracked package, it gets back a transparent proxy that
records each call: arguments, result or error, and the file:line of your
code. Calls on returned objects are followed too, so chains like
dayjs(x).add(1, 'day').format() are recorded as a chain. Secrets
(passwords, tokens, API keys, card numbers) are redacted before anything is
written.
- Replay. For a target version, the old and new versions are installed
into isolated sandboxes (install scripts disabled). The recorded calls run in
separate Node processes with a minimal environment and the recorded time
zone.
- Compare. The old version is replayed twice. If those two runs
disagree, the call depends on time, randomness or hidden state, so it is
marked unstable and never reported as a change. Stable calls are diffed
structurally against the new version.
- Report. Changes are grouped by function and kind of change, sorted by
severity, and rendered as text, a Markdown pull request comment, or JSON.
When the new version ships a changelog, each change is shown with the lines
that mention it, so you see what the authors said next to what your code
will actually get. Only the installed files are read; nothing is fetched.
What happens to each recorded call
flowchart TD
A([recorded call]) --> B{replayable?}
B -- "no: promise argument or async callback" --> S[not replayed]
B -- yes --> C{old run A equals old run B?}
C -- no --> U[unstable: ignored]
C -- yes --> E{"recorded exactly, but the old run<br/>no longer matches the recording?"}
E -- yes --> U
E -- no --> R{did the new run reach the call?}
R -- "no: an earlier call in its chain changed" --> S
R -- yes --> D{diff old vs new}
D -- equal --> SAME[same]
D -- "new property, internal state" --> INFO[info]
D -- "same type, different value" --> CH[changed]
D -- "throws, type changed, property removed" --> BR[breaking]
classDef same fill:#dafbe1,stroke:#2ea043,color:#1f2328
classDef info fill:#ddf4ff,stroke:#0969da,color:#1f2328
classDef changed fill:#fff8c5,stroke:#bf8700,color:#1f2328
classDef breaking fill:#ffebe9,stroke:#cf222e,color:#1f2328
classDef ignored fill:#eaeef2,stroke:#8c959f,color:#1f2328
class SAME same
class INFO info
class CH changed
class BR breaking
class U,S ignored
This is why the tool stays quiet: it only reports differences it has shown to
be caused by the version change.
| Severity |
Meaning |
Example |
| ✖ breaking |
A call now throws, a value changed type, or a property disappeared |
parse('nope') returned an invalid Date, now it throws RangeError |
| ▲ changed |
Same type, different value |
format(d) returned "01/12/2026", now "12/01/2026" |
| ℹ info |
New properties, or a library object's internal state changed |
A returned object gained a new quarter field |
Quick start
Requires Node.js 20 or newer.
npm install --save-dev shadow-upgrade
Then, in your project:
# 1. Record while your tests (or dev server, or a script) run
npx shadow-upgrade record -- npm test
# 2. See what was recorded
npx shadow-upgrade stats
# 3. Check an upgrade before merging it
npx shadow-upgrade check dayjs --to 1.11.13
npx shadow-upgrade check dayjs --to latest --format markdown --output report.md
git clone https://github.com/Priyadharsan-85/shadow-upgrade.git
cd shadow-upgrade && npm install && npm run build && npm link
Try it in two minutes
examples/quickcart is a tiny shop that formats invoice,
delivery and receipt dates with a fixture library whose version 3 silently
switches its default date order.
npm install && npm run build
cd examples/quickcart && npm install
node ../../dist/cli/index.js record -- node index.js
node ../../dist/cli/index.js check easydate \
--from-dir ../../test/fixtures/easydate-2 --to-dir ../../test/fixtures/easydate-3
You get the report shown at the top of this page.
Recording tips
- Record more than your tests. Run the recorder against a staging server or a
replay of real traffic for a few minutes. Real usage is where tests are
thinnest.
- Sample long runs with
--sample 5% to record only a share of call
chains, and cap the size with --max-calls (default 20000 per package per
process). Identical calls from the same line are stored once anyway.
- Choose packages with
--packages dayjs,lodash (default: all
dependencies in package.json).
- Commit recordings (
.shadow/) if you want CI to use them, or let the
GitHub Action record on the base branch for you.
- Custom sensitive fields:
--redact-keys aadhaar,pan.
GitHub Action for Dependabot and Renovate PRs
sequenceDiagram
autonumber
participant Bot as Dependabot / Renovate
participant CI as GitHub Actions
participant SU as shadow-upgrade
Bot->>CI: opens PR: easydate 2.0.0 → 3.0.0
CI->>SU: run the action
alt record-command is set
SU->>SU: record on the base branch (e.g. npm test)
else
SU->>SU: use recordings committed in .shadow/
end
SU->>SU: compare package.json and the lockfile of base and head
loop every upgraded dependency with recordings
SU->>SU: replay old ×2 and new ×1, then compare
end
SU-->>CI: job summary, pass or fail by fail-on
SU-->>Bot: one PR comment, updated on every push
name: Shadow Upgrade
on: pull_request
permissions:
contents: read
pull-requests: write
jobs:
shadow-upgrade:
if: github.actor == 'dependabot[bot]' || github.actor == 'renovate[bot]'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-node@v7
with:
node-version: 22
- run: npm ci
- uses: Priyadharsan-85/shadow-upgrade@v0 # or pin an exact release, e.g. @v0.5.0
with:
record-command: npm test # records on the base branch; omit to use committed recordings
fail-on: breaking # or: changed, never
| Input |
Default |
Description |
record-command |
(empty) |
Command to record on the base revision. Empty: use committed recordings. |
fail-on |
breaking |
Fail the job on breaking, on any changed behaviour, or never. changed also fails when an upgrade could not be verified. |
recordings-dir |
.shadow |
Recordings folder, relative to the repository root. |
base-ref |
PR base branch |
Revision before the upgrade. |
comment |
true |
Post or update one pull request comment with the report. |
github-token |
github.token |
Token used to comment. |
Outputs: report (path of the Markdown report) and exit-code (0 ok, 1
fail-on reached, 2 error).
Shadow Upgrade: easydate 2.0.0 → 3.0.0
🟡 Behaviour changes found. Please review them before merging.
| Calls compared |
Same |
Changed |
Unstable |
Not replayed |
| 30 |
20 |
10 |
0 |
0 |
1. 🟡 easydate.format() · changed
The return value changed: "01/12/2026" → "12/01/2026".
- Calls affected: 5
- Where:
src/invoice.js:5 (5)
- The changelog says:
- 3.0.0:
`format()` now defaults to the US order, `MM/DD/YYYY`. Pass a pattern to keep the old order.
easydate.format(1796083200000)
2.0.0: "01/12/2026"
3.0.0: "12/01/2026"
at src/invoice.js:5
2. 🟡 easydate().add().format() · changed
The return value changed: "03/12/2026" → "12/03/2026".
- Calls affected: 5
- Where:
src/tracking.js:5 (5)
- The changelog says:
- 3.0.0:
`format()` now defaults to the US order, `MM/DD/YYYY`. Pass a pattern to keep the old order.
easydate(1796083200000).add(2).format()
2.0.0: "03/12/2026"
3.0.0: "12/03/2026"
at src/tracking.js:5
3.0.0
### Changed
- `format()` now defaults to the US order, `MM/DD/YYYY`. Pass a pattern to keep the old order.
- `DEFAULT_FORMAT` follows the new default.
- `parse()` throws a `RangeError` for text that is not a date, instead of returning an invalid date.
- `info()` returns `quarter` instead of `weekend`.
- `toUnix()` returns milliseconds.
- `sortBy()` sorts newest first.
2.5.0
### Added
- `nextBusinessDay()` skips weekends.
Replayed 30 recorded calls (recorded on 2.0.0) in 0.3s · Unstable calls give different results on every run and are not counted as changes
CLI reference
| Command |
What it does |
record -- <command> |
Runs the command with the recorder preloaded |
check <pkg> --to <version> |
Replays the recorded calls on the recorded and target versions |
review --base <revision> |
Checks every upgraded dependency between two revisions (CI) |
stats |
Lists recorded packages and call counts |
clean |
Deletes recordings |
Exit codes: 0 ok, 1 the --fail-on level was reached, 2 usage or runtime
error. Run shadow-upgrade <command> --help for every option.
When no recorded call can be compared on both versions (every call is unstable
or not replayed), the verdict is unknown: the upgrade was not verified.
This prints a warning (a workflow annotation in GitHub Actions) and fails only
with --fail-on changed.
Programmatic API
import { analyze, renderMarkdown } from 'shadow-upgrade';
const report = await analyze({ pkg: 'dayjs', dir: '.shadow', to: { kind: 'npm', spec: '1.11.13' } });
console.log(report.verdict); // 'safe' | 'review' | 'breaking' | 'unknown'
console.log(renderMarkdown(report));
Limitations (honest list)
import is recorded on Node 22.15+ / 23.5+, and replaying an ES module
package needs Node 22.12+; require works everywhere. Named constants
imported from an ES module (import { VERSION }) are not recorded, because
they are bound once at import time; reads through a default export
(lib.VERSION) are.
- Callbacks are replayed from what they answered, not re-run. If the new
version calls a callback with inputs that were never recorded, the call is
counted as "not replayed". Promise arguments, functions nested inside
other arguments (
{ transform: fn }) and async callbacks are not replayed.
- Replay is sandboxed with Node's permission model on Node 22.13+: replayed
code cannot write files, start processes or load native addons, and such calls
count as "not replayed". Network access is not restricted, so replay works
best for libraries that compute things: dates, formatting, parsing,
validation, math, URLs, serialization. Do not record packages that send email
or write to your database. See SECURITY.md.
- Only reads from the package's exports are recorded (
lib.VERSION,
lib.defaults.format). Reading a property of an object returned by a call
is seen only through the calls made on it.
review checks direct dependencies and optionalDependencies of the
root package only. Exact versions come from package-lock.json,
npm-shrinkwrap.json, pnpm-lock.yaml (v5 to v9) or yarn.lock (classic
and Berry). Other workspace packages are not checked yet.
Roadmap
- [x] Publish to npm
- [x] ESM support through Node's module hooks
- [ ] Recording from production-like traffic with sampling
- [ ] Optional local-LLM explanations that link a change to the changelog entry
- [ ] A study: replaying hundreds of real Dependabot upgrades from popular projects
Documentation
| Document |
For |
| How it works |
Contributors: one call followed from recording to report |
| Recording format |
Tool authors: the v1 .jsonl format |
| Contributing |
Setting up, testing, sending a pull request |
| Security |
Reporting a vulnerability, safe use |
| Changelog |
What changed in each release |
Development
npm install
npm test # builds, then runs every test with the built-in node:test runner