@remnic/core 9.3.581 → 9.3.583
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-http.js +2 -2
- package/dist/access-mcp.js +1 -1
- package/dist/{chunk-HLAVGJ62.js → chunk-35NN3ZFA.js} +25 -3
- package/dist/chunk-35NN3ZFA.js.map +1 -0
- package/dist/{chunk-YR7XMOWK.js → chunk-6GMPIJAZ.js} +2 -2
- package/dist/{chunk-WP5OWVLZ.js → chunk-LAL7WBLY.js} +5 -5
- package/dist/{chunk-QNXFFUWA.js → chunk-QRWZOCJN.js} +7 -7
- package/dist/{chunk-XSQ4SGM5.js → chunk-R3PQUPQ4.js} +2 -2
- package/dist/{chunk-5WB4C7KM.js → chunk-ZY6UPHNY.js} +6 -6
- package/dist/cli.js +3 -3
- package/dist/contradiction/index.js +3 -3
- package/dist/{contradiction-review-6V2LXXK6.js → contradiction-review-QKJH5DKD.js} +2 -2
- package/dist/{contradiction-scan-GIRVC4C7.js → contradiction-scan-GD7KUFWS.js} +3 -3
- package/dist/index.js +6 -6
- package/dist/{resolution-ZY7VM6WS.js → resolution-3SAP4SH2.js} +3 -3
- package/dist/schemas.d.ts +22 -22
- package/dist/transfer/types.d.ts +12 -12
- package/package.json +1 -1
- package/src/contradiction/contradiction-review.ts +33 -2
- package/src/contradiction/contradiction.test.ts +28 -3
- package/dist/chunk-HLAVGJ62.js.map +0 -1
- /package/dist/{chunk-YR7XMOWK.js.map → chunk-6GMPIJAZ.js.map} +0 -0
- /package/dist/{chunk-WP5OWVLZ.js.map → chunk-LAL7WBLY.js.map} +0 -0
- /package/dist/{chunk-QNXFFUWA.js.map → chunk-QRWZOCJN.js.map} +0 -0
- /package/dist/{chunk-XSQ4SGM5.js.map → chunk-R3PQUPQ4.js.map} +0 -0
- /package/dist/{chunk-5WB4C7KM.js.map → chunk-ZY6UPHNY.js.map} +0 -0
- /package/dist/{contradiction-review-6V2LXXK6.js.map → contradiction-review-QKJH5DKD.js.map} +0 -0
- /package/dist/{contradiction-scan-GIRVC4C7.js.map → contradiction-scan-GD7KUFWS.js.map} +0 -0
- /package/dist/{resolution-ZY7VM6WS.js.map → resolution-3SAP4SH2.js.map} +0 -0
package/dist/access-http.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EngramAccessHttpServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZY6UPHNY.js";
|
|
4
4
|
import "./chunk-SEDEKFYQ.js";
|
|
5
5
|
import "./chunk-AU7Q3LSC.js";
|
|
6
6
|
import "./chunk-42NQ7AVG.js";
|
|
@@ -8,7 +8,7 @@ import "./chunk-TMSXWOBZ.js";
|
|
|
8
8
|
import "./chunk-J64TK33U.js";
|
|
9
9
|
import "./chunk-RSUYKGGZ.js";
|
|
10
10
|
import "./chunk-7RXCMVFQ.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-LAL7WBLY.js";
|
|
12
12
|
import "./chunk-EAZGEEG2.js";
|
|
13
13
|
import "./chunk-D24OXEPB.js";
|
|
14
14
|
import "./chunk-VFB2G5YL.js";
|
package/dist/access-mcp.js
CHANGED
|
@@ -62,6 +62,22 @@ function isDeferralActive(pair) {
|
|
|
62
62
|
const deferredUntil = deferralUntilMillis(pair);
|
|
63
63
|
return deferredUntil !== null && Date.now() < deferredUntil;
|
|
64
64
|
}
|
|
65
|
+
function isReviewActionable(pair) {
|
|
66
|
+
return !isTerminalResolution(pair.resolution) && !isDeferralActive(pair) && pair.resolution !== "both-valid" && pair.verdict !== "independent";
|
|
67
|
+
}
|
|
68
|
+
function compareReviewPairs(a, b) {
|
|
69
|
+
const aActionable = isReviewActionable(a);
|
|
70
|
+
const bActionable = isReviewActionable(b);
|
|
71
|
+
if (aActionable !== bActionable) return aActionable ? -1 : 1;
|
|
72
|
+
const aDetectedAt = parseIsoMillis(a.detectedAt) ?? Number.POSITIVE_INFINITY;
|
|
73
|
+
const bDetectedAt = parseIsoMillis(b.detectedAt) ?? Number.POSITIVE_INFINITY;
|
|
74
|
+
if (aDetectedAt !== bDetectedAt) return aDetectedAt < bDetectedAt ? -1 : 1;
|
|
75
|
+
const aPairId = typeof a.pairId === "string" ? a.pairId : "";
|
|
76
|
+
const bPairId = typeof b.pairId === "string" ? b.pairId : "";
|
|
77
|
+
const pairIdOrder = aPairId.localeCompare(bPairId);
|
|
78
|
+
if (pairIdOrder !== 0) return pairIdOrder;
|
|
79
|
+
return a.memoryIds.join("\0").localeCompare(b.memoryIds.join("\0"));
|
|
80
|
+
}
|
|
65
81
|
function reviewStateMillis(pair) {
|
|
66
82
|
return Math.max(
|
|
67
83
|
parseIsoMillis(pair.deferredUntil) ?? Number.NEGATIVE_INFINITY,
|
|
@@ -223,7 +239,7 @@ function listPairs(memoryDir, options) {
|
|
|
223
239
|
const startTime = Date.now();
|
|
224
240
|
const dir = reviewDir(memoryDir);
|
|
225
241
|
const { filter = "all", namespace, includeUnscopedForNamespace = false, limit = 50 } = options ?? {};
|
|
226
|
-
const
|
|
242
|
+
const matchingPairs = [];
|
|
227
243
|
let total = 0;
|
|
228
244
|
if (!fs.existsSync(dir)) {
|
|
229
245
|
return { pairs: [], total: 0, durationMs: Date.now() - startTime };
|
|
@@ -247,11 +263,17 @@ function listPairs(memoryDir, options) {
|
|
|
247
263
|
continue;
|
|
248
264
|
}
|
|
249
265
|
total++;
|
|
250
|
-
|
|
266
|
+
matchingPairs.push(pair);
|
|
251
267
|
} catch {
|
|
252
268
|
continue;
|
|
253
269
|
}
|
|
254
270
|
}
|
|
271
|
+
matchingPairs.sort(compareReviewPairs);
|
|
272
|
+
const pairs = [];
|
|
273
|
+
for (const pair of matchingPairs) {
|
|
274
|
+
if (!(pairs.length < limit)) break;
|
|
275
|
+
pairs.push(pair);
|
|
276
|
+
}
|
|
255
277
|
return { pairs, total, durationMs: Date.now() - startTime };
|
|
256
278
|
}
|
|
257
279
|
function migrateUnscopedPairsToNamespace(memoryDir, namespace, options = {}) {
|
|
@@ -380,4 +402,4 @@ export {
|
|
|
380
402
|
deferPair,
|
|
381
403
|
memoryHashesChanged
|
|
382
404
|
};
|
|
383
|
-
//# sourceMappingURL=chunk-
|
|
405
|
+
//# sourceMappingURL=chunk-35NN3ZFA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/contradiction/contradiction-review.ts"],"sourcesContent":["/**\n * Contradiction Review Queue — storage for detected contradiction pairs (issue #520).\n *\n * Stores candidate pairs as JSON files under `memoryDir/.review/contradictions/`.\n * Pair IDs are deterministic (sha256 of sorted memory IDs plus namespace when scoped) so reruns are idempotent.\n *\n * Lifecycle:\n * - `contradicts` → awaiting user review\n * - `duplicates` → auto-flagged for dedup (still needs user approval)\n * - `independent` / `both-valid` → dormant with cooldown\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { createHash, randomUUID } from \"node:crypto\";\nimport type { ContradictionVerdict } from \"./contradiction-judge.js\";\n\n// ── Types ──────────────────────────────────────────────────────────────────────\n\nexport type ResolutionVerb = \"keep-a\" | \"keep-b\" | \"merge\" | \"both-valid\" | \"needs-more-context\";\n\nconst VALID_RESOLUTION_VERBS: readonly ResolutionVerb[] = [\n \"keep-a\",\n \"keep-b\",\n \"merge\",\n \"both-valid\",\n \"needs-more-context\",\n];\n\nexport interface ContradictionPair {\n /** Deterministic pair ID: sha256(sorted(memoryIdA, memoryIdB) plus namespace when scoped). */\n pairId: string;\n /** Memory IDs (sorted). */\n memoryIds: [string, string];\n /** Judge verdict. */\n verdict: ContradictionVerdict;\n /** Judge rationale. */\n rationale: string;\n /** Judge confidence in [0, 1]. */\n confidence: number;\n /** ISO timestamp when detected. */\n detectedAt: string;\n /** ISO timestamp when last reviewed by user. */\n lastReviewedAt?: string;\n /** Resolution verb applied by user. */\n resolution?: ResolutionVerb;\n /** ISO timestamp until which a non-terminal deferral remains hidden from review. */\n deferredUntil?: string;\n /** Content hashes captured for each referenced memory when this pair was judged. */\n memoryContentHashes?: Record<string, string>;\n /** Namespace scope. */\n namespace?: string;\n}\n\nexport interface ContradictionListResult {\n pairs: ContradictionPair[];\n total: number;\n durationMs: number;\n}\n\nexport type ContradictionFilter = ContradictionVerdict | \"all\" | \"unresolved\";\nexport interface WritePairOptions {\n /** Cooldown used by scan callers to preserve still-dormant reviewed pairs. */\n cooldownDays?: number;\n}\nconst NEEDS_MORE_CONTEXT_COOLDOWN_MS = 24 * 60 * 60 * 1000;\nconst UNSCOPED_MIGRATION_MARKER_PREFIX = \".unscoped-migrated-\";\nconst UNSCOPED_MIGRATION_MARKER_SUFFIX = \".done\";\n\n// ── Helpers ────────────────────────────────────────────────────────────────────\n\nexport function computePairId(memoryIdA: string, memoryIdB: string, namespace?: string): string {\n const sorted = [memoryIdA, memoryIdB].sort();\n const normalizedNamespace = namespace?.trim();\n const scope = normalizedNamespace ? `ns:${normalizedNamespace}::` : \"\";\n return createHash(\"sha256\").update(`${scope}${sorted.join(\"::\")}`).digest(\"hex\").slice(0, 24);\n}\n\nexport function isDefaultReviewNamespace(\n defaultNamespace: string,\n requestedNamespace: string | undefined,\n resolvedNamespace: string,\n): boolean {\n const requested = requestedNamespace?.trim();\n return !requested || requested === defaultNamespace || resolvedNamespace === defaultNamespace;\n}\n\nfunction isTerminalResolution(resolution: ResolutionVerb | undefined): boolean {\n return resolution === \"keep-a\" || resolution === \"keep-b\" || resolution === \"merge\";\n}\n\nfunction preservesDirectResolution(resolution: ResolutionVerb | undefined): boolean {\n return isTerminalResolution(resolution) || resolution === \"both-valid\";\n}\n\nfunction isDormantReviewedPair(pair: ContradictionPair): boolean {\n return pair.verdict === \"independent\" || pair.resolution === \"both-valid\";\n}\n\nfunction reviewStateRank(pair: ContradictionPair, cooldownDays?: number): number {\n if (isTerminalResolution(pair.resolution)) return 5;\n if (pair.resolution === \"both-valid\") return 4;\n if (isDeferralActive(pair)) return 3;\n if (isDormantReviewedPair(pair)) {\n if (cooldownDays === undefined) return 2;\n return isCoolingDown(pair, cooldownDays) ? 2 : 0;\n }\n return 1;\n}\n\nfunction parseIsoMillis(value: string | undefined): number | null {\n if (!value) return null;\n const millis = new Date(value).getTime();\n return Number.isFinite(millis) ? millis : null;\n}\n\nfunction isDeferred(pair: Pick<ContradictionPair, \"resolution\" | \"deferredUntil\">): boolean {\n return pair.resolution === \"needs-more-context\" || Boolean(pair.deferredUntil);\n}\n\nfunction deferralUntilMillis(pair: ContradictionPair): number | null {\n const deferredUntil = parseIsoMillis(pair.deferredUntil);\n if (deferredUntil !== null) return deferredUntil;\n\n if (pair.resolution === \"needs-more-context\") {\n const lastReviewed = parseIsoMillis(pair.lastReviewedAt);\n return lastReviewed === null ? null : lastReviewed + NEEDS_MORE_CONTEXT_COOLDOWN_MS;\n }\n\n return null;\n}\n\nfunction isDeferralActive(pair: ContradictionPair): boolean {\n const deferredUntil = deferralUntilMillis(pair);\n return deferredUntil !== null && Date.now() < deferredUntil;\n}\n\nfunction isReviewActionable(pair: ContradictionPair): boolean {\n return !isTerminalResolution(pair.resolution)\n && !isDeferralActive(pair)\n && pair.resolution !== \"both-valid\"\n && pair.verdict !== \"independent\";\n}\n\nfunction compareReviewPairs(a: ContradictionPair, b: ContradictionPair): number {\n const aActionable = isReviewActionable(a);\n const bActionable = isReviewActionable(b);\n if (aActionable !== bActionable) return aActionable ? -1 : 1;\n\n const aDetectedAt = parseIsoMillis(a.detectedAt) ?? Number.POSITIVE_INFINITY;\n const bDetectedAt = parseIsoMillis(b.detectedAt) ?? Number.POSITIVE_INFINITY;\n if (aDetectedAt !== bDetectedAt) return aDetectedAt < bDetectedAt ? -1 : 1;\n\n const aPairId = typeof a.pairId === \"string\" ? a.pairId : \"\";\n const bPairId = typeof b.pairId === \"string\" ? b.pairId : \"\";\n const pairIdOrder = aPairId.localeCompare(bPairId);\n if (pairIdOrder !== 0) return pairIdOrder;\n\n return a.memoryIds.join(\"\\0\").localeCompare(b.memoryIds.join(\"\\0\"));\n}\n\nfunction reviewStateMillis(pair: ContradictionPair): number {\n return Math.max(\n parseIsoMillis(pair.deferredUntil) ?? Number.NEGATIVE_INFINITY,\n parseIsoMillis(pair.lastReviewedAt) ?? Number.NEGATIVE_INFINITY,\n parseIsoMillis(pair.detectedAt) ?? Number.NEGATIVE_INFINITY,\n );\n}\n\nfunction mergeMigratedPair(existing: ContradictionPair, migrated: ContradictionPair, options: WritePairOptions): ContradictionPair {\n const existingRank = reviewStateRank(existing, options.cooldownDays);\n const migratedRank = reviewStateRank(migrated, options.cooldownDays);\n const selected = migratedRank > existingRank\n ? migrated\n : migratedRank < existingRank\n ? existing\n : reviewStateMillis(migrated) > reviewStateMillis(existing)\n ? migrated\n : existing;\n\n return {\n ...selected,\n pairId: migrated.pairId,\n namespace: migrated.namespace,\n };\n}\n\nfunction reviewDir(memoryDir: string): string {\n return path.join(memoryDir, \".review\", \"contradictions\");\n}\n\nfunction migrationMarkerPath(memoryDir: string, namespace: string): string {\n const namespaceKey = createHash(\"sha256\").update(namespace).digest(\"hex\").slice(0, 16);\n return path.join(reviewDir(memoryDir), `${UNSCOPED_MIGRATION_MARKER_PREFIX}${namespaceKey}${UNSCOPED_MIGRATION_MARKER_SUFFIX}`);\n}\n\nfunction clearUnscopedMigrationMarkers(memoryDir: string): void {\n const dir = reviewDir(memoryDir);\n if (!fs.existsSync(dir)) return;\n\n try {\n for (const entry of fs.readdirSync(dir)) {\n if (entry.startsWith(UNSCOPED_MIGRATION_MARKER_PREFIX) && entry.endsWith(UNSCOPED_MIGRATION_MARKER_SUFFIX)) {\n fs.rmSync(path.join(dir, entry), { force: true });\n }\n }\n } catch {\n // Marker cleanup is best-effort. The next migration/list call can recover.\n }\n}\n\nfunction pairPath(memoryDir: string, pairId: string): string {\n if (pairId.includes(\"/\") || pairId.includes(\"\\\\\") || pairId.includes(\"..\")) {\n throw new Error(`Invalid pairId: ${pairId}`);\n }\n return path.join(reviewDir(memoryDir), `${pairId}.json`);\n}\n\nfunction isSafeReviewJsonFile(memoryDir: string, filePath: string): boolean {\n const root = path.resolve(reviewDir(memoryDir));\n const resolved = path.resolve(filePath);\n const relative = path.relative(root, resolved);\n if (relative === \"\" || relative.startsWith(\"..\") || path.isAbsolute(relative)) {\n return false;\n }\n\n try {\n return fs.lstatSync(resolved).isFile();\n } catch {\n return false;\n }\n}\n\nfunction ensureDir(memoryDir: string): void {\n const dir = reviewDir(memoryDir);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n}\n\nfunction uniqueTempPath(filePath: string): string {\n return `${filePath}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`;\n}\n\nfunction writePairFile(filePath: string, pair: ContradictionPair): void {\n const tmpPath = uniqueTempPath(filePath);\n try {\n fs.writeFileSync(tmpPath, JSON.stringify(pair, null, 2), \"utf-8\");\n fs.renameSync(tmpPath, filePath);\n } catch (error) {\n try {\n fs.rmSync(tmpPath, { force: true });\n } catch {\n // Best-effort cleanup only; preserve the original write failure.\n }\n throw error;\n }\n}\n\nexport function computeMemoryContentHash(content: string, category?: string): string {\n const normalized = JSON.stringify({\n content: content.trim(),\n category: (category ?? \"\").trim(),\n });\n return createHash(\"sha256\").update(normalized).digest(\"hex\").slice(0, 16);\n}\n\nfunction suppliedMemoryHashesChanged(\n existing: ContradictionPair,\n pair: Omit<ContradictionPair, \"pairId\"> & { memoryIds: [string, string] },\n): boolean {\n if (!existing.memoryContentHashes || !pair.memoryContentHashes) return false;\n return pair.memoryIds.some((memoryId) => {\n const current = pair.memoryContentHashes?.[memoryId];\n return typeof current === \"string\" && existing.memoryContentHashes?.[memoryId] !== current;\n });\n}\n\n// ── Write ──────────────────────────────────────────────────────────────────────\n\n/**\n * Write a contradiction pair to the review queue.\n * Idempotent: if the pair already exists with a higher or equal confidence,\n * the existing entry is preserved.\n */\nexport function writePair(\n memoryDir: string,\n pair: Omit<ContradictionPair, \"pairId\"> & { memoryIds: [string, string] },\n options: WritePairOptions = {},\n): ContradictionPair {\n ensureDir(memoryDir);\n if (pair.namespace === undefined) {\n clearUnscopedMigrationMarkers(memoryDir);\n }\n const pairId = computePairId(pair.memoryIds[0], pair.memoryIds[1], pair.namespace);\n const existing = readPair(memoryDir, pairId);\n\n // Preserve terminal user resolutions if already reviewed.\n if (isTerminalResolution(existing?.resolution)) {\n return existing!;\n }\n const contentChanged = Boolean(existing && suppliedMemoryHashesChanged(existing, pair));\n if (existing?.resolution === \"both-valid\" && options.cooldownDays === undefined && !contentChanged) {\n return existing;\n }\n\n // Preserve active deferrals, but allow expired deferrals to be refreshed.\n const existingDeferralExpired = Boolean(existing && isDeferred(existing) && !isDeferralActive(existing));\n if (existing && isDeferralActive(existing) && !contentChanged) {\n return existing;\n }\n\n // Preserve same-verdict or still-cooling entries, but let expired dormant\n // verdicts refresh when the judge now finds an actionable conflict.\n const existingDormantCooldownActive = Boolean(\n existing\n && isDormantReviewedPair(existing)\n && options.cooldownDays !== undefined\n && isCoolingDown(existing, options.cooldownDays),\n );\n const dormantContentChanged = Boolean(\n existing\n && existingDormantCooldownActive\n && contentChanged,\n );\n const existingDormantExpired = Boolean(\n existing\n && isDormantReviewedPair(existing)\n && options.cooldownDays !== undefined\n && !existingDormantCooldownActive,\n );\n if (\n existing\n && !existingDeferralExpired\n && (\n (existingDormantCooldownActive && !dormantContentChanged)\n || (!existingDormantExpired && !contentChanged && existing.confidence >= pair.confidence)\n )\n ) {\n return existing;\n }\n\n const full: ContradictionPair = {\n ...pair,\n pairId,\n lastReviewedAt: (existingDeferralExpired || existingDormantExpired || contentChanged)\n ? pair.lastReviewedAt\n : (existing?.lastReviewedAt ?? pair.lastReviewedAt),\n resolution: undefined,\n deferredUntil: (existingDeferralExpired || existingDormantExpired || contentChanged)\n ? undefined\n : existing?.deferredUntil,\n };\n\n const filePath = pairPath(memoryDir, pairId);\n writePairFile(filePath, full);\n\n return full;\n}\n\n/**\n * Write multiple pairs, deduplicating inputs first (rule 49).\n */\nexport function writePairs(\n memoryDir: string,\n pairs: Array<Omit<ContradictionPair, \"pairId\"> & { memoryIds: [string, string] }>,\n options: WritePairOptions = {},\n): ContradictionPair[] {\n const seen = new Set<string>();\n const results: ContradictionPair[] = [];\n\n for (const pair of pairs) {\n const key = computePairId(pair.memoryIds[0], pair.memoryIds[1], pair.namespace);\n if (seen.has(key)) continue;\n seen.add(key);\n results.push(writePair(memoryDir, pair, options));\n }\n\n return results;\n}\n\n// ── Read ───────────────────────────────────────────────────────────────────────\n\n/**\n * Read a single pair by ID. Returns null if not found.\n */\nexport function readPair(memoryDir: string, pairId: string): ContradictionPair | null {\n const filePath = pairPath(memoryDir, pairId);\n try {\n if (!isSafeReviewJsonFile(memoryDir, filePath)) return null;\n const raw = fs.readFileSync(filePath, \"utf-8\");\n const parsed = JSON.parse(raw);\n if (typeof parsed === \"object\" && parsed !== null && Array.isArray(parsed.memoryIds)) {\n return parsed as ContradictionPair;\n }\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * List pairs in the review queue, optionally filtered by verdict.\n */\nexport function listPairs(\n memoryDir: string,\n options?: {\n filter?: ContradictionFilter;\n namespace?: string;\n includeUnscopedForNamespace?: boolean;\n limit?: number;\n },\n): ContradictionListResult {\n const startTime = Date.now();\n const dir = reviewDir(memoryDir);\n const { filter = \"all\", namespace, includeUnscopedForNamespace = false, limit = 50 } = options ?? {};\n const matchingPairs: ContradictionPair[] = [];\n let total = 0;\n\n if (!fs.existsSync(dir)) {\n return { pairs: [], total: 0, durationMs: Date.now() - startTime };\n }\n\n for (const entry of fs.readdirSync(dir)) {\n if (!entry.endsWith(\".json\")) continue;\n\n try {\n const filePath = path.join(dir, entry);\n if (!isSafeReviewJsonFile(memoryDir, filePath)) continue;\n const raw = fs.readFileSync(filePath, \"utf-8\");\n const pair = JSON.parse(raw) as ContradictionPair;\n\n if (typeof pair !== \"object\" || pair === null) continue;\n if (!Array.isArray(pair.memoryIds)) continue;\n\n // Namespace filter\n if (namespace && pair.namespace !== namespace && !(includeUnscopedForNamespace && pair.namespace === undefined)) continue;\n\n // Verdict filter\n if (filter === \"unresolved\") {\n if (isTerminalResolution(pair.resolution)) continue;\n if (isDeferralActive(pair)) continue;\n if (pair.resolution === \"both-valid\") continue;\n if (pair.verdict === \"independent\") continue;\n } else if (filter !== \"all\" && pair.verdict !== filter) {\n continue;\n }\n\n total++;\n matchingPairs.push(pair);\n } catch {\n continue;\n }\n }\n\n matchingPairs.sort(compareReviewPairs);\n const pairs: ContradictionPair[] = [];\n for (const pair of matchingPairs) {\n if (!(pairs.length < limit)) break;\n pairs.push(pair);\n }\n\n return { pairs, total, durationMs: Date.now() - startTime };\n}\n\nexport function migrateUnscopedPairsToNamespace(memoryDir: string, namespace: string, options: WritePairOptions = {}): number {\n const resolvedNamespace = namespace.trim();\n if (!resolvedNamespace) return 0;\n\n const dir = reviewDir(memoryDir);\n if (!fs.existsSync(dir)) return 0;\n const markerPath = migrationMarkerPath(memoryDir, resolvedNamespace);\n if (fs.existsSync(markerPath)) return 0;\n\n let migrated = 0;\n let hadMigrationFailure = false;\n for (const entry of fs.readdirSync(dir)) {\n if (!entry.endsWith(\".json\")) continue;\n const filePath = path.join(dir, entry);\n\n try {\n if (!isSafeReviewJsonFile(memoryDir, filePath)) continue;\n const raw = fs.readFileSync(filePath, \"utf-8\");\n const pair = JSON.parse(raw) as ContradictionPair;\n if (typeof pair !== \"object\" || pair === null) continue;\n if (!Array.isArray(pair.memoryIds)) continue;\n if (pair.namespace !== undefined) continue;\n\n const pairId = computePairId(pair.memoryIds[0], pair.memoryIds[1], resolvedNamespace);\n const migratedPair = { ...pair, namespace: resolvedNamespace, pairId };\n const targetPath = pairPath(memoryDir, pairId);\n try {\n if (targetPath === filePath) {\n writePairFile(filePath, migratedPair);\n } else if (!fs.existsSync(targetPath)) {\n writePairFile(targetPath, migratedPair);\n fs.rmSync(filePath, { force: true });\n } else {\n if (!isSafeReviewJsonFile(memoryDir, targetPath)) {\n hadMigrationFailure = true;\n continue;\n }\n const existing = readPair(memoryDir, pairId);\n writePairFile(targetPath, existing ? mergeMigratedPair(existing, migratedPair, options) : migratedPair);\n fs.rmSync(filePath, { force: true });\n }\n migrated += 1;\n } catch {\n hadMigrationFailure = true;\n continue;\n }\n } catch {\n continue;\n }\n }\n\n if (!hadMigrationFailure) {\n try {\n fs.writeFileSync(markerPath, `${new Date().toISOString()}\\n`, { encoding: \"utf-8\", flag: \"wx\" });\n } catch {\n // Another caller may have completed the same one-shot migration first.\n }\n }\n\n return migrated;\n}\n\n// ── Cooldown ───────────────────────────────────────────────────────────────────\n\n/**\n * Check if a pair is within its cooldown window.\n * Returns true if the pair should be SKIPPED (still cooling down).\n */\nexport function isCoolingDown(pair: ContradictionPair, cooldownDays: number): boolean {\n if (cooldownDays <= 0) return false; // rule 27: guard against 0\n\n const deferredUntil = deferralUntilMillis(pair);\n if (deferredUntil !== null) {\n return Date.now() < deferredUntil;\n }\n\n if (!pair.lastReviewedAt) return false;\n\n const lastReviewed = parseIsoMillis(pair.lastReviewedAt);\n if (lastReviewed === null) return false;\n\n const cooldownMs = cooldownDays * 24 * 60 * 60 * 1000;\n return Date.now() < lastReviewed + cooldownMs;\n}\n\n/**\n * Mark a pair as reviewed (sets lastReviewedAt and, for terminal verbs, resolution).\n */\nexport function resolvePair(\n memoryDir: string,\n pairId: string,\n verb: ResolutionVerb,\n): ContradictionPair | null {\n if (typeof verb !== \"string\" || !VALID_RESOLUTION_VERBS.includes(verb)) {\n throw new Error(`Invalid contradiction resolution verb: ${String(verb)}`);\n }\n\n if (verb === \"needs-more-context\") {\n return deferPair(memoryDir, pairId);\n }\n\n const existing = readPair(memoryDir, pairId);\n if (!existing) return null;\n if (preservesDirectResolution(existing.resolution)) return existing;\n\n const updated: ContradictionPair = {\n ...existing,\n lastReviewedAt: new Date().toISOString(),\n resolution: verb,\n deferredUntil: undefined,\n };\n\n const filePath = pairPath(memoryDir, pairId);\n writePairFile(filePath, updated);\n\n return updated;\n}\n\n/**\n * Defer a pair without terminally resolving it.\n */\nexport function deferPair(\n memoryDir: string,\n pairId: string,\n deferredUntil = new Date(Date.now() + NEEDS_MORE_CONTEXT_COOLDOWN_MS).toISOString(),\n): ContradictionPair | null {\n const existing = readPair(memoryDir, pairId);\n if (!existing) return null;\n if (preservesDirectResolution(existing.resolution)) return existing;\n\n const updated: ContradictionPair = {\n ...existing,\n lastReviewedAt: new Date().toISOString(),\n resolution: undefined,\n deferredUntil,\n };\n\n const filePath = pairPath(memoryDir, pairId);\n writePairFile(filePath, updated);\n\n return updated;\n}\n\n/**\n * Check whether a pair's referenced memories have changed since detection,\n * which should override cooldown.\n */\nexport function memoryHashesChanged(\n _memoryDir: string,\n pair: ContradictionPair,\n getCurrentHash: (memoryId: string) => string | null,\n): boolean {\n if (!pair.memoryContentHashes) return false;\n\n for (const memoryId of pair.memoryIds) {\n const previousHash = pair.memoryContentHashes[memoryId];\n if (typeof previousHash !== \"string\") continue;\n\n const currentHash = getCurrentHash(memoryId);\n if (currentHash !== null && currentHash !== previousHash) return true;\n }\n\n return false;\n}\n"],"mappings":";AAYA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,YAAY,kBAAkB;AAOvC,IAAM,yBAAoD;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAsCA,IAAM,iCAAiC,KAAK,KAAK,KAAK;AACtD,IAAM,mCAAmC;AACzC,IAAM,mCAAmC;AAIlC,SAAS,cAAc,WAAmB,WAAmB,WAA4B;AAC9F,QAAM,SAAS,CAAC,WAAW,SAAS,EAAE,KAAK;AAC3C,QAAM,sBAAsB,WAAW,KAAK;AAC5C,QAAM,QAAQ,sBAAsB,MAAM,mBAAmB,OAAO;AACpE,SAAO,WAAW,QAAQ,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO,KAAK,IAAI,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AAC9F;AAEO,SAAS,yBACd,kBACA,oBACA,mBACS;AACT,QAAM,YAAY,oBAAoB,KAAK;AAC3C,SAAO,CAAC,a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AY,KAAK,WAAW;AACrC,UAAM,eAAe,KAAK,oBAAoB,QAAQ;AACtD,QAAI,OAAO,iBAAiB,SAAU;AAEtC,UAAM,cAAc,eAAe,QAAQ;AAC3C,QAAI,gBAAgB,QAAQ,gBAAgB,aAAc,QAAO;AAAA,EACnE;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
migrateUnscopedPairsToNamespace,
|
|
7
7
|
readPair,
|
|
8
8
|
writePairs
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-35NN3ZFA.js";
|
|
10
10
|
import {
|
|
11
11
|
extractJsonCandidates
|
|
12
12
|
} from "./chunk-UZB5KHKX.js";
|
|
@@ -543,4 +543,4 @@ export {
|
|
|
543
543
|
ACTIVE_STATUSES,
|
|
544
544
|
runContradictionScan
|
|
545
545
|
};
|
|
546
|
-
//# sourceMappingURL=chunk-
|
|
546
|
+
//# sourceMappingURL=chunk-6GMPIJAZ.js.map
|
|
@@ -2628,7 +2628,7 @@ ${body}`;
|
|
|
2628
2628
|
const {
|
|
2629
2629
|
isDefaultReviewNamespace,
|
|
2630
2630
|
listPairs
|
|
2631
|
-
} = await import("./contradiction-review-
|
|
2631
|
+
} = await import("./contradiction-review-QKJH5DKD.js");
|
|
2632
2632
|
const VALID_REVIEW_FILTERS = /* @__PURE__ */ new Set(["all", "unresolved", "contradicts", "independent", "duplicates", "needs-user"]);
|
|
2633
2633
|
const rawFilter = typeof args.filter === "string" ? args.filter : "unresolved";
|
|
2634
2634
|
if (!VALID_REVIEW_FILTERS.has(rawFilter)) {
|
|
@@ -2655,9 +2655,9 @@ ${body}`;
|
|
|
2655
2655
|
const verb = typeof args.verb === "string" ? args.verb : "";
|
|
2656
2656
|
if (!pairId) throw new Error("pairId is required");
|
|
2657
2657
|
if (!verb) throw new Error("verb is required");
|
|
2658
|
-
const { isValidResolutionVerb } = await import("./resolution-
|
|
2658
|
+
const { isValidResolutionVerb } = await import("./resolution-3SAP4SH2.js");
|
|
2659
2659
|
if (!isValidResolutionVerb(verb)) throw new Error(`Invalid verb: ${verb}. Must be one of: keep-a, keep-b, merge, both-valid, needs-more-context`);
|
|
2660
|
-
const { executeResolution } = await import("./resolution-
|
|
2660
|
+
const { executeResolution } = await import("./resolution-3SAP4SH2.js");
|
|
2661
2661
|
return executeResolution(this.service.memoryDir, this.service.storageRef, pairId, verb, {
|
|
2662
2662
|
mergedMemoryId: typeof args.mergedMemoryId === "string" ? args.mergedMemoryId : void 0,
|
|
2663
2663
|
mergedContent: typeof args.mergedContent === "string" ? args.mergedContent : void 0,
|
|
@@ -2669,7 +2669,7 @@ ${body}`;
|
|
|
2669
2669
|
}
|
|
2670
2670
|
case "engram.contradiction_scan_run":
|
|
2671
2671
|
case "remnic.contradiction_scan_run": {
|
|
2672
|
-
const { runContradictionScan } = await import("./contradiction-scan-
|
|
2672
|
+
const { runContradictionScan } = await import("./contradiction-scan-GD7KUFWS.js");
|
|
2673
2673
|
return runContradictionScan({
|
|
2674
2674
|
storage: this.service.storageRef,
|
|
2675
2675
|
config: this.service.configRef,
|
|
@@ -2860,4 +2860,4 @@ ${body}`;
|
|
|
2860
2860
|
export {
|
|
2861
2861
|
EngramMcpServer
|
|
2862
2862
|
};
|
|
2863
|
-
//# sourceMappingURL=chunk-
|
|
2863
|
+
//# sourceMappingURL=chunk-LAL7WBLY.js.map
|
|
@@ -209,10 +209,10 @@ import {
|
|
|
209
209
|
} from "./chunk-OADWQ5CR.js";
|
|
210
210
|
import {
|
|
211
211
|
EngramAccessHttpServer
|
|
212
|
-
} from "./chunk-
|
|
212
|
+
} from "./chunk-ZY6UPHNY.js";
|
|
213
213
|
import {
|
|
214
214
|
EngramMcpServer
|
|
215
|
-
} from "./chunk-
|
|
215
|
+
} from "./chunk-LAL7WBLY.js";
|
|
216
216
|
import {
|
|
217
217
|
EngramAccessService
|
|
218
218
|
} from "./chunk-VFB2G5YL.js";
|
|
@@ -5836,7 +5836,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
|
|
|
5836
5836
|
process.exit(1);
|
|
5837
5837
|
}
|
|
5838
5838
|
const limit = parseInt(options.limit ?? "50", 10);
|
|
5839
|
-
const { listPairs } = await import("./contradiction-review-
|
|
5839
|
+
const { listPairs } = await import("./contradiction-review-QKJH5DKD.js");
|
|
5840
5840
|
const result = listPairs(orchestrator.config.memoryDir, {
|
|
5841
5841
|
filter,
|
|
5842
5842
|
namespace: options.namespace,
|
|
@@ -5863,7 +5863,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
|
|
|
5863
5863
|
console.error("pairId is required");
|
|
5864
5864
|
process.exit(1);
|
|
5865
5865
|
}
|
|
5866
|
-
const { readPair } = await import("./contradiction-review-
|
|
5866
|
+
const { readPair } = await import("./contradiction-review-QKJH5DKD.js");
|
|
5867
5867
|
const pair = readPair(orchestrator.config.memoryDir, pairId);
|
|
5868
5868
|
if (!pair) {
|
|
5869
5869
|
console.error(`Pair ${pairId} not found.`);
|
|
@@ -5883,7 +5883,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
|
|
|
5883
5883
|
console.error("--verb is required. Must be one of: keep-a, keep-b, merge, both-valid, needs-more-context");
|
|
5884
5884
|
process.exit(1);
|
|
5885
5885
|
}
|
|
5886
|
-
const { isValidResolutionVerb, executeResolution } = await import("./resolution-
|
|
5886
|
+
const { isValidResolutionVerb, executeResolution } = await import("./resolution-3SAP4SH2.js");
|
|
5887
5887
|
if (!isValidResolutionVerb(verb)) {
|
|
5888
5888
|
console.error(`Invalid verb: ${verb}. Must be one of: keep-a, keep-b, merge, both-valid, needs-more-context`);
|
|
5889
5889
|
process.exit(1);
|
|
@@ -5909,7 +5909,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
|
|
|
5909
5909
|
});
|
|
5910
5910
|
reviewCmd.command("scan").description("Run an on-demand contradiction scan").option("--namespace <ns>", "Namespace to scan").action(async (...args) => {
|
|
5911
5911
|
const options = args[0] ?? {};
|
|
5912
|
-
const { runContradictionScan } = await import("./contradiction-scan-
|
|
5912
|
+
const { runContradictionScan } = await import("./contradiction-scan-GD7KUFWS.js");
|
|
5913
5913
|
console.log("Running contradiction scan...");
|
|
5914
5914
|
const result = await runContradictionScan({
|
|
5915
5915
|
storage: orchestrator.storage,
|
|
@@ -6616,4 +6616,4 @@ export {
|
|
|
6616
6616
|
resolveMemoryDirForNamespace,
|
|
6617
6617
|
registerCli
|
|
6618
6618
|
};
|
|
6619
|
-
//# sourceMappingURL=chunk-
|
|
6619
|
+
//# sourceMappingURL=chunk-QRWZOCJN.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readPair,
|
|
3
3
|
resolvePair
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-35NN3ZFA.js";
|
|
5
5
|
import {
|
|
6
6
|
log
|
|
7
7
|
} from "./chunk-2ODBA7MQ.js";
|
|
@@ -299,4 +299,4 @@ export {
|
|
|
299
299
|
isValidResolutionVerb,
|
|
300
300
|
executeResolution
|
|
301
301
|
};
|
|
302
|
-
//# sourceMappingURL=chunk-
|
|
302
|
+
//# sourceMappingURL=chunk-R3PQUPQ4.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-AU7Q3LSC.js";
|
|
4
4
|
import {
|
|
5
5
|
EngramMcpServer
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LAL7WBLY.js";
|
|
7
7
|
import {
|
|
8
8
|
EngramAccessInputError
|
|
9
9
|
} from "./chunk-VFB2G5YL.js";
|
|
@@ -1115,7 +1115,7 @@ var EngramAccessHttpServer = class {
|
|
|
1115
1115
|
const {
|
|
1116
1116
|
isDefaultReviewNamespace,
|
|
1117
1117
|
listPairs
|
|
1118
|
-
} = await import("./contradiction-review-
|
|
1118
|
+
} = await import("./contradiction-review-QKJH5DKD.js");
|
|
1119
1119
|
const principal = this.resolveRequestPrincipal(req);
|
|
1120
1120
|
const resolved = await this.service.getReadableStorageForNamespace(namespace, principal);
|
|
1121
1121
|
const reviewNamespace = this.service.configRef.namespacesEnabled ? resolved.namespace : void 0;
|
|
@@ -1133,7 +1133,7 @@ var EngramAccessHttpServer = class {
|
|
|
1133
1133
|
}
|
|
1134
1134
|
if (req.method === "GET" && pathname.startsWith("/engram/v1/review/contradictions/")) {
|
|
1135
1135
|
const pairId = pathname.split("/").pop() ?? "";
|
|
1136
|
-
const { readPair } = await import("./contradiction-review-
|
|
1136
|
+
const { readPair } = await import("./contradiction-review-QKJH5DKD.js");
|
|
1137
1137
|
const pair = readPair(this.service.memoryDir, pairId);
|
|
1138
1138
|
if (!pair) {
|
|
1139
1139
|
this.respondJson(res, 404, { error: "pair_not_found" });
|
|
@@ -1156,7 +1156,7 @@ var EngramAccessHttpServer = class {
|
|
|
1156
1156
|
this.respondJson(res, 400, { error: "pairId and verb are required" });
|
|
1157
1157
|
return;
|
|
1158
1158
|
}
|
|
1159
|
-
const { isValidResolutionVerb, executeResolution } = await import("./resolution-
|
|
1159
|
+
const { isValidResolutionVerb, executeResolution } = await import("./resolution-3SAP4SH2.js");
|
|
1160
1160
|
if (!isValidResolutionVerb(verb)) {
|
|
1161
1161
|
this.respondJson(res, 400, { error: `Invalid verb: ${verb}. Must be one of: keep-a, keep-b, merge, both-valid, needs-more-context` });
|
|
1162
1162
|
return;
|
|
@@ -1249,7 +1249,7 @@ var EngramAccessHttpServer = class {
|
|
|
1249
1249
|
}
|
|
1250
1250
|
if (req.method === "POST" && pathname === "/engram/v1/contradiction-scan") {
|
|
1251
1251
|
const body = await this.readJsonBody(req);
|
|
1252
|
-
const { runContradictionScan } = await import("./contradiction-scan-
|
|
1252
|
+
const { runContradictionScan } = await import("./contradiction-scan-GD7KUFWS.js");
|
|
1253
1253
|
const principal = this.resolveRequestPrincipal(req);
|
|
1254
1254
|
const result = await runContradictionScan({
|
|
1255
1255
|
storage: this.service.storageRef,
|
|
@@ -1846,4 +1846,4 @@ var EngramAccessHttpServer = class {
|
|
|
1846
1846
|
export {
|
|
1847
1847
|
EngramAccessHttpServer
|
|
1848
1848
|
};
|
|
1849
|
-
//# sourceMappingURL=chunk-
|
|
1849
|
+
//# sourceMappingURL=chunk-ZY6UPHNY.js.map
|
package/dist/cli.js
CHANGED
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
runWorkProductStatusCliCommand,
|
|
90
90
|
runWorkProjectCliCommand,
|
|
91
91
|
runWorkTaskCliCommand
|
|
92
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-QRWZOCJN.js";
|
|
93
93
|
import "./chunk-LQHDIS7L.js";
|
|
94
94
|
import "./chunk-7F7Z6MOS.js";
|
|
95
95
|
import "./chunk-4RR6ROTB.js";
|
|
@@ -182,7 +182,7 @@ import "./chunk-6HZ6AO2P.js";
|
|
|
182
182
|
import "./chunk-HQ6NIBL6.js";
|
|
183
183
|
import "./chunk-PVGDJXVK.js";
|
|
184
184
|
import "./chunk-OADWQ5CR.js";
|
|
185
|
-
import "./chunk-
|
|
185
|
+
import "./chunk-ZY6UPHNY.js";
|
|
186
186
|
import "./chunk-SEDEKFYQ.js";
|
|
187
187
|
import "./chunk-AU7Q3LSC.js";
|
|
188
188
|
import "./chunk-42NQ7AVG.js";
|
|
@@ -190,7 +190,7 @@ import "./chunk-TMSXWOBZ.js";
|
|
|
190
190
|
import "./chunk-J64TK33U.js";
|
|
191
191
|
import "./chunk-RSUYKGGZ.js";
|
|
192
192
|
import "./chunk-7RXCMVFQ.js";
|
|
193
|
-
import "./chunk-
|
|
193
|
+
import "./chunk-LAL7WBLY.js";
|
|
194
194
|
import "./chunk-EAZGEEG2.js";
|
|
195
195
|
import "./chunk-D24OXEPB.js";
|
|
196
196
|
import "./chunk-VFB2G5YL.js";
|
|
@@ -2,7 +2,7 @@ import "../chunk-V5OCT34X.js";
|
|
|
2
2
|
import {
|
|
3
3
|
executeResolution,
|
|
4
4
|
isValidResolutionVerb
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-R3PQUPQ4.js";
|
|
6
6
|
import {
|
|
7
7
|
ACTIVE_STATUSES,
|
|
8
8
|
clearVerdictCache,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
judgeContradictionPairs,
|
|
11
11
|
runContradictionScan,
|
|
12
12
|
verdictCacheSize
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-6GMPIJAZ.js";
|
|
14
14
|
import {
|
|
15
15
|
computePairId,
|
|
16
16
|
isCoolingDown,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
resolvePair,
|
|
20
20
|
writePair,
|
|
21
21
|
writePairs
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-35NN3ZFA.js";
|
|
23
23
|
import "../chunk-UZB5KHKX.js";
|
|
24
24
|
import "../chunk-2ODBA7MQ.js";
|
|
25
25
|
import "../chunk-PZ5AY32C.js";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
resolvePair,
|
|
12
12
|
writePair,
|
|
13
13
|
writePairs
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-35NN3ZFA.js";
|
|
15
15
|
import "./chunk-PZ5AY32C.js";
|
|
16
16
|
export {
|
|
17
17
|
computeMemoryContentHash,
|
|
@@ -27,4 +27,4 @@ export {
|
|
|
27
27
|
writePair,
|
|
28
28
|
writePairs
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=contradiction-review-
|
|
30
|
+
//# sourceMappingURL=contradiction-review-QKJH5DKD.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ACTIVE_STATUSES,
|
|
3
3
|
runContradictionScan
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-6GMPIJAZ.js";
|
|
5
|
+
import "./chunk-35NN3ZFA.js";
|
|
6
6
|
import "./chunk-UZB5KHKX.js";
|
|
7
7
|
import "./chunk-2ODBA7MQ.js";
|
|
8
8
|
import "./chunk-PZ5AY32C.js";
|
|
@@ -10,4 +10,4 @@ export {
|
|
|
10
10
|
ACTIVE_STATUSES,
|
|
11
11
|
runContradictionScan
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=contradiction-scan-
|
|
13
|
+
//# sourceMappingURL=contradiction-scan-GD7KUFWS.js.map
|
package/dist/index.js
CHANGED
|
@@ -48,12 +48,12 @@ import "./chunk-V5OCT34X.js";
|
|
|
48
48
|
import {
|
|
49
49
|
executeResolution,
|
|
50
50
|
isValidResolutionVerb
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-R3PQUPQ4.js";
|
|
52
52
|
import {
|
|
53
53
|
ACTIVE_STATUSES,
|
|
54
54
|
judgeContradictionPairs,
|
|
55
55
|
runContradictionScan
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-6GMPIJAZ.js";
|
|
57
57
|
import {
|
|
58
58
|
computePairId,
|
|
59
59
|
isCoolingDown,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
resolvePair,
|
|
63
63
|
writePair,
|
|
64
64
|
writePairs
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-35NN3ZFA.js";
|
|
66
66
|
import {
|
|
67
67
|
generateToken,
|
|
68
68
|
getAllValidTokens,
|
|
@@ -93,7 +93,7 @@ import {
|
|
|
93
93
|
listTrainingExportAdapters,
|
|
94
94
|
registerTrainingExportAdapter,
|
|
95
95
|
runBulkImportCliCommand
|
|
96
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-QRWZOCJN.js";
|
|
97
97
|
import "./chunk-LQHDIS7L.js";
|
|
98
98
|
import "./chunk-7F7Z6MOS.js";
|
|
99
99
|
import "./chunk-4RR6ROTB.js";
|
|
@@ -477,7 +477,7 @@ import "./chunk-PVGDJXVK.js";
|
|
|
477
477
|
import "./chunk-OADWQ5CR.js";
|
|
478
478
|
import {
|
|
479
479
|
EngramAccessHttpServer
|
|
480
|
-
} from "./chunk-
|
|
480
|
+
} from "./chunk-ZY6UPHNY.js";
|
|
481
481
|
import "./chunk-SEDEKFYQ.js";
|
|
482
482
|
import "./chunk-AU7Q3LSC.js";
|
|
483
483
|
import "./chunk-42NQ7AVG.js";
|
|
@@ -487,7 +487,7 @@ import "./chunk-RSUYKGGZ.js";
|
|
|
487
487
|
import "./chunk-7RXCMVFQ.js";
|
|
488
488
|
import {
|
|
489
489
|
EngramMcpServer
|
|
490
|
-
} from "./chunk-
|
|
490
|
+
} from "./chunk-LAL7WBLY.js";
|
|
491
491
|
import {
|
|
492
492
|
REMNIC_CHATGPT_MEMORY_INSPECTOR_CANONICAL_TOOL,
|
|
493
493
|
REMNIC_CHATGPT_MEMORY_INSPECTOR_MIME_TYPE,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeResolution,
|
|
3
3
|
isValidResolutionVerb
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-R3PQUPQ4.js";
|
|
5
|
+
import "./chunk-35NN3ZFA.js";
|
|
6
6
|
import "./chunk-2ODBA7MQ.js";
|
|
7
7
|
import "./chunk-PZ5AY32C.js";
|
|
8
8
|
export {
|
|
9
9
|
executeResolution,
|
|
10
10
|
isValidResolutionVerb
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=resolution-
|
|
12
|
+
//# sourceMappingURL=resolution-3SAP4SH2.js.map
|
package/dist/schemas.d.ts
CHANGED
|
@@ -275,12 +275,12 @@ declare const EntityMentionSchema: z.ZodObject<{
|
|
|
275
275
|
title: z.ZodString;
|
|
276
276
|
facts: z.ZodArray<z.ZodString, "many">;
|
|
277
277
|
}, "strip", z.ZodTypeAny, {
|
|
278
|
-
key: string;
|
|
279
278
|
title: string;
|
|
279
|
+
key: string;
|
|
280
280
|
facts: string[];
|
|
281
281
|
}, {
|
|
282
|
-
key: string;
|
|
283
282
|
title: string;
|
|
283
|
+
key: string;
|
|
284
284
|
facts: string[];
|
|
285
285
|
}>, "many">>>;
|
|
286
286
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -288,8 +288,8 @@ declare const EntityMentionSchema: z.ZodObject<{
|
|
|
288
288
|
name: string;
|
|
289
289
|
facts: string[];
|
|
290
290
|
structuredSections?: {
|
|
291
|
-
key: string;
|
|
292
291
|
title: string;
|
|
292
|
+
key: string;
|
|
293
293
|
facts: string[];
|
|
294
294
|
}[] | null | undefined;
|
|
295
295
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -298,8 +298,8 @@ declare const EntityMentionSchema: z.ZodObject<{
|
|
|
298
298
|
name: string;
|
|
299
299
|
facts: string[];
|
|
300
300
|
structuredSections?: {
|
|
301
|
-
key: string;
|
|
302
301
|
title: string;
|
|
302
|
+
key: string;
|
|
303
303
|
facts: string[];
|
|
304
304
|
}[] | null | undefined;
|
|
305
305
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -584,12 +584,12 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
584
584
|
title: z.ZodString;
|
|
585
585
|
facts: z.ZodArray<z.ZodString, "many">;
|
|
586
586
|
}, "strip", z.ZodTypeAny, {
|
|
587
|
-
key: string;
|
|
588
587
|
title: string;
|
|
588
|
+
key: string;
|
|
589
589
|
facts: string[];
|
|
590
590
|
}, {
|
|
591
|
-
key: string;
|
|
592
591
|
title: string;
|
|
592
|
+
key: string;
|
|
593
593
|
facts: string[];
|
|
594
594
|
}>, "many">>>;
|
|
595
595
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -597,8 +597,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
597
597
|
name: string;
|
|
598
598
|
facts: string[];
|
|
599
599
|
structuredSections?: {
|
|
600
|
-
key: string;
|
|
601
600
|
title: string;
|
|
601
|
+
key: string;
|
|
602
602
|
facts: string[];
|
|
603
603
|
}[] | null | undefined;
|
|
604
604
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -607,8 +607,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
607
607
|
name: string;
|
|
608
608
|
facts: string[];
|
|
609
609
|
structuredSections?: {
|
|
610
|
-
key: string;
|
|
611
610
|
title: string;
|
|
611
|
+
key: string;
|
|
612
612
|
facts: string[];
|
|
613
613
|
}[] | null | undefined;
|
|
614
614
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -665,8 +665,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
665
665
|
name: string;
|
|
666
666
|
facts: string[];
|
|
667
667
|
structuredSections?: {
|
|
668
|
-
key: string;
|
|
669
668
|
title: string;
|
|
669
|
+
key: string;
|
|
670
670
|
facts: string[];
|
|
671
671
|
}[] | null | undefined;
|
|
672
672
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -714,8 +714,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
714
714
|
name: string;
|
|
715
715
|
facts: string[];
|
|
716
716
|
structuredSections?: {
|
|
717
|
-
key: string;
|
|
718
717
|
title: string;
|
|
718
|
+
key: string;
|
|
719
719
|
facts: string[];
|
|
720
720
|
}[] | null | undefined;
|
|
721
721
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -952,12 +952,12 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
952
952
|
title: z.ZodString;
|
|
953
953
|
facts: z.ZodArray<z.ZodString, "many">;
|
|
954
954
|
}, "strip", z.ZodTypeAny, {
|
|
955
|
-
key: string;
|
|
956
955
|
title: string;
|
|
956
|
+
key: string;
|
|
957
957
|
facts: string[];
|
|
958
958
|
}, {
|
|
959
|
-
key: string;
|
|
960
959
|
title: string;
|
|
960
|
+
key: string;
|
|
961
961
|
facts: string[];
|
|
962
962
|
}>, "many">>>;
|
|
963
963
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -965,8 +965,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
965
965
|
name: string;
|
|
966
966
|
facts: string[];
|
|
967
967
|
structuredSections?: {
|
|
968
|
-
key: string;
|
|
969
968
|
title: string;
|
|
969
|
+
key: string;
|
|
970
970
|
facts: string[];
|
|
971
971
|
}[] | null | undefined;
|
|
972
972
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -975,8 +975,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
975
975
|
name: string;
|
|
976
976
|
facts: string[];
|
|
977
977
|
structuredSections?: {
|
|
978
|
-
key: string;
|
|
979
978
|
title: string;
|
|
979
|
+
key: string;
|
|
980
980
|
facts: string[];
|
|
981
981
|
}[] | null | undefined;
|
|
982
982
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1047,8 +1047,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
1047
1047
|
name: string;
|
|
1048
1048
|
facts: string[];
|
|
1049
1049
|
structuredSections?: {
|
|
1050
|
-
key: string;
|
|
1051
1050
|
title: string;
|
|
1051
|
+
key: string;
|
|
1052
1052
|
facts: string[];
|
|
1053
1053
|
}[] | null | undefined;
|
|
1054
1054
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1102,8 +1102,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
1102
1102
|
name: string;
|
|
1103
1103
|
facts: string[];
|
|
1104
1104
|
structuredSections?: {
|
|
1105
|
-
key: string;
|
|
1106
1105
|
title: string;
|
|
1106
|
+
key: string;
|
|
1107
1107
|
facts: string[];
|
|
1108
1108
|
}[] | null | undefined;
|
|
1109
1109
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1172,12 +1172,12 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1172
1172
|
title: z.ZodString;
|
|
1173
1173
|
facts: z.ZodArray<z.ZodString, "many">;
|
|
1174
1174
|
}, "strip", z.ZodTypeAny, {
|
|
1175
|
-
key: string;
|
|
1176
1175
|
title: string;
|
|
1176
|
+
key: string;
|
|
1177
1177
|
facts: string[];
|
|
1178
1178
|
}, {
|
|
1179
|
-
key: string;
|
|
1180
1179
|
title: string;
|
|
1180
|
+
key: string;
|
|
1181
1181
|
facts: string[];
|
|
1182
1182
|
}>, "many">>>;
|
|
1183
1183
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1185,8 +1185,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1185
1185
|
name: string;
|
|
1186
1186
|
facts: string[];
|
|
1187
1187
|
structuredSections?: {
|
|
1188
|
-
key: string;
|
|
1189
1188
|
title: string;
|
|
1189
|
+
key: string;
|
|
1190
1190
|
facts: string[];
|
|
1191
1191
|
}[] | null | undefined;
|
|
1192
1192
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1195,8 +1195,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1195
1195
|
name: string;
|
|
1196
1196
|
facts: string[];
|
|
1197
1197
|
structuredSections?: {
|
|
1198
|
-
key: string;
|
|
1199
1198
|
title: string;
|
|
1199
|
+
key: string;
|
|
1200
1200
|
facts: string[];
|
|
1201
1201
|
}[] | null | undefined;
|
|
1202
1202
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1215,8 +1215,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1215
1215
|
name: string;
|
|
1216
1216
|
facts: string[];
|
|
1217
1217
|
structuredSections?: {
|
|
1218
|
-
key: string;
|
|
1219
1218
|
title: string;
|
|
1219
|
+
key: string;
|
|
1220
1220
|
facts: string[];
|
|
1221
1221
|
}[] | null | undefined;
|
|
1222
1222
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1235,8 +1235,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1235
1235
|
name: string;
|
|
1236
1236
|
facts: string[];
|
|
1237
1237
|
structuredSections?: {
|
|
1238
|
-
key: string;
|
|
1239
1238
|
title: string;
|
|
1239
|
+
key: string;
|
|
1240
1240
|
facts: string[];
|
|
1241
1241
|
}[] | null | undefined;
|
|
1242
1242
|
promptedByQuestion?: string | null | undefined;
|
package/dist/transfer/types.d.ts
CHANGED
|
@@ -313,13 +313,13 @@ declare const CapsuleBlockSchema: z.ZodObject<{
|
|
|
313
313
|
peerProfiles: boolean;
|
|
314
314
|
}>;
|
|
315
315
|
}, "strip", z.ZodTypeAny, {
|
|
316
|
+
schemaVersion: string;
|
|
316
317
|
includes: {
|
|
317
318
|
procedural: boolean;
|
|
318
319
|
taxonomy: boolean;
|
|
319
320
|
identityAnchors: boolean;
|
|
320
321
|
peerProfiles: boolean;
|
|
321
322
|
};
|
|
322
|
-
schemaVersion: string;
|
|
323
323
|
id: string;
|
|
324
324
|
description: string;
|
|
325
325
|
version: string;
|
|
@@ -334,13 +334,13 @@ declare const CapsuleBlockSchema: z.ZodObject<{
|
|
|
334
334
|
directAnswerEnabled: boolean;
|
|
335
335
|
};
|
|
336
336
|
}, {
|
|
337
|
+
schemaVersion: string;
|
|
337
338
|
includes: {
|
|
338
339
|
procedural: boolean;
|
|
339
340
|
taxonomy: boolean;
|
|
340
341
|
identityAnchors: boolean;
|
|
341
342
|
peerProfiles: boolean;
|
|
342
343
|
};
|
|
343
|
-
schemaVersion: string;
|
|
344
344
|
id: string;
|
|
345
345
|
description: string;
|
|
346
346
|
version: string;
|
|
@@ -464,13 +464,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
|
|
|
464
464
|
peerProfiles: boolean;
|
|
465
465
|
}>;
|
|
466
466
|
}, "strip", z.ZodTypeAny, {
|
|
467
|
+
schemaVersion: string;
|
|
467
468
|
includes: {
|
|
468
469
|
procedural: boolean;
|
|
469
470
|
taxonomy: boolean;
|
|
470
471
|
identityAnchors: boolean;
|
|
471
472
|
peerProfiles: boolean;
|
|
472
473
|
};
|
|
473
|
-
schemaVersion: string;
|
|
474
474
|
id: string;
|
|
475
475
|
description: string;
|
|
476
476
|
version: string;
|
|
@@ -485,13 +485,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
|
|
|
485
485
|
directAnswerEnabled: boolean;
|
|
486
486
|
};
|
|
487
487
|
}, {
|
|
488
|
+
schemaVersion: string;
|
|
488
489
|
includes: {
|
|
489
490
|
procedural: boolean;
|
|
490
491
|
taxonomy: boolean;
|
|
491
492
|
identityAnchors: boolean;
|
|
492
493
|
peerProfiles: boolean;
|
|
493
494
|
};
|
|
494
|
-
schemaVersion: string;
|
|
495
495
|
id: string;
|
|
496
496
|
description: string;
|
|
497
497
|
version: string;
|
|
@@ -518,13 +518,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
|
|
|
518
518
|
pluginVersion: string;
|
|
519
519
|
includesTranscripts: boolean;
|
|
520
520
|
capsule: {
|
|
521
|
+
schemaVersion: string;
|
|
521
522
|
includes: {
|
|
522
523
|
procedural: boolean;
|
|
523
524
|
taxonomy: boolean;
|
|
524
525
|
identityAnchors: boolean;
|
|
525
526
|
peerProfiles: boolean;
|
|
526
527
|
};
|
|
527
|
-
schemaVersion: string;
|
|
528
528
|
id: string;
|
|
529
529
|
description: string;
|
|
530
530
|
version: string;
|
|
@@ -551,13 +551,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
|
|
|
551
551
|
pluginVersion: string;
|
|
552
552
|
includesTranscripts: boolean;
|
|
553
553
|
capsule: {
|
|
554
|
+
schemaVersion: string;
|
|
554
555
|
includes: {
|
|
555
556
|
procedural: boolean;
|
|
556
557
|
taxonomy: boolean;
|
|
557
558
|
identityAnchors: boolean;
|
|
558
559
|
peerProfiles: boolean;
|
|
559
560
|
};
|
|
560
|
-
schemaVersion: string;
|
|
561
561
|
id: string;
|
|
562
562
|
description: string;
|
|
563
563
|
version: string;
|
|
@@ -683,13 +683,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
683
683
|
peerProfiles: boolean;
|
|
684
684
|
}>;
|
|
685
685
|
}, "strip", z.ZodTypeAny, {
|
|
686
|
+
schemaVersion: string;
|
|
686
687
|
includes: {
|
|
687
688
|
procedural: boolean;
|
|
688
689
|
taxonomy: boolean;
|
|
689
690
|
identityAnchors: boolean;
|
|
690
691
|
peerProfiles: boolean;
|
|
691
692
|
};
|
|
692
|
-
schemaVersion: string;
|
|
693
693
|
id: string;
|
|
694
694
|
description: string;
|
|
695
695
|
version: string;
|
|
@@ -704,13 +704,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
704
704
|
directAnswerEnabled: boolean;
|
|
705
705
|
};
|
|
706
706
|
}, {
|
|
707
|
+
schemaVersion: string;
|
|
707
708
|
includes: {
|
|
708
709
|
procedural: boolean;
|
|
709
710
|
taxonomy: boolean;
|
|
710
711
|
identityAnchors: boolean;
|
|
711
712
|
peerProfiles: boolean;
|
|
712
713
|
};
|
|
713
|
-
schemaVersion: string;
|
|
714
714
|
id: string;
|
|
715
715
|
description: string;
|
|
716
716
|
version: string;
|
|
@@ -737,13 +737,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
737
737
|
pluginVersion: string;
|
|
738
738
|
includesTranscripts: boolean;
|
|
739
739
|
capsule: {
|
|
740
|
+
schemaVersion: string;
|
|
740
741
|
includes: {
|
|
741
742
|
procedural: boolean;
|
|
742
743
|
taxonomy: boolean;
|
|
743
744
|
identityAnchors: boolean;
|
|
744
745
|
peerProfiles: boolean;
|
|
745
746
|
};
|
|
746
|
-
schemaVersion: string;
|
|
747
747
|
id: string;
|
|
748
748
|
description: string;
|
|
749
749
|
version: string;
|
|
@@ -770,13 +770,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
770
770
|
pluginVersion: string;
|
|
771
771
|
includesTranscripts: boolean;
|
|
772
772
|
capsule: {
|
|
773
|
+
schemaVersion: string;
|
|
773
774
|
includes: {
|
|
774
775
|
procedural: boolean;
|
|
775
776
|
taxonomy: boolean;
|
|
776
777
|
identityAnchors: boolean;
|
|
777
778
|
peerProfiles: boolean;
|
|
778
779
|
};
|
|
779
|
-
schemaVersion: string;
|
|
780
780
|
id: string;
|
|
781
781
|
description: string;
|
|
782
782
|
version: string;
|
|
@@ -815,13 +815,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
815
815
|
pluginVersion: string;
|
|
816
816
|
includesTranscripts: boolean;
|
|
817
817
|
capsule: {
|
|
818
|
+
schemaVersion: string;
|
|
818
819
|
includes: {
|
|
819
820
|
procedural: boolean;
|
|
820
821
|
taxonomy: boolean;
|
|
821
822
|
identityAnchors: boolean;
|
|
822
823
|
peerProfiles: boolean;
|
|
823
824
|
};
|
|
824
|
-
schemaVersion: string;
|
|
825
825
|
id: string;
|
|
826
826
|
description: string;
|
|
827
827
|
version: string;
|
|
@@ -854,13 +854,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
854
854
|
pluginVersion: string;
|
|
855
855
|
includesTranscripts: boolean;
|
|
856
856
|
capsule: {
|
|
857
|
+
schemaVersion: string;
|
|
857
858
|
includes: {
|
|
858
859
|
procedural: boolean;
|
|
859
860
|
taxonomy: boolean;
|
|
860
861
|
identityAnchors: boolean;
|
|
861
862
|
peerProfiles: boolean;
|
|
862
863
|
};
|
|
863
|
-
schemaVersion: string;
|
|
864
864
|
id: string;
|
|
865
865
|
description: string;
|
|
866
866
|
version: string;
|
package/package.json
CHANGED
|
@@ -135,6 +135,30 @@ function isDeferralActive(pair: ContradictionPair): boolean {
|
|
|
135
135
|
return deferredUntil !== null && Date.now() < deferredUntil;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
function isReviewActionable(pair: ContradictionPair): boolean {
|
|
139
|
+
return !isTerminalResolution(pair.resolution)
|
|
140
|
+
&& !isDeferralActive(pair)
|
|
141
|
+
&& pair.resolution !== "both-valid"
|
|
142
|
+
&& pair.verdict !== "independent";
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function compareReviewPairs(a: ContradictionPair, b: ContradictionPair): number {
|
|
146
|
+
const aActionable = isReviewActionable(a);
|
|
147
|
+
const bActionable = isReviewActionable(b);
|
|
148
|
+
if (aActionable !== bActionable) return aActionable ? -1 : 1;
|
|
149
|
+
|
|
150
|
+
const aDetectedAt = parseIsoMillis(a.detectedAt) ?? Number.POSITIVE_INFINITY;
|
|
151
|
+
const bDetectedAt = parseIsoMillis(b.detectedAt) ?? Number.POSITIVE_INFINITY;
|
|
152
|
+
if (aDetectedAt !== bDetectedAt) return aDetectedAt < bDetectedAt ? -1 : 1;
|
|
153
|
+
|
|
154
|
+
const aPairId = typeof a.pairId === "string" ? a.pairId : "";
|
|
155
|
+
const bPairId = typeof b.pairId === "string" ? b.pairId : "";
|
|
156
|
+
const pairIdOrder = aPairId.localeCompare(bPairId);
|
|
157
|
+
if (pairIdOrder !== 0) return pairIdOrder;
|
|
158
|
+
|
|
159
|
+
return a.memoryIds.join("\0").localeCompare(b.memoryIds.join("\0"));
|
|
160
|
+
}
|
|
161
|
+
|
|
138
162
|
function reviewStateMillis(pair: ContradictionPair): number {
|
|
139
163
|
return Math.max(
|
|
140
164
|
parseIsoMillis(pair.deferredUntil) ?? Number.NEGATIVE_INFINITY,
|
|
@@ -390,7 +414,7 @@ export function listPairs(
|
|
|
390
414
|
const startTime = Date.now();
|
|
391
415
|
const dir = reviewDir(memoryDir);
|
|
392
416
|
const { filter = "all", namespace, includeUnscopedForNamespace = false, limit = 50 } = options ?? {};
|
|
393
|
-
const
|
|
417
|
+
const matchingPairs: ContradictionPair[] = [];
|
|
394
418
|
let total = 0;
|
|
395
419
|
|
|
396
420
|
if (!fs.existsSync(dir)) {
|
|
@@ -423,12 +447,19 @@ export function listPairs(
|
|
|
423
447
|
}
|
|
424
448
|
|
|
425
449
|
total++;
|
|
426
|
-
|
|
450
|
+
matchingPairs.push(pair);
|
|
427
451
|
} catch {
|
|
428
452
|
continue;
|
|
429
453
|
}
|
|
430
454
|
}
|
|
431
455
|
|
|
456
|
+
matchingPairs.sort(compareReviewPairs);
|
|
457
|
+
const pairs: ContradictionPair[] = [];
|
|
458
|
+
for (const pair of matchingPairs) {
|
|
459
|
+
if (!(pairs.length < limit)) break;
|
|
460
|
+
pairs.push(pair);
|
|
461
|
+
}
|
|
462
|
+
|
|
432
463
|
return { pairs, total, durationMs: Date.now() - startTime };
|
|
433
464
|
}
|
|
434
465
|
|
|
@@ -545,12 +545,37 @@ test("listPairs filters by verdict", async () => {
|
|
|
545
545
|
test("listPairs respects limit", async () => {
|
|
546
546
|
const { dir, cleanup } = await makeTempDir();
|
|
547
547
|
try {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
548
|
+
const expectedFirst = writePair(dir, makePair({
|
|
549
|
+
memoryIds: ["a-first", "b-first"],
|
|
550
|
+
detectedAt: "2026-01-01T00:00:00.000Z",
|
|
551
|
+
}));
|
|
552
|
+
const expectedSecond = writePair(dir, makePair({
|
|
553
|
+
memoryIds: ["a-second", "b-second"],
|
|
554
|
+
detectedAt: "2026-01-02T00:00:00.000Z",
|
|
555
|
+
}));
|
|
556
|
+
const terminal = writePair(dir, makePair({
|
|
557
|
+
memoryIds: ["a-terminal", "b-terminal"],
|
|
558
|
+
detectedAt: "2025-01-01T00:00:00.000Z",
|
|
559
|
+
}));
|
|
560
|
+
resolvePair(dir, terminal.pairId, "keep-a");
|
|
561
|
+
writePair(dir, makePair({
|
|
562
|
+
memoryIds: ["a-independent", "b-independent"],
|
|
563
|
+
detectedAt: "2025-01-02T00:00:00.000Z",
|
|
564
|
+
verdict: "independent",
|
|
565
|
+
}));
|
|
566
|
+
writePair(dir, makePair({
|
|
567
|
+
memoryIds: ["a-third", "b-third"],
|
|
568
|
+
detectedAt: "2026-01-03T00:00:00.000Z",
|
|
569
|
+
}));
|
|
570
|
+
|
|
551
571
|
const result = listPairs(dir, { filter: "all", limit: 2 });
|
|
552
572
|
assert.equal(result.pairs.length, 2);
|
|
553
573
|
assert.equal(result.total, 5, "total should reflect all matching pairs, not just returned");
|
|
574
|
+
assert.deepEqual(
|
|
575
|
+
result.pairs.map((pair) => pair.pairId),
|
|
576
|
+
[expectedFirst.pairId, expectedSecond.pairId],
|
|
577
|
+
"limit should apply after deterministic review ordering, not raw directory order",
|
|
578
|
+
);
|
|
554
579
|
} finally {
|
|
555
580
|
await cleanup();
|
|
556
581
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contradiction/contradiction-review.ts"],"sourcesContent":["/**\n * Contradiction Review Queue — storage for detected contradiction pairs (issue #520).\n *\n * Stores candidate pairs as JSON files under `memoryDir/.review/contradictions/`.\n * Pair IDs are deterministic (sha256 of sorted memory IDs plus namespace when scoped) so reruns are idempotent.\n *\n * Lifecycle:\n * - `contradicts` → awaiting user review\n * - `duplicates` → auto-flagged for dedup (still needs user approval)\n * - `independent` / `both-valid` → dormant with cooldown\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { createHash, randomUUID } from \"node:crypto\";\nimport type { ContradictionVerdict } from \"./contradiction-judge.js\";\n\n// ── Types ──────────────────────────────────────────────────────────────────────\n\nexport type ResolutionVerb = \"keep-a\" | \"keep-b\" | \"merge\" | \"both-valid\" | \"needs-more-context\";\n\nconst VALID_RESOLUTION_VERBS: readonly ResolutionVerb[] = [\n \"keep-a\",\n \"keep-b\",\n \"merge\",\n \"both-valid\",\n \"needs-more-context\",\n];\n\nexport interface ContradictionPair {\n /** Deterministic pair ID: sha256(sorted(memoryIdA, memoryIdB) plus namespace when scoped). */\n pairId: string;\n /** Memory IDs (sorted). */\n memoryIds: [string, string];\n /** Judge verdict. */\n verdict: ContradictionVerdict;\n /** Judge rationale. */\n rationale: string;\n /** Judge confidence in [0, 1]. */\n confidence: number;\n /** ISO timestamp when detected. */\n detectedAt: string;\n /** ISO timestamp when last reviewed by user. */\n lastReviewedAt?: string;\n /** Resolution verb applied by user. */\n resolution?: ResolutionVerb;\n /** ISO timestamp until which a non-terminal deferral remains hidden from review. */\n deferredUntil?: string;\n /** Content hashes captured for each referenced memory when this pair was judged. */\n memoryContentHashes?: Record<string, string>;\n /** Namespace scope. */\n namespace?: string;\n}\n\nexport interface ContradictionListResult {\n pairs: ContradictionPair[];\n total: number;\n durationMs: number;\n}\n\nexport type ContradictionFilter = ContradictionVerdict | \"all\" | \"unresolved\";\nexport interface WritePairOptions {\n /** Cooldown used by scan callers to preserve still-dormant reviewed pairs. */\n cooldownDays?: number;\n}\nconst NEEDS_MORE_CONTEXT_COOLDOWN_MS = 24 * 60 * 60 * 1000;\nconst UNSCOPED_MIGRATION_MARKER_PREFIX = \".unscoped-migrated-\";\nconst UNSCOPED_MIGRATION_MARKER_SUFFIX = \".done\";\n\n// ── Helpers ────────────────────────────────────────────────────────────────────\n\nexport function computePairId(memoryIdA: string, memoryIdB: string, namespace?: string): string {\n const sorted = [memoryIdA, memoryIdB].sort();\n const normalizedNamespace = namespace?.trim();\n const scope = normalizedNamespace ? `ns:${normalizedNamespace}::` : \"\";\n return createHash(\"sha256\").update(`${scope}${sorted.join(\"::\")}`).digest(\"hex\").slice(0, 24);\n}\n\nexport function isDefaultReviewNamespace(\n defaultNamespace: string,\n requestedNamespace: string | undefined,\n resolvedNamespace: string,\n): boolean {\n const requested = requestedNamespace?.trim();\n return !requested || requested === defaultNamespace || resolvedNamespace === defaultNamespace;\n}\n\nfunction isTerminalResolution(resolution: ResolutionVerb | undefined): boolean {\n return resolution === \"keep-a\" || resolution === \"keep-b\" || resolution === \"merge\";\n}\n\nfunction preservesDirectResolution(resolution: ResolutionVerb | undefined): boolean {\n return isTerminalResolution(resolution) || resolution === \"both-valid\";\n}\n\nfunction isDormantReviewedPair(pair: ContradictionPair): boolean {\n return pair.verdict === \"independent\" || pair.resolution === \"both-valid\";\n}\n\nfunction reviewStateRank(pair: ContradictionPair, cooldownDays?: number): number {\n if (isTerminalResolution(pair.resolution)) return 5;\n if (pair.resolution === \"both-valid\") return 4;\n if (isDeferralActive(pair)) return 3;\n if (isDormantReviewedPair(pair)) {\n if (cooldownDays === undefined) return 2;\n return isCoolingDown(pair, cooldownDays) ? 2 : 0;\n }\n return 1;\n}\n\nfunction parseIsoMillis(value: string | undefined): number | null {\n if (!value) return null;\n const millis = new Date(value).getTime();\n return Number.isFinite(millis) ? millis : null;\n}\n\nfunction isDeferred(pair: Pick<ContradictionPair, \"resolution\" | \"deferredUntil\">): boolean {\n return pair.resolution === \"needs-more-context\" || Boolean(pair.deferredUntil);\n}\n\nfunction deferralUntilMillis(pair: ContradictionPair): number | null {\n const deferredUntil = parseIsoMillis(pair.deferredUntil);\n if (deferredUntil !== null) return deferredUntil;\n\n if (pair.resolution === \"needs-more-context\") {\n const lastReviewed = parseIsoMillis(pair.lastReviewedAt);\n return lastReviewed === null ? null : lastReviewed + NEEDS_MORE_CONTEXT_COOLDOWN_MS;\n }\n\n return null;\n}\n\nfunction isDeferralActive(pair: ContradictionPair): boolean {\n const deferredUntil = deferralUntilMillis(pair);\n return deferredUntil !== null && Date.now() < deferredUntil;\n}\n\nfunction reviewStateMillis(pair: ContradictionPair): number {\n return Math.max(\n parseIsoMillis(pair.deferredUntil) ?? Number.NEGATIVE_INFINITY,\n parseIsoMillis(pair.lastReviewedAt) ?? Number.NEGATIVE_INFINITY,\n parseIsoMillis(pair.detectedAt) ?? Number.NEGATIVE_INFINITY,\n );\n}\n\nfunction mergeMigratedPair(existing: ContradictionPair, migrated: ContradictionPair, options: WritePairOptions): ContradictionPair {\n const existingRank = reviewStateRank(existing, options.cooldownDays);\n const migratedRank = reviewStateRank(migrated, options.cooldownDays);\n const selected = migratedRank > existingRank\n ? migrated\n : migratedRank < existingRank\n ? existing\n : reviewStateMillis(migrated) > reviewStateMillis(existing)\n ? migrated\n : existing;\n\n return {\n ...selected,\n pairId: migrated.pairId,\n namespace: migrated.namespace,\n };\n}\n\nfunction reviewDir(memoryDir: string): string {\n return path.join(memoryDir, \".review\", \"contradictions\");\n}\n\nfunction migrationMarkerPath(memoryDir: string, namespace: string): string {\n const namespaceKey = createHash(\"sha256\").update(namespace).digest(\"hex\").slice(0, 16);\n return path.join(reviewDir(memoryDir), `${UNSCOPED_MIGRATION_MARKER_PREFIX}${namespaceKey}${UNSCOPED_MIGRATION_MARKER_SUFFIX}`);\n}\n\nfunction clearUnscopedMigrationMarkers(memoryDir: string): void {\n const dir = reviewDir(memoryDir);\n if (!fs.existsSync(dir)) return;\n\n try {\n for (const entry of fs.readdirSync(dir)) {\n if (entry.startsWith(UNSCOPED_MIGRATION_MARKER_PREFIX) && entry.endsWith(UNSCOPED_MIGRATION_MARKER_SUFFIX)) {\n fs.rmSync(path.join(dir, entry), { force: true });\n }\n }\n } catch {\n // Marker cleanup is best-effort. The next migration/list call can recover.\n }\n}\n\nfunction pairPath(memoryDir: string, pairId: string): string {\n if (pairId.includes(\"/\") || pairId.includes(\"\\\\\") || pairId.includes(\"..\")) {\n throw new Error(`Invalid pairId: ${pairId}`);\n }\n return path.join(reviewDir(memoryDir), `${pairId}.json`);\n}\n\nfunction isSafeReviewJsonFile(memoryDir: string, filePath: string): boolean {\n const root = path.resolve(reviewDir(memoryDir));\n const resolved = path.resolve(filePath);\n const relative = path.relative(root, resolved);\n if (relative === \"\" || relative.startsWith(\"..\") || path.isAbsolute(relative)) {\n return false;\n }\n\n try {\n return fs.lstatSync(resolved).isFile();\n } catch {\n return false;\n }\n}\n\nfunction ensureDir(memoryDir: string): void {\n const dir = reviewDir(memoryDir);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n}\n\nfunction uniqueTempPath(filePath: string): string {\n return `${filePath}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`;\n}\n\nfunction writePairFile(filePath: string, pair: ContradictionPair): void {\n const tmpPath = uniqueTempPath(filePath);\n try {\n fs.writeFileSync(tmpPath, JSON.stringify(pair, null, 2), \"utf-8\");\n fs.renameSync(tmpPath, filePath);\n } catch (error) {\n try {\n fs.rmSync(tmpPath, { force: true });\n } catch {\n // Best-effort cleanup only; preserve the original write failure.\n }\n throw error;\n }\n}\n\nexport function computeMemoryContentHash(content: string, category?: string): string {\n const normalized = JSON.stringify({\n content: content.trim(),\n category: (category ?? \"\").trim(),\n });\n return createHash(\"sha256\").update(normalized).digest(\"hex\").slice(0, 16);\n}\n\nfunction suppliedMemoryHashesChanged(\n existing: ContradictionPair,\n pair: Omit<ContradictionPair, \"pairId\"> & { memoryIds: [string, string] },\n): boolean {\n if (!existing.memoryContentHashes || !pair.memoryContentHashes) return false;\n return pair.memoryIds.some((memoryId) => {\n const current = pair.memoryContentHashes?.[memoryId];\n return typeof current === \"string\" && existing.memoryContentHashes?.[memoryId] !== current;\n });\n}\n\n// ── Write ──────────────────────────────────────────────────────────────────────\n\n/**\n * Write a contradiction pair to the review queue.\n * Idempotent: if the pair already exists with a higher or equal confidence,\n * the existing entry is preserved.\n */\nexport function writePair(\n memoryDir: string,\n pair: Omit<ContradictionPair, \"pairId\"> & { memoryIds: [string, string] },\n options: WritePairOptions = {},\n): ContradictionPair {\n ensureDir(memoryDir);\n if (pair.namespace === undefined) {\n clearUnscopedMigrationMarkers(memoryDir);\n }\n const pairId = computePairId(pair.memoryIds[0], pair.memoryIds[1], pair.namespace);\n const existing = readPair(memoryDir, pairId);\n\n // Preserve terminal user resolutions if already reviewed.\n if (isTerminalResolution(existing?.resolution)) {\n return existing!;\n }\n const contentChanged = Boolean(existing && suppliedMemoryHashesChanged(existing, pair));\n if (existing?.resolution === \"both-valid\" && options.cooldownDays === undefined && !contentChanged) {\n return existing;\n }\n\n // Preserve active deferrals, but allow expired deferrals to be refreshed.\n const existingDeferralExpired = Boolean(existing && isDeferred(existing) && !isDeferralActive(existing));\n if (existing && isDeferralActive(existing) && !contentChanged) {\n return existing;\n }\n\n // Preserve same-verdict or still-cooling entries, but let expired dormant\n // verdicts refresh when the judge now finds an actionable conflict.\n const existingDormantCooldownActive = Boolean(\n existing\n && isDormantReviewedPair(existing)\n && options.cooldownDays !== undefined\n && isCoolingDown(existing, options.cooldownDays),\n );\n const dormantContentChanged = Boolean(\n existing\n && existingDormantCooldownActive\n && contentChanged,\n );\n const existingDormantExpired = Boolean(\n existing\n && isDormantReviewedPair(existing)\n && options.cooldownDays !== undefined\n && !existingDormantCooldownActive,\n );\n if (\n existing\n && !existingDeferralExpired\n && (\n (existingDormantCooldownActive && !dormantContentChanged)\n || (!existingDormantExpired && !contentChanged && existing.confidence >= pair.confidence)\n )\n ) {\n return existing;\n }\n\n const full: ContradictionPair = {\n ...pair,\n pairId,\n lastReviewedAt: (existingDeferralExpired || existingDormantExpired || contentChanged)\n ? pair.lastReviewedAt\n : (existing?.lastReviewedAt ?? pair.lastReviewedAt),\n resolution: undefined,\n deferredUntil: (existingDeferralExpired || existingDormantExpired || contentChanged)\n ? undefined\n : existing?.deferredUntil,\n };\n\n const filePath = pairPath(memoryDir, pairId);\n writePairFile(filePath, full);\n\n return full;\n}\n\n/**\n * Write multiple pairs, deduplicating inputs first (rule 49).\n */\nexport function writePairs(\n memoryDir: string,\n pairs: Array<Omit<ContradictionPair, \"pairId\"> & { memoryIds: [string, string] }>,\n options: WritePairOptions = {},\n): ContradictionPair[] {\n const seen = new Set<string>();\n const results: ContradictionPair[] = [];\n\n for (const pair of pairs) {\n const key = computePairId(pair.memoryIds[0], pair.memoryIds[1], pair.namespace);\n if (seen.has(key)) continue;\n seen.add(key);\n results.push(writePair(memoryDir, pair, options));\n }\n\n return results;\n}\n\n// ── Read ───────────────────────────────────────────────────────────────────────\n\n/**\n * Read a single pair by ID. Returns null if not found.\n */\nexport function readPair(memoryDir: string, pairId: string): ContradictionPair | null {\n const filePath = pairPath(memoryDir, pairId);\n try {\n if (!isSafeReviewJsonFile(memoryDir, filePath)) return null;\n const raw = fs.readFileSync(filePath, \"utf-8\");\n const parsed = JSON.parse(raw);\n if (typeof parsed === \"object\" && parsed !== null && Array.isArray(parsed.memoryIds)) {\n return parsed as ContradictionPair;\n }\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * List pairs in the review queue, optionally filtered by verdict.\n */\nexport function listPairs(\n memoryDir: string,\n options?: {\n filter?: ContradictionFilter;\n namespace?: string;\n includeUnscopedForNamespace?: boolean;\n limit?: number;\n },\n): ContradictionListResult {\n const startTime = Date.now();\n const dir = reviewDir(memoryDir);\n const { filter = \"all\", namespace, includeUnscopedForNamespace = false, limit = 50 } = options ?? {};\n const pairs: ContradictionPair[] = [];\n let total = 0;\n\n if (!fs.existsSync(dir)) {\n return { pairs: [], total: 0, durationMs: Date.now() - startTime };\n }\n\n for (const entry of fs.readdirSync(dir)) {\n if (!entry.endsWith(\".json\")) continue;\n\n try {\n const filePath = path.join(dir, entry);\n if (!isSafeReviewJsonFile(memoryDir, filePath)) continue;\n const raw = fs.readFileSync(filePath, \"utf-8\");\n const pair = JSON.parse(raw) as ContradictionPair;\n\n if (typeof pair !== \"object\" || pair === null) continue;\n if (!Array.isArray(pair.memoryIds)) continue;\n\n // Namespace filter\n if (namespace && pair.namespace !== namespace && !(includeUnscopedForNamespace && pair.namespace === undefined)) continue;\n\n // Verdict filter\n if (filter === \"unresolved\") {\n if (isTerminalResolution(pair.resolution)) continue;\n if (isDeferralActive(pair)) continue;\n if (pair.resolution === \"both-valid\") continue;\n if (pair.verdict === \"independent\") continue;\n } else if (filter !== \"all\" && pair.verdict !== filter) {\n continue;\n }\n\n total++;\n if (pairs.length < limit) pairs.push(pair);\n } catch {\n continue;\n }\n }\n\n return { pairs, total, durationMs: Date.now() - startTime };\n}\n\nexport function migrateUnscopedPairsToNamespace(memoryDir: string, namespace: string, options: WritePairOptions = {}): number {\n const resolvedNamespace = namespace.trim();\n if (!resolvedNamespace) return 0;\n\n const dir = reviewDir(memoryDir);\n if (!fs.existsSync(dir)) return 0;\n const markerPath = migrationMarkerPath(memoryDir, resolvedNamespace);\n if (fs.existsSync(markerPath)) return 0;\n\n let migrated = 0;\n let hadMigrationFailure = false;\n for (const entry of fs.readdirSync(dir)) {\n if (!entry.endsWith(\".json\")) continue;\n const filePath = path.join(dir, entry);\n\n try {\n if (!isSafeReviewJsonFile(memoryDir, filePath)) continue;\n const raw = fs.readFileSync(filePath, \"utf-8\");\n const pair = JSON.parse(raw) as ContradictionPair;\n if (typeof pair !== \"object\" || pair === null) continue;\n if (!Array.isArray(pair.memoryIds)) continue;\n if (pair.namespace !== undefined) continue;\n\n const pairId = computePairId(pair.memoryIds[0], pair.memoryIds[1], resolvedNamespace);\n const migratedPair = { ...pair, namespace: resolvedNamespace, pairId };\n const targetPath = pairPath(memoryDir, pairId);\n try {\n if (targetPath === filePath) {\n writePairFile(filePath, migratedPair);\n } else if (!fs.existsSync(targetPath)) {\n writePairFile(targetPath, migratedPair);\n fs.rmSync(filePath, { force: true });\n } else {\n if (!isSafeReviewJsonFile(memoryDir, targetPath)) {\n hadMigrationFailure = true;\n continue;\n }\n const existing = readPair(memoryDir, pairId);\n writePairFile(targetPath, existing ? mergeMigratedPair(existing, migratedPair, options) : migratedPair);\n fs.rmSync(filePath, { force: true });\n }\n migrated += 1;\n } catch {\n hadMigrationFailure = true;\n continue;\n }\n } catch {\n continue;\n }\n }\n\n if (!hadMigrationFailure) {\n try {\n fs.writeFileSync(markerPath, `${new Date().toISOString()}\\n`, { encoding: \"utf-8\", flag: \"wx\" });\n } catch {\n // Another caller may have completed the same one-shot migration first.\n }\n }\n\n return migrated;\n}\n\n// ── Cooldown ───────────────────────────────────────────────────────────────────\n\n/**\n * Check if a pair is within its cooldown window.\n * Returns true if the pair should be SKIPPED (still cooling down).\n */\nexport function isCoolingDown(pair: ContradictionPair, cooldownDays: number): boolean {\n if (cooldownDays <= 0) return false; // rule 27: guard against 0\n\n const deferredUntil = deferralUntilMillis(pair);\n if (deferredUntil !== null) {\n return Date.now() < deferredUntil;\n }\n\n if (!pair.lastReviewedAt) return false;\n\n const lastReviewed = parseIsoMillis(pair.lastReviewedAt);\n if (lastReviewed === null) return false;\n\n const cooldownMs = cooldownDays * 24 * 60 * 60 * 1000;\n return Date.now() < lastReviewed + cooldownMs;\n}\n\n/**\n * Mark a pair as reviewed (sets lastReviewedAt and, for terminal verbs, resolution).\n */\nexport function resolvePair(\n memoryDir: string,\n pairId: string,\n verb: ResolutionVerb,\n): ContradictionPair | null {\n if (typeof verb !== \"string\" || !VALID_RESOLUTION_VERBS.includes(verb)) {\n throw new Error(`Invalid contradiction resolution verb: ${String(verb)}`);\n }\n\n if (verb === \"needs-more-context\") {\n return deferPair(memoryDir, pairId);\n }\n\n const existing = readPair(memoryDir, pairId);\n if (!existing) return null;\n if (preservesDirectResolution(existing.resolution)) return existing;\n\n const updated: ContradictionPair = {\n ...existing,\n lastReviewedAt: new Date().toISOString(),\n resolution: verb,\n deferredUntil: undefined,\n };\n\n const filePath = pairPath(memoryDir, pairId);\n writePairFile(filePath, updated);\n\n return updated;\n}\n\n/**\n * Defer a pair without terminally resolving it.\n */\nexport function deferPair(\n memoryDir: string,\n pairId: string,\n deferredUntil = new Date(Date.now() + NEEDS_MORE_CONTEXT_COOLDOWN_MS).toISOString(),\n): ContradictionPair | null {\n const existing = readPair(memoryDir, pairId);\n if (!existing) return null;\n if (preservesDirectResolution(existing.resolution)) return existing;\n\n const updated: ContradictionPair = {\n ...existing,\n lastReviewedAt: new Date().toISOString(),\n resolution: undefined,\n deferredUntil,\n };\n\n const filePath = pairPath(memoryDir, pairId);\n writePairFile(filePath, updated);\n\n return updated;\n}\n\n/**\n * Check whether a pair's referenced memories have changed since detection,\n * which should override cooldown.\n */\nexport function memoryHashesChanged(\n _memoryDir: string,\n pair: ContradictionPair,\n getCurrentHash: (memoryId: string) => string | null,\n): boolean {\n if (!pair.memoryContentHashes) return false;\n\n for (const memoryId of pair.memoryIds) {\n const previousHash = pair.memoryContentHashes[memoryId];\n if (typeof previousHash !== \"string\") continue;\n\n const currentHash = getCurrentHash(memoryId);\n if (currentHash !== null && currentHash !== previousHash) return true;\n }\n\n return false;\n}\n"],"mappings":";AAYA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,YAAY,kBAAkB;AAOvC,IAAM,yBAAoD;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAsCA,IAAM,iCAAiC,KAAK,KAAK,KAAK;AACtD,IAAM,mCAAmC;AACzC,IAAM,mCAAmC;AAIlC,SAAS,cAAc,WAAmB,WAAmB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SAAU,QAAO;AACtB,MAAI,0BAA0B,SAAS,UAAU,EAAG,QAAO;AAE3D,QAAM,UAA6B;AAAA,IACjC,GAAG;AAAA,IACH,iBAAgB,oBAAI,KAAK,GAAE,YAAY;AAAA,IACvC,YAAY;AAAA,IACZ,eAAe;AAAA,EACjB;AAEA,QAAM,WAAW,SAAS,WAAW,MAAM;AAC3C,gBAAc,UAAU,OAAO;AAE/B,SAAO;AACT;AAKO,SAAS,UACd,WACA,QACA,gBAAgB,IAAI,KAAK,KAAK,IAAI,IAAI,8BAA8B,EAAE,YAAY,GACxD;AAC1B,QAAM,WAAW,SAAS,WAAW,MAAM;AAC3C,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,0BAA0B,SAAS,UAAU,EAAG,QAAO;AAE3D,QAAM,UAA6B;AAAA,IACjC,GAAG;AAAA,IACH,iBAAgB,oBAAI,KAAK,GAAE,YAAY;AAAA,IACvC,YAAY;AAAA,IACZ;AAAA,EACF;AAEA,QAAM,WAAW,SAAS,WAAW,MAAM;AAC3C,gBAAc,UAAU,OAAO;AAE/B,SAAO;AACT;AAMO,SAAS,oBACd,YACA,MACA,gBACS;AACT,MAAI,CAAC,KAAK,oBAAqB,QAAO;AAEtC,aAAW,YAAY,KAAK,WAAW;AACrC,UAAM,eAAe,KAAK,oBAAoB,QAAQ;AACtD,QAAI,OAAO,iBAAiB,SAAU;AAEtC,UAAM,cAAc,eAAe,QAAQ;AAC3C,QAAI,gBAAgB,QAAQ,gBAAgB,aAAc,QAAO;AAAA,EACnE;AAEA,SAAO;AACT;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|