opencode-swarm 7.144.1 → 7.144.2
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/agents/architect.d.ts +1 -0
- package/dist/agents/coder.d.ts +1 -0
- package/dist/agents/critic.d.ts +1 -0
- package/dist/agents/explorer.d.ts +1 -0
- package/dist/agents/reviewer.d.ts +1 -0
- package/dist/cli/{ast-diff-ypptrcan.js → ast-diff-wbjcazfx.js} +5 -3
- package/dist/cli/{config-doctor-5hj26phk.js → config-doctor-7dfvxwjb.js} +3 -3
- package/dist/cli/{core-aqtegsag.js → core-dwmwdc4y.js} +2 -2
- package/dist/cli/{curator-llm-factory-1rg62kzr.js → curator-llm-factory-rrs1q4hg.js} +20 -20
- package/dist/cli/{curator-vcrcht4h.js → curator-w213v33y.js} +20 -20
- package/dist/cli/{evidence-summary-service-fsh6jfhm.js → evidence-summary-service-t7n2h1he.js} +7 -7
- package/dist/cli/{explorer-18353rhn.js → explorer-zvk5kbcb.js} +3 -1
- package/dist/cli/{gate-evidence-9w2eehnj.js → gate-evidence-xvxn603y.js} +3 -3
- package/dist/cli/{guardrail-explain-6mxn4bj8.js → guardrail-explain-v1mwsnkq.js} +21 -21
- package/dist/cli/{guardrail-log-81c5b018.js → guardrail-log-dn03dpz2.js} +4 -4
- package/dist/cli/{hive-promoter-rxkykddk.js → hive-promoter-asjtj7ga.js} +20 -20
- package/dist/cli/{index-8gs34d2q.js → index-333kvewd.js} +4 -4
- package/dist/cli/{index-xmzmeknp.js → index-70ha9e09.js} +2 -1
- package/dist/cli/{index-dq26vbfp.js → index-7ca3a6gj.js} +3 -3
- package/dist/cli/{index-5n69863d.js → index-7ryh498h.js} +1 -173
- package/dist/cli/{index-g0vr2a4m.js → index-av0f6mm0.js} +5 -5
- package/dist/cli/{index-c3zag2cw.js → index-ckrasab9.js} +4 -4
- package/dist/cli/{index-sqp6349j.js → index-d55crzd4.js} +1 -1
- package/dist/cli/index-ddpkwdcb.js +176 -0
- package/dist/cli/{index-8jrn4rwp.js → index-dg2w0wr4.js} +3 -3
- package/dist/cli/{index-2ht8c7ew.js → index-dhh2j2nd.js} +2 -7
- package/dist/cli/{index-bgdr1ww3.js → index-g1c5fgaw.js} +1 -1
- package/dist/cli/{index-j2eb0x44.js → index-g2ajae1z.js} +2 -2
- package/dist/cli/{index-j3byg0a9.js → index-h3z64mhz.js} +6 -2
- package/dist/cli/{index-4s5htbgq.js → index-hqvt3mhk.js} +1 -1
- package/dist/cli/{index-mz1zwz96.js → index-jb4tchvy.js} +2 -2
- package/dist/cli/{index-n11zkp9g.js → index-jsfghpy2.js} +2 -2
- package/dist/cli/{index-2pmaxbvj.js → index-m6wv2qdr.js} +1 -1
- package/dist/cli/{index-315tnsve.js → index-ne8cfgw5.js} +1 -1
- package/dist/cli/{index-e9w1tfmm.js → index-nretd4qn.js} +6659 -1725
- package/dist/cli/{index-rr2fjfsd.js → index-p3tnmkvc.js} +3 -3
- package/dist/cli/{index-1faydhv8.js → index-qpt8ahph.js} +196 -93
- package/dist/cli/{index-hc25qawy.js → index-tg9fn2dy.js} +22 -22
- package/dist/cli/{index-jqsfsqbx.js → index-whezv7vc.js} +4 -0
- package/dist/cli/{index-4905hd2m.js → index-wx8zdh4a.js} +6 -1
- package/dist/cli/{index-rdb3nr6d.js → index-y95nwsge.js} +1 -1
- package/dist/cli/{index-f79hf8dr.js → index-zr370283.js} +3 -3
- package/dist/cli/index.js +22 -36
- package/dist/cli/{knowledge-escalator-hg4jzbrx.js → knowledge-escalator-cg19dhe5.js} +7 -7
- package/dist/cli/{knowledge-events-wgy7gbct.js → knowledge-events-yzvysaqd.js} +5 -5
- package/dist/cli/{knowledge-store-nd0f0e86.js → knowledge-store-6f77xpmm.js} +1 -1
- package/dist/cli/{knowledge-validator-0ar015bf.js → knowledge-validator-4b28zdxa.js} +2 -2
- package/dist/cli/{runtime-te94z1zb.js → runtime-x10qb3z1.js} +3 -2
- package/dist/cli/{scan-cursor-pqp3bsqv.js → scan-cursor-nqbb1xt6.js} +2 -2
- package/dist/cli/{schema-4ew49zrv.js → schema-jj2pb6zp.js} +2 -2
- package/dist/cli/{scope-persistence-geth2hb1.js → scope-persistence-63nasq0z.js} +5 -5
- package/dist/cli/{skill-generator-8azm6p2y.js → skill-generator-nsymtdqm.js} +8 -8
- package/dist/cli/tree-sitter-431q1bka.js +26 -0
- package/dist/cli/{worktree-isolation-cqxgdk2p.js → worktree-isolation-g54kxw6x.js} +20 -20
- package/dist/config/constants.d.ts +1 -1
- package/dist/config/schema.d.ts +8 -0
- package/dist/hooks/review-receipt-scope.d.ts +42 -15
- package/dist/hooks/reviewer-scope-file-fingerprint.d.ts +58 -6
- package/dist/hooks/reviewer-scope-lifecycle.d.ts +9 -1
- package/dist/hooks/reviewer-scope-mergeback.d.ts +23 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +564 -522
- package/dist/memory/config.d.ts +6 -0
- package/dist/memory/consolidation.d.ts +2 -0
- package/dist/memory/gateway.d.ts +12 -1
- package/dist/memory/index.d.ts +6 -4
- package/dist/memory/jsonl-migration.d.ts +28 -3
- package/dist/memory/local-jsonl-provider.d.ts +16 -1
- package/dist/memory/maintenance.d.ts +5 -0
- package/dist/memory/memory-family-migration.d.ts +12 -0
- package/dist/memory/outcome-events.d.ts +24 -0
- package/dist/memory/provider.d.ts +7 -1
- package/dist/memory/reflection-injection.d.ts +1 -0
- package/dist/memory/reflection-service.d.ts +68 -0
- package/dist/memory/reflection.d.ts +41 -0
- package/dist/memory/schema.d.ts +13 -1
- package/dist/memory/sqlite-provider.d.ts +18 -1
- package/dist/memory/types.d.ts +19 -1
- package/dist/state.d.ts +107 -2
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/manifest.d.ts +1 -0
- package/dist/tools/swarm-memory-outcome.d.ts +11 -0
- package/dist/tools/tool-metadata.d.ts +4 -0
- package/package.json +1 -1
package/dist/memory/config.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ export interface MemoryConfig {
|
|
|
19
19
|
tokenBudget: number;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
reflection: {
|
|
23
|
+
/** Generate/inject deterministic outcome lessons automatically. */
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
/** Exponential decay half-life for signed outcomes. */
|
|
26
|
+
halfLifeDays: number;
|
|
27
|
+
};
|
|
22
28
|
learning: MemoryLearningConfig;
|
|
23
29
|
writes: {
|
|
24
30
|
mode: 'propose';
|
|
@@ -28,6 +28,8 @@ export interface ConsolidationDeps {
|
|
|
28
28
|
logEvent: (event: MemoryRunLogEvent) => Promise<void>;
|
|
29
29
|
readLog: () => Promise<ConsolidationLogRecord[]>;
|
|
30
30
|
appendLog: (record: ConsolidationLogRecord) => Promise<void>;
|
|
31
|
+
/** Worktree-local structural staleness. Optional for legacy/test callers. */
|
|
32
|
+
readDeadAnchorMemoryIds?: () => ReadonlySet<string>;
|
|
31
33
|
signal?: AbortSignal;
|
|
32
34
|
}
|
|
33
35
|
export interface ConsolidationInput {
|
package/dist/memory/gateway.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { type MemoryConfig } from './config';
|
|
2
2
|
import type { MemoryProposalStore, MemoryProvider, MemoryRecallUsageEvent, MemoryRecallUsageFilter } from './provider';
|
|
3
3
|
import { type VettedMemoryRoot } from './storage-root';
|
|
4
|
-
import type { AppliedMemoryChange, CuratorMemoryDecision, MemoryContext, MemoryKind, MemoryListFilter, MemoryProposal, MemoryRecord, MemoryScopeRef, MemorySource, RecallBundle, RecallMode } from './types';
|
|
4
|
+
import type { AppliedMemoryChange, CuratorMemoryDecision, MemoryAnchor, MemoryContext, MemoryKind, MemoryListFilter, MemoryOutcome, MemoryProposal, MemoryRecord, MemoryScopeRef, MemorySource, RecallBundle, RecallMode } from './types';
|
|
5
5
|
export interface MemoryGatewayOptions {
|
|
6
6
|
config?: Partial<MemoryConfig>;
|
|
7
7
|
provider?: MemoryProvider & Partial<MemoryProposalStore>;
|
|
8
8
|
now?: () => Date;
|
|
9
9
|
}
|
|
10
|
+
export interface RecordMemoryOutcomeInput {
|
|
11
|
+
memoryId?: string;
|
|
12
|
+
question?: string;
|
|
13
|
+
outcome: MemoryOutcome['outcome'];
|
|
14
|
+
anchors?: MemoryAnchor[];
|
|
15
|
+
correction?: string;
|
|
16
|
+
eventId?: string;
|
|
17
|
+
}
|
|
10
18
|
export interface ProposeMemoryInput {
|
|
11
19
|
operation: MemoryProposal['operation'];
|
|
12
20
|
kind?: MemoryKind;
|
|
@@ -59,6 +67,7 @@ export declare class MemoryGateway {
|
|
|
59
67
|
}): Promise<MemoryProposal[]>;
|
|
60
68
|
listRecallUsage(filter?: MemoryRecallUsageFilter): Promise<MemoryRecallUsageEvent[]>;
|
|
61
69
|
upsertCurated(record: MemoryRecord): Promise<MemoryRecord>;
|
|
70
|
+
recordOutcome(input: RecordMemoryOutcomeInput): Promise<MemoryRecord>;
|
|
62
71
|
applyCuratorDecision(decision: CuratorMemoryDecision): Promise<AppliedMemoryChange>;
|
|
63
72
|
createRecord(input: {
|
|
64
73
|
kind: MemoryKind;
|
|
@@ -70,6 +79,8 @@ export declare class MemoryGateway {
|
|
|
70
79
|
stability?: MemoryRecord['stability'];
|
|
71
80
|
tags?: string[];
|
|
72
81
|
metadata?: Record<string, unknown>;
|
|
82
|
+
anchors?: MemoryAnchor[];
|
|
83
|
+
outcomes?: MemoryOutcome[];
|
|
73
84
|
}): MemoryRecord;
|
|
74
85
|
private resolveCuratorDecision;
|
|
75
86
|
private createRecordFromNew;
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -2,20 +2,22 @@ export type { MemoryConfig } from './config';
|
|
|
2
2
|
export { DEFAULT_MEMORY_CONFIG, resolveMemoryConfig } from './config';
|
|
3
3
|
export { MemoryDisabledError, MemoryValidationError } from './errors';
|
|
4
4
|
export { evaluateMemoryRecallFixtures, loadRecallEvaluationFixtures, type RecallEvaluationMetrics, type RecallEvaluationMode, type RecallEvaluationOptions, type RecallEvaluationProviderName, type RecallEvaluationReport, type RecallEvaluationRun, } from './evaluation';
|
|
5
|
-
export type { MemoryGatewayOptions, ProposeMemoryInput, RecallMemoryInput, } from './gateway';
|
|
5
|
+
export type { MemoryGatewayOptions, ProposeMemoryInput, RecallMemoryInput, RecordMemoryOutcomeInput, } from './gateway';
|
|
6
6
|
export { createConfiguredMemoryProvider, createConfiguredMemoryProviderForRoot, createMemoryGateway, MemoryGateway, } from './gateway';
|
|
7
7
|
export { createMemoryLifecycleHooks, type MemoryLifecycleHookOptions, type MemoryLifecycleHooks, } from './injector';
|
|
8
|
-
export { backupLegacyJsonl, getLegacyJsonlFileStatus, type JsonlBackupResult, type JsonlImportPayload, type JsonlInvalidRow, type JsonlMigrationReport, LEGACY_JSONL_MIGRATION_NAME, LEGACY_JSONL_MIGRATION_VERSION, readLegacyJsonl, readMigrationReport, resolveMemoryStorageDir, resolveSqliteDatabasePath, writeJsonlExport, writeMigrationReport, } from './jsonl-migration';
|
|
8
|
+
export { backupLegacyJsonl, getLegacyJsonlFileStatus, getLegacyOutcomeJsonlSignature, type JsonlBackupResult, type JsonlImportPayload, type JsonlInvalidRow, type JsonlMigrationReport, LEGACY_JSONL_MIGRATION_NAME, LEGACY_JSONL_MIGRATION_VERSION, LEGACY_JSONL_OUTCOME_META_KEY, readLegacyJsonl, readMigrationReport, resolveMemoryStorageDir, resolveSqliteDatabasePath, writeJsonlExport, writeMigrationReport, } from './jsonl-migration';
|
|
9
9
|
export { LocalJsonlMemoryProvider } from './local-jsonl-provider';
|
|
10
10
|
export { buildMemoryMaintenanceReport, type MemoryMaintenanceReport, type MemoryMaintenanceReportOptions, type MemoryRecallUsageByMemory, type MemoryRecallUsageByRole, type MemorySupersededChain, shouldCompactMemory, } from './maintenance';
|
|
11
11
|
export { invalidateMemoryStoreDirCache, isMemoryLinked, MEMORY_LINK_POINTER_FILENAME, type MemoryLinkPointer, readMemoryLinkPointer, removeMemoryLinkPointer, resolveMemoryStoreDir, writeMemoryLinkPointer, } from './memory-link';
|
|
12
|
+
export type { MemoryOutcomeEvent } from './outcome-events';
|
|
12
13
|
export { buildRecallPromptBlock } from './prompt-block';
|
|
13
14
|
export type { MemoryCompactOptions, MemoryCompactResult, MemoryProposalStore, MemoryProvider, MemoryRecallUsageEvent, MemoryRecallUsageFilter, } from './provider';
|
|
14
15
|
export { buildMemoryRecallPlan, type MemoryRecallPlan, type MemoryRecallPlannerInput, } from './recall-planner';
|
|
15
16
|
export { buildMemoryCohortFingerprintInput, computeMemoryCohortFingerprint, computeRedactionPolicyVersion, FINGERPRINT_ALGORITHM_VERSION, findSecrets, redactSecrets, } from './redaction';
|
|
17
|
+
export { readDeadAnchorMemoryIds, readReflectionDigest, recordOutcomeWithReflection, regenerateMemoryReflection, } from './reflection-service';
|
|
16
18
|
export { MEMORY_RECALL_PROFILES, type MemoryRecallProfile, normalizeMemoryAgentRole, resolveMemoryRecallProfile, } from './role-profiles';
|
|
17
19
|
export { appendMemoryRunLog, sanitizeRunId } from './run-log';
|
|
18
|
-
export { computeMemoryContentHash, createBundleId, createMemoryId, createProposalId, isExpired, normalizeMemoryText, validateCuratorMemoryDecision, validateMemoryProposal, validateMemoryRecordRules, } from './schema';
|
|
20
|
+
export { computeMemoryContentHash, createBundleId, createMemoryId, createProposalId, isExpired, MemoryAnchorSchema, normalizeMemoryAnchorFile, normalizeMemoryText, validateCuratorMemoryDecision, validateMemoryProposal, validateMemoryRecordRules, } from './schema';
|
|
19
21
|
export { SQLiteMemoryProvider } from './sqlite-provider';
|
|
20
22
|
export { isCohortRoot, isLocalRoot, resolveVettedMemoryRoot, rootStoragePath, type VettedMemoryRoot, wrapLocalRoot, } from './storage-root';
|
|
21
|
-
export type { AppliedMemoryChange, CuratorMemoryDecision, MemoryContext, MemoryKind, MemoryListFilter, MemoryPatch, MemoryProposal, MemoryRecord, MemoryScopeRef, MemoryScopeType, NewMemoryRecord, RecallBundle, RecallInjectionSkipReason, RecallMode, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision, } from './types';
|
|
23
|
+
export type { AppliedMemoryChange, CuratorMemoryDecision, MemoryAnchor, MemoryContext, MemoryKind, MemoryListFilter, MemoryOutcome, MemoryPatch, MemoryProposal, MemoryRecord, MemoryScopeRef, MemoryScopeType, NewMemoryRecord, RecallBundle, RecallInjectionSkipReason, RecallMode, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision, } from './types';
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { type MemoryConfig } from './config';
|
|
2
|
+
import { type MemoryOutcomeEvent } from './outcome-events';
|
|
2
3
|
import type { MemoryProposal, MemoryRecord } from './types';
|
|
3
4
|
export declare const LEGACY_JSONL_MIGRATION_VERSION = 2;
|
|
4
5
|
export declare const LEGACY_JSONL_MIGRATION_NAME = "legacy_jsonl_import_complete";
|
|
6
|
+
/**
|
|
7
|
+
* Separate additive marker for outcome events. Existing databases may already
|
|
8
|
+
* carry the immutable v2 schema_migrations row, so outcome import cannot reuse
|
|
9
|
+
* that row or invent a future migration version (the migration runner is
|
|
10
|
+
* MAX(version)-based).
|
|
11
|
+
*/
|
|
12
|
+
export declare const LEGACY_JSONL_OUTCOME_META_KEY = "legacy_jsonl_outcomes_import_complete";
|
|
5
13
|
export interface JsonlInvalidRow {
|
|
6
|
-
file: 'memories.jsonl' | 'proposals.jsonl';
|
|
14
|
+
file: 'memories.jsonl' | 'proposals.jsonl' | 'outcome-events.jsonl';
|
|
7
15
|
line: number;
|
|
8
16
|
error: string;
|
|
9
17
|
}
|
|
10
18
|
export interface JsonlImportPayload {
|
|
11
19
|
memories: MemoryRecord[];
|
|
20
|
+
memoryRows: Array<{
|
|
21
|
+
line: number;
|
|
22
|
+
record: MemoryRecord;
|
|
23
|
+
}>;
|
|
12
24
|
proposals: MemoryProposal[];
|
|
25
|
+
outcomeEvents: MemoryOutcomeEvent[];
|
|
26
|
+
outcomeEventRows: Array<{
|
|
27
|
+
line: number;
|
|
28
|
+
event: MemoryOutcomeEvent;
|
|
29
|
+
}>;
|
|
13
30
|
invalidRows: JsonlInvalidRow[];
|
|
14
31
|
totalRows: number;
|
|
15
32
|
}
|
|
@@ -25,6 +42,7 @@ export interface JsonlMigrationReport {
|
|
|
25
42
|
reason?: string;
|
|
26
43
|
importedMemories: number;
|
|
27
44
|
importedProposals: number;
|
|
45
|
+
importedOutcomes: number;
|
|
28
46
|
invalidRows: JsonlInvalidRow[];
|
|
29
47
|
backups: JsonlBackupResult[];
|
|
30
48
|
}
|
|
@@ -32,16 +50,23 @@ export declare function resolveMemoryStorageDir(rootDirectory: string, config?:
|
|
|
32
50
|
export declare function resolveSqliteDatabasePath(rootDirectory: string, config?: Partial<MemoryConfig>): string;
|
|
33
51
|
export declare function readLegacyJsonl(rootDirectory: string, config?: Partial<MemoryConfig>): Promise<JsonlImportPayload>;
|
|
34
52
|
export declare function backupLegacyJsonl(rootDirectory: string, config?: Partial<MemoryConfig>): Promise<JsonlBackupResult[]>;
|
|
35
|
-
export declare function writeJsonlExport(rootDirectory: string, config: Partial<MemoryConfig>, memories: MemoryRecord[], proposals: MemoryProposal[]): Promise<{
|
|
53
|
+
export declare function writeJsonlExport(rootDirectory: string, config: Partial<MemoryConfig>, memories: MemoryRecord[], proposals: MemoryProposal[], outcomeEvents?: MemoryOutcomeEvent[]): Promise<{
|
|
36
54
|
directory: string;
|
|
37
55
|
memoriesPath: string;
|
|
38
56
|
proposalsPath: string;
|
|
57
|
+
outcomesPath: string;
|
|
39
58
|
}>;
|
|
40
59
|
export declare function writeMigrationReport(rootDirectory: string, report: JsonlMigrationReport, config?: Partial<MemoryConfig>): Promise<string>;
|
|
41
60
|
export declare function readMigrationReport(rootDirectory: string, config?: Partial<MemoryConfig>): Promise<JsonlMigrationReport | null>;
|
|
42
61
|
export declare function getLegacyJsonlFileStatus(rootDirectory: string, config?: Partial<MemoryConfig>): Promise<Array<{
|
|
43
|
-
file: 'memories.jsonl' | 'proposals.jsonl';
|
|
62
|
+
file: 'memories.jsonl' | 'proposals.jsonl' | 'outcome-events.jsonl';
|
|
44
63
|
path: string;
|
|
45
64
|
exists: boolean;
|
|
46
65
|
sizeBytes: number;
|
|
47
66
|
}>>;
|
|
67
|
+
/**
|
|
68
|
+
* Cheap change token for the append-only outcome stream. Unlike the legacy v2
|
|
69
|
+
* one-shot marker, this advances when a user switches back to JSONL, records
|
|
70
|
+
* more outcomes, and later reopens SQLite.
|
|
71
|
+
*/
|
|
72
|
+
export declare function getLegacyOutcomeJsonlSignature(rootDirectory: string, config?: Partial<MemoryConfig>): Promise<string>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type MemoryConfig } from './config';
|
|
2
|
+
import { type MemoryOutcomeEvent } from './outcome-events';
|
|
2
3
|
import type { MemoryCompactOptions, MemoryCompactResult, MemoryProposalStore, MemoryProvider, MemoryRecallUsageEvent, MemoryRecallUsageFilter, MemoryRewardEvent, MemoryRewardEventFilter } from './provider';
|
|
3
4
|
import type { RecallScoringDiagnostics } from './scoring';
|
|
4
|
-
import type { AppliedMemoryChange, MemoryListFilter, MemoryProposal, MemoryRecord, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision } from './types';
|
|
5
|
+
import type { AppliedMemoryChange, MemoryAnchor, MemoryListFilter, MemoryOutcome, MemoryProposal, MemoryRecord, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision } from './types';
|
|
5
6
|
export declare class LocalJsonlMemoryProvider implements MemoryProvider, MemoryProposalStore {
|
|
6
7
|
readonly name = "local-jsonl";
|
|
7
8
|
private readonly rootDirectory;
|
|
@@ -25,6 +26,11 @@ export declare class LocalJsonlMemoryProvider implements MemoryProvider, MemoryP
|
|
|
25
26
|
initialize(): Promise<void>;
|
|
26
27
|
upsert(record: MemoryRecord): Promise<MemoryRecord>;
|
|
27
28
|
get(id: string): Promise<MemoryRecord | null>;
|
|
29
|
+
appendOutcome(memoryId: string, event: {
|
|
30
|
+
id: string;
|
|
31
|
+
outcome: MemoryOutcome;
|
|
32
|
+
}, anchors?: MemoryAnchor[]): Promise<MemoryRecord>;
|
|
33
|
+
listOutcomeEvents(): Promise<MemoryOutcomeEvent[]>;
|
|
28
34
|
delete(id: string, reason?: string): Promise<void>;
|
|
29
35
|
recall(request: RecallRequest): Promise<RecallResultItem[]>;
|
|
30
36
|
recallWithDiagnostics(request: RecallRequest): Promise<{
|
|
@@ -42,9 +48,18 @@ export declare class LocalJsonlMemoryProvider implements MemoryProvider, MemoryP
|
|
|
42
48
|
limit?: number;
|
|
43
49
|
}): Promise<MemoryProposal[]>;
|
|
44
50
|
applyCuratorDecision(decision: ResolvedCuratorMemoryDecision): Promise<AppliedMemoryChange>;
|
|
51
|
+
private applyCuratorDecisionUnlocked;
|
|
45
52
|
compact(): Promise<void>;
|
|
46
53
|
compactMaintenance(options?: MemoryCompactOptions): Promise<MemoryCompactResult>;
|
|
47
54
|
private audit;
|
|
55
|
+
private withOutcomeStoreLock;
|
|
56
|
+
private refreshMemoriesUnlocked;
|
|
57
|
+
private appendMemoryUnlocked;
|
|
58
|
+
private refreshProposalsUnlocked;
|
|
59
|
+
private readOutcomeEventsSync;
|
|
60
|
+
private appendOutcomeEventUnlocked;
|
|
61
|
+
private rewriteMemoryFamilyUnlocked;
|
|
62
|
+
private validateMaterializedRecordUnlocked;
|
|
48
63
|
/**
|
|
49
64
|
* #1850 (critic CONCERN-1): bump the cohort generation marker so sibling
|
|
50
65
|
* worktrees observe this write on their next revalidation. Called at the
|
|
@@ -41,6 +41,9 @@ export interface MemoryMaintenanceReport {
|
|
|
41
41
|
supersededMemories: MemoryRecord[];
|
|
42
42
|
supersededChains: MemorySupersededChain[];
|
|
43
43
|
lowUtilityMemories: MemoryRecord[];
|
|
44
|
+
/** Structurally stale memories whose anchors are all dead in the latest
|
|
45
|
+
* worktree-local reflection digest. Reporting never deletes them. */
|
|
46
|
+
deadAnchorMemories: MemoryRecord[];
|
|
44
47
|
/**
|
|
45
48
|
* Memories suppressed for low LEARNED utility (q-value < suppression
|
|
46
49
|
* threshold). Distinct from `lowUtilityMemories`, which is the orthogonal
|
|
@@ -71,6 +74,8 @@ export interface MemoryMaintenanceReportOptions {
|
|
|
71
74
|
importanceThreshold?: number;
|
|
72
75
|
/** Learned-utility (q-value) thresholds for the low-Q / promotion surfaces. Defaults to DEFAULT_QLEARNING_CONFIG. */
|
|
73
76
|
qLearning?: QLearningConfig;
|
|
77
|
+
/** Worktree-local stale ids read from `.swarm/reflections/lessons.json`. */
|
|
78
|
+
deadAnchorMemoryIds?: ReadonlySet<string>;
|
|
74
79
|
}
|
|
75
80
|
type ObservableProvider = MemoryProvider & Partial<MemoryProposalStore> & {
|
|
76
81
|
listRecallUsage?: MemoryProvider['listRecallUsage'];
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* No writes happen here on the plugin-init path (invariant 1). Called only
|
|
26
26
|
* from the `/swarm memory link` / `/swarm memory unlink` command handlers.
|
|
27
27
|
*/
|
|
28
|
+
import { type MemoryOutcomeEvent } from './outcome-events.js';
|
|
28
29
|
import type { VettedMemoryRoot } from './storage-root.js';
|
|
29
30
|
export interface MemoryFamilyMigrationCounts {
|
|
30
31
|
readonly perMember: ReadonlyArray<{
|
|
@@ -39,6 +40,16 @@ declare function appendUnionById<T>(destination: T[], source: T[]): {
|
|
|
39
40
|
added: number;
|
|
40
41
|
skipped: number;
|
|
41
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Outcome event ids are retry identities, not generic append-only row ids.
|
|
45
|
+
* Apply the provider's shared semantic collision rules while retaining the
|
|
46
|
+
* destination's first committed representation (including its timestamp).
|
|
47
|
+
*/
|
|
48
|
+
declare function appendUnionOutcomeEvents(destination: unknown[], source: unknown[]): {
|
|
49
|
+
merged: MemoryOutcomeEvent[];
|
|
50
|
+
added: number;
|
|
51
|
+
skipped: number;
|
|
52
|
+
};
|
|
42
53
|
/** Serialize a merged JSONL member. */
|
|
43
54
|
declare function serializeJsonl(values: unknown[]): string;
|
|
44
55
|
/** Validate a serialized JSONL member: every line must parse and carry an id. */
|
|
@@ -85,6 +96,7 @@ declare function countRowsSafe(dbPath: string): Promise<number>;
|
|
|
85
96
|
export declare function migrateMemoryFamily(destRoot: VettedMemoryRoot, sourceRoot: VettedMemoryRoot): Promise<MemoryFamilyMigrationCounts>;
|
|
86
97
|
export declare const _internals: {
|
|
87
98
|
appendUnionById: typeof appendUnionById;
|
|
99
|
+
appendUnionOutcomeEvents: typeof appendUnionOutcomeEvents;
|
|
88
100
|
serializeJsonl: typeof serializeJsonl;
|
|
89
101
|
validateSerializedJsonl: typeof validateSerializedJsonl;
|
|
90
102
|
stageSqliteDb: typeof stageSqliteDb;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MemoryAnchor, MemoryOutcome, MemoryRecord } from './types';
|
|
2
|
+
export interface MemoryOutcomeEvent {
|
|
3
|
+
id: string;
|
|
4
|
+
memoryId: string;
|
|
5
|
+
generation: string;
|
|
6
|
+
outcome: MemoryOutcome;
|
|
7
|
+
anchors: MemoryAnchor[];
|
|
8
|
+
}
|
|
9
|
+
export declare function newOutcomeGeneration(): string;
|
|
10
|
+
export declare function ensureOutcomeGeneration(record: MemoryRecord): MemoryRecord;
|
|
11
|
+
export declare function outcomeGeneration(record: MemoryRecord): string;
|
|
12
|
+
export declare function stripMaterializedOutcomes(record: MemoryRecord): MemoryRecord;
|
|
13
|
+
export declare function materializeOutcomeRecord(base: MemoryRecord, events: readonly MemoryOutcomeEvent[]): MemoryRecord;
|
|
14
|
+
export declare function importMaterializedOutcomeEvents(record: MemoryRecord, existing: readonly MemoryOutcomeEvent[]): MemoryOutcomeEvent[];
|
|
15
|
+
export declare function validateOutcomeEvent(value: unknown): MemoryOutcomeEvent;
|
|
16
|
+
/**
|
|
17
|
+
* Apply record-sensitive policy before an outcome event reaches either
|
|
18
|
+
* provider's canonical store. Shape validation alone cannot determine whether
|
|
19
|
+
* correction text belongs to a durable record.
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateOutcomeEventForMemory(value: unknown, memory: MemoryRecord, rejectDurableSecrets: boolean): MemoryOutcomeEvent;
|
|
22
|
+
export declare function assertEventIdentityCompatible(existing: MemoryOutcomeEvent | undefined, next: MemoryOutcomeEvent): void;
|
|
23
|
+
export declare function canonicalOutcomePayload(outcome: MemoryOutcome, anchors: readonly MemoryAnchor[]): string;
|
|
24
|
+
export declare function dedupeAnchors(anchors: readonly MemoryAnchor[]): MemoryAnchor[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { MemoryOutcomeEvent } from './outcome-events';
|
|
1
2
|
import type { RecallScoringDiagnostics } from './scoring';
|
|
2
|
-
import type { AppliedMemoryChange, MemoryListFilter, MemoryProposal, MemoryRecord, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision } from './types';
|
|
3
|
+
import type { AppliedMemoryChange, MemoryAnchor, MemoryListFilter, MemoryOutcome, MemoryProposal, MemoryRecord, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision } from './types';
|
|
3
4
|
export interface MemoryRecallResult {
|
|
4
5
|
items: RecallResultItem[];
|
|
5
6
|
diagnostics?: RecallScoringDiagnostics;
|
|
@@ -73,6 +74,11 @@ export interface MemoryProvider {
|
|
|
73
74
|
initialize?(): Promise<void>;
|
|
74
75
|
close?(): Promise<void> | void;
|
|
75
76
|
upsert(record: MemoryRecord): Promise<MemoryRecord>;
|
|
77
|
+
appendOutcome?(memoryId: string, event: {
|
|
78
|
+
id: string;
|
|
79
|
+
outcome: MemoryOutcome;
|
|
80
|
+
}, anchors?: MemoryAnchor[]): Promise<MemoryRecord>;
|
|
81
|
+
listOutcomeEvents?(): Promise<MemoryOutcomeEvent[]>;
|
|
76
82
|
get(id: string): Promise<MemoryRecord | null>;
|
|
77
83
|
delete(id: string, reason?: string): Promise<void>;
|
|
78
84
|
recall(request: RecallRequest): Promise<RecallResultItem[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildReflectionInjection(directory: string, estimateTokens: (text: string) => number): string | null;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type MemoryConfig } from './config';
|
|
2
|
+
import { type MemoryGateway, type RecordMemoryOutcomeInput } from './gateway';
|
|
3
|
+
import { type ReflectionDigest } from './reflection';
|
|
4
|
+
import type { MemoryOutcome, MemoryRecord } from './types';
|
|
5
|
+
interface OutcomeWriteThroughBase {
|
|
6
|
+
record: MemoryRecord;
|
|
7
|
+
eventId: string;
|
|
8
|
+
outcomeRecorded: true;
|
|
9
|
+
reflectionEnabled: boolean;
|
|
10
|
+
reflectionAttempted: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type OutcomeWriteThroughResult = (OutcomeWriteThroughBase & {
|
|
13
|
+
reflectionEnabled: false;
|
|
14
|
+
reflectionAttempted: false;
|
|
15
|
+
reflectionUpdated: false;
|
|
16
|
+
}) | (OutcomeWriteThroughBase & {
|
|
17
|
+
reflectionEnabled: true;
|
|
18
|
+
reflectionAttempted: true;
|
|
19
|
+
reflectionUpdated: true;
|
|
20
|
+
digest: ReflectionDigest;
|
|
21
|
+
}) | (OutcomeWriteThroughBase & {
|
|
22
|
+
reflectionEnabled: true;
|
|
23
|
+
reflectionAttempted: true;
|
|
24
|
+
reflectionUpdated: false;
|
|
25
|
+
error: string;
|
|
26
|
+
});
|
|
27
|
+
export declare function recordOutcomeWithReflection(directory: string, config: Partial<MemoryConfig>, gateway: MemoryGateway, input: RecordMemoryOutcomeInput): Promise<OutcomeWriteThroughResult>;
|
|
28
|
+
export declare function regenerateMemoryReflection(directory: string, config: Partial<MemoryConfig>): Promise<ReflectionDigest>;
|
|
29
|
+
export declare function readReflectionDigest(directory: string): ReflectionDigest | null;
|
|
30
|
+
export declare function readDeadAnchorMemoryIds(directory: string): ReadonlySet<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Providers have historically returned bounded results in different orders.
|
|
33
|
+
* Re-sort centrally with an id tie-break, and reserve one slot for a
|
|
34
|
+
* just-committed target that is older than the normal window.
|
|
35
|
+
*/
|
|
36
|
+
declare function selectReflectionEntries(storedEntries: readonly MemoryRecord[], writeThroughRecord?: MemoryRecord, asOf?: Date, allowInactiveWriteThrough?: boolean): MemoryRecord[];
|
|
37
|
+
declare function prepareWriteThroughEntry(writeThrough: {
|
|
38
|
+
record: MemoryRecord;
|
|
39
|
+
eventId: string;
|
|
40
|
+
outcome: MemoryOutcome['outcome'];
|
|
41
|
+
}, asOf: Date): {
|
|
42
|
+
record: MemoryRecord;
|
|
43
|
+
allowInactive: boolean;
|
|
44
|
+
} | undefined;
|
|
45
|
+
declare function isReflectionEligible(record: MemoryRecord, asOf: Date): boolean;
|
|
46
|
+
declare function sanitizeReflectionRecord(record: MemoryRecord): MemoryRecord;
|
|
47
|
+
export declare const _test_exports: {
|
|
48
|
+
selectReflectionEntries: typeof selectReflectionEntries;
|
|
49
|
+
isReflectionEligible: typeof isReflectionEligible;
|
|
50
|
+
prepareWriteThroughEntry: typeof prepareWriteThroughEntry;
|
|
51
|
+
sanitizeReflectionRecord: typeof sanitizeReflectionRecord;
|
|
52
|
+
};
|
|
53
|
+
export declare const _internals: {
|
|
54
|
+
withReflectionLock: typeof withReflectionLock;
|
|
55
|
+
serializeDigestArtifacts: typeof serializeDigestArtifacts;
|
|
56
|
+
boundDigest: typeof boundDigest;
|
|
57
|
+
};
|
|
58
|
+
declare function withReflectionLock<T>(directory: string, fn: () => Promise<T>): Promise<T>;
|
|
59
|
+
interface ReflectionArtifactPair {
|
|
60
|
+
markdown: string;
|
|
61
|
+
json: string;
|
|
62
|
+
}
|
|
63
|
+
declare function serializeDigestArtifacts(digest: ReflectionDigest): ReflectionArtifactPair;
|
|
64
|
+
declare function boundDigest(digest: ReflectionDigest): {
|
|
65
|
+
digest: ReflectionDigest;
|
|
66
|
+
artifacts: ReflectionArtifactPair;
|
|
67
|
+
};
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { MemoryAnchor, MemoryOutcome, MemoryRecord } from './types';
|
|
2
|
+
export interface ReflectionAnchorStatus {
|
|
3
|
+
alive: boolean;
|
|
4
|
+
packageBoundary?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ReflectionDigestItem {
|
|
7
|
+
memoryId: string;
|
|
8
|
+
text: string;
|
|
9
|
+
anchor?: MemoryAnchor;
|
|
10
|
+
group?: string;
|
|
11
|
+
score: number;
|
|
12
|
+
positiveOutcomes: number;
|
|
13
|
+
negativeOutcomes: number;
|
|
14
|
+
latestAt: string;
|
|
15
|
+
resolution?: MemoryOutcome['outcome'];
|
|
16
|
+
}
|
|
17
|
+
export interface ReflectionCorrection {
|
|
18
|
+
memoryId: string;
|
|
19
|
+
correction: string;
|
|
20
|
+
at: string;
|
|
21
|
+
anchor?: MemoryAnchor;
|
|
22
|
+
group?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ReflectionDigest {
|
|
25
|
+
preferred: ReflectionDigestItem[];
|
|
26
|
+
tentative: ReflectionDigestItem[];
|
|
27
|
+
contested: ReflectionDigestItem[];
|
|
28
|
+
deadEnds: ReflectionDigestItem[];
|
|
29
|
+
corrections: ReflectionCorrection[];
|
|
30
|
+
deadAnchorMemoryIds: string[];
|
|
31
|
+
generatedFrom: {
|
|
32
|
+
entries: number;
|
|
33
|
+
asOf: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface BuildReflectionOptions {
|
|
37
|
+
halfLifeDays?: number;
|
|
38
|
+
resolveAnchor?: (anchor: MemoryAnchor) => ReflectionAnchorStatus;
|
|
39
|
+
}
|
|
40
|
+
export declare function buildReflectionDigest(entries: readonly MemoryRecord[], now: Date, opts?: BuildReflectionOptions): ReflectionDigest;
|
|
41
|
+
export declare function renderReflectionMarkdown(digest: ReflectionDigest): string;
|
package/dist/memory/schema.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { CuratorMemoryDecision, MemoryKind, MemoryPatch, MemoryProposal, MemoryRecord, MemoryScopeRef, NewMemoryRecord } from './types';
|
|
2
|
+
import type { CuratorMemoryDecision, MemoryAnchor, MemoryKind, MemoryOutcome, MemoryPatch, MemoryProposal, MemoryRecord, MemoryScopeRef, NewMemoryRecord } from './types';
|
|
3
|
+
export declare const MAX_MEMORY_TEXT_LENGTH = 2000;
|
|
4
|
+
export declare const MAX_MEMORY_ANCHORS = 20;
|
|
5
|
+
export declare const MEMORY_OUTCOME_QUESTION_PREFIX = "Outcome evidence for question: ";
|
|
6
|
+
export declare const MAX_OUTCOME_QUESTION_LENGTH: number;
|
|
3
7
|
export declare const MemoryScopeTypeSchema: z.ZodEnum<{
|
|
4
8
|
agent: "agent";
|
|
5
9
|
project: "project";
|
|
@@ -60,6 +64,10 @@ export declare const MemorySourceSchema: z.ZodObject<{
|
|
|
60
64
|
commitSha: z.ZodOptional<z.ZodString>;
|
|
61
65
|
createdBy: z.ZodOptional<z.ZodString>;
|
|
62
66
|
}, z.core.$strict>;
|
|
67
|
+
export declare const MemoryAnchorSchema: z.ZodType<MemoryAnchor>;
|
|
68
|
+
/** Normalize a repository-relative memory anchor to a portable identity. */
|
|
69
|
+
export declare function normalizeMemoryAnchorFile(value: string): string;
|
|
70
|
+
export declare const MemoryOutcomeSchema: z.ZodType<MemoryOutcome>;
|
|
63
71
|
export declare const MemoryRecordSchema: z.ZodObject<{
|
|
64
72
|
id: z.ZodString;
|
|
65
73
|
scope: z.ZodObject<{
|
|
@@ -130,6 +138,8 @@ export declare const MemoryRecordSchema: z.ZodObject<{
|
|
|
130
138
|
supersededBy: z.ZodOptional<z.ZodString>;
|
|
131
139
|
contentHash: z.ZodString;
|
|
132
140
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
141
|
+
anchors: z.ZodOptional<z.ZodArray<z.ZodType<MemoryAnchor, unknown, z.core.$ZodTypeInternals<MemoryAnchor, unknown>>>>;
|
|
142
|
+
outcomes: z.ZodOptional<z.ZodArray<z.ZodType<MemoryOutcome, unknown, z.core.$ZodTypeInternals<MemoryOutcome, unknown>>>>;
|
|
133
143
|
cohortId: z.ZodOptional<z.ZodString>;
|
|
134
144
|
producerSessionId: z.ZodOptional<z.ZodString>;
|
|
135
145
|
producerAgentRole: z.ZodOptional<z.ZodString>;
|
|
@@ -218,6 +228,8 @@ export declare const MemoryProposalSchema: z.ZodObject<{
|
|
|
218
228
|
supersededBy: z.ZodOptional<z.ZodString>;
|
|
219
229
|
contentHash: z.ZodString;
|
|
220
230
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
231
|
+
anchors: z.ZodOptional<z.ZodArray<z.ZodType<MemoryAnchor, unknown, z.core.$ZodTypeInternals<MemoryAnchor, unknown>>>>;
|
|
232
|
+
outcomes: z.ZodOptional<z.ZodArray<z.ZodType<MemoryOutcome, unknown, z.core.$ZodTypeInternals<MemoryOutcome, unknown>>>>;
|
|
221
233
|
cohortId: z.ZodOptional<z.ZodString>;
|
|
222
234
|
producerSessionId: z.ZodOptional<z.ZodString>;
|
|
223
235
|
producerAgentRole: z.ZodOptional<z.ZodString>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type MemoryConfig } from './config';
|
|
2
2
|
import { type JsonlMigrationReport } from './jsonl-migration';
|
|
3
|
+
import { type MemoryOutcomeEvent } from './outcome-events';
|
|
3
4
|
import type { MemoryCompactOptions, MemoryCompactResult, MemoryProposalStore, MemoryProvider, MemoryRecallUsageEvent, MemoryRecallUsageFilter, MemoryRewardEvent, MemoryRewardEventFilter, MemoryTransaction } from './provider';
|
|
4
5
|
import type { RecallScoringDiagnostics } from './scoring';
|
|
5
|
-
import type { AppliedMemoryChange, MemoryListFilter, MemoryProposal, MemoryRecord, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision } from './types';
|
|
6
|
+
import type { AppliedMemoryChange, MemoryAnchor, MemoryListFilter, MemoryOutcome, MemoryProposal, MemoryRecord, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision } from './types';
|
|
6
7
|
interface Migration {
|
|
7
8
|
version: number;
|
|
8
9
|
name: string;
|
|
@@ -12,6 +13,7 @@ export declare const MIGRATIONS: Migration[];
|
|
|
12
13
|
export interface SQLiteJsonlImportResult {
|
|
13
14
|
importedMemories: number;
|
|
14
15
|
importedProposals: number;
|
|
16
|
+
importedOutcomes: number;
|
|
15
17
|
invalidRows: JsonlMigrationReport['invalidRows'];
|
|
16
18
|
totalRows: number;
|
|
17
19
|
}
|
|
@@ -63,6 +65,11 @@ export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryPropo
|
|
|
63
65
|
private doInitialize;
|
|
64
66
|
upsert(record: MemoryRecord): Promise<MemoryRecord>;
|
|
65
67
|
get(id: string): Promise<MemoryRecord | null>;
|
|
68
|
+
appendOutcome(memoryId: string, event: {
|
|
69
|
+
id: string;
|
|
70
|
+
outcome: MemoryOutcome;
|
|
71
|
+
}, anchors?: MemoryAnchor[]): Promise<MemoryRecord>;
|
|
72
|
+
listOutcomeEvents(): Promise<MemoryOutcomeEvent[]>;
|
|
66
73
|
withTransaction<T>(fn: (tx: MemoryTransaction) => Promise<T> | T): Promise<T>;
|
|
67
74
|
delete(id: string, reason?: string): Promise<void>;
|
|
68
75
|
recall(request: RecallRequest): Promise<RecallResultItem[]>;
|
|
@@ -114,8 +121,10 @@ export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryPropo
|
|
|
114
121
|
directory: string;
|
|
115
122
|
memoriesPath: string;
|
|
116
123
|
proposalsPath: string;
|
|
124
|
+
outcomesPath: string;
|
|
117
125
|
memories: number;
|
|
118
126
|
proposals: number;
|
|
127
|
+
outcomes: number;
|
|
119
128
|
}>;
|
|
120
129
|
compactMaintenance(options?: MemoryCompactOptions): Promise<MemoryCompactResult>;
|
|
121
130
|
hasMigration(name: string): boolean;
|
|
@@ -136,6 +145,10 @@ export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryPropo
|
|
|
136
145
|
private loadMemories;
|
|
137
146
|
private loadProposals;
|
|
138
147
|
private writeMemory;
|
|
148
|
+
private readMemoryById;
|
|
149
|
+
private readOutcomeEvents;
|
|
150
|
+
private readOutcomeEventsForMemoryIds;
|
|
151
|
+
private insertOutcomeEvent;
|
|
139
152
|
/**
|
|
140
153
|
* #1850: write a monotonic generation marker so siblings re-open their
|
|
141
154
|
* in-memory mirror. Fire-and-forget; failures are non-fatal (peers simply
|
|
@@ -166,6 +179,10 @@ export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryPropo
|
|
|
166
179
|
private validateDecisionMemory;
|
|
167
180
|
private migrateLegacyJsonlIfNeeded;
|
|
168
181
|
private importLegacyJsonlRows;
|
|
182
|
+
private importLegacyMaterializedOutcomeRow;
|
|
183
|
+
private importLegacyOutcomeRows;
|
|
184
|
+
private importLegacyOutcomeEventRows;
|
|
185
|
+
private hasOutcomeEvent;
|
|
169
186
|
private event;
|
|
170
187
|
private insertEvent;
|
|
171
188
|
private requireDb;
|
package/dist/memory/types.d.ts
CHANGED
|
@@ -22,6 +22,18 @@ export interface MemorySource {
|
|
|
22
22
|
commitSha?: string;
|
|
23
23
|
createdBy?: string;
|
|
24
24
|
}
|
|
25
|
+
/** Repository-relative structural location associated with a memory result. */
|
|
26
|
+
export interface MemoryAnchor {
|
|
27
|
+
file: string;
|
|
28
|
+
symbol?: string;
|
|
29
|
+
}
|
|
30
|
+
/** A task-observed result for a recalled memory or graph answer. */
|
|
31
|
+
export interface MemoryOutcome {
|
|
32
|
+
outcome: 'useful' | 'dead_end' | 'corrected';
|
|
33
|
+
at: string;
|
|
34
|
+
taskId?: string;
|
|
35
|
+
correction?: string;
|
|
36
|
+
}
|
|
25
37
|
export interface MemoryRecord {
|
|
26
38
|
id: string;
|
|
27
39
|
scope: MemoryScopeRef;
|
|
@@ -39,6 +51,10 @@ export interface MemoryRecord {
|
|
|
39
51
|
supersededBy?: string;
|
|
40
52
|
contentHash: string;
|
|
41
53
|
metadata: Record<string, unknown>;
|
|
54
|
+
/** Optional code-structure anchors; additive for pre-#1989 stores. */
|
|
55
|
+
anchors?: MemoryAnchor[];
|
|
56
|
+
/** Append-only materialized outcome view; provider events remain canonical. */
|
|
57
|
+
outcomes?: MemoryOutcome[];
|
|
42
58
|
/** Canonical cohort id the record belongs to. Matches `scope.cohortId`
|
|
43
59
|
* when `scope.type === 'cohort'`. */
|
|
44
60
|
cohortId?: string;
|
|
@@ -85,8 +101,10 @@ export interface NewMemoryRecord {
|
|
|
85
101
|
source?: MemorySource;
|
|
86
102
|
expiresAt?: string;
|
|
87
103
|
metadata?: Record<string, unknown>;
|
|
104
|
+
anchors?: MemoryAnchor[];
|
|
105
|
+
outcomes?: MemoryOutcome[];
|
|
88
106
|
}
|
|
89
|
-
export type MemoryPatch = Partial<Pick<NewMemoryRecord, 'scope' | 'kind' | 'text' | 'tags' | 'confidence' | 'stability' | 'source' | 'expiresAt' | 'metadata'>>;
|
|
107
|
+
export type MemoryPatch = Partial<Pick<NewMemoryRecord, 'scope' | 'kind' | 'text' | 'tags' | 'confidence' | 'stability' | 'source' | 'expiresAt' | 'metadata' | 'anchors' | 'outcomes'>>;
|
|
90
108
|
export type CuratorMemoryDecision = {
|
|
91
109
|
action: 'add';
|
|
92
110
|
proposalId: string;
|