@gamaze/hicortex 0.27.1 → 0.27.3
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 +2 -2
- package/assets/dashboard.html +19 -19
- package/dist/calibration.d.ts +2 -2
- package/dist/calibration.js +2 -2
- package/dist/capture.d.ts +19 -1
- package/dist/capture.js +57 -16
- package/dist/classification.d.ts +9 -9
- package/dist/classification.js +11 -11
- package/dist/cluster.d.ts +1 -1
- package/dist/confidential-marker.d.ts +1 -1
- package/dist/consolidate.d.ts +6 -5
- package/dist/consolidate.js +6 -5
- package/dist/dashboard.d.ts +5 -5
- package/dist/dashboard.js +2 -2
- package/dist/db.js +1 -1
- package/dist/graph.d.ts +1 -2
- package/dist/graph.js +4 -6
- package/dist/learnings-identity.d.ts +26 -3
- package/dist/learnings-identity.js +54 -17
- package/dist/marker-key-api.d.ts +7 -7
- package/dist/marker-key-api.js +7 -7
- package/dist/mcp-server.js +16 -16
- package/dist/prompts.d.ts +10 -12
- package/dist/prompts.js +10 -12
- package/dist/quality-scoreboard.js +15 -3
- package/dist/recall-hook-cli.d.ts +3 -0
- package/dist/recall-hook-cli.js +14 -1
- package/dist/recall-precision.d.ts +2 -2
- package/dist/recall-precision.js +2 -2
- package/dist/redact.js +1 -1
- package/dist/transcript-reader.d.ts +10 -0
- package/dist/transcript-reader.js +8 -0
- package/dist/types.d.ts +4 -4
- package/opencode-plugin/hicortex/index.ts +146 -11
- package/package.json +1 -1
- package/pi-extension/hicortex/index.ts +114 -11
- package/server.json +2 -2
package/dist/graph.js
CHANGED
|
@@ -159,8 +159,7 @@ function confidentialNodeIds(db) {
|
|
|
159
159
|
* #332: `includeConfidential` defaults to FALSE — the agent-facing surfaces
|
|
160
160
|
* (REST /graph?op=hubs without a member agent, the MCP graph tool) hard-omit
|
|
161
161
|
* confidential hubs (their content snippets ARE content-bearing). The /viz
|
|
162
|
-
* export (
|
|
163
|
-
* passes true.
|
|
162
|
+
* export (deliberately ungated, #332) passes true.
|
|
164
163
|
*/
|
|
165
164
|
function detectHubs(db, thresholdMultiplier = 2, minLinks = 3, opts) {
|
|
166
165
|
const hidden = opts?.includeConfidential === true ? null : confidentialNodeIds(db);
|
|
@@ -205,7 +204,7 @@ function getNeighbors(db, memoryId, limit = 10, relationship, opts) {
|
|
|
205
204
|
// row). The CENTER memory's own class is the CALLER's gate — an
|
|
206
205
|
// agent-facing adapter must refuse a confidential center id before calling
|
|
207
206
|
// (REST /graph and the MCP tool 404 it for non-members, same contract as
|
|
208
|
-
// GET /memory). Default false = omit;
|
|
207
|
+
// GET /memory). Default false = omit; member-gated callers pass true.
|
|
209
208
|
const hidden = opts?.includeConfidential === true ? null : confidentialNodeIds(db);
|
|
210
209
|
let sql = `SELECT source_id, target_id, relationship, strength
|
|
211
210
|
FROM memory_links
|
|
@@ -300,9 +299,8 @@ function exportGraph(db, options = {}) {
|
|
|
300
299
|
if (where.length > 0)
|
|
301
300
|
sql += ` WHERE ${where.join(" AND ")}`;
|
|
302
301
|
const rows = db.prepare(sql).all(...params);
|
|
303
|
-
// #332: the /viz export is
|
|
304
|
-
//
|
|
305
|
-
// show-confidential graph toggle is a separate later item). Explicit true.
|
|
302
|
+
// #332: the /viz export is deliberately ungated (a show-confidential
|
|
303
|
+
// graph toggle is a separate later item). Explicit true.
|
|
306
304
|
const hubIds = new Set(detectHubs(db, 2, 3, { includeConfidential: true }).map((h) => h.id));
|
|
307
305
|
// Score, filter on effective strength, rank, cap
|
|
308
306
|
const scored = rows.map((row) => {
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
* GET /lessons → episodic memory lessons + memory index, rendered as the
|
|
18
18
|
* existing `## Hicortex Memory` block.
|
|
19
19
|
*
|
|
20
|
+
* #600: both fetches carry `?agent=<sanitized basename of the session cwd>` —
|
|
21
|
+
* the workspace folder name IS the agent name, so a rostered workspace reads
|
|
22
|
+
* as a confidential-circle member server-side (fail-closed otherwise).
|
|
23
|
+
*
|
|
20
24
|
* The two fetches run in Promise.all, each with its OWN 3 s timeout and
|
|
21
25
|
* INDEPENDENT fail-soft: an /identity failure must never cost the lessons
|
|
22
26
|
* block, and vice versa. Sequential fetches would double worst-case
|
|
@@ -43,7 +47,10 @@ export interface ResolvedConfig {
|
|
|
43
47
|
serverUrl: string;
|
|
44
48
|
authToken: string | undefined;
|
|
45
49
|
home: string;
|
|
46
|
-
/**
|
|
50
|
+
/** The resolved config `agentName` (0.13). #600: CONFIG/STATUS-REPORTED
|
|
51
|
+
* ONLY — the hooks no longer send it (the workspace basename is the agent
|
|
52
|
+
* identity on the wire now); `hicortex status` reports it via its own
|
|
53
|
+
* resolveAgentIdentity call. null → unset/invalid config value. */
|
|
47
54
|
agentName: string | null;
|
|
48
55
|
/** Max lessons to inject (config.lessonsLimit, default 10). */
|
|
49
56
|
lessonsLimit?: number;
|
|
@@ -71,6 +78,19 @@ export declare function resolveConfig(): ResolvedConfig | null;
|
|
|
71
78
|
* plus this function are the whole client-side seam).
|
|
72
79
|
*/
|
|
73
80
|
export declare function deriveHookProject(cwd: string, aliases?: Readonly<Record<string, string>> | null): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* #600: the workspace-scoped agent id a CC client sends on its read calls —
|
|
83
|
+
* the SANITIZED basename of the session's working directory (the workspace
|
|
84
|
+
* folder name IS the agent name, the same basename `project` is derived
|
|
85
|
+
* from; no precedence chain, no configured-name override). The server's
|
|
86
|
+
* confidential-circle gate matches rostered BARE ids
|
|
87
|
+
* here. null when the basename sanitizes to nothing (e.g. "!!!" or "/") → the
|
|
88
|
+
* caller omits the `agent` param entirely, never sending an id the server
|
|
89
|
+
* would 400 on (the fail-soft hook would silently swallow that and drop the
|
|
90
|
+
* whole block). Reuses the package's sanitizeAgentId so client and server
|
|
91
|
+
* agree on the id grammar by construction.
|
|
92
|
+
*/
|
|
93
|
+
export declare function workspaceAgentId(cwd: string): string | null;
|
|
74
94
|
/**
|
|
75
95
|
* Title-case a section name for its heading: split on `-`/`_`, capitalize each
|
|
76
96
|
* word ("user" → "User", "my_notes" → "My Notes").
|
|
@@ -163,9 +183,12 @@ export declare function gateAndRenderIdentity(data: IdentityResponse, harness: s
|
|
|
163
183
|
* Fetch identity + lessons concurrently and return the combined Markdown block,
|
|
164
184
|
* or null when neither yields anything (nothing to inject; caller prints
|
|
165
185
|
* nothing and exits 0). The `## Identity` block is prepended before the existing
|
|
166
|
-
* `## Hicortex Memory` block.
|
|
186
|
+
* `## Hicortex Memory` block. #600: `cwd` is the session's working directory
|
|
187
|
+
* (default process.cwd()) — its sanitized basename is the workspace-scoped
|
|
188
|
+
* agent id both fetches send; the optional parameter is the test seam,
|
|
189
|
+
* mirroring buildHookRequest.
|
|
167
190
|
*/
|
|
168
|
-
export declare function fetchLessonsIdentity(): Promise<string | null>;
|
|
191
|
+
export declare function fetchLessonsIdentity(cwd?: string): Promise<string | null>;
|
|
169
192
|
/** Backcompat alias (#264). */
|
|
170
193
|
export declare const fetchLessonsContext: typeof fetchLessonsIdentity;
|
|
171
194
|
/** Backcompat aliases (#264) for the renamed symbols. */
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
* GET /lessons → episodic memory lessons + memory index, rendered as the
|
|
19
19
|
* existing `## Hicortex Memory` block.
|
|
20
20
|
*
|
|
21
|
+
* #600: both fetches carry `?agent=<sanitized basename of the session cwd>` —
|
|
22
|
+
* the workspace folder name IS the agent name, so a rostered workspace reads
|
|
23
|
+
* as a confidential-circle member server-side (fail-closed otherwise).
|
|
24
|
+
*
|
|
21
25
|
* The two fetches run in Promise.all, each with its OWN 3 s timeout and
|
|
22
26
|
* INDEPENDENT fail-soft: an /identity failure must never cost the lessons
|
|
23
27
|
* block, and vice versa. Sequential fetches would double worst-case
|
|
@@ -31,6 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
31
35
|
exports.gateAndRenderContext = exports.renderContextBlock = exports.fetchLessonsContext = void 0;
|
|
32
36
|
exports.resolveConfig = resolveConfig;
|
|
33
37
|
exports.deriveHookProject = deriveHookProject;
|
|
38
|
+
exports.workspaceAgentId = workspaceAgentId;
|
|
34
39
|
exports.titleCaseSection = titleCaseSection;
|
|
35
40
|
exports.orderSectionNames = orderSectionNames;
|
|
36
41
|
exports.renderIdentityBlock = renderIdentityBlock;
|
|
@@ -67,11 +72,11 @@ function resolveConfig() {
|
|
|
67
72
|
const serverUrl = config.mode === "client" && typeof config.serverUrl === "string"
|
|
68
73
|
? config.serverUrl.replace(/\/+$/, "")
|
|
69
74
|
: `http://127.0.0.1:${config.port ?? DEFAULT_PORT}`;
|
|
70
|
-
// Per-agent identity id (0.13) via the shared resolver, so
|
|
71
|
-
// always matches what `hicortex status` reports.
|
|
72
|
-
//
|
|
73
|
-
// identity
|
|
74
|
-
//
|
|
75
|
+
// Per-agent identity id (0.13) via the shared resolver, so what an install
|
|
76
|
+
// has CONFIGURED always matches what `hicortex status` reports. #600: the
|
|
77
|
+
// hooks no longer send this id — the workspace basename is the agent
|
|
78
|
+
// identity on the wire (see workspaceAgentId); agentName stays
|
|
79
|
+
// config/status-reported only.
|
|
75
80
|
const agentName = (0, identity_store_js_1.resolveAgentIdentity)(config).agentId;
|
|
76
81
|
return {
|
|
77
82
|
serverUrl,
|
|
@@ -98,6 +103,21 @@ function authHeaders(authToken) {
|
|
|
98
103
|
function deriveHookProject(cwd, aliases) {
|
|
99
104
|
return (0, project_canonicalize_js_1.canonicalizeProject)((0, node_path_1.basename)(cwd), aliases);
|
|
100
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* #600: the workspace-scoped agent id a CC client sends on its read calls —
|
|
108
|
+
* the SANITIZED basename of the session's working directory (the workspace
|
|
109
|
+
* folder name IS the agent name, the same basename `project` is derived
|
|
110
|
+
* from; no precedence chain, no configured-name override). The server's
|
|
111
|
+
* confidential-circle gate matches rostered BARE ids
|
|
112
|
+
* here. null when the basename sanitizes to nothing (e.g. "!!!" or "/") → the
|
|
113
|
+
* caller omits the `agent` param entirely, never sending an id the server
|
|
114
|
+
* would 400 on (the fail-soft hook would silently swallow that and drop the
|
|
115
|
+
* whole block). Reuses the package's sanitizeAgentId so client and server
|
|
116
|
+
* agree on the id grammar by construction.
|
|
117
|
+
*/
|
|
118
|
+
function workspaceAgentId(cwd) {
|
|
119
|
+
return (0, identity_store_js_1.sanitizeAgentId)((0, node_path_1.basename)(cwd));
|
|
120
|
+
}
|
|
101
121
|
/**
|
|
102
122
|
* Trust framing + provenance for the injected lessons block (#516). The
|
|
103
123
|
* fence + two lines are byte-identical on every client surface (CC hook,
|
|
@@ -112,9 +132,17 @@ const MEMORY_PROVENANCE = "Provenance: auto-distilled by Hicortex from this memo
|
|
|
112
132
|
/**
|
|
113
133
|
* Fetch /lessons and build the `## Hicortex Memory` block, or null on any
|
|
114
134
|
* failure (missing/non-2xx/parse). Preserves the pre-0.12 behavior exactly.
|
|
135
|
+
* #600: `cwd` is the session's working directory (default process.cwd()) —
|
|
136
|
+
* the sanitized basename rides the request as `?agent=` (confidential lessons
|
|
137
|
+
* are member-gated server-side) and feeds the project fold. A null-sanitizing
|
|
138
|
+
* basename → bare /lessons (non-member, fail-closed).
|
|
115
139
|
*/
|
|
116
|
-
async function fetchLessonsBlock(cfg) {
|
|
117
|
-
const
|
|
140
|
+
async function fetchLessonsBlock(cfg, cwd = process.cwd()) {
|
|
141
|
+
const agent = workspaceAgentId(cwd);
|
|
142
|
+
const url = agent
|
|
143
|
+
? `${cfg.serverUrl}/lessons?agent=${encodeURIComponent(agent)}`
|
|
144
|
+
: `${cfg.serverUrl}/lessons`;
|
|
145
|
+
const resp = await fetch(url, {
|
|
118
146
|
headers: authHeaders(cfg.authToken),
|
|
119
147
|
signal: AbortSignal.timeout(3000),
|
|
120
148
|
});
|
|
@@ -129,7 +157,7 @@ async function fetchLessonsBlock(cfg) {
|
|
|
129
157
|
// This enables in-project + same-domain lesson boosting on the CC path.
|
|
130
158
|
// #567: folded through the shared canonicalizer so the local label
|
|
131
159
|
// compares equal to the canonical server corpus (see deriveHookProject).
|
|
132
|
-
const project = deriveHookProject(
|
|
160
|
+
const project = deriveHookProject(cwd, cfg.projectAliases);
|
|
133
161
|
const selected = await (0, extensions_js_1.getLessonSelector)().select(data.lessons, { maxLessons, moduleIndex, project });
|
|
134
162
|
const lessonLines = selected.map((l) => {
|
|
135
163
|
const typeMatch = l.content.match(/\*\*Type:\*\* (\w+)/);
|
|
@@ -296,14 +324,20 @@ function gateAndRenderIdentity(data, harness, opts) {
|
|
|
296
324
|
* Fetch /identity and build the `## Identity` block, or null when nothing should
|
|
297
325
|
* be injected: non-2xx, this harness not in `clients`, no sections, or all
|
|
298
326
|
* sections empty. Throws propagate to the caller's fail-soft catch.
|
|
327
|
+
* #600: `cwd` is the session's working directory (default process.cwd()) —
|
|
328
|
+
* its sanitized basename is the workspace-scoped identity sent as `?agent=`.
|
|
299
329
|
*/
|
|
300
|
-
async function fetchIdentityBlock(cfg) {
|
|
330
|
+
async function fetchIdentityBlock(cfg, cwd = process.cwd()) {
|
|
301
331
|
// Send ?agent= only when we have a valid id; the server does the merge and
|
|
302
332
|
// returns the resolved sections, so the hook stays dumb (no client-side mode
|
|
303
|
-
// logic).
|
|
304
|
-
//
|
|
305
|
-
|
|
306
|
-
|
|
333
|
+
// logic). #600: the id is the SANITIZED WORKSPACE BASENAME (the folder
|
|
334
|
+
// name IS the agent name — it replaces the configured
|
|
335
|
+
// agentName on the hook path, which stays config/status-reported only). A
|
|
336
|
+
// null id (a basename that sanitizes to nothing) → bare /identity → the
|
|
337
|
+
// shared global set.
|
|
338
|
+
const id = workspaceAgentId(cwd);
|
|
339
|
+
const url = id
|
|
340
|
+
? `${cfg.serverUrl}/identity?agent=${encodeURIComponent(id)}`
|
|
307
341
|
: `${cfg.serverUrl}/identity`;
|
|
308
342
|
const resp = await fetch(url, {
|
|
309
343
|
headers: authHeaders(cfg.authToken),
|
|
@@ -323,9 +357,12 @@ async function fetchIdentityBlock(cfg) {
|
|
|
323
357
|
* Fetch identity + lessons concurrently and return the combined Markdown block,
|
|
324
358
|
* or null when neither yields anything (nothing to inject; caller prints
|
|
325
359
|
* nothing and exits 0). The `## Identity` block is prepended before the existing
|
|
326
|
-
* `## Hicortex Memory` block.
|
|
360
|
+
* `## Hicortex Memory` block. #600: `cwd` is the session's working directory
|
|
361
|
+
* (default process.cwd()) — its sanitized basename is the workspace-scoped
|
|
362
|
+
* agent id both fetches send; the optional parameter is the test seam,
|
|
363
|
+
* mirroring buildHookRequest.
|
|
327
364
|
*/
|
|
328
|
-
async function fetchLessonsIdentity() {
|
|
365
|
+
async function fetchLessonsIdentity(cwd = process.cwd()) {
|
|
329
366
|
const cfg = resolveConfig();
|
|
330
367
|
if (!cfg)
|
|
331
368
|
return null;
|
|
@@ -333,8 +370,8 @@ async function fetchLessonsIdentity() {
|
|
|
333
370
|
// other. Promise.all runs them concurrently — each carries its own 3 s
|
|
334
371
|
// timeout, so worst-case latency stays ~3 s, not ~6 s (spec §7).
|
|
335
372
|
const [identityBlock, lessonsBlock] = await Promise.all([
|
|
336
|
-
fetchIdentityBlock(cfg).catch(() => null),
|
|
337
|
-
fetchLessonsBlock(cfg).catch(() => null),
|
|
373
|
+
fetchIdentityBlock(cfg, cwd).catch(() => null),
|
|
374
|
+
fetchLessonsBlock(cfg, cwd).catch(() => null),
|
|
338
375
|
]);
|
|
339
376
|
const blocks = [identityBlock, lessonsBlock].filter((b) => b !== null && b !== "");
|
|
340
377
|
if (blocks.length === 0)
|
package/dist/marker-key-api.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* The problem (#616): `hicortex confidential` (#614) requires the server's
|
|
6
6
|
* `confidentialMarkerKey` on the machine it runs on, and distributing it by
|
|
7
7
|
* hand (mirror into each client's config.json, or export its env mirror) is
|
|
8
|
-
* ceremony
|
|
8
|
+
* ceremony the operator repeats once per machine. The fix keeps the client's ONE
|
|
9
9
|
* existing credential: the machine already holds the server URL + authToken,
|
|
10
10
|
* so the command can FETCH the key (second machine: no new key generated) or
|
|
11
11
|
* GENERATE one and REGISTER it with the server (first machine ever) — one
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
* and NOTHING else. Anything richer would turn the bearer token into a
|
|
17
17
|
* config exfiltration/write surface it deliberately is not today.
|
|
18
18
|
*
|
|
19
|
-
* Accepted trade-off (
|
|
20
|
-
*
|
|
21
|
-
* token
|
|
22
|
-
* processes WITHOUT the token/config access (a shell
|
|
23
|
-
* the marker file cannot forge one); a token holder
|
|
24
|
-
*
|
|
19
|
+
* Accepted trade-off (settled design decision — do not re-litigate): the key
|
|
20
|
+
* is fetchable by token, which collapses the marker key's barrier to the
|
|
21
|
+
* token itself. That is acceptable: the marker key's real protection is
|
|
22
|
+
* against workspace processes WITHOUT the token/config access (a shell
|
|
23
|
+
* script or agent reading the marker file cannot forge one); a token holder
|
|
24
|
+
* can already POST arbitrary content.
|
|
25
25
|
*
|
|
26
26
|
* Layout follows the identity-store.ts precedent: pure, side-effect-free
|
|
27
27
|
* handlers HERE (validation + response shaping), thin adapters in
|
package/dist/marker-key-api.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* The problem (#616): `hicortex confidential` (#614) requires the server's
|
|
7
7
|
* `confidentialMarkerKey` on the machine it runs on, and distributing it by
|
|
8
8
|
* hand (mirror into each client's config.json, or export its env mirror) is
|
|
9
|
-
* ceremony
|
|
9
|
+
* ceremony the operator repeats once per machine. The fix keeps the client's ONE
|
|
10
10
|
* existing credential: the machine already holds the server URL + authToken,
|
|
11
11
|
* so the command can FETCH the key (second machine: no new key generated) or
|
|
12
12
|
* GENERATE one and REGISTER it with the server (first machine ever) — one
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
* and NOTHING else. Anything richer would turn the bearer token into a
|
|
18
18
|
* config exfiltration/write surface it deliberately is not today.
|
|
19
19
|
*
|
|
20
|
-
* Accepted trade-off (
|
|
21
|
-
*
|
|
22
|
-
* token
|
|
23
|
-
* processes WITHOUT the token/config access (a shell
|
|
24
|
-
* the marker file cannot forge one); a token holder
|
|
25
|
-
*
|
|
20
|
+
* Accepted trade-off (settled design decision — do not re-litigate): the key
|
|
21
|
+
* is fetchable by token, which collapses the marker key's barrier to the
|
|
22
|
+
* token itself. That is acceptable: the marker key's real protection is
|
|
23
|
+
* against workspace processes WITHOUT the token/config access (a shell
|
|
24
|
+
* script or agent reading the marker file cannot forge one); a token holder
|
|
25
|
+
* can already POST arbitrary content.
|
|
26
26
|
*
|
|
27
27
|
* Layout follows the identity-store.ts precedent: pure, side-effect-free
|
|
28
28
|
* handlers HERE (validation + response shaping), thin adapters in
|
package/dist/mcp-server.js
CHANGED
|
@@ -1528,8 +1528,8 @@ async function startServer(options = {}) {
|
|
|
1528
1528
|
// HICORTEX_CONFIDENTIAL_MARKER_KEY env override 409s (the env would shadow
|
|
1529
1529
|
// the write — no no-op success; the rule lives in the pure handler).
|
|
1530
1530
|
// Bearer-only: the standard auth middleware above, no exemption — the key
|
|
1531
|
-
// is the confidential circle's secret, fetchable by token
|
|
1532
|
-
//
|
|
1531
|
+
// is the confidential circle's secret, fetchable by token (the #616
|
|
1532
|
+
// accepted trade-off). Pure handlers in marker-key-api.ts.
|
|
1533
1533
|
app.get("/confidential/marker-key", (_req, res) => {
|
|
1534
1534
|
const r = (0, marker_key_api_js_1.handleMarkerKeyGet)(confidentialMarkerKey);
|
|
1535
1535
|
res.status(r.status).json(r.body);
|
|
@@ -1713,8 +1713,8 @@ async function startServer(options = {}) {
|
|
|
1713
1713
|
// messages branch is already covered above. Disable-resistance
|
|
1714
1714
|
// (hostedMode) is Phase 0b.
|
|
1715
1715
|
// #332 redaction pilot: CONFIDENTIAL deliveries use the extended preset
|
|
1716
|
-
// (DEFAULT_PATTERNS + emails + phone numbers) — the material
|
|
1717
|
-
//
|
|
1716
|
+
// (DEFAULT_PATTERNS + emails + phone numbers) — the material a
|
|
1717
|
+
// confidential-circle agent captures is exactly the contact-identifier-rich
|
|
1718
1718
|
// kind (#558). Standard deliveries keep today's set byte-identically.
|
|
1719
1719
|
if (fromTextBranch) {
|
|
1720
1720
|
const { text: redacted, count } = (0, redact_js_1.redact)(conversationText, {
|
|
@@ -1969,8 +1969,8 @@ async function startServer(options = {}) {
|
|
|
1969
1969
|
return;
|
|
1970
1970
|
}
|
|
1971
1971
|
// NOTE (#332): `privacy` is no longer a writable field — classification is
|
|
1972
|
-
// server-derived at intake and changed only by the
|
|
1973
|
-
//
|
|
1972
|
+
// server-derived at intake and changed only by the `hicortex
|
|
1973
|
+
// backfill-privacy` command. A body privacy field is ignored (kept out
|
|
1974
1974
|
// of the destructure so the intent is structural).
|
|
1975
1975
|
const { id, content, project, memory_type } = req.body ?? {};
|
|
1976
1976
|
if (!id || typeof id !== "string") {
|
|
@@ -2176,9 +2176,9 @@ async function startServer(options = {}) {
|
|
|
2176
2176
|
const filterDomain = typeof req.query.domain === "string" && req.query.domain ? req.query.domain : undefined;
|
|
2177
2177
|
const filterRelationship = typeof req.query.relationship === "string" && req.query.relationship ? req.query.relationship : undefined;
|
|
2178
2178
|
// #332: the optional `agent` param gates neighbors/hubs/path (the
|
|
2179
|
-
// content-bearing ops). op=export stays UNGATED — it
|
|
2180
|
-
//
|
|
2181
|
-
//
|
|
2179
|
+
// content-bearing ops). op=export stays UNGATED — it feeds /viz, which
|
|
2180
|
+
// is deliberately ungated (a show-confidential toggle is a separate
|
|
2181
|
+
// later item).
|
|
2182
2182
|
const member = requestSeesConfidential(req.query.agent);
|
|
2183
2183
|
// A confidential endpoint/center id is invisible to non-members — same
|
|
2184
2184
|
// 404 contract as GET /memory (existence is not revealed).
|
|
@@ -2359,13 +2359,13 @@ async function startServer(options = {}) {
|
|
|
2359
2359
|
// src/dashboard.ts.
|
|
2360
2360
|
app.get("/dashboard/quality/contested", (0, dashboard_js_1.dashboardQualityContestedHandler)(() => db));
|
|
2361
2361
|
// PUT /dashboard/quality/verdict — the dashboard's THIRD scoped writer
|
|
2362
|
-
// (after /dashboard/model and /dashboard/capture-pause):
|
|
2363
|
-
// on a contested line. Body {id, verdict: 1|-1} (numeric: 1
|
|
2364
|
-
// not) — persisted as grader='owner', a NEW verdict row against
|
|
2365
|
-
// (push, memory) so history is append-only; these rows are the
|
|
2366
|
-
//
|
|
2367
|
-
// retention. 404 on an unknown id, 400 on a malformed body.
|
|
2368
|
-
// like every dashboard writer; localhost bypass applies.
|
|
2362
|
+
// (after /dashboard/model and /dashboard/capture-pause): manual review
|
|
2363
|
+
// (thumbs) on a contested line. Body {id, verdict: 1|-1} (numeric: 1
|
|
2364
|
+
// useful, -1 not) — persisted as grader='owner', a NEW verdict row against
|
|
2365
|
+
// the same (push, memory) so history is append-only; these rows are the
|
|
2366
|
+
// manual-verdict calibration reference and are NEVER pruned by the nightly
|
|
2367
|
+
// verdict retention. 404 on an unknown id, 400 on a malformed body.
|
|
2368
|
+
// Bearer-only like every dashboard writer; localhost bypass applies.
|
|
2369
2369
|
app.put("/dashboard/quality/verdict", (0, dashboard_js_1.dashboardQualityVerdictPutHandler)(() => db));
|
|
2370
2370
|
// GET /account — account identity for the console nav (name/org/plan from
|
|
2371
2371
|
// config). The LIGHTWEIGHT twin of the account block inside /dashboard/data:
|
package/dist/prompts.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ import type { MemoryPrivacy } from "./types.js";
|
|
|
18
18
|
export declare const REFLECTION_PRIVACY_LINE_STANDARD = "Privacy: Never include personal data (names, health, finances, credentials) in lesson text. Abstract to the process level.";
|
|
19
19
|
/**
|
|
20
20
|
* The CONFIDENTIAL pool's reflection privacy line (#602). Three elements:
|
|
21
|
-
* (a) the pool
|
|
22
|
-
*
|
|
21
|
+
* (a) the pool is scoped to the confidential circle only (#598 — its
|
|
22
|
+
* lessons stay inside the pool via the inherited stamp);
|
|
23
23
|
* (b) lesson text MAY reference the user's personal domains at the process
|
|
24
24
|
* level where needed to make the lesson actionable — the standard line
|
|
25
25
|
* suppressed all confidential lessons by construction (#602 finding);
|
|
@@ -46,16 +46,14 @@ export declare function importanceScoring(memoriesBlock: string): string;
|
|
|
46
46
|
* POOL-AWARE (#602): the optional `pool` argument swaps ONLY the privacy line.
|
|
47
47
|
* Absent/undefined = "standard" = the pre-#602 prompt BYTE-IDENTICAL — the
|
|
48
48
|
* standard pool's prompt must never change. The confidential variant exists
|
|
49
|
-
* because the confidential pool is
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* Everything else in the prompt (generality bar, examples, output schema) is
|
|
58
|
-
* shared verbatim by both pools — pinned by tests/reflection-prompt.test.ts.
|
|
49
|
+
* because the confidential pool is personal-domain content by definition,
|
|
50
|
+
* so the standard line ("Never include personal data (names, health,
|
|
51
|
+
* finances, credentials)") suppressed confidential lessons by construction
|
|
52
|
+
* — only the PROMPT suppressed them; the confidential pool SHOULD generate
|
|
53
|
+
* lessons. The confidential line keeps one absolute: credentials/passwords/
|
|
54
|
+
* API keys/secrets are never included. Everything else in the prompt
|
|
55
|
+
* (generality bar, examples, output schema) is shared verbatim by both
|
|
56
|
+
* pools — pinned by tests/reflection-prompt.test.ts.
|
|
59
57
|
*/
|
|
60
58
|
export declare function reflection(memoriesBlock: string, recentLessons?: string, pool?: MemoryPrivacy): string;
|
|
61
59
|
/**
|
package/dist/prompts.js
CHANGED
|
@@ -24,8 +24,8 @@ exports.domainCuration = domainCuration;
|
|
|
24
24
|
exports.REFLECTION_PRIVACY_LINE_STANDARD = "Privacy: Never include personal data (names, health, finances, credentials) in lesson text. Abstract to the process level.";
|
|
25
25
|
/**
|
|
26
26
|
* The CONFIDENTIAL pool's reflection privacy line (#602). Three elements:
|
|
27
|
-
* (a) the pool
|
|
28
|
-
*
|
|
27
|
+
* (a) the pool is scoped to the confidential circle only (#598 — its
|
|
28
|
+
* lessons stay inside the pool via the inherited stamp);
|
|
29
29
|
* (b) lesson text MAY reference the user's personal domains at the process
|
|
30
30
|
* level where needed to make the lesson actionable — the standard line
|
|
31
31
|
* suppressed all confidential lessons by construction (#602 finding);
|
|
@@ -83,16 +83,14 @@ No explanations. Just the JSON array.`;
|
|
|
83
83
|
* POOL-AWARE (#602): the optional `pool` argument swaps ONLY the privacy line.
|
|
84
84
|
* Absent/undefined = "standard" = the pre-#602 prompt BYTE-IDENTICAL — the
|
|
85
85
|
* standard pool's prompt must never change. The confidential variant exists
|
|
86
|
-
* because the confidential pool is
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* Everything else in the prompt (generality bar, examples, output schema) is
|
|
95
|
-
* shared verbatim by both pools — pinned by tests/reflection-prompt.test.ts.
|
|
86
|
+
* because the confidential pool is personal-domain content by definition,
|
|
87
|
+
* so the standard line ("Never include personal data (names, health,
|
|
88
|
+
* finances, credentials)") suppressed confidential lessons by construction
|
|
89
|
+
* — only the PROMPT suppressed them; the confidential pool SHOULD generate
|
|
90
|
+
* lessons. The confidential line keeps one absolute: credentials/passwords/
|
|
91
|
+
* API keys/secrets are never included. Everything else in the prompt
|
|
92
|
+
* (generality bar, examples, output schema) is shared verbatim by both
|
|
93
|
+
* pools — pinned by tests/reflection-prompt.test.ts.
|
|
96
94
|
*/
|
|
97
95
|
function reflection(memoriesBlock, recentLessons, pool) {
|
|
98
96
|
const recentSection = recentLessons
|
|
@@ -562,11 +562,18 @@ async function runQualityGradeStageInner(db, gradedWeek, opts) {
|
|
|
562
562
|
const fromDay = windowStartDay(now, calibration_js_1.MEMORY_PRECISION_WINDOW_DAYS);
|
|
563
563
|
const nowIso = now.toISOString();
|
|
564
564
|
// --- Population: every shown (push, memory) pair in the retention window,
|
|
565
|
-
// with the push's prompt excerpt + the memory row for the line render.
|
|
565
|
+
// with the push's prompt excerpt + the memory row for the line render.
|
|
566
|
+
// STANDARD-ONLY by construction (#618): the LEFT JOIN + privacy filter keep
|
|
567
|
+
// confidential rows out of BOTH arms of the lane (revealed-useful marking
|
|
568
|
+
// AND auto-grading) — a confidential line or excerpt must never egress.
|
|
569
|
+
// LEFT JOIN so a standard-class row whose memory row is gone still flows
|
|
570
|
+
// (renderLine already returns null for deleted memories — unchanged). ---
|
|
566
571
|
const shownRows = db
|
|
567
572
|
.prepare(`SELECT e.push_id AS push_id, e.memory_id AS memory_id, p.prompt_excerpt AS prompt_excerpt
|
|
568
573
|
FROM recall_events e JOIN recall_pushes p ON p.id = e.push_id
|
|
569
|
-
|
|
574
|
+
LEFT JOIN memories m ON m.id = e.memory_id
|
|
575
|
+
WHERE e.day >= ? AND e.kind = 'shown'
|
|
576
|
+
AND (m.privacy IS NULL OR m.privacy != 'confidential')`)
|
|
570
577
|
.all(fromDay);
|
|
571
578
|
const fetchedInWindow = new Set(db
|
|
572
579
|
.prepare("SELECT DISTINCT memory_id FROM recall_events WHERE day >= ? AND kind = 'fetch'")
|
|
@@ -578,12 +585,17 @@ async function runQualityGradeStageInner(db, gradedWeek, opts) {
|
|
|
578
585
|
.prepare("SELECT push_id, memory_id FROM recall_verdicts WHERE grader = 'revealed'")
|
|
579
586
|
.all().map((r) => `${r.push_id ?? ""}|${r.memory_id}`));
|
|
580
587
|
const requestProject = resolveRequestProjects(db, fromDay, null);
|
|
581
|
-
const memStmt = db.prepare(`SELECT id, content, created_at, domain, project, source_agent, memory_type
|
|
588
|
+
const memStmt = db.prepare(`SELECT id, content, created_at, domain, project, source_agent, memory_type, privacy
|
|
582
589
|
FROM memories WHERE id = ?`);
|
|
583
590
|
const renderLine = (memoryId) => {
|
|
584
591
|
const row = memStmt.get(memoryId);
|
|
585
592
|
if (!row)
|
|
586
593
|
return null; // memory gone (deleted) — not gradable, skipped
|
|
594
|
+
// #618 belt: the population filter above is the gate; this render-path
|
|
595
|
+
// refusal means confidential content can NEVER reach the egress even if
|
|
596
|
+
// the population query changes shape later.
|
|
597
|
+
if (row.privacy === "confidential")
|
|
598
|
+
return null;
|
|
587
599
|
return (0, recall_index_js_1.formatIndexLine)({
|
|
588
600
|
id: row.id,
|
|
589
601
|
content: row.content,
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* dispatches on the payload):
|
|
6
6
|
* - UserPromptSubmit: POST the prompt to the server's /recall-index; print
|
|
7
7
|
* the returned index block to stdout (CC injects hook stdout as context).
|
|
8
|
+
* #600: the body carries `agent` = the sanitized basename of the session
|
|
9
|
+
* cwd (the workspace folder name IS the agent name) so the server's
|
|
10
|
+
* confidential-circle gate can recognize the session.
|
|
8
11
|
* - SessionStart (startup/resume/clear/compact): POST a reset so the
|
|
9
12
|
* server's per-session shown-set matches the fresh context window.
|
|
10
13
|
*
|
package/dist/recall-hook-cli.js
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* dispatches on the payload):
|
|
7
7
|
* - UserPromptSubmit: POST the prompt to the server's /recall-index; print
|
|
8
8
|
* the returned index block to stdout (CC injects hook stdout as context).
|
|
9
|
+
* #600: the body carries `agent` = the sanitized basename of the session
|
|
10
|
+
* cwd (the workspace folder name IS the agent name) so the server's
|
|
11
|
+
* confidential-circle gate can recognize the session.
|
|
9
12
|
* - SessionStart (startup/resume/clear/compact): POST a reset so the
|
|
10
13
|
* server's per-session shown-set matches the fresh context window.
|
|
11
14
|
*
|
|
@@ -58,7 +61,17 @@ function buildHookRequest(payload, cwd = process.cwd()) {
|
|
|
58
61
|
// soft project-affinity boost. basename(cwd) matches capture's
|
|
59
62
|
// decodeProjectDirName for non-hyphenated dirs (the common case); a hyphen
|
|
60
63
|
// edge case is a pre-existing capture bug, filed separately.
|
|
61
|
-
|
|
64
|
+
// #600: the same basename IS the agent id — sent SANITIZED so the server's
|
|
65
|
+
// confidential-circle gate can recognize the session (a rostered workspace
|
|
66
|
+
// reads as a member). A basename that sanitizes to null omits the field
|
|
67
|
+
// entirely (non-member, fail-closed — never an id the server would 400 on).
|
|
68
|
+
// The SessionStart reset above deliberately carries NO agent: a reset
|
|
69
|
+
// returns no rows, so there is nothing to gate.
|
|
70
|
+
const body = { session_id: sessionId, prompt, project: (0, node_path_1.basename)(cwd) };
|
|
71
|
+
const agent = (0, learnings_identity_js_1.workspaceAgentId)(cwd);
|
|
72
|
+
if (agent)
|
|
73
|
+
body.agent = agent;
|
|
74
|
+
return body;
|
|
62
75
|
}
|
|
63
76
|
async function runRecallHook() {
|
|
64
77
|
const cfg = (0, learnings_identity_js_1.resolveConfig)();
|
|
@@ -95,8 +95,8 @@ export declare function recordRecallFetch(db: Database.Database, memoryId: strin
|
|
|
95
95
|
* is deleted — retained rows == window rows.
|
|
96
96
|
*
|
|
97
97
|
* #578 retention split — recall_verdicts rides the SAME horizon with ONE
|
|
98
|
-
* carve-out: grader='owner' rows are NEVER dropped (they are the
|
|
99
|
-
* calibration reference, tiny volume by construction — about
|
|
98
|
+
* carve-out: grader='owner' rows are NEVER dropped (they are the
|
|
99
|
+
* manual-verdict calibration reference, tiny volume by construction — about
|
|
100
100
|
* five thumbs a week). Machine rows ('auto', 'revealed') prune with the events
|
|
101
101
|
* they were derived from — a revealed verdict outliving its own event rows
|
|
102
102
|
* would claim a window the store no longer holds.
|
package/dist/recall-precision.js
CHANGED
|
@@ -161,8 +161,8 @@ function recordRecallFetch(db, memoryId, ts) {
|
|
|
161
161
|
* is deleted — retained rows == window rows.
|
|
162
162
|
*
|
|
163
163
|
* #578 retention split — recall_verdicts rides the SAME horizon with ONE
|
|
164
|
-
* carve-out: grader='owner' rows are NEVER dropped (they are the
|
|
165
|
-
* calibration reference, tiny volume by construction — about
|
|
164
|
+
* carve-out: grader='owner' rows are NEVER dropped (they are the
|
|
165
|
+
* manual-verdict calibration reference, tiny volume by construction — about
|
|
166
166
|
* five thumbs a week). Machine rows ('auto', 'revealed') prune with the events
|
|
167
167
|
* they were derived from — a revealed verdict outliving its own event rows
|
|
168
168
|
* would claim a window the store no longer holds.
|
package/dist/redact.js
CHANGED
|
@@ -63,7 +63,7 @@ const DEFAULT_PATTERNS = [
|
|
|
63
63
|
/**
|
|
64
64
|
* The CONFIDENTIAL preset (#332 redaction pilot, the #558 gap): everything in
|
|
65
65
|
* DEFAULT_PATTERNS plus emails and phone numbers. Confidential-pool content
|
|
66
|
-
* is the material
|
|
66
|
+
* is the material a confidential-circle agent captures (finance, medical, personal
|
|
67
67
|
* correspondence), so its intake redacts contact identifiers BEFORE queueing
|
|
68
68
|
* — standard deliveries keep today's set unchanged (the general email/phone
|
|
69
69
|
* fix for standard rows is deliberately out of scope, #332 non-goals).
|
|
@@ -30,6 +30,16 @@ export interface TranscriptBatch {
|
|
|
30
30
|
* conversations, no cwd in its store; never invented).
|
|
31
31
|
*/
|
|
32
32
|
workspacePath?: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Per-DELTA-entry workspace (#619), aligned with `entries` (length ===
|
|
35
|
+
* entries.length) — entry i's OWN workspace, null when that entry carries
|
|
36
|
+
* none. CC fills it (CC writes `cwd` on every entry) so the packer can
|
|
37
|
+
* split the delta at every mid-session workspace change; readers with a
|
|
38
|
+
* session-level workspace (Pi/OC/opencode: the header `cwd` /
|
|
39
|
+
* `session.directory`) or none (Hermes) OMIT it and keep `workspacePath`
|
|
40
|
+
* as the whole batch's birthplace — the capture loop falls back to it.
|
|
41
|
+
*/
|
|
42
|
+
entryWorkspaces?: Array<string | null>;
|
|
33
43
|
/**
|
|
34
44
|
* Per-session cursor key (`<prefix>:<sessionId>`) — the capture-cursors.json
|
|
35
45
|
* key whose value gates and advances this session's incremental capture (#189).
|
|
@@ -148,6 +148,9 @@ function parseTranscriptFile(filePath, projectName, cursorKey, startCursor, gene
|
|
|
148
148
|
// entries (CC writes the session's cwd on every entry; the delta slice keeps
|
|
149
149
|
// the value authoritative for what THIS capture covers). projectName stays
|
|
150
150
|
// the lossy directory-name decode — it keeps serving only the label.
|
|
151
|
+
// #619: this stays the BATCH-LEVEL fallback; `entryWorkspaces` below carries
|
|
152
|
+
// each entry's own cwd so a mid-session cd re-birthplaces only the entries
|
|
153
|
+
// after it (the packer splits on changes, never rewrites this label).
|
|
151
154
|
let workspacePath = null;
|
|
152
155
|
for (const entry of delta) {
|
|
153
156
|
const cwd = entry?.cwd;
|
|
@@ -156,6 +159,10 @@ function parseTranscriptFile(filePath, projectName, cursorKey, startCursor, gene
|
|
|
156
159
|
break;
|
|
157
160
|
}
|
|
158
161
|
}
|
|
162
|
+
const entryWorkspaces = delta.map((entry) => {
|
|
163
|
+
const cwd = entry?.cwd;
|
|
164
|
+
return typeof cwd === "string" && cwd ? cwd : null;
|
|
165
|
+
});
|
|
159
166
|
return {
|
|
160
167
|
sessionId: (0, node_path_1.basename)(filePath, ".jsonl"),
|
|
161
168
|
projectName,
|
|
@@ -164,6 +171,7 @@ function parseTranscriptFile(filePath, projectName, cursorKey, startCursor, gene
|
|
|
164
171
|
: new Date().toISOString().slice(0, 10),
|
|
165
172
|
entries: delta,
|
|
166
173
|
workspacePath,
|
|
174
|
+
entryWorkspaces,
|
|
167
175
|
cursorKey,
|
|
168
176
|
startCursor: start,
|
|
169
177
|
generation: gen,
|
package/dist/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* server: derived at intake from `source_agent` × the `confidentialAgents`
|
|
11
11
|
* config roster, a `confidentialPaths` workspace match (#609), or marker
|
|
12
12
|
* content validated against the server's `confidentialMarkerKey` (#614) — or
|
|
13
|
-
* stamped by the `backfill-privacy`
|
|
13
|
+
* stamped by the `hicortex backfill-privacy` command; the client only RELAYS
|
|
14
14
|
* raw inputs, it never declares the class. The class is a hard gate on every
|
|
15
15
|
* agent-facing read path (absent/unknown requester = non-member =
|
|
16
16
|
* confidential rows omitted, single fetch 404) and routes every LLM touch of
|
|
@@ -852,8 +852,8 @@ export interface HicortexConfig {
|
|
|
852
852
|
* #332 — the confidential-circle roster: agent ids (the same sanitized id
|
|
853
853
|
* namespace as `identityAgents` / `?agent=`) whose captures are stamped
|
|
854
854
|
* `confidential` at intake (matched by `source_agent` with the first
|
|
855
|
-
* `<harness>/` segment stripped, so a Hermes profile `
|
|
856
|
-
* `hermes/
|
|
855
|
+
* `<harness>/` segment stripped, so a Hermes profile `atlas` capturing as
|
|
856
|
+
* `hermes/atlas` matches the roster entry `atlas`) and whose read requests
|
|
857
857
|
* (the optional `agent` param on every agent-facing read path) see both
|
|
858
858
|
* pools. Absent/empty (the default) = no circle: every capture is
|
|
859
859
|
* standard, nothing is ever omitted, zero behavior change. Deploy-time
|
|
@@ -862,7 +862,7 @@ export interface HicortexConfig {
|
|
|
862
862
|
*/
|
|
863
863
|
confidentialAgents?: string[];
|
|
864
864
|
/**
|
|
865
|
-
* #614 — the confidential marker key: the
|
|
865
|
+
* #614 — the confidential marker key: the operator-set secret the workspace
|
|
866
866
|
* marker `.hicortex-confidential` must carry (as its single-line content)
|
|
867
867
|
* for a client-marked folder to stamp `confidential` at intake. The client
|
|
868
868
|
* RELAYS the marker's content (`client_marker` on /distill); the server
|