@gamaze/hicortex 0.27.4 → 0.28.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/assets/dashboard.html +361 -100
- package/dist/backfill-privacy.d.ts +68 -45
- package/dist/backfill-privacy.js +236 -145
- package/dist/calibration.d.ts +67 -68
- package/dist/calibration.js +75 -78
- package/dist/capture-health.d.ts +2 -2
- package/dist/capture-health.js +2 -2
- package/dist/classification.d.ts +141 -12
- package/dist/classification.js +214 -27
- package/dist/classify-domains.d.ts +1 -1
- package/dist/classify-domains.js +2 -2
- package/dist/cli-args.d.ts +5 -3
- package/dist/cli-args.js +7 -3
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +64 -16
- package/dist/cluster.d.ts +12 -9
- package/dist/cluster.js +9 -6
- package/dist/consolidate.d.ts +93 -43
- package/dist/consolidate.js +255 -119
- package/dist/dashboard.d.ts +48 -5
- package/dist/dashboard.js +55 -3
- package/dist/db.js +27 -6
- package/dist/dedup.d.ts +2 -3
- package/dist/dedup.js +2 -3
- package/dist/distill-queue.d.ts +36 -4
- package/dist/distill-queue.js +80 -18
- package/dist/distiller.d.ts +1 -1
- package/dist/distiller.js +13 -12
- package/dist/domain-classify.d.ts +8 -9
- package/dist/domain-classify.js +6 -7
- package/dist/graph.d.ts +15 -5
- package/dist/graph.js +46 -13
- package/dist/hermes-transcript-reader.d.ts +1 -1
- package/dist/hermes-transcript-reader.js +1 -1
- package/dist/init.d.ts +2 -2
- package/dist/init.js +3 -3
- package/dist/llm.d.ts +1 -1
- package/dist/llm.js +5 -5
- package/dist/mcp-server.js +323 -59
- package/dist/memory-instructions.d.ts +2 -2
- package/dist/memory-instructions.js +2 -2
- package/dist/nightly.d.ts +1 -1
- package/dist/nightly.js +64 -5
- package/dist/nofit.d.ts +2 -2
- package/dist/nofit.js +2 -2
- package/dist/observed-agents.d.ts +54 -0
- package/dist/observed-agents.js +78 -0
- package/dist/project-canonicalize.d.ts +6 -5
- package/dist/project-canonicalize.js +6 -5
- package/dist/prompts.d.ts +29 -8
- package/dist/prompts.js +39 -16
- package/dist/quality-scoreboard.d.ts +1 -1
- package/dist/recall-hook-cli.d.ts +1 -1
- package/dist/recall-hook-cli.js +2 -2
- package/dist/recall-index.d.ts +28 -14
- package/dist/recall-index.js +22 -10
- package/dist/recall-precision.d.ts +3 -3
- package/dist/recall-precision.js +5 -4
- package/dist/reconcile-projects.d.ts +2 -2
- package/dist/reconcile-projects.js +2 -2
- package/dist/reconsolidation.d.ts +9 -2
- package/dist/reconsolidation.js +48 -31
- package/dist/relink.d.ts +2 -2
- package/dist/relink.js +4 -4
- package/dist/rescore-importance.d.ts +2 -2
- package/dist/rescore-importance.js +22 -3
- package/dist/retrieval.d.ts +14 -0
- package/dist/retrieval.js +11 -11
- package/dist/schema-prototypes.d.ts +1 -1
- package/dist/schema-prototypes.js +1 -1
- package/dist/seed-lesson.js +4 -2
- package/dist/spaces-api.d.ts +104 -0
- package/dist/spaces-api.js +193 -0
- package/dist/spaces-cli.d.ts +90 -0
- package/dist/spaces-cli.js +245 -0
- package/dist/spaces.d.ts +187 -0
- package/dist/spaces.js +360 -0
- package/dist/storage.d.ts +47 -10
- package/dist/storage.js +74 -17
- package/dist/sweep-volatile.d.ts +2 -2
- package/dist/sweep-volatile.js +2 -2
- package/dist/telemetry-cli.d.ts +1 -1
- package/dist/telemetry-cli.js +1 -1
- package/dist/type-classify.d.ts +1 -1
- package/dist/type-classify.js +1 -1
- package/dist/type-labels.d.ts +1 -1
- package/dist/type-labels.js +1 -1
- package/dist/types.d.ts +43 -20
- package/dist/wrapper-prompt.d.ts +2 -2
- package/dist/wrapper-prompt.js +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/cli-args.js
CHANGED
|
@@ -33,14 +33,18 @@ function readValueFlag(argv, flag) {
|
|
|
33
33
|
* Normalize a raw CLI command word. Hidden aliases resolve to their canonical
|
|
34
34
|
* name so the cli.ts dispatch switch only spells the canonical form. Aliases
|
|
35
35
|
* today (#264 rename): `context` → `identity` and `lessons-context` →
|
|
36
|
-
* `learnings-identity`;
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* `learnings-identity`; #642 rename: `backfill-privacy` → `backfill-spaces`
|
|
37
|
+
* (the confidential N=1 command generalized to per-space stamping). Kept so
|
|
38
|
+
* old scripts, installed hooks, and muscle memory keep working. Pure +
|
|
39
|
+
* side-effect-free (unlike cli.ts, which dispatches on import) so it can be
|
|
40
|
+
* unit-tested directly.
|
|
39
41
|
*/
|
|
40
42
|
function resolveCommandAlias(raw) {
|
|
41
43
|
if (raw === "context")
|
|
42
44
|
return "identity";
|
|
43
45
|
if (raw === "lessons-context")
|
|
44
46
|
return "learnings-identity";
|
|
47
|
+
if (raw === "backfill-privacy")
|
|
48
|
+
return "backfill-spaces";
|
|
45
49
|
return raw;
|
|
46
50
|
}
|
package/dist/cli.d.ts
CHANGED
|
@@ -27,5 +27,7 @@
|
|
|
27
27
|
* history --rollback <row> Undo one rewrite + un-absorb triggers
|
|
28
28
|
* status Show config, DB stats, adapter status
|
|
29
29
|
* uninstall Clean removal of CC integration
|
|
30
|
+
* space Manage spaces — private memory pools (#642): list, assign,
|
|
31
|
+
* unassign, or `space <name>` inside a workspace (one command)
|
|
30
32
|
*/
|
|
31
33
|
export {};
|
package/dist/cli.js
CHANGED
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
* history --rollback <row> Undo one rewrite + un-absorb triggers
|
|
29
29
|
* status Show config, DB stats, adapter status
|
|
30
30
|
* uninstall Clean removal of CC integration
|
|
31
|
+
* space Manage spaces — private memory pools (#642): list, assign,
|
|
32
|
+
* unassign, or `space <name>` inside a workspace (one command)
|
|
31
33
|
*/
|
|
32
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
35
|
const cli_args_js_1 = require("./cli-args.js");
|
|
@@ -337,10 +339,13 @@ switch (command) {
|
|
|
337
339
|
});
|
|
338
340
|
break;
|
|
339
341
|
}
|
|
340
|
-
case "backfill-
|
|
341
|
-
// One-shot
|
|
342
|
-
//
|
|
343
|
-
//
|
|
342
|
+
case "backfill-spaces": {
|
|
343
|
+
// One-shot space stamping for EXISTING rows (#642 AC-14; the #332
|
|
344
|
+
// `backfill-privacy` command generalized — the legacy spelling resolves
|
|
345
|
+
// here via resolveCommandAlias, flags identical): every still-SHARED row
|
|
346
|
+
// whose source_agent matches a space's members, or whose stored
|
|
347
|
+
// workspace_path matches a space's pattern, flips to that space; an
|
|
348
|
+
// already-stamped row NEVER moves. Mirrors `dedup`/`reconcile-projects`:
|
|
344
349
|
// dry-run default, --apply explicit (backup + capture lock + ONE
|
|
345
350
|
// transaction); flags parsed here, the runner lives in
|
|
346
351
|
// backfill-privacy.ts so this switch stays thin.
|
|
@@ -350,13 +355,13 @@ switch (command) {
|
|
|
350
355
|
dbPath = (0, cli_args_js_1.readValueFlag)(args, "--db");
|
|
351
356
|
}
|
|
352
357
|
catch {
|
|
353
|
-
console.error("[hicortex] backfill-
|
|
358
|
+
console.error("[hicortex] backfill-spaces: --db requires a path value");
|
|
354
359
|
process.exit(1);
|
|
355
360
|
}
|
|
356
361
|
const backfillOptions = { apply: args.includes("--apply"), dbPath };
|
|
357
|
-
import("./backfill-privacy.js").then(({
|
|
358
|
-
|
|
359
|
-
console.error(err instanceof Error ? err.message : `[hicortex] backfill-
|
|
362
|
+
import("./backfill-privacy.js").then(({ runBackfillSpaces }) => {
|
|
363
|
+
runBackfillSpaces(backfillOptions).catch((err) => {
|
|
364
|
+
console.error(err instanceof Error ? err.message : `[hicortex] backfill-spaces failed: ${err}`);
|
|
360
365
|
process.exit(1);
|
|
361
366
|
});
|
|
362
367
|
});
|
|
@@ -389,6 +394,30 @@ switch (command) {
|
|
|
389
394
|
});
|
|
390
395
|
break;
|
|
391
396
|
}
|
|
397
|
+
case "space": {
|
|
398
|
+
// #642 AC-13: space management against the AC-10 admin API — the SAME
|
|
399
|
+
// endpoints the dashboard's space management card drives (one API, two
|
|
400
|
+
// interfaces). `space list|assign|unassign` are the explicit forms; ANY
|
|
401
|
+
// other argv[3] is a SPACE NAME — the one-command form that assigns the
|
|
402
|
+
// CURRENT workspace (its #600 sanitized basename as the agent id). Bare
|
|
403
|
+
// `space` prints the usage: there is no create/remove (a space exists by
|
|
404
|
+
// config presence, the `domains` precedent). The runner owns URL/token
|
|
405
|
+
// resolution + authed fetch (the identity-cli layout); this stays thin.
|
|
406
|
+
const args = process.argv.slice(3);
|
|
407
|
+
import("./spaces-cli.js").then(({ runSpacesCommand, SpacesCliError }) => {
|
|
408
|
+
runSpacesCommand(args).catch((err) => {
|
|
409
|
+
if (err instanceof SpacesCliError)
|
|
410
|
+
console.error(err.message);
|
|
411
|
+
else
|
|
412
|
+
console.error("[hicortex] space command failed:", err instanceof Error ? err.message : err);
|
|
413
|
+
process.exit(1);
|
|
414
|
+
});
|
|
415
|
+
}).catch((err) => {
|
|
416
|
+
console.error("[hicortex] space command failed:", err);
|
|
417
|
+
process.exit(1);
|
|
418
|
+
});
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
392
421
|
case "sweep-volatile": {
|
|
393
422
|
// One-shot store sweep of volatile GH-status/version rows (#489,
|
|
394
423
|
// deliverable iii): reuses the distill path's deterministic gate over the
|
|
@@ -552,13 +581,21 @@ Commands:
|
|
|
552
581
|
relink Resumable link-discovery pass over the ENTIRE corpus (server mode)
|
|
553
582
|
dedup Cluster + merge near-duplicate memories (server mode; dry run by default)
|
|
554
583
|
reconcile-projects Canonicalize existing project labels (server mode; dry run by default)
|
|
555
|
-
backfill-
|
|
556
|
-
dry run by default — --apply executes: backup +
|
|
584
|
+
backfill-spaces Stamp history by space assignment — members + path patterns, per space
|
|
585
|
+
(#642; server mode; dry run by default — --apply executes: backup +
|
|
586
|
+
capture lock + stamp; never moves an already-stamped row)
|
|
587
|
+
(alias: backfill-privacy — the pre-#642 name, kept for backcompat)
|
|
557
588
|
confidential Mark a workspace folder confidential via a local marker file
|
|
558
589
|
(#616: the marker carries the server's confidentialMarkerKey,
|
|
559
590
|
provisioned by this very command — fetched from the server,
|
|
560
591
|
or generated + registered there on first use; --key <value>
|
|
561
592
|
rotates); confidential [path] writes, --off [path] removes
|
|
593
|
+
space Manage spaces — private memory pools (#642)
|
|
594
|
+
space list spaces, members, counts, unassigned agents
|
|
595
|
+
space assign <agent> <space> add an agent to a space (applies live)
|
|
596
|
+
space unassign <agent> <space> remove an agent (it drops to shared-only)
|
|
597
|
+
space <name> inside a workspace: assign it in one command
|
|
598
|
+
(no create/remove — a space exists by config presence, the domains precedent)
|
|
562
599
|
history Show a memory's rewrite history, or roll one back (server mode)
|
|
563
600
|
history <id> List rewrite events (read-only)
|
|
564
601
|
history --rollback <row> Undo one rewrite + un-absorb its triggers
|
|
@@ -597,12 +634,14 @@ Options:
|
|
|
597
634
|
reconcile-projects --apply Execute the project renames (default: dry run, report only)
|
|
598
635
|
Backup first; renames memories + distill_queue only
|
|
599
636
|
reconcile-projects --db <path> DB path override (defaults to the configured DB)
|
|
600
|
-
backfill-
|
|
601
|
-
Backup + capture lock first; stamps memories + distill_queue
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
637
|
+
backfill-spaces --apply Execute the stamps (default: dry run, report only)
|
|
638
|
+
Backup + capture lock first; stamps memories + distill_queue
|
|
639
|
+
shared → space ONLY (per-space member rosters + path patterns
|
|
640
|
+
over the stored workspace_path); an already-stamped row NEVER
|
|
641
|
+
moves (no demotion, no space→space); NULL-path rows are never
|
|
642
|
+
path-matched
|
|
643
|
+
backfill-spaces --db <path> DB path override (defaults to the configured DB)
|
|
644
|
+
(the legacy 'backfill-privacy' spelling remains as a hidden alias)
|
|
606
645
|
confidential [path] Mark a folder confidential — writes .hicortex-confidential carrying
|
|
607
646
|
the server's confidentialMarkerKey at its root (default path: cwd).
|
|
608
647
|
ONE command, no manual key mirroring (#616): no local key → fetch
|
|
@@ -618,6 +657,15 @@ Options:
|
|
|
618
657
|
previous key then stamp standard. The server refuses (409) while
|
|
619
658
|
its HICORTEX_CONFIDENTIAL_MARKER_KEY env override is set
|
|
620
659
|
confidential --off [path] Remove the marker (succeeds when absent; no key needed, no network)
|
|
660
|
+
space list Every configured space (members, memory counts, llm posture) plus the
|
|
661
|
+
observed agents assigned to no space (#642)
|
|
662
|
+
space assign <agent> <space> Add an agent to a space (writes the server's config, applies live)
|
|
663
|
+
space unassign <agent> <space> Remove an agent from a space (it drops to shared-only; already-
|
|
664
|
+
captured memories stay stamped)
|
|
665
|
+
space <name> Run INSIDE a workspace: assigns THIS workspace (its folder name, the
|
|
666
|
+
#600 agent grammar) to space <name> — the one-command form.
|
|
667
|
+
No create/remove: a space exists by config presence (the domains
|
|
668
|
+
precedent) — add a spaces.<id> entry to config.json on the server
|
|
621
669
|
history --rollback <row> Roll back history row <row>: restores prior content/status, un-absorbs triggers
|
|
622
670
|
history --db <path> DB path override (defaults to the configured DB)
|
|
623
671
|
backup --out <dir> Write the artifact into <dir> as hicortex-<ISO>.tar.gz (default: <home>/backups)
|
package/dist/cluster.d.ts
CHANGED
|
@@ -30,11 +30,12 @@ export declare function clusterExcess(clusters: string[][]): number;
|
|
|
30
30
|
* rail was REMOVED (#206 decision 2) —
|
|
31
31
|
* cross-agent clusters merge, because attribution survives on the retained
|
|
32
32
|
* absorbed-loser row and no recall path filters by source_agent. Project is
|
|
33
|
-
* one rail; `privacy` (the #
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* classification-shaped rail #206 removed when
|
|
33
|
+
* one rail; `privacy` (the #642 space stamp, of which the #332
|
|
34
|
+
* standard|confidential pair is the N=1 case) is the other — a cluster
|
|
35
|
+
* mixing SPACES is NEVER blended (one pool must not absorb another pool's
|
|
36
|
+
* rows into hidden view, nor leak its content onto another pool's
|
|
37
|
+
* canonical). This re-adds a classification-shaped rail #206 removed when
|
|
38
|
+
* the column was vestigial. */
|
|
38
39
|
export interface ClusterMetaRow {
|
|
39
40
|
project: string | null;
|
|
40
41
|
privacy: string | null;
|
|
@@ -42,12 +43,14 @@ export interface ClusterMetaRow {
|
|
|
42
43
|
}
|
|
43
44
|
export interface ClusterMetadataMismatch {
|
|
44
45
|
projectMismatch: boolean;
|
|
45
|
-
/** #332: members disagree on
|
|
46
|
+
/** #332/#642: members disagree on their SPACE (any two distinct space ids,
|
|
47
|
+
* including standard-vs-confidential — the rail is now space-shaped and
|
|
48
|
+
* strictly wider than the old two-class check). */
|
|
46
49
|
classificationMismatch: boolean;
|
|
47
50
|
}
|
|
48
|
-
/** Do cluster members disagree on project or
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
+
/** Do cluster members disagree on project or space? (merge-safety input for
|
|
52
|
+
* #100/#206 + #332/#642.) source_agent is intentionally NOT checked — see
|
|
53
|
+
* ClusterMetaRow. */
|
|
51
54
|
export declare function clusterMetadataMismatch(members: ClusterMetaRow[]): ClusterMetadataMismatch;
|
|
52
55
|
/**
|
|
53
56
|
* Build the max-cosine edge set via top-K KNN on `memory_vectors`, keeping
|
package/dist/cluster.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.clusterExcess = clusterExcess;
|
|
|
14
14
|
exports.clusterMetadataMismatch = clusterMetadataMismatch;
|
|
15
15
|
exports.buildKnnEdges = buildKnnEdges;
|
|
16
16
|
const retrieval_js_1 = require("./retrieval.js");
|
|
17
|
+
const spaces_js_1 = require("./spaces.js");
|
|
17
18
|
// ---------------------------------------------------------------------------
|
|
18
19
|
// Union-Find (pure — unit tested)
|
|
19
20
|
// ---------------------------------------------------------------------------
|
|
@@ -69,14 +70,16 @@ function clusterEdges(edges, threshold) {
|
|
|
69
70
|
function clusterExcess(clusters) {
|
|
70
71
|
return clusters.reduce((sum, c) => sum + (c.length - 1), 0);
|
|
71
72
|
}
|
|
72
|
-
/** Do cluster members disagree on project or
|
|
73
|
-
*
|
|
74
|
-
*
|
|
73
|
+
/** Do cluster members disagree on project or space? (merge-safety input for
|
|
74
|
+
* #100/#206 + #332/#642.) source_agent is intentionally NOT checked — see
|
|
75
|
+
* ClusterMetaRow. */
|
|
75
76
|
function clusterMetadataMismatch(members) {
|
|
76
77
|
const projects = new Set(members.map((m) => m.project ?? "\u0000null"));
|
|
77
|
-
// The
|
|
78
|
-
// the
|
|
79
|
-
|
|
78
|
+
// The space comparison runs through spaceOf: NULL/''/'standard' (pre-v27
|
|
79
|
+
// rows, the fixed shared pool) all read 'standard', every other stamp is
|
|
80
|
+
// its own space — so the rail blocks cross-space merges AND still blocks
|
|
81
|
+
// the standard-vs-confidential blend #332 introduced it for.
|
|
82
|
+
const classes = new Set(members.map((m) => (0, spaces_js_1.spaceOf)(m.privacy)));
|
|
80
83
|
return {
|
|
81
84
|
projectMismatch: projects.size > 1,
|
|
82
85
|
classificationMismatch: classes.size > 1,
|
package/dist/consolidate.d.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* Ported from hicortex/consolidate/ (stages.py, __init__.py, budget.py).
|
|
5
5
|
*/
|
|
6
6
|
import type Database from "better-sqlite3";
|
|
7
|
-
import type { Memory, ConsolidationReport
|
|
8
|
-
import type { LlmClient } from "./llm.js";
|
|
7
|
+
import type { Memory, ConsolidationReport } from "./types.js";
|
|
8
|
+
import type { LlmClient, LlmConfig } from "./llm.js";
|
|
9
|
+
import { type SpaceDef } from "./spaces.js";
|
|
9
10
|
import type { EmbedFn } from "./retrieval.js";
|
|
10
11
|
import { type DomainDef } from "./domain-classify.js";
|
|
11
12
|
import { type ReconsolidationOptions } from "./reconsolidation.js";
|
|
@@ -15,10 +16,10 @@ import type { RunDeadline } from "./run-deadline.js";
|
|
|
15
16
|
* #241 consolidateMaxLlmCalls mechanism, renamed and widened). A runaway
|
|
16
17
|
* BACKSTOP that bounds money/load INDEPENDENT OF LATENCY — a fast metered or
|
|
17
18
|
* capacity-limited endpoint permits thousands of calls inside the wall-clock
|
|
18
|
-
* budget, so time alone cannot protect it
|
|
19
|
+
* budget, so time alone cannot protect it. Consumed
|
|
19
20
|
* in run order: a stage that exhausts it defers its remainder via its cursor.
|
|
20
|
-
* 5000 clears a one-time classification backlog
|
|
21
|
-
*
|
|
21
|
+
* 5000 clears a one-time classification backlog in a couple of runs with
|
|
22
|
+
* margin. Config: `nightlyLlmCallBudget` (#405); the old
|
|
22
23
|
* `consolidateMaxLlmCalls` key is a deprecated alias honored one release.
|
|
23
24
|
*/
|
|
24
25
|
export declare const DEFAULT_NIGHTLY_LLM_CALL_BUDGET = 5000;
|
|
@@ -33,12 +34,12 @@ export declare function resolveNightlyLlmCallBudget(config: Record<string, unkno
|
|
|
33
34
|
/**
|
|
34
35
|
* Minimum COSINE similarity for a link candidate.
|
|
35
36
|
*
|
|
36
|
-
* Calibration
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* top-3 cap yields ≈ 2
|
|
37
|
+
* Calibration: measured top-10 neighbor cosine histogram on a
|
|
38
|
+
* several-thousand-memory production corpus — typical top-1 neighbor cosine
|
|
39
|
+
* sits in the mid-0.8s. Threshold 0.75 combined with the
|
|
40
|
+
* top-3 cap yields ≈ 2 candidate links/memory. The previous value (0.55)
|
|
40
41
|
* lived on an accidental 1−L2 scale where it required cosine > 0.90 — a
|
|
41
|
-
* near-duplicate detector that linked only
|
|
42
|
+
* near-duplicate detector that linked only a small fraction of memories.
|
|
42
43
|
*/
|
|
43
44
|
export declare const CONSOLIDATE_LINK_THRESHOLD = 0.75;
|
|
44
45
|
/** Max link candidates kept per memory (highest-cosine neighbors first). */
|
|
@@ -57,9 +58,10 @@ export declare const CONSOLIDATE_LINK_FETCH_MAX_K = 200;
|
|
|
57
58
|
/**
|
|
58
59
|
* Minimum COSINE similarity for a CROSS-PROJECT link candidate.
|
|
59
60
|
*
|
|
60
|
-
* A
|
|
61
|
-
* wrong-link
|
|
62
|
-
* (wrong-link
|
|
61
|
+
* A many-judge link audit found cross-project links were overwhelmingly
|
|
62
|
+
* wrong-link while same-project links were mostly right, and that strength
|
|
63
|
+
* (cosine) predicts quality (the wrong-link share fell steadily across
|
|
64
|
+
* strength quartiles). Cross-project pairs must clear
|
|
63
65
|
* a much higher bar than the same-project 0.75 to survive discovery. Same-project
|
|
64
66
|
* links keep CONSOLIDATE_LINK_THRESHOLD (0.75).
|
|
65
67
|
*/
|
|
@@ -198,27 +200,52 @@ export declare function scoreMemoriesImportance(db: Database.Database, memories:
|
|
|
198
200
|
onBatch?: (written: number, failed: number) => void;
|
|
199
201
|
/**
|
|
200
202
|
* #332: the confidential-pool client. The batch builder partitions the
|
|
201
|
-
* pool by
|
|
202
|
-
* by construction), so every LLM call carries one
|
|
203
|
+
* pool by SPACE FIRST (buildImportanceBatches — batches are single-space
|
|
204
|
+
* by construction), so every LLM call carries one space's text to one
|
|
203
205
|
* client. Confidential batches without a client are SKIPPED (their rows
|
|
204
206
|
* keep importance_scored_at NULL — the watermark pool re-finds them next
|
|
205
207
|
* run; counted in skipped_confidential), never scored on the main model.
|
|
206
208
|
*/
|
|
207
209
|
confidentialLlm?: LlmClient | null;
|
|
210
|
+
/**
|
|
211
|
+
* #642: per-space clients (every configured space except 'confidential').
|
|
212
|
+
* A batch whose space has no client HOLDS exactly like the confidential
|
|
213
|
+
* pool — counted per space id in skipped_spaces, never scored on the
|
|
214
|
+
* main model. Absent = a legacy two-pool run (any other space id holds).
|
|
215
|
+
*/
|
|
216
|
+
spaceClients?: Map<string, LlmClient | null>;
|
|
217
|
+
/** #642: the configured space order for batch emission (config key
|
|
218
|
+
* order). Absent = the pre-#642 ['confidential'] two-pool order. */
|
|
219
|
+
spaceOrder?: string[];
|
|
208
220
|
}): Promise<{
|
|
209
221
|
scored: number;
|
|
210
222
|
failed: number;
|
|
211
223
|
skipped_budget: number;
|
|
212
224
|
skipped_confidential?: number;
|
|
225
|
+
/** #642: rows held per space id (no client for that space). */
|
|
226
|
+
skipped_spaces?: Record<string, number>;
|
|
213
227
|
}>;
|
|
214
228
|
/**
|
|
215
|
-
* #332 — the importance batch builder: partition by
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
229
|
+
* #332/#642 — the importance batch builder: partition by SPACE (spaceOf —
|
|
230
|
+
* 'standard' is the shared pool, every other stamp its own space), then
|
|
231
|
+
* slice into batches. Every batch is SINGLE-SPACE by construction (AC-10
|
|
232
|
+
* widened to N pools), so the scoring call site can route each batch to the
|
|
233
|
+
* client matching its space with no per-item checks. Exported for the unit
|
|
234
|
+
* test.
|
|
235
|
+
*
|
|
236
|
+
* Emission order (#642, deterministic): the shared pool first (arrival
|
|
237
|
+
* order), then the `spaceOrder` sequence (the CONFIG key order —
|
|
238
|
+
* resolveSpaces preserves it), then any residual stored ids no configured
|
|
239
|
+
* space claims, in first-appearance order. A residual (stored-but-retired)
|
|
240
|
+
* id has no client by construction, so its batches HOLD at the call site —
|
|
241
|
+
* retired rows are reported as held, never scored, never lost.
|
|
219
242
|
*/
|
|
220
|
-
export declare function buildImportanceBatches(memories: Memory[], batchSize?: number
|
|
221
|
-
|
|
243
|
+
export declare function buildImportanceBatches(memories: Memory[], batchSize?: number,
|
|
244
|
+
/** #642: the configured space ids in config order. The default keeps the
|
|
245
|
+
* pre-#642 two-pool output (standard then confidential) for every
|
|
246
|
+
* existing caller. */
|
|
247
|
+
spaceOrder?: string[]): Array<{
|
|
248
|
+
pool: string;
|
|
222
249
|
memories: Memory[];
|
|
223
250
|
}>;
|
|
224
251
|
/**
|
|
@@ -243,28 +270,29 @@ export interface LinkCandidate {
|
|
|
243
270
|
/**
|
|
244
271
|
* Discovery: find link candidates for one memory given its embedding.
|
|
245
272
|
* Vector neighbors (excluding self), keep the CONSOLIDATE_LINK_TOP_K
|
|
246
|
-
* highest-cosine SAME-
|
|
273
|
+
* highest-cosine SAME-SPACE neighbors above CONSOLIDATE_LINK_THRESHOLD,
|
|
247
274
|
* pre-compute the heuristic relationship type.
|
|
248
275
|
*
|
|
249
|
-
* #602 — ADAPTIVE
|
|
250
|
-
*
|
|
276
|
+
* #602 — ADAPTIVE SPACE-SCOPED FETCH (class-scoped at birth, space-scoped
|
|
277
|
+
* since #642). The pre-#602 code fetched a fixed
|
|
278
|
+
* top-10 UNFILTERED window and then dropped cross-space neighbors in the
|
|
251
279
|
* loop — the #192 filtered-over-fetch defect class. Starvation math: when
|
|
252
|
-
* the
|
|
253
|
-
* memory's 10 nearest neighbors are usually ALL
|
|
254
|
-
* topically distinct but the majority
|
|
255
|
-
*
|
|
280
|
+
* the shared pool heavily outnumbers a private space, a private
|
|
281
|
+
* memory's 10 nearest neighbors are usually ALL shared (the spaces are
|
|
282
|
+
* topically distinct but the majority pool is much larger), so the
|
|
283
|
+
* private pool systematically under-linked — its same-space neighbors
|
|
256
284
|
* never made the window. The fix
|
|
257
285
|
* escalates the window (k × 4 per step, capped at CONSOLIDATE_LINK_FETCH_MAX_K
|
|
258
286
|
* = the #192 over-fetch cap) until the window holds CONSOLIDATE_LINK_TOP_K
|
|
259
|
-
* same-
|
|
287
|
+
* same-space neighbors, comes back short (no more rows may exist), or hits
|
|
260
288
|
* the cap. Balanced corpora do ZERO extra queries (the first window already
|
|
261
|
-
* holds 3+ same-
|
|
289
|
+
* holds 3+ same-space neighbors).
|
|
262
290
|
*
|
|
263
|
-
* WHY the
|
|
291
|
+
* WHY the space is not denormalized into the vec0 table (a WHERE clause
|
|
264
292
|
* would make this a one-fetch query): memory_vectors carries only id +
|
|
265
293
|
* embedding, and privacy is MUTABLE post-insert (`hicortex backfill-privacy`
|
|
266
|
-
* and REST /update can reclassify a row) — a vec0-side
|
|
267
|
-
* stale the moment a row's
|
|
294
|
+
* and REST /update can reclassify a row) — a vec0-side space column would go
|
|
295
|
+
* stale the moment a row's stamp changed without a re-embed. The space is
|
|
268
296
|
* read live from memories, so it can never disagree with the row.
|
|
269
297
|
*
|
|
270
298
|
* Shared between the nightly `stageLinks` (which embeds via embedFn) and
|
|
@@ -274,9 +302,9 @@ export declare function discoverLinkCandidates(db: Database.Database, mem: Memor
|
|
|
274
302
|
/**
|
|
275
303
|
* Classification: assign a relationship type to each candidate link.
|
|
276
304
|
*
|
|
277
|
-
* HEURISTIC-ONLY
|
|
278
|
-
*
|
|
279
|
-
* types near-useless (
|
|
305
|
+
* HEURISTIC-ONLY. LLM edge classification was retired after a comprehensive
|
|
306
|
+
* link audit (see the Stage 3 header) found the LLM-classified UPPERCASE
|
|
307
|
+
* types near-useless (every one below half acceptable). Every candidate now takes its
|
|
280
308
|
* pre-computed `heuristicType` (only `extends` or `relates_to` — see
|
|
281
309
|
* classifyRelationship). No LLM call is made. #405: the ignored `llm`/`budget`
|
|
282
310
|
* params are deleted — the signature now tells the truth.
|
|
@@ -295,10 +323,10 @@ export declare function classifyLinkCandidates(candidates: LinkCandidate[]): Pro
|
|
|
295
323
|
/**
|
|
296
324
|
* Classify the relationship between two memories.
|
|
297
325
|
*
|
|
298
|
-
* TWO-LABEL heuristic
|
|
299
|
-
* showed only `extends`
|
|
326
|
+
* TWO-LABEL heuristic. The link audit (see the Stage 3 header)
|
|
327
|
+
* showed only `extends` and `relates_to` held up; the
|
|
300
328
|
* emitted vocabulary is collapsed to exactly those two. The retired labels
|
|
301
|
-
* `updates` and `derives` (
|
|
329
|
+
* `updates` and `derives` (weak in the audit) and all UPPERCASE LLM types are no
|
|
302
330
|
* longer produced. They remain in VALID_RELATIONSHIP_TYPES so pre-existing rows
|
|
303
331
|
* still validate.
|
|
304
332
|
*
|
|
@@ -328,8 +356,8 @@ export declare function stageDecayPrune(db: Database.Database, dryRun: boolean):
|
|
|
328
356
|
* iterated once per new use — iteration is what makes the ceiling asymptotic
|
|
329
357
|
* (a count-sized single shot would overshoot it).
|
|
330
358
|
*
|
|
331
|
-
* The formula's S input is floored at PROMOTION_STRENGTH_FLOOR (#453 review
|
|
332
|
-
*
|
|
359
|
+
* The formula's S input is floored at PROMOTION_STRENGTH_FLOOR (#453 review):
|
|
360
|
+
* S^(−0.3) has a zero-singularity, and a writable
|
|
333
361
|
* base_strength of 0.0 would otherwise leap to the ceiling via Infinity→clamp
|
|
334
362
|
* on a single access. The floor bounds the first boost at ≈+0.13; it clamps
|
|
335
363
|
* the INPUT only — the stored 0.0 row is not rewritten, and the promoted
|
|
@@ -428,6 +456,28 @@ deadline?: RunDeadline,
|
|
|
428
456
|
* reconsolidation verdicts/rewrites) selects per-pool — confidential work
|
|
429
457
|
* goes here; when null, that work HOLDS/skips, never falls back to `llm`.
|
|
430
458
|
* Optional so every pre-#332 caller (and corpora with no confidential
|
|
431
|
-
* rows) is byte-identical.
|
|
459
|
+
* rows) is byte-identical. #642: the confidential SPACE keeps this exact
|
|
460
|
+
* role — it is never routed through spaceClients.
|
|
461
|
+
*/
|
|
462
|
+
confidentialLlm?: LlmClient | null,
|
|
463
|
+
/**
|
|
464
|
+
* #642 AC-9: per-space clients — every configured space except
|
|
465
|
+
* 'confidential' (resolveLlmPair/buildSpaceLlms). Every pool-aware stage
|
|
466
|
+
* above selects per space; a space with a null entry HOLDS its work
|
|
467
|
+
* (skipped_spaces / held_spaces report fields), never falls back to `llm`.
|
|
468
|
+
* Default empty = the pre-#642 two-pool run.
|
|
469
|
+
*/
|
|
470
|
+
spaceClients?: Map<string, LlmClient | null>,
|
|
471
|
+
/**
|
|
472
|
+
* #642: their per-space endpoint configs. No consolidation stage reads a
|
|
473
|
+
* config today (the drain's per-endpoint chunk-size cache is the consumer);
|
|
474
|
+
* the field rides here so the nightly threads ONE resolved bundle through
|
|
475
|
+
* both calls.
|
|
476
|
+
*/
|
|
477
|
+
spaceConfigs?: Map<string, LlmConfig | null>,
|
|
478
|
+
/**
|
|
479
|
+
* #642: the resolved SpaceDef list (config order) — reflection cohort
|
|
480
|
+
* order, each space's privacyLine, and the importance batch order. Default
|
|
481
|
+
* [] = the pre-#642 two-pool shape.
|
|
432
482
|
*/
|
|
433
|
-
|
|
483
|
+
spaces?: SpaceDef[]): Promise<ConsolidationReport>;
|