Skip to content

Live monitor (v0.5.0), always-on kit (v0.6.0), risk intelligence (v0.7.0), hardening audits and release gate (v0.8.0, v0.8.1) - #2

Open
Apostal322 wants to merge 67 commits into
mainfrom
claude/chainwatch-ml-system-vxq2wa
Open

Apostal322 wants to merge 67 commits into
mainfrom
claude/chainwatch-ml-system-vxq2wa

Conversation

@Apostal322

@Apostal322 Apostal322 commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

This PR contains seven pieces of work:

  1. v0.5.0: an opt-in live Bitcoin mempool monitor on mempool.space's public API.
  2. v0.6.0: a $0 always-on collector kit for a small VM (Oracle Always Free target).
  3. v0.7.0: risk intelligence for the live monitor, as separate layers that are never blended into one score: A. OFAC screening; A'. observed-graph relations; B. anomalies; C. a supervised gate that abstains.
  4. v0.8.0: an independent hardening audit (docs/AUDIT.md, rows V1–V33, D1–D6, M1–M4) and release blockers B1–B6 (500 headers, bounded fetch retries, hash-locked CI, Dependabot + dependency audit, publish gate on CI success for the exact SHA, faster stats).
  5. v0.8.1: a second independent audit of v0.8.0, 7 parallel reviews, rows W1–W24 in docs/AUDIT.md.
  6. v0.8.1 second review of those fixes: row W25.
  7. Paged risk lists (row X1, a26b60d): the last open P2. Server-side pagination and filtering for the findings list and the investigation queue. Plus 4f091cd, setuptools 84.1.0 for an advisory published meanwhile.

Every code fix in v0.8.1 has a regression test that fails on the commit before it (d8fcb94 for W1–W24, 62b42ad for W25) and passes now.

Nothing has been deployed or published. No cloud resource was created, render.yaml and the public demo are unchanged, no image was pushed, no 24/7 reliability is claimed, and no trained model is applied to live data.

Paged findings and alert queue (X1)

Before: the dashboard loaded the 50 newest findings and the first 200 alerts. Anything older was unreachable from the UI, and "open" was filtered in the browser over a truncated list.

API. /v1/live/findings and /v1/live/alerts now filter and page on the server. Details are in docs/RISK_ENGINE.md §9.

  • Findings filters: type (source_match / relation / anomaly / insufficient_evidence), authority (the official OFAC file and its mirror count as one), priority / max_priority, and since / until / hours.
  • Alerts filters: status (including open), type (source_match / retrospective / relation / anomaly), authority, priority, time range on last seen, and sort (triage / newest).
  • Responses keep their lists and add page: total, next_cursor, limit, available.

Stable ordering. Pages use keyset cursors, not offsets.

  • Findings are ordered by observation id, which never changes, so a row never moves. New rows appear on the first page only.
  • Alerts are in triage order with id as the last tiebreak. A cursor is bound to its sort order.
  • An unchanged row is never skipped or shown twice. In triage order, an alert whose sort key changes between two requests moves to its new place; the UI says so.
  • The total and the page are read in one SQLite read transaction.

Kept apart:

  • Insufficient evidence is its own list. It is never mixed with findings, and a failed assessment is in neither.
  • Live and retrospective source matches are separate alert types.
  • No score or probability is returned.

Bounds.

  • limit is at most 200; the UI uses 25 per page.
  • Cursors and time bounds are validated: bad values get 400 or 422, never a 500.
  • Two new covering indexes serve the ids, filters and counts; full rows are read only for the page being returned.

Benchmark (scripts/bench_risk_pages.py, constructed data, 50,000 observations):

  • With 50,000 alerts (a stress case), every query takes ≤ 46 ms at the maximum.
  • With 2,000 alerts, alert queries take ≤ 4.4 ms; findings queries take ≤ 4.3 ms, except the authority filter at ≤ 23 ms.

Compatibility.

  • Older clients get the same response lists.
  • The dashboard's remote proxy validates filters and cursors itself, so a bad request is a 400 at the dashboard and is never forwarded.
  • An edge API from before paging would silently ignore unknown filters. The proxy therefore refuses filtered requests to such an edge (502, "upgrade the collector") instead of mislabelling rows. Unfiltered first pages still work, shown with "total not reported".

Dashboard.

  • Each list has filter selects with explicit labels and a Previous / Next pager.
  • The pager buttons stay focusable at the ends (aria-disabled), and the page and total are announced politely.
  • Each list has an empty state that names the filters, an "unavailable" state, and a "page emptied meanwhile" state.
  • Layout is responsive at 375 px.

Tests.

  • tests/test_risk_pages.py (54 tests): pagination across every filter, concurrent writes while paging, total and page from one snapshot, validation, token and read-only permissions, remote proxy, and an older edge.
  • 7 vitest tests.
  • 5 new browser E2E checks.
  • Mutation checks: the snapshot test fails without the read transaction (3/3 runs), and two cursor mutations break 12 and 13 tests.

v0.8.1 highlights (full matrix in docs/AUDIT.md#v081-independent-audit)

Area Change
Supply chain (W1) certifi 2026.10.19 (a trusted root with compromised intermediates), pillow 13.0.0, vitest 4.1.12; setuptools 84.1.0 (GHSA-xmj3-9gf7-h52w, 4f091cd); pip-audit and npm audit at 0
Screening (W2, W6–W8, W25) retrospective screening uses only listings in force; the mass-removal guard measures a source's own rows; indicators.closed_by (backfilled for rows closed before the upgrade) stops a stale mirror re-listing what the official file superseded; older-dated official content is refused (--allow-older); a refused official snapshot exits 3 even when the mirror works
Restore and backups (W3, W12, W21, W25) writers hold a shared flock; restore takes it exclusively and copies through SQLite's backup API (no renames); a writer starting meanwhile exits 75; the pre-restore copy includes WAL data; backups are verified before rotation, carry .sha256, and leave a concurrent run's .partial alone; a damaged database (schema page included) exits 78
Assessment states (W13, W18, W25) a failed assessment leaves an "Assessment failed" record; feed rows carry risk_state; the dashboard never shows "no finding" for unscreened rows
Collector (W9–W11, W20, W25) retries are never lost on shutdown; a locked database in the failure path is not fatal; re-sync stretches are coverage gaps subtracted from availability; the stale watchdog needs mempool updates, not pongs
Anomaly (W15) robust-tail/3: "strong" needs flags in two evidence groups
API (W22) out-of-range ids are 422; /v1 is no-store; Caddy passes GET only; the synthetic demo states a synthetic disclaimer (W4)
Deploy / CI (W16, W17, W23) install.sh verifies EXPECTED_SHA before checkout, uses a staging clone and re-execs the new installer; CI runs the suite on the deployed locks (py3.12)
Docs (W19) rollback runbook corrected; X-Forwarded-For hop-count verification procedure

Verification

The head is 1ee4a64. Code and locks were last changed in 4f091cd, which only pins setuptools and edits docs; the pagination code is a26b60d. 1ee4a64 is docs only.

  • CI: 9/9 green on 1ee4a64 (run 84) and on 4f091cd (run 83): Ubuntu and Windows × Python 3.11 and 3.13, deployed locks / py3.12, frontend, dependency audit, shell, docker.
    • Run 82 on a26b60d had a red dependency audit: the setuptools advisory had been published since the last green run, and 4f091cd fixes it.
  • Python: 561 tests pass on 3.13, 3.11 and the deployed locks (py3.12). ruff check and format, actionlint and shellcheck are clean.
  • Frontend: type-check, 58 tests and the production build pass.
  • Docker: the demo image built from 4f091cd passes check_demo_image.sh, which includes smoke_demo.sh: ready in 62 s at 0.1 CPU, 238 MiB, setuptools 84.1.0.
  • Browser end-to-end on a26b60d, against a local mock source through the dashboard's remote proxy: 20/20, with no console errors.
    • New checks: paging through the API with no duplicates; keyboard-only paging with focus kept; insufficient evidence listed apart; alert filters (retrospective kept apart, totals shown); no horizontal scroll at 375 px.
  • Real systemd (Ubuntu 24.04 container; install.sh installed 4f091cd): 39/39.
  • Rehearsal of the 24-hour procedure (docs/LIVE_CLOUD.md §10) in that container, against the local mock. These are minutes, not 24 hours, and not network data.
    • The paged routes on the installed edge: 401 without the token, 400 for a bad cursor, totals reported.
    • SIGKILL: the collector restarted in about 10 s and left one 15.1 s collector_down gap marked "unclean exit".
    • Reboot: both units and both timers came back, auth answered 401 / 401 / 200, a 1.0 s clean-stop gap was recorded, and integrity_check is ok.
    • chainwatch-live report run as the service user returns every field the pass criteria need.
  • 90-minute fault-injection soak on 3cd8148, against a local mock: 18/18 checks. It was not re-run; the collector is unchanged since then.

Real-network test: BLOCKED. The sandbox egress proxy refuses mempool.space (HTTP 403), and the Oracle API is unreachable from here. No real-network result is claimed.

Not verified / needs you

  • External:
    • Render's real X-Forwarded-For hop count (procedure in docs/DEPLOYMENT.md; a wrong value is P1 on the public demo).
    • Real mempool.space traffic, and anomaly behaviour on it.
    • The Oracle VM.
    • A 24-hour cloud run (docs/LIVE_CLOUD.md §7 A–D, then §10).
  • Supervised ML is not validated: the gate abstains (NO_VALIDATED_MODEL).
  • Open P3: listed in docs/AUDIT.md ("Accepted or open after v0.8.1").
  • Merging this PR starts CI on main. After it succeeds, publish-demo-image.yml publishes a new public GHCR image (0.8.1). Switching Render to remote mode is a separate production change.

🤖 Generated with Claude Code

https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7

claude added 15 commits October 14, 2026 02:23
Opt-in, zero-cost pipeline from the public mempool.space API to a "Live monitor" tab,
isolated from the historical research and the synthetic demo.

- chainwatch live-collect (src/chainwatch/live/): WebSocket track-mempool-txids ->
  validated, deduplicated (bounded LRU), hash-sampled txids -> bounded queue ->
  token-bucket-limited REST detail fetches (timeouts, HTTP 429 Retry-After pause) ->
  observation-time features + rule-based indicators -> SQLite (WAL, idempotent,
  bounded retention). Exponential backoff with jitter, staleness watchdog, graceful
  shutdown, metrics.
- Read-only /v1/live/{status,transactions,transactions/{txid},stats,events} with SSE;
  404 live_disabled unless live.enabled (only configs/live.yaml); the API never
  contacts mempool.space; non-mempool.space sources are labelled as mock data.
- Live monitor tab: connection state, throughput and fee-rate charts, filterable feed,
  detail panel with explorer links; real, synthetic and mock data labelled separately.
- Bitcoin semantics: output sums include change (never a payment amount); input
  references are observable spends only (no ownership inference). No Elliptic++ model
  is applied to live data.
- API contract verified against mempool's open-source backend (commit 4cf96d2); real
  ingestion could not be verified here (egress proxy returns 403 for mempool.space).
- Tests: 44 new Python tests with local WebSocket/REST mocks, frontend helper tests;
  scripts/live_load_test.py, scripts/mock_mempool.py; docs/LIVE_MONITOR.md,
  docs/LIVE_ML_PROPOSAL.md.

render.yaml stays on the 0.4.1 demo image; no research result changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…quence semantics

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…hangelog

Resource figures in docs/LIVE_CLOUD.md section 8 are pending the measurement run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…ck memory

scripts/soak_test.py runs mock -> collector -> edge API -> remote-mode dashboard as real
processes, injects REST/WebSocket/process faults round-robin and evaluates pass criteria.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
- backoff exponent clamped: after ~1024 failures (~8.5 h) 2**attempt overflowed and the
  WebSocket task died while the process stayed up (systemd never restarted it)
- supervision: run() returns as soon as any pipeline task dies; fatal state, CLI exit 1
  so systemd restarts; one bad item is logged/counted (internal_errors), not fatal
- payload range checks (amounts in [0, MAX_MONEY], weight <= 4M): out-of-range integers
  crashed the SQLite insert and killed the worker
- removed/mined txids are not fetched (gone_before_fetch); mined counter; replaced ->
  replacement_pairs with documented overlap with removed; already_stored split from
  duplicates
- disconnect outages start at the last received message (watchdog latency counted)
- Retry-After HTTP-date; no refill burst after a 429 pause; age re-check after waiting;
  5xx pauses the fetch budget; backoff resets only after 30 s of healthy stream; token
  bucket float-rounding spin; 16 MB frame cap for mempool resync deltas
- timelocked only when nLockTime is enforced; confirmed_at_fetch None when unknown
- backup refuses a missing database / keep 0; new verified 'restore' command

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…enance

Audit of the historical research (no result or metric changed; every number re-checked
against reports/):
- the Phase 2 protocol is described as fixed before the runs per the author's record; its
  timing cannot be verified from the published history (first appears with the results)
- headline leads with the protocol's primary comparison (pooled AP 35-49, +0.085
  [0.024, 0.229]); the 43-49 gain is labelled a sub-period with a CI-coverage caveat
- corrected misquotes: 43-49 AP range (0.39-0.49), standardised AP 0.93->0.18, which
  static model each ROC-AUC belongs to, zero-P@20 steps (3 of 7), all-transaction hit
  totals, test counts, 'close to random', 'no gain before the shift'
- caveats: publisher-computed aggregate features, in-sample calibration ECE, mean-of-step
  ECE/Brier, winner's curse in the dev robustness rule, time-proxy ablation, no drift
  detector was run; live-ML proposal lists collector gaps to close before a study
- (code in the previous commit) manifest.json records actual raw-file hashes and
  matches_published; run metadata carries real fingerprints; evaluate() warns on change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
- event streams: slot reserved before any await (concurrent opens bypassed the cap and
  could fill uvicorn's concurrency limit, taking /health/ready down with it); per-client
  cap (2, 429); sse_max_clients 10 < limit_concurrency 32 on Render; slots released even
  if a response is never iterated; Last-Event-ID parsed strictly (was a 500)
- RemoteBackend: single-flight per key, negative cache for failures, LRU (256), shared
  upstream token bucket (3/s, burst 20), bounded streamed reads, invalid JSON -> 502
- edge API: a valid service token is exempt from the per-IP limit, so unauthenticated
  floods from a shared egress IP cannot lock the dashboard out
- 429/413 responses carry security headers and no-store; HSTS header; IPv6 clients keyed
  by /64; graceful shutdown no longer waits up to sse_max_seconds for open streams
- install.sh: CHAINWATCH_HOST/REF validation, optional EXPECTED_SHA, Caddyfile rendered
  to a temp file and validated before replacing, token file 0600 root:root (migrated)
- systemd: SystemCallFilter=@System-service, ProtectProc/ProcSubset, RemoveIPC; edge API
  loopback-only (IPAddressDeny); exposure 3.0 -> 1.3 (collector), 3.0 -> 1.1 (edge)
- docker-compose real-data profile bound to 127.0.0.1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…er live queries

Frontend (from the frontend audit; 13 new tests, 20 total):
- source badge says REAL only when status says so; unknown when status is missing or
  unreadable (a failed status poll used to show mock data as REAL BITCOIN NETWORK DATA)
- connection badge never claims Connected on stale information: status unknown when the
  API is unreachable or status is older than 20 s; 'Connected, no new data' when nothing
  was fetched for 2 min (server clock); 'Collector failed' for a fatal exit
- event stream reconnects with backoff after HTTP errors (EventSource gave up for good on
  a 503) and opens after the initial load with ?since=; malformed events ignored
- keyboard-reachable feed rows (buttons), WAI-ARIA tabs, WCAG AA text colours, dark-mode
  tooltips, no horizontal scroll at 390 px, stacked detail panel scrolls into view
- stale-response guards (live detail, replay paging, transaction detail); per-panel
  loading/empty/error states; throughput chart drops the partial minute and breaks at
  gaps; axis labels; histogram bin-width note; 1 s tick re-renders only the time cells;
  polling pauses while hidden; PerformanceView no longer crashes on a missing budget

Store (measured at the 50k-row retention cap, before -> after p50):
- covering index (outcome, fee_rate): default list 15.7 -> 2.8 ms, fee-filtered list
  69 -> 3.0 ms; stats(60) 92 -> 14 ms (no ORDER BY forcing a fee_rate index walk);
  unary '+' hints keep last_observation/time-range/id-ordered pages on their best index

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…latency

- docs/AUDIT.md: 18-row findings table (severity, component, problem, root cause, fix,
  evidence) and accepted risks
- docs/ARCHITECTURE.md: research / synthetic demo / local live / cloud live boundaries,
  why SQLite, scaling limit
- docs/LIVE_CLOUD.md: hardened security model, runbook (failed state, stale data, token
  rotation with its 502 window, restore command, upgrade, rollback), latency before/after,
  real-systemd container test and fault-injection soak results
- docs/LIVE_MONITOR.md: counter semantics from mempool's backend source
- README test counts (370 Python + 20 frontend), CHANGELOG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
- stats(): fetched/failed totals use stored rows when larger than the per-minute counters
  (a SIGKILL loses up to heartbeat_s of counter flushes; found by the e2e test: 17 vs 24)
- scripts/e2e_live_browser.py: mock -> collector -> edge API -> remote dashboard -> SSE
  -> React in Chromium; 10/10 checks (live arrival, detail = API, outage and recovery
  shown, gap listed, replay stays synthetic, no console errors)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
@Apostal322 Apostal322 changed the title Phase 5: live Bitcoin mempool monitor MVP (v0.5.0) Live mempool monitor (v0.5.0) + always-on collector kit and engineering audit (v0.6.0) Oct 14, 2026
claude added 14 commits October 14, 2026 04:19
…t loop

Missing/unparsable/invalid configs and a missing edge token used to print a traceback and
make systemd restart forever; now 'config error' on stderr, exit 78, and the units set
RestartPreventExitStatus=78 so the failure stays visible. Regression tests (4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
The 110-min fault-injection soak (52 faults, 99.97 % availability, 0 tracebacks,
integrity ok) passed 10/11 checks: the database ended at 3,026 rows against a 3,000
cap because retention runs every 60 s. A clean stop now prunes (regression test), the
soak checks the documented running bound (cap + one minute of fetches), and the docs
record the run, including an earlier 3-hour attempt cut off by a container recycle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…, alerts

New chainwatch.risk package (no ML dependencies; runs on the collector VM):
- addresses: Bitcoin mainnet address validation/canonicalisation (base58check, BIP173
  bech32, BIP350 bech32m); rejects e.g. a Tron address filed under XBT in the SDN list
- indicators/sources: versioned, provenance-carrying snapshots; official OFAC
  sdn_advanced.xml parser (party name, profile, programmes, entry date; DTDs refused) and
  an address-list parser (third-party nightly OFAC extraction as fallback)
- persistence: indicator availability intervals [available_at, removed_at), per-tx
  screened addresses, risk records, grouped alerts with status workflow and audit log,
  tx lifecycle state (mined/removed/replaced) kept separate from features, retrospective
  screening that never rewrites point-in-time records
- screening (Layer A): point-in-time exact matches on input and output addresses;
  SCREENING_MATCH / NO_KNOWN_SCREENING_MATCH / SCREENING_DATA_UNAVAILABLE /
  INSUFFICIENT_INFORMATION; distance-2 relations within observed data only
- anomaly (Layer B): non-parametric tail probabilities vs the collector's previous
  transactions, robust z guard, explanations, abstention without a baseline
- supervised (Layer C): evidence gate; abstains with NO_VALIDATED_MODEL
- engine: per-layer failure isolation; ordinal review priority (not a probability)
- collector assesses every fetched transaction; API /v1/live/risk/summary, /findings,
  /alerts, risk + lifecycle in transaction detail; CLI indicators update/status, alerts
- fixtures now use valid deterministic addresses; 27 new tests (403 total)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
- chainwatch-live indicators update --fallback: official OFAC XML first, third-party
  extraction if unreachable; a failed refresh keeps the previous version (exit 1)
- chainwatch-indicators.service/.timer (daily, hardened, exposure 1.3); install.sh
  enables it
- tests: risk routes on the edge API and through the Render remote proxy, readers on a
  pre-v0.7 database, fallback behaviour (30 risk tests)
- verified with real data: 531 OFAC-derived Bitcoin addresses ingested over the network
  (one non-Bitcoin entry rejected); assessment p50 2.0 ms with a full 2,000-tx window

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
The whole-tree parse would have exceeded the indicator service's MemoryMax=400M on the
VM with the real ~100 MB sdn_advanced.xml. Sources are now downloaded to a temporary file
while counting bytes (size cap), and the XML is parsed with iterparse, freeing each party
after reading it. Regression test bounds peak memory on a 20,000-party file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
- multi-party listings kept (1H939dom... is listed under profiles 38419 and 38420; the
  first-party-only parser dropped one)
- OFAC's entry date is the party's designation date, not when an address was added:
  listed_on is now null for OFAC and the date is details.party_designated_on; screening
  availability stays ChainWatch's first snapshot containing the address
- streaming clears every list-section record (Locations, IDRegDocuments, ...): real file
  peak 206 MB -> 16 MB traced, 24 s; 516 valid Bitcoin addresses, 56 parties, 1 TRON-style
  address rejected; matches the third-party extraction (1 removed, 16 added since January)
- User-Agent on fetches (the sanctions list service answers 403 without one)
- authentic public-domain excerpt committed as a test fixture with provenance

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Point-in-time replay of a collected database: flag rate and alerts/day, hourly stability,
window/alpha sensitivity, measurement drift (KS), agreement between methods at equal alert
volume, CPU cost, and treatment of known-benign shapes (batch payout, consolidation,
CoinJoin-like: all flagged, which is why anomalies are not evidence of wrongdoing). No
labels, no fraud metrics. Validated on a mock database only; real numbers need a real
collection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Pre-registers question, hypotheses, feature sets (out_txs_degree excluded as future
information), unchanged Phase 1 method, primary metric (pooled test AP, XGBoost,
live_computable vs all), caveats and the rule that no resulting model is promoted to the
live monitor. Adds feature sets 'augmented' and 'live_computable' and their configs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
- docs/RISK_ENGINE.md: event-time model with the tests that enforce it, indicator
  versioning, live-features/2 schema (units, nulls, provenance), screening/graph/anomaly/
  supervised semantics, review priority, alert grouping and workflow, failure isolation,
  what is not claimed
- docs/RISK_DATA_FEASIBILITY.md: cited matrix of 12 sources (Elliptic, Elliptic++,
  Elliptic2, BitcoinHeist, Paquet-Clouston, BABD-13, OFAC, Chainabuse, Ransomwhere, ...),
  decision gate (no supervised live risk model is feasible with legitimate public data),
  OFAC structure/fixture provenance/data-quality pitfalls, Chainabuse constraints
- config accepts the 'augmented' and 'live_computable' feature sets

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…t 64 KB

A comment longer than 64 KB before a DOCTYPE could have hidden an entity declaration from
the head-only check. The file is now scanned in overlapping chunks while hashing.
Regression test with a 3 MB comment; the real 122 MB file still parses (516 records).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Runs the pre-registered protocol (6b16109) on the verified Elliptic++ data.
XGBoost on the 16 live-computable features: pooled test AP 0.646 vs 0.797 with
all 182 features (paired block-bootstrap delta -0.151, 95% [-0.216, -0.089]);
all models collapse after step 42. No missing-value shortcut (AP on complete
rows is unchanged). Exploratory only; nothing is promoted to the live monitor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Dashboard (frontend): risk overview tiles, investigation queue, recent
findings, per-transaction risk assessment with evidence and limitations,
priority column in the feed, mock-data notice; staleness and baseline
thresholds come from the server when reported.

API/collector fixes found while building it:
- the fetched row and its risk record are committed together (savepoint for
  the risk writes), so the feed never shows a row before its assessment;
- list rows carry risk_assessed; findings carry insufficient_evidence/errors;
- summary reports per-source age/stale and the anomaly settings;
- retrospective alerts carry the same evidence fields as live matches;
- alert titles use source names; the mirror no longer labels each address
  with the source description;
- anomaly layer text avoids 'illicit'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…t 50k rows)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…sk engine contracts

- AUDIT.md: v0.8 findings with root cause, fix, regression test and commit.
- LIVE_CLOUD.md: database at the 50k cap is 283 MB with risk records (the
  62.7 MB figure predates the risk tables); HTTP latency at the cap; Caddy
  timeouts; zero-downtime token rotation; systemd container test 35/35.
- RISK_ENGINE.md: diff semantics, refusals, one authority per list, graph
  re-screening, robust-tail/2, alert keys and retrospective semantics.
- Missing test: alert upserts stay idempotent beyond the displayed txids
  (fails on f9f8765).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…ng, guarded retro

- P1 (regression in a2d0802): supersession ran both ways, so when the
  official fetch failed a lagging mirror delisted the newest official
  designations and re-listed addresses OFAC had just delisted. A
  lower-ranked copy now never closes a higher-ranked listing and never
  re-lists what it delisted; the official file is never 'superseded' by its
  mirror, so a failing official refresh shows its real age.
- v0.7 alerts are re-keyed to the authority/role group keys during the
  migration, so dismissed/resolved states carry over.
- The collector's retrospective pass is guarded (db_errors, retried next
  beat), re-screens each source's latest snapshot at start-up, and counts
  only matches not already alerted on.
- LifecycleMemo keeps 'replaced' when 'removed' follows (as mark_lifecycle).
- Proxy: budget-refused failures are not cached (they evicted the polling
  answers); the stream and the feed poll one query; /status is never served
  stale; make_backend uses the edge's token rule.

Every new test fails on d4194e4 and passes now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
The 90-minute soak on 4872b7b refused 4 of 5 refreshes: each one replaced
the whole TEST list, which the mass-removal guard (a2d0802) rejects by
design ('would delist 11999 of 11999 active listings'). Refreshes now keep
the base list, delist a few entries and add up to 1,000.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…7/17), test counts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
@Apostal322 Apostal322 changed the title Live monitor (v0.5.0), always-on kit + audit (v0.6.0), risk intelligence (v0.7.0) Live monitor (v0.5.0), always-on kit (v0.6.0), risk intelligence (v0.7.0), independent hardening audit (v0.8.0) Oct 16, 2026
…publish gated on CI

- Collector: transient detail-fetch failures (timeout, network, 429, 5xx, a
  first 404) are retried with exponential backoff and jitter, at most
  fetch_max_attempts (default 3, max 10), never past max_queue_age_s, with
  at most queue_max/2 pending; every attempt draws from the fetch budget.
  Malformed/oversized payloads and other 4xx are final. Pending retries are
  recorded with their last error on shutdown. New counters.
- 500 responses (dashboard and edge) carry the security headers and a JSON
  error envelope: Starlette sends them from ServerErrorMiddleware, outside
  the header hook; the edge had no 500 handler at all.
- CI installs from requirements/dev.lock.txt (hash-locked, universal for
  3.11-3.13 on Linux/Windows, build backend included) and runs a dependency
  audit job (pip-audit on the dev/serve/live locks, npm audit).
- The demo image is published only after CI succeeds for a push to main
  (workflow_run), from exactly the tested commit, re-checked through the API
  (also for manual runs). Dependabot for pip, npm, actions and Docker.
- Tests for each; the release gate itself is regression-tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…: p50 220 -> 160 ms)

Output is identical (hash of stats(60/240/1440) on the 50k-row database
equals the previous code's). The deep-offset sort=vsize path (~120 ms) is
left as is: it would need a new index on the write path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…d run

- AUDIT.md: B1-B6 (500 headers, bounded retries, CI lock, Dependabot and
  audit, publish gated on CI, stats speed-up) with tests and commits; the
  open list now holds only the LOW items.
- DEPLOYMENT.md: the image is published only after CI succeeded for the
  exact commit. LIVE_CLOUD.md: bounded retries, supply chain, 500 answers,
  real-systemd test on 6bd4f52 (32 checks, reboot).
- live-cloud.yaml: retry settings explicit (the defaults); database size
  comment corrected (~285 MB at the cap).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…ic 24 h DB size

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
@Apostal322 Apostal322 changed the title Live monitor (v0.5.0), always-on kit (v0.6.0), risk intelligence (v0.7.0), independent hardening audit (v0.8.0) Live monitor (v0.5.0), always-on kit (v0.6.0), risk intelligence (v0.7.0), independent hardening audit and release gate (v0.8.0) Oct 19, 2026
claude added 12 commits October 23, 2026 16:33
…dvisories)

The dependency-audit gate went red after v0.8.0 was validated:
- certifi < 2026.10.18 trusts emSign ECC Root CA - G3, whose eMudhra
  intermediates have compromised keys (PYSEC-2026-4320 / GHSA-6q48-6c7w-9gw2):
  every lock (VM, serving image, CI, audit tool); the collector's and the
  proxy's HTTPS use it. Pinned to the fix release 2026.10.19.
- pillow 12.3.0 in the serving image (via matplotlib; the app never opens
  untrusted images): ~40 advisories fixed in 13.0.0, the version the dev lock
  and CI already used.
- vitest 4.1.12 (dev only, moderate): mocker code injection.
Only these packages changed (pip-compile/uv --upgrade-package; the npm lock
was updated with npm 11 because npm 10.9 crashes in its peer-set resolver;
npm 10 'npm ci' installs it). pip-audit: no known vulnerabilities in any lock;
npm audit: 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…eted

From the v0.8.1 independent OFAC/screening audit (each test fails on d8fcb94):
- P1: retrospective screening (re-run for each source's latest version at
  every collector start) matched listings closed since, e.g. a mirror row the
  official file superseded: a P1 'now listed' alert for a transaction that
  was correctly assessed without a match. Only rows in force are used.
- P2: superseding a lower-ranked copy's extra rows counted towards the
  official file's mass-removal limit, so a mirror with extra rows blocked
  every later official refresh. The limit now measures the source's own
  rows (a first official snapshot is still measured against the copy it
  replaces; a truncated official file is still refused).
- P2: a mirror row closed by the official file left no trace, so the same
  stale mirror content listed it again. Closures record the closing version
  (indicators.closed_by, added by migration); a lower-ranked copy cannot
  re-list what a higher-ranked snapshot superseded.
- P2: a snapshot dated before the stored version (stale CDN edge, old file)
  was a new version that re-listed delisted addresses; refused unless
  --allow-older.
- P3: a refused official snapshot followed by a successful fallback now
  exits 3, so the refresh unit shows as failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…pdates

From the v0.8.1 independent collector audit (each test fails on d8fcb94):
- P2: after a 5xx the token bucket pauses 30 s, longer than the retry delay,
  so a retry usually waits in the queue or for a token, outside the timers:
  shutdown lost it without a row. Interrupted and queued retries are now
  recorded with their last error.
- P2: a failed fetch's add_failed was called directly, so a writer lock
  longer than the busy timeout killed the worker (fatal exit). Contained and
  counted (db_errors); an unusable database still stops the heartbeat.
- P2: mempool repeats its sequence for the whole out-of-sync stretch (clear
  protection); the skipped arrivals left no trace and availability looked
  complete. Each stretch is recorded as a sequence_gap with its duration.
- P3: frames without mempool updates (pongs, junk) satisfied the stale
  watchdog and reset the backoff; it now needs deltas.
- P3: a txid announced again while its retry is pending is not queued twice
  (an orphaned timer could fire after shutdown); an expired retry counted as
  expired and failed; vin sequence values must be uint32 (a bool or negative
  value switched on rbf_signal); with prevouts missing, fee + outputs must
  still be a valid amount and cover the known inputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…trace

From the v0.8.1 independent persistence audit (each test fails on d8fcb94):
- P1 (was accepted as LOW): restore renamed the live files while other
  processes could open the database. A collector restarted by systemd (state
  still 'stopped') or a timer-run indicator refresh then wrote to the renamed
  files, or paired its fresh WAL with the restored file, so a restore that
  reported OK lost its data. Every writer now holds a shared flock on
  <db>.lock; restore needs it exclusively (refused otherwise) and copies the
  backup into the live file through SQLite's backup API, renaming nothing.
  A writer starting during a restore exits 75 and systemd retries.
- P2: the pre-restore copy lacked WAL frames not yet checkpointed (the WAL
  was renamed to a name SQLite never pairs); it is now one self-contained
  backup-API copy.
- P2: a failed assessment rolled back its address rows (retro screening
  could never find it) and looked exactly like risk being off. Addresses are
  saved in their own savepoint, a failed assessment stores an all-ERROR
  record labelled 'Assessment failed', and feed rows carry risk_state
  (finding / no_finding / insufficient_evidence / failed / not_assessed);
  the dashboard shows '?' and 'err' instead of '-' (no finding).
- P2: dismissed (and other reviewed) alerts with their notes were deleted
  after 90 days without a recurrence; only untouched 'new' alerts expire.
- P3: backups are integrity-checked before getting their final name, carry
  a .sha256, stale .partial files are removed, rotation matches only its own
  names; the collector refuses a corrupted database at start (exit 78, no
  restart loop); orphans are removed when every transaction aged out; the
  anomaly window is updated only after the record is committed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…anations

From the v0.8.1 independent ML audit:
- P2: vsize is close to a linear function of the input and output counts, so
  one unusual count flagged two measurements and counted as 'strong'
  (priority 3, an alert). On realistic correlated noise that was about 1.2
  priority-3 alert groups per hour at 12 fetches/min; 56 of 61 strong results
  were {vsize + a count}. Measurements now belong to evidence groups (size,
  fee, value, output shape) and strong needs two groups. The old test used
  exactly that redundant pair as its 'several measurements' case.
- P3: the explanation used the doubled two-sided p ('higher than about
  99.90%' for a fee above every reference value); it now states the share
  of the reference from the counts.
- Docs in the module: alpha is per measurement (about 3-4 x alpha of
  transactions get a flag under the null).
Each new test fails on d8fcb94.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
… via Caddy

From the v0.8.1 independent HTTP audit (tests fail on d8fcb94):
- after_id/before_id above SQLite's INTEGER range reached SQLite
  (OverflowError: HTTP 500 and a multi-KB traceback in the edge journal,
  reachable anonymously through the dashboard at up to 3/s): now 422.
- The edge's 422 answers did not use the error envelope and echoed the input.
- Dashboard /v1 answers carry cache-control: no-store (as the edge's do).
- Caddy forwarded HEAD, which every edge route answers with 405: GET only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
…t deployed locks

From the v0.8.1 independent supply-chain/deploy audit:
- P2: install.sh checked out the commit before comparing EXPECTED_SHA, so a
  mismatch left the unverified tree in place for the next restart. The
  fetched commit is verified first; a fresh clone goes to a staging dir.
- P2: upgrading ran the old installer (bash keeps executing the old text
  after git replaces the file): a v0.6 install skipped EXPECTED_SHA, the
  indicators timer and the token-permission fix. After the checkout the new
  installer is re-executed when it differs.
- P2: CI never ran the suite on the versions actually deployed (the dev lock
  resolves newer fastapi/starlette/pyarrow). New 'deployed locks' job on
  Python 3.12 (Ubuntu 24.04's) with serve.lock + a hashed pytest lock
  (requirements/test.lock.txt, constrained to serve.lock); 502 pass locally.
- P3: a version tag is pushed only on an explicit 'manifest unknown' (any
  inspect failure used to count as 'free'); the version reaches run: via
  env; shellcheck covers docker/entrypoint.sh; Dependabot ignores the ML
  stack that must equal the training environment; live.env.example states
  0600 root:root; dev.in documents --exclude-newer for exact reproduction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
- P1: the synthetic demo's Limitations tab stated the research-dataset
  disclaimer ('Historical replay on the Elliptic++ research dataset'),
  contradicting its SYNTHETIC banner: the API now sends a synthetic one.
- P1: replay kept the previous step's rows (and a mixed 'Model used' tile)
  under the new step's caption after a failed request; ranking and metrics
  are cleared on change and on error, and the error is announced.
- P2: 'Not evaluated (no parent transactions)' when the graph was skipped
  because screening was unavailable; a 'no known match' from a stale source
  was in the reassuring tone; 'Connected' (green) with nothing ever fetched
  however long; ordinary tab switching remounted the live view (7 requests
  and a new stream each time) into 429s: it now stays mounted once visited.
- P2: replay rows are buttons (screen readers did not announce them).
- P3: the tab is kept in the URL hash (reload, back/forward); empty replay
  pages say so; chart legend text meets contrast; panel errors are polite
  live regions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
… hop-count procedure, real-network checklist

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
- Dashboard: skip-link and in-page anchors no longer reset the active tab
  (only tab slugs in the hash switch views); replay selection clears when
  the ranking it came from changes.
- Persistence: closed_by is backfilled for rows closed before the upgrade,
  so those closures still block a stale lower-ranked mirror.
- Risk state: rows screened by no indicator list after the baseline report
  screening_unavailable, never no_finding.
- collect: quick_check runs on a read-only connection before the store is
  opened, so a damaged schema page exits 78 instead of raising.
- Availability: resync stretches count as unobserved time.
- Backup: only .partial files older than an hour are removed, leaving a
  concurrent backup's copy alone.
- Installer: the staging clone is removed on every exit path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
@Apostal322 Apostal322 changed the title Live monitor (v0.5.0), always-on kit (v0.6.0), risk intelligence (v0.7.0), independent hardening audit and release gate (v0.8.0) Live monitor (v0.5.0), always-on kit (v0.6.0), risk intelligence (v0.7.0), hardening audits and release gate (v0.8.0, v0.8.1) Oct 23, 2026
The dashboard loaded the 50 newest findings and the first 200 alerts, so
older ones were out of reach and "open" was filtered in the browser over a
truncated list.

- /v1/live/findings and /v1/live/alerts take filters (type, source
  authority, priority, status incl. open, time range, sort) and keyset
  cursors, and report the total matching the filters. Total and page come
  from one read snapshot. Live and retrospective source matches are
  separate alert types; insufficient evidence is its own list, never mixed
  with findings; no score or probability is returned.
- Covering indexes for the filtered ids and counts; full rows are read
  for the page only. Every query <= 46 ms at 50,000 observations and
  50,000 alerts (scripts/bench_risk_pages.py).
- The remote proxy validates filters and cursors itself and refuses
  filters an older edge API would silently ignore; old clients keep the
  same response lists.
- Dashboard: filters and a pager per list (keyboard operable, explicit
  labels, polite status), empty / unavailable / page-emptied states,
  responsive at 375 px.
- CLI: alerts list accepts --status open and refuses unknown statuses.
- Tests: tests/test_risk_pages.py (pagination, concurrent writes,
  filters, validation, permissions, remote proxy), vitest, browser e2e.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
A new advisory turned the dependency-audit job red; only setuptools
changes (hashes checked against the PyPI files; pip-audit clean on all
three locks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7
Real-systemd harness 39/39 on the final source (4f091cd), and the §10
steps (SIGKILL, reboot, report) rehearsed against the local mock, recorded
as a rehearsal, not as a 24-hour or real-network result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FbdkMvyfPtk41mcHA7eR7

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants