@gamaze/hicortex 0.25.0 → 0.26.0

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.
package/README.md CHANGED
@@ -288,6 +288,8 @@ Config at `~/.hicortex/config.json`. Created by `init`. Key options:
288
288
  | `memorySoftCap` | Soft cap on the memory corpus (default 10000). When the corpus exceeds this, the nightly's capacity-eviction stage removes the lowest-`effectiveStrength` memories (ties broken by oldest access) until under the cap — the active forgetting mechanism that bounds DB size, vector-index RAM, and consolidation workload. `0` disables eviction (indefinite growth — the pre-#245 behaviour). The evicted tail is cold by construction (effectiveStrength is the same decay-weighted score the recall ranker uses, so these were not surfacing in the top-k anyway). At 10K memories the load + JS sort is <100 ms |
289
289
  | `updateChannel` | Release channel pinned into the generated daemon/timer ExecStart for **npx-thin** installs (global-binary installs use the absolute binary and are unaffected). A dist-tag (`"rc"`, `"next"`) or an exact version (`"0.17.1"`). E.g. `"rc"` → the timer runs `npx -y @gamaze/hicortex@rc nightly`, so the host tracks the rc dist-tag (an internal fleet can ride rc through a pre-promotion soak). Validated as `[\w.\-]+` (rejects anything that'd break the unit/plist templates). Absent → auto-detect (bare on `latest`, else `@next`). (0.17.1) |
290
290
  | `nightlyHour` | **Deprecated (0.17) single-slot fallback.** Local hour (0–23) honoured only when `consolidationHours` is absent — yields one daily consolidation slot at that hour (preserves the pre-0.17 "one daily job" intent). New installs should use `consolidationHours` |
291
+ | `qualityGrading` | Explicit opt-in for the weekly recall-quality grading pass (default **off**). The pass sends a redacted prompt excerpt and the pushed index line to a third-party decisions endpoint for scoring; with the key off (or absent) the stage skips and logs a health line. Also requires the endpoint API key (OPENROUTER_HICORTEX_KEY env) and `qualityGradeModel`. |
292
+ | `qualityGradeModel` | The model id the grading lane requests when `qualityGrading` is on. No default — absent → the stage skips (greppable health line). |
291
293
  | `telemetry` | Anonymous usage telemetry. **On by default and not written into config by `init`** — add `"telemetry": false` yourself (or set `HICORTEX_TELEMETRY=off`) to opt out. Inspect exactly what is sent with `hicortex telemetry` |
292
294
 
293
295
  **Calibration is release-managed.** The ~35 tuning keys earlier releases exposed (recall breadth, relevance floors, ranking weights, decay speed, dedup/supersession/correction thresholds, the weak-primary floor) are no longer config: they are constants that ship with each release and change only in releases, with the eval evidence linked in the changelog. Config values for them are ignored — the server prints a one-time boot warning naming each ignored key. Your config file now describes your *install* (mode, model, schedules, identity, budgets), not the brain's tuning. The one deliberate exception is `recallCrossProjectMinSimilarity` — on the `firstRunLookbackDays` precedent, it is a per-install posture dial rather than corpus calibration, so it stayed a live config key.
@@ -467,7 +467,23 @@
467
467
  .rec-l1 .l1txt{ color:var(--dim); overflow:hidden; text-overflow:ellipsis; font-size:10.5px; letter-spacing:-.01em; }
468
468
  .rec-l1 b{ color:var(--green-mid); font-weight:600; }
469
469
  .rec-l1.below b{ color:var(--dim); }
470
- #rec-div{ color:var(--amber); overflow:hidden; text-overflow:ellipsis; }
470
+ /* #578 quality drawers (divergence + contested): native details/summary
471
+ in the card's .csub scale — collapsed they are one dim line, open they
472
+ stack their rows inside the card (no page modal for ~5 rows/week).
473
+ Theme tokens only; the thumbs are small ghost buttons. */
474
+ .rec-det{ font-size:10.5px; color:var(--dim); }
475
+ .rec-det summary{ cursor:pointer; color:var(--dim); letter-spacing:-.01em; user-select:none; }
476
+ .rec-det summary:hover{ color:var(--text); }
477
+ .rec-det[open] summary{ color:var(--text); }
478
+ .rec-det-body{ margin:4px 0 2px; display:flex; flex-direction:column; gap:4px; }
479
+ .rec-det-body .rec-line{ font-size:10.5px; color:var(--dim); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
480
+ .rec-contest-empty{ font-style:italic; }
481
+ .rec-thumb{ border:1px solid color-mix(in srgb, var(--text) 22%, transparent); background:none; color:var(--dim); border-radius:5px; font-size:11px; line-height:1; padding:2px 6px; cursor:pointer; }
482
+ .rec-thumb:hover{ color:var(--text); border-color:color-mix(in srgb, var(--text) 45%, transparent); }
483
+ .rec-thumb.ok:hover{ color:var(--green); border-color:var(--green); }
484
+ .rec-thumb.no:hover{ color:var(--red); border-color:var(--red); }
485
+ .rec-item{ display:flex; align-items:center; gap:6px; min-width:0; }
486
+ .rec-item .rec-item-line{ flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10.5px; color:var(--dim); }
471
487
  .b-health{ display:flex; align-items:center; gap:7px; font-size:11px; color:var(--dim); white-space:nowrap; }
472
488
  .dot{ width:6px; height:6px; border-radius:50%; background:var(--green); box-shadow:0 0 10px color-mix(in srgb, var(--green) 70%, transparent); animation:breathe 3.2s ease-in-out infinite; flex:none; }
473
489
  .dot.blue{ background:var(--blue); box-shadow:0 0 10px color-mix(in srgb, var(--blue) 70%, transparent); }
@@ -1264,32 +1280,49 @@
1264
1280
  <div class="csub" id="tok-sub">&nbsp;</div>
1265
1281
  <div id="tok-nights" aria-label="LLM tokens per nightly run this billing period"></div>
1266
1282
  </div>
1267
- <!-- Memory Precision (#476, owner retitle) — ONE card, two context
1268
- levels. Level 2 (recall depth) keeps the #426 U-band + zone word +
1269
- provisional-hover semantics; the marker/tooltip read the WINDOW
1270
- ratio off D.memory_precision.level2 (a pre-#476 server has no block
1271
- → the headline ratio — today's rendering exactly). Level 1 (pushed
1272
- index) is a compact second row: mean similarity of pushed lines to
1273
- their prompt, with a floor marker at the echoed
1274
- recall_min_similarity and muted below it (the index's bar reads
1275
- conservative — its noise costs compound per prompt) + the
1276
- redundancy share; direction-only coloring, NO verdict words (the
1277
- #426 semantics ruling extended: similarity is
1278
- conversation-dependent). Divergence count on the FACE, the ≤3
1279
- titles hover-only (no memory lists on the main page — owner ruling
1280
- 2026-09-12; the header search panel is the list surface). The
1281
- window rides the #452 selector via the echoed window_days — never
1282
- hardcoded, never a second range control. -->
1283
+ <!-- Memory Precision (#476, owner retitle; #578 quality audit) — ONE
1284
+ card, two context levels + the quality instrument. Level 2 (recall
1285
+ depth) keeps the #426 U-band + zone word + provisional-hover
1286
+ semantics; the marker/tooltip read the WINDOW ratio off
1287
+ D.memory_precision.level2 (a pre-#476 server has no block → the
1288
+ headline ratio — today's rendering exactly). The #578 audit
1289
+ (owner: "do the numbers earn their place"): mean similarity and
1290
+ redundant share are TOOLTIP-ONLY (high cosine was the noise's
1291
+ camouflage — not actionable), divergence lives in a details
1292
+ drawer, and the FACE carries what answers "is recall quality
1293
+ improving": uses-per-showing (the big word), pushes/lines volume,
1294
+ and the Tier-1 rows (block size, cross-project share + attribution
1295
+ coverage, sub-bar share at the echoed fence bar, distinct-memory
1296
+ recycling) with per-change deltas off the server's change-registry
1297
+ entries while the raw window covers them. The contested drawer
1298
+ (#578 judgment layer) lazily fetches /dashboard/quality/contested
1299
+ and PUTs the owner's thumbs — no grading data in the ≤ 2 KB
1300
+ memory_precision block. The window rides the #452 selector via the
1301
+ echoed window_days — never hardcoded, never a second range
1302
+ control. -->
1283
1303
  <div class="bseg" id="lim-rec">
1284
1304
  <div class="gh"><span class="t">Memory Precision</span><span class="sub" id="rec-sub">uses per showing</span></div>
1285
1305
  <div class="big"><b class="n rec-word" id="rec-zone">—</b></div>
1286
1306
  <div class="rec-bandrow" id="rec-bandrow"><div class="rec-band" id="rec-band"></div><i class="rec-dot" id="rec-dot" hidden></i></div>
1287
1307
  <div class="rec-l1" id="rec-l1" hidden style="display:block">
1288
- <div class="l1row" id="l1-rel">&nbsp;</div>
1289
- <div class="l1row" id="l1-rep">&nbsp;</div>
1290
- <div class="l1row" id="l1-off">&nbsp;</div>
1308
+ <div class="l1row" id="l1-blk">&nbsp;</div>
1309
+ <div class="l1row" id="l1-cross">&nbsp;</div>
1310
+ <div class="l1row" id="l1-sub">&nbsp;</div>
1311
+ <div class="l1row" id="l1-recy">&nbsp;</div>
1312
+ <div class="l1row" id="l1-vol">&nbsp;</div>
1291
1313
  </div>
1292
- <div class="csub rec-foot"><span id="rec-div" hidden></span></div>
1314
+ <details id="rec-divdet" class="rec-det" hidden>
1315
+ <summary>divergence &middot; <span id="rec-divn">0</span> never read</summary>
1316
+ <div id="rec-div-lines" class="rec-det-body"></div>
1317
+ </details>
1318
+ <details id="rec-series" class="rec-det" hidden>
1319
+ <summary>corpus &amp; graded &middot; last nightly</summary>
1320
+ <div id="rec-series-body" class="rec-det-body"></div>
1321
+ </details>
1322
+ <details id="rec-contest" class="rec-det">
1323
+ <summary>contested lines &middot; <span id="rec-contest-n">&mdash;</span></summary>
1324
+ <div id="rec-contest-rows" class="rec-det-body rec-contest-empty">open to load</div>
1325
+ </details>
1293
1326
  </div>
1294
1327
  </div>
1295
1328
  <!-- row 2 · ops & maturity — capture health · 30 nights · maturity split · model -->
@@ -3385,6 +3418,7 @@ function renderRecBand(ups){
3385
3418
  if(mp&&mp.level2) ups=mp.level2.uses_per_showing;
3386
3419
  lastRecUses=ups;
3387
3420
  renderRecL1(mp);
3421
+ renderRecSeries();
3388
3422
  const z=F&&F.thresholds?F.thresholds.recall_uses:null;
3389
3423
  const axis=z&&typeof z.axis_max==='number'&&z.axis_max>0?z.axis_max:null;
3390
3424
  const row=el('rec-bandrow'), band=el('rec-band'), dot=el('rec-dot'), word=el('rec-zone');
@@ -3431,22 +3465,24 @@ function renderRecBand(ups){
3431
3465
  before the counter was ever seeded). */
3432
3466
  }
3433
3467
 
3434
- /* ---------- Memory Precision — Level 1, the pushed index (#476). A compact
3435
- second row beside Level 2's U-band: mean similarity of pushed lines to
3436
- their prompt (a 0..1 bar with a floor tick at the /dashboard/field echo of
3437
- recall_min_similarity — the server's own recall floor, never a page
3438
- literal), muted below the floor (the index row reads conservative: its
3439
- noise lands on every prompt), plus the redundancy share (lines restating
3440
- the session's standing context at/above the echoed cosine). Direction-only
3441
- coloring, NO verdict words — the #426 semantics ruling extended.
3442
- Divergence: the COUNT on the card face, the ≤3 titles hover-only (no
3443
- memory lists on the main page, owner 2026-09-12 — the search panel is the
3444
- list surface). Absent block (pre-#476 server) → the whole row hides and
3445
- the sub keeps the old label — today's rendering exactly. */
3468
+ /* ---------- Memory Precision — Level 1, the pushed index (#476) + the #578
3469
+ quality audit (owner: "do the numbers earn their place"). The FACE carries
3470
+ the Tier-1 quality rows — block size (lines per push), cross-project share
3471
+ with its attribution coverage, sub-bar share at the ECHOED fence bar,
3472
+ distinct-memory recycling — each tagged with the per-change deltas off the
3473
+ server's change-registry entries (mp.changes; numbers computed at render
3474
+ server-side, the page never freezes one), plus the pushes/lines volume
3475
+ (the denominators). Mean similarity + redundant share are TOOLTIP-ONLY
3476
+ (they were the noise's camouflage); divergence lives in the #rec-divdet
3477
+ drawer below. NO verdict words anywhere — numbers, the #426 ruling. Absent
3478
+ tier1 (a pre-#578 server) → the quality rows hide and the card keeps the
3479
+ #476 shape; absent block entirely → the whole row hides and the sub keeps
3480
+ the old label (the capture card's block-absence guard). */
3446
3481
  function renderRecL1(mp){
3447
- const row=el('rec-l1'), sub=el('rec-sub'), dv=el('rec-div');
3482
+ const row=el('rec-l1'), sub=el('rec-sub');
3448
3483
  if(!mp||!mp.level1||!mp.level2){
3449
- row.hidden=true; dv.hidden=true; dv.title='';
3484
+ row.hidden=true;
3485
+ const dd0=el('rec-divdet'); if(dd0) dd0.hidden=true;
3450
3486
  if(sub) sub.textContent='uses per showing';
3451
3487
  return;
3452
3488
  }
@@ -3454,39 +3490,166 @@ function renderRecL1(mp){
3454
3490
  const l1=mp.level1;
3455
3491
  const floor=(F&&F.thresholds&&typeof F.thresholds.recall_min_similarity==='number')?F.thresholds.recall_min_similarity:null;
3456
3492
  const ra=(l1.thresholds&&typeof l1.thresholds.redundant_above==='number')?l1.thresholds.redundant_above:null;
3457
- const mins=(l1.thresholds&&typeof l1.thresholds.divergence_min_shown==='number')?l1.thresholds.divergence_min_shown:5;
3458
3493
  const sim=(typeof l1.mean_similarity==='number'&&isFinite(l1.mean_similarity))?l1.mean_similarity:null;
3459
3494
  const red=(typeof l1.redundant_share==='number'&&isFinite(l1.redundant_share))?l1.redundant_share:null;
3460
- if(sim===null){
3461
- row.hidden=true; /* nothing measured in the window — the row degrades away */
3462
- }else{
3463
- row.hidden=false;
3464
- row.classList.toggle('below',floor!==null&&sim<floor);
3465
- /* numbers only on the face — direction carries the meaning, no verdict words */
3466
- /* #476 owner rename (2026-09-20): the three buckets as named — Relevant /
3467
- Repeated known / Off-target. Relevant = the mean relevance; Repeated =
3468
- the redundant share; Off-target = the remainder (pushed lines that were
3469
- neither relevant nor new). Numbers, no verdict words (#426). */
3470
- const relPct=Math.round(clamp(sim,0,1)*100);
3471
- const repPct=red!==null?Math.round(clamp(red,0,1)*100):0;
3472
- const offPct=Math.max(0,100-relPct-repPct);
3473
- const dv=mp.divergence, nUsed=(dv&&typeof dv.count==='number')?dv.count:0;
3474
- el('l1-rel').innerHTML='<b>Relevant: '+relPct+'%</b>';
3475
- el('l1-rep').textContent='Repeated known: '+repPct+'%';
3476
- el('l1-off').textContent='Off-target: '+offPct+'%'+(nUsed>0?' ('+nUsed+' never used)':'');
3477
- row.title='pushed index, last '+(mp.window_days||90)+' days — mean similarity of pushed lines to their prompt (tick at the recall floor '+
3478
- (floor!==null?floor.toFixed(2):'—')+'; muted below it)'+
3479
- (ra!==null?'; redundant = share of lines at ≥'+ra.toFixed(2)+' cosine vs the session\'s standing context (lessons + identity)':'')+
3480
- ' · '+fmt(l1.pushes)+' pushes, '+fmt(l1.lines)+' lines';
3481
- }
3482
- /* divergence — the face count is amber; the ≤3 lines ride the native
3483
- tooltip ONLY (text via .title, never face content) */
3484
- /* #476 owner bundling (2026-09-20): the never-used count rides inside
3485
- Off-target; the separate face element stays hidden (titles on hover) */
3486
- const dEl=el('rec-div');
3487
- if(dEl){ dEl.hidden=true; }
3495
+ /* the tooltip carries the demoted #476 numbers — mean similarity (with the
3496
+ recall-floor context) + the redundant share (#578 audit: face rows these
3497
+ are not; high cosine was the noise's camouflage) */
3498
+ row.title='pushed index, last '+(mp.window_days||90)+' days — mean similarity '+
3499
+ (sim!==null?sim.toFixed(2):'—')+
3500
+ (floor!==null?' (recall floor '+floor.toFixed(2)+')':'')+
3501
+ (red!==null&&ra!==null?'; repeated-known '+Math.round(clamp(red,0,1)*100)+'% (≥'+ra.toFixed(2)+' cosine vs the session\'s standing context — lessons + identity)':'');
3502
+ renderRecDivDet(mp);
3503
+ const t=mp.tier1;
3504
+ if(!t){
3505
+ /* pre-#578 server: no quality rows exist — the face rows hide (their
3506
+ markup is #578's), the tooltip above still carries the #476 numbers,
3507
+ and the divergence drawer still renders from mp.divergence. */
3508
+ row.hidden=true;
3509
+ return;
3510
+ }
3511
+ row.hidden=false;
3512
+ row.classList.remove('below');
3513
+ /* per-change delta tags: one dim tag per registry entry the window covers
3514
+ and the server computed both sides for. pct when the before is nonzero,
3515
+ the raw arrow otherwise (a 0→x move has no honest percentage). */
3516
+ const tag=(k)=>{
3517
+ if(!Array.isArray(mp.changes)) return '';
3518
+ const parts=[];
3519
+ for(const ch of mp.changes){
3520
+ const b=ch.before&&typeof ch.before[k]==='number'?ch.before[k]:null;
3521
+ const a=ch.after&&typeof ch.after[k]==='number'?ch.after[k]:null;
3522
+ if(b===null||a===null) continue;
3523
+ let d;
3524
+ if(b!==0){ d=Math.round((a-b)/b*100); d=(d>0?'+':'')+d+'%'; }
3525
+ else { d=(a===0?'±0%':b+'→'+a); }
3526
+ parts.push(ch.id+' '+d);
3527
+ }
3528
+ return parts.length?' ('+parts.join(', ')+')':'';
3529
+ };
3530
+ const bs=(typeof t.block_size==='number'&&isFinite(t.block_size))?t.block_size.toFixed(2):'—';
3531
+ const cs=(typeof t.cross_share==='number'&&isFinite(t.cross_share))?Math.round(t.cross_share*100)+'%':'—';
3532
+ const cv=(typeof t.attribution_coverage==='number'&&isFinite(t.attribution_coverage))?Math.round(t.attribution_coverage*100)+'%':'—';
3533
+ const sb=(typeof t.sub_bar_share==='number'&&isFinite(t.sub_bar_share))?Math.round(t.sub_bar_share*100)+'%':'—';
3534
+ const rc=(typeof t.recycling==='number'&&isFinite(t.recycling))?Math.round(t.recycling).toString():'—';
3535
+ el('l1-blk').innerHTML='<b>Block: '+bs+' lines/push</b>'+tag('block_size');
3536
+ el('l1-cross').textContent='Cross-project: '+cs+' (attributed '+cv+')'+tag('cross_share');
3537
+ el('l1-sub').textContent='Sub-bar: '+sb+' below bar '+(typeof t.cross_project_bar==='number'?t.cross_project_bar.toFixed(2):'—')+tag('sub_bar_share');
3538
+ el('l1-recy').textContent='Recycling: '+rc+' memories/day'+tag('recycling');
3539
+ el('l1-vol').textContent=fmt(t.pushes)+' pushes · '+fmt(t.lines)+' lines';
3540
+ }
3541
+
3542
+ /* divergence drawer (#578 audit: off the face, into the details element).
3543
+ The count rides the summary; the ≤3 lines ride the drawer body — no memory
3544
+ lists on the card FACE (the 2026-09-12 ruling stands; a drawer is not a
3545
+ face row). */
3546
+ function renderRecDivDet(mp){
3547
+ const dd=el('rec-divdet'), dn=el('rec-divn'), dl=el('rec-div-lines');
3548
+ if(!dd||!dn||!dl) return;
3549
+ const dv=mp&&mp.divergence, n=(dv&&typeof dv.count==='number')?dv.count:0;
3550
+ if(!dv||!n){ dd.hidden=true; return; }
3551
+ dd.hidden=false;
3552
+ dn.textContent=n;
3553
+ dl.innerHTML='';
3554
+ for(const it of (dv.top||[])){
3555
+ const d=document.createElement('div');
3556
+ d.className='rec-line';
3557
+ d.textContent=it.line+' ('+it.shown+'×)';
3558
+ dl.appendChild(d);
3559
+ }
3560
+ }
3561
+
3562
+ /* ---------- corpus &amp; graded drawer (#578): the snapshot-stamped half.
3563
+ The corpus-health trio (near-dup clusters, scope-anchor rate, canonical
3564
+ label drift) and the graded aggregates are computed by the NIGHTLY
3565
+ snapshot writer only (the dup-cluster KNN alone forbids a per-request
3566
+ path), so they render from the SNAPSHOT SERIES — the newest snapshot row
3567
+ carrying metrics.quality — never from live work. No snapshots with the
3568
+ block yet (first nights after upgrade) → the drawer hides. */
3569
+ function renderRecSeries(){
3570
+ const det=el('rec-series'), body=el('rec-series-body');
3571
+ if(!det||!body) return;
3572
+ let q=null;
3573
+ if(D&&Array.isArray(D.series)){
3574
+ for(let i=D.series.length-1;i>=0;i--){
3575
+ const m=D.series[i]&&D.series[i].metrics;
3576
+ if(m&&m.quality){ q=m.quality; break; }
3577
+ }
3578
+ }
3579
+ if(!q){ det.hidden=true; return; }
3580
+ det.hidden=false;
3581
+ const c=q.corpus||{}, g=q.graded||{};
3582
+ body.innerHTML='';
3583
+ const row=(k,v)=>{
3584
+ const d=document.createElement('div');
3585
+ d.className='rec-line';
3586
+ d.textContent=k+': '+v;
3587
+ body.appendChild(d);
3588
+ };
3589
+ row('near-dup clusters',(typeof c.dup_clusters==='number'?c.dup_clusters:'—')+' at the merge bar');
3590
+ row('scope-anchored',(typeof c.scope_anchor_rate==='number'?Math.round(c.scope_anchor_rate*100)+'%':'—')+' of live memories');
3591
+ row('label drift',(typeof c.canonical_drift==='number'?c.canonical_drift:'—')+' non-canonical');
3592
+ row('graded useful',(typeof g.useful_share==='number'?Math.round(g.useful_share*100)+'%':'—')+' of '+(typeof g.graded==='number'?g.graded:0)+' verdicts');
3488
3593
  }
3489
3594
 
3595
+ /* ---------- contested drawer (#578 judgment layer). Lazy by design: graded
3596
+ data NEVER rides the memory_precision block (≤ 2 KB discipline); the list
3597
+ is fetched on FIRST OPEN of the details element only, then kept in sync
3598
+ after each thumb. Thumbs PUT /dashboard/quality/verdict {id, verdict:
3599
+ 1|-1} (numeric — the server's strict body), and a thumbed item leaves the
3600
+ list (the server clears owner-answered rows). Fail-soft: a fetch error
3601
+ renders the error line, never a dead drawer. */
3602
+ let CONTESTED_LOADED=false;
3603
+ async function loadContested(force){
3604
+ const box=el('rec-contest-rows'), num=el('rec-contest-n');
3605
+ if(!box) return;
3606
+ if(CONTESTED_LOADED&&!force) return;
3607
+ try{
3608
+ const r=await api('/dashboard/quality/contested?limit=20');
3609
+ CONTESTED_LOADED=true;
3610
+ if(num) num.textContent=String(r.total);
3611
+ box.innerHTML='';
3612
+ box.classList.remove('rec-contest-empty');
3613
+ if(!r.items||!r.items.length){
3614
+ box.classList.add('rec-contest-empty');
3615
+ box.textContent='nothing contested — the grader is confident this week';
3616
+ return;
3617
+ }
3618
+ for(const it of r.items){
3619
+ const row=document.createElement('div');
3620
+ row.className='rec-item';
3621
+ const line=document.createElement('span');
3622
+ line.className='rec-item-line';
3623
+ line.textContent=(it.line||('['+it.memory_id+'] memory no longer available'))+
3624
+ (it.prompt_excerpt?' — prompt: '+it.prompt_excerpt:'');
3625
+ line.title='score '+(typeof it.score==='number'?it.score.toFixed(2):'—')+
3626
+ ', confidence '+(typeof it.confidence==='number'?it.confidence.toFixed(2):'—');
3627
+ const up=document.createElement('button');
3628
+ up.className='rec-thumb ok'; up.textContent='👍'; up.title='useful';
3629
+ const down=document.createElement('button');
3630
+ down.className='rec-thumb no'; down.textContent='👎'; down.title='not useful';
3631
+ const send=async(v)=>{
3632
+ try{
3633
+ await api('/dashboard/quality/verdict',{method:'PUT',body:JSON.stringify({id:it.id,verdict:v})});
3634
+ row.remove();
3635
+ if(num) num.textContent=String(Math.max(0,(parseInt(num.textContent,10)||1)-1));
3636
+ }catch(e){ /* fail-soft: the row stays, the next open retries */ }
3637
+ };
3638
+ up.addEventListener('click',()=>send(1));
3639
+ down.addEventListener('click',()=>send(-1));
3640
+ row.appendChild(line); row.appendChild(up); row.appendChild(down);
3641
+ box.appendChild(row);
3642
+ }
3643
+ }catch(e){
3644
+ box.classList.add('rec-contest-empty');
3645
+ box.textContent='contested list unavailable ('+(e&&e.message?e.message:'load failed')+')';
3646
+ }
3647
+ }
3648
+ (function(){
3649
+ const det=el('rec-contest');
3650
+ if(det) det.addEventListener('toggle',()=>{ if(det.open) loadContested(); });
3651
+ })();
3652
+
3490
3653
  let MODEL_LABEL='';
3491
3654
  /* #409 fix round 5 — owner ruling 2026-09-14 (verbatim): "I do NOT want to
3492
3655
  know what it is compatible with, I want to know the fucking model." The
@@ -159,6 +159,65 @@ export declare const MEMORY_PRECISION_DIVERGENCE_MIN_SHOWN = 5;
159
159
  * the same trust boundary as /distill's denoised conversation text).
160
160
  */
161
161
  export declare const MEMORY_PRECISION_PROMPT_EXCERPT_CHARS = 256;
162
+ /**
163
+ * One pinned quality change — the Tier-3 baseline discipline (#578): every
164
+ * change that can move recall quality pins its deploy DATE here (edited at
165
+ * release, exactly like a calibration constant's rationale comment), and the
166
+ * card computes each entry's before/after from the RAW event store at render
167
+ * (before = window up to the date, after = the date onward). No frozen
168
+ * numbers: a pinned number freezes a metric definition that will evolve
169
+ * (the moving-reference problem), a date does not. Baselines age out of raw
170
+ * events after the 90-day retention; the nightly snapshot's quality block
171
+ * carries the trend from there.
172
+ */
173
+ export interface QualityChange {
174
+ /** Short machine id (rendered as the delta tag on the card face). */
175
+ id: string;
176
+ /** ISO date (UTC) the change deployed — the before/after split day. */
177
+ date: string;
178
+ /** Human label for the drawer/tooltip. */
179
+ label: string;
180
+ /** Source issue (provenance, the house convention). */
181
+ issue: number;
182
+ }
183
+ /**
184
+ * The seeded change registry (#578): TWO
185
+ * entries for 2026-10-28 — #566 (the cross-project recall fence, bar
186
+ * CROSS_PROJECT_MIN_SIMILARITY) and #567 (project-label reconciliation,
187
+ * shipped in the same 0.25.0 release) — independent changes, independent
188
+ * before/afters, back-pinned now while the 90-day raw window still covers
189
+ * them. Future quality changes append their entry at release time (#569's
190
+ * decay fix is the next: its date lands when it deploys).
191
+ */
192
+ export declare const QUALITY_CHANGES: readonly QualityChange[];
193
+ /**
194
+ * Weekly quality-grading call cap (#578: its own weekly lane, separate from
195
+ * nightlyLlmCallBudget) — different provider, different endpoint,
196
+ * independent starvation risk; folding it into the one #405 ceiling would
197
+ * let the consolidation LLM starve grading (or vice versa) with no signal.
198
+ * The per-call cost is negligible, so the cap bounds spend trivially.
199
+ * At cap the remaining sampled items DEFER to the next week (the week
200
+ * cursor does not advance past ungraded items — dup-over-loss).
201
+ * Release-managed: no config key, moving it is a release decision.
202
+ */
203
+ export declare const QUALITY_GRADE_WEEKLY_CALL_CAP = 60;
204
+ /**
205
+ * Auto-grader confidence below which a graded line lands in the CONTESTED
206
+ * slice for the owner's thumbs (#578). PROVISIONAL first anchor (the #426
207
+ * posture): 0.70, expected to move on fleet data. Applied at RENDER only
208
+ * (raw score + confidence are stored threshold-free; a recalibration never
209
+ * rewrites history).
210
+ */
211
+ export declare const QUALITY_CONTESTED_CONFIDENCE = 0.7;
212
+ /**
213
+ * Render edge for "useful" on a graded score (#578): a grading `score`
214
+ * question answers 0..1; ≥ this reads useful in the graded-useful share.
215
+ * 0.5 — the scale's own midpoint, deliberately NOT the utility threshold
216
+ * calibrated for recall INJECTION trimming (0.75 — a different decision).
217
+ * Derived at render, never stored. PROVISIONAL alongside
218
+ * QUALITY_CONTESTED_CONFIDENCE.
219
+ */
220
+ export declare const QUALITY_USEFUL_SCORE = 0.5;
162
221
  /**
163
222
  * Kill-switch for the deterministic volatility gate (#489, owner decision 5):
164
223
  * false disables isVolatileStatusEntry's use in the distill path (entries
@@ -24,8 +24,8 @@
24
24
  * the removal is never silent.
25
25
  */
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.STAGE_FADING_STRENGTH = exports.STAGE_FADING_DAYS = exports.WEAK_PRIMARY_FLOOR = exports.CORRECTION_REWRITE_MIN_CONFIDENCE = exports.CORRECTION_MIN_SIMILARITY = exports.DEDUP_AUTO_MERGE_THRESHOLD = exports.IMPORTANCE_SETTLE_WINDOW_DAYS = exports.IMPORTANCE_CEILING = exports.BM25_WEIGHT_DOMAIN = exports.BM25_WEIGHT_PROJECT = exports.BM25_WEIGHT_BODY = exports.BOTH_CHANNEL_BOOST = exports.RRF_VECTOR_WEIGHT = exports.RRF_FTS_WEIGHT = exports.RRF_COMPOSITE_WEIGHT = exports.RRF_K = exports.SCOPE_AFFINITY_WEIGHT = exports.SUPERSEDED_DEMOTION = exports.RECENCY_HEAD_DAYS = exports.RECENCY_HEAD_WEIGHT = exports.RECENCY_HOURLY_DECAY = exports.SCORE_RECENCY_WEIGHT = exports.CONNECTIONS_SATURATION_DEGREE = exports.SCORE_CONNECTIONS_WEIGHT = exports.SCORE_STRENGTH_WEIGHT = exports.SCORE_SIMILARITY_WEIGHT = exports.VOLATILE_GATE_MAX_CHARS = exports.VOLATILE_STATUS_FILTER = exports.MEMORY_PRECISION_PROMPT_EXCERPT_CHARS = exports.MEMORY_PRECISION_DIVERGENCE_MIN_SHOWN = exports.MEMORY_PRECISION_REDUNDANT_ABOVE = exports.MEMORY_PRECISION_WINDOW_DAYS = exports.RECALL_USES_AXIS_MAX = exports.RECALL_USES_NORMAL_MAX = exports.RECALL_USES_LOW_MAX = exports.RECALL_RESHOW_TURNS = exports.NOVELTY_FLOOR_SLOTS = exports.RECALL_TITLE_CHARS = exports.RECALL_MIN_PROMPT_CHARS = exports.RECALL_MAX_ITEMS = exports.CROSS_PROJECT_MIN_SIMILARITY = exports.RECALL_MIN_SIMILARITY = exports.SESSION_INTENT_WEIGHT = exports.COLD_EXPOSURE_SLOTS = exports.RECENT_WINDOW_DAYS = exports.RECENT_LIMIT = exports.SEARCH_LIMIT = exports.PROMOTION_STRENGTH_FLOOR = exports.PROMOTION_RATE = exports.DECAY_HALF_LIFE_DAYS = void 0;
28
- exports.DRAIN_QUEUE_WARN_AGE_HOURS = exports.DRAIN_YIELD_PROBE_TIMEOUT_MS = exports.DRAIN_YIELD_WAIT_CAP_MS = exports.DRAIN_YIELD_POLL_MS = exports.DIAGNOSTIC_ENV_TIER = exports.OLLAMA_FLUSH_WAIT_MS = exports.OLLAMA_FLUSH_EVERY = exports.NUM_CTX = exports.DEFAULT_FIRST_RUN_LOOKBACK_DAYS = exports.ENRICH_STRENGTH_DELTA = exports.STAGE_TRUTH_STRENGTH = exports.STAGE_BELIEF_STRENGTH = void 0;
27
+ exports.CORRECTION_MIN_SIMILARITY = exports.DEDUP_AUTO_MERGE_THRESHOLD = exports.IMPORTANCE_SETTLE_WINDOW_DAYS = exports.IMPORTANCE_CEILING = exports.BM25_WEIGHT_DOMAIN = exports.BM25_WEIGHT_PROJECT = exports.BM25_WEIGHT_BODY = exports.BOTH_CHANNEL_BOOST = exports.RRF_VECTOR_WEIGHT = exports.RRF_FTS_WEIGHT = exports.RRF_COMPOSITE_WEIGHT = exports.RRF_K = exports.SCOPE_AFFINITY_WEIGHT = exports.SUPERSEDED_DEMOTION = exports.RECENCY_HEAD_DAYS = exports.RECENCY_HEAD_WEIGHT = exports.RECENCY_HOURLY_DECAY = exports.SCORE_RECENCY_WEIGHT = exports.CONNECTIONS_SATURATION_DEGREE = exports.SCORE_CONNECTIONS_WEIGHT = exports.SCORE_STRENGTH_WEIGHT = exports.SCORE_SIMILARITY_WEIGHT = exports.VOLATILE_GATE_MAX_CHARS = exports.VOLATILE_STATUS_FILTER = exports.QUALITY_USEFUL_SCORE = exports.QUALITY_CONTESTED_CONFIDENCE = exports.QUALITY_GRADE_WEEKLY_CALL_CAP = exports.QUALITY_CHANGES = exports.MEMORY_PRECISION_PROMPT_EXCERPT_CHARS = exports.MEMORY_PRECISION_DIVERGENCE_MIN_SHOWN = exports.MEMORY_PRECISION_REDUNDANT_ABOVE = exports.MEMORY_PRECISION_WINDOW_DAYS = exports.RECALL_USES_AXIS_MAX = exports.RECALL_USES_NORMAL_MAX = exports.RECALL_USES_LOW_MAX = exports.RECALL_RESHOW_TURNS = exports.NOVELTY_FLOOR_SLOTS = exports.RECALL_TITLE_CHARS = exports.RECALL_MIN_PROMPT_CHARS = exports.RECALL_MAX_ITEMS = exports.CROSS_PROJECT_MIN_SIMILARITY = exports.RECALL_MIN_SIMILARITY = exports.SESSION_INTENT_WEIGHT = exports.COLD_EXPOSURE_SLOTS = exports.RECENT_WINDOW_DAYS = exports.RECENT_LIMIT = exports.SEARCH_LIMIT = exports.PROMOTION_STRENGTH_FLOOR = exports.PROMOTION_RATE = exports.DECAY_HALF_LIFE_DAYS = void 0;
28
+ exports.DRAIN_QUEUE_WARN_AGE_HOURS = exports.DRAIN_YIELD_PROBE_TIMEOUT_MS = exports.DRAIN_YIELD_WAIT_CAP_MS = exports.DRAIN_YIELD_POLL_MS = exports.DIAGNOSTIC_ENV_TIER = exports.OLLAMA_FLUSH_WAIT_MS = exports.OLLAMA_FLUSH_EVERY = exports.NUM_CTX = exports.DEFAULT_FIRST_RUN_LOOKBACK_DAYS = exports.ENRICH_STRENGTH_DELTA = exports.STAGE_TRUTH_STRENGTH = exports.STAGE_BELIEF_STRENGTH = exports.STAGE_FADING_STRENGTH = exports.STAGE_FADING_DAYS = exports.WEAK_PRIMARY_FLOOR = exports.CORRECTION_REWRITE_MIN_CONFIDENCE = void 0;
29
29
  exports.resolveNumCtx = resolveNumCtx;
30
30
  exports.resolveOllamaFlushEvery = resolveOllamaFlushEvery;
31
31
  exports.resolveOllamaFlushWaitMs = resolveOllamaFlushWaitMs;
@@ -186,6 +186,57 @@ exports.MEMORY_PRECISION_DIVERGENCE_MIN_SHOWN = 5;
186
186
  * the same trust boundary as /distill's denoised conversation text).
187
187
  */
188
188
  exports.MEMORY_PRECISION_PROMPT_EXCERPT_CHARS = 256;
189
+ /**
190
+ * The seeded change registry (#578): TWO
191
+ * entries for 2026-10-28 — #566 (the cross-project recall fence, bar
192
+ * CROSS_PROJECT_MIN_SIMILARITY) and #567 (project-label reconciliation,
193
+ * shipped in the same 0.25.0 release) — independent changes, independent
194
+ * before/afters, back-pinned now while the 90-day raw window still covers
195
+ * them. Future quality changes append their entry at release time (#569's
196
+ * decay fix is the next: its date lands when it deploys).
197
+ */
198
+ exports.QUALITY_CHANGES = Object.freeze([
199
+ Object.freeze({
200
+ id: "fence",
201
+ date: "2026-10-28",
202
+ label: "cross-project recall fence (0.72 bar)",
203
+ issue: 566,
204
+ }),
205
+ Object.freeze({
206
+ id: "labels",
207
+ date: "2026-10-28",
208
+ label: "project-label reconciliation (canonicalize at gate + ingest)",
209
+ issue: 567,
210
+ }),
211
+ ]);
212
+ /**
213
+ * Weekly quality-grading call cap (#578: its own weekly lane, separate from
214
+ * nightlyLlmCallBudget) — different provider, different endpoint,
215
+ * independent starvation risk; folding it into the one #405 ceiling would
216
+ * let the consolidation LLM starve grading (or vice versa) with no signal.
217
+ * The per-call cost is negligible, so the cap bounds spend trivially.
218
+ * At cap the remaining sampled items DEFER to the next week (the week
219
+ * cursor does not advance past ungraded items — dup-over-loss).
220
+ * Release-managed: no config key, moving it is a release decision.
221
+ */
222
+ exports.QUALITY_GRADE_WEEKLY_CALL_CAP = 60;
223
+ /**
224
+ * Auto-grader confidence below which a graded line lands in the CONTESTED
225
+ * slice for the owner's thumbs (#578). PROVISIONAL first anchor (the #426
226
+ * posture): 0.70, expected to move on fleet data. Applied at RENDER only
227
+ * (raw score + confidence are stored threshold-free; a recalibration never
228
+ * rewrites history).
229
+ */
230
+ exports.QUALITY_CONTESTED_CONFIDENCE = 0.70;
231
+ /**
232
+ * Render edge for "useful" on a graded score (#578): a grading `score`
233
+ * question answers 0..1; ≥ this reads useful in the graded-useful share.
234
+ * 0.5 — the scale's own midpoint, deliberately NOT the utility threshold
235
+ * calibrated for recall INJECTION trimming (0.75 — a different decision).
236
+ * Derived at render, never stored. PROVISIONAL alongside
237
+ * QUALITY_CONTESTED_CONFIDENCE.
238
+ */
239
+ exports.QUALITY_USEFUL_SCORE = 0.5;
189
240
  // ---------------------------------------------------------------------------
190
241
  // Volatility gate (#489) — deterministic drop of GH-ticket-status /
191
242
  // version-bump / commit-state entries at the distill gate, and the one-shot
@@ -1,14 +1,16 @@
1
1
  /**
2
- * /dashboard — view-only memory analytics (#224) + the console's live-data
3
- * endpoints (#409/#421 Phase 1: /dashboard/field, /dashboard/events).
2
+ * /dashboard — memory analytics (#224) + the console's live-data endpoints
3
+ * (#409/#421 Phase 1: /dashboard/field, /dashboard/events).
4
4
  *
5
- * STRICTLY view-only: this module computes metrics, reads snapshots, writes
6
- * ONE snapshot row per full nightly run (the writer is here because the
7
- * metric SQL lives next to its definition, not in nightly.ts), and exposes
8
- * the pure data handlers mounted at GET /dashboard/data,
9
- * GET /dashboard/field and GET /dashboard/events. There are NO mutation
10
- * endpoints on the dashboard surface — the only write path is the nightly
11
- * snapshot writer + the one-time backfill, both internal.
5
+ * View-only-leaning with SCOPED writers: this module computes metrics, reads
6
+ * snapshots, writes ONE snapshot row per full nightly run (the writer is
7
+ * here because the metric SQL lives next to its definition, not in
8
+ * nightly.ts), and exposes the pure data handlers mounted at GET
9
+ * /dashboard/data, GET /dashboard/field and GET /dashboard/events. The
10
+ * mutation surface is deliberately narrow: PUT /dashboard/model (#422),
11
+ * PUT /dashboard/capture-pause (#423), and PUT /dashboard/quality/verdict
12
+ * (#578 — the contested thumbs) — each an owner-ruled scoped writer, never
13
+ * a general write path.
12
14
  *
13
15
  * Layering (mirrors how recall-index.ts holds pure logic and viz.ts holds
14
16
  * thin express adapters): all metric SQL + snapshot shape lives HERE so it
@@ -24,6 +26,7 @@ import type express from "express";
24
26
  import type Database from "better-sqlite3";
25
27
  import { type CaptureHealthRow } from "./capture-health.js";
26
28
  import { type MemoryPrecision } from "./recall-precision.js";
29
+ import { type QualitySnapshotBlock } from "./quality-scoreboard.js";
27
30
  import { type Stage } from "./stages.js";
28
31
  /** Corpus-shape snapshot. `adoption` is null in backfilled rows (point-in-time,
29
32
  * can't be reconstructed from created_at). */
@@ -158,6 +161,16 @@ export interface DashboardMetrics {
158
161
  cold_count: number;
159
162
  uses_per_showing: number | null;
160
163
  };
164
+ /**
165
+ * #578 — the quality scoreboard block: Tier-1 aggregates (7d + 30d), the
166
+ * graded aggregates, and the corpus-health trio. Stamped by the NIGHTLY
167
+ * snapshot writer ONLY (the dup-cluster KNN is far too heavy per dashboard
168
+ * load — the card renders the trio from this series, never live); the
169
+ * live dashboard path computes tier1/changes from raw events at render
170
+ * instead (handleDashboardData). Undefined on backfilled rows. New keys
171
+ * only — the metrics blob is a stable contract, existing keys untouched.
172
+ */
173
+ quality?: QualitySnapshotBlock;
161
174
  }
162
175
  /** One row of the snapshot series (run_at + parsed metrics). */
163
176
  export interface DashboardSnapshot {
@@ -749,3 +762,19 @@ export declare function handleDashboardCapturePausePut(body: unknown, setPause:
749
762
  * is skipped (200) or captured as before.
750
763
  */
751
764
  export declare function dashboardCapturePausePutHandler(getDb: () => Database.Database): express.RequestHandler;
765
+ /**
766
+ * Express adapter for GET /dashboard/quality/contested. Bearer-only (auth
767
+ * middleware, no shell exemption — it carries grading data); localhost
768
+ * bypass applies. Query: `limit` (default 20, cap 100), `offset` (default 0).
769
+ */
770
+ export declare function dashboardQualityContestedHandler(getDb: () => Database.Database): express.RequestHandler;
771
+ /**
772
+ * Express adapter for PUT /dashboard/quality/verdict — the contested
773
+ * drawer's thumbs. Body `{id: number, verdict: 1 | -1}` (numeric thumbs: 1 =
774
+ * useful, -1 = not). Persists grader='owner' (retained forever — the
775
+ * calibration reference; the nightly verdict prune never drops owner
776
+ * rows). Bearer-only like every dashboard writer; localhost bypass
777
+ * applies. 404 on an unknown id,
778
+ * 400 on a malformed body — strict validation, the model-PUT convention.
779
+ */
780
+ export declare function dashboardQualityVerdictPutHandler(getDb: () => Database.Database): express.RequestHandler;