Brick Heart: handover, offline pack bench
1. State
Verified (your bench run, subject 1, ?step=9):
- Install: 4021 of 4021 files, 1.5 s.
- Origin storage: 13.7 MiB (whole origin, includes the sql.js DB).
- Run: 196 of 1759 stems, closure 899 files, 0 missing, closure 114 ms, geometry 2522 ms, 18,092 triangles, 0 failures.
- JS heap: 110.9 MiB.
- The
r:1flag works:listStemsreturned 1759. dist/data/ldrawis served, so thebuild.mjscopy block works.
Inferred, not tested:
- The hook serves every request.
bench-build.mjsv2 wipesdist/benchand writes no/bench/ldrawtree, and there were 1 failures. Applying inline style violates the following Content Security Policy directive 'style-src 'self''. Either the 'unsafe-inline' keyword, a hash ('sha256-BT3cCquDgSz1RSD7tm34sX+FhZxo0u2myqBEoq1Ginw='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. The action has been blocked.
-
Run
?all=1, and report time and heap. installing: 2157/2157 files installed in 0.9 s storage usage (whole origin): 18.1 MiB stems 923 of 923, closure 2157 files, missing 0 closure 245 ms, geometry 10230 ms, 80,040 triangles failures 0: JS heap 301.9 MiB (Chromium only) -
npm run typecheck
app@0.0.0 typecheck tsc --noEmit
src/bench/ldraw-store.ts:154:20 - error TS2345: Argument of type 'DecompressionStream' is not assignable to parameter of type 'ReadableWritablePair<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBufferLike>>'. Types of property 'writable' are incompatible. Type 'WritableStream<BufferSource>' is not assignable to type 'WritableStream<Uint8Array<ArrayBufferLike>>'. Type 'BufferSource' is not assignable to type 'Uint8Array<ArrayBufferLike>'. Type 'ArrayBuffer' is missing the following properties from type 'Uint8Array<ArrayBufferLike>': BYTES_PER_ELEMENT, buffer, byteOffset, copyWithin, and 29 more.
154 .pipeThrough(new DecompressionStream('gzip')) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in src/bench/ldraw-store.ts:154
npm error Lifecycle script typecheck failed with error:
npm error code 2
npm error path /home/chinapal/brickheart-web/app
npm error workspace app@0.0.0
npm error location /home/chinapal/brickheart-web/app
npm error command failed
npm error command sh -c tsc --noEmit
Not done:
- The blocked-network test (
*/data/ldraw/*). - Install of subjects 2 and 3, and shared-file dedup on removal.
removeSubject, interrupted installs andpersist()results (thepersist()result printed but was not pasted).- A true offline reload, which needs the service worker.
- Cloudflare
Content-Encodingon.gzis untested, because it has not been deployed. engineRotFromLdrawand the stockLDrawLoaderversus classmare still unresolved (2fmu4y60objlb.jslines 160 to 190).
2. Decisions made
- No stripping. Packs hold the text as read.
- Option B.
filesis keyed by normalised name and shared across subjects. Amembersstore keyed[subject, name]has an index onnameand anrroot flag. Removal deletes a file only when no member row remains. - Pack format.
subject-N.jsonl.gz, one line per file:{n, d, t, r?}.ldconfig.ldris in every pack. - Packer checks. It verifies that shared files are identical across subjects. The last run passed: 4,674 distinct names against 8,765 summed, 10.25 MiB gzip in total.
- Persistence. The tap handler calls
requestPersistence()explicitly, before the install. - Bench source. The bench takes its parts from the installed pack, with no excavator and no MPD.
3. Files (all in app/)
ldraw_pack.py, at/home/chinapal/brickheart/rebrickable/. It is the full rewrite.src/bench/ldraw-store.ts, the full rewrite.src/bench/ldraw-hook.ts, which patchesFileLoader.prototype.loadfor/bench/ldraw/URLs.src/bench/offline.ts, which imports from./geometry.src/bench/geometry.ts, your loader module, withBASE = '/bench/ldraw'. The hook has its own copy of that string, so the two must match.build.mjs, with the pack copy block.bench-build.mjsv2, which buildsdist/bench/offline/.
Build order: npm run build, then node bench-build.mjs, then npm run preview. Open /bench/offline/?subject=1&step=9.
4. Next session
- Run the blocked-network test: block
*/data/ldraw/*, reload, click Run, and confirm that no ldraw requests appear and the results match. - Install subjects 2 and 3, then remove subject 1. Confirm that files shared with 2 and 3 survive, using
?parts=on a shared part. - Test an interrupted install (abort mid-download, reload, and confirm
cleanupInterruptedran) and a quota failure. - Read
2fmu4y60objlb.jslines 160 to 190 for the realengineRotFromLdraw. Do this withsed -n '160,190p'andcut -c1-3000, or run prettier on a copy. - Move on to the service worker, so that a real offline reload is possible.
After that, in order:
- The
?set=build page and the palette (needs your approval of theui.jsonkeys). - Connector-based PLACE (needs
2fmu4y60objlb.jslines 205 to 337 and theconnections.jsonformat). - The colour modes.
5. Cautions
- Don't guess. Ask for the command output instead.
- Mark anything unverified. British spelling.
- All visible text in the real app goes through
site/ui.jsonwith your approval. The bench is English only and not shipped. - The sql.js CSP uses
'wasm-unsafe-eval', not'unsafe-eval'. - Cloudflare limits are 25 MiB per file and 20,000 files, and generated artefacts must be committed.
- Don't assume the tooling. The app is built with
build.mjs(esbuild) and previewed withwrangler dev. - Give whole files, not patches when many edits are required that arent simple additions or function replacements.