@vellumai/assistant 0.10.7-dev.202607092332.9deedf4 → 0.10.7-dev.202607100313.fffdfea
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/ARCHITECTURE.md +1 -2
- package/docs/architecture/memory.md +1 -3
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +0 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +0 -2
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
- package/node_modules/@vellumai/service-contracts/package.json +0 -2
- package/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
- package/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
- package/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
- package/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
- package/openapi.yaml +1 -222
- package/package.json +1 -1
- package/scripts/memory-inspect.ts +2 -8
- package/src/__tests__/approval-routes-http.test.ts +0 -8
- package/src/__tests__/background-workers-disk-pressure.test.ts +4 -2
- package/src/__tests__/compaction-events.test.ts +0 -4
- package/src/__tests__/context-search-memory-source.test.ts +0 -1
- package/src/__tests__/conversation-agent-loop-disk-pressure.test.ts +0 -1
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +0 -2
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +0 -2
- package/src/__tests__/conversation-agent-loop.test.ts +0 -4
- package/src/__tests__/conversation-app-control-lifecycle.test.ts +0 -4
- package/src/__tests__/conversation-fork-crud.test.ts +18 -5
- package/src/__tests__/conversation-fork-retrospective.test.ts +483 -0
- package/src/__tests__/conversation-routes-disk-view.test.ts +0 -4
- package/src/__tests__/conversation-store.test.ts +0 -10
- package/src/__tests__/conversation-summarize-up-to.test.ts +0 -4
- package/src/__tests__/credential-execution-api-key-propagation.test.ts +0 -40
- package/src/__tests__/credential-execution-client.test.ts +3 -3
- package/src/__tests__/credential-execution-managed-contract.test.ts +8 -104
- package/src/__tests__/file-write-tool.test.ts +9 -13
- package/src/__tests__/graph-extraction-event-date.test.ts +0 -9
- package/src/__tests__/injection-block.test.ts +0 -1
- package/src/__tests__/job-handler-registration-guard.test.ts +0 -1
- package/src/__tests__/lexical-index-dual-write.test.ts +2 -2
- package/src/__tests__/llm-resolver.test.ts +0 -1
- package/src/__tests__/messages-after-tiebreaker.test.ts +0 -1
- package/src/__tests__/playbook-execution.test.ts +2 -26
- package/src/__tests__/plugin-import-boundary-guard.test.ts +0 -4
- package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +318 -0
- package/src/__tests__/proxy-approval-callback.test.ts +0 -1
- package/src/__tests__/rebuild-index-graph-nodes.test.ts +0 -4
- package/src/__tests__/send-endpoint-busy.test.ts +0 -12
- package/src/__tests__/service-contracts-import-guard.test.ts +4 -9
- package/src/__tests__/subagent-fork-spawn.test.ts +0 -37
- package/src/__tests__/task-memory-cleanup.test.ts +0 -11
- package/src/__tests__/voice-scoped-grant-consumer.test.ts +0 -1
- package/src/__tests__/voice-session-bridge.test.ts +0 -56
- package/src/__tests__/workspace-migration-009-backfill-conversation-disk-view.test.ts +0 -1
- package/src/__tests__/workspace-migration-013-repair-conversation-disk-view.test.ts +0 -1
- package/src/__tests__/workspace-migration-028-recover-conversations-from-disk-view.test.ts +0 -1
- package/src/__tests__/workspace-migration-129-remove-analyze-conversation-config.test.ts +190 -0
- package/src/cli/commands/db/repair-step-conversation-backfill.ts +0 -1
- package/src/config/bundled-skills/messaging/tools/messaging-analyze-style.ts +0 -6
- package/src/config/bundled-skills/playbooks/tools/playbook-create.ts +0 -3
- package/src/config/bundled-skills/playbooks/tools/playbook-delete.ts +0 -3
- package/src/config/bundled-skills/playbooks/tools/playbook-list.ts +1 -3
- package/src/config/bundled-skills/playbooks/tools/playbook-update.ts +0 -4
- package/src/config/call-site-defaults.ts +0 -1
- package/src/config/feature-flag-registry.json +0 -16
- package/src/config/schema.ts +0 -3
- package/src/config/schemas/call-site-catalog.ts +0 -6
- package/src/config/schemas/llm.ts +0 -1
- package/src/conversations/job-handlers/summarization.ts +0 -2
- package/src/daemon/conversation-agent-loop-handlers.ts +0 -1
- package/src/daemon/conversation-agent-loop.ts +1 -6
- package/src/daemon/conversation-lifecycle.ts +0 -14
- package/src/daemon/conversation-turn-finalize.ts +0 -1
- package/src/daemon/handlers/shared.ts +1 -2
- package/src/export/transcript-formatter.ts +9 -39
- package/src/home/conversation-starter-checkpoints.ts +9 -5
- package/src/home/job-handlers/conversation-starters.ts +24 -54
- package/src/hooks/types.ts +2 -2
- package/src/ipc/routes/__tests__/memory-v2-backfill.test.ts +5 -7
- package/src/persistence/__tests__/bulk-write-gate.test.ts +165 -0
- package/src/persistence/__tests__/immediate-transaction-guard.test.ts +70 -0
- package/src/persistence/auto-analysis-constants.ts +4 -13
- package/src/persistence/bulk-write-gate.ts +82 -0
- package/src/persistence/conversation-bootstrap.ts +3 -3
- package/src/persistence/conversation-crud.ts +158 -80
- package/src/persistence/conversation-key-store.ts +0 -2
- package/src/persistence/conversation-row-batch-delete.ts +16 -1
- package/src/persistence/conversation-types.ts +12 -1
- package/src/persistence/db-async-query.ts +18 -9
- package/src/persistence/db-connection.ts +20 -4
- package/src/persistence/db-maintenance.ts +78 -6
- package/src/persistence/embeddings/qdrant-client.ts +2 -18
- package/src/persistence/fork-message-copy.ts +18 -4
- package/src/persistence/jobs-store.ts +3 -86
- package/src/persistence/migrations/323-delete-non-default-memory-scopes.test.ts +148 -0
- package/src/persistence/migrations/323-delete-non-default-memory-scopes.ts +35 -0
- package/src/persistence/schema/conversations.ts +0 -1
- package/src/persistence/schema/memory-core.ts +17 -28
- package/src/persistence/schema/memory-graph.ts +0 -4
- package/src/persistence/schema/tasks.ts +0 -1
- package/src/persistence/steps.ts +2 -0
- package/src/playbooks/playbook-compiler.ts +2 -10
- package/src/plugins/defaults/memory/__tests__/db-maintenance.test.ts +105 -11
- package/src/plugins/defaults/memory/__tests__/jobs-store-enqueue-gate.test.ts +7 -62
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-job.test.ts +47 -5
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-skill-card.test.ts +29 -1
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-startup-cleanup.test.ts +133 -70
- package/src/plugins/defaults/memory/activation-session-store.ts +1 -1
- package/src/plugins/defaults/memory/config.ts +1 -1
- package/src/plugins/defaults/memory/context-search/sources/conversations.ts +1 -1
- package/src/plugins/defaults/memory/context-search/sources/memory-v2.ts +1 -1
- package/src/plugins/defaults/memory/context-search/sources/memory.ts +1 -1
- package/src/plugins/defaults/memory/filing-jobs.ts +1 -1
- package/src/plugins/defaults/memory/fork-conversation-memory.ts +8 -4
- package/src/plugins/defaults/memory/frontmatter.ts +1 -1
- package/src/plugins/defaults/memory/graph/__tests__/handle-remember-v2.test.ts +4 -25
- package/src/plugins/defaults/memory/graph/bootstrap.ts +12 -18
- package/src/plugins/defaults/memory/graph/capability-seed.ts +4 -18
- package/src/plugins/defaults/memory/graph/consolidation.ts +7 -14
- package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +1 -3
- package/src/plugins/defaults/memory/graph/decay.ts +5 -10
- package/src/plugins/defaults/memory/graph/extraction-job.ts +2 -3
- package/src/plugins/defaults/memory/graph/extraction.test.ts +1 -9
- package/src/plugins/defaults/memory/graph/extraction.ts +1 -8
- package/src/plugins/defaults/memory/graph/graph-search.ts +1 -2
- package/src/plugins/defaults/memory/graph/injection.test.ts +0 -1
- package/src/plugins/defaults/memory/graph/injection.ts +1 -1
- package/src/plugins/defaults/memory/graph/narrative.ts +1 -3
- package/src/plugins/defaults/memory/graph/pattern-scan.ts +1 -4
- package/src/plugins/defaults/memory/graph/retriever.test.ts +0 -19
- package/src/plugins/defaults/memory/graph/retriever.ts +6 -14
- package/src/plugins/defaults/memory/graph/scoring.test.ts +0 -1
- package/src/plugins/defaults/memory/graph/store.test.ts +6 -58
- package/src/plugins/defaults/memory/graph/store.ts +5 -43
- package/src/plugins/defaults/memory/graph/tool-handlers.test.ts +0 -4
- package/src/plugins/defaults/memory/graph/tool-handlers.ts +1 -11
- package/src/plugins/defaults/memory/graph/types.ts +0 -3
- package/src/plugins/defaults/memory/hooks/init.ts +1 -1
- package/src/plugins/defaults/memory/indexer.ts +2 -45
- package/src/plugins/defaults/memory/injectors.ts +2 -3
- package/src/plugins/defaults/memory/job-handler-registration.ts +0 -4
- package/src/plugins/defaults/memory/job-handlers/backfill.ts +0 -1
- package/src/plugins/defaults/memory/job-handlers/embedding.test.ts +0 -1
- package/src/plugins/defaults/memory/job-handlers/embedding.ts +0 -4
- package/src/plugins/defaults/memory/job-handlers/index-maintenance.ts +1 -1
- package/src/plugins/defaults/memory/job-handlers.ts +5 -9
- package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +1 -1
- package/src/plugins/defaults/memory/jobs/embed-pkb-file.test.ts +41 -21
- package/src/plugins/defaults/memory/jobs/embed-pkb-file.ts +10 -5
- package/src/plugins/defaults/memory/jobs-worker.ts +21 -9
- package/src/plugins/defaults/memory/logging.ts +17 -0
- package/src/plugins/defaults/memory/memory-retrospective-constants.ts +10 -7
- package/src/plugins/defaults/memory/memory-retrospective-enqueue.ts +5 -6
- package/src/plugins/defaults/memory/memory-retrospective-fork-boundary.ts +57 -20
- package/src/plugins/defaults/memory/memory-retrospective-job.ts +13 -15
- package/src/plugins/defaults/memory/memory-retrospective-skill-card.ts +2 -2
- package/src/plugins/defaults/memory/memory-retrospective-startup-cleanup.ts +52 -39
- package/src/plugins/defaults/memory/memory-retrospective-trigger-check.ts +1 -1
- package/src/plugins/defaults/memory/pkb/pkb-index.test.ts +25 -38
- package/src/plugins/defaults/memory/pkb/pkb-index.ts +7 -19
- package/src/plugins/defaults/memory/pkb/pkb-reconcile.test.ts +46 -28
- package/src/plugins/defaults/memory/pkb/pkb-reconcile.ts +4 -9
- package/src/plugins/defaults/memory/pkb/pkb-search.test.ts +3 -9
- package/src/plugins/defaults/memory/pkb/pkb-search.ts +2 -9
- package/src/plugins/defaults/memory/pkb/types.ts +0 -11
- package/src/plugins/defaults/memory/rerank-local.ts +1 -1
- package/src/plugins/defaults/memory/routes/memory-eval-routes.ts +1 -1
- package/src/plugins/defaults/memory/routes/memory-item-routes.test.ts +0 -1
- package/src/plugins/defaults/memory/routes/memory-item-routes.ts +3 -11
- package/src/plugins/defaults/memory/routes/memory-v2-routes.ts +1 -1
- package/src/plugins/defaults/memory/routes/memory-v3-routes.ts +1 -1
- package/src/plugins/defaults/memory/startup.ts +2 -3
- package/src/plugins/defaults/memory/task-memory-cleanup.ts +1 -1
- package/src/plugins/defaults/memory/tools.test.ts +1 -9
- package/src/plugins/defaults/memory/tools.ts +0 -1
- package/src/plugins/defaults/memory/v2/backfill-jobs.ts +1 -1
- package/src/plugins/defaults/memory/v2/cli-command-store.ts +1 -1
- package/src/plugins/defaults/memory/v2/consolidation-job.ts +1 -1
- package/src/plugins/defaults/memory/v2/frontmatter-sweep.ts +1 -1
- package/src/plugins/defaults/memory/v2/injection-events.ts +1 -1
- package/src/plugins/defaults/memory/v2/injection.ts +1 -1
- package/src/plugins/defaults/memory/v2/memory-v2-startup.ts +1 -1
- package/src/plugins/defaults/memory/v2/migration.ts +1 -1
- package/src/plugins/defaults/memory/v2/page-index.ts +1 -1
- package/src/plugins/defaults/memory/v2/prompts/consolidation.ts +1 -1
- package/src/plugins/defaults/memory/v2/prompts/router.ts +1 -1
- package/src/plugins/defaults/memory/v2/qdrant.ts +1 -1
- package/src/plugins/defaults/memory/v2/reranker.ts +1 -1
- package/src/plugins/defaults/memory/v2/router.ts +1 -1
- package/src/plugins/defaults/memory/v2/skill-store.ts +1 -1
- package/src/plugins/defaults/memory/v2/sweep-job.ts +1 -1
- package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
- package/src/plugins/defaults/memory/v3/dense.ts +1 -1
- package/src/plugins/defaults/memory/v3/injector.ts +1 -1
- package/src/plugins/defaults/memory/v3/maintain-job.ts +1 -1
- package/src/plugins/defaults/memory/v3/orchestrate.ts +1 -1
- package/src/plugins/defaults/memory/v3/pool-select.ts +1 -1
- package/src/plugins/defaults/memory/v3/prune.ts +1 -1
- package/src/plugins/defaults/memory/v3/section-dense-store.ts +1 -1
- package/src/plugins/defaults/memory/v3/shadow-plugin.ts +1 -1
- package/src/plugins/defaults/memory/worker.ts +1 -1
- package/src/runtime/capabilities.ts +1 -1
- package/src/runtime/routes/__tests__/bookmark-routes.test.ts +0 -1
- package/src/runtime/routes/__tests__/conversation-management-routes.test.ts +0 -1
- package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +0 -1
- package/src/runtime/routes/conversation-starter-routes.ts +12 -23
- package/src/runtime/routes/index.ts +0 -2
- package/src/runtime/services/__tests__/auto-analysis-guard.test.ts +1 -8
- package/src/runtime/services/__tests__/conversation-serializer.test.ts +0 -1
- package/src/runtime/services/auto-analysis-guard.ts +5 -5
- package/src/runtime/services/conversation-serializer.ts +2 -3
- package/src/tasks/SPEC.md +10 -17
- package/src/tools/executor.ts +1 -102
- package/src/tools/filesystem/write.ts +0 -2
- package/src/tools/tool-types.ts +0 -15
- package/src/tools/types.ts +0 -10
- package/src/workspace/migrations/028-recover-conversations-from-disk-view.ts +0 -1
- package/src/workspace/migrations/129-remove-analyze-conversation-config.ts +59 -0
- package/src/workspace/migrations/registry.ts +2 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
- package/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
- package/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
- package/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
- package/src/__tests__/auto-analysis-end-to-end.test.ts +0 -621
- package/src/__tests__/auto-analysis-prompt.test.ts +0 -50
- package/src/__tests__/config-analysis.test.ts +0 -83
- package/src/__tests__/conversation-analysis-routes.test.ts +0 -156
- package/src/__tests__/credential-execution-approval-bridge.test.ts +0 -297
- package/src/config/schemas/analysis.ts +0 -32
- package/src/credential-execution/approval-bridge.ts +0 -320
- package/src/daemon/__tests__/conversation-lifecycle-auto-analyze.test.ts +0 -449
- package/src/plugins/defaults/memory/__tests__/find-analysis-conversation.test.ts +0 -197
- package/src/runtime/routes/conversation-analysis-routes.ts +0 -75
- package/src/runtime/services/__tests__/analyze-conversation.test.ts +0 -477
- package/src/runtime/services/__tests__/auto-analysis-enqueue.test.ts +0 -386
- package/src/runtime/services/__tests__/auto-analysis-prompt.test.ts +0 -53
- package/src/runtime/services/__tests__/conversation-analyze-job.test.ts +0 -213
- package/src/runtime/services/__tests__/manual-analysis-prompt.test.ts +0 -41
- package/src/runtime/services/analyze-conversation.ts +0 -334
- package/src/runtime/services/auto-analysis-enqueue.ts +0 -130
- package/src/runtime/services/auto-analysis-prompt.ts +0 -55
- package/src/runtime/services/conversation-analyze-job.ts +0 -53
|
@@ -12,16 +12,11 @@ mock.module("../../../../util/logger.js", () => ({
|
|
|
12
12
|
const indexPkbFileCalls: Array<{
|
|
13
13
|
pkbRoot: string;
|
|
14
14
|
absPath: string;
|
|
15
|
-
memoryScopeId: string;
|
|
16
15
|
}> = [];
|
|
17
16
|
|
|
18
17
|
mock.module("../pkb/pkb-index.js", () => ({
|
|
19
|
-
indexPkbFile: async (
|
|
20
|
-
pkbRoot
|
|
21
|
-
absPath: string,
|
|
22
|
-
memoryScopeId: string,
|
|
23
|
-
) => {
|
|
24
|
-
indexPkbFileCalls.push({ pkbRoot, absPath, memoryScopeId });
|
|
18
|
+
indexPkbFile: async (pkbRoot: string, absPath: string) => {
|
|
19
|
+
indexPkbFileCalls.push({ pkbRoot, absPath });
|
|
25
20
|
},
|
|
26
21
|
}));
|
|
27
22
|
|
|
@@ -31,6 +26,14 @@ mock.module("../../../../config/loader.js", () => ({
|
|
|
31
26
|
invalidateConfigCache: () => {},
|
|
32
27
|
}));
|
|
33
28
|
|
|
29
|
+
// Controls the enqueue gate: PKB index jobs are v1-only, so the enqueue
|
|
30
|
+
// helper consults memory.v2.enabled.
|
|
31
|
+
let v2Enabled = false;
|
|
32
|
+
|
|
33
|
+
mock.module("../config.js", () => ({
|
|
34
|
+
getMemoryConfig: () => ({ v2: { enabled: v2Enabled } }),
|
|
35
|
+
}));
|
|
36
|
+
|
|
34
37
|
import { DEFAULT_CONFIG } from "../../../../config/defaults.js";
|
|
35
38
|
import type { AssistantConfig } from "../../../../config/types.js";
|
|
36
39
|
import { getMemoryDb } from "../../../../persistence/db-connection.js";
|
|
@@ -77,7 +80,6 @@ describe("embedPkbFileJob", () => {
|
|
|
77
80
|
makeJob({
|
|
78
81
|
pkbRoot: "/pkb/root",
|
|
79
82
|
absPath: "/pkb/root/note.md",
|
|
80
|
-
memoryScopeId: "scope-123",
|
|
81
83
|
}),
|
|
82
84
|
TEST_CONFIG,
|
|
83
85
|
);
|
|
@@ -86,32 +88,39 @@ describe("embedPkbFileJob", () => {
|
|
|
86
88
|
expect(indexPkbFileCalls[0]).toEqual({
|
|
87
89
|
pkbRoot: "/pkb/root",
|
|
88
90
|
absPath: "/pkb/root/note.md",
|
|
89
|
-
memoryScopeId: "scope-123",
|
|
90
91
|
});
|
|
91
92
|
});
|
|
92
93
|
|
|
93
94
|
test("skips when pkbRoot is missing", async () => {
|
|
94
95
|
await embedPkbFileJob(
|
|
95
|
-
makeJob({ absPath: "/pkb/root/note.md"
|
|
96
|
+
makeJob({ absPath: "/pkb/root/note.md" }),
|
|
96
97
|
TEST_CONFIG,
|
|
97
98
|
);
|
|
98
99
|
expect(indexPkbFileCalls).toHaveLength(0);
|
|
99
100
|
});
|
|
100
101
|
|
|
101
102
|
test("skips when absPath is missing", async () => {
|
|
102
|
-
await embedPkbFileJob(
|
|
103
|
-
makeJob({ pkbRoot: "/pkb/root", memoryScopeId: "scope-123" }),
|
|
104
|
-
TEST_CONFIG,
|
|
105
|
-
);
|
|
103
|
+
await embedPkbFileJob(makeJob({ pkbRoot: "/pkb/root" }), TEST_CONFIG);
|
|
106
104
|
expect(indexPkbFileCalls).toHaveLength(0);
|
|
107
105
|
});
|
|
108
106
|
|
|
109
|
-
test("
|
|
107
|
+
test("processes a legacy payload that still carries a memoryScopeId key", async () => {
|
|
108
|
+
// Rows enqueued before scope removal persist in the job queue with the
|
|
109
|
+
// extra key; the handler reads only pkbRoot/absPath and must not skip.
|
|
110
110
|
await embedPkbFileJob(
|
|
111
|
-
makeJob({
|
|
111
|
+
makeJob({
|
|
112
|
+
pkbRoot: "/pkb/root",
|
|
113
|
+
absPath: "/pkb/root/note.md",
|
|
114
|
+
memoryScopeId: "legacy-scope",
|
|
115
|
+
}),
|
|
112
116
|
TEST_CONFIG,
|
|
113
117
|
);
|
|
114
|
-
|
|
118
|
+
|
|
119
|
+
expect(indexPkbFileCalls).toHaveLength(1);
|
|
120
|
+
expect(indexPkbFileCalls[0]).toEqual({
|
|
121
|
+
pkbRoot: "/pkb/root",
|
|
122
|
+
absPath: "/pkb/root/note.md",
|
|
123
|
+
});
|
|
115
124
|
});
|
|
116
125
|
});
|
|
117
126
|
|
|
@@ -122,15 +131,29 @@ describe("enqueuePkbIndexJob", () => {
|
|
|
122
131
|
|
|
123
132
|
beforeEach(() => {
|
|
124
133
|
indexPkbFileCalls.length = 0;
|
|
134
|
+
v2Enabled = false;
|
|
125
135
|
const db = getMemoryDb()!;
|
|
126
136
|
db.delete(memoryJobs).run();
|
|
127
137
|
});
|
|
128
138
|
|
|
139
|
+
test("does not enqueue when memory v2 is enabled", () => {
|
|
140
|
+
v2Enabled = true;
|
|
141
|
+
|
|
142
|
+
const id = enqueuePkbIndexJob({
|
|
143
|
+
pkbRoot: "/pkb/root",
|
|
144
|
+
absPath: "/pkb/root/note.md",
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
expect(id).toBe("");
|
|
148
|
+
expect(claimMemoryJobs({ slowLlm: 10, fast: 10, embed: 10 })).toHaveLength(
|
|
149
|
+
0,
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
129
153
|
test("enqueues a pending embed_pkb_file job with payload", () => {
|
|
130
154
|
const id = enqueuePkbIndexJob({
|
|
131
155
|
pkbRoot: "/pkb/root",
|
|
132
156
|
absPath: "/pkb/root/note.md",
|
|
133
|
-
memoryScopeId: "scope-abc",
|
|
134
157
|
});
|
|
135
158
|
expect(id).toBeTruthy();
|
|
136
159
|
|
|
@@ -142,7 +165,6 @@ describe("enqueuePkbIndexJob", () => {
|
|
|
142
165
|
expect(job.payload).toEqual({
|
|
143
166
|
pkbRoot: "/pkb/root",
|
|
144
167
|
absPath: "/pkb/root/note.md",
|
|
145
|
-
memoryScopeId: "scope-abc",
|
|
146
168
|
});
|
|
147
169
|
});
|
|
148
170
|
|
|
@@ -150,7 +172,6 @@ describe("enqueuePkbIndexJob", () => {
|
|
|
150
172
|
enqueuePkbIndexJob({
|
|
151
173
|
pkbRoot: "/pkb/root",
|
|
152
174
|
absPath: "/pkb/root/note.md",
|
|
153
|
-
memoryScopeId: "scope-rt",
|
|
154
175
|
});
|
|
155
176
|
|
|
156
177
|
const claimed = claimMemoryJobs({ slowLlm: 10, fast: 10, embed: 10 });
|
|
@@ -163,7 +184,6 @@ describe("enqueuePkbIndexJob", () => {
|
|
|
163
184
|
expect(indexPkbFileCalls[0]).toEqual({
|
|
164
185
|
pkbRoot: "/pkb/root",
|
|
165
186
|
absPath: "/pkb/root/note.md",
|
|
166
|
-
memoryScopeId: "scope-rt",
|
|
167
187
|
});
|
|
168
188
|
});
|
|
169
189
|
});
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
isMemoryEnabled,
|
|
6
6
|
type MemoryJob,
|
|
7
7
|
} from "../../../../persistence/jobs-store.js";
|
|
8
|
+
import { getMemoryConfig } from "../config.js";
|
|
8
9
|
import { indexPkbFile } from "../pkb/pkb-index.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -13,7 +14,6 @@ import { indexPkbFile } from "../pkb/pkb-index.js";
|
|
|
13
14
|
export interface EmbedPkbFileJobInput {
|
|
14
15
|
pkbRoot: string;
|
|
15
16
|
absPath: string;
|
|
16
|
-
memoryScopeId: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -28,11 +28,10 @@ export async function embedPkbFileJob(
|
|
|
28
28
|
): Promise<void> {
|
|
29
29
|
const pkbRoot = asString(job.payload.pkbRoot);
|
|
30
30
|
const absPath = asString(job.payload.absPath);
|
|
31
|
-
|
|
32
|
-
if (!pkbRoot || !absPath || !memoryScopeId) return;
|
|
31
|
+
if (!pkbRoot || !absPath) return;
|
|
33
32
|
|
|
34
33
|
try {
|
|
35
|
-
await indexPkbFile(pkbRoot, absPath
|
|
34
|
+
await indexPkbFile(pkbRoot, absPath);
|
|
36
35
|
} catch (error) {
|
|
37
36
|
if (
|
|
38
37
|
error !== null &&
|
|
@@ -48,12 +47,18 @@ export async function embedPkbFileJob(
|
|
|
48
47
|
|
|
49
48
|
/**
|
|
50
49
|
* Enqueue an `embed_pkb_file` job (async, fire-and-forget).
|
|
50
|
+
*
|
|
51
|
+
* PKB is the v1 storage layer; under v2 nothing reads the PKB index and the
|
|
52
|
+
* v1 Qdrant collection is not initialized, so processing the job would throw.
|
|
53
|
+
* Skipping the enqueue here covers every producer (file-write hook, remember,
|
|
54
|
+
* startup reconcile); a later switch back to v1 rebuilds the index via the
|
|
55
|
+
* startup reconcile.
|
|
51
56
|
*/
|
|
52
57
|
export function enqueuePkbIndexJob(input: EmbedPkbFileJobInput): string {
|
|
53
58
|
if (!isMemoryEnabled()) return "";
|
|
59
|
+
if (getMemoryConfig().v2.enabled) return "";
|
|
54
60
|
return enqueueMemoryJob("embed_pkb_file", {
|
|
55
61
|
pkbRoot: input.pkbRoot,
|
|
56
62
|
absPath: input.absPath,
|
|
57
|
-
memoryScopeId: input.memoryScopeId,
|
|
58
63
|
});
|
|
59
64
|
}
|
|
@@ -17,7 +17,10 @@ import {
|
|
|
17
17
|
getLastScheduledCleanupEnqueueMs,
|
|
18
18
|
markScheduledCleanupEnqueued,
|
|
19
19
|
} from "../../../persistence/cleanup-schedule-state.js";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
maybeRunDbMaintenance,
|
|
22
|
+
maybeRunPassiveWalCheckpoint,
|
|
23
|
+
} from "../../../persistence/db-maintenance.js";
|
|
21
24
|
import {
|
|
22
25
|
EmbeddingBillingBlockError,
|
|
23
26
|
extractHttpStatus,
|
|
@@ -50,8 +53,8 @@ import {
|
|
|
50
53
|
SLOW_LLM_JOB_TYPES,
|
|
51
54
|
} from "../../../persistence/jobs-store.js";
|
|
52
55
|
import { spawnMemoryWorkerProcess } from "../../../persistence/worker-control.js";
|
|
53
|
-
import { getLogger } from "../../../util/logger.js";
|
|
54
56
|
import { getWorkspaceDir } from "../../../util/platform.js";
|
|
57
|
+
import { getLogger } from "./logging.js";
|
|
55
58
|
import { sweepOrphanMemoryRetrospectiveConversations } from "./memory-retrospective-startup-cleanup.js";
|
|
56
59
|
import { hasPkbBufferContent } from "./pkb-schedule.js";
|
|
57
60
|
import { countBufferLines } from "./v2/consolidation-job.js";
|
|
@@ -132,6 +135,9 @@ const LEGACY_JOB_TYPES = new Set([
|
|
|
132
135
|
"memory_v3_index_maintenance",
|
|
133
136
|
"memory_v3_edge_learning",
|
|
134
137
|
"memory_proc_distill",
|
|
138
|
+
// Retired analyze-conversation job type — pre-upgrade pending rows drop
|
|
139
|
+
// gracefully.
|
|
140
|
+
"conversation_analyze",
|
|
135
141
|
]);
|
|
136
142
|
|
|
137
143
|
export const POLL_INTERVAL_MIN_MS = 1_500;
|
|
@@ -258,16 +264,18 @@ export function startInProcessMemoryJobsWorker(
|
|
|
258
264
|
|
|
259
265
|
// After running-job recovery (so legitimate in-flight retries aren't
|
|
260
266
|
// swept), clean up orphan memory-retrospective background conversations
|
|
261
|
-
// left behind by daemon crashes mid-job. Best-effort
|
|
262
|
-
// startup on
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
267
|
+
// left behind by daemon crashes mid-job. Best-effort and detached — worker
|
|
268
|
+
// startup never blocks on the sweep, and failures only log. Concurrent
|
|
269
|
+
// ticking is safe: the sweep reads the active-job set and the orphan
|
|
270
|
+
// candidates in one synchronous block after its awaited baseline loads, so
|
|
271
|
+
// a retrospective forked by a mid-sweep tick is protected by its
|
|
272
|
+
// pending/running job.
|
|
273
|
+
void sweepOrphanMemoryRetrospectiveConversations().catch((err: unknown) => {
|
|
266
274
|
log.warn(
|
|
267
275
|
{ err },
|
|
268
276
|
"Memory-retrospective startup cleanup failed; continuing worker startup",
|
|
269
277
|
);
|
|
270
|
-
}
|
|
278
|
+
});
|
|
271
279
|
|
|
272
280
|
let stopped = false;
|
|
273
281
|
let tickRunning = false;
|
|
@@ -411,6 +419,7 @@ export async function runMemoryJobsOnce(
|
|
|
411
419
|
maybeEnqueueGraphMaintenanceJobs(config);
|
|
412
420
|
if (memoryEnabled) {
|
|
413
421
|
await maybeRunDbMaintenance();
|
|
422
|
+
await maybeRunPassiveWalCheckpoint();
|
|
414
423
|
}
|
|
415
424
|
return 0;
|
|
416
425
|
}
|
|
@@ -478,6 +487,7 @@ export async function runMemoryJobsOnce(
|
|
|
478
487
|
}
|
|
479
488
|
maybeEnqueueGraphMaintenanceJobs(config);
|
|
480
489
|
await maybeRunDbMaintenance();
|
|
490
|
+
await maybeRunPassiveWalCheckpoint();
|
|
481
491
|
return slowProcessed + fastProcessed + embedProcessed;
|
|
482
492
|
}
|
|
483
493
|
|
|
@@ -871,7 +881,9 @@ function isWithinPkbActiveHours(
|
|
|
871
881
|
start: number | null,
|
|
872
882
|
end: number | null,
|
|
873
883
|
): boolean {
|
|
874
|
-
if (start == null || end == null)
|
|
884
|
+
if (start == null || end == null) {
|
|
885
|
+
return true;
|
|
886
|
+
}
|
|
875
887
|
if (start <= end) {
|
|
876
888
|
return hour >= start && hour < end;
|
|
877
889
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The memory plugin's single logging channel. Every module in this plugin
|
|
3
|
+
* obtains its logger here rather than importing host `util/logger` directly,
|
|
4
|
+
* so the host import below is the plugin's sole logging escape (tracked by
|
|
5
|
+
* `plugin-import-boundary-guard.test.ts`).
|
|
6
|
+
*
|
|
7
|
+
* A plain forward is deliberate: memory creates module-scoped loggers in
|
|
8
|
+
* files that also run inside the jobs worker and CLI processes, where no
|
|
9
|
+
* plugin bootstrap (and therefore no `InitContext.logger`) exists. Deriving
|
|
10
|
+
* from the host-provided plugin logger requires a per-process binding story
|
|
11
|
+
* first; centralizing the import here keeps that cutover a one-file change.
|
|
12
|
+
*/
|
|
13
|
+
import { getLogger as getHostLogger } from "../../../util/logger.js";
|
|
14
|
+
|
|
15
|
+
export function getLogger(name: string) {
|
|
16
|
+
return getHostLogger(name);
|
|
17
|
+
}
|
|
@@ -26,8 +26,8 @@ export const MEMORY_RETROSPECTIVE_SOURCES: readonly string[] = [
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Whether a conversation `source` value marks a memory-retrospective
|
|
29
|
-
* background conversation (either kind). Shared predicate for
|
|
30
|
-
*
|
|
29
|
+
* background conversation (either kind). Shared predicate for recursion
|
|
30
|
+
* guards.
|
|
31
31
|
*/
|
|
32
32
|
export function isMemoryRetrospectiveSource(source: string): boolean {
|
|
33
33
|
return MEMORY_RETROSPECTIVE_SOURCES.includes(source);
|
|
@@ -35,16 +35,19 @@ export function isMemoryRetrospectiveSource(source: string): boolean {
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Dedicated `group_id` value for memory-retrospective background
|
|
38
|
-
* conversations. Placed under `system:background` alongside
|
|
39
|
-
*
|
|
38
|
+
* conversations. Placed under `system:background` alongside heartbeat and
|
|
39
|
+
* filing conversations.
|
|
40
40
|
*/
|
|
41
41
|
export const MEMORY_RETROSPECTIVE_GROUP_ID = "system:background";
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* `metadata.kind` value stamped on the user-role instruction message that
|
|
45
|
-
* fork-based retrospectives append to the forked conversation.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* fork-based retrospectives append to the forked conversation. Doubles as
|
|
46
|
+
* the empty-prefix discriminator in fork-boundary detection: a stampless
|
|
47
|
+
* fork-kind conversation whose first row carries this kind is run-authored
|
|
48
|
+
* end-to-end (see `memory-retrospective-fork-boundary.ts`). Also lets
|
|
49
|
+
* operators inspecting a fork's history tell the instruction apart from a
|
|
50
|
+
* real user turn.
|
|
48
51
|
*/
|
|
49
52
|
export const MEMORY_RETROSPECTIVE_INSTRUCTION_KIND =
|
|
50
53
|
"memory_retrospective_instruction";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "../../../persistence/jobs-store.js";
|
|
26
26
|
import { type TrustClass } from "../../../runtime/actor-trust-resolver.js";
|
|
27
27
|
import { resolveCapabilities } from "../../../runtime/capabilities.js";
|
|
28
|
-
import { getLogger } from "
|
|
28
|
+
import { getLogger } from "./logging.js";
|
|
29
29
|
import { isMemoryRetrospectiveSource } from "./memory-retrospective-constants.js";
|
|
30
30
|
import { MEMORY_V2_CONSOLIDATION_SOURCE } from "./v2/constants.js";
|
|
31
31
|
|
|
@@ -107,11 +107,10 @@ function isLowYieldRetrospectiveSource(conversationId: string): boolean {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* Fire a memory-retrospective enqueue from the compaction site.
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* failures).
|
|
110
|
+
* Fire a memory-retrospective enqueue from the compaction site. Trust-class
|
|
111
|
+
* gated (don't run a guardian-trust background loop over untrusted-actor
|
|
112
|
+
* conversations) with best-effort error swallowing (never block compaction
|
|
113
|
+
* on enqueue failures).
|
|
115
114
|
*/
|
|
116
115
|
export function enqueueMemoryRetrospectiveOnCompaction(
|
|
117
116
|
conversationId: string,
|
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
// next run's dedup baseline). Lives in its own module so the sweep doesn't
|
|
9
9
|
// have to import the job handler's full dependency graph.
|
|
10
10
|
|
|
11
|
-
import { getMessages } from "
|
|
12
|
-
|
|
13
|
-
import {
|
|
11
|
+
import { getMessages } from "@vellumai/plugin-api";
|
|
12
|
+
|
|
13
|
+
import { getLogger } from "./logging.js";
|
|
14
|
+
import {
|
|
15
|
+
MEMORY_RETROSPECTIVE_FORK_SOURCE,
|
|
16
|
+
MEMORY_RETROSPECTIVE_INSTRUCTION_KIND,
|
|
17
|
+
} from "./memory-retrospective-constants.js";
|
|
14
18
|
|
|
15
19
|
const log = getLogger("memory-retrospective-fork-boundary");
|
|
16
20
|
|
|
@@ -21,9 +25,11 @@ const log = getLogger("memory-retrospective-fork-boundary");
|
|
|
21
25
|
* source message); its `createdAt` is the boundary. The stamp's value may
|
|
22
26
|
* point at any ancestor when the source was itself a fork
|
|
23
27
|
* (`cloneForkMessageMetadata` preserves pre-existing values), so we only
|
|
24
|
-
* check for presence, not equality. Returns `null`
|
|
25
|
-
*
|
|
26
|
-
*
|
|
28
|
+
* check for presence, not equality. Returns `null` when no message carries a
|
|
29
|
+
* stamp — either the fork's copied prefix is empty (a tail-only fork whose
|
|
30
|
+
* inherited compaction covers the whole cutoff range copies nothing) or the
|
|
31
|
+
* copied rows' stamps are unreadable; `loadRetrospectiveRunMessages`
|
|
32
|
+
* disambiguates the two via the leading instruction row.
|
|
27
33
|
*/
|
|
28
34
|
export function findForkBoundaryCreatedAt(
|
|
29
35
|
forkMessages: Array<{
|
|
@@ -33,7 +39,9 @@ export function findForkBoundaryCreatedAt(
|
|
|
33
39
|
): number | null {
|
|
34
40
|
for (let i = forkMessages.length - 1; i >= 0; i--) {
|
|
35
41
|
const row = forkMessages[i]!;
|
|
36
|
-
if (!row.metadata)
|
|
42
|
+
if (!row.metadata) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
37
45
|
try {
|
|
38
46
|
const parsed = JSON.parse(row.metadata) as {
|
|
39
47
|
forkSourceMessageId?: unknown;
|
|
@@ -48,28 +56,49 @@ export function findForkBoundaryCreatedAt(
|
|
|
48
56
|
return null;
|
|
49
57
|
}
|
|
50
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Whether the row is a run-authored retrospective-instruction message
|
|
61
|
+
* (`metadata.kind` stamped by the job when it appends the instruction).
|
|
62
|
+
*/
|
|
63
|
+
function isRetrospectiveInstructionRow(metadata: string | null): boolean {
|
|
64
|
+
if (!metadata) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const parsed = JSON.parse(metadata) as { kind?: unknown };
|
|
69
|
+
return parsed.kind === MEMORY_RETROSPECTIVE_INSTRUCTION_KIND;
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
51
75
|
/**
|
|
52
76
|
* Load the messages a retrospective run produced itself, given the
|
|
53
77
|
* retrospective conversation's `source` kind:
|
|
54
78
|
*
|
|
55
|
-
* - **Fork-kind** rows carry the
|
|
56
|
-
* post-fork tail (messages strictly after the fork
|
|
57
|
-
* scanning the whole row would attribute the source
|
|
58
|
-
* turns to the retrospective.
|
|
79
|
+
* - **Fork-kind** rows carry the copied source prefix (the source's visible
|
|
80
|
+
* tail), so only the post-fork tail (messages strictly after the fork
|
|
81
|
+
* boundary) counts — scanning the whole row would attribute the source
|
|
82
|
+
* conversation's own turns to the retrospective. When no row carries a
|
|
83
|
+
* `forkSourceMessageId` stamp, the fork is run-authored end-to-end only
|
|
84
|
+
* if its first row is the run's own instruction message (the empty-prefix
|
|
85
|
+
* tail-only fork); a stampless fork WITHOUT a leading instruction row is
|
|
86
|
+
* indeterminate — attributing it would mine copied source tool calls as
|
|
87
|
+
* run output — and degrades to "produced none".
|
|
59
88
|
* - **Legacy-kind** rows start empty, so every message is the run's own.
|
|
60
89
|
*
|
|
61
|
-
* Returns `null` when the run's output cannot be determined
|
|
62
|
-
* failure, or
|
|
63
|
-
*
|
|
64
|
-
*
|
|
90
|
+
* Returns `null` when the run's output cannot be determined (message load
|
|
91
|
+
* failure, or the indeterminate stampless shape above) — callers degrade
|
|
92
|
+
* (empty dedup baseline / "no output"). Best-effort: failures are logged,
|
|
93
|
+
* never thrown.
|
|
65
94
|
*/
|
|
66
|
-
export function loadRetrospectiveRunMessages(
|
|
95
|
+
export async function loadRetrospectiveRunMessages(
|
|
67
96
|
conversationId: string,
|
|
68
97
|
source: string | null | undefined,
|
|
69
|
-
): ReturnType<typeof getMessages
|
|
70
|
-
let messages: ReturnType<typeof getMessages
|
|
98
|
+
): Promise<Awaited<ReturnType<typeof getMessages>> | null> {
|
|
99
|
+
let messages: Awaited<ReturnType<typeof getMessages>>;
|
|
71
100
|
try {
|
|
72
|
-
messages = getMessages(conversationId);
|
|
101
|
+
messages = await getMessages(conversationId);
|
|
73
102
|
} catch (err) {
|
|
74
103
|
log.warn(
|
|
75
104
|
{ err, retrospectiveConversationId: conversationId },
|
|
@@ -81,9 +110,17 @@ export function loadRetrospectiveRunMessages(
|
|
|
81
110
|
if (source === MEMORY_RETROSPECTIVE_FORK_SOURCE) {
|
|
82
111
|
const boundaryCreatedAt = findForkBoundaryCreatedAt(messages);
|
|
83
112
|
if (boundaryCreatedAt == null) {
|
|
113
|
+
if (messages.length === 0) {
|
|
114
|
+
return messages;
|
|
115
|
+
}
|
|
116
|
+
if (isRetrospectiveInstructionRow(messages[0]?.metadata ?? null)) {
|
|
117
|
+
// Empty copied prefix — the run's instruction opens the conversation,
|
|
118
|
+
// so every message is the run's own output.
|
|
119
|
+
return messages;
|
|
120
|
+
}
|
|
84
121
|
log.warn(
|
|
85
122
|
{ retrospectiveConversationId: conversationId },
|
|
86
|
-
"memory-retrospective: fork-kind retrospective has no
|
|
123
|
+
"memory-retrospective: fork-kind retrospective has no forkSourceMessageId stamps and no leading instruction row; treating run as having produced none",
|
|
87
124
|
);
|
|
88
125
|
return null;
|
|
89
126
|
}
|
|
@@ -77,8 +77,8 @@ import {
|
|
|
77
77
|
import { resolveUserSlug } from "../../../prompts/persona-resolver.js";
|
|
78
78
|
import type { SystemPromptPersonaOverride } from "../../../prompts/system-prompt.js";
|
|
79
79
|
import { wakeAgentForOpportunity } from "../../../runtime/agent-wake.js";
|
|
80
|
-
import { getLogger } from "../../../util/logger.js";
|
|
81
80
|
import { findMostRecentRetrospectiveFor } from "./find-most-recent-retrospective-for.js";
|
|
81
|
+
import { getLogger } from "./logging.js";
|
|
82
82
|
import { getRetrospectiveMessagesAfter } from "./memory-retrospective-accounting.js";
|
|
83
83
|
import {
|
|
84
84
|
MEMORY_RETROSPECTIVE_FORK_SOURCE,
|
|
@@ -238,12 +238,12 @@ export async function runForkBasedRetrospective(
|
|
|
238
238
|
}
|
|
239
239
|
const cutoffMessageId = cutoffMessage.id;
|
|
240
240
|
|
|
241
|
-
// The fork carries the
|
|
242
|
-
//
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
//
|
|
246
|
-
// turn-context metadata block.
|
|
241
|
+
// The fork carries the source's visible window (inherited compaction
|
|
242
|
+
// summary + tail rows), so the agent needs an explicit anchor telling it
|
|
243
|
+
// where the review window begins. Prefer the user turn's `<turn_context>`
|
|
244
|
+
// `current_time:` (the exact string the model sees in its rehydrated
|
|
245
|
+
// history); fall back to `createdAt` rendered in the conversation's
|
|
246
|
+
// timezone when no row in the slice carries a turn-context metadata block.
|
|
247
247
|
const timezoneContext = resolveTurnTimezoneContext({
|
|
248
248
|
configuredUserTimeZone: config.ui.userTimezone ?? null,
|
|
249
249
|
detectedTimezone: config.ui.detectedTimezone ?? null,
|
|
@@ -271,10 +271,9 @@ export async function runForkBasedRetrospective(
|
|
|
271
271
|
// advances to `cutoffMessageId`, causing the next retrospective to
|
|
272
272
|
// reprocess (and potentially re-`remember`) those same turns.
|
|
273
273
|
//
|
|
274
|
-
//
|
|
275
|
-
//
|
|
276
|
-
//
|
|
277
|
-
// fork ⇒ summary + tail visible to the agent natively.
|
|
274
|
+
// The fork copies only the source's visible tail and carries the inherited
|
|
275
|
+
// compaction summary on its own row (with a fork-local compacted count of
|
|
276
|
+
// 0). Compacted source ⇒ summary + tail visible to the agent natively.
|
|
278
277
|
let forkConversationRow: Awaited<
|
|
279
278
|
ReturnType<typeof forkConversationForRetrospective>
|
|
280
279
|
>;
|
|
@@ -913,14 +912,14 @@ async function collectPriorRetrospectiveRemembers(
|
|
|
913
912
|
* `loadRetrospectiveRunMessages` scopes fork-kind rows to the post-fork tail
|
|
914
913
|
* (the copied prefix contains the source conversation's own inline
|
|
915
914
|
* `remember` calls, which must not pollute the dedup baseline) and returns
|
|
916
|
-
* `null` on load failure
|
|
917
|
-
*
|
|
915
|
+
* `null` on load failure (logged, never fatal) — treated here as "the run
|
|
916
|
+
* saved nothing".
|
|
918
917
|
*/
|
|
919
918
|
async function extractRetrospectiveRunRemembers(
|
|
920
919
|
conversationId: string,
|
|
921
920
|
): Promise<string[]> {
|
|
922
921
|
const conv = await getConversation(conversationId);
|
|
923
|
-
const runMessages = loadRetrospectiveRunMessages(
|
|
922
|
+
const runMessages = await loadRetrospectiveRunMessages(
|
|
924
923
|
conversationId,
|
|
925
924
|
conv?.source ?? null,
|
|
926
925
|
);
|
|
@@ -995,7 +994,6 @@ function extractRememberContents(messages: MessageLike[]): string[] {
|
|
|
995
994
|
/**
|
|
996
995
|
* Neutralize closing `</already_remembered>` sentinels in untrusted content so
|
|
997
996
|
* they can't close the wrapper tag and escape into instruction context.
|
|
998
|
-
* Mirrors `neutralizeTranscriptSentinel` from the auto-analysis prompt.
|
|
999
997
|
*/
|
|
1000
998
|
function neutralizeSentinels(s: string): string {
|
|
1001
999
|
return s.replace(
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
upsertSkillCardInsertJob,
|
|
41
41
|
} from "../../../persistence/jobs-store.js";
|
|
42
42
|
import { publishConversationMessagesChanged } from "../../../runtime/sync/resource-sync-events.js";
|
|
43
|
-
import { getLogger } from "
|
|
43
|
+
import { getLogger } from "./logging.js";
|
|
44
44
|
import { SKILL_CARD_MESSAGE_KIND } from "./memory-retrospective-constants.js";
|
|
45
45
|
import { loadRetrospectiveRunMessages } from "./memory-retrospective-fork-boundary.js";
|
|
46
46
|
|
|
@@ -79,7 +79,7 @@ export interface AuthoredSkill {
|
|
|
79
79
|
export async function extractRetrospectiveRunSkillScaffolds(
|
|
80
80
|
retrospectiveConversationId: string,
|
|
81
81
|
): Promise<AuthoredSkill[]> {
|
|
82
|
-
const runMessages = loadRetrospectiveRunMessages(
|
|
82
|
+
const runMessages = await loadRetrospectiveRunMessages(
|
|
83
83
|
retrospectiveConversationId,
|
|
84
84
|
(await getConversation(retrospectiveConversationId))?.source ?? null,
|
|
85
85
|
);
|