Skip to content

feat(quantum + L105): finish the alignment build, add eml universal primitive#25

Draft
slavazeph-coder wants to merge 8 commits into
mainfrom
claude/review-quantum-alignment-tests-kmemI
Draft

feat(quantum + L105): finish the alignment build, add eml universal primitive#25
slavazeph-coder wants to merge 8 commits into
mainfrom
claude/review-quantum-alignment-tests-kmemI

Conversation

@slavazeph-coder

Copy link
Copy Markdown
Owner

Summary

Closes the gaps PR #22 left open and wires in Odrzywołek 2603.21852
"All elementary functions from a single binary operator" — as Layer 105 —
Universal Primitive Lab
plus a Python sibling. Bundles the prior three
quantum commits (Qiskit suite, L101, L102–L104) so this branch is a
self-contained landing zone if the team would rather merge from here than
from #22.

What was missing on claude/quantum-alignment-tests-lv0JM (PR #22)

  • Real-mode and ideal-mode Qiskit artifacts not committed (only noisy/ was)
  • Bell experiment lived only in the browser (L102), nothing in the Python suite
  • L104 Quantum Glossary had 0 unit tests
  • L103 Quantum Sweep had no onApplyToBrain wiring
  • No pytest harness for quantum_alignment_tests.py (708 lines untested)
  • requirements.lock flagged in README but never generated
  • PR feat(quantum-alignment): Qiskit suite + Layer 101 browser-native sibling #22 description / test plan stale relative to L102–L104

This branch fixes all of those and adds the eml content as a follow-on
layer that ties the three universality stories together.

Layer 105 — Universal Primitive Lab (browser)

  • utils/eml.js: core eml(x, y) = exp(x) − ln(y) + derivations of
    e, 0, π, exp, ln, +, , neg, mul, sqrt, sin, cos.
  • UniversalPrimitivePanel.jsx: live calculator side-by-side with Math.*,
    shows the eml composition tree per derivation, and frames a three-way
    universality bridge: NAND (Boolean) ↔ eml (continuous) ↔ {H, CNOT, T} (quantum).
  • 16 new tests in eml.test.mjs covering every derivation to ~1e-9.

Qiskit suite — Experiment 4: Bell-pair correlation sweep

  • bell_circuit + run_bell_experiment: |00⟩ → H ⊗ I → CNOT(0,1) → RY(θ) on q0 → measure both.
  • Sweeps θ ∈ {0, π/4, π/2, 3π/4, π}; signed correlation E(θ) = (P00+P11) − (P01+P10) matches cos(θ) to ≤0.04 even on noisy.
  • New --skip-bell CLI flag; report.md and results.csv extended with the Experiment 4 table.

Python tests + repro

  • eml.py mirrors the JS port + reference_table() helper.
  • test_eml.py: 45 parametrized cases.
  • test_quantum_alignment_tests.py: 17 fast tests (counts aggregation, every circuit constructor, CSV round-trip, parse_args, select_backend); 1 slow @pytest.mark.slow test runs the full ideal AerSimulator pipeline.
  • pytest.ini registers the slow marker; fast lane stays sub-second.
  • requirements.lock pins the 2026-04-30 snapshot for reproducible runs.

Layer 103 — Apply-to-brain

  • sweepBrainDeltas(summary) maps PFC/AMY/THL/HPC/BG/CBL/CTX from avgCoherence / maxError / rangeP0 / avgError / n. Wired in App.jsx; toast + scenario label match the L101 / L102 pattern.

Layer 104 — Glossary

  • TERMS / category data extracted into utils/quantumGlossary.js so the
    data is testable without a JSX runtime.
  • New "Universal gate set" entry citing arXiv:2603.21852 alongside NAND
    and {H, CNOT, T}.
  • 9 new tests in quantumGlossary.test.mjs.

Pre-generated artifacts

  • results/ideal/* and results/noisy/* are now both checked in (the
    previous tree only had noisy at the root).
  • --mode real is run by the user against a live IBM account; nothing
    from a real run is committed.

Test plan

  • npm run test:quantum66/66 (was 39/39)
  • npm run build — ✓ (676 KB index, ~10 KB delta for L105)
  • python -m pytest -q62 passed in ~3.5s
  • python -m pytest -q -m slow — 1 passed (e2e ideal smoke)
  • python quantum_alignment_tests.py --mode ideal --shots 4096 --out results/ideal — 4 artifacts written
  • python quantum_alignment_tests.py --mode noisy --shots 4096 --out results/noisy — 4 artifacts written
  • Manual browser QA — open the app, scroll to:
    • L101 Quantum Coherence Lab: θ sweep, noise slider, observe-midway, X·X depth, Scientific↔Metaphor toggle, Apply-to-brain
    • L102 Bell Pair Lab: θ slider, noise slider, joint bars, signed correlation, Apply-to-brain
    • L103 Quantum Sweep: phase/noise/depth picker, chart, Download CSV, Apply to brain (new)
    • L104 Quantum Glossary: search "bell", "Hadamard", "Universal" — last should match the new entry citing 2603.21852
    • L105 Universal Primitive Lab (new): switch fns (exp, ln, sin, …), watch eml-side and Math.* agree to ~1e-9, derivation card updates
  • Real-hardware Qiskit run (--mode real) — owner has IBM Quantum account

Reference

  • Odrzywołek, A. — All elementary functions from a single binary operatorarXiv:2603.21852

🤖 Generated with Claude Code


Generated by Claude Code

claude added 8 commits April 30, 2026 16:55
Adds quantum_alignment/ with a single-file Qiskit harness that runs three
experiments (H-RZ-H interference sweep, mid-circuit measurement vs HH,
deepening identity X-X chains) across three execution modes (ideal Aer,
noisy Aer from a synthetic fake backend, and real IBM hardware via
qiskit-ibm-runtime when IBM_QUANTUM_TOKEN is set). Outputs CSV, two
matplotlib plots, and a plain-English report. README documents safe token
handling and explicitly frames the suite as a test of quantum phase
coherence/interference/noise -- not literal multiverse theory.
…e Qiskit suite

Completes the in-browser side of the quantum-alignment work that landed in
6325d38 (which shipped only the Python/Qiskit harness under
quantum_alignment/). The original task asked for "browser-native first, no
backend, simulate locally in JavaScript" — that part wasn't built. This adds:

- src/utils/quantumCoherence.js: complex/H/X/Z/RZ helpers, three
  experiments (phase / observation / decoherence) shaped to mirror the
  Qiskit circuits in quantum_alignment/quantum_alignment_tests.py, simple
  dephasing + bit-flip noise, coherenceScore, and mapQuantumToBrainState
  (PFC↑ coherence · AMY↑ noise · THL↑ routing · HPC↑ survival ·
  BG↑ dominance · CBL↑ correction · CTX↑ complexity).
- src/components/QuantumCoherencePanel.jsx: theta / shots / noise /
  depth / observe-midway controls, scientific ↔ metaphor mode toggle,
  P(0)/P(1) bars, coherence score 0–100, plain-English explanation,
  circuit-row visualization. Cross-links the Qiskit suite as the
  hardware-grade offline path.
- App.jsx: wired with onApplyToBrain that nudges the 7 region levels.
- layerCatalog: registered as L101 with new "experimental" group.
- Tests: 18 cases via node:test (theta=0/π, observation, decoherence,
  noise/depth scaling, brain mapping). `npm run test:quantum`.
- Docs: README section explicitly disclaims literal multiverse /
  consciousness / Planck / spiritual claims; cross-references the Qiskit
  suite for hardware runs. No vendor API keys in the frontend — IBM
  tokens stay in the Python suite (IBM_QUANTUM_TOKEN at runtime).

npm install + npm run build pass.

https://claude.ai/code/session_01VYArf8MTS6QdhmswtqNPox
Completes the quantum cluster on top of L101. All three layers are
browser-native, no backend, no vendor API keys.

Layer 102 — Bell Pair Lab
- bellPair.js: 2-qubit state (4 amplitudes), H/X/RY/RZ-on-qubit, CNOT,
  joint distribution + sampling, signed correlationStrength.
- runBellPairExperiment: |00⟩ → H ⊗ I → CNOT(0,1) → optional RY(θ) on
  qubit 0 → joint measurement. Depolarizing noise mixes the pure
  distribution with uniform [0.25 × 4] by weight `noise`.
- mapBellToBrainState: HPC↑ correlation, PFC↑ |correlation|, CTX↑ shots,
  AMY↑ noise, THL↑ rotation, BG↑ dominance, CBL↑ noise·(1-|corr|).
- BellPairPanel: RY-θ slider, noise slider, shots picker, joint bars
  for |00⟩|01⟩|10⟩|11⟩, signed correlation strength card, ASCII circuit
  diagram, Scientific ↔ Metaphor mode, Apply-to-brain.
- 12 tests covering Hadamard / CNOT / Bell construction / rotation
  breakdown / noise damping / brain mapping bounds.

Layer 103 — Quantum Sweep
- quantumSweep.js: runSweep(kind: 'phase' | 'noise' | 'depth'), CSV
  serialization with the same column shape as
  quantum_alignment/results/results.csv, sweepSummary stats.
- QuantumSweepPanel: kind picker, steps / shots / fixed-noise / fixed-θ /
  max-depth controls, inline SVG line chart of P(0) / P(1) vs the ideal
  curve, "Download CSV" button.
- 9 tests covering sweep correctness, CSV escaping, summary math.

Layer 104 — Quantum Glossary
- QuantumGlossaryPanel: searchable reference card (23 terms across
  states / gates / processes / noise / metrics) with plain-language,
  math, and metaphor columns side-by-side. Complements the Metaphor
  toggle in L101 and L102.

L101 noise model
- Replaced random per-gate bit-flips with a single depolarizing-style
  distribution mix (matches L102 / L103). This makes runs deterministic
  in expectation, fixes a flaky decoherence test, and aligns with the
  "noise = mix toward uniform" reading the panel and glossary teach.

Wiring
- App.jsx: 3 new ErrorBoundary blocks, L102 wired with onApplyToBrain.
- layerCatalog.js: L102 / L103 / L104 registered under the experimental
  group.
- README.md: file-map rows for 102/103/104; Quantum Coherence Lab
  section gains a "cluster siblings" subsection summarizing all three.
- package.json: test:quantum runs all three test files.

39/39 tests pass (`npm run test:quantum`). `npm run build` ✓ — index
bundle 648 → 676 KB (+27 KB / +7 KB gzipped) for three new layers.

https://claude.ai/code/session_01VYArf8MTS6QdhmswtqNPox
Closes the gaps PR #22 left open and wires in
Odrzywołek 2603.21852 — "All elementary functions from a single binary
operator" — as Layer 105 plus a Python sibling.

Layer 105 — Universal Primitive Lab (browser)
- utils/eml.js: eml(x, y) = exp(x) - ln(y) plus the constant 1, with
  derivations for e, 0, pi, exp, ln, +, -, neg, mul, sqrt, sin, cos.
- UniversalPrimitivePanel.jsx: live calculator side-by-side with Math.*,
  shows the eml composition tree per derivation, and frames a three-way
  universality bridge: NAND (Boolean) <-> eml (continuous) <-> {H, CNOT, T}
  (quantum).
- 16 new tests in eml.test.mjs covering core operator + every derivation
  to ~1e-9 precision. Wired into npm run test:quantum.

Qiskit suite — Experiment 4: Bell-pair correlation sweep
- bell_circuit + run_bell_experiment: |00> -> H ⊗ I -> CNOT(0,1) ->
  RY(theta) on q0 -> measure both. Sweeps theta in {0, pi/4, pi/2,
  3pi/4, pi}; signed correlation E(theta) = (P00+P11) - (P01+P10)
  matches the closed-form ideal cos(theta).
- New --skip-bell CLI flag; report.md and results.csv extended with the
  Experiment 4 table.
- New eml.py mirroring the JS port + reference_table() helper.

Python tests
- test_eml.py: 45 cases via pytest parametrize, all to 1e-9.
- test_quantum_alignment_tests.py: 17 fast tests covering counts
  aggregation, probability math, every circuit constructor, CSV
  round-trip, parse_args, select_backend behaviour; 1 slow test gated
  by @pytest.mark.slow runs the full ideal AerSimulator pipeline.
- pytest.ini registers the slow marker so the fast lane stays sub-second.
- requirements.lock pinned for reproducible CI / hardware runs.

Layer 103 — onApplyToBrain
- sweepBrainDeltas(summary) maps PFC/AMY/THL/HPC/BG/CBL/CTX from
  avgCoherence / maxError / rangeP0 / avgError / n. App.jsx wires the
  button; toast + scenario label match the L101 / L102 pattern.

Layer 104 — Quantum Glossary
- TERMS / category data extracted into utils/quantumGlossary.js so it is
  testable without a JSX runtime.
- New "Universal gate set" entry citing arXiv:2603.21852 alongside NAND
  and {H, CNOT, T}.
- 9 new tests in quantumGlossary.test.mjs.

Pre-generated artifacts
- results/ideal/* and results/noisy/* are now both checked in (the
  previous tree only had noisy at the root). --mode real is run by the
  user against a live IBM account; nothing from a real run is stored.

Test totals
- npm run test:quantum: 39/39 -> 66/66 (all green).
- python -m pytest -q: 0 -> 62 (fast lane); -m slow adds 1 e2e test.
- npm run build: ✓ (676 KB index, ~10 KB delta for L105).

The PR description on #22 is stale relative to L102-L105 and the manual
QA boxes were never ticked. This commit lands on
claude/review-quantum-alignment-tests-kmemI; a follow-up PR description
should reflect the new scope.

https://claude.ai/code/session_014cPeirgJpbbt2LtDCPVD9i
…cluster

Lands the three follow-on layers that close the universality bridge,
plus the production-hardening items (CI workflow, eml REPL, results
JSON schema).

Layer 106 — NAND Lab
- utils/nand.js: NAND primitive + derived NOT / AND / OR / NOR / XOR /
  XNOR / 2-to-1 MUX. Every derivation uses ONLY nested nand calls and
  the literals 0 / 1 — no native &&, ||, !, or === in the function
  bodies.
- NandLabPanel.jsx: live truth-table builder, derivation tree per gate,
  three-way universality bridge card.
- 9 tests in nand.test.mjs pin every derived gate against JS native
  logic across all 2^arity inputs.

Layer 107 — GHZ Lab
- utils/ghzState.js: 3-qubit state vector (8 amplitudes), H / X / CNOT
  on indexed qubit, joint distribution + sampling, depolarizing noise
  toward uniform 1/8, parity metric P(000)+P(111).
- runGhzExperiment: |000⟩ → H ⊗ I ⊗ I → CNOT(0,1) → CNOT(0,2) gives
  (|000⟩+|111⟩)/√2 with parity 1.0 ideal, 1/4 fully randomised.
- mapGhzToBrainState: same 7-region scheme as L102 / L103.
- GhzLabPanel.jsx: noise slider, 8-bin joint distribution bars (★ on
  the two correlated kets), parity / leakage metrics, Apply-to-brain.
- 11 tests in ghzState.test.mjs.

Layer 108 — Solovay-Kitaev mini-demo
- utils/solovayKitaev.js: 2x2 complex unitaries, Hadamard / T / T†, RZ,
  multiplication, Frobenius distance modulo global phase. Brute-force
  basic-approximation step over {H, T, T†} sequences up to length L,
  with cancelling-pair pruning. approximationReport(theta, maxLen)
  returns the convergence series.
- SolovayKitaevPanel.jsx: theta slider, L slider (capped at 8 because
  brute force is 3^L), inline SVG convergence chart, sequence + distance
  table.
- 15 tests in solovayKitaev.test.mjs (H·H = I, T^8 = I, distance is
  symmetric, exact match for π/4 reachable in 1 T, monotone convergence
  with L, …).

Wiring
- layerCatalog.js: L106 / L107 / L108 registered under experimental.
- App.jsx: 3 new ErrorBoundary blocks. L107 wired with onApplyToBrain.
- README.md: file-map rows + "cluster siblings" entries for all three.
- package.json: npm run test:quantum runs all 8 quantum test files.

Python sibling — nand.py
- Mirrors the JS NAND primitive + derivations.
- test_nand.py: 12 cases plus a cross-bridge test asserting that
  UNIVERSALITY_BRIDGE in nand.py is byte-identical to eml.py
  (nand.py re-exports the dict from eml.py to make drift impossible).

eml REPL CLI — eml_cli.py
- python -m eml_cli '<expression>' for one-shot evaluation
- python -m eml_cli for an interactive prompt
- A tiny purpose-built tokeniser + recursive-descent parser; no eval.
- Allowed identifiers are a registry of eml + nand functions plus the
  three constants e, pi, zero.
- Operators +, -, *, /, ^ map to eml_add / eml_sub / eml_mul (when
  both operands positive) / division / eml_pow.
- 12 tests in test_eml_cli.py covering tokens, constants, calls, op
  precedence, boolean predicates, error paths, and main exit codes.

results_schema.json — JSON Schema for results.csv
- Pins the 11 column names + types + the four-experiment enum.
- test_results_schema.py: schema is valid JSON, lists all four
  experiments, columns match the writer (CSV_FIELDS == required), and
  every row of the committed ideal/results.csv validates against it
  (slow lane, jsonschema-gated).

CI workflow — .github/workflows/quantum-tests.yml
- Triggers on pushes / PRs that touch any quantum / eml / nand file or
  the workflow itself.
- Three jobs:
  - js: npm run test:quantum (101 tests) + npm run build
  - python-fast: pytest -q (100 tests, sub-4s, no AerSimulator)
  - python-slow: pytest -q -m slow (ideal AerSimulator e2e) plus the
    schema validation test, with jsonschema installed.
- Uses pinned requirements.lock for reproducible installs.

Test totals
- JS: 66 → 101 tests
- Python fast: 62 → 100 tests
- Python slow: still 1 (e2e ideal smoke)
- npm run build: ✓ (704 KB index, +18 KB for L106–L108)

The cluster narrative now spans Boolean (L106 NAND) → continuous
(L105 eml) → quantum (Bell L102 / GHZ L107 / SK L108), with the
Qiskit suite providing hardware-grade Bell + phase + observation +
decoherence (the four committed experiments under quantum_alignment/).

https://claude.ai/code/session_014cPeirgJpbbt2LtDCPVD9i
…lass

notes with the cognitive firewall built in

Path A (cognitive-firewall + knowledge) lit up; the load-bearing pieces
of B (vault, wikilinks, backlinks, graph, search, daily, import/export)
shipped together so brainsnn.com can launch as a real Obsidian
alternative — not a marketing tease.

Layer 109 — Vault
- utils/vault.js: localStorage-backed store with abstract { get, set,
  remove, keys } backend (memoryBackend for tests, localStorageBackend
  for the browser, IndexedDB drop-in possible later). One key per note
  (`brainsnn_vault_note_<id>`) plus a single index key. Slug-based
  ids with collision suffixing, importBundle / exportBundle round-trip,
  16-tag cap, stats() returning noteCount / bytes / unique tags.
- utils/vaultMarkdown.js: minimal markdown → safe HTML, with
  [[wikilinks]], [[Real|Alias]], #tags, code fences, blockquotes,
  ordered + unordered lists. Every untrusted substring escaped before
  interpolation. resolveWikilink() callback toggles "found" vs
  "missing" classes for broken links.
- utils/vaultGraph.js: extractWikilinks → directed edge list,
  backlinksByNoteId, missing wikilink summary, in/out degree per node,
  case-insensitive title resolution, simple force-directed layout
  (200 iterations, suitable for browser-side few-hundred-node graphs).
- utils/vaultSearch.js: prefix + contains + subsequence + body-word +
  tag matching with a deterministic score model.
- utils/vaultDaily.js: ensureDailyNote(vault) creates / opens today's
  note (ISO date title, ##Today / ##Notes template, `daily` tag).
- VaultPanel.jsx: full Obsidian-style three-pane experience —
  sidebar with search + per-note autocomplete, split editor /
  live-preview, [[wikilink]] autocomplete on `[[`, click-to-create
  flow when a wikilink doesn't exist yet, tag editor, backlinks pane,
  broken-link footer, import .md / .json, export JSON, delete with
  confirm — and a CognitiveFirewallScoreCard rendered for any body
  ≥ 5 words. The differentiator: the firewall doesn't only score
  pasted external content; it scores everything you write.

Layer 110 — Vault Graph
- VaultGraphPanel.jsx: lightweight 2D SVG force-directed view of the
  link graph. Node radius scales with in+out degree. Clicking a node
  highlights it and its incident edges. Refresh button + iterations
  slider. Listens for window focus to repick up changes from the
  Vault panel without a full reload.

Layer 111 — Daily Notes
- "Today's note" button inside VaultPanel, with ensureDailyNote()
  doing the deterministic open-or-create. Idempotent across multiple
  clicks on the same day (stable ISO-date slug).

Wiring
- layerCatalog.js: L109 / L110 / L111 registered under `data` group.
- App.jsx: 2 new ErrorBoundary blocks for VaultPanel + VaultGraphPanel.
- package.json: new test:vault script (5 files), test:all = quantum + vault.
- README.md: file-map rows for 109 / 110 / 111.
- DEPLOY.md: new §8 covering brainsnn.com launch — recommended split
  (apex = marketing, app.brainsnn.com = R3F app), pre-launch smoke
  test, manual vault QA checklist, and a localStorage-quota note with
  the upgrade path to IndexedDB.

Test totals
- JS quantum: 101 (unchanged)
- JS vault: 71 NEW
  - vault.test.mjs: 19 (CRUD, slug uniqueness, importBundle/exportBundle,
    persistence, corrupted-index recovery, tag cap, stats)
  - vaultMarkdown.test.mjs: 21 (escapeHtml, extract*, wordCount, render
    paragraph/headings/lists/code/blockquote/wikilinks/aliases/tags;
    XSS safety: <script> escaped, javascript: links dropped to #)
  - vaultGraph.test.mjs: 12 (edges, missing, in/out degree, backlinks,
    forward links, tag index, layout bounds, case-insensitivity)
  - vaultSearch.test.mjs: 13 (exact > prefix > body, tag match via
    explicit and #body, subsequence fallback, autocomplete prefix order)
  - vaultDaily.test.mjs: 6 (isoDate padding, template substitution,
    idempotent ensureDailyNote across calls)
- npm run build: ✓ (727 KB index, +23 KB for L109–L111)

Storage discipline
- One key per note + an index key. Roughly 2k–3k notes per browser
  before the 5MB localStorage budget gets tight. The vault is
  storage-agnostic (`{ get, set, remove, keys }` backend), so the
  upgrade to IndexedDB is a one-file swap when users hit that ceiling.

Cognitive-firewall integration
- Every save (or live edit ≥ 5 words) runs scoreContent(body) and
  surfaces a four-bar card under the editor: emotional activation,
  cognitive suppression, manipulation pressure, trust erosion. This
  is the load-bearing differentiator vs Obsidian — your *own* notes
  get audited, not just inbound text.

Architectural notes
- VaultPanel and VaultGraphPanel each instantiate `createVault(...)`
  against the same shared localStorage backend; the graph picks up
  changes via the window 'focus' listener and a manual Refresh button.
  A future commit can promote the vault to a top-level singleton
  exported from utils/vault.js if the cross-panel coupling becomes
  hot-path; right now both views work fine.
- The markdown renderer is intentionally minimal — no remark/marked
  dep added — so the vault carries no new third-party surface area.
  XSS is closed by escaping every untrusted substring before it lands
  in the rendered HTML.

Launch readiness for brainsnn.com
- Recommended domain layout: apex = marketing site (ui/brainsnn-site,
  static, fast TTFB), app.brainsnn.com = this Railway service.
- Manual QA checklist in DEPLOY.md §8b. The five must-pass items are:
  (1) wikilink autocomplete works, (2) clicking a missing wikilink
  creates the target, (3) firewall card appears on a 5+-word note,
  (4) graph picks up new notes on Refresh, (5) "Today's note" is
  idempotent.

https://claude.ai/code/session_014cPeirgJpbbt2LtDCPVD9i
Closes the four follow-ups from the L109–L111 commit in one go.

1. Shared vault singleton + cross-panel reactivity
- utils/vault.js: exports `sharedVault`, `subscribeVaultChanges()`,
  `notifyVaultChanged()`. Uses a `brainsnn:vault-changed` window event
  so panels in different React trees see saves from each other without
  polling or focus-listener tricks.
- VaultPanel + VaultGraphPanel: drop their per-panel `createVault(...)`
  instances and import `sharedVault` instead. The graph re-renders
  automatically the moment the editor saves.
- KnowledgeBrainPanel: subscribes too, so the "Scan vault (N)" button
  count updates live as you create / delete notes.

2. L18 Knowledge Brain ← L109 Vault
- knowledgeScanner.js: new `vaultNotesToDocuments(notes)` adapter
  shapes vault notes into the same `{ title, content, path, tags }`
  surface that classifyDocuments / buildKnowledgeMap consume.
- KnowledgeBrainPanel: new `Scan vault (N)` button alongside the
  existing inventory / JSON / tree / Obsidian inputs. Auto-disabled
  when the vault is empty; tooltip explains. Closes the L18 ↔ L109
  integration loop — L18 stops requiring a hand-pasted file inventory
  and audits the user's own notes for domain coverage.

3. PWA upgrades — vault-aware shortcuts + cache bump
- public/sw.js: CACHE_VERSION 'brainsnn-v1' → 'brainsnn-v2'. Old
  shells evict on activate. SHELL_URLS now includes
  /manifest.webmanifest so first install is fully offline-ready.
- public/manifest.webmanifest: description rewritten to lead with the
  vault story; new shortcuts `Today's note` (`/?vault=today`) and
  `New note` (`/?vault=new`); existing Scan + Daily Challenge kept.
- VaultPanel: reads `?vault=today` / `?vault=new` on mount and routes
  into the right action (ensureDailyNote / create-untitled). PWA
  long-press lands users directly in the editor.

4. CodeMirror 6 editor for the vault
- New components/VaultEditor.jsx: CM6 EditorView with
  - markdown syntax highlighting (`@codemirror/lang-markdown`)
  - active-line highlight + line numbers + line wrapping
  - undo/redo with proper history (per-note, remounts on noteId)
  - find/replace via the search keymap (Ctrl-F)
  - bracket auto-close (`closeBrackets`) — `[[` opens both halves
  - bespoke wikilink completion source: typing `[[Foo` triggers an
    autocomplete list of matching note titles; Enter inserts
    `Foo]]` with the cursor positioned after the closing brackets
  - dark theme tuned to the BrainSNN palette
- VaultPanel: replaces the textarea with `<VaultEditor>`. The custom
  React-side autocomplete state and the `editorRef` are gone —
  CodeMirror handles its own popup, so a chunk of dead code goes
  with this commit.
- The editor is `lazy()` + Suspense-wrapped so CM6's ~570 KB chunk
  (~195 KB gzipped) is fetched on demand. First paint of the app
  doesn't pay for it, and the main bundle stays at 727 KB. The
  fallback shows a "Loading editor…" hint while the chunk arrives.

5. Marketing site (ui/brainsnn-site) refresh for launch
- constants/site.js: tagline rewritten to lead with the vault
  positioning ("Local-first knowledge vault with a cognitive firewall
  on every note."), new `subtagline` line ("Obsidian audits your
  folders. BrainSNN audits your thinking…"), new `appUrl`
  (`https://app.brainsnn.com`). New WHY_CARDS that lead with the three
  defensible angles: cognitive firewall on every note, local-first +
  no accounts, three-way universality bridge (NAND ↔ eml ↔ {H,CNOT,T}).
- src/App.jsx: hero CTA flips from `Live Demo` (anchor link) to
  `Open the app →` (links to `appUrl`); hero copy rewritten to
  describe the vault + 110+ layers + no telemetry.
- DEPLOY.md §8 (from previous commit) covers the recommended split:
  apex = marketing site, app.brainsnn.com = R3F service.

Bundle sizes
- Main app index: 727 KB (was 727 KB) — unchanged thanks to lazy CM
- VaultEditor chunk: 568 KB raw / 195 KB gzipped — only loaded on first
  note open
- Marketing site: 43 KB main + 1.1 MB three.js (unchanged)

Test totals
- JS quantum: 101/101 (unchanged)
- JS vault: 71/71 (unchanged)
- Python pytest fast: 100/100 (unchanged)
- npm run build (R3F app): ✓
- npm run build (marketing site): ✓

Launch impact
- L109 + L110 + L111 vault now ships with a real editor, not a textarea.
- L18 audits the vault as a corpus.
- PWA shortcuts land users in the right view from the OS launcher.
- The marketing site's hero now matches the product story.

https://claude.ai/code/session_014cPeirgJpbbt2LtDCPVD9i
After the CNAME flip, the R3F app is reachable at app.brainsnn.com.
The bookmarklet, the MV3 extension generator, and the curl examples
in the API docs were all pointing at brainsnn.com (the apex), which
will become the marketing site once Pages takes over the apex.

- New utils/appHost.js exporting APP_HOST + MARKETING_HOST as the
  single source of truth.
- extensionSource.js: MV3 BACKGROUND BASE + README copy use APP_HOST.
- ScanAnywherePanel.jsx: bookmarklet src uses APP_HOST.
- ApiDocsPanel.jsx: curl example uses APP_HOST.

When the apex eventually flips to the marketing site, the bookmarklet
and "Scan with BrainSNN" extension still resolve correctly because
they always point at app.brainsnn.com directly.

No new tests needed — these are constant rewrites; the build passes
and the bundle size is unchanged (lazy CM chunk still 195 KB gzipped,
main bundle still 727 KB).

https://claude.ai/code/session_014cPeirgJpbbt2LtDCPVD9i
slavazeph-coder pushed a commit that referenced this pull request May 2, 2026
Roll the homepage repositioning across the in-product app, build the
Brand Risk Scorecard layer, and replace the homepage gallery
placeholders with real scan illustrations.

brainsnn-r3f-app
- index.html title + og + twitter meta now lead with "affective-
  intelligence engine" and the four-outcome positioning sentence.
- OnboardingWalkthrough STEPS rewritten — step 1 leads with the
  positioning sentence, the Cognitive Firewall is framed as "the
  engine," the new Brand Risk Scorecard gets its own step, and the
  ordering puts the engine before the visualization layer.
- MilestonePanel intro paragraph updated to the new framing.
- Layer 106 (Brand Risk Scorecard) added to layerCatalog and mounted
  in App.jsx behind an ErrorBoundary, after the Milestone panel.

L106 — Brand Risk Scorecard
- src/utils/brandRisk.js: splitItems / scoreItem / computeBrandRisk /
  brandBriefMarkdown. Pure functions, no side effects. Aggregates
  Cognitive Firewall (L4) + Propaganda Templates (L39) + Ad
  Transparency archetypes (L48) into a single 0–100 score with a
  4-tier classification (Clean / Watch / At risk / Critical).
- src/components/BrandRiskPanel.jsx: brand input + items textarea +
  load-sample helper, headline score card, dominant archetypes,
  most-fired templates, top 5 worst items, copy-brief-as-Markdown.
- Score formula: 60% mean pressure + 25% peak pressure + 15% high-
  risk archetype share. High-risk archetypes: abusive-domestic,
  phishing, conspiracy-hook, political-attack, cult-recruitment.
- Number 106 picked to avoid colliding with the open L101 PRs (#22,
  #24, #25 — see PR #27 description for the suggested resolution).

ui/brainsnn-site gallery
- public/scan-fear-cascade.svg, scan-certainty-theater.svg, and
  scan-affective-trajectory.svg — three hand-rolled SVG cards that
  match the new gallery copy. 4-dim score bars, brain proxy with the
  appropriate region glowing, evidence chips.
- GALLERY_ITEMS now carries an `image` field; App.jsx reads it with
  the demo-placeholder.svg as a fallback.

Builds
- npm run build --prefix ui/brainsnn-site — 624 modules, 8.03s, clean.
- npm run build --prefix brainsnn-r3f-app — 912 modules, 6.19s, clean.

https://claude.ai/code/session_brainsnn-ui-build-28ebr
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