# vuln-notif graph viewer
Static, backend-free viewer for the atproto records `vuln-notif` uploads. It
renders a force-directed graph of records and the links between them, caches the
records in IndexedDB, and stays live through the Bluesky jetstream.
## Build
From the repository root:
```sh
python3 -m py_compile spa/build.py
python3 spa/build.py --db .state/prod-week.db
jq '.counts' spa/dist/graph.json
```
Deploy the built site to wisp.place (credentials from the environment):
```sh
export ATP_HANDLE=...
export ATP_APP_PASSWORD=...
./spa/deploy.sh
```
`WISP_SITE` defaults to `cve`; `CACHE_DB` overrides the SQLite source. The
script rebuilds `dist/`, copies the vendored dependencies from `spa/vendor/`,
and runs `wispctl deploy --spa` so client-side routes fall back to
`index.html`. No credentials are stored in the script or repository.
Vendored runtime assets (no CDN at load time):
- D3 `7.9.0` (`spa/vendor/d3.min.js`)
- Pico CSS `2.1.1` (`spa/vendor/pico.min.css`)
- highlight.js `11.9.0` JS + GitHub theme CSS
The only network calls at runtime are the live PDS/PLC/jetstream services.
Options:
```sh
python3 spa/build.py --db .state/prod-week.db --out /tmp/graph.json
python3 spa/build.py --db .state/prod-week.db --repo-did did:plc:...
```
`--db` defaults to `$CACHE_DB`, then `.state/prod-week.db`. `--repo-did`
defaults to the first DID found in the cache. The script only reads SQLite and
uses the Python standard library.
`spa/dist/config.json` is written next to the viewer:
```json
{
"repo_did": "did:plc:...",
"generated_at": "2026-01-01T00:00:00Z"
}
```
`graph.json` is still written for backward compatibility and offline tooling.
The SPA does not read it: the browser builds its own mirror from the PDS.
## Serve
```sh
python3 -m http.server 8092 --directory spa/dist
```
Open . Any static file server works; no backend is
involved.
## Seeding
On first load the viewer opens the `vuln-notif-graph` IndexedDB database
(version 1) and checks the `records` store. When it is empty it resolves the
repo's PDS and seeds from the read-only XRPC endpoint:
```
GET /xrpc/com.atproto.repo.listRecords?repo=&collection=&limit=100
```
It follows `cursor` until exhausted or until roughly 1000 records are seen per
collection. Records, links, and meta values are written in batched IndexedDB
transactions, and `#status` shows `seeding collection n/7`. Later loads find
the cache non-empty and skip seeding entirely, rendering immediately.
PDS resolution uses the DID document at `https://plc.directory/` and picks
the service entry whose id ends with `#atproto_pds`. A `pds_url` field in
`config.json` overrides resolution. The PDS must allow browser CORS requests
for `com.atproto.repo.listRecords`; public Bluesky PDS hosts send
`access-control-allow-origin: *`. The viewer never writes to the PDS.
## Live updates
The viewer connects to
`wss://jetstream1.us-east.bsky.network/subscribe` as soon as the repo DID is
known, in parallel with seeding. The URL carries `wantedDids=` and one
`wantedCollections` parameter per indexed collection. The connection is opened
even while seeding is still running, and live events update both IndexedDB and
the graph.
Only `kind: "commit"` frames are handled. `create` and `update` put the record
and replace the links whose source is that record; `delete` removes the record
and those links. Identity, account, and other frame kinds are ignored. The
`time_us` of each commit is stored in meta as `jetstreamCursor` and passed back
as `cursor=` on reconnect. If the socket closes or errors, the viewer reconnects
automatically forever with exponential backoff and jitter (1s up to 30s); no
user action is needed. `#status` shows `connecting`, `live`, `reconnecting`,
or `error`, plus node/edge counts and the number of records mirrored in
IndexedDB.
## IndexedDB
Database `vuln-notif-graph`, version 1:
- `records`, keyed by `uri`: `{uri, collection, rkey, did, cid, record, indexedAt}`
- `edges`, keyed by `[source, target, label]`: `{source, target, label, collection}`
- `meta`, key/value: `repoDid`, `pdsUrl`, `jetstreamCursor`, `seededAt`,
`lastEventAt`
Clear and reseed from the browser console:
```js
await window.__vulnGraph.clear(); // empty IndexedDB and the graph
await window.__vulnGraph.reseed(); // clear, then seed again from the PDS
window.__vulnGraph.counts(); // {records, edges}
window.__vulnGraph.db; // IDBDatabase handle
```
Or delete the database in DevTools > Application > IndexedDB and reload.
Offline behavior: a previously seeded database still renders without a
network. Seeding fails gracefully and leaves cached records in place; the
jetstream keeps retrying in the background. Live-only updates are lost while
offline and return when the socket reconnects.
## Indexed collections
- `com.nahdig.cve.atprotoV1`
- `software.release.project`
- `software.release.channel`
- `software.release.version`
- `software.release.manifest`
- `software.release.status`
- `com.nahdig.release.projectMeta`
`com.nahdig.cve.nvdV2`, `com.nahdig.software`, and `com.nahdig.purl` are not
indexed or rendered.
Edges follow `src/links.rs`: `nvd.uri`, `software[].project.uri`,
`software[].channels[].uri`, `software[].versions[].uri`,
`software[].manifests[].uri`, `parent`, `renamedTo`, `project`,
`manifest.uri`, `version.uri`, `subject`, and project meta `project`.
StrongRefs (`{uri, cid}`) contribute their URI; duplicate links are dropped.
## Use
- Click a node to open its detail modal. The modal shows the collection and
rkey, the at-URI, the DID, and the record as highlighted YAML.
- `Open on pdsls.dev` opens the record in a new tab.
- `Show connected only` hides everything except the selected node, its 1-hop
neighbors, and the edges among them. Press it again (or close the modal, or
press Escape) to restore the graph.
- Legend checkboxes hide or show collections.
- Drag nodes, pan by dragging the background, and scroll to zoom.
## Checks
```sh
python3 -m py_compile spa/build.py
python3 spa/build.py --db .state/prod-week.db
jq '.counts' spa/dist/graph.json
```
Deterministic live-ingest smoke test from the browser console:
```js
await window.__vulnGraph.ingest({
kind: "commit",
commit: {
operation: "create",
collection: "software.release.project",
rkey: "test-live-node",
record: { "$type": "software.release.project", name: "test-live-node" },
cid: "bafytest",
},
});
```
There is no npm or Node build step.