@xdarkicex/openclaw-memory-libravdb 1.4.3 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -16
- package/docs/README.md +3 -12
- package/docs/architecture.md +68 -153
- package/docs/contributing.md +1 -2
- package/openclaw.plugin.json +64 -1
- package/package.json +2 -2
- package/src/cli.ts +34 -0
- package/src/comparison-experiments.ts +128 -0
- package/src/context-engine.ts +286 -72
- package/src/dream-promotion.ts +492 -0
- package/src/dream-routing.ts +40 -0
- package/src/index.ts +16 -1
- package/src/markdown-hash.ts +104 -0
- package/src/markdown-ingest.ts +627 -0
- package/src/memory-runtime.ts +32 -9
- package/src/scoring.ts +6 -3
- package/src/temporal.ts +657 -80
- package/src/types.ts +48 -0
- package/docs/ast-v2.md +0 -167
- package/docs/ast.md +0 -70
- package/docs/compaction-evaluation.md +0 -182
- package/docs/continuity.md +0 -708
- package/docs/elevated-guidance.md +0 -258
- package/docs/gating.md +0 -134
- package/docs/implementation.md +0 -447
- package/docs/mathematics-v2.md +0 -1879
- package/docs/mathematics.md +0 -695
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export const COMPARISON_ABLATION_MODES = [
|
|
2
|
+
"reserve_bump",
|
|
3
|
+
"protected_pair_pack",
|
|
4
|
+
"discriminative_affiliation",
|
|
5
|
+
"witness_position_pastness",
|
|
6
|
+
"contamination_penalty",
|
|
7
|
+
"pair_score_on_witness",
|
|
8
|
+
"comparison_blend",
|
|
9
|
+
] as const;
|
|
10
|
+
|
|
11
|
+
export type ComparisonAblationMode = typeof COMPARISON_ABLATION_MODES[number];
|
|
12
|
+
|
|
13
|
+
export interface ComparisonProfileSummary {
|
|
14
|
+
ablationMode?: ComparisonAblationMode;
|
|
15
|
+
rankTotalMs: number;
|
|
16
|
+
decorateMs: number;
|
|
17
|
+
slotCoverageMs: number;
|
|
18
|
+
sideAffiliationMs: number;
|
|
19
|
+
specificityMs: number;
|
|
20
|
+
pairSelectionMs: number;
|
|
21
|
+
greedyFillMs: number;
|
|
22
|
+
recoveryPackingMs: number;
|
|
23
|
+
debugBuildMs: number;
|
|
24
|
+
rawCandidateCount: number;
|
|
25
|
+
comparisonCandidateCount: number;
|
|
26
|
+
side0AffiliatedCount: number;
|
|
27
|
+
side1AffiliatedCount: number;
|
|
28
|
+
normalizeTermsCalls: number;
|
|
29
|
+
normalizeContentTermsCalls: number;
|
|
30
|
+
estimateTokensCalls: number;
|
|
31
|
+
sortCalls: number;
|
|
32
|
+
totalSortedLength: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ComparisonExperimentConfig {
|
|
36
|
+
profilingEnabled: boolean;
|
|
37
|
+
ablationMode: ComparisonAblationMode | null;
|
|
38
|
+
disableReserveBump: boolean;
|
|
39
|
+
disableProtectedPairPack: boolean;
|
|
40
|
+
disableDiscriminativeAffiliation: boolean;
|
|
41
|
+
disableWitnessPositionPastness: boolean;
|
|
42
|
+
disableContaminationPenalty: boolean;
|
|
43
|
+
disablePairScoreOnWitness: boolean;
|
|
44
|
+
disableComparisonBlend: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function resolveComparisonExperimentConfig(
|
|
48
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
49
|
+
): ComparisonExperimentConfig {
|
|
50
|
+
const profilingEnabled = env.LONGMEMEVAL_PROFILE_COMPARISON === "1";
|
|
51
|
+
const rawMode = env.LONGMEMEVAL_COMPARISON_PROFILE_MODE?.trim() ?? "";
|
|
52
|
+
const ablationMode = COMPARISON_ABLATION_MODES.includes(rawMode as ComparisonAblationMode)
|
|
53
|
+
? rawMode as ComparisonAblationMode
|
|
54
|
+
: null;
|
|
55
|
+
return {
|
|
56
|
+
profilingEnabled,
|
|
57
|
+
ablationMode,
|
|
58
|
+
disableReserveBump: ablationMode === "reserve_bump",
|
|
59
|
+
disableProtectedPairPack: ablationMode === "protected_pair_pack",
|
|
60
|
+
disableDiscriminativeAffiliation: ablationMode === "discriminative_affiliation",
|
|
61
|
+
disableWitnessPositionPastness: ablationMode === "witness_position_pastness",
|
|
62
|
+
disableContaminationPenalty: ablationMode === "contamination_penalty",
|
|
63
|
+
disablePairScoreOnWitness: ablationMode === "pair_score_on_witness",
|
|
64
|
+
disableComparisonBlend: ablationMode === "comparison_blend",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function createComparisonProfileSummary(
|
|
69
|
+
ablationMode: ComparisonAblationMode | null,
|
|
70
|
+
): ComparisonProfileSummary {
|
|
71
|
+
return {
|
|
72
|
+
ablationMode: ablationMode ?? undefined,
|
|
73
|
+
rankTotalMs: 0,
|
|
74
|
+
decorateMs: 0,
|
|
75
|
+
slotCoverageMs: 0,
|
|
76
|
+
sideAffiliationMs: 0,
|
|
77
|
+
specificityMs: 0,
|
|
78
|
+
pairSelectionMs: 0,
|
|
79
|
+
greedyFillMs: 0,
|
|
80
|
+
recoveryPackingMs: 0,
|
|
81
|
+
debugBuildMs: 0,
|
|
82
|
+
rawCandidateCount: 0,
|
|
83
|
+
comparisonCandidateCount: 0,
|
|
84
|
+
side0AffiliatedCount: 0,
|
|
85
|
+
side1AffiliatedCount: 0,
|
|
86
|
+
normalizeTermsCalls: 0,
|
|
87
|
+
normalizeContentTermsCalls: 0,
|
|
88
|
+
estimateTokensCalls: 0,
|
|
89
|
+
sortCalls: 0,
|
|
90
|
+
totalSortedLength: 0,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function mergeComparisonProfileSummaries(
|
|
95
|
+
profiles: ComparisonProfileSummary[],
|
|
96
|
+
): ComparisonProfileSummary | null {
|
|
97
|
+
if (profiles.length === 0) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const merged = createComparisonProfileSummary(
|
|
102
|
+
profiles.every((profile) => profile.ablationMode === profiles[0]!.ablationMode)
|
|
103
|
+
? (profiles[0]!.ablationMode ?? null)
|
|
104
|
+
: null,
|
|
105
|
+
);
|
|
106
|
+
for (const profile of profiles) {
|
|
107
|
+
merged.rankTotalMs += profile.rankTotalMs;
|
|
108
|
+
merged.decorateMs += profile.decorateMs;
|
|
109
|
+
merged.slotCoverageMs += profile.slotCoverageMs;
|
|
110
|
+
merged.sideAffiliationMs += profile.sideAffiliationMs;
|
|
111
|
+
merged.specificityMs += profile.specificityMs;
|
|
112
|
+
merged.pairSelectionMs += profile.pairSelectionMs;
|
|
113
|
+
merged.greedyFillMs += profile.greedyFillMs;
|
|
114
|
+
merged.recoveryPackingMs += profile.recoveryPackingMs;
|
|
115
|
+
merged.debugBuildMs += profile.debugBuildMs;
|
|
116
|
+
merged.rawCandidateCount += profile.rawCandidateCount;
|
|
117
|
+
merged.comparisonCandidateCount += profile.comparisonCandidateCount;
|
|
118
|
+
merged.side0AffiliatedCount += profile.side0AffiliatedCount;
|
|
119
|
+
merged.side1AffiliatedCount += profile.side1AffiliatedCount;
|
|
120
|
+
merged.normalizeTermsCalls += profile.normalizeTermsCalls;
|
|
121
|
+
merged.normalizeContentTermsCalls += profile.normalizeContentTermsCalls;
|
|
122
|
+
merged.estimateTokensCalls += profile.estimateTokensCalls;
|
|
123
|
+
merged.sortCalls += profile.sortCalls;
|
|
124
|
+
merged.totalSortedLength += profile.totalSortedLength;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return merged;
|
|
128
|
+
}
|