recallnest 2.2.0 → 2.3.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/.env +4 -0
- package/CLAUDE.md +1 -1
- package/README.md +30 -5
- package/README_CN.md +30 -5
- package/config.json +55 -0
- package/connectors/examples/email-adapter.ts +73 -0
- package/connectors/examples/logs-adapter.ts +103 -0
- package/connectors/examples/rss-adapter.ts +95 -0
- package/logs/daily-recall.error.log +0 -0
- package/logs/daily-recall.log +60 -0
- package/logs/ingest-2026-04-11.log +110 -0
- package/logs/ingest-2026-04-12.log +90 -0
- package/logs/ingest-2026-04-13.log +87 -0
- package/logs/launchagent-stderr.log +0 -0
- package/logs/launchagent-stdout.log +0 -0
- package/package.json +1 -1
- package/src/cli.ts +30 -0
- package/src/connector-types.ts +57 -0
- package/src/conversation-importer.ts +25 -1
- package/src/data-checkup.ts +31 -1
- package/src/doctor.ts +29 -0
- package/src/ingest.ts +203 -0
- package/src/mcp-server.ts +2 -2
- package/src/obsidian-connector.ts +282 -0
- package/src/session-schema.ts +2 -2
- package/src/source-heartbeat.ts +108 -0
- package/.claude-plugin/CLAUDE.md +0 -29
- package/.claude-plugin/marketplace.json +0 -18
- package/.dockerignore +0 -11
- package/.github/workflows/ci.yml +0 -28
- package/.mcp.json +0 -9
- package/CHANGELOG.md +0 -51
- package/DEMO.md +0 -94
- package/Dockerfile +0 -20
- package/EVAL.md +0 -89
- package/FAILURES.md +0 -75
- package/OPERATIONS.md +0 -59
- package/ROADMAP.md +0 -245
- package/SKILL.md +0 -250
- package/assets/dashboard.png +0 -0
- package/assets/knowledge-graph.png +0 -0
- package/assets/recallnest-workbench.png +0 -0
- package/assets/screenshots/ui-full.png +0 -0
- package/assets/screenshots/ui-overview.png +0 -0
- package/assets/screenshots/ui-search.png +0 -0
- package/assets/ui/app.js +0 -1031
- package/assets/ui/index.html +0 -224
- package/assets/ui/styles.css +0 -781
- package/assets/wechat-qr.jpg +0 -0
- package/bun.lock +0 -337
- package/daily-reflections/2026-03-05.md +0 -15
- package/daily-reflections/2026-03-06.md +0 -15
- package/daily-reflections/2026-03-07.md +0 -7
- package/daily-reflections/2026-03-08.md +0 -34
- package/daily-reflections/2026-03-09.md +0 -35
- package/daily-reflections/2026-03-10.md +0 -36
- package/daily-reflections/2026-03-11.md +0 -35
- package/daily-reflections/2026-03-12.md +0 -36
- package/daily-reflections/2026-03-13.md +0 -35
- package/daily-reflections/2026-03-14.md +0 -35
- package/daily-reflections/2026-03-15.md +0 -35
- package/daily-reflections/2026-03-16.md +0 -41
- package/daily-reflections/2026-03-17.md +0 -10
- package/daily-reflections/2026-03-18.md +0 -10
- package/daily-reflections/2026-03-19.md +0 -10
- package/daily-reflections/2026-03-20.md +0 -10
- package/daily-reflections/2026-03-21.md +0 -10
- package/daily-reflections/2026-03-22.md +0 -10
- package/daily-reflections/2026-03-23.md +0 -10
- package/daily-reflections/2026-03-24.md +0 -10
- package/daily-reflections/2026-03-25.md +0 -32
- package/daily-reflections/2026-03-26.md +0 -37
- package/daily-reflections/2026-03-27.md +0 -35
- package/daily-reflections/2026-03-28.md +0 -35
- package/daily-reflections/2026-03-29.md +0 -35
- package/daily-reflections/2026-03-30.md +0 -36
- package/daily-reflections/2026-03-31.md +0 -35
- package/daily-reflections/2026-04-01.md +0 -35
- package/daily-reflections/2026-04-02.md +0 -35
- package/daily-reflections/2026-04-03.md +0 -37
- package/daily-reflections/2026-04-04.md +0 -37
- package/daily-reflections/2026-04-05.md +0 -35
- package/daily-reflections/2026-04-06.md +0 -36
- package/daily-reflections/2026-04-07.md +0 -35
- package/daily-reflections/2026-04-08.md +0 -35
- package/daily-reflections/2026-04-12.md +0 -35
- package/data/alias-map.example.json +0 -22
- package/docs/api-reference.md +0 -1291
- package/docs/architecture.md +0 -168
- package/docs/memory-boundary-contract.md +0 -226
- package/docs/memory-categories.md +0 -119
- package/docs/pipeline-audit-ultramemory.md +0 -177
- package/docs/plans/2026-03-08-query-expansion.md +0 -270
- package/docs/plans/2026-03-16-continuity-layer.md +0 -196
- package/docs/plans/2026-04-01-recall-boost.md +0 -100
- package/docs/plans/mcp-tiering-plan.md +0 -126
- package/docs/research/recall-quality-audit-2026-03-22.md +0 -153
- package/docs/self-evolution.md +0 -198
- package/docs/superpowers/plans/2026-03-19-ingest-pipeline-upgrade.md +0 -782
- package/docs/superpowers/plans/2026-04-11-constructive-retrieval-emotion.md +0 -1195
- package/docs/superpowers/specs/2026-03-19-ingest-pipeline-upgrade-design.md +0 -77
- package/docs/superpowers/specs/2026-03-23-pull-claude-desktop-design.md +0 -95
- package/docs/superpowers/specs/2026-04-11-constructive-retrieval-emotion-design.md +0 -398
- package/eval/continuity/results-2026-03-16.md +0 -117
- package/eval/continuity/results-2026-03-19.md +0 -453
- package/eval/continuity/runbook.md +0 -110
- package/eval/continuity/seed-cases.md +0 -54
- package/eval/reports/2026-03-06-abstract-query-baseline.md +0 -96
- package/eval/reports/2026-03-06-aws-ssh-baseline.md +0 -82
- package/eval/reports/2026-03-06-baseline.md +0 -82
- package/eval/reports/query-expansion.md +0 -138
- package/glama.json +0 -6
- package/lm +0 -19
- package/plan-philosophy-upgrades.md +0 -363
- package/plan-product-upgrades.md +0 -155
- package/plan-v1.2-distributable.md +0 -105
- package/plan.md +0 -140
- package/research-memory-evolution.md +0 -440
- package/research-rl-agent-memory.md +0 -330
- package/scripts/archive-distilled-junk.ts +0 -116
- package/scripts/backfill-anchors.ts +0 -130
- package/scripts/backfill-l0l1l2.ts +0 -98
- package/scripts/blind-scan.ts +0 -588
- package/scripts/cleanup-step1-exact-dups.ts +0 -117
- package/scripts/cleanup-step2-template-dups.ts +0 -113
- package/scripts/cleanup-step3-stale-content.ts +0 -149
- package/scripts/cleanup-step4-orphan-scopes.ts +0 -131
- package/scripts/delete-distilled-junk.ts +0 -88
- package/scripts/diagnose-vector-search.ts +0 -132
- package/scripts/distill-facts.ts +0 -305
- package/scripts/health-check.ts +0 -343
- package/scripts/incremental-ingest.sh +0 -71
- package/scripts/migrate-language.ts +0 -75
- package/scripts/mlp-health-check.ts +0 -382
- package/scripts/pull-claude-desktop.ts +0 -515
- package/scripts/re-ingest-cc.sh +0 -66
- package/scripts/rebalance-memory-health.ts +0 -181
- package/scripts/run-desktop-ingest.sh +0 -11
- package/scripts/start-server.sh +0 -12
- package/scripts/verify-emotion-decay.ts +0 -148
- package/scripts/viz-dashboard.html +0 -423
- package/scripts/viz-export.ts +0 -703
- package/src/__tests__/access-tracker-novelty.test.ts +0 -228
- package/src/__tests__/activity-counter.test.ts +0 -96
- package/src/__tests__/admission-control.test.ts +0 -206
- package/src/__tests__/anchor-generator.test.ts +0 -67
- package/src/__tests__/auto-consolidation.test.ts +0 -168
- package/src/__tests__/auto-recall.test.ts +0 -131
- package/src/__tests__/babel-integration.test.ts +0 -139
- package/src/__tests__/batch-dedup.test.ts +0 -65
- package/src/__tests__/capture-engine.test.ts +0 -1144
- package/src/__tests__/capture-heuristic.test.ts +0 -171
- package/src/__tests__/cascade-forget.test.ts +0 -210
- package/src/__tests__/category-min-scores.test.ts +0 -33
- package/src/__tests__/cc8-cc1-essential-context.test.ts +0 -298
- package/src/__tests__/circuit-breaker.test.ts +0 -99
- package/src/__tests__/cluster-consolidation.test.ts +0 -712
- package/src/__tests__/confidence-metadata.test.ts +0 -125
- package/src/__tests__/confidence-tracker.test.ts +0 -249
- package/src/__tests__/conflict-advisor.test.ts +0 -206
- package/src/__tests__/conflict-escalation.test.ts +0 -149
- package/src/__tests__/conflict-lifecycle.test.ts +0 -83
- package/src/__tests__/conflict-output.test.ts +0 -85
- package/src/__tests__/conflict-store.test.ts +0 -374
- package/src/__tests__/consolidation-engine.test.ts +0 -181
- package/src/__tests__/constructive-retrieval.test.ts +0 -509
- package/src/__tests__/context-collapse-renderer.test.ts +0 -214
- package/src/__tests__/context-composer-pins.test.ts +0 -64
- package/src/__tests__/context-composer-task-selection.test.ts +0 -24
- package/src/__tests__/context-reconstructor.test.ts +0 -65
- package/src/__tests__/context-renderer.test.ts +0 -91
- package/src/__tests__/continuity-eval.test.ts +0 -275
- package/src/__tests__/continuity-schema.test.ts +0 -97
- package/src/__tests__/conversation-importer.test.ts +0 -692
- package/src/__tests__/core-recall-eval.test.ts +0 -235
- package/src/__tests__/core-summary.test.ts +0 -109
- package/src/__tests__/data-checkup.test.ts +0 -225
- package/src/__tests__/decay-exemption.test.ts +0 -84
- package/src/__tests__/dedup-actions.test.ts +0 -58
- package/src/__tests__/dedup-guard.test.ts +0 -39
- package/src/__tests__/deterministic-id.test.ts +0 -39
- package/src/__tests__/distill-lock.test.ts +0 -176
- package/src/__tests__/doctor.test.ts +0 -303
- package/src/__tests__/dream-pipeline.test.ts +0 -232
- package/src/__tests__/drill-down.test.ts +0 -108
- package/src/__tests__/embedder.test.ts +0 -122
- package/src/__tests__/emotion-decay.test.ts +0 -46
- package/src/__tests__/emotion-detector.test.ts +0 -56
- package/src/__tests__/emotion-phase1-integration.test.ts +0 -153
- package/src/__tests__/emotion-retrieval.test.ts +0 -56
- package/src/__tests__/entity-resolver.test.ts +0 -58
- package/src/__tests__/ethics-layer.test.ts +0 -476
- package/src/__tests__/event-segmenter.test.ts +0 -153
- package/src/__tests__/feature-flags-integration.test.ts +0 -54
- package/src/__tests__/frequency-tracker.test.ts +0 -113
- package/src/__tests__/graph-export.test.ts +0 -489
- package/src/__tests__/hotness-blend.test.ts +0 -76
- package/src/__tests__/ingest.test.ts +0 -360
- package/src/__tests__/interference-detector.test.ts +0 -203
- package/src/__tests__/kg-extractor.test.ts +0 -184
- package/src/__tests__/kg-store.test.ts +0 -198
- package/src/__tests__/llm-consolidation.test.ts +0 -226
- package/src/__tests__/mcp-efficiency.test.ts +0 -288
- package/src/__tests__/memory-boundaries.test.ts +0 -237
- package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +0 -243
- package/src/__tests__/memory-evolution.test.ts +0 -271
- package/src/__tests__/memory-health-rebalance.test.ts +0 -144
- package/src/__tests__/memory-lint.test.ts +0 -271
- package/src/__tests__/memory-output.test.ts +0 -215
- package/src/__tests__/multi-vector.test.ts +0 -242
- package/src/__tests__/narrative-architecture.test.ts +0 -456
- package/src/__tests__/pending-review.test.ts +0 -77
- package/src/__tests__/post-retrieval-filter.test.ts +0 -178
- package/src/__tests__/ppr-traversal.test.ts +0 -256
- package/src/__tests__/prediction-engine.test.ts +0 -349
- package/src/__tests__/predictive-prospective-memory.test.ts +0 -416
- package/src/__tests__/preference-guard-smoke.test.ts +0 -211
- package/src/__tests__/preference-matcher.test.ts +0 -230
- package/src/__tests__/preference-slots.test.ts +0 -205
- package/src/__tests__/prospective-memory.test.ts +0 -283
- package/src/__tests__/query-entity-detector.test.ts +0 -171
- package/src/__tests__/query-expander-alias.test.ts +0 -89
- package/src/__tests__/query-expander.test.ts +0 -34
- package/src/__tests__/recall-governor.test.ts +0 -227
- package/src/__tests__/recall-mode.test.ts +0 -64
- package/src/__tests__/result-synthesizer.test.ts +0 -198
- package/src/__tests__/resume-context.test.ts +0 -4898
- package/src/__tests__/retrieval-trace.test.ts +0 -213
- package/src/__tests__/retriever-boundary-weight.test.ts +0 -136
- package/src/__tests__/retroactive-boost.test.ts +0 -223
- package/src/__tests__/salience-scoring.test.ts +0 -106
- package/src/__tests__/scope-inventory.test.ts +0 -200
- package/src/__tests__/scope-policy.test.ts +0 -69
- package/src/__tests__/session-checkpoint.test.ts +0 -259
- package/src/__tests__/session-distiller.test.ts +0 -611
- package/src/__tests__/session-gc.test.ts +0 -215
- package/src/__tests__/skill-engine.test.ts +0 -546
- package/src/__tests__/skill-promotion.test.ts +0 -349
- package/src/__tests__/store-scope-audit.test.ts +0 -81
- package/src/__tests__/supersede-chain.test.ts +0 -154
- package/src/__tests__/temporal-parser.test.ts +0 -241
- package/src/__tests__/temporal-validity.test.ts +0 -160
- package/src/__tests__/term-registry.test.ts +0 -121
- package/src/__tests__/tool-output-compressor.test.ts +0 -133
- package/src/__tests__/topic-tag.test.ts +0 -113
- package/src/__tests__/trusted-memory.test.ts +0 -828
- package/src/__tests__/version-manager.test.ts +0 -213
- package/src/__tests__/workflow-observation.test.ts +0 -400
- package/src/__tests__/write-verifier.test.ts +0 -122
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from "bun:test";
|
|
2
|
-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
|
|
6
|
-
import { collectScopeInventory, formatScopeInventoryReport } from "../scope-inventory.js";
|
|
7
|
-
import { MemoryStore } from "../store.js";
|
|
8
|
-
|
|
9
|
-
const cleanupPaths: string[] = [];
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
while (cleanupPaths.length > 0) {
|
|
13
|
-
const target = cleanupPaths.pop();
|
|
14
|
-
if (target) {
|
|
15
|
-
rmSync(target, { recursive: true, force: true });
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
function createTempRoot(): string {
|
|
21
|
-
const root = mkdtempSync(join(tmpdir(), "recallnest-scope-inventory-"));
|
|
22
|
-
cleanupPaths.push(root);
|
|
23
|
-
return root;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function writeJson(dir: string, name: string, payload: unknown): void {
|
|
27
|
-
mkdirSync(dir, { recursive: true });
|
|
28
|
-
writeFileSync(join(dir, name), JSON.stringify(payload, null, 2) + "\n");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe("collectScopeInventory", () => {
|
|
32
|
-
it("audits memories, pins, checkpoints, and workflow observations separately", async () => {
|
|
33
|
-
const root = createTempRoot();
|
|
34
|
-
const store = new MemoryStore({
|
|
35
|
-
dbPath: join(root, "db"),
|
|
36
|
-
vectorDim: 3,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
await store.store({
|
|
40
|
-
text: "Scoped durable memory.",
|
|
41
|
-
vector: [1, 0, 0],
|
|
42
|
-
category: "entities",
|
|
43
|
-
scope: "project:recallnest",
|
|
44
|
-
importance: 0.8,
|
|
45
|
-
metadata: "{}",
|
|
46
|
-
});
|
|
47
|
-
await store.store({
|
|
48
|
-
text: "Historical global memory row.",
|
|
49
|
-
vector: [0, 1, 0],
|
|
50
|
-
category: "events",
|
|
51
|
-
scope: "global",
|
|
52
|
-
importance: 0.5,
|
|
53
|
-
metadata: "{}",
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const pinsDir = join(root, "pins");
|
|
57
|
-
writeJson(pinsDir, "pin-legacy.json", {
|
|
58
|
-
id: "pin-legacy",
|
|
59
|
-
type: "pinned-memory",
|
|
60
|
-
title: "Legacy pin",
|
|
61
|
-
summary: "Pinned from an old global row.",
|
|
62
|
-
source: {
|
|
63
|
-
memoryId: "memory-1",
|
|
64
|
-
scope: "global",
|
|
65
|
-
timestamp: Date.now(),
|
|
66
|
-
metadata: {},
|
|
67
|
-
},
|
|
68
|
-
createdAt: "2026-03-18T00:00:00.000Z",
|
|
69
|
-
updatedAt: "2026-03-18T00:00:00.000Z",
|
|
70
|
-
snippet: "Legacy pin snippet.",
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const checkpointsDir = join(root, "session-checkpoints");
|
|
74
|
-
writeJson(checkpointsDir, "checkpoint-legacy.json", {
|
|
75
|
-
checkpointId: "checkpoint-legacy",
|
|
76
|
-
sessionId: "session-1",
|
|
77
|
-
resolvedScope: " ",
|
|
78
|
-
summary: "Old checkpoint that never got a real resolved scope.",
|
|
79
|
-
updatedAt: "2026-03-18T00:01:00.000Z",
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const workflowDir = join(root, "workflow-observations");
|
|
83
|
-
writeJson(workflowDir, "workflow-legacy.json", {
|
|
84
|
-
observationId: "workflow-legacy",
|
|
85
|
-
workflowId: "resume_context",
|
|
86
|
-
resolvedScope: null,
|
|
87
|
-
summary: "Legacy workflow observation missing scope.",
|
|
88
|
-
recordedAt: "2026-03-18T00:02:00.000Z",
|
|
89
|
-
});
|
|
90
|
-
mkdirSync(workflowDir, { recursive: true });
|
|
91
|
-
writeFileSync(join(workflowDir, "broken.json"), "{not-json");
|
|
92
|
-
|
|
93
|
-
const report = await collectScopeInventory({
|
|
94
|
-
store,
|
|
95
|
-
sampleLimit: 10,
|
|
96
|
-
pinsDir,
|
|
97
|
-
checkpointsDir,
|
|
98
|
-
workflowObservationsDir: workflowDir,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
expect(report.totalScannedCount).toBe(6);
|
|
102
|
-
expect(report.totalAnomalyCount).toBe(4);
|
|
103
|
-
expect(report.totalInvalidCount).toBe(1);
|
|
104
|
-
expect(report.totalReviewedCount).toBe(0);
|
|
105
|
-
|
|
106
|
-
const memoryLayer = report.layers.find((layer) => layer.layer === "memories");
|
|
107
|
-
const pinLayer = report.layers.find((layer) => layer.layer === "pins");
|
|
108
|
-
const checkpointLayer = report.layers.find((layer) => layer.layer === "session-checkpoints");
|
|
109
|
-
const workflowLayer = report.layers.find((layer) => layer.layer === "workflow-observations");
|
|
110
|
-
|
|
111
|
-
expect(memoryLayer?.anomalyCount).toBe(1);
|
|
112
|
-
expect(memoryLayer?.counts.global).toBe(1);
|
|
113
|
-
expect(pinLayer?.anomalyCount).toBe(1);
|
|
114
|
-
expect(pinLayer?.counts.global).toBe(1);
|
|
115
|
-
expect(checkpointLayer?.anomalyCount).toBe(1);
|
|
116
|
-
expect(checkpointLayer?.counts.empty).toBe(1);
|
|
117
|
-
expect(workflowLayer?.anomalyCount).toBe(1);
|
|
118
|
-
expect(workflowLayer?.counts.missing).toBe(1);
|
|
119
|
-
expect(workflowLayer?.invalidCount).toBe(1);
|
|
120
|
-
expect(workflowLayer?.reviewedCount).toBe(0);
|
|
121
|
-
|
|
122
|
-
const output = formatScopeInventoryReport(report);
|
|
123
|
-
expect(output).toContain("Scope inventory");
|
|
124
|
-
expect(output).toContain("[memories]");
|
|
125
|
-
expect(output).toContain("[pins]");
|
|
126
|
-
expect(output).toContain("[session-checkpoints]");
|
|
127
|
-
expect(output).toContain("[workflow-observations]");
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("returns a clean report when every layer is scoped correctly", async () => {
|
|
131
|
-
const root = createTempRoot();
|
|
132
|
-
const store = new MemoryStore({
|
|
133
|
-
dbPath: join(root, "db"),
|
|
134
|
-
vectorDim: 3,
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
await store.store({
|
|
138
|
-
text: "Scoped memory.",
|
|
139
|
-
vector: [1, 0, 0],
|
|
140
|
-
category: "entities",
|
|
141
|
-
scope: "project:recallnest",
|
|
142
|
-
importance: 0.9,
|
|
143
|
-
metadata: "{}",
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const report = await collectScopeInventory({
|
|
147
|
-
store,
|
|
148
|
-
sampleLimit: 5,
|
|
149
|
-
pinsDir: join(root, "missing-pins"),
|
|
150
|
-
checkpointsDir: join(root, "missing-checkpoints"),
|
|
151
|
-
workflowObservationsDir: join(root, "missing-workflows"),
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
expect(report.totalScannedCount).toBe(1);
|
|
155
|
-
expect(report.totalAnomalyCount).toBe(0);
|
|
156
|
-
expect(report.totalInvalidCount).toBe(0);
|
|
157
|
-
expect(report.totalReviewedCount).toBe(0);
|
|
158
|
-
expect(report.layers.every((layer) => layer.samples.length === 0)).toBe(true);
|
|
159
|
-
expect(formatScopeInventoryReport(report)).toContain("No unresolved legacy scope anomalies found");
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("suppresses reviewed keep-global workflow observations from unresolved anomaly counts", async () => {
|
|
163
|
-
const root = createTempRoot();
|
|
164
|
-
const store = new MemoryStore({
|
|
165
|
-
dbPath: join(root, "db"),
|
|
166
|
-
vectorDim: 3,
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
const workflowDir = join(root, "workflow-observations");
|
|
170
|
-
writeJson(workflowDir, "workflow-reviewed.json", {
|
|
171
|
-
observationId: "workflow-reviewed",
|
|
172
|
-
workflowId: "resume_context",
|
|
173
|
-
resolvedScope: "global",
|
|
174
|
-
summary: "Legacy workflow observation intentionally left global.",
|
|
175
|
-
recordedAt: "2026-03-18T00:02:00.000Z",
|
|
176
|
-
legacyScopeReview: {
|
|
177
|
-
decision: "keep",
|
|
178
|
-
kind: "global",
|
|
179
|
-
reason: "external-task",
|
|
180
|
-
reviewedAt: "2026-03-18T00:03:00.000Z",
|
|
181
|
-
},
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
const report = await collectScopeInventory({
|
|
185
|
-
store,
|
|
186
|
-
sampleLimit: 5,
|
|
187
|
-
workflowObservationsDir: workflowDir,
|
|
188
|
-
pinsDir: join(root, "missing-pins"),
|
|
189
|
-
checkpointsDir: join(root, "missing-checkpoints"),
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
const workflowLayer = report.layers.find((layer) => layer.layer === "workflow-observations");
|
|
193
|
-
expect(report.totalAnomalyCount).toBe(0);
|
|
194
|
-
expect(report.totalReviewedCount).toBe(1);
|
|
195
|
-
expect(workflowLayer?.anomalyCount).toBe(0);
|
|
196
|
-
expect(workflowLayer?.reviewedCount).toBe(1);
|
|
197
|
-
expect(workflowLayer?.samples).toHaveLength(0);
|
|
198
|
-
expect(formatScopeInventoryReport(report)).toContain("Reviewed keeps : 1");
|
|
199
|
-
});
|
|
200
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
|
|
3
|
-
import { matchesScopeFilter, resolveScopeSelection, resolveSessionScope } from "../scope-policy.js";
|
|
4
|
-
|
|
5
|
-
describe("scope-policy", () => {
|
|
6
|
-
it("prefers explicit scope over inferred values", () => {
|
|
7
|
-
const resolved = resolveScopeSelection({
|
|
8
|
-
scope: "project:recallnest",
|
|
9
|
-
sessionId: "session-123",
|
|
10
|
-
operation: "test:search",
|
|
11
|
-
env: {
|
|
12
|
-
RECALLNEST_DEFAULT_SCOPE: "project:other",
|
|
13
|
-
} as NodeJS.ProcessEnv,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
expect(resolved.resolvedScope).toBe("project:recallnest");
|
|
17
|
-
expect(resolved.scopeFilter).toEqual(["project:recallnest"]);
|
|
18
|
-
expect(resolved.inferredFrom).toBe("scope");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("falls back to session scope when explicit scope is absent", () => {
|
|
22
|
-
expect(resolveSessionScope("session-123")).toBe("session:session-123");
|
|
23
|
-
|
|
24
|
-
const resolved = resolveScopeSelection({
|
|
25
|
-
sessionId: "session-123",
|
|
26
|
-
operation: "test:search",
|
|
27
|
-
env: {} as NodeJS.ProcessEnv,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
expect(resolved.resolvedScope).toBe("session:session-123");
|
|
31
|
-
expect(resolved.scopeFilter).toEqual(["session:session-123"]);
|
|
32
|
-
expect(resolved.inferredFrom).toBe("sessionId");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("uses environment defaults when request scope is omitted", () => {
|
|
36
|
-
const resolved = resolveScopeSelection({
|
|
37
|
-
operation: "test:search",
|
|
38
|
-
env: {
|
|
39
|
-
RECALLNEST_DEFAULT_SCOPE: "project:recallnest",
|
|
40
|
-
} as NodeJS.ProcessEnv,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
expect(resolved.resolvedScope).toBe("project:recallnest");
|
|
44
|
-
expect(resolved.scopeFilter).toEqual(["project:recallnest"]);
|
|
45
|
-
expect(resolved.inferredFrom).toBe("RECALLNEST_DEFAULT_SCOPE");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("requires explicit opt-in before allowing cross-scope reads", () => {
|
|
49
|
-
expect(() => resolveScopeSelection({
|
|
50
|
-
operation: "test:search",
|
|
51
|
-
env: {} as NodeJS.ProcessEnv,
|
|
52
|
-
})).toThrow("requires a scope");
|
|
53
|
-
|
|
54
|
-
const allScopes = resolveScopeSelection({
|
|
55
|
-
operation: "test:search",
|
|
56
|
-
allScopes: true,
|
|
57
|
-
env: {} as NodeJS.ProcessEnv,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
expect(allScopes.allScopes).toBe(true);
|
|
61
|
-
expect(allScopes.scopeFilter).toBeUndefined();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("matches both exact and prefix scope filters", () => {
|
|
65
|
-
expect(matchesScopeFilter("project:recallnest", ["project:recallnest"])).toBe(true);
|
|
66
|
-
expect(matchesScopeFilter("cc:session-123", ["cc"])).toBe(true);
|
|
67
|
-
expect(matchesScopeFilter("project:other", ["project:recallnest"])).toBe(false);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
|
|
6
|
-
import { buildSessionCheckpointRecord, buildSessionCheckpointResult, normalizeCheckpointScope, resolveCheckpointScope, type CheckpointQuality } from "../session-engine.js";
|
|
7
|
-
import { formatCheckpointRecallSummary, formatCheckpointSaved, formatCheckpointSummary, formatResumeContext } from "../session-output.js";
|
|
8
|
-
import { SessionCheckpointStore } from "../session-store.js";
|
|
9
|
-
|
|
10
|
-
describe("session checkpoint engine", () => {
|
|
11
|
-
it("defaults checkpoint scope to session:<sessionId>", () => {
|
|
12
|
-
const record = buildSessionCheckpointRecord({
|
|
13
|
-
sessionId: "session-abc",
|
|
14
|
-
summary: "Implement checkpoint storage",
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
expect(resolveCheckpointScope(record)).toBe("session:session-abc");
|
|
18
|
-
expect(record.resolvedScope).toBe("session:session-abc");
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe("SessionCheckpointStore", () => {
|
|
23
|
-
it("saves and retrieves latest checkpoints by scope and session", async () => {
|
|
24
|
-
const dir = mkdtempSync(join(tmpdir(), "recallnest-checkpoints-"));
|
|
25
|
-
try {
|
|
26
|
-
const store = new SessionCheckpointStore(dir);
|
|
27
|
-
|
|
28
|
-
const first = await store.save(buildSessionCheckpointRecord({
|
|
29
|
-
sessionId: "session-1",
|
|
30
|
-
scope: "agent:codex",
|
|
31
|
-
summary: "First checkpoint",
|
|
32
|
-
nextActions: ["Implement checkpoint_session"],
|
|
33
|
-
updatedAt: "2026-03-16T03:00:00.000Z",
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
const second = await store.save(buildSessionCheckpointRecord({
|
|
37
|
-
sessionId: "session-2",
|
|
38
|
-
scope: "agent:codex",
|
|
39
|
-
summary: "Second checkpoint",
|
|
40
|
-
updatedAt: "2026-03-16T03:05:00.000Z",
|
|
41
|
-
}));
|
|
42
|
-
|
|
43
|
-
const latestByScope = await store.getLatest({ scope: "agent:codex" });
|
|
44
|
-
const latestBySession = await store.getLatest({ sessionId: "session-1" });
|
|
45
|
-
|
|
46
|
-
expect(latestByScope?.checkpointId).toBe(second.checkpointId);
|
|
47
|
-
expect(latestBySession?.checkpointId).toBe(first.checkpointId);
|
|
48
|
-
} finally {
|
|
49
|
-
rmSync(dir, { recursive: true, force: true });
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("session checkpoint output", () => {
|
|
55
|
-
it("formats saved and summary views", () => {
|
|
56
|
-
const record = buildSessionCheckpointRecord({
|
|
57
|
-
sessionId: "session-xyz",
|
|
58
|
-
summary: "Current task is implementing session checkpoints",
|
|
59
|
-
decisions: ["Keep checkpoints out of LanceDB"],
|
|
60
|
-
openLoops: ["Need resume_context next"],
|
|
61
|
-
nextActions: ["Add latest checkpoint API"],
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
expect(formatCheckpointSaved(record)).toContain("Keep checkpoints out of LanceDB");
|
|
65
|
-
expect(formatCheckpointSummary(record)).toContain("Latest checkpoint");
|
|
66
|
-
expect(formatCheckpointSummary(null)).toBe("No checkpoint found.");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("enriches recall checkpoint summaries with missing entity hints only once", () => {
|
|
70
|
-
const record = buildSessionCheckpointRecord({
|
|
71
|
-
sessionId: "session-entity-hints",
|
|
72
|
-
summary: "Raised continuity coverage for RecallNest startup recovery.",
|
|
73
|
-
entities: ["RecallNest", "smoke:claude-continuity", "resume_context"],
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
expect(formatCheckpointRecallSummary(record)).toBe(
|
|
77
|
-
"Raised continuity coverage for RecallNest startup recovery. Entities: smoke:claude-continuity, resume_context",
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("includes recall-only guidance in formatted resume context output", () => {
|
|
82
|
-
const output = formatResumeContext({
|
|
83
|
-
summary: "Stable context: Preference: 用户不喜欢 AI 味太重的文案语气。",
|
|
84
|
-
resolvedScope: "project:writing",
|
|
85
|
-
stableContext: ["Preference: 用户不喜欢 AI 味太重的文案语气。"],
|
|
86
|
-
relevantPatterns: [],
|
|
87
|
-
recentCases: [],
|
|
88
|
-
latestCheckpoint: {
|
|
89
|
-
sessionId: "session-writing",
|
|
90
|
-
resolvedScope: "project:writing",
|
|
91
|
-
summary: "Continue writing-style preference recovery.",
|
|
92
|
-
updatedAt: "2026-03-16T04:30:00.000Z",
|
|
93
|
-
},
|
|
94
|
-
responseMode: "recall-only",
|
|
95
|
-
responseGuidance: "Recall-only mode: answer from the recalled stable context item only.",
|
|
96
|
-
generatedAt: "2026-03-16T04:40:00.000Z",
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
expect(output).toContain("Scope: project:writing");
|
|
100
|
-
expect(output).toContain("Response mode: recall-only");
|
|
101
|
-
expect(output).toContain("Guidance: Recall-only mode");
|
|
102
|
-
expect(output).toContain("Stable context:");
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("sanitizes repo-state text out of checkpoint content", () => {
|
|
106
|
-
const result = buildSessionCheckpointResult({
|
|
107
|
-
sessionId: "session-repo-state",
|
|
108
|
-
summary: "Only resumed context in this window. git status shows many modified files.",
|
|
109
|
-
task: "Handle git status follow-up",
|
|
110
|
-
decisions: ["Keep repo-state out of checkpoints."],
|
|
111
|
-
openLoops: ["git status shows many uncommitted changes that still need review"],
|
|
112
|
-
nextActions: ["Process modified files after checking git status locally"],
|
|
113
|
-
});
|
|
114
|
-
const { record } = result;
|
|
115
|
-
|
|
116
|
-
expect(record.summary).toBe("Checkpoint captured current task state without repo-state details.");
|
|
117
|
-
expect(record.task).toBeUndefined();
|
|
118
|
-
expect(record.decisions).toEqual(["Keep repo-state out of checkpoints."]);
|
|
119
|
-
expect(record.openLoops).toEqual(["Current repo state still needs local verification if it matters for the next task."]);
|
|
120
|
-
expect(record.nextActions).toEqual(["Verify current repo state locally if it matters for the next task."]);
|
|
121
|
-
expect(result.sanitization.changed).toBe(true);
|
|
122
|
-
expect(result.sanitization.changedFields).toEqual(["summary", "task", "openLoops", "nextActions"]);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("does not mark sanitization when checkpoint content is already clean", () => {
|
|
126
|
-
const result = buildSessionCheckpointResult({
|
|
127
|
-
sessionId: "session-clean",
|
|
128
|
-
summary: "Continue wiring workflow observations into managed continuity.",
|
|
129
|
-
task: "Hook managed continuity observations",
|
|
130
|
-
decisions: ["Keep observations out of durable memory."],
|
|
131
|
-
openLoops: ["Need to update the managed snippets."],
|
|
132
|
-
nextActions: ["Add MCP and HTTP auto-observation coverage."],
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
expect(result.sanitization.changed).toBe(false);
|
|
136
|
-
expect(result.sanitization.changedFields).toEqual([]);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
describe("checkpoint scope normalization", () => {
|
|
141
|
-
it("normalizes bare project names to project: prefix", () => {
|
|
142
|
-
expect(normalizeCheckpointScope("recallnest")).toBe("project:recallnest");
|
|
143
|
-
expect(normalizeCheckpointScope("RecallNest")).toBe("project:recallnest");
|
|
144
|
-
expect(normalizeCheckpointScope("telegram-bridge")).toBe("project:telegram-bridge");
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("preserves existing prefixes but lowercases", () => {
|
|
148
|
-
expect(normalizeCheckpointScope("project:RecallNest")).toBe("project:recallnest");
|
|
149
|
-
expect(normalizeCheckpointScope("session:abc")).toBe("session:abc");
|
|
150
|
-
expect(normalizeCheckpointScope("eval:continuity")).toBe("eval:continuity");
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("applies normalization at save time via resolveCheckpointScope", () => {
|
|
154
|
-
expect(resolveCheckpointScope({ sessionId: "s1", scope: "RecallNest" })).toBe("project:recallnest");
|
|
155
|
-
expect(resolveCheckpointScope({ sessionId: "s1", scope: "project:RecallNest" })).toBe("project:recallnest");
|
|
156
|
-
expect(resolveCheckpointScope({ sessionId: "s1" })).toBe("session:s1");
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("matches checkpoints across scope variants in getLatest", async () => {
|
|
160
|
-
const dir = mkdtempSync(join(tmpdir(), "recallnest-scope-norm-"));
|
|
161
|
-
try {
|
|
162
|
-
const store = new SessionCheckpointStore(dir);
|
|
163
|
-
|
|
164
|
-
// Save with bare "recallnest" — will be normalized to "project:recallnest"
|
|
165
|
-
await store.save(buildSessionCheckpointRecord({
|
|
166
|
-
sessionId: "s-bare",
|
|
167
|
-
scope: "recallnest",
|
|
168
|
-
summary: "Bare scope checkpoint",
|
|
169
|
-
}));
|
|
170
|
-
|
|
171
|
-
// Save with "project:RecallNest" — will be normalized to "project:recallnest"
|
|
172
|
-
const later = buildSessionCheckpointRecord({
|
|
173
|
-
sessionId: "s-cased",
|
|
174
|
-
scope: "project:RecallNest",
|
|
175
|
-
summary: "Cased scope checkpoint",
|
|
176
|
-
});
|
|
177
|
-
// Manually set a later timestamp
|
|
178
|
-
(later as any).updatedAt = new Date(Date.now() + 1000).toISOString().replace(/\.\d+Z$/, ".000Z");
|
|
179
|
-
await store.save(later);
|
|
180
|
-
|
|
181
|
-
// Query with canonical "project:recallnest" should find both, return latest
|
|
182
|
-
const latest = await store.getLatest({ scope: "project:recallnest" });
|
|
183
|
-
expect(latest).not.toBeNull();
|
|
184
|
-
expect(latest!.summary).toBe("Cased scope checkpoint");
|
|
185
|
-
|
|
186
|
-
// Query with bare "recallnest" should also work
|
|
187
|
-
const latestBare = await store.getLatest({ scope: "recallnest" });
|
|
188
|
-
expect(latestBare).not.toBeNull();
|
|
189
|
-
expect(latestBare!.summary).toBe("Cased scope checkpoint");
|
|
190
|
-
} finally {
|
|
191
|
-
rmSync(dir, { recursive: true, force: true });
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
describe("checkpoint quality gate", () => {
|
|
197
|
-
it("classifies checkpoints with fallback summary and empty fields as minimal", () => {
|
|
198
|
-
const result = buildSessionCheckpointResult({
|
|
199
|
-
sessionId: "s-empty",
|
|
200
|
-
scope: "project:recallnest",
|
|
201
|
-
summary: "git status shows 5 modified files and 3 untracked files",
|
|
202
|
-
});
|
|
203
|
-
// Summary was sanitized to fallback, no decisions/openLoops/nextActions
|
|
204
|
-
expect(result.quality).toBe("minimal");
|
|
205
|
-
expect(result.sanitization.changed).toBe(true);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it("classifies checkpoints with real content as rich", () => {
|
|
209
|
-
const result = buildSessionCheckpointResult({
|
|
210
|
-
sessionId: "s-rich",
|
|
211
|
-
scope: "project:recallnest",
|
|
212
|
-
summary: "Completed scope normalization and checkpoint quality gate.",
|
|
213
|
-
decisions: ["Normalize scope at save and query time"],
|
|
214
|
-
});
|
|
215
|
-
expect(result.quality).toBe("rich");
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("classifies checkpoints with fallback summary but structured fields as rich", () => {
|
|
219
|
-
const result = buildSessionCheckpointResult({
|
|
220
|
-
sessionId: "s-mixed",
|
|
221
|
-
scope: "project:recallnest",
|
|
222
|
-
summary: "git status shows dirty worktree",
|
|
223
|
-
decisions: ["Keep using bun for builds"],
|
|
224
|
-
});
|
|
225
|
-
// Summary sanitized to fallback but decisions non-empty → still rich
|
|
226
|
-
expect(result.quality).toBe("rich");
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it("prefers rich checkpoints over minimal ones in getLatest", async () => {
|
|
230
|
-
const dir = mkdtempSync(join(tmpdir(), "recallnest-quality-gate-"));
|
|
231
|
-
try {
|
|
232
|
-
const store = new SessionCheckpointStore(dir);
|
|
233
|
-
|
|
234
|
-
// Save a rich checkpoint first (older)
|
|
235
|
-
await store.save(buildSessionCheckpointRecord({
|
|
236
|
-
sessionId: "s-rich",
|
|
237
|
-
scope: "project:recallnest",
|
|
238
|
-
summary: "Good checkpoint with real content.",
|
|
239
|
-
decisions: ["Keep checkpoints clean"],
|
|
240
|
-
updatedAt: "2026-03-22T01:00:00.000Z",
|
|
241
|
-
}));
|
|
242
|
-
|
|
243
|
-
// Save a minimal checkpoint later (newer) — all-sanitized fallback
|
|
244
|
-
await store.save(buildSessionCheckpointRecord({
|
|
245
|
-
sessionId: "s-minimal",
|
|
246
|
-
scope: "project:recallnest",
|
|
247
|
-
summary: "Checkpoint captured current task state without repo-state details.",
|
|
248
|
-
updatedAt: "2026-03-22T02:00:00.000Z",
|
|
249
|
-
}));
|
|
250
|
-
|
|
251
|
-
const latest = await store.getLatest({ scope: "project:recallnest" });
|
|
252
|
-
expect(latest).not.toBeNull();
|
|
253
|
-
// Should return the rich one even though it's older
|
|
254
|
-
expect(latest!.summary).toBe("Good checkpoint with real content.");
|
|
255
|
-
} finally {
|
|
256
|
-
rmSync(dir, { recursive: true, force: true });
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
});
|