@remnic/core 9.10.0 → 9.12.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/dist/access-cli.js +1 -1
- package/dist/{chunk-7PY55HMI.js → chunk-3VBXP5HS.js} +626 -38
- package/dist/chunk-3VBXP5HS.js.map +1 -0
- package/dist/index.d.ts +154 -2
- package/dist/index.js +31 -1
- package/dist/orchestrator.js +1 -1
- package/package.json +2 -2
- package/src/activity/digest.test.ts +180 -0
- package/src/activity/digest.ts +429 -0
- package/src/activity/index.ts +9 -0
- package/src/activity/store.test.ts +226 -0
- package/src/activity/store.ts +352 -0
- package/src/activity/types.ts +86 -0
- package/src/admin/admin-surfaces.test.ts +4 -5
- package/src/chat/chat-cli.test.ts +4 -7
- package/src/chat/chat-engine.test.ts +4 -8
- package/src/chat/chat-http.test.ts +4 -7
- package/src/chat/chat-security.test.ts +4 -6
- package/src/console/trace.test.ts +4 -9
- package/src/contradiction/contradiction.test.ts +4 -3
- package/src/correction/correction-executor.test.ts +4 -10
- package/src/correction/correction-planner.test.ts +5 -10
- package/src/extraction-redaction-rules.test.ts +5 -10
- package/src/index.ts +1 -1
- package/src/maintenance/graph-edge-decay.test.ts +5 -10
- package/src/peers/migrate-from-identity-anchor.test.ts +3 -4
- package/src/peers/peers.test.ts +3 -4
- package/src/session-summaries/session-summaries.test.ts +4 -8
- package/src/testing/tmp-dir.ts +68 -0
- package/src/transfer/capsule-encrypt.test.ts +4 -5
- package/src/write-quarantine.test.ts +4 -8
- package/dist/chunk-7PY55HMI.js.map +0 -1
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { strict as assert } from "node:assert";
|
|
15
|
-
import {
|
|
16
|
-
import { tmpdir } from "node:os";
|
|
15
|
+
import { readFile } from "node:fs/promises";
|
|
17
16
|
import path from "node:path";
|
|
18
17
|
import { test } from "node:test";
|
|
18
|
+
|
|
19
|
+
import { withTempDir as managedWithTempDir } from "../testing/tmp-dir.js";
|
|
19
20
|
import {
|
|
20
21
|
CorrectionContractError,
|
|
21
22
|
MEMORY_CATEGORIES,
|
|
@@ -88,14 +89,8 @@ function makeDeps(stateDir: string, state: StubState, opts: { maxAffected?: numb
|
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
return await fn(dir);
|
|
95
|
-
} finally {
|
|
96
|
-
await rm(dir, { recursive: true, force: true });
|
|
97
|
-
}
|
|
98
|
-
}
|
|
92
|
+
const withTempDir = <T>(fn: (dir: string) => Promise<T>): Promise<T> =>
|
|
93
|
+
managedWithTempDir(fn, "remnic-corr-plan-");
|
|
99
94
|
|
|
100
95
|
// ---------------------------------------------------------------------------
|
|
101
96
|
// Tests
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* correction actually blocks future extraction of matching content.
|
|
8
8
|
*/
|
|
9
9
|
import { strict as assert } from "node:assert";
|
|
10
|
-
import { mkdir,
|
|
10
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
11
11
|
import path from "node:path";
|
|
12
|
-
import { tmpdir } from "node:os";
|
|
13
12
|
import { test } from "node:test";
|
|
13
|
+
|
|
14
|
+
import { withTempDir as managedWithTempDir } from "./testing/tmp-dir.js";
|
|
14
15
|
import {
|
|
15
16
|
REDACTION_RULES_SUBDIR,
|
|
16
17
|
compileRedactionPattern,
|
|
@@ -20,14 +21,8 @@ import {
|
|
|
20
21
|
} from "./extraction-redaction-rules.js";
|
|
21
22
|
import { validateRedactionPattern } from "./correction/correction-contract.js";
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
return await fn(dir);
|
|
27
|
-
} finally {
|
|
28
|
-
await rm(dir, { recursive: true, force: true });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
24
|
+
const withTempDir = <T>(fn: (dir: string) => Promise<T>): Promise<T> =>
|
|
25
|
+
managedWithTempDir(fn, "remnic-redact-");
|
|
31
26
|
|
|
32
27
|
async function writeRule(stateDir: string, pattern: string): Promise<void> {
|
|
33
28
|
const dir = path.join(stateDir, REDACTION_RULES_SUBDIR);
|
package/src/index.ts
CHANGED
|
@@ -1205,8 +1205,8 @@ export {
|
|
|
1205
1205
|
// Wearable transcript subsystem (Limitless / Bee / Omi connectors).
|
|
1206
1206
|
// Connector packages import the registry + types from here.
|
|
1207
1207
|
// ---------------------------------------------------------------------------
|
|
1208
|
-
|
|
1209
1208
|
export * from "./wearables/index.js";
|
|
1209
|
+
export * from "./activity/index.js";
|
|
1210
1210
|
|
|
1211
1211
|
// ---------------------------------------------------------------------------
|
|
1212
1212
|
// Shared importer base (issue #568)
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import assert from "node:assert/strict";
|
|
6
|
-
import os from "node:os";
|
|
7
6
|
import path from "node:path";
|
|
8
7
|
import test from "node:test";
|
|
9
|
-
import { mkdir,
|
|
8
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
9
|
+
|
|
10
|
+
import { withTempDir as managedWithTempDir } from "../testing/tmp-dir.js";
|
|
10
11
|
|
|
11
12
|
import { appendEdge, graphFilePath, graphsDir, type GraphEdge } from "../graph.js";
|
|
12
13
|
import {
|
|
@@ -85,14 +86,8 @@ async function readEdgesFile(memoryDir: string): Promise<GraphEdge[]> {
|
|
|
85
86
|
.map((l) => JSON.parse(l) as GraphEdge);
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
await fn(dir);
|
|
92
|
-
} finally {
|
|
93
|
-
await rm(dir, { recursive: true, force: true });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
89
|
+
const withTempDir = (fn: (dir: string) => Promise<void>): Promise<void> =>
|
|
90
|
+
managedWithTempDir(fn, "remnic-graph-decay-test-");
|
|
96
91
|
|
|
97
92
|
test("runs end-to-end on a fixture graph with fresh, mid-decay, stale edges", async () => {
|
|
98
93
|
await withTempDir(async (memoryDir) => {
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
import assert from "node:assert/strict";
|
|
8
8
|
import { promises as fs } from "node:fs";
|
|
9
|
-
import os from "node:os";
|
|
10
9
|
import path from "node:path";
|
|
11
10
|
import test from "node:test";
|
|
12
11
|
|
|
12
|
+
import { makeTempDir as managedMakeTempDir } from "../testing/tmp-dir.js";
|
|
13
|
+
|
|
13
14
|
import { readPeer } from "./storage.js";
|
|
14
15
|
import { migrateFromIdentityAnchor } from "./migrate-from-identity-anchor.js";
|
|
15
16
|
|
|
@@ -17,9 +18,7 @@ import { migrateFromIdentityAnchor } from "./migrate-from-identity-anchor.js";
|
|
|
17
18
|
// Helpers
|
|
18
19
|
// ──────────────────────────────────────────────────────────────────────────────
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
return fs.mkdtemp(path.join(os.tmpdir(), "peer-migrate-test-"));
|
|
22
|
-
}
|
|
21
|
+
const makeTempDir = (): Promise<string> => managedMakeTempDir("peer-migrate-test-");
|
|
23
22
|
|
|
24
23
|
/** Write a file, creating intermediate directories as needed. */
|
|
25
24
|
async function writeFixture(filePath: string, content: string): Promise<void> {
|
package/src/peers/peers.test.ts
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import assert from "node:assert/strict";
|
|
9
9
|
import { promises as fs } from "node:fs";
|
|
10
|
-
import os from "node:os";
|
|
11
10
|
import path from "node:path";
|
|
12
11
|
import test from "node:test";
|
|
13
12
|
|
|
13
|
+
import { makeTempDir as managedMakeTempDir } from "../testing/tmp-dir.js";
|
|
14
|
+
|
|
14
15
|
import {
|
|
15
16
|
appendInteractionLog,
|
|
16
17
|
assertValidPeerId,
|
|
@@ -33,9 +34,7 @@ import {
|
|
|
33
34
|
// Fixtures
|
|
34
35
|
// ──────────────────────────────────────────────────────────────────────
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
return await fs.mkdtemp(path.join(os.tmpdir(), "peers-test-"));
|
|
38
|
-
}
|
|
37
|
+
const makeTempDir = (): Promise<string> => managedMakeTempDir("peers-test-");
|
|
39
38
|
|
|
40
39
|
function samplePeer(overrides: Partial<Peer> = {}): Peer {
|
|
41
40
|
return {
|
|
@@ -4,16 +4,12 @@ import os from "node:os";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import test from "node:test";
|
|
6
6
|
|
|
7
|
+
import { withTempDir as managedWithTempDir } from "../testing/tmp-dir.js";
|
|
8
|
+
|
|
7
9
|
import { collectLocalSessionSummaries, compileRedactionRules, runLocalSessionSummaryCliCommand } from "./index.js";
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
return await fn(dir);
|
|
13
|
-
} finally {
|
|
14
|
-
await rm(dir, { recursive: true, force: true });
|
|
15
|
-
}
|
|
16
|
-
}
|
|
11
|
+
const withTempDir = <T>(fn: (dir: string) => Promise<T>): Promise<T> =>
|
|
12
|
+
managedWithTempDir(fn, "remnic-session-summary-");
|
|
17
13
|
|
|
18
14
|
test("collectLocalSessionSummaries produces metadata-only drafts without local paths or raw session keys", async () => {
|
|
19
15
|
await withTempDir(async (dir) => {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { after } from "node:test";
|
|
2
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Shared temp-dir lifecycle for `@remnic/core` tests (#2083). The single source
|
|
9
|
+
* of truth within this package, so its tests are self-cleaning rather than
|
|
10
|
+
* relying solely on the run-level TMPDIR sandbox (Tier 1).
|
|
11
|
+
*
|
|
12
|
+
* `makeTempDir` / `makeTempDirSync` register the created directory for cleanup
|
|
13
|
+
* via a single file-scoped `after()` hook (registered at import time, before
|
|
14
|
+
* any test runs), so a bare `const dir = await makeTempDir()` call site needs
|
|
15
|
+
* no per-test teardown wiring. `withTempDir` scopes the directory to a callback
|
|
16
|
+
* and removes it in `finally`.
|
|
17
|
+
*/
|
|
18
|
+
const pendingCleanup = new Set<string>();
|
|
19
|
+
|
|
20
|
+
// Registered at module load — importing this module from a test file installs
|
|
21
|
+
// one file-scoped after-all hook that removes every managed temp dir. Doing it
|
|
22
|
+
// here (not lazily inside a test) guarantees the hook binds to the file root
|
|
23
|
+
// rather than whichever test happened to allocate the first dir.
|
|
24
|
+
after(async () => {
|
|
25
|
+
const dirs = [...pendingCleanup];
|
|
26
|
+
pendingCleanup.clear();
|
|
27
|
+
// Surface cleanup failures (do not swallow): a dir that cannot be removed is
|
|
28
|
+
// a real signal. `force: true` already ignores a missing dir, so a rejection
|
|
29
|
+
// here means an actual teardown problem and should fail the file loudly.
|
|
30
|
+
await Promise.all(dirs.map((dir) => rm(dir, { recursive: true, force: true })));
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** Create a temp dir that is removed automatically after the file's tests. */
|
|
34
|
+
export async function makeTempDir(prefix = "remnic-test-"): Promise<string> {
|
|
35
|
+
const dir = await mkdtemp(join(tmpdir(), prefix));
|
|
36
|
+
pendingCleanup.add(dir);
|
|
37
|
+
return dir;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Synchronous {@link makeTempDir}. */
|
|
41
|
+
export function makeTempDirSync(prefix = "remnic-test-"): string {
|
|
42
|
+
const dir = mkdtempSync(join(tmpdir(), prefix));
|
|
43
|
+
pendingCleanup.add(dir);
|
|
44
|
+
return dir;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Run `fn` with a fresh temp dir, removing it in `finally`. */
|
|
48
|
+
export async function withTempDir<T>(
|
|
49
|
+
fn: (dir: string) => T | Promise<T>,
|
|
50
|
+
prefix = "remnic-test-",
|
|
51
|
+
): Promise<T> {
|
|
52
|
+
const dir = await mkdtemp(join(tmpdir(), prefix));
|
|
53
|
+
try {
|
|
54
|
+
return await fn(dir);
|
|
55
|
+
} finally {
|
|
56
|
+
await rm(dir, { recursive: true, force: true });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Synchronous {@link withTempDir}. */
|
|
61
|
+
export function withTempDirSync<T>(fn: (dir: string) => T, prefix = "remnic-test-"): T {
|
|
62
|
+
const dir = mkdtempSync(join(tmpdir(), prefix));
|
|
63
|
+
try {
|
|
64
|
+
return fn(dir);
|
|
65
|
+
} finally {
|
|
66
|
+
rmSync(dir, { recursive: true, force: true });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
|
|
23
23
|
import assert from "node:assert/strict";
|
|
24
24
|
import test from "node:test";
|
|
25
|
-
import {
|
|
25
|
+
import { rm, writeFile, readFile, mkdir, stat, readdir } from "node:fs/promises";
|
|
26
26
|
import path from "node:path";
|
|
27
|
-
import { tmpdir } from "node:os";
|
|
28
27
|
import { gzipSync, gunzipSync } from "node:zlib";
|
|
29
28
|
|
|
29
|
+
import { makeTempDir as managedMakeTempDir } from "../testing/tmp-dir.js";
|
|
30
|
+
|
|
30
31
|
import { exportCapsule } from "./capsule-export.js";
|
|
31
32
|
import { importCapsule } from "./capsule-import.js";
|
|
32
33
|
import { backupMemoryDir } from "./backup.js";
|
|
@@ -53,9 +54,7 @@ const FAST_SCRYPT: ScryptParams = {
|
|
|
53
54
|
|
|
54
55
|
const TEST_PASSPHRASE = "hunter2-test-passphrase";
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
return mkdtemp(path.join(tmpdir(), "capsule-enc-test-"));
|
|
58
|
-
}
|
|
57
|
+
const makeTempDir = (): Promise<string> => managedMakeTempDir("capsule-enc-test-");
|
|
59
58
|
|
|
60
59
|
/**
|
|
61
60
|
* Initialize a secure-store header in `memoryDir` and unlock the keyring.
|
|
@@ -4,16 +4,12 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import test from "node:test";
|
|
6
6
|
|
|
7
|
+
import { withTempDir as managedWithTempDir } from "./testing/tmp-dir.js";
|
|
8
|
+
|
|
7
9
|
import { WriteQuarantineStore } from "./write-quarantine.js";
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
await fn(dir);
|
|
13
|
-
} finally {
|
|
14
|
-
await rm(dir, { recursive: true, force: true });
|
|
15
|
-
}
|
|
16
|
-
}
|
|
11
|
+
const withTempDir = (fn: (dir: string) => Promise<void>): Promise<void> =>
|
|
12
|
+
managedWithTempDir(fn, "remnic-quarantine-");
|
|
17
13
|
|
|
18
14
|
function isInside(root: string, child: string): boolean {
|
|
19
15
|
const rel = path.relative(path.resolve(root), path.resolve(child));
|