@gamaze/hicortex 0.27.4 → 0.29.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.
Files changed (94) hide show
  1. package/assets/dashboard.html +1898 -3211
  2. package/assets/viz.html +229 -2
  3. package/dist/backfill-privacy.d.ts +68 -45
  4. package/dist/backfill-privacy.js +236 -145
  5. package/dist/calibration.d.ts +67 -68
  6. package/dist/calibration.js +75 -78
  7. package/dist/capture-health.d.ts +2 -2
  8. package/dist/capture-health.js +2 -2
  9. package/dist/classification.d.ts +141 -12
  10. package/dist/classification.js +214 -27
  11. package/dist/classify-domains.d.ts +1 -1
  12. package/dist/classify-domains.js +2 -2
  13. package/dist/cli-args.d.ts +5 -3
  14. package/dist/cli-args.js +7 -3
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +64 -16
  17. package/dist/cluster.d.ts +12 -9
  18. package/dist/cluster.js +9 -6
  19. package/dist/consolidate.d.ts +93 -43
  20. package/dist/consolidate.js +255 -119
  21. package/dist/dashboard.d.ts +48 -5
  22. package/dist/dashboard.js +55 -3
  23. package/dist/db.js +27 -6
  24. package/dist/dedup.d.ts +2 -3
  25. package/dist/dedup.js +2 -3
  26. package/dist/distill-queue.d.ts +36 -4
  27. package/dist/distill-queue.js +80 -18
  28. package/dist/distiller.d.ts +1 -1
  29. package/dist/distiller.js +13 -12
  30. package/dist/domain-classify.d.ts +8 -9
  31. package/dist/domain-classify.js +6 -7
  32. package/dist/graph.d.ts +15 -5
  33. package/dist/graph.js +46 -13
  34. package/dist/hermes-transcript-reader.d.ts +1 -1
  35. package/dist/hermes-transcript-reader.js +1 -1
  36. package/dist/init.d.ts +30 -2
  37. package/dist/init.js +48 -3
  38. package/dist/llm.d.ts +1 -1
  39. package/dist/llm.js +5 -5
  40. package/dist/mcp-server.js +323 -59
  41. package/dist/memory-instructions.d.ts +2 -2
  42. package/dist/memory-instructions.js +2 -2
  43. package/dist/nightly.d.ts +1 -1
  44. package/dist/nightly.js +64 -5
  45. package/dist/nofit.d.ts +2 -2
  46. package/dist/nofit.js +2 -2
  47. package/dist/observed-agents.d.ts +54 -0
  48. package/dist/observed-agents.js +78 -0
  49. package/dist/project-canonicalize.d.ts +6 -5
  50. package/dist/project-canonicalize.js +6 -5
  51. package/dist/prompts.d.ts +29 -8
  52. package/dist/prompts.js +39 -16
  53. package/dist/quality-scoreboard.d.ts +1 -1
  54. package/dist/recall-hook-cli.d.ts +1 -1
  55. package/dist/recall-hook-cli.js +2 -2
  56. package/dist/recall-index.d.ts +28 -14
  57. package/dist/recall-index.js +22 -10
  58. package/dist/recall-precision.d.ts +3 -3
  59. package/dist/recall-precision.js +5 -4
  60. package/dist/reconcile-projects.d.ts +2 -2
  61. package/dist/reconcile-projects.js +2 -2
  62. package/dist/reconsolidation.d.ts +9 -2
  63. package/dist/reconsolidation.js +48 -31
  64. package/dist/relink.d.ts +2 -2
  65. package/dist/relink.js +4 -4
  66. package/dist/rescore-importance.d.ts +2 -2
  67. package/dist/rescore-importance.js +22 -3
  68. package/dist/retrieval.d.ts +14 -0
  69. package/dist/retrieval.js +11 -11
  70. package/dist/schema-prototypes.d.ts +1 -1
  71. package/dist/schema-prototypes.js +1 -1
  72. package/dist/seed-lesson.js +4 -2
  73. package/dist/spaces-api.d.ts +104 -0
  74. package/dist/spaces-api.js +193 -0
  75. package/dist/spaces-cli.d.ts +90 -0
  76. package/dist/spaces-cli.js +245 -0
  77. package/dist/spaces.d.ts +187 -0
  78. package/dist/spaces.js +360 -0
  79. package/dist/storage.d.ts +47 -10
  80. package/dist/storage.js +74 -17
  81. package/dist/sweep-volatile.d.ts +2 -2
  82. package/dist/sweep-volatile.js +2 -2
  83. package/dist/telemetry-cli.d.ts +1 -1
  84. package/dist/telemetry-cli.js +1 -1
  85. package/dist/type-classify.d.ts +1 -1
  86. package/dist/type-classify.js +1 -1
  87. package/dist/type-labels.d.ts +1 -1
  88. package/dist/type-labels.js +1 -1
  89. package/dist/types.d.ts +43 -20
  90. package/dist/wrapper-prompt.d.ts +2 -2
  91. package/dist/wrapper-prompt.js +2 -2
  92. package/opencode-plugin/hicortex/index.ts +562 -364
  93. package/package.json +2 -2
  94. package/server.json +2 -2
package/assets/viz.html CHANGED
@@ -164,6 +164,44 @@
164
164
  padding: 3px 6px; font: inherit;
165
165
  }
166
166
  #panel input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
167
+ /* ---- ranked search browser (#644 round 3) — one results list under the
168
+ existing highlight filter; native dark-blue tokens, the calm accent
169
+ family only (zero neon) ---- */
170
+ #search-results { margin-top: 6px; }
171
+ #search-results:empty { display: none; }
172
+ #search-results .s-state {
173
+ color: var(--text-dim); font-size: 12px; padding: 6px 2px; line-height: 1.5;
174
+ overflow-wrap: break-word;
175
+ }
176
+ #search-results .s-note {
177
+ color: var(--text-dim); font-size: 11px; padding: 6px 2px; line-height: 1.45;
178
+ }
179
+ #search-results .s-row {
180
+ display: block; width: 100%; text-align: left;
181
+ background: transparent; border: none; border-bottom: 1px solid var(--panel-border);
182
+ border-radius: 0; padding: 7px 2px; cursor: pointer; font: inherit; color: var(--text);
183
+ }
184
+ #search-results .s-row:hover { background: rgba(91, 157, 217, 0.10); }
185
+ #search-results .s-row:last-of-type { border-bottom: none; }
186
+ #search-results .s-row .tt {
187
+ font-size: 12.5px; line-height: 1.4; color: var(--text);
188
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
189
+ }
190
+ #search-results .s-row .sn {
191
+ font-size: 11px; color: var(--text-dim); margin-top: 1px;
192
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
193
+ }
194
+ #search-results .s-row .bm {
195
+ color: var(--accent); border: 1px solid var(--accent); border-radius: 999px;
196
+ font-size: 10px; padding: 0 6px; margin-left: 4px;
197
+ }
198
+ #search-results .s-row.weak { opacity: 0.55; }
199
+ #search-results .s-more {
200
+ display: block; width: 100%; text-align: center;
201
+ background: transparent; border: none; border-bottom: 1px solid var(--panel-border);
202
+ color: var(--accent); font: inherit; font-size: 12px; padding: 6px 2px; cursor: pointer;
203
+ }
204
+ #search-results .s-more:hover { background: rgba(91, 157, 217, 0.10); }
167
205
  #panel .val { flex: none; width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
168
206
  #panel button {
169
207
  background: var(--accent); color: #0b0d12; font: inherit; font-weight: 600;
@@ -359,9 +397,14 @@
359
397
  </div>
360
398
 
361
399
  <h2>Search</h2>
362
- <div class="row tip-up" data-tip="Highlight memories matching this text; everything else dims. Clear to reset.">
363
- <input type="text" id="search" placeholder="highlight matching nodes…">
400
+ <div class="row tip-up" data-tip="Rank memories by relevance (server search) AND highlight matching nodes — everything else dims. Clear to reset.">
401
+ <input type="text" id="search" placeholder="search memories…">
364
402
  </div>
403
+ <!-- Ranked search browser (#644 round 3) — the successor of the dashboard
404
+ floor's results list, living under the existing highlight filter.
405
+ Rendered by renderSearchResults(): ranked server rows (GET /search),
406
+ honest states, best-match badge, results tail + expander. -->
407
+ <div id="search-results"></div>
365
408
 
366
409
  <div class="hint">Click a node to read the memory. White halo = hub.</div>
367
410
  </div>
@@ -1470,6 +1513,190 @@
1470
1513
  }
1471
1514
  inpSearch.addEventListener("input", applySearch);
1472
1515
 
1516
+ // =========================================================================
1517
+ // Ranked search browser (#644 round 3) — the successor of the dashboard
1518
+ // floor's results list (moved here by the redesign; built in this PR).
1519
+ // The same mechanics carried from the dashboard floor: a debounced
1520
+ // GET /search (limit 60 — the floor's own convention), ranked server
1521
+ // rows with their MEASURED similarity, the best-match badge (derived
1522
+ // from the max measured similarity, never row position — #425 owns
1523
+ // ranking), the results tail + expander (top 10 full contrast, the rest
1524
+ // dimmed behind the expander), and the honest states (searching… /
1525
+ // failed / no matches; a fabricated zero never stands in for unknown).
1526
+ // AUGMENTS, does not replace, the node-highlight filter above: the
1527
+ // highlight dims the graph for the query; the list surfaces memories
1528
+ // the current graph filters may have hidden. No relevance floor is
1529
+ // sent — viz holds no /dashboard/field echo, and the absent param is
1530
+ // the server's ungated behavior. GET /search only: no new endpoints,
1531
+ // no server changes.
1532
+ // Routing: a row click opens the EXISTING click-to-detail when the
1533
+ // memory is in the current graph; otherwise an honest inline note
1534
+ // (the memory exists but the active filters exclude it — widen and
1535
+ // Apply). There is no browse list here: viz holds no client-side
1536
+ // strength-ranked corpus, so an empty query renders no list (honest
1537
+ // empty state, never dressed as results).
1538
+ // =========================================================================
1539
+ var RESULTS_STRONG_N = 10; // rows shown before the expander (the floor's convention)
1540
+ /** Pure split plan: head rows at full contrast, tail rows behind the
1541
+ * expander. ≤STRONG rows → no expander at all (nothing to fold). */
1542
+ function resultsTailPlan(n, expanded) {
1543
+ if (n <= RESULTS_STRONG_N) return { head: n, tail: 0, expander: null };
1544
+ var t = n - RESULTS_STRONG_N;
1545
+ return { head: RESULTS_STRONG_N, tail: t, expander: (expanded ? "hide weaker" : "weaker") + " matches (" + t + ")" };
1546
+ }
1547
+ function firstLine(s) { var i = s.indexOf("\n"); return i < 0 ? s : s.slice(0, i); }
1548
+ /** The /search URL for one query (fetch-inspection pin): the query param
1549
+ * + the floor's limit-60 convention, nothing else — no floor, no project
1550
+ * filter (the brief's param list; viz has no project context to send). */
1551
+ function searchUrl(q) {
1552
+ return "/search?query=" + encodeURIComponent(q) + "&limit=60";
1553
+ }
1554
+ /** Best MEASURED similarity among the rows — the badge marks the
1555
+ * strongest semantic hit without reordering the server's ranking. */
1556
+ function bestMatchId(rows) {
1557
+ var bestId = null, bestSim = -1;
1558
+ for (var i = 0; i < rows.length; i++) {
1559
+ var r = rows[i];
1560
+ if (r && typeof r.similarity === "number" && r.similarity > bestSim) { bestSim = r.similarity; bestId = r.id; }
1561
+ }
1562
+ return bestId;
1563
+ }
1564
+ function nodeById(id) {
1565
+ for (var i = 0; i < raw.nodes.length; i++) if (raw.nodes[i].id === id) return raw.nodes[i];
1566
+ return null;
1567
+ }
1568
+ /** Render the results panel. `results` mirrors the fetch lifecycle:
1569
+ * null = pending (or failed, per opts.failed), [] = explicit no
1570
+ * matches, rows = ranked render. opts.inGraph(id) routes clicks (the
1571
+ * rig injects a stub; the page passes nodeById). EVERY interpolated
1572
+ * string goes through esc() — the pinned security property. */
1573
+ function renderSearchResults(box, q, results, expanded, opts) {
1574
+ opts = opts || {};
1575
+ var failed = !!opts.failed;
1576
+ var inGraph = opts.inGraph || function () { return false; };
1577
+ box.innerHTML = "";
1578
+ if (!q) return; // empty query → empty panel (honest empty state)
1579
+ if (!results) {
1580
+ var pend = document.createElement("div");
1581
+ pend.className = "s-state";
1582
+ pend.textContent = failed
1583
+ ? "search failed — check the connection and try again"
1584
+ : "searching…";
1585
+ box.appendChild(pend);
1586
+ return;
1587
+ }
1588
+ var count = document.createElement("div");
1589
+ count.className = "s-state";
1590
+ if (!results.length) {
1591
+ count.textContent = "no matches for “" + q + "” — no memories match this phrase";
1592
+ box.appendChild(count);
1593
+ return;
1594
+ }
1595
+ count.textContent = String(results.length) + (results.length === 1 ? " result" : " results") + " for “" + q + "”";
1596
+ box.appendChild(count);
1597
+ var bestId = bestMatchId(results);
1598
+ var tail = resultsTailPlan(results.length, expanded);
1599
+ var mkRow = function (r, i) {
1600
+ var row = document.createElement("button");
1601
+ row.type = "button";
1602
+ row.className = "s-row" + (tail && i >= RESULTS_STRONG_N ? " weak" : "");
1603
+ row.dataset.id = r.id;
1604
+ var title = document.createElement("div");
1605
+ title.className = "tt";
1606
+ title.textContent = r.content ? firstLine(r.content) : "(untitled)";
1607
+ var sub = document.createElement("div");
1608
+ sub.className = "sn";
1609
+ // Honest nulls: each provenance piece renders only when the payload
1610
+ // carries it; similarity renders only when MEASURED (an FTS-only hit
1611
+ // says so instead of inventing a number).
1612
+ var bits = [];
1613
+ if (r.memory_type) bits.push(String(r.memory_type).toLowerCase());
1614
+ if (r.project) bits.push(String(r.project));
1615
+ if (r.source_agent) bits.push(String(r.source_agent));
1616
+ if (r.created_at) bits.push(String(r.created_at).slice(0, 10));
1617
+ if (typeof r.similarity === "number") bits.push("sim " + r.similarity.toFixed(2));
1618
+ else if (r.source === "fts") bits.push("token match");
1619
+ var subHtml = esc(bits.join(" · "));
1620
+ if (r.id === bestId) subHtml += ' · <span class="bm">best match</span>';
1621
+ sub.innerHTML = subHtml;
1622
+ row.appendChild(title);
1623
+ row.appendChild(sub);
1624
+ box.appendChild(row);
1625
+ };
1626
+ // strong window at full contrast → the expander → the dimmed tail
1627
+ for (var i = 0; i < tail.head; i++) mkRow(results[i], i);
1628
+ if (tail.tail > 0) {
1629
+ var exp = document.createElement("button");
1630
+ exp.type = "button";
1631
+ exp.className = "s-more";
1632
+ exp.setAttribute("aria-expanded", expanded ? "true" : "false");
1633
+ exp.textContent = (expanded ? "▾ " : "▸ ") + tail.expander;
1634
+ exp.addEventListener("click", function () {
1635
+ weakExpanded = !weakExpanded;
1636
+ renderSearchResults(document.getElementById("search-results"), searchText, searchRows, weakExpanded, { inGraph: nodeByIdBool });
1637
+ });
1638
+ box.appendChild(exp);
1639
+ if (expanded) for (var j = tail.head; j < results.length; j++) mkRow(results[j], j);
1640
+ }
1641
+ }
1642
+ function nodeByIdBool(id) { return !!nodeById(id); }
1643
+ var searchText = ""; // the trimmed, lower-cased query that owns the panel
1644
+ var searchRows = null; // last /search results (null = pending/failed)
1645
+ var searchFailed = false;
1646
+ var weakExpanded = false; // a new query folds the tail away again
1647
+ var sTimer = null;
1648
+ var searchResultsBox = document.getElementById("search-results");
1649
+ searchResultsBox.addEventListener("click", function (e) {
1650
+ var rowEl = e.target && e.target.closest ? e.target.closest(".s-row") : null;
1651
+ if (!rowEl) return;
1652
+ var n = nodeById(rowEl.dataset.id);
1653
+ if (n) { openDetail(n); return; }
1654
+ // Honest no-route state: the memory exists but the active graph
1655
+ // filters exclude it — say so instead of a silent no-op.
1656
+ var note = document.createElement("div");
1657
+ note.className = "s-note";
1658
+ note.textContent = "That memory is not in the current graph view — widen the filters and Apply to open it.";
1659
+ var old = searchResultsBox.querySelector(".s-note");
1660
+ if (old) old.remove();
1661
+ searchResultsBox.appendChild(note);
1662
+ });
1663
+ // The debounced fetch (the floor's pattern, viz's fetch/auth idiom): a
1664
+ // keystroke clears pending state immediately (the previous query's rows
1665
+ // never linger as if current) and folds the tail; the timer refuses a
1666
+ // box emptied since the keystroke and drops stale responses.
1667
+ inpSearch.addEventListener("input", function (e) {
1668
+ clearTimeout(sTimer);
1669
+ searchFailed = false;
1670
+ searchRows = null;
1671
+ weakExpanded = false;
1672
+ searchText = e.target.value.trim().toLowerCase();
1673
+ renderSearchResults(searchResultsBox, searchText, searchRows, false);
1674
+ if (!searchText) return;
1675
+ sTimer = setTimeout(function () {
1676
+ var q = e.target.value.trim();
1677
+ if (!q) return; // box emptied since the keystroke
1678
+ if (q.toLowerCase() !== searchText) return; // a newer keystroke owns the fetch
1679
+ var headers = {};
1680
+ if (token) headers["Authorization"] = "Bearer " + token;
1681
+ fetch(searchUrl(q), { headers: headers })
1682
+ .then(function (resp) {
1683
+ if (resp.status === 401) { showTokenPrompt(); throw new Error("unauthorized"); }
1684
+ if (!resp.ok) throw new Error("Server error " + resp.status);
1685
+ return resp.json();
1686
+ })
1687
+ .then(function (data) {
1688
+ if (q.toLowerCase() !== searchText) return; // stale response — drop it
1689
+ searchRows = data.results || [];
1690
+ renderSearchResults(searchResultsBox, searchText, searchRows, weakExpanded, { inGraph: nodeByIdBool });
1691
+ })
1692
+ .catch(function (err) {
1693
+ if (err.message === "unauthorized") return; // prompt already shown
1694
+ searchFailed = true;
1695
+ renderSearchResults(searchResultsBox, searchText, null, false, { failed: true });
1696
+ });
1697
+ }, 90);
1698
+ });
1699
+
1473
1700
  // =========================================================================
1474
1701
  // Detail panel — memory content is ALWAYS set via textContent, never
1475
1702
  // innerHTML (pinned security property).
@@ -1,58 +1,73 @@
1
1
  /**
2
- * `hicortex backfill-privacy` (#332) — one-shot classification stamping for
3
- * EXISTING rows, by source agent, and (#609) by workspace path.
2
+ * `hicortex backfill-spaces` (#642 AC-14; the #332 `backfill-privacy` command
3
+ * generalized — the old name stays a hidden alias via resolveCommandAlias) —
4
+ * one-shot space stamping for EXISTING rows, by member roster and workspace
5
+ * path, PER SPACE.
4
6
  *
5
7
  * The intake derivation stamps every NEW delivery; this command heals history
6
- * when the roster or the path patterns change (an agent joins the circle, a
7
- * folder is listed, or the feature lands on a store that already has captures
8
- * from a now-covered birthplace). The plan is a pure function of the config ×
9
- * the rows' stored values:
10
- * - every memories/distill_queue row whose source_agent matches the roster
11
- * (isConfidentialSourceAgent — the same `<harness>/`-stripping matcher the
12
- * intake uses) AND whose privacy != 'confidential' → stamped confidential;
13
- * - #609: every row whose stored `workspace_path` matches a
14
- * `confidentialPaths` pattern (the same pure matcher the intake uses),
15
- * grouped per pattern. NULL-path rows are NEVER path-matched (pre-v28
16
- * rows have no path by construction; they are reported as unmatched, not
17
- * silently stamped). A row matching both a rostered agent and a pattern
18
- * flips once (agent groups claim it first; each remaining row joins its
19
- * first matching pattern so overlapping patterns never double-count);
20
- * - NOTHING is ever stamped BACK to standard (a roster/pattern removal is
21
- * not a demotion — memories stay confidential until the operator
8
+ * when a space's members or paths change (an agent joins a space, a folder
9
+ * tree is listed, or the feature lands on a store that already has captures
10
+ * from a now-covered birthplace). The plan is a pure function of the resolved
11
+ * spaces × the rows' stored values:
12
+ * - every memories/distill_queue row whose source_agent matches a space's
13
+ * members (isConfidentialSourceAgent — the same `<harness>/`-stripping
14
+ * matcher the intake uses) AND is still shared → stamped with that
15
+ * space's id, grouped per (space, stored source_agent);
16
+ * - every row whose stored `workspace_path` matches a space's path pattern
17
+ * (matchesConfidentialPath — the same pure matcher the intake uses),
18
+ * grouped per (space, pattern). NULL-path rows are NEVER path-matched
19
+ * (pre-v28 rows have no path by construction; they are reported as
20
+ * unmatched, not silently stamped);
21
+ * - CANDIDATES are ONLY rows with `privacy IS NULL OR privacy = 'standard'`
22
+ * — an already-stamped row NEVER moves (no demotion, no space→space);
23
+ * today's `!= 'confidential'` was the N=1 equivalent of this rule;
24
+ * - claim order: agent groups first (spaces in config order), then path
25
+ * groups (spaces in config order, patterns in entry order) — the FIRST
26
+ * matching space in config order claims a row (single flip, never
27
+ * double-counted);
28
+ * - NOTHING is ever stamped BACK to standard (a members/pattern removal is
29
+ * not a demotion — memories stay in their space until the operator
22
30
  * explicitly changes them; re-running with a smaller config is a no-op by
23
31
  * design).
24
32
  *
33
+ * A pure-legacy config (confidentialAgents/confidentialPaths, no `spaces`
34
+ * key) resolves to the MATERIALIZED confidential space — byte-identical
35
+ * legacy behavior: the same groups, the same 'confidential' stamps, the same
36
+ * report fields (roster/patterns stay the confidential space's).
37
+ *
25
38
  * Safety rails (the `hicortex dedup` / `reconcile-projects` pattern): dry run
26
39
  * by default (report only, zero writes); `--apply` takes a pre-apply DB
27
40
  * backup (abort all writes on failure), the single-flight capture lock
28
- * (waitMs 0 — busy aborts), and stamps in ONE transaction. The queue rows are
29
- * stamped too: a pre-upgrade queued segment from a covered birthplace would
30
- * otherwise distill as standard (migration v27 normalized it) — the backfill
31
- * closes that seam.
41
+ * (waitMs 0 — busy aborts), and stamps in ONE transaction, with the space id
42
+ * PARAMETERIZED (never interpolated into SQL). The queue rows are stamped
43
+ * too: a pre-upgrade queued segment from a covered birthplace would
44
+ * otherwise distill as standard — the backfill closes that seam.
32
45
  *
33
46
  * Idempotent by construction: a second run finds every covered row already
34
- * confidential and reports zero.
47
+ * stamped and reports zero.
35
48
  */
36
49
  import type Database from "better-sqlite3";
37
50
  import { acquireCaptureLock } from "./capture.js";
38
51
  import { type ConfidentialPathPattern } from "./classification.js";
39
- /** One planned stamp group: rows from one rostered source agent, or (#609)
40
- * from one confidentialPaths pattern. */
52
+ import { type SpaceDef } from "./spaces.js";
53
+ /** One planned stamp group: rows from one space's rostered source agent, or
54
+ * from one space's path pattern. */
41
55
  export interface BackfillGroup {
56
+ /** #642: the space whose birthplace claimed these rows (the stamp value). */
57
+ space: string;
42
58
  /**
43
59
  * The DISTINCT source_agent value as stored (not the roster entry) — or,
44
- * for a #609 path group, the pattern's raw config entry (display label).
60
+ * for a path group, the pattern's raw config entry (display label).
45
61
  */
46
62
  sourceAgent: string;
47
- /** Rows in `memories` that would flip to confidential. */
63
+ /** Rows in `memories` that would flip to the space. */
48
64
  memoryRows: number;
49
- /** Rows in `distill_queue` that would flip (distill as confidential). */
65
+ /** Rows in `distill_queue` that would flip (distill into the space). */
50
66
  queuedRows: number;
51
67
  /**
52
- * #609: the pattern this group matches — present on path groups only.
53
- * Path groups stamp by exact row ids (the matcher is JS-side; SQL cannot
54
- * express the three pattern forms); agent groups leave these unset and
55
- * stamp by the source_agent predicate.
68
+ * Present on path groups only. Path groups stamp by exact row ids (the
69
+ * matcher is JS-side; SQL cannot express the three pattern forms); agent
70
+ * groups leave these unset and stamp by the source_agent predicate.
56
71
  */
57
72
  pattern?: ConfidentialPathPattern;
58
73
  memoryIds?: string[];
@@ -60,9 +75,11 @@ export interface BackfillGroup {
60
75
  }
61
76
  export interface BackfillReport {
62
77
  dryRun: boolean;
63
- /** The roster entries the plan matched (subset of confidentialAgents). */
78
+ /** The LEGACY report fields: the (materialized or explicit) confidential
79
+ * space's roster — [] when no confidential space exists. Groups carry the
80
+ * per-space truth. */
64
81
  roster: string[];
65
- /** #609: the resolved confidentialPaths entries (raw strings). */
82
+ /** The confidential space's raw path patterns (legacy field, same rule). */
66
83
  patterns: string[];
67
84
  /** Planned/executed stamp groups, largest first. */
68
85
  groups: BackfillGroup[];
@@ -91,19 +108,25 @@ export interface BackfillOptions {
91
108
  acquireLock?: typeof acquireCaptureLock;
92
109
  }
93
110
  /**
94
- * The pure plan: which stored source_agent values match the roster, and how
95
- * many of their rows are not yet confidential. Roster matching uses the
111
+ * The pure plan. #642 AC-14: `planBackfill(db, resolveSpaces(config).spaces)`
112
+ * plans per-space groups; the legacy `planBackfill(db, roster, patterns)`
113
+ * form delegates with the confidential space. Roster matching uses the
96
114
  * INTAKE matcher (isConfidentialSourceAgent — `<harness>/`-stripping) so the
97
- * backfill and the intake can never disagree about who is rostered. #609 adds
98
- * the per-pattern groups (see planPathGroups) alongside the agent groups —
99
- * same rails, same never-demotes rule.
115
+ * backfill and the intake can never disagree about who is a member; path
116
+ * matching uses the intake's pure matcher over the stored workspace_path.
117
+ * Candidates are ONLY still-shared rows (privacy IS NULL OR 'standard') — an
118
+ * already-stamped row never moves.
100
119
  */
101
- export declare function planBackfill(db: Database.Database, roster: string[], patterns?: ConfidentialPathPattern[]): BackfillGroup[];
120
+ export declare function planBackfill(db: Database.Database, rosterOrSpaces: string[] | SpaceDef[], patterns?: ConfidentialPathPattern[]): BackfillGroup[];
102
121
  /**
103
- * Run `hicortex backfill-privacy`. Dry run by default (options.apply falsy) —
104
- * plan + report only, zero writes. `options.apply` executes: backup, capture
105
- * lock, ONE transaction stamping every planned row in BOTH tables. A busy
106
- * lock is an abort (reported as `lockBusy: true`, never a wait); a failed
107
- * backup aborts all writes (throw, like dedup/reconcile-projects).
122
+ * Run `hicortex backfill-spaces` (alias `backfill-privacy`). Dry run by
123
+ * default (options.apply falsy) — plan + report only, zero writes.
124
+ * `options.apply` executes: backup, capture lock, ONE transaction stamping
125
+ * every planned row in BOTH tables with its group's space id (parameterized
126
+ * SQL). A busy lock is an abort (reported as `lockBusy: true`, never a
127
+ * wait); a failed backup aborts all writes (throw, like
128
+ * dedup/reconcile-projects).
108
129
  */
109
130
  export declare function runBackfillPrivacy(options?: BackfillOptions): Promise<BackfillReport>;
131
+ /** #642: the canonical command name — same runner, clearer export. */
132
+ export declare const runBackfillSpaces: typeof runBackfillPrivacy;