blockyard 0.0.9 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +359 -1
  2. package/README.md +48 -27
  3. package/SECURITY.md +2 -2
  4. package/bin/blockyard.js +2 -1
  5. package/docs/API.md +17 -15
  6. package/docs/ARCHITECTURE.md +128 -10
  7. package/docs/CONFIGURATION.md +39 -30
  8. package/docs/DEFECTS.md +4 -1
  9. package/docs/GETTING-STARTED.md +18 -8
  10. package/docs/INSTALL.md +97 -37
  11. package/docs/MEASUREMENTS.md +147 -0
  12. package/docs/PLAN-SCORCHED-YARD.md +456 -0
  13. package/docs/PLAN-SKIES.md +142 -0
  14. package/docs/SECURITY-AUDIT-2026-09-16.md +647 -0
  15. package/docs/SECURITY.md +58 -22
  16. package/docs/TROUBLESHOOTING.md +44 -5
  17. package/docs/USER-GUIDE.md +505 -35
  18. package/package.json +4 -2
  19. package/public/404.html +1 -1
  20. package/public/css/app.css +393 -82
  21. package/public/donate-qr.png +0 -0
  22. package/public/index.html +353 -109
  23. package/public/js/agents.js +228 -51
  24. package/public/js/app.js +131 -16
  25. package/public/js/blockanoid.js +15 -7
  26. package/public/js/blockout.js +15 -7
  27. package/public/js/blockscene3d.js +230 -38
  28. package/public/js/charts.js +21 -21
  29. package/public/js/depthchart.js +31 -27
  30. package/public/js/details3d.js +1481 -73
  31. package/public/js/doom.js +31 -0
  32. package/public/js/dosaudio.js +48 -0
  33. package/public/js/dosgame.js +389 -0
  34. package/public/js/dosio.js +186 -0
  35. package/public/js/dospc.js +1353 -0
  36. package/public/js/dosworker.js +196 -0
  37. package/public/js/explorer.js +7 -1
  38. package/public/js/livingsky.js +494 -0
  39. package/public/js/login.js +8 -2
  40. package/public/js/markets.js +46 -8
  41. package/public/js/mining.js +314 -36
  42. package/public/js/panels.js +41 -28
  43. package/public/js/pricechart.js +14 -13
  44. package/public/js/quake.js +20 -0
  45. package/public/js/safenext.js +14 -0
  46. package/public/js/scorched.js +1051 -0
  47. package/public/js/scorchedai.js +227 -0
  48. package/public/js/scorchedair.js +286 -0
  49. package/public/js/scorchedfx.js +376 -0
  50. package/public/js/scorchedshop.js +105 -0
  51. package/public/js/scorchedwind.js +69 -0
  52. package/public/js/scorchedyard.js +1338 -0
  53. package/public/js/settings.js +368 -100
  54. package/public/js/soundcard.js +459 -0
  55. package/public/js/tetrust.js +15 -6
  56. package/public/js/tetsound.js +35 -5
  57. package/public/js/theme.js +235 -0
  58. package/public/js/wolf3d.js +22 -0
  59. package/public/js/x86.js +1978 -0
  60. package/scripts/check.js +46 -0
  61. package/scripts/donate-qr.py +12 -9
  62. package/scripts/dos-bench.js +56 -0
  63. package/scripts/index-build.js +9 -2
  64. package/scripts/pool-map.js +152 -36
  65. package/scripts/setup.js +142 -22
  66. package/scripts/shots.mjs +27 -0
  67. package/scripts/smoke.sh +7 -6
  68. package/scripts/tls.js +31 -0
  69. package/scripts/ui.js +4 -2
  70. package/server/auth/sessions.js +33 -13
  71. package/server/chain/blockfile.js +64 -5
  72. package/server/chain/index/build.js +451 -58
  73. package/server/chain/index/heights.js +29 -3
  74. package/server/chain/index/live.js +13 -7
  75. package/server/chain/index/rows.js +6 -1
  76. package/server/chain/index/store.js +28 -5
  77. package/server/chain/index/worker.js +23 -11
  78. package/server/collect/logparse.js +65 -18
  79. package/server/collect/markets.js +76 -7
  80. package/server/collect/mining.js +32 -0
  81. package/server/collect/monitor.js +54 -12
  82. package/server/collect/network.js +305 -0
  83. package/server/config.js +53 -22
  84. package/server/http/api.js +119 -18
  85. package/server/http/games.js +77 -0
  86. package/server/http/server.js +30 -5
  87. package/server/http/sse.js +53 -7
  88. package/server/main.js +66 -11
  89. package/server/rpc/allowlist.js +26 -0
  90. package/server/rpc/client.js +30 -2
  91. package/server/store/audit.js +6 -1
  92. package/server/store/history.js +19 -3
  93. package/server/store/ledger.js +15 -4
  94. package/server/tls/selfsigned.js +160 -0
  95. package/systemd/blockyard.service +41 -8
  96. package/docs/PRIVATE-LEADERBOARD.md +0 -230
  97. package/docs/STATE-2026-09-09.md +0 -200
@@ -1,200 +0,0 @@
1
- # State of the project — 2026-09-09 (handoff for an agent with a real browser)
2
-
3
- > **Superseded 2026-09-14, names only.** This is a dated record and its measurements stand as
4
- > written. The names in it are the ones in use that day and are no longer current: the project
5
- > is **BlockYard** (`/storage/blockyard`, systemd `blockyard.service`, env vars `BLOCKYARD_*`,
6
- > default web port 21000), and the node it watches is Bitcoin Core. `bmc-port-guard.sh` and
7
- > `/etc/ssl/bmc-local/ca.crt` are real artefacts on the operator's machine and keep their names.
8
-
9
- Written by the session that built the mining/visualisation layer. Everything below was
10
- run on this box; the things I could **not** do are listed explicitly at the end. Read
11
- `AGENTS.md` first for the rules (zero dependencies, RPC-only sources, never fabricate a
12
- figure, a chart never erases itself).
13
-
14
- ## What is running
15
-
16
- | Thing | Where | Note |
17
- |---|---|---|
18
- | bmcmonitor | `https://<LAN address>:8088` | systemd `bmcmonitor.service`, TLS via a **local CA** (`/etc/ssl/bmc-local/ca.crt`), binds the **LAN address only** — loopback, docker bridges and the tailnet address all refuse, by design |
19
- | Node watched | `bmc-main`, RPC `127.0.0.1:8331` | the node's own esplora REST is on `127.0.0.1:3005` |
20
- | Log tailing | **OFF** (default since today) | the UI reads RPC only. `BMC_MON_LOG_SOURCE=1` re-enables it for parser work; do not add panels that need it |
21
- | Block-chain node under dev | `/storage/bitcoinmachinecode` | a *different* session works there; do not restart or reindex it casually |
22
-
23
- Import the CA or the browser will refuse the certificate. After any deploy, hard-reload:
24
- asset URLs are stamped `?v=<build>` and the stamp changes when files change, so a tab
25
- holding an old tab keeps running old code — that has already produced one false report
26
- today ("still renders nothing" while the fix was on disk and undeployed).
27
-
28
- ## Verify, don't trust this document
29
-
30
- ```bash
31
- cd /storage/bmcmonitor
32
- npm test # unit + render + contract tests
33
- bash scripts/smoke.sh # 109 checks against a real server
34
- npm run counts # do the documented counts match the suite?
35
- LAN=$(python3 -c "import json;print(json.load(open('config/local.json'))['server']['hosts'][0])")
36
- BMC_MON_BASE=https://$LAN:8088 BMC_MON_CA=/etc/ssl/bmc-local/ca.crt npm run render:live
37
- sudo systemctl restart bmcmonitor # deploy after editing public/** or server/**
38
- sudo journalctl -u bmcmonitor -f # server-side view; the UI records to it
39
- ```
40
-
41
- `render:live` renders **every page** under the DOM stub against the running monitor and
42
- fails if an asserted card is empty. Today it caught, in order: an uncaught `ReferenceError`
43
- that killed the entire Overview (two cards "rendered nothing" because one line above them
44
- threw), a `fmt is not defined` crash on the Node page, and a card that no test had ever
45
- reached.
46
-
47
- ## What was built today (mining + visualisation)
48
-
49
- - **Mining page** (`#mining`): block flow (construction → tip → history, the tip explicitly
50
- labelled `current tip`, colour = age verdict), ghost cards for the next blocks marked
51
- `not yet assembled`/`estimate`, ancestor-package table (CPFP shape from
52
- `getblocktemplate…depends`, with `depends` being **indices into the array**, not txids),
53
- and two treemaps.
54
- - **Treemaps** (`public/js/goggles.js`): one rectangle per transaction, area = vbytes,
55
- colour = the feerate it pays, richest-first. The canvas is **the block**: a 14%-full block
56
- looks 14% full and the rest is drawn blank and labelled. Cells are bounded (400) and the
57
- remainder collapses into ONE aggregate cell so the block is always whole.
58
- - **Tip freshness** is judged against the chain's own measured block interval, not a fixed
59
- clock: amber past ~1× the average gap, red past ~1.5×, floors at 4/8 min. Arrival is only
60
- counted when the page **witnessed** the height change — a first paint must not claim a
61
- fresh tip (that bug coloured a 14-minute-old block green).
62
- - **Overview** gained a compact copy of the block map (`ovGnTreemap`, `w4`, `.treemap.sm`).
63
-
64
- ## Bugs I fixed, so you don't re-diagnose them
65
-
66
- - `rows` TDZ in `renderOverview` — two `rows` in one function; killed the whole Overview
67
- render (the Fees card and the "mempool vs blocks" card were collateral).
68
- - `fmt is not defined` in `panels.js:drawSelf` — the Node page crashed.
69
- - Treemap `drawFrame` referenced `label` without destructuring → **every partly-filled
70
- block threw at paint time and the canvas stayed blank**.
71
- - The treemap tween re-requested animation frames whenever the clock failed to advance
72
- (hidden/throttled tab) → unbounded loop. Now a frame budget + stalled-clock check, and
73
- the settled layout always draws.
74
- - **CSP**: the policy is `style-src 'self'` with no `style-src-attr` allowance (correct,
75
- tightened earlier today). My new markup emitted `style="..."` and the browser blocked
76
- **several hundred** applications, so the train and maps lost every colour. All of it now
77
- travels as `data-pool` / `data-rate` / `data-w` / `data-delay` / `data-rail` and lands on
78
- `el.style` through the CSSOM (`applyMiningStyles` in `mining.js`, `applyDataSizes` in
79
- `app.js`). The palette index comes from our own array — a pool name from the node cannot
80
- become CSS. `test/csp.test.js` now fails if any JS-built markup carries a style attribute.
81
- - **The Fees card** was found with `getElementById('ovFees').closest('.card')`, and the DOM
82
- stub answers `closest()` with `null` — so **no test ever exercised that card**. It is now
83
- `#ovFeesCard`, addressed by id, and asserted in `test/web-contract.test.js`.
84
-
85
- ## Known, open, or unverified — this is what a browser is for
86
-
87
- 1. **Nothing has been seen rendered.** No real-browser harness exists. Layout, colour
88
- legibility, overlap, and "does the treemap read as a block" are unverified by me.
89
- 2. **Treemaps at `w4`** (33%) on Mining, `w4` on Overview: is 168px/240px high enough for
90
- the labels, and is the "block unfilled" band legible at that width?
91
- 3. **Legend/label collisions** inside rectangles (rate + `k` vbytes text) at small cell
92
- sizes, and the `selection ends` / `everything fits in one block` label near the right
93
- edge.
94
- 4. **Hover tooltips** (`.goggles-tip`) are positioned `left/bottom` — check they don't
95
- cover the cursor's cell or overflow the card.
96
- 5. **Motion**: the map tweens only when the Mining page is open and the template refetches
97
- (on load + every 20 s). Confirm the tween is visible, and that `prefers-reduced-motion`
98
- snaps without losing information.
99
- 6. **`app.js` boot throws under the DOM stub** (`TypeError` at `boot()`, harness-only). Real
100
- browsers don't hit it; it means a stub element is missing, and it will keep biting anyone
101
- extending the harness.
102
- 7. Ghost-card forward capacity numbers are **queue-depth estimates**, not node data.
103
- 8. No TLS certificate automation (self-signed local CA), and `:8999` (mempool-backend API)
104
- is loopback-only by a netfilter rule — separate from this app.
105
-
106
- ## Guardrails that will bite if you ignore them
107
-
108
- - **Zero dependencies.** No `npm install`. Node builtins and hand-written canvas only.
109
- - **No host identity in committed files.** `test/privacy.test.js` derives the username,
110
- hostname forms and interface addresses at run time and fails on them — it caught a
111
- hardcoded LAN address in one of my scripts today. Use RFC 5737 documentation ranges in
112
- docs and tests, and read addresses from config/env at run time.
113
- - **Test counts are generated** (`npm run counts:fix`). Never type them.
114
- - **Every claim in a comment must be a measurement** with a number and a date. "Seems" is
115
- not a justification, and this project has twice been burned by a check that passed for
116
- the wrong reason (a vacuous assertion, a stub that answered `null`).
117
- - A chart **never erases itself** to show a status; absence renders as `–` with a reason,
118
- and stale data renders visibly stale.
119
- - Absent data is **never** filled with a guess: no per-tx `depends` in
120
- `getrawmempool` on this node, so cluster analysis is only drawn from
121
- `getblocktemplate`, and the panel says which of the two it is.
122
-
123
- ---
124
-
125
- ## Measured in a real browser (2026-09-10, headless Chromium over CDP)
126
-
127
- `scripts/browser-check.mjs` drives Chromium over CDP with Node's built-in WebSocket: it
128
- loads the page, samples **canvas pixels with getImageData**, reads inline vs computed CSSOM
129
- values, measures element rects, collects console/exceptions, and can pass the screenshot to
130
- the local vision model. This is the first time any of this has been looked at rather than
131
- inferred. It found five defects that 349 passing tests did not.
132
-
133
- ### Found and fixed
134
- 1. **Shared animation handle.** `goggles.js` kept one module-level `raf` for both maps, so
135
- each canvas's render cancelled the *other* one's pending frame — and the first frame was
136
- drawn only inside that callback. The loser painted **nothing**: `__hasData: true`, 401
137
- rects laid out, 68% of the canvas covered on paper, **zero painted pixels**. Now the
138
- handle is per-canvas (`c.__raf`) and the settled layout is painted before any animation.
139
- 2. **Tween grew cells from zero size.** With a snapshot arriving every second, the chart
140
- spent most of its life mostly-cleared with 1px rectangles. Now position interpolates and
141
- **size never does**; new cells fade in with alpha. A tween must be the difference between
142
- two visible states, not the thing that makes pixels exist.
143
- 3. **`style-src` was silently vetoing my own markup** (several hundred blocked
144
- applications): all `style="..."` removed in favour of `data-pool` / `data-rate` /
145
- `data-w` / `data-h` / `data-delay` / `data-rail` + CSSOM. Guarded by a test that fails if
146
- any JS-built markup carries a style attribute.
147
- 4. **`.closest('.card')`** made the Fees card invisible to every test (the DOM stub answers
148
- `null`), so it could render nothing forever. Now addressed by `#ovFeesCard`.
149
- 5. **`rows` TDZ** in `renderOverview` killed the whole Overview. Also: the earlier "fixed"
150
- report was false because the fix was never **deployed** — deploy is part of a fix.
151
-
152
- ### Still broken, with the measurements
153
- - **The Mining page block map still paints nothing** (`gnTreemap`: `rects: 401`,
154
- `distinctColours: 0`, `paintedPixelsPct: 0`) while the mempool map on the same page paints
155
- 100% with the identical code path and the same rect count. I did not find the cause. Start
156
- by comparing what differs at `drawFrame` time between the two — `geom.unused` is set for
157
- the block map and absent for the mempool map, which changes `region`; instrument
158
- `drawFrame` with a counter and a sample of the first rect's `fillStyle`.
159
- - **The style pass is only half applying.** In the browser: `.bdot` inline style is
160
- `background: rgb(95, 176, 201)` with **no `--pool`**, and `.bfill span` has `background`
161
- but **no width**, while `document.querySelectorAll('[data-w]')` counts 27 of which **2**
162
- have an inline width (the sync hero's, applied by app.js). So `applyMiningStyles` is
163
- running an older code path than the one on disk and served (`setProperty` and
164
- `applySizes` are both present in the served bytes, and `Cache-Control: no-cache`). That
165
- contradiction is unresolved — check whether the module the browser evaluates is the
166
- module the server sent (compare `import.meta` resolution / a marker constant), before
167
- touching the style code again.
168
- - **The flow row overflows its card** and is cut off: `.flow` scrollWidth 2236 inside
169
- clientWidth 1369. I added `.flow { width: max-content }` + `.flowwrap { overflow-x: auto }`;
170
- the browser still measured clipping after the change, so either the CSS did not apply as
171
- written or the grid parent constrains it. Re-measure `.flowwrap` rather than `.flow`.
172
-
173
- > **Superseded 2026-09-14:** the first two readings above were the harness measuring the
174
- > previous build, not the page — `Page.navigate` to a URL differing only in its fragment does not
175
- > reload the document (`docs/RULES.md` rule 25). Re-run against the current build on 2026-09-10,
176
- > `gnTreemap` and `gnMempoolTreemap` both painted 100% of their pixels.
177
-
178
- ### Notes on the harness itself
179
- - Chromium only survives inside one shell invocation, so launch + check must run together:
180
- `rm -rf /tmp/cp; (setsid /usr/bin/chromium-browser --headless=new --no-sandbox
181
- --user-data-dir=/tmp/cp --remote-debugging-port=9333 --ignore-certificate-errors
182
- about:blank &) ; until curl -s 127.0.0.1:9333/json/version >/dev/null; do sleep 2; done;
183
- BMC_MON_BASE=https://<lan>:8088 node scripts/browser-check.mjs mining`
184
- - Quote `--remote-allow-origins=*` or the shell globs it into filenames.
185
- - **`Page.navigate` to a URL differing only in `#fragment` does not reload the document.**
186
- Reusing a warm browser therefore re-measures whatever was loaded before the last deploy:
187
- `public/**` changes, the page does not, and every reading is of the previous build. The
188
- harness now appends `?t=<ms>` for this reason. Rule 25: prove the browser is running the
189
- bytes you served before believing anything it says about them.
190
- - Do not assert `document.body.firstChild` is an element. Leading whitespace before
191
- `<header>` is a `#text` node in every ordinary document; a probe that checked this
192
- "proved" the Overview rendered nothing when it had rendered fine throughout.
193
- - `Page.loadEventFired` is not reliably seen by the current waiter; the probe's
194
- **load guard** (abort unless `#nav` and body children exist) is what stops a broken
195
- invocation being reported as "the page is blank" — that happened once and the vision
196
- model confidently confirmed a blank white page that was only my own bad URL.
197
- - Vision: this deployment answers with `content: null` and the text in `reasoning`; reading
198
- only `content` silently yields an empty review.
199
- - `mempool-backend.service` has been `failed` since 2026-09-09 16:58 (start-limit hit after
200
- 12 restarts; its own stdout is not in the journal). Unrelated to the above, untouched.