@gamaze/hicortex 0.27.3 → 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 +30 -9
- package/dist/prompts.js +40 -17
- 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 +3 -2
- package/server.json +2 -2
|
@@ -1,58 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `hicortex backfill-
|
|
3
|
-
*
|
|
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
|
|
7
|
-
*
|
|
8
|
-
* from a now-covered birthplace). The plan is a pure function of the
|
|
9
|
-
* the rows' stored values:
|
|
10
|
-
* - every memories/distill_queue row whose source_agent matches
|
|
11
|
-
* (isConfidentialSourceAgent — the same `<harness>/`-stripping
|
|
12
|
-
* intake uses) AND
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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
|
|
29
|
-
*
|
|
30
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
40
|
-
|
|
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
|
|
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
|
|
63
|
+
/** Rows in `memories` that would flip to the space. */
|
|
48
64
|
memoryRows: number;
|
|
49
|
-
/** Rows in `distill_queue` that would flip (distill
|
|
65
|
+
/** Rows in `distill_queue` that would flip (distill into the space). */
|
|
50
66
|
queuedRows: number;
|
|
51
67
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
95
|
-
*
|
|
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
|
|
98
|
-
* the
|
|
99
|
-
*
|
|
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,
|
|
120
|
+
export declare function planBackfill(db: Database.Database, rosterOrSpaces: string[] | SpaceDef[], patterns?: ConfidentialPathPattern[]): BackfillGroup[];
|
|
102
121
|
/**
|
|
103
|
-
* Run `hicortex backfill-privacy
|
|
104
|
-
* plan + report only, zero writes.
|
|
105
|
-
* lock, ONE transaction stamping
|
|
106
|
-
*
|
|
107
|
-
*
|
|
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;
|