@gamaze/hicortex 0.29.0 → 0.29.2

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.
@@ -4,37 +4,44 @@
4
4
  HICORTEX DASHBOARD — the #644 four-quadrant console (prototype F, blue-teal
5
5
  light theme), rebuilt in place on the same data layer as the #409 console.
6
6
 
7
- LAYOUT CONTRACT (#644): a 52 px header row plus a 2×2 quadrant grid
8
- (1fr 1fr / 1fr 1fr, 14 px gaps). At ≥1080 px the page fits the viewport
9
- with overflow hidden and nothing but a quadrant's body scrolls; below
10
- 1080 px the quadrants stack one-column with a ~420 px minimum height.
7
+ LAYOUT CONTRACT (#644; #648 item 8 swapped the right column — Brain
8
+ top-right, Analytics bottom-left): a 52 px header row plus a 2×2 quadrant
9
+ grid (1fr 1fr / 1fr 1fr, 14 px gaps). At ≥1080 px the page fits the
10
+ viewport with overflow hidden and nothing but a quadrant's body scrolls;
11
+ below 1080 px the quadrants stack one-column with a ~420 px minimum
12
+ height.
11
13
 
12
14
  Agents (top-left) — one row per observed agent: machine, space badges
13
15
  (assign/unassign popovers), capture presence,
14
- last-seen. Flat / Space / Machine grouping, the
15
- Spaces·N panel (assign/remove only), the Agents
16
- gear (capture-pause per bundle).
17
- Analytics (top-right) — the pipeline strip (queue depth + echoed warn
18
- age, last nightly run, consolidation outcome),
19
- three tiles with 15/15 delta math, the 30-night
20
- token chart (distill solid / consolidation
21
- dashed, backfill nights as gaps), memories by
22
- topic. No range selector: fixed 30-night views
23
- (the server's own defaults hold; the #452 pills
24
- are dropped).
25
- Brain (bottom-left) — memory precision (zone chip over the echoed
16
+ last-seen. Flat / Space / Machine grouping (the
17
+ machine view's Pre-tracking bucket — pre-stamp
18
+ agents — collapses by default, #648 item 1),
19
+ the Spaces·N panel (assign/remove only), the
20
+ Agents gear (capture-pause per bundle).
21
+ Brain (top-right) — memory precision (zone chip over the echoed
26
22
  recall_uses edges, tier-1 tiles with MP_GOOD
27
23
  valence, the pastel health band with stops at
28
24
  the echoed thresholds), model kv (the Brain gear
29
- opens the model modal), corpus kv, nightly
30
- budget. Contested rides the presence-gated chip
31
- + drawer.
25
+ opens the model modal), corpus kv. Contested
26
+ rides the presence-gated chip + drawer.
27
+ Analytics (bottom-left) — the pipeline strip (queue depth + echoed warn
28
+ age, last nightly run, consolidation outcome),
29
+ three tiles with 15/15 delta math, the 30-night
30
+ token chart (distill solid / consolidation
31
+ dashed, backfill nights as gaps, the derived
32
+ 1/2/5 vertical scale — #648 item 7), memories
33
+ by topic, nightly budget (moved here from Brain,
34
+ #648 item 9). No range selector: fixed 30-night
35
+ views (the server's own defaults hold; the #452
36
+ pills are dropped).
32
37
  Brain map (bottom-right) — the SAME field engine, in presence mode: the
33
- canvas, the domain legend, and the replay
34
- timeline strip. Hover tooltips only (inspection
35
- lives in /viz, one expand-icon away). The replay
36
- walks the ledger once and rests (#452), driven
37
- by /dashboard/events at its 30-night default.
38
+ canvas, the domain legend (full quadrant width,
39
+ #648 item 4), the zoom + fit controls (#648
40
+ item 3), and the replay timeline strip. Hover
41
+ tooltips only (inspection lives in /viz, one
42
+ expand-icon away). The replay walks the ledger
43
+ once and rests (#452), driven by
44
+ /dashboard/events at its 30-night default.
38
45
 
39
46
  SURFACE MAP: the old band of stat cards, the fleet rail, the capture
40
47
  card, the memory browser (search floor + results panel + detail) and the
@@ -178,17 +185,14 @@
178
185
  }
179
186
  .acct-link:hover{ background:var(--teal-wash); color:var(--teal-deep); }
180
187
  .acct-link.acct-danger:hover{ background:#f6e8e4; color:#a0402c; }
181
- /* the Subscription entry's upgrade pill (#371 round 3: the menu's
182
- two billing entries merged into ONE "Plan & billing" item, which can
183
- have an upgrade pill/label after it before any subscription is active).
184
- The ENTRY always renders; the PILL is what the plan-unset eligibility
185
- gates. */
186
- .acct-link .acct-pill{
187
- margin-left:8px; font-size:9px; font-weight:640; letter-spacing:.08em; text-transform:uppercase;
188
- color:var(--green); border:1px solid color-mix(in srgb, var(--green) 35%, transparent);
189
- background:color-mix(in srgb, var(--green) 8%, transparent);
190
- border-radius:999px; padding:1px 7px; vertical-align:1px;
191
- }
188
+ /* the Plan & billing entry (#371 round 3: the menu's two billing entries
189
+ merged into ONE always-rendered item). #648 item 10: the plan-unset
190
+ eligibility now GATES the billing path instead of advertising checkout —
191
+ a plan-less (self-hosted) account renders the entry dimmed + disabled
192
+ with a muted self-hosted hint riding the label; the hosted console is
193
+ the purchase surface. */
194
+ .acct-link.acct-disabled{ opacity:.45; cursor:default; }
195
+ .acct-link .acct-hint{ margin-left:6px; font-size:10px; font-weight:500; color:var(--muted); }
192
196
 
193
197
  /* ============ billing-return banner (#371) — the one-line acknowledgment
194
198
  for ?billing=success|cancelled (the URLs the router stamps on every
@@ -335,6 +339,11 @@
335
339
  .pill.std{ background:var(--teal-wash); color:var(--teal-deep); }
336
340
  .pill.shr{ background:#eef1f2; color:var(--muted); }
337
341
  .grp-h .n{ margin-left:auto; font-weight:500; letter-spacing:0; text-transform:none; white-space:nowrap; }
342
+ /* #648 item 1: the Pre-tracking bucket's collapsed header — the plain
343
+ language hint sits beside the label (case reset: the header uppercases),
344
+ the whole header is the expand/collapse target */
345
+ .grp-h .grp-hint{ font-weight:400; letter-spacing:0; text-transform:none; color:var(--faint); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
346
+ .grp-h[data-collapsed]{ cursor:pointer; }
338
347
  .pm-empty{ color:var(--muted); font-size:12.5px; }
339
348
  .empty-cta{ margin-top:10px; font-size:12px; font-weight:600; color:var(--teal-deep); background:var(--teal-wash); border:1px solid #c4dde2; border-radius:8px; padding:5px 12px; }
340
349
  #ag-circle{ flex:none; display:inline-flex; }
@@ -376,6 +385,12 @@
376
385
  .tile .d.down{ color:var(--amber); }
377
386
  .panel-label{ font-size:10.5px; letter-spacing:.08em; text-transform:uppercase; color:var(--muted); margin:12px 0 6px; }
378
387
  .chart{ width:100%; height:96px; display:block; }
388
+ /* #648 item 7: the token chart's derived vertical scale — gutter labels
389
+ live OUTSIDE the svg (preserveAspectRatio="none" would stretch text) */
390
+ .chartrow{ display:flex; gap:8px; }
391
+ .yscale{ position:relative; width:44px; height:96px; flex:none; }
392
+ .yscale span{ position:absolute; right:0; transform:translateY(-50%); font:9.5px var(--mono); color:var(--muted); white-space:nowrap; }
393
+ .chartrow .chart{ flex:1; min-width:0; }
379
394
  .axis{ display:flex; justify-content:space-between; font-size:10px; color:var(--muted); margin-top:3px; }
380
395
  .stackbar{ display:flex; height:14px; border-radius:7px; overflow:hidden; margin:8px 0 10px; background:#eef2f3; }
381
396
  .stackbar i{ display:block; height:100%; }
@@ -463,11 +478,24 @@
463
478
  #field.hovering{ cursor:pointer; }
464
479
  #field.orbiting{ cursor:grabbing; }
465
480
  #legend{
466
- position:absolute; right:14px; top:10px; display:flex; gap:10px; flex-wrap:wrap; max-width:70%;
481
+ /* AC-V1 (#648 item 4): the legend spans the quadrant — inset on both
482
+ sides, wrapping; the right-anchor + max-width cap are gone. */
483
+ position:absolute; left:14px; right:14px; top:10px; display:flex; gap:10px; flex-wrap:wrap;
467
484
  font-size:10.5px; color:var(--muted); background:rgba(255,255,255,.88);
468
485
  padding:4px 9px; border-radius:6px; border:1px solid var(--hairline);
469
486
  }
470
487
  #legend i{ display:inline-block; width:8px; height:8px; border-radius:99px; margin-right:4px; vertical-align:-1px; }
488
+ /* #648 item 3: zoom + fit — three square buttons above the timeline
489
+ strip, the #legend chrome language (translucent white, hairline border,
490
+ teal on hover). They drive the canvas engine's own camera (the same
491
+ targets the wheel mutates); zero external anything. */
492
+ .zoomctl{ position:absolute; right:14px; bottom:44px; display:flex; flex-direction:column; gap:4px; }
493
+ .zoomctl button{
494
+ width:24px; height:24px; border-radius:6px; border:1px solid var(--hairline);
495
+ background:rgba(255,255,255,.88); color:var(--muted);
496
+ font-size:13px; line-height:1; display:flex; align-items:center; justify-content:center; padding:0;
497
+ }
498
+ .zoomctl button:hover{ color:var(--teal); }
471
499
  .timeline{
472
500
  position:absolute; left:0; right:0; bottom:0; height:34px; background:rgba(255,255,255,.92);
473
501
  border-top:1px solid var(--hairline); display:flex; align-items:center; padding:0 14px; gap:10px;
@@ -680,11 +708,12 @@
680
708
  router stamps). Dismiss removes it; the param is stripped on show. -->
681
709
  <div id="billing-banner" role="status" aria-live="polite" hidden></div>
682
710
 
683
- <!-- ============ the four-quadrant grid (AC-L1): Agents · Analytics ·
684
- Brain · Brain map. One .qhead + one internally scrollable .qbody per
685
- quadrant (AC-L3); one gear per quadrant (AC-L4): Agents = capture
686
- pause, Brain = model settings, Brain map = the expand icon (opens /viz
687
- in a new tab), Analytics = none. ============ -->
711
+ <!-- ============ the four-quadrant grid (AC-L1): Agents · Brain ·
712
+ Analytics · Brain map (#648 item 8 — the right column swapped; the grid
713
+ is row-major, so DOM order IS the layout). One .qhead + one internally
714
+ scrollable .qbody per quadrant (AC-L3); one gear per quadrant (AC-L4):
715
+ Agents = capture pause, Brain = model settings, Brain map = the expand
716
+ icon (opens /viz in a new tab), Analytics = none. ============ -->
688
717
  <main>
689
718
  <!-- ============ AGENTS (top-left) ============ -->
690
719
  <section class="q" id="q-agents">
@@ -713,39 +742,7 @@
713
742
  <div class="qbody" id="ag-body"><!-- rendered by agRender() --></div>
714
743
  </section>
715
744
 
716
- <!-- ============ ANALYTICS (top-right) ============ -->
717
- <section class="q" id="q-analytics">
718
- <div class="qhead">
719
- <h2>Analytics</h2>
720
- <span class="sub">last 30 nights</span>
721
- <div class="right"><span id="sys-chip">all systems <span class="ok-txt">normal</span></span></div>
722
- </div>
723
- <div class="qbody">
724
- <!-- AC-N1: the pipeline strip. The distill-inbox signal (queue depth +
725
- the echoed warn age) is the #529 block — hidden entirely when a
726
- pre-#529 server omits it; the warn threshold is ALWAYS the echo,
727
- never a page literal. -->
728
- <div class="pipe" id="an-pipe" hidden></div>
729
- <!-- AC-N2: three tiles with 15/15 delta math. Missing metering
730
- renders "—", never a fabricated 0. -->
731
- <div class="tiles" id="an-tiles"></div>
732
- <!-- AC-N3: 30-night token chart — distill (solid) vs consolidation
733
- (dashed); backfill nights (no tokens_by_stage) are gaps. -->
734
- <div class="panel-label">Token usage by night</div>
735
- <svg class="chart" id="an-chart" viewBox="0 0 600 96" preserveAspectRatio="none" aria-hidden="true"></svg>
736
- <div class="axis" id="an-axis"></div>
737
- <div class="legend" style="margin-top:6px">
738
- <span><i style="background:#14586a"></i>distill</span>
739
- <span><i style="background:#9cc3cd"></i>consolidation</span>
740
- </div>
741
- <!-- AC-N4: memories by topic — top five live domains + the live count. -->
742
- <div class="panel-label" id="an-topics-label">Memories by topic</div>
743
- <div class="stackbar" id="an-topics"></div>
744
- <div class="legend" id="an-legend"></div>
745
- </div>
746
- </section>
747
-
748
- <!-- ============ BRAIN (bottom-left) ============ -->
745
+ <!-- ============ BRAIN (top-right) ============ -->
749
746
  <section class="q" id="q-brain">
750
747
  <div class="qhead">
751
748
  <h2>Brain</h2>
@@ -817,10 +814,49 @@
817
814
  </dl>
818
815
  </div>
819
816
  </div>
820
- <!-- AC-B7: nightly budget — LLM calls used/max (no row when the day's
821
- snapshot carries no budget fields), tokens this run (a number, no
822
- bar), the amber note on an exhausted run. The #plan-billing id
823
- stays the billing-adjacent anchor (tests pin it). -->
817
+ <!-- AC-N4: memories by topic — top five live domains + the live count.
818
+ #651: moved here from Analytics — topics are corpus CONTENT (they
819
+ belong with the Brain quadrant), activity stays in Analytics. -->
820
+ <div class="panel-label" id="an-topics-label">Memories by topic</div>
821
+ <div class="stackbar" id="an-topics"></div>
822
+ <div class="legend" id="an-legend"></div>
823
+ </div>
824
+ </section>
825
+
826
+ <!-- ============ ANALYTICS (bottom-left) ============ -->
827
+ <section class="q" id="q-analytics">
828
+ <div class="qhead">
829
+ <h2>Analytics</h2>
830
+ <span class="sub">last 30 nights</span>
831
+ <div class="right"><span id="sys-chip">all systems <span class="ok-txt">normal</span></span></div>
832
+ </div>
833
+ <div class="qbody">
834
+ <!-- AC-N1: the pipeline strip. The distill-inbox signal (queue depth +
835
+ the echoed warn age) is the #529 block — hidden entirely when a
836
+ pre-#529 server omits it; the warn threshold is ALWAYS the echo,
837
+ never a page literal. -->
838
+ <div class="pipe" id="an-pipe" hidden></div>
839
+ <!-- AC-N2: three tiles with 15/15 delta math. Missing metering
840
+ renders "—", never a fabricated 0. -->
841
+ <div class="tiles" id="an-tiles"></div>
842
+ <!-- AC-N3: 30-night token chart — distill (solid) vs consolidation
843
+ (dashed); backfill nights (no tokens_by_stage) are gaps.
844
+ #648 item 7: the chartrow wraps the derived vertical-scale gutter
845
+ (an-scale) + the svg — the labels must live OUTSIDE the svg
846
+ (preserveAspectRatio="none" would stretch text). -->
847
+ <div class="panel-label">Token usage by night</div>
848
+ <div class="chartrow"><div class="yscale" id="an-scale"></div><svg class="chart" id="an-chart" viewBox="0 0 600 96" preserveAspectRatio="none" aria-hidden="true"></svg></div>
849
+ <div class="axis" id="an-axis"></div>
850
+ <div class="legend" style="margin-top:6px">
851
+ <span><i style="background:#14586a"></i>distill</span>
852
+ <span><i style="background:#9cc3cd"></i>consolidation</span>
853
+ </div>
854
+ <!-- Nightly budget (#648 item 9: moved from Brain — the spend story
855
+ lives with the pipeline numbers it measures). LLM calls used/max
856
+ (no row when the day's snapshot carries no budget fields), tokens
857
+ this run (a number, no bar), the amber note on an exhausted run.
858
+ The #plan-billing id stays the billing-adjacent anchor (tests pin
859
+ it). -->
824
860
  <div class="panel-label" id="plan-billing">Nightly budget</div>
825
861
  <div class="usebar" id="bud-calls" hidden>
826
862
  <div class="lbl"><span>LLM calls</span><span class="num" id="bud-calls-n">—</span></div>
@@ -848,9 +884,20 @@
848
884
  </div>
849
885
  <div class="vizwrap">
850
886
  <canvas id="field" aria-label="Brain map: memories as maturity-colored stars in domain regions, threaded by real synapses."></canvas>
851
- <!-- AC-V1: presence mode shows the field, the domain legend and the
852
- replay timeline strip ONLY — no search floor, no control band. -->
887
+ <!-- AC-V1 (#648 item 4: the legend spans the quadrant): presence mode
888
+ shows the field, the domain legend and the replay timeline strip
889
+ ONLY — no search floor, no control band. #648 item 3 adds the
890
+ zoom + fit controls (the #409 engine's own camera; no /viz
891
+ dependency, no external anything). -->
853
892
  <div id="legend"></div>
893
+ <div class="zoomctl" id="map-zoom">
894
+ <button type="button" id="map-zin" title="Zoom in (or scroll on the field)" aria-label="Zoom in">+</button>
895
+ <button type="button" id="map-zout" title="Zoom out" aria-label="Zoom out">−</button>
896
+ <!-- #651: fit carries the corner-brackets frame glyph — the header's
897
+ expand icon (diagonal arrows, open /viz) stays the ONLY
898
+ open-full-view affordance; two actions, two icons. -->
899
+ <button type="button" id="map-zfit" title="Fit the whole field in view" aria-label="Fit the whole field in view"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/></svg></button>
900
+ </div>
854
901
  <div class="timeline" id="replay">
855
902
  <button type="button" id="rp-pause" title="pause the replay">❚❚</button>
856
903
  <button type="button" id="rp-again" title="replay the last 30 nights again">▶ replay</button>
@@ -1186,12 +1233,13 @@ let learnedL = [], mergedL = [], enrichedL = [];
1186
1233
  let NIGHTS = []; // the events payload's night list
1187
1234
  let WINDOW = 1, NOW_T = .999, REPLAY_OK = false;
1188
1235
 
1189
- /* Replay pacing (#474: 2x faster default). Event-driven cruise:
1190
- each ledger event lands every REPLAY_TICK_MS; a heralded (birth/merge)
1191
- event holds the clock REPLAY_HERALD_MS then applies; boundary beats rest
1192
- REPLAY_REST_MS. Halve all three to run 2x; the constants are the only
1193
- pacing surface. */
1194
- const REPLAY_TICK_MS=205, REPLAY_HERALD_MS=108, REPLAY_REST_MS=800;
1236
+ /* Replay pacing (#474: 2x faster default; #648 item 6 halves all three
1237
+ again — 205/108/800 → 102/54/400 — for the feedback round's 2x pass).
1238
+ Event-driven cruise: each ledger event lands every REPLAY_TICK_MS; a
1239
+ heralded (birth/merge) event holds the clock REPLAY_HERALD_MS then
1240
+ applies; boundary beats rest REPLAY_REST_MS. Halve all three to run 2x;
1241
+ the constants are the only pacing surface. */
1242
+ const REPLAY_TICK_MS=102, REPLAY_HERALD_MS=54, REPLAY_REST_MS=400;
1195
1243
 
1196
1244
  function domIndex(domain){ const i = DOMAINS.findIndex(d=>d.name===domain); return i<0?0:i; }
1197
1245
  function titleOf(id){ const m=mems.get(id); return m?m.title:'(absorbed)'; }
@@ -2313,6 +2361,15 @@ cv.addEventListener('wheel',e=>{
2313
2361
  cam.ts=clamp(cam.ts*(e.deltaY<0?1.14:1/1.14),.5,6);
2314
2362
  dirty=true; wake();
2315
2363
  },{passive:false});
2364
+ /* #648 item 3: the zoom + fit buttons drive the SAME camera targets the
2365
+ wheel mutates — one clamp pair (.5,6), one dirty/wake per action. Fit
2366
+ recenters AND clears a region focus (it is the pointer peer of the
2367
+ Escape path's setFocus(null)). */
2368
+ function mapZoom(f){ cam.ts=clamp(cam.ts*f,.5,6); dirty=true; wake(); }
2369
+ function mapFit(){ focusDom=null; cam.tx=.5; cam.ty=.5; cam.ts=.98; cam.rotT=0; cam.rot=0; dirty=true; wake(); }
2370
+ el('map-zin').onclick=()=>mapZoom(1.3);
2371
+ el('map-zout').onclick=()=>mapZoom(1/1.3);
2372
+ el('map-zfit').onclick=mapFit;
2316
2373
 
2317
2374
  /* ---------- keyboard ---------- */
2318
2375
  document.addEventListener('keydown',e=>{
@@ -2350,10 +2407,16 @@ function setFocus(i, opt){
2350
2407
 
2351
2408
  /* ---------- the DOMAIN legend (AC-V1: presence mode shows the field, the
2352
2409
  domain legend and the timeline). One entry per live domain — name +
2353
- window-count, swatch in the domain's F-family tone. The canvas dots stay
2410
+ window-count, swatch in the domain's tone. The canvas dots stay
2354
2411
  STAGE-toned (the engine's own encoding, untouched); the legend is the
2355
2412
  index of the canvas waymarkers, not a dot-color key. ---------- */
2356
- const DOMAIN_TONES=['#1d7a8c','#4f9dab','#7fb6c1','#a3ccd4','#c9a86a','#8fb8a8'];
2413
+ /* #648 item 5: separable muted hues — teal / sand / rose / slate-blue /
2414
+ gray-green / plum / gray / clay, matched luminance (the precision-band
2415
+ precedent): adjacent domains no longer read as one blue ramp. The STAGE
2416
+ palette (PAL.stages) is a different encoding and stays untouched. Both
2417
+ domain surfaces (this legend + the Analytics topics bar) share the ONE
2418
+ family. */
2419
+ const DOMAIN_TONES=['#4f9dab','#c9a86a','#d0a0ac','#7b93c4','#8fb8a8','#a993b8','#9aa8ad','#c2917e'];
2357
2420
  function renderLegend(){
2358
2421
  el('legend').innerHTML=DOMAINS.slice(0,8).map((d,i)=>
2359
2422
  '<span><i style="background:'+DOMAIN_TONES[i%DOMAIN_TONES.length]+'"></i>'+esc(d.name)+' <b>'+fmt(winCount[i]||d.count||0)+'</b></span>'
@@ -2835,22 +2898,6 @@ function circlePill(agentId){
2835
2898
  if(n===null) return '';
2836
2899
  return '<span class="conf-pill" title="Confidential circle — this agent\'s captures are confidential, hidden from other agents\' recall · '+n+' confidential '+(n===1?'memory':'memories')+'">confidential</span>';
2837
2900
  }
2838
- /** Bundle-level pill (group headers) — the tooltip names every member agent
2839
- + its count; '' when none of the ids are members.
2840
- #642: fleet.spaces present → one chip per space covering any of the ids
2841
- (same typeof-D guard as circlePill). */
2842
- function circleBundlePill(ids){
2843
- if(!Array.isArray(ids)) return '';
2844
- const sb=(typeof D!=='undefined'&&D&&D.fleet)?D.fleet.spaces:null;
2845
- if(sb&&Array.isArray(sb.spaces)) return spaceBundleBadges(ids,sb);
2846
- const hits=[];
2847
- for(const id of ids){
2848
- const n=circleCount(id);
2849
- if(n!==null) hits.push(id+' ('+n+')');
2850
- }
2851
- if(!hits.length) return '';
2852
- return '<span class="conf-pill" role="img" aria-label="confidential bundle" title="Confidential circle agents in this bundle: '+esc(hits.join(', '))+'"><svg viewBox="0 0 12 12" aria-hidden="true"><rect x="2.2" y="5.2" width="7.6" height="5.6" rx="1.2"/><path d="M4 5.2V3.8a2 2 0 0 1 4 0v1.4"/></svg></span>';
2853
- }
2854
2901
  /** The header legend chip — null when no roster exists (nothing rendered,
2855
2902
  honest empty state); the tooltip carries the ROSTER itself plus the
2856
2903
  capturing members (the issue's presence rule: the roster is visible
@@ -2865,7 +2912,7 @@ function circleLegend(){
2865
2912
  /* ---------- #642: spaces — fleet.spaces rides the same /dashboard/data
2866
2913
  payload (ALWAYS present; spaces [] when nothing is configured). The
2867
2914
  per-agent chips REPLACE the single amber circle pill when the block is
2868
- there (circlePill/circleBundlePill delegate); the confidential chip keeps
2915
+ there (circlePill delegates); the confidential chip keeps
2869
2916
  the amber family. Agents in no space show nothing extra — the Spaces
2870
2917
  panel's Unassigned lane is where they surface. D.fleet.spaces ABSENT on a
2871
2918
  pre-#642 server → every helper here is never reached (the pill helpers
@@ -2908,19 +2955,6 @@ function spaceBadges(agentId,b){
2908
2955
  }
2909
2956
  return out;
2910
2957
  }
2911
- /** Bundle-level chips (group headers) — one chip per space covering ANY of
2912
- the bundle's ids; the tooltip names the member agents. */
2913
- function spaceBundleBadges(ids,b){
2914
- if(!Array.isArray(ids)||!b||!Array.isArray(b.spaces)) return '';
2915
- let out='';
2916
- for(const s of b.spaces){
2917
- if(!s||!Array.isArray(s.members)) continue;
2918
- const hits=ids.filter(id=>s.members.some(m=>spaceMemberMatch(id,m)));
2919
- if(!hits.length) continue;
2920
- out+='<span class="space-chip'+(s.id==='confidential'?' conf':'')+'" role="img" aria-label="'+esc(s.id)+' space" title="Space: '+esc(s.id)+' — agents in this bundle: '+esc(hits.join(', '))+'">'+esc(s.id)+'</span>';
2921
- }
2922
- return out;
2923
- }
2924
2958
  let spPickerAgent=null; // the unassigned agent whose inline assign picker is open
2925
2959
  async function spacesAssign(agent,space){
2926
2960
  try{
@@ -3037,7 +3071,14 @@ function agGroupRows(rows,mode,spacesBlockVal,winRows){
3037
3071
  const groups=new Map();
3038
3072
  for(const r of rows){
3039
3073
  const k=r.machine||'(unstamped)';
3040
- if(!groups.has(k)) groups.set(k,{key:k,label:k==='(unstamped)'?'pre-tracking':k,pillKind:null,members:[],sums:sums.get(k)||{sessions:0,bytes:0}});
3074
+ if(!groups.has(k)){
3075
+ // #648 item 1: the unstamped bucket is the ONE collapsed group —
3076
+ // display-cased "Pre-tracking" (it keys the sums map unchanged);
3077
+ // stamped groups carry no collapsed flag at all
3078
+ const g={key:k,label:k==='(unstamped)'?'Pre-tracking':k,pillKind:null,members:[],sums:sums.get(k)||{sessions:0,bytes:0}};
3079
+ if(k==='(unstamped)') g.collapsed=true;
3080
+ groups.set(k,g);
3081
+ }
3041
3082
  groups.get(k).members.push(r);
3042
3083
  }
3043
3084
  return [...groups.values()].sort((a,b)=>a.label.localeCompare(b.label));
@@ -3059,6 +3100,7 @@ function agGroupRows(rows,mode,spacesBlockVal,winRows){
3059
3100
 
3060
3101
  /* ---------- the Agents table renderer (AC-A1/A2/A6) ---------- */
3061
3102
  let agSort={k:'name',dir:1}, agGroupMode='none';
3103
+ let agPreOpen=false; // #648 item 1: the Pre-tracking bucket's expansion survives re-renders
3062
3104
  function agStatusHtml(r){
3063
3105
  if(r.statusCls==='paused') return '<span class="cap-paused" title="capture paused — posts are skipped (200) and sessions are not backfilled">PAUSED</span>';
3064
3106
  if(!r.statusCls) return '<span class="st"><span style="color:var(--faint)">—</span></span>';
@@ -3110,12 +3152,21 @@ function agRender(){
3110
3152
  const pill=g.pillKind==='conf'?'<span class="pill conf">confidential</span>'
3111
3153
  :g.pillKind==='std'?'<span class="pill std">standard</span>'
3112
3154
  :g.pillKind==='shr'?'<span class="pill shr">needs a space</span>':'';
3113
- const ids=g.members.map(m=>m.id);
3114
3155
  const sums=g.sums?' <span class="n">'+fmt(g.sums.sessions)+' sess · '+mbFmt(g.sums.bytes)+'</span>':'';
3115
- const bundlePill=g.key.indexOf('space:')===0?'':circleBundlePill(ids);
3156
+ /* #651: no bundle badges here — the privacy pill IS the space-group
3157
+ key; machine/flat headers carry label · sums · count · toggle only
3158
+ (per-row Space cells show membership). */
3116
3159
  const n='<span class="n">'+g.members.length+' agent'+(g.members.length>1?'s':'')+'</span>';
3117
- return '<tbody><tr><td colspan="5" style="padding:0"><div class="grp-h">'+(pill+bundlePill+' '+esc(g.label)+sums+n).trim()+'</div></td></tr>'
3118
- +g.members.map(tr).join('')+'</tbody>';
3160
+ // #648 item 1: a collapsed group (only Pre-tracking carries the flag)
3161
+ // renders its members hidden until agPreOpen flips; the header carries
3162
+ // the plain-language hint + the right-side expand/collapse affordance
3163
+ // (the .n span owns the auto margin) and the full explanation on title
3164
+ const toggle=g.collapsed?' <span class="n">'+(agPreOpen?'collapse ▾':'expand ▸')+'</span>':'';
3165
+ const hint=g.collapsed?' <span class="grp-hint">no machine stamp — captured before workspace stamping</span>':'';
3166
+ const head=g.collapsed?' data-collapsed title="agents with no machine stamp — sessions predate workspace stamping; they still distill, they only lack a machine label"':'';
3167
+ const trRow=r=>(g.collapsed&&!agPreOpen)?tr(r).replace('<tr>','<tr hidden>'):tr(r);
3168
+ return '<tbody><tr><td colspan="5" style="padding:0"><div class="grp-h"'+head+'>'+(pill+' '+esc(g.label)+hint+sums+n+toggle).trim()+'</div></td></tr>'
3169
+ +g.members.map(trRow).join('')+'</tbody>';
3119
3170
  }).join('');
3120
3171
  html+='</table>';
3121
3172
  }
@@ -3142,6 +3193,10 @@ function buildAgents(){
3142
3193
  }
3143
3194
  /* table interactions — delegated (the rows re-render on every refresh) */
3144
3195
  el('ag-body').addEventListener('click',e=>{
3196
+ // #648 item 1: the collapsed group's header toggles its member rows;
3197
+ // agPreOpen is module scope, so the expansion survives every re-render
3198
+ const grp=e.target.closest('.grp-h[data-collapsed]');
3199
+ if(grp){ agPreOpen=!agPreOpen; agRender(); return; }
3145
3200
  const th=e.target.closest('th[data-k]');
3146
3201
  if(th){ agSortBy(th.dataset.k); return; }
3147
3202
  const plus=e.target.closest('.plus');
@@ -3501,6 +3556,17 @@ function lineSegments(vals){
3501
3556
  if(cur&&cur.length>1) segs.push(cur);
3502
3557
  return segs;
3503
3558
  }
3559
+ /** #648 item 7: the token chart's HONEST vertical scale — the 1/2/5×10^k
3560
+ * ceiling at or above the data max (floored at 1 so an all-flat series
3561
+ * still gets a usable axis). Gridlines and the gutter labels derive from
3562
+ * this ONE value, so the lines and the scale cannot disagree. Pure. */
3563
+ function tokScale(maxV){
3564
+ const v=Math.max(Number(maxV)||0,1);
3565
+ let p=1;
3566
+ while(v>p*10) p*=10;
3567
+ const m=v<=p?1:v<=2*p?2:v<=5*p?5:10;
3568
+ return {top:m*p, ticks:[m*p,m*p/2]};
3569
+ }
3504
3570
  function renderAnalytics(){
3505
3571
  renderPipe();
3506
3572
  const snaps=Array.isArray(D&&D.series)?D.series:[];
@@ -3520,9 +3586,14 @@ function renderAnalytics(){
3520
3586
  '<div class="tile"><div class="k">Tokens · 30 d</div><div class="v num">'+(tokSum==null?'—':fmtTokens(tokSum))+'</div>'+deltaHtml(tokD)+'</div>'
3521
3587
  +'<div class="tile"><div class="k">Sessions distilled</div><div class="v num">'+(hasSessions?fmt(sessions):'—')+'</div><div class="d">'+(hasSessions?'last '+wd+' days':'—')+'</div></div>'
3522
3588
  +'<div class="tile"><div class="k">Memories captured</div><div class="v num">'+(addSum==null?'—':fmt(addSum))+'</div>'+deltaHtml(addD)+'</div>';
3523
- // the token chart (AC-N3)
3589
+ // the token chart (AC-N3). #648 item 7: the vertical scale is DERIVED
3590
+ // from the metered nights — a nice 1/2/5 ceiling over the real max — and
3591
+ // the gridlines + gutter labels ride that same value; an empty series
3592
+ // renders no scale at all (honest absence, never a fabricated axis)
3524
3593
  const pts=tokSeries(snaps);
3525
- const maxV=Math.max(1,...pts.map(p=>Math.max(p.distill||0,p.consol||0)));
3594
+ const hasPts=pts.some(p=>p.distill!=null||p.consol!=null);
3595
+ const scale=hasPts?tokScale(Math.max(1,...pts.map(p=>Math.max(p.distill||0,p.consol||0)))):null;
3596
+ const maxV=scale?scale.top:1;
3526
3597
  const W=600,H=96;
3527
3598
  const n=Math.max(pts.length,1);
3528
3599
  const px=i=>(i/(n-1||1))*(W-4)+2;
@@ -3535,6 +3606,11 @@ function renderAnalytics(){
3535
3606
  }).join(' ');
3536
3607
  const dPath=pathOf(dSegs);
3537
3608
  let svg='';
3609
+ if(scale){
3610
+ // the gridlines go in FIRST so the area/line paths paint over them
3611
+ for(const tk of scale.ticks)
3612
+ svg+='<line x1="2" x2="598" y1="'+py(tk).toFixed(1)+'" y2="'+py(tk).toFixed(1)+'" stroke="#e6eef0" stroke-width="1"/>';
3613
+ }
3538
3614
  if(dPath){
3539
3615
  const firstSeg=dSegs[0], lastSeg=dSegs[dSegs.length-1];
3540
3616
  const area='M'+px(firstSeg[0][0]).toFixed(1)+','+(H-2)
@@ -3549,6 +3625,12 @@ function renderAnalytics(){
3549
3625
  const cPath=pathOf(cSegs);
3550
3626
  if(cPath) svg+='<path d="'+cPath+'" fill="none" stroke="#9cc3cd" stroke-width="1.8" stroke-dasharray="4 3"/>';
3551
3627
  el('an-chart').innerHTML=svg;
3628
+ // the scale gutter (#648 item 7): one absolutely-positioned span per tick
3629
+ // (the transform comes from .yscale span — the svg's
3630
+ // preserveAspectRatio="none" would stretch any text inside it)
3631
+ el('an-scale').innerHTML=scale
3632
+ ?scale.ticks.map(tk=>'<span style="top:'+(py(tk)/H*100).toFixed(2)+'%">'+fmtTokens(tk)+'</span>').join('')
3633
+ :'';
3552
3634
  // the axis: up to five night labels
3553
3635
  const dates=snaps.map(s=>s&&s.run_at?s.run_at.slice(0,10):null).filter(Boolean);
3554
3636
  const axisEl=el('an-axis');
@@ -3556,18 +3638,6 @@ function renderAnalytics(){
3556
3638
  const picks=[0,Math.floor((dates.length-1)/4),Math.floor((dates.length-1)/2),Math.floor(3*(dates.length-1)/4),dates.length-1];
3557
3639
  axisEl.innerHTML=[...new Set(picks)].map(i=>'<span>'+fmtDay(dates[i])+'</span>').join('');
3558
3640
  }else axisEl.innerHTML='<span>—</span>';
3559
- // memories by topic (AC-N4): top five live domains + the live count
3560
- const byDomain=(D&&D.composition&&D.composition.by_domain)||{};
3561
- const top=Object.entries(byDomain).sort((a,b)=>b[1]-a[1]).slice(0,5);
3562
- const total=top.reduce((a,[,v])=>a+v,0)||1;
3563
- const tones=['#1d7a8c','#4f9dab','#7fb6c1','#a3ccd4','#cfe3e8'];
3564
- const live=(D&&D.headline&&D.headline.live_memories!=null)?D.headline.live_memories:(D&&D.headline?D.headline.total_memories:null);
3565
- el('an-topics-label').textContent='Memories by topic'+(live!=null?' · '+fmt(live)+' live':'');
3566
- el('an-topics').innerHTML=top.length
3567
- ?top.map(([k,v],i)=>'<i style="width:'+Math.max(1,Math.round(v/total*100))+'%;background:'+tones[i]+';cursor:help" title="'+esc(k)+' '+fmt(v)+'"></i>').join('')
3568
- :'<i style="width:100%;background:#eef2f3"></i>';
3569
- el('an-legend').innerHTML=top.map(([k,v],i)=>'<span><i style="background:'+tones[i]+'"></i><b>'+esc(k)+'</b> '+fmt(v)+'</span>').join('')
3570
- ||'<span style="color:var(--faint)">no domains yet</span>';
3571
3641
  // the status chip (AC-N5): queue staleness + stale capture bundles
3572
3642
  const staleCapture=(Array.isArray(D&&D.fleet&&D.fleet.last_seen)?D.fleet.last_seen:[])
3573
3643
  .filter(s=>{ const p=presenceOf(s); return p&&p.cls==='stale'; }).length;
@@ -3580,6 +3650,23 @@ function renderAnalytics(){
3580
3650
  }
3581
3651
  const st=systemStatus(queueStale,staleCapture);
3582
3652
  el('sys-chip').innerHTML='all systems <span class="'+(st.cls==='ok'?'ok-txt':'att-txt')+'">'+st.word+'</span>';
3653
+ // nightly budget (#648 item 9: moved here from Brain — the spend story
3654
+ // lives with the pipeline numbers it measures). LLM calls used/max (the
3655
+ // row hides when the day's snapshot carries no budget fields), tokens
3656
+ // this run as a number, the amber note on an exhausted run.
3657
+ const stages=D&&D.digest?D.digest.stages:null;
3658
+ const hasCalls=!!(stages&&typeof stages.budget_calls_used==='number'&&typeof stages.budget_max_calls==='number');
3659
+ el('bud-calls').hidden=!hasCalls;
3660
+ if(hasCalls){
3661
+ el('bud-calls-n').textContent=fmt(stages.budget_calls_used)+' / '+fmt(stages.budget_max_calls);
3662
+ el('bud-calls-fill').style.width=clamp(stages.budget_calls_used/Math.max(stages.budget_max_calls,1)*100,0,100)+'%';
3663
+ }
3664
+ el('bud-tokens').textContent=(stages&&typeof stages.tokens==='number')?fmtTokens(stages.tokens):'—';
3665
+ const note=el('bud-note');
3666
+ if(stages&&stages.budget_exhausted){
3667
+ note.hidden=false;
3668
+ note.textContent='Consolidation budget exhausted — LLM-bound stages deferred the remaining work.';
3669
+ }else note.hidden=true;
3583
3670
  }
3584
3671
 
3585
3672
  /* ---------- divergence affordance (spec decided default 2; the #578
@@ -3604,7 +3691,10 @@ function renderRecDiv(){
3604
3691
  +lines.map(l=>'· '+l.line+(typeof l.shown==='number'?' — '+fmt(l.shown)+' showings':'')).join('\n');
3605
3692
  }
3606
3693
 
3607
- /* ---------- Brain corpus kv (AC-B6) + nightly budget (AC-B7) ---------- */
3694
+ /* ---------- Brain corpus kv (AC-B6) + memories by topic (AC-N4; moved
3695
+ here from renderAnalytics — #651: topics are corpus content, the
3696
+ renderer follows the DOM like #648 item 9 did for the budget).
3697
+ The nightly budget itself stays in renderAnalytics (#648 item 9). ---------- */
3608
3698
  function renderBrain(){
3609
3699
  const h=D&&D.headline?D.headline:null;
3610
3700
  renderRecDiv();
@@ -3627,22 +3717,21 @@ function renderBrain(){
3627
3717
  el('cor-links').textContent=linkCount!=null?fmt(linkCount):'—';
3628
3718
  const domains=(D&&D.composition&&D.composition.by_domain)?Object.keys(D.composition.by_domain).length:null;
3629
3719
  el('cor-domains').textContent=domains!=null?fmt(domains):'—';
3630
- // nightly budget (AC-B7)
3631
- const stages=D&&D.digest?D.digest.stages:null;
3632
- const hasCalls=!!(stages&&typeof stages.budget_calls_used==='number'&&typeof stages.budget_max_calls==='number');
3633
- el('bud-calls').hidden=!hasCalls;
3634
- if(hasCalls){
3635
- el('bud-calls-n').textContent=fmt(stages.budget_calls_used)+' / '+fmt(stages.budget_max_calls);
3636
- el('bud-calls-fill').style.width=clamp(stages.budget_calls_used/Math.max(stages.budget_max_calls,1)*100,0,100)+'%';
3637
- }
3638
- el('bud-tokens').textContent=(stages&&typeof stages.tokens==='number')?fmtTokens(stages.tokens):'—';
3639
- const note=el('bud-note');
3640
- if(stages&&stages.budget_exhausted){
3641
- note.hidden=false;
3642
- note.textContent='Consolidation budget exhausted — LLM-bound stages deferred the remaining work.';
3643
- }else note.hidden=true;
3644
3720
  renderModelCard();
3645
3721
  renderRecBand(h?h.uses_per_showing:null);
3722
+ // memories by topic (AC-N4): top five live domains + the live count.
3723
+ // #648 item 5: the swatches share the ONE DOMAIN_TONES family with the
3724
+ // Brain map's legend (no second inline ramp on this page)
3725
+ const byDomain=(D&&D.composition&&D.composition.by_domain)||{};
3726
+ const top=Object.entries(byDomain).sort((a,b)=>b[1]-a[1]).slice(0,5);
3727
+ const total=top.reduce((a,[,v])=>a+v,0)||1;
3728
+ const live=(D&&D.headline&&D.headline.live_memories!=null)?D.headline.live_memories:(D&&D.headline?D.headline.total_memories:null);
3729
+ el('an-topics-label').textContent='Memories by topic'+(live!=null?' · '+fmt(live)+' live':'');
3730
+ el('an-topics').innerHTML=top.length
3731
+ ?top.map(([k,v],i)=>'<i style="width:'+Math.max(1,Math.round(v/total*100))+'%;background:'+DOMAIN_TONES[i]+';cursor:help" title="'+esc(k)+' '+fmt(v)+'"></i>').join('')
3732
+ :'<i style="width:100%;background:#eef2f3"></i>';
3733
+ el('an-legend').innerHTML=top.map(([k,v],i)=>'<span><i style="background:'+DOMAIN_TONES[i]+'"></i><b>'+esc(k)+'</b> '+fmt(v)+'</span>').join('')
3734
+ ||'<span style="color:var(--faint)">no domains yet</span>';
3646
3735
  }
3647
3736
  /* ---------- Post-write refresh (AC-A7): assign, unassign and capture-pause
3648
3737
  re-fetch /dashboard/data (the fleet block is what changed) and re-render
@@ -3668,13 +3757,16 @@ async function refreshFleet(){
3668
3757
  ===================================================================== */
3669
3758
  const $ = el; // the harvested block below uses the $ shorthand
3670
3759
  /* Pure decision — what the corner renders for an /account payload (#409 fix
3671
- round 2: an account menu where you can upgrade, get the token, and see
3672
- who you're logged in as). The chip + menu render for EVERY account shape /account
3760
+ round 2: an account menu where you can get the token and see who you're
3761
+ logged in as). The chip + menu render for EVERY account shape /account
3673
3762
  answers — including the all-null self-hosted default, which previously
3674
3763
  degraded the corner to a standalone Upgrade button and hid the token.
3675
- The upgrade CTA is a MENU ITEM iff the plan is unset (the same
3676
- plan===null eligibility the shipped #365 code used — trial hosted, or
3677
- self-hosted null-plan). Returns null only when there is no account object
3764
+ #648 item 10 (owner ruling 2026-11-24): the plan-unset eligibility now
3765
+ GATES the billing path instead of advertising checkout — the same
3766
+ plan===null predicate the shipped #365 code used, surfaced as
3767
+ selfHosted: an account with no plan label renders its Plan & billing
3768
+ entry disabled with a self-hosted hint (the hosted console is the
3769
+ purchase surface). Returns null only when there is no account object
3678
3770
  at all (/account failed — fail-soft, empty corner). */
3679
3771
  function acctMenuPlan(a) {
3680
3772
  if (!a || typeof a !== "object") return null;
@@ -3682,7 +3774,7 @@ function acctMenuPlan(a) {
3682
3774
  return {
3683
3775
  parts, // name/org display parts (escaped at render)
3684
3776
  plan: typeof a.plan === "string" && a.plan !== "" ? a.plan : null,
3685
- upgrade: a.plan === null || a.plan === undefined || a.plan === "",
3777
+ selfHosted: a.plan === null || a.plan === undefined || a.plan === "",
3686
3778
  avatar: ((typeof a.name === "string" && a.name) ? a.name : "?").slice(0, 2).toUpperCase(),
3687
3779
  };
3688
3780
  }
@@ -3765,14 +3857,14 @@ function acctPlanLine(p) {
3765
3857
  ? "Current plan — " + p.plan
3766
3858
  : "Current plan — none yet (hosted trial, or self-hosted install)";
3767
3859
  }
3768
- /* Pure decision (#371 round 3) — the entry's upgrade pill.
3769
- The menu's two billing entries (Upgrade + Plan & billing) merged into
3770
- ONE always-rendered "Plan & billing" item; the PILL is what the old
3771
- plan-unset eligibility gates (it can have an upgrade pill/label
3772
- after it before any subscription is active). Returns the pill markup
3860
+ /* Pure decision (#371 round 3 → #648 item 10) — the entry's hint.
3861
+ The menu's billing entry is ONE always-rendered "Plan & billing" item;
3862
+ where the account carries no plan (self-hosted) the interpolation is a
3863
+ muted self-hosted hint and the entry renders disabled — there is NO
3864
+ clickable billing path on this surface. Returns the hint markup
3773
3865
  or "" — interpolated into the entry's label. */
3774
3866
  function acctPill(p) {
3775
- return p.upgrade ? '<span class="acct-pill">Upgrade</span>' : "";
3867
+ return p.selfHosted ? '<span class="acct-hint">self-hosted</span>' : "";
3776
3868
  }
3777
3869
  /* AC-H1: the env label — v<version> · <account name>. Both parts are
3778
3870
  null-safe: an all-null self-hosted account renders just the version; a
@@ -3793,7 +3885,7 @@ function renderAccount(a) {
3793
3885
  if (!p) { host.innerHTML = ""; return; } // /account failed — no chip (fail-soft)
3794
3886
  ACCOUNT_NAME = (typeof a.name === "string" && a.name) ? a.name : ACCOUNT_NAME;
3795
3887
  renderEnv();
3796
- const pill = acctPill(p); // #371 round 3: the entry always renders; the PILL is eligibility-gated
3888
+ const pill = acctPill(p); // #371 round 3: the entry always renders; #648 item 10 gates the PATH (hint + disabled markup)
3797
3889
  host.innerHTML = `
3798
3890
  <button id="acct-trigger" type="button" class="acct-trigger" aria-haspopup="menu" aria-expanded="false" title="Account">
3799
3891
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 3.6-6.5 8-6.5s8 2.5 8 6.5"/></svg>
@@ -3808,12 +3900,12 @@ function renderAccount(a) {
3808
3900
  <button id="acct-connect-entry" type="button" class="acct-link">Connect an agent</button>
3809
3901
  <button id="acct-identity" type="button" class="acct-link">Identity editor</button>
3810
3902
  <div class="acct-label">Account</div>
3811
- <button id="acct-subscription" type="button" class="acct-link">Plan &amp; billing${pill}</button>
3903
+ <button id="acct-subscription" type="button" class="acct-link${p.selfHosted ? " acct-disabled" : ""}"${p.selfHosted ? ' disabled title="Self-hosted install — plans and billing live in the hosted console"' : ""}>Plan &amp; billing${pill}</button>
3812
3904
  <button id="acct-signout" type="button" class="acct-link acct-danger">Sign out</button>
3813
3905
  </div>`;
3814
3906
  wireAcctMenu();
3815
3907
  renderPlanOverlay(p);
3816
- wireSubscription();
3908
+ wireSubscription(p);
3817
3909
  wireConnectEntry();
3818
3910
  wireIdentityEntry();
3819
3911
  }
@@ -3828,18 +3920,21 @@ function wireIdentityEntry() {
3828
3920
  });
3829
3921
  }
3830
3922
  /* The overlay's content (#371, amendment 2): the honest current-plan line
3831
- from the pure decision, and the purchase options under the SAME
3832
- plan-label-unset eligibility as the menu entry (a second checkout for an
3833
- active subscriber would mint a second Stripe subscription — checkout
3834
- passes customer_email, not a subscription update; switching is Phase 3).
3835
- /account failed (p null) → nothing fills (fail-soft, like the empty
3836
- corner); the overlay itself opens only from the menu entry anyway. */
3923
+ from the pure decision, and the purchase options' reachability (see the
3924
+ toggle below — #648 item 10). /account failed (p null) → nothing fills
3925
+ (fail-soft, like the empty corner); the overlay itself opens only from
3926
+ the menu entry anyway. */
3837
3927
  function renderPlanOverlay(p) {
3838
3928
  if (!p) return;
3839
3929
  const cur = $("po-current");
3840
3930
  if (cur) cur.textContent = acctPlanLine(p);
3931
+ // The purchase options are unreachable from this surface (#648 item 10):
3932
+ // a self-hosted install is gated at the entry (selfHosted), an active
3933
+ // subscriber by the double-billing guard that used to drive this toggle —
3934
+ // the hosted console is the purchase surface, so the grid stays hidden
3935
+ // for EVERY account shape.
3841
3936
  const opts = $("acct-options");
3842
- if (opts) opts.hidden = !p.upgrade;
3937
+ if (opts) opts.hidden = true;
3843
3938
  }
3844
3939
  function openPlanOverlay() {
3845
3940
  const ov = $("plan-overlay");
@@ -3932,14 +4027,16 @@ function wirePlanCurrency() {
3932
4027
  t.addEventListener("click", () => { setPlanCur(PLAN_CUR === "usd" ? "eur" : "usd"); });
3933
4028
  }
3934
4029
  wirePlanCurrency();
3935
- function wireSubscription() {
4030
+ function wireSubscription(p) {
3936
4031
  const btn = $("acct-subscription");
3937
4032
  if (!btn) return;
3938
- // #371 round 3: the ONE Plan & billing entry (Upgrade + Plan & billing
3939
- // merged) opens the FULL-COVER plan & billing overlay; the entry
3940
- // always renders — the Upgrade pill alone marks the plan-unset state.
4033
+ // #371 round 3: the ONE Plan & billing entry opens the FULL-COVER plan &
4034
+ // billing overlay; the entry always renders — #648 item 10 marks the
4035
+ // plan-unset (self-hosted) state on it with the disabled attribute +
4036
+ // hint, and the guard below is the backstop for any programmatic click.
3941
4037
  // Menu closes first; × / cover-click / ESC return.
3942
4038
  btn.addEventListener("click", () => {
4039
+ if (p && p.selfHosted) return; // no clickable billing path on self-hosted installs (#648 item 10)
3943
4040
  closeAcctMenu();
3944
4041
  openPlanOverlay();
3945
4042
  });
@@ -4183,7 +4280,8 @@ function wireAcctMenu() {
4183
4280
  // #506: the copy-cli/copy-mcp wiring moved to the STATIC init block by
4184
4281
  // the connect overlay — those buttons live in the overlay now, not here.
4185
4282
  // #371 round 3: the menu's billing surface is the ONE Plan & billing
4186
- // entry; the #plan-billing budget anchor (Brain quadrant) is display.
4283
+ // entry (self-hosted-gated, #648 item 10); the #plan-billing budget
4284
+ // anchor (Analytics quadrant since #648 item 9) is display.
4187
4285
  $("acct-signout").addEventListener("click", signOut);
4188
4286
  renderAcctToken();
4189
4287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamaze/hicortex",
3
- "version": "0.29.0",
3
+ "version": "0.29.2",
4
4
  "description": "Persistent agent identity for AI agents \u2014 a hand-edited identity layer, nightly-distilled experience, and lessons injected every session, shared across your whole fleet. Works with Hermes, OpenClaw, Claude Code, Pi, and opencode.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/server.json CHANGED
@@ -3,12 +3,12 @@
3
3
  "name": "io.github.gamaze-labs/hicortex",
4
4
  "title": "Hicortex \u2014 AI Fleet Memory",
5
5
  "description": "Shared fleet memory for AI agents: nightly self-correction, recall every prompt (supported agents).",
6
- "version": "0.29.0",
6
+ "version": "0.29.2",
7
7
  "packages": [
8
8
  {
9
9
  "registryType": "npm",
10
10
  "identifier": "@gamaze/hicortex",
11
- "version": "0.29.0",
11
+ "version": "0.29.2",
12
12
  "transport": {
13
13
  "type": "stdio",
14
14
  "command": "npx",