Software: npm releases
Overview › Data acquisition › Software
- Included: the crawl script, the lowest-version script, the link-extraction code, the frozen input (73,840 stable releases with their dependency ranges) and the output links (in cascade_link_extraction.zip).
- The link step (level A) reproduces the delivered links. The crawl (level C) needs network access and gives a different result at another time: packages publish new releases and unpublish old ones. The lowest-version step needs the npm package
semver. - Crawled in October 2026.
- 1 Crawling the registry
- 2 Lowest version of a range
- 3 Extracting the links
- 4 Package and parameters
- 5 Parameters of this domain
- 6 Limits
1. Crawling the registry
The registry gives one JSON document per package with all its versions. A breadth-first crawl starts from seed packages and adds the packages that the latest version depends on, until a cap is reached. It samples the neighbourhood of well-known packages; it is not a random sample of npm.
The sample is a breadth-first crawl of the npm registry (https://registry.npmjs.org/<package>). It starts from 50 well-known packages and follows the dependencies of the latest version of each package. The crawl stops at 2,500 packages (2,544 were reached because the last batch is completed). For each package the script keeps the repository URL, the latest version, and, for each version, the publish time and the declared ranges of dependencies, peerDependencies and optionalDependencies. It keeps the releases from 1 June 2024 and the last release before that date.
crawl.pydownload
import requests, json, time, re, sys
from concurrent.futures import ThreadPoolExecutor
from urllib.parse import quote
SEEDS=['express','react','react-dom','vue','@angular/core','next','webpack','vite','rollup','eslint','prettier','typescript','jest','mocha','@babel/core','lodash','axios','tailwindcss','postcss','sass','mongoose','socket.io','@nestjs/core','fastify','koa','chalk','commander','yargs','inquirer','cheerio','puppeteer','playwright','@storybook/react','@testing-library/react','styled-components','redux','@reduxjs/toolkit','rxjs','zod','dotenv','uuid','dayjs','date-fns','vitest','esbuild','nodemon','cypress','sequelize','typeorm','prisma']
CAP=2500;CUT='2024-06-01'
S=requests.Session()
def fetch(name):
for i in range(4):
try:
r=S.get('https://registry.npmjs.org/'+quote(name,safe='@'),timeout=90)
if r.status_code==200: return r.json()
if r.status_code==404: return None
except Exception: time.sleep(2+i)
return None
def compact(j):
t=j.get('time',{});latest=j.get('dist-tags',{}).get('latest')
vs=[]
for v,meta in j.get('versions',{}).items():
ts=t.get(v)
if not ts: continue
vs.append((ts,v,meta))
vs.sort()
out=[];lastold=None
for ts,v,meta in vs:
if ts<CUT: lastold=(ts,v,meta);continue
out.append((ts,v,meta))
if lastold: out.insert(0,lastold)
repo=j.get('repository');repo=(repo.get('url') if isinstance(repo,dict) else repo) or ''
rows=[]
for ts,v,meta in out:
deps={}
for k in ('dependencies','peerDependencies','optionalDependencies'):
d=meta.get(k) or {}
if isinstance(d,dict): deps.update({a:b for a,b in d.items() if isinstance(b,str)})
rows.append(dict(t=ts,v=v,d=deps,u=(meta.get('_npmUser') or {}).get('name','')))
ld=j['versions'].get(latest,{}) if latest else {}
ldeps={}
for k in ('dependencies','peerDependencies','optionalDependencies'):
d=ld.get(k) or {}
if isinstance(d,dict): ldeps.update(d)
return dict(name=j['name'],repo=repo,latest=latest,ldeps=list(ldeps.keys()),rel=rows)
data={};seen=set();queue=list(SEEDS)
t0=time.time()
while queue and len(data)<CAP:
batch=[]
while queue and len(batch)<64:
n=queue.pop(0)
if n in seen: continue
seen.add(n);batch.append(n)
with ThreadPoolExecutor(8) as ex: res=list(ex.map(fetch,batch))
for n,j in zip(batch,res):
if not j or 'versions' not in j: continue
c=compact(j);data[n]=c
for d in c['ldeps']:
if d not in seen: queue.append(d)
print(len(data),len(queue),round(time.time()-t0),flush=True)
json.dump(data,open('npm_sample.json','w'))
print('done',len(data),sum(len(c['rel']) for c in data.values()),'release rows')
| What | Address | Note |
|---|---|---|
| Package document | https://registry.npmjs.org/<package> not re-checked | GET; JSON with dist-tags.latest, versions (each with the ranges dependencies, peerDependencies, optionalDependencies and repository) and time (publish time per version) |
| Registry API description | https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md not re-checked | – |
| semver library | https://www.npmjs.com/package/semver not re-checked · https://github.com/npm/node-semver not re-checked | semver.minVersion(range, {loose: true}) |
| Licence of the data | not recorded for the pilot | – |
2. The lowest version of a range
A dependency is declared as a range, for example ^4.17.0 or >=2 <4. The lowest version that the range allows is its floor. When a release raises the floor to the version of an upstream release, that upstream release has been adopted.
A link needs the lowest version that a declared range allows. We compute it with the semver library of npm (minVersion, loose mode). First collect the distinct ranges:
import json
D = json.load(open('npm_sample.json'))
ranges = sorted({rg for c in D.values() for r in c['rel'] for rg in r['d'].values()})
json.dump(ranges, open('ranges.json', 'w'))
npm install semver node minv.js # reads ranges.json, writes minv.json: range -> lowest version, or null
minv.jsdownload
const s=require('semver');const r=JSON.parse(require('fs').readFileSync('ranges.json'));const o={};for(const x of r){try{const m=s.minVersion(x,{loose:true});o[x]=m?m.version:null}catch(e){o[x]=null}}require('fs').writeFileSync('minv.json',JSON.stringify(o));3. Extracting the links
Rule: the dependent release changes the declared range of an upstream package so that the floor rises and equals exactly the version of an upstream release, and that upstream release was published 0 to 30 days before the dependent one. Links inside one repository (same repository field) are the kind hand_off; links between repositories are dependency.
A link goes from an upstream release to a dependent release when the dependent release changes the range of the upstream package so that the lowest version rises and equals exactly the version of the upstream release, and that release was published 0 to 30 days earlier. Links inside one repository have the kind hand_off, the others dependency. The input holds the stable releases, the dependency ranges on packages of the sample, the repository of each package and the table of lowest versions. There are 49,561 links: 41,918 hand_off and 7,643 dependency.
software_build_links.pydownload
#!/usr/bin/env python3
"""Link extraction for the npm release cascades.
A link goes from an upstream release U to a dependent release W when W changes the declared dependency range of the
upstream package so that the lowest version allowed by the range rises and equals exactly the version of U, and U was
published 0 to 30 days before W. Inside one repository the link has kind 'hand_off', otherwise 'dependency'.
The lowest version of a range is computed with the semver library of npm (minVersion, loose mode); the table range -> lowest
version is part of the input ("range_lowest_version").
Usage: python build_links.py [--input input_events.json] [--output output_links.json]
Only the Python standard library is needed.
"""
import argparse, collections, datetime as dt, json, re
def secs(t): return int(dt.datetime.fromisoformat(t.replace('Z', '+00:00')).timestamp())
def stamp(t): return dt.datetime.fromisoformat(t.replace('Z', '+00:00')).timestamp()
def norm_repo(u):
u = u.lower().strip(); u = re.sub(r'^git\+', '', u); u = re.sub(r'\.git$', '', u)
u = re.sub(r'^(ssh://)?git@github\.com[:/]', 'https://github.com/', u)
return u.replace('git://', 'https://').replace('http://', 'https://').replace('www.', '')
def build_links(inp):
lo, hi = inp['window']['start'], inp['window']['end'] # compared as strings with the ISO time stamps
max_gap = inp['parameters']['max_gap_days']
lowest = inp['range_lowest_version']
pkgs = inp['packages']
by_pkg = collections.defaultdict(list)
for e in inp['events']:
by_pkg[e['package']].append(e)
for p in by_pkg:
by_pkg[p].sort(key=lambda r: r['time']) # releases of a package in time order
in_window = {} # (package, version) -> release inside the window
for p, rel in by_pkg.items():
for r in rel:
if lo <= r['time'] < hi:
in_window[(p, r['version'])] = r
found = {}
for p, rel in by_pkg.items():
repo_p = norm_repo(pkgs[p]['repo'])
for i, w in enumerate(rel):
if not (lo <= w['time'] < hi) or i == 0: # only releases inside the window that have a predecessor
continue
prev = rel[i - 1]
for a, rng in w['deps'].items():
if a not in pkgs or a == p: # dependencies on packages of the sample only
continue
before = prev['deps'].get(a)
if before is None or before == rng: # the range must have changed
continue
m = lowest.get(rng)
if not m or lowest.get(before) == m: # and its lowest version must have moved
continue
u = in_window.get((a, m)) # upstream release with exactly that version
if u is None:
continue
days = (stamp(w['time']) - stamp(u['time'])) / 86400
if days <= 0 or days > max_gap:
continue
repo_a = norm_repo(pkgs[a]['repo'])
same = bool(repo_a) and repo_a == repo_p
found[(u['id'], w['id'])] = (u, w, same, a, rng, before, m, days)
links = []
for (uid, wid), (u, w, same, a, rng, before, m, days) in found.items():
gs = secs(w['time']) - secs(u['time'])
l = {'id': f'{uid}>{wid}', 'from': uid, 'to': wid, 'kind': 'hand_off' if same else 'dependency', 'propagates': True,
'direction': 'evidence' if gs == 0 else 'time', 'gap_seconds': gs,
'evidence': {'existence': {'level': 'rule', 'basis': 'manifest_diff', 'rule_id': 'R_MIN_VERSION_RAISED',
'text': f"{w['package']} {w['version']} raises its range for {a} from {before} to {rng}, whose lowest version is {m}; {a} {m} was published {days:.2f} days earlier",
'source_ref': {'source': 'npm_registry', 'id': wid}}},
'attrs': {'dependency': a, 'range_before': before, 'range_after': rng, 'lowest_version': m}}
if same:
l['flags'] = ['same_owner']
links.append(l)
links.sort(key=lambda l: (l['from'], l['to'], l['kind'], l.get('relation', ''))) # order of the package
return links
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument('--input', default='input_events.json'); ap.add_argument('--output', default='output_links.json')
a = ap.parse_args()
inp = json.load(open(a.input, encoding='utf8'))
links = build_links(inp)
out = {'spec_version': '0.1', 'package_id': inp['package_id'], 'link_count': len(links), 'propagating_links': len(links),
'omitted_counts': {}, 'links': links, 'omitted': []}
json.dump(out, open(a.output, 'w', encoding='utf8'), ensure_ascii=False, separators=(',', ':'))
print(f'{len(links)} links ({sum(1 for l in links if l["kind"] == "hand_off")} hand_off) -> {a.output}')
if __name__ == '__main__':
main()
4. Package and parameters
The package builder is software_pkg.py. Releases are dated by the registry publish time, to the second (UTC); the manifest notes that two releases in one second would be simultaneous. The manifest gives the default window of both link kinds as 7 days and the maximum gap as 30 days.
package_builders/software_pkg.pydownload
import sys,json,re,collections,datetime as dt;sys.path.insert(0,'/home/claude/pkg')
from pkgkit import *
src=open('/home/claude/sw/crawl.py').read();SEEDS=eval(re.search(r'SEEDS=(\[.*?\])\n',src,re.S).group(1))
D=json.load(open('/home/claude/sw/npm_sample.json'));MIN=json.load(open('/home/claude/sw/minv.json'))
def norm(u):
u=u.lower().strip();u=re.sub(r'^git\+','',u);u=re.sub(r'\.git$','',u);u=re.sub(r'^(ssh://)?git@github\.com[:/]','https://github.com/',u);return u.replace('git://','https://').replace('http://','https://').replace('www.','')
LO,HI='2025-01-01','2026-10-01'
def secs(t): return int(dt.datetime.fromisoformat(t.replace('Z','+00:00')).timestamp())
def iso(s): return dt.datetime.fromtimestamp(s,dt.timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
ev=[];idx={}
for p,c in D.items():
rel=sorted([r for r in c['rel'] if '-' not in r['v']],key=lambda r:r['t']);c['_rel']=rel
for r in rel:
if LO<=r['t']<HI: idx[(p,r['v'])]=len(ev);ev.append((p,r['v'],r['t']))
TS=[secs(e[2]) for e in ev];TF=[dt.datetime.fromisoformat(e[2].replace('Z','+00:00')).timestamp() for e in ev]
links=[]
for p,c in D.items():
rel=c['_rel']
for i,w in enumerate(rel):
if not (LO<=w['t']<HI) or i==0: continue
prev=rel[i-1]
for a,rg in w['d'].items():
if a not in D or a==p: continue
pr=prev['d'].get(a)
if pr is None or pr==rg: continue
m=MIN.get(rg)
if not m or MIN.get(pr)==m: continue
u=idx.get((a,m))
if u is None: continue
iw=idx[(p,w['v'])];g=(TF[iw]-TF[u])/86400
if g<=0 or g>30: continue
same=bool(norm(D[a]['repo'])) and norm(D[a]['repo'])==norm(c['repo'])
links.append((u,iw,same,dict(pkg=a,rng=rg,prev=pr,min=m)))
links=list({(l[0],l[1]):l for l in links}.values());print('events',len(ev),'links',len(links),'packages',len(D))
sid='npm_registry'
ents=[dict(id=f'pkg:{p}',type='package',label=p,attrs=dict(latest_version=c['latest']) if c['latest'] else {},provenance=dict(source_ids=[dict(source=sid,id=p)],derived=False)) for p,c in D.items()]
rels=[]
for p,c in D.items():
for a in c['ldeps']:
if a in D and a!=p: rels.append(dict(id=f'dep:{p}>{a}',source=f'pkg:{p}',target=f'pkg:{a}',type='depends_on',directed=True,attrs={},provenance=dict(source_ids=[dict(source=sid,id=p)],derived=False)))
events=[dict(id=f'{p}@{v}',kind='release',title=f'{p} {v}',time=dict(start=iso(TS[i]),precision='second',basis='recorded'),refs=[dict(entity=f'pkg:{p}',role='anchor')],attrs=dict(version=v),
provenance=dict(source_ids=[dict(source=sid,id=f'{p}@{v}')],extraction=dict(method='stable release (no pre-release suffix) published inside the window',rule_ids=['R_STABLE_RELEASE']),confidence=None),link_coverage='partial') for i,(p,v,t) in enumerate(ev)]
L=[]
for u,iw,same,a in links:
f=f'{ev[u][0]}@{ev[u][1]}';t=f'{ev[iw][0]}@{ev[iw][1]}';gs=TS[iw]-TS[u];days=(TF[iw]-TF[u])/86400
L.append({'id':f'{f}>{t}','from':f,'to':t,'kind':'hand_off' if same else 'dependency','propagates':True,'direction':'evidence' if gs==0 else 'time','gap_seconds':gs,
'evidence':{'existence':{'level':'rule','basis':'manifest_diff','rule_id':'R_MIN_VERSION_RAISED','text':f"{ev[iw][0]} {ev[iw][1]} raises its range for {a['pkg']} from {a['prev']} to {a['rng']}, whose lowest version is {a['min']}; {a['pkg']} {a['min']} was published {days:.2f} days earlier",'source_ref':dict(source=sid,id=f'{ev[iw][0]}@{ev[iw][1]}')}},
'attrs':dict(dependency=a['pkg'],range_before=a['prev'],range_after=a['rng'],lowest_version=a['min']),**({'flags':['same_owner']} if same else {})})
M=dict(spec_version='0.1',package_id='software-npm-0.1',created_at=CREATED,
adapter=dict(name='npm_release_adapter',version='0.1',domain='software',code_ref=None,produced_by='Claude, from the npm release pilot scripts (crawl.py, d_sw.py)'),
domain=dict(event_definition='A stable release (a version without a pre-release suffix) of an npm package, published between 2025-01-01 and 2026-09-30, dated by its publish time',entity_description='npm packages; package relations follow the dependencies declared by the latest version'),
sources=[dict(id=sid,name='npm registry package documents (versions, publish times, declared dependencies, repository)',url='https://registry.npmjs.org',accessed_at='2026-10',version='crawl of October 2026',license='npm registry metadata; terms not recorded in the pilot, to be filled in before the package is shared',notes='The release rows keep publisher user names out of this package')],
observation_window=dict(start='2025-01-01',end='2026-09-30',collected_at='2026-10',right_censored=True),
coverage=dict(procedure='snowball',description=f'Breadth-first crawl from {len(SEEDS)} well-known packages along the dependencies of the latest version, capped at 2500 packages (2544 packages reached); all stable releases of these packages in the window are events',seeds=SEEDS,depth_limit=None,selection_rules=['R_STABLE_RELEASE'],
known_gaps=['Only packages reached by the capped crawl; dependents outside the sample are not seen, so links of heavily used packages are undercounted','Dependencies are the declared ranges of each release; a bump that happens through a lock file is not seen','Pre-release versions are excluded','The last release before each window start is not an event','The dependency relation among packages uses only the latest version of each package']),
event_kinds=[dict(id='release',label='Release',description='A stable release of a package')],
entity_types=[dict(id='package',label='Package',description='An npm package')],entity_relation_types=[],roles=[],
link_kinds=[dict(id='hand_off',core_kind='hand_off',description='A release raises the minimum version of a dependency to exactly an upstream release of the same repository (release train)',propagates_default=True,default_window_seconds=604800,max_gap_seconds=2592000,direction_rule='From the upstream release to the dependent release in time',levels=['rule']),
dict(id='dependency',core_kind='dependency',description='A release raises the minimum version of a declared dependency to exactly an upstream release of another repository',propagates_default=True,default_window_seconds=604800,max_gap_seconds=2592000,direction_rule='From the upstream release to the dependent release in time',levels=['rule'])],
evidence_bases=[dict(id='manifest_diff',label='Manifest difference',description='Difference between the declared dependency ranges of consecutive stable releases')],
rules=[dict(id='R_STABLE_RELEASE',description='Version without a pre-release suffix published inside the window',parameters=dict(window_start=LO,window_end='2026-10-01'),applies_to='event'),
dict(id='R_MIN_VERSION_RAISED',description='A release changes the declared range of a package in the sample so that its lowest version rises and equals an upstream stable release published 0 to 30 days before',parameters=dict(max_gap_days=30),applies_to='link')],
parameters=dict(max_gap_days=dict(value=30,description='Longest gap between the upstream release and the dependent release'),default_window_days=dict(value=7,description='Default window of the pilot'),same_repository_flag=dict(value='repository url equal after normalisation',description='Links inside one repository use kind hand_off and the flag same_owner')),
limitations=['The sample is a capped snowball and not the whole registry','Only links where the new minimum version equals an upstream release in the sample are emitted','The link states that a release adopted an upstream release, not that it was caused by it','Publish times are the registry time stamps, second precision; two releases in one second would be simultaneous','Mass releases inside one repository create many links of the same pattern','Licence of the registry metadata is not recorded'],
notes='Hand check: for any link, open the dependent release manifest and compare the range of the named dependency with the previous release.')
od='/home/claude/pkg/out/software-npm'
st=write_package(od,M,events,ents,rels,L,[],{},gz=('events.jsonl','links.jsonl','entity_relations.jsonl'));print(json.dumps(st)[:500]);print(finalize(od))
node minv.js # ranges.json -> minv.json python software_build_links.py --input input_events.json --output output_links.json # level A python crawl.py # level C: live registry
5. Parameters of this domain
| Parameter | Value | Where | Effect |
|---|---|---|---|
| Seeds | 50 well-known packages | crawl.py | Starting point of the crawl |
| Cap | 2,500 packages (2,544 reached) | crawl.py | The last batch is completed |
| Release period in the crawl | from 1 June 2024, and the last release before that date | crawl.py | 73,840 stable releases in the input of the link step; pre-releases are dropped |
| Release period of the package | 1 Jan 2025 to 30 Sep 2026, stable releases | package builder | 55,102 events; time precision second |
| Dependency fields | dependencies, peerDependencies, optionalDependencies | crawl.py | Only packages of the sample count |
| Floor | minVersion, loose mode | minv.js | A range without a floor gives no link |
| Link rule | floor rises and equals an upstream release | link script | 49,561 links: 41,918 hand_off, 7,643 dependency |
| Lag range | 0 to 30 days | link script / manifest max gap | Window of the rule |
| Default window | 7 days | manifest | The user can change it in the tool; the sweep is on the parameter page |
6. Limits
- The sample is a capped crawl. Dependents outside the sample are not seen, so the links of heavily used packages are undercounted.
- A bump through a lock file is not seen. Only declared ranges count.
- Only a new lowest version that equals an upstream release of the sample and the window gives a link.
- A link states that a release adopted an upstream release, not that it was caused by it.
- Releases of one repository that appear together create many links of the same pattern. The same-repository links are marked.

