@edihasaj/recall 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-G44JMYVI.js → chunk-53GKSF42.js} +6 -6
- package/dist/{chunk-5FY3HYGU.js → chunk-65XK27KK.js} +127 -44
- package/dist/chunk-65XK27KK.js.map +1 -0
- package/dist/{chunk-NFCBG4OH.js → chunk-6QFOCUEJ.js} +10 -10
- package/dist/chunk-6QFOCUEJ.js.map +1 -0
- package/dist/{chunk-UUCSHXES.js → chunk-7Q5CBVUT.js} +20 -9
- package/dist/{chunk-UUCSHXES.js.map → chunk-7Q5CBVUT.js.map} +1 -1
- package/dist/{chunk-KD4OKHYF.js → chunk-JKWK73GY.js} +7 -2
- package/dist/chunk-JKWK73GY.js.map +1 -0
- package/dist/{chunk-B6KSSZUW.js → chunk-JO5LRCA2.js} +2 -6
- package/dist/{chunk-B6KSSZUW.js.map → chunk-JO5LRCA2.js.map} +1 -1
- package/dist/{chunk-JP5YAQPQ.js → chunk-JSTZKFZR.js} +3 -3
- package/dist/{chunk-T5FOKQH2.js → chunk-MMYLXICL.js} +2 -2
- package/dist/{chunk-TUC6GU35.js → chunk-UWERS646.js} +3 -3
- package/dist/{cleanup-PT3VB3CG.js → cleanup-RHNBHBNP.js} +4 -4
- package/dist/cli.js +24 -22
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +25 -11
- package/dist/daemon.js.map +1 -1
- package/dist/{dispatcher-2Q6LY57F.js → dispatcher-ON7LNX6X.js} +4 -4
- package/dist/{embeddings-CLBTYK7N.js → embeddings-HDNAGCOS.js} +2 -2
- package/dist/{ingest-ERAUAPMC.js → ingest-MHPMJPUA.js} +3 -3
- package/dist/mcp.js +7 -7
- package/dist/{memory-value-2NDAQNMS.js → memory-value-6JUQEYJZ.js} +4 -4
- package/dist/{quality-WFWVU4FQ.js → quality-HVTIOIXP.js} +5 -5
- package/dist/{retrieval-JOC63UXZ.js → retrieval-72EIHKRF.js} +4 -4
- package/dist/{tasks-ANFQXOYX.js → tasks-AJ62N26N.js} +4 -4
- package/dist/webui/assets/{index-DSV5JHmg.css → GraphPage-B5DZHykP.css} +1 -1
- package/dist/webui/assets/GraphPage-DJhwG-72.js +5165 -0
- package/dist/webui/assets/GraphPage-DJhwG-72.js.map +1 -0
- package/dist/webui/assets/index-CVWARq15.css +1 -0
- package/dist/webui/assets/index-Cpn2MjW0.js +186 -0
- package/dist/webui/assets/index-Cpn2MjW0.js.map +1 -0
- package/dist/webui/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-5FY3HYGU.js.map +0 -1
- package/dist/chunk-KD4OKHYF.js.map +0 -1
- package/dist/chunk-NFCBG4OH.js.map +0 -1
- package/dist/webui/assets/index-2DR_ysOm.js +0 -5348
- package/dist/webui/assets/index-2DR_ysOm.js.map +0 -1
- /package/dist/{chunk-G44JMYVI.js.map → chunk-53GKSF42.js.map} +0 -0
- /package/dist/{chunk-JP5YAQPQ.js.map → chunk-JSTZKFZR.js.map} +0 -0
- /package/dist/{chunk-T5FOKQH2.js.map → chunk-MMYLXICL.js.map} +0 -0
- /package/dist/{chunk-TUC6GU35.js.map → chunk-UWERS646.js.map} +0 -0
- /package/dist/{cleanup-PT3VB3CG.js.map → cleanup-RHNBHBNP.js.map} +0 -0
- /package/dist/{dispatcher-2Q6LY57F.js.map → dispatcher-ON7LNX6X.js.map} +0 -0
- /package/dist/{embeddings-CLBTYK7N.js.map → embeddings-HDNAGCOS.js.map} +0 -0
- /package/dist/{ingest-ERAUAPMC.js.map → ingest-MHPMJPUA.js.map} +0 -0
- /package/dist/{memory-value-2NDAQNMS.js.map → memory-value-6JUQEYJZ.js.map} +0 -0
- /package/dist/{quality-WFWVU4FQ.js.map → quality-HVTIOIXP.js.map} +0 -0
- /package/dist/{retrieval-JOC63UXZ.js.map → retrieval-72EIHKRF.js.map} +0 -0
- /package/dist/{tasks-ANFQXOYX.js.map → tasks-AJ62N26N.js.map} +0 -0
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
listInjectedHistoryIdsForSession,
|
|
12
12
|
signalOutcomeFallback,
|
|
13
13
|
startSessionLifecycle
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-7Q5CBVUT.js";
|
|
15
15
|
import {
|
|
16
16
|
detectCorrections,
|
|
17
17
|
isHighRiskRule,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
isWorkspaceRootAlias,
|
|
20
20
|
peekTasks,
|
|
21
21
|
redactSensitiveText
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-65XK27KK.js";
|
|
23
23
|
import {
|
|
24
24
|
detectAndRecordRetrievalMissesSemantic,
|
|
25
25
|
listInjectedMemoryIdsForSession,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
pathMatchesMemory,
|
|
28
28
|
recordCompletionUseValueEventsSemantic,
|
|
29
29
|
toolCallTouchesMemory
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-JSTZKFZR.js";
|
|
31
31
|
import {
|
|
32
32
|
textMatches
|
|
33
33
|
} from "./chunk-FHEH6QDU.js";
|
|
@@ -37,10 +37,10 @@ import {
|
|
|
37
37
|
import {
|
|
38
38
|
hookCallDedupeKey,
|
|
39
39
|
queryMemories
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-JO5LRCA2.js";
|
|
41
41
|
import {
|
|
42
42
|
tagActivitySource
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-JKWK73GY.js";
|
|
44
44
|
import {
|
|
45
45
|
and,
|
|
46
46
|
eq,
|
|
@@ -1196,4 +1196,4 @@ export {
|
|
|
1196
1196
|
readCodexSessionEndInputFromStdin,
|
|
1197
1197
|
dispatchCodexNotify
|
|
1198
1198
|
};
|
|
1199
|
-
//# sourceMappingURL=chunk-
|
|
1199
|
+
//# sourceMappingURL=chunk-53GKSF42.js.map
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
defineOwn,
|
|
13
13
|
demoteMemory,
|
|
14
14
|
getMemory,
|
|
15
|
-
getMemoryFeedback,
|
|
16
15
|
incrementMemoryRepetition,
|
|
17
16
|
listMemories,
|
|
18
17
|
memoryDedupeKey,
|
|
@@ -21,7 +20,7 @@ import {
|
|
|
21
20
|
queryMemories,
|
|
22
21
|
restoreAutoInject,
|
|
23
22
|
updateMemoryCaptureContext
|
|
24
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-JO5LRCA2.js";
|
|
25
24
|
import {
|
|
26
25
|
CONFIDENCE,
|
|
27
26
|
LlmCredentialError,
|
|
@@ -31,7 +30,7 @@ import {
|
|
|
31
30
|
findSimilarRejectedExemplar,
|
|
32
31
|
loadEmbeddingConfigFromEnv,
|
|
33
32
|
queueMemoryEmbeddingSync
|
|
34
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-JKWK73GY.js";
|
|
35
34
|
import {
|
|
36
35
|
hasProviderConfigured,
|
|
37
36
|
init_keychain
|
|
@@ -204,13 +203,51 @@ function computeHealthScore(db, memoryId) {
|
|
|
204
203
|
}
|
|
205
204
|
function computeAllHealthScores(db, repo) {
|
|
206
205
|
const mems = repo ? queryMemories(db, { repo }) : listMemories(db);
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
const feedbackRows = db.select({
|
|
207
|
+
memory_id: feedbackEvents.memory_id,
|
|
208
|
+
outcome: feedbackEvents.outcome,
|
|
209
|
+
count: sql`count(*)`
|
|
210
|
+
}).from(feedbackEvents).innerJoin(memories, eq(feedbackEvents.memory_id, memories.id)).where(repo ? eq(memories.repo, repo) : void 0).groupBy(feedbackEvents.memory_id, feedbackEvents.outcome).all();
|
|
211
|
+
const signalRows = db.select({
|
|
212
|
+
memory_id: implicitSignals.memory_id,
|
|
213
|
+
signal_type: implicitSignals.signal_type,
|
|
214
|
+
count: sql`count(*)`
|
|
215
|
+
}).from(implicitSignals).innerJoin(memories, eq(implicitSignals.memory_id, memories.id)).where(repo ? eq(memories.repo, repo) : void 0).groupBy(implicitSignals.memory_id, implicitSignals.signal_type).all();
|
|
216
|
+
const feedbackByMemory = /* @__PURE__ */ new Map();
|
|
217
|
+
for (const row of feedbackRows) {
|
|
218
|
+
const summary = feedbackByMemory.get(row.memory_id) ?? { followed: 0, total: 0 };
|
|
219
|
+
summary.total += row.count;
|
|
220
|
+
if (row.outcome === "followed") summary.followed += row.count;
|
|
221
|
+
feedbackByMemory.set(row.memory_id, summary);
|
|
212
222
|
}
|
|
213
|
-
|
|
223
|
+
const signalsByMemory = /* @__PURE__ */ new Map();
|
|
224
|
+
for (const row of signalRows) {
|
|
225
|
+
const summary = signalsByMemory.get(row.memory_id) ?? { positive: 0, total: 0 };
|
|
226
|
+
summary.total += row.count;
|
|
227
|
+
if (["test_pass", "file_unchanged", "task_accepted"].includes(row.signal_type)) {
|
|
228
|
+
summary.positive += row.count;
|
|
229
|
+
}
|
|
230
|
+
signalsByMemory.set(row.memory_id, summary);
|
|
231
|
+
}
|
|
232
|
+
return mems.filter((mem) => mem.status !== "rejected").map((mem) => {
|
|
233
|
+
const feedback = feedbackByMemory.get(mem.id);
|
|
234
|
+
const signals = signalsByMemory.get(mem.id);
|
|
235
|
+
const confidence = mem.confidence;
|
|
236
|
+
const freshness = computeFreshness(mem);
|
|
237
|
+
const followRate = feedback && feedback.total > 0 ? feedback.followed / feedback.total : 0.5;
|
|
238
|
+
const signalRatio = signals && signals.total > 0 ? signals.positive / signals.total : 0.5;
|
|
239
|
+
return {
|
|
240
|
+
memory_id: mem.id,
|
|
241
|
+
score: clamp(
|
|
242
|
+
WEIGHTS.confidence * confidence + WEIGHTS.freshness * freshness + WEIGHTS.follow_rate * followRate + WEIGHTS.signal_ratio * signalRatio
|
|
243
|
+
),
|
|
244
|
+
confidence_component: confidence,
|
|
245
|
+
freshness_component: freshness,
|
|
246
|
+
follow_rate_component: followRate,
|
|
247
|
+
signal_ratio_component: signalRatio,
|
|
248
|
+
computed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
249
|
+
};
|
|
250
|
+
}).sort((a, b) => b.score - a.score);
|
|
214
251
|
}
|
|
215
252
|
function computeFreshness(mem) {
|
|
216
253
|
const now = Date.now();
|
|
@@ -270,16 +307,16 @@ function getRepoQualityProfile(db, repo) {
|
|
|
270
307
|
if (!repo) {
|
|
271
308
|
return defaultProfile();
|
|
272
309
|
}
|
|
273
|
-
const
|
|
274
|
-
const active =
|
|
310
|
+
const memories2 = queryMemories(db, { repo }).filter((m) => m.status !== "rejected");
|
|
311
|
+
const active = memories2.filter((m) => m.status === "active");
|
|
275
312
|
const activeCount = active.length;
|
|
276
|
-
const totalCount =
|
|
313
|
+
const totalCount = memories2.length;
|
|
277
314
|
const health = computeAllHealthScores(db, repo);
|
|
278
315
|
const avgHealth = health.length > 0 ? health.reduce((sum, item) => sum + item.score, 0) / health.length : 0;
|
|
279
|
-
const totalInjections =
|
|
280
|
-
const totalOverrides =
|
|
316
|
+
const totalInjections = memories2.reduce((sum, m) => sum + m.injection_count, 0);
|
|
317
|
+
const totalOverrides = memories2.reduce((sum, m) => sum + m.override_count, 0);
|
|
281
318
|
const overrideRate = totalInjections > 0 ? totalOverrides / totalInjections : 0;
|
|
282
|
-
const ids = new Set(
|
|
319
|
+
const ids = new Set(memories2.map((m) => m.id));
|
|
283
320
|
const unresolved = db.select().from(contradictions).where(eq(contradictions.resolved, false)).all().filter((item) => ids.has(item.memory_a_id) || ids.has(item.memory_b_id));
|
|
284
321
|
const contradictionRate = activeCount > 0 ? unresolved.length / activeCount : 0;
|
|
285
322
|
const stage = classifyStage(activeCount);
|
|
@@ -576,6 +613,10 @@ function buildExtractRulesFromPromptPrompt(task) {
|
|
|
576
613
|
" (a) Imperative \u2014 telling the agent what to always/never do, or what to prefer.",
|
|
577
614
|
" (b) Durable \u2014 the user expects it to apply across future sessions, not just this one task.",
|
|
578
615
|
" (c) Specific \u2014 concrete enough that an agent can follow it without further clarification.",
|
|
616
|
+
"Judge durability from MEANING and conversational context in whatever language the user used; never require magic keywords or a special syntax. Habitual behavior, standing preferences, defaults, and repo/team conventions can be durable even without words equivalent to 'always' or 'never'.",
|
|
617
|
+
"Current-task authorization is NOT durable memory: 'don't commit', 'do not push', 'no commit/push', 'work in the existing worktree', and semantic equivalents in any language normally apply only to the live task. Explicit persistence wording is strong evidence, but not required when the meaning clearly describes an ongoing policy.",
|
|
618
|
+
"For every returned rule set durability='durable'|'ephemeral'|'ambiguous' and durability_evidence to an exact short quote from USER PROMPT in its original language that supports the judgment. Return only durable rules; the other labels are accepted defensively but will be discarded.",
|
|
619
|
+
"Do not return scope='session'. Session-only instructions remain in conversation context and must not enter the persistent memory store.",
|
|
579
620
|
"Recognize rules in ANY natural language (English, Spanish, French, German, Italian, Portuguese, Russian, Chinese, Japanese, Albanian, Turkish, Arabic, \u2026). When the source is non-English, return the cleaned rule TEXT in English so memories are searchable across sessions.",
|
|
580
621
|
"REJECT (return empty list):",
|
|
581
622
|
" \u2022 Questions ('should we use X?'), one-off task requests ('please fix this bug now'), narration ('I never use X' as description of past behavior), code paste, error logs, transcripts.",
|
|
@@ -600,7 +641,7 @@ function buildExtractRulesFromPromptPrompt(task) {
|
|
|
600
641
|
`USER PROMPT:`,
|
|
601
642
|
JSON.stringify(payload.raw_prompt ?? ""),
|
|
602
643
|
"",
|
|
603
|
-
'Return JSON: {"rules": [{"text": string, "type": "rule"|"decision"|"review_pattern"|"command"|"gotcha", "scope": "session"|"path"|"repo"|"team"|"global", "path_scope": string|null, "confidence": number, "is_destructive_risky": boolean, "rationale": string}], "dropped_reason": string?}',
|
|
644
|
+
'Return JSON: {"rules": [{"text": string, "type": "rule"|"decision"|"review_pattern"|"command"|"gotcha", "scope": "session"|"path"|"repo"|"team"|"global", "path_scope": string|null, "confidence": number, "durability": "durable"|"ephemeral"|"ambiguous", "durability_evidence": string|null, "is_destructive_risky": boolean, "rationale": string}], "dropped_reason": string?}',
|
|
604
645
|
'When the prompt contains no durable rule, return {"rules": []} with a brief dropped_reason.'
|
|
605
646
|
].join("\n");
|
|
606
647
|
return { system, user, max_output_tokens: 1600 };
|
|
@@ -1008,6 +1049,11 @@ import { randomUUID as randomUUID3 } from "crypto";
|
|
|
1008
1049
|
|
|
1009
1050
|
// src/contradictions/detector.ts
|
|
1010
1051
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
1052
|
+
function countContradictionCandidates(db, repo) {
|
|
1053
|
+
const conditions = [inArray(memories.status, ["active", "candidate"])];
|
|
1054
|
+
if (repo) conditions.push(eq(memories.repo, repo));
|
|
1055
|
+
return db.select({ count: sql`count(*)` }).from(memories).where(and(...conditions)).get()?.count ?? 0;
|
|
1056
|
+
}
|
|
1011
1057
|
function detectContradictions(db, repo) {
|
|
1012
1058
|
const mems = queryMemories(db, { repo }).filter(
|
|
1013
1059
|
(m) => m.status === "active" || m.status === "candidate"
|
|
@@ -1233,6 +1279,47 @@ var INJECTION_ARTIFACT_RE = new RegExp(
|
|
|
1233
1279
|
"i"
|
|
1234
1280
|
);
|
|
1235
1281
|
var EPHEMERAL_TASK_CONTEXT_RE = /(?:^\s*\/goal\b|pause for (?:the )?user\b|this is task def(?:inition)?:|key details\s+description\s+(?:goal|background)\b|link to jira ticket|what(?:'|’)s changed\?|this article lists the tools we use for development|required software on node)/i;
|
|
1282
|
+
var OPERATIONAL_REPORT_MARKERS = [
|
|
1283
|
+
/(?:^|\n)\s*(?:✏️|❓|✅|❌)\s*(?:review|test|checkout)\s*:/iu,
|
|
1284
|
+
/\bTouch-map\s*:/i,
|
|
1285
|
+
/\b\d+\/\d+ gates passed\b/i,
|
|
1286
|
+
/\b(?:gates|checkout) skipped\b/i,
|
|
1287
|
+
/\bUsage Error\s*:/i,
|
|
1288
|
+
/\b(?:no provider review|verdict from gates only)\b/i,
|
|
1289
|
+
/\bLocal review only for this repo\b/i
|
|
1290
|
+
];
|
|
1291
|
+
function looksLikePastedOperationalReport(text) {
|
|
1292
|
+
if (text.length < 500 || !text.includes("\n")) return false;
|
|
1293
|
+
const leadingRequest = text.split(/\r?\n\s*\r?\n/, 1)[0] ?? "";
|
|
1294
|
+
if (DURABLE_INTENT_MARKER_RE.test(leadingRequest)) return false;
|
|
1295
|
+
const markerCount = OPERATIONAL_REPORT_MARKERS.reduce(
|
|
1296
|
+
(count, marker) => count + (marker.test(text) ? 1 : 0),
|
|
1297
|
+
0
|
|
1298
|
+
);
|
|
1299
|
+
return markerCount >= 2;
|
|
1300
|
+
}
|
|
1301
|
+
var DURABLE_INTENT_MARKER_RE = /\b(?:always|never|from now on|going forward|henceforth|every time|whenever|by default|make (?:this|it) a rule|remember this|save this|for this repo|for this project|repo-wide|project-wide|across (?:all )?(?:repos|projects)|globally|everywhere)\b/i;
|
|
1302
|
+
var GENERIC_CHANGE_CONTROL_RE = new RegExp(
|
|
1303
|
+
[
|
|
1304
|
+
"(?:do\\s+not|don't|no)\\s+(?:commit|push)(?:\\s*(?:\\/|or|and)\\s*(?:commit|push))?(?:\\s+(?:any\\s+)?(?:changes?|work|anything|repository\\s+changes?|from\\s+this\\s+worktree))?",
|
|
1305
|
+
"without\\s+(?:committing|pushing)(?:\\s+or\\s+(?:committing|pushing))?"
|
|
1306
|
+
].join("|"),
|
|
1307
|
+
"i"
|
|
1308
|
+
);
|
|
1309
|
+
function changeControlClauses(text) {
|
|
1310
|
+
return text.split(/(?:\r?\n|[.!?;])+/).map((clause) => clause.trim()).filter((clause) => /\b(?:commit|push|committing|pushing)\b/i.test(clause));
|
|
1311
|
+
}
|
|
1312
|
+
function isEphemeralTaskConstraint(ruleText, rawPrompt) {
|
|
1313
|
+
if (!GENERIC_CHANGE_CONTROL_RE.test(ruleText)) return false;
|
|
1314
|
+
if (/\b(?:secret|credential|token|private key|\.env|config(?:uration)?|generated file|lockfile)s?\b/i.test(ruleText)) {
|
|
1315
|
+
return false;
|
|
1316
|
+
}
|
|
1317
|
+
const sourceClauses = changeControlClauses(rawPrompt);
|
|
1318
|
+
if (sourceClauses.length === 0) return false;
|
|
1319
|
+
const matchingClauses = sourceClauses.filter((clause) => GENERIC_CHANGE_CONTROL_RE.test(clause));
|
|
1320
|
+
if (matchingClauses.length === 0) return false;
|
|
1321
|
+
return matchingClauses.every((clause) => !DURABLE_INTENT_MARKER_RE.test(clause));
|
|
1322
|
+
}
|
|
1236
1323
|
var LLM_WORKER_PROMPT_RE = /(?:^\s*you are (?:the|an?)\s+[^\n]{0,80}?\b(?:worker|judge|extractor|summari[sz]er|compactor|classifier|grader|scorer|labeler)\b|\bfor a personal agent runtime\b|\breturn json only\b[^\n]{0,60}\bno (?:markdown|prose)\b)/i;
|
|
1237
1324
|
var CODEX_INTERNAL_PROMPT_RE = /(?:^\s*generate a title and a git branch name for a coding agent\b|^\s*#\s*overview\s+generate\s+0\s+to\s+3\s+hyperpersonalized suggestions for what this user can do with codex\b|^\s*you are an expert at upholding safety and compliance standards for codex ambient suggestions\b|^\s*you are the implementation worker for one isolated git worktree\b|^\s*you are reviewing github pull request\b[^\n]*\bon behalf of the maintainer\b|^\s*#\s*github issue workorder\s*:|^\s*continue the previous coding task using user-provided context only\b)/i;
|
|
1238
1325
|
function looksLikeQuestionContext(text) {
|
|
@@ -1249,7 +1336,7 @@ function looksLikeQuestionContext(text) {
|
|
|
1249
1336
|
return /\?\s*$/.test(text.trim()) || /(?:^|[.!?]\s+)(?:how|why|what|where|which|who|can|could|should|would|do|does|did|is|are|was|were|have|has)\b/i.test(text);
|
|
1250
1337
|
}
|
|
1251
1338
|
function isNonUserCaptureContext(text) {
|
|
1252
|
-
return SYSTEM_SCAFFOLD_RE.test(text) || NON_USER_CONTEXT_RE.test(text) || INJECTION_ARTIFACT_RE.test(text) || EPHEMERAL_TASK_CONTEXT_RE.test(text) || LLM_WORKER_PROMPT_RE.test(text) || CODEX_INTERNAL_PROMPT_RE.test(text) || looksLikeQuestionContext(text);
|
|
1339
|
+
return SYSTEM_SCAFFOLD_RE.test(text) || NON_USER_CONTEXT_RE.test(text) || INJECTION_ARTIFACT_RE.test(text) || EPHEMERAL_TASK_CONTEXT_RE.test(text) || looksLikePastedOperationalReport(text) || LLM_WORKER_PROMPT_RE.test(text) || CODEX_INTERNAL_PROMPT_RE.test(text) || looksLikeQuestionContext(text);
|
|
1253
1340
|
}
|
|
1254
1341
|
|
|
1255
1342
|
// src/scanner/signal.ts
|
|
@@ -1977,11 +2064,13 @@ function planPromoteRepeats(db) {
|
|
|
1977
2064
|
text: memories.text,
|
|
1978
2065
|
repetition_count: memories.repetition_count,
|
|
1979
2066
|
source: memories.source,
|
|
1980
|
-
status: memories.status
|
|
2067
|
+
status: memories.status,
|
|
2068
|
+
scope: memories.scope
|
|
1981
2069
|
}).from(memories).where(and(eq(memories.status, "candidate"), eq(memories.source, "user_correction"))).all();
|
|
1982
2070
|
const out = [];
|
|
1983
2071
|
for (const row of rows) {
|
|
1984
2072
|
const text = row.text.trim();
|
|
2073
|
+
if (row.scope === "session") continue;
|
|
1985
2074
|
if (qualityReasons(text).length > 0) continue;
|
|
1986
2075
|
if (isDestructiveRisky(text)) continue;
|
|
1987
2076
|
if (row.repetition_count >= 2) {
|
|
@@ -2525,6 +2614,7 @@ var TRANSCRIPT_MARKERS = [
|
|
|
2525
2614
|
var DURABLE_DECISION_HINT = /\b(repo|repository|project|default|defaults|convention(?:al|s)?|configured|config|editorconfig|prettier|eslint|tsconfig|package\.json|ci|workflow|style|pattern|architecture|runtime|database|sqlite|pnpm|yarn|npm|uv|pytest|vitest)\b/i;
|
|
2526
2615
|
var TRANSCRIPT_LINE_RE = /^(?:[⏺⎿❯✻※]|(?:Bash|Edit|Write|Read|Grep|Glob|Task|TodoWrite)\(|\s*(?:│|├|┌|└|─)|\s*…|\s*={3,})/u;
|
|
2527
2616
|
function looksLikePastedTranscript(text) {
|
|
2617
|
+
if (looksLikePastedOperationalReport(text)) return true;
|
|
2528
2618
|
if (text.length < 1200) return false;
|
|
2529
2619
|
const markerCount = TRANSCRIPT_MARKERS.reduce(
|
|
2530
2620
|
(total, marker) => total + (text.includes(marker) ? 1 : 0),
|
|
@@ -2549,7 +2639,7 @@ function isDurableDecision(segment, first, second) {
|
|
|
2549
2639
|
async function processCorrection(db, text, ctx) {
|
|
2550
2640
|
text = redactSensitiveText(text);
|
|
2551
2641
|
if (isNonUserCaptureContext(text)) return { ids: [] };
|
|
2552
|
-
if (process.env.RECALL_LLM_CAPTURE_DISABLED !== "true" && hasAnyLlmProvider() && isPromptWorthLLM(text)) {
|
|
2642
|
+
if (process.env.RECALL_LLM_CAPTURE_DISABLED !== "true" && hasAnyLlmProvider() && (ctx.force_semantic_capture || isPromptWorthLLM(text))) {
|
|
2553
2643
|
const promptId = stablePromptId(ctx.sessionId, ctx.repo, text);
|
|
2554
2644
|
const taskId = enqueueExtractRulesFromPrompt(db, {
|
|
2555
2645
|
prompt_id: promptId,
|
|
@@ -2565,6 +2655,14 @@ async function processCorrection(db, text, ctx) {
|
|
|
2565
2655
|
return { ids: [], pendingTaskId: taskId ?? `dedup:${promptId}` };
|
|
2566
2656
|
}
|
|
2567
2657
|
const corrections = detectCorrections(text);
|
|
2658
|
+
if (corrections.length === 0 && ctx.force_semantic_capture) {
|
|
2659
|
+
corrections.push({
|
|
2660
|
+
type: "rule",
|
|
2661
|
+
text: ensureSentence(text),
|
|
2662
|
+
confidence: 0.35,
|
|
2663
|
+
original: text
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2568
2666
|
if (corrections.length === 0) return { ids: [] };
|
|
2569
2667
|
const profile = getRepoQualityProfile(db, ctx.repo);
|
|
2570
2668
|
const ids = [];
|
|
@@ -2630,6 +2728,7 @@ async function processCorrection(db, text, ctx) {
|
|
|
2630
2728
|
original_text: text
|
|
2631
2729
|
}
|
|
2632
2730
|
);
|
|
2731
|
+
if (inferredScope.scope === "session") continue;
|
|
2633
2732
|
const input = {
|
|
2634
2733
|
type: correction.type,
|
|
2635
2734
|
text: correction.text,
|
|
@@ -2645,7 +2744,6 @@ async function processCorrection(db, text, ctx) {
|
|
|
2645
2744
|
capture_context: captureContext
|
|
2646
2745
|
};
|
|
2647
2746
|
const id = createMemory(db, input);
|
|
2648
|
-
maybePromoteGroupCandidate(db, id);
|
|
2649
2747
|
enqueueVerifyCapture(db, {
|
|
2650
2748
|
id,
|
|
2651
2749
|
text: input.text,
|
|
@@ -2662,29 +2760,6 @@ function stablePromptId(sessionId, repo, text) {
|
|
|
2662
2760
|
const hash = createHash("sha256").update(`${sessionId}${repo ?? ""}${normalizeDedupeText(text)}`).digest("hex").slice(0, 16);
|
|
2663
2761
|
return `prompt:${sessionId}:${hash}`;
|
|
2664
2762
|
}
|
|
2665
|
-
function maybePromoteGroupCandidate(db, candidateId) {
|
|
2666
|
-
const candidate = getMemory(db, candidateId);
|
|
2667
|
-
if (!candidate || candidate.status !== "candidate") return;
|
|
2668
|
-
if (isHighRiskRule(candidate.text)) return;
|
|
2669
|
-
const followedCount = queryMemories(db, {
|
|
2670
|
-
repo: candidate.repo ?? void 0,
|
|
2671
|
-
type: candidate.type,
|
|
2672
|
-
scope: candidate.scope
|
|
2673
|
-
}).filter((memory) => memory.id !== candidate.id).reduce((total, memory) => total + getMemoryFeedback(db, memory.id).filter((entry) => entry.outcome === "followed").length, 0);
|
|
2674
|
-
if (followedCount < 3) return;
|
|
2675
|
-
const before = candidate;
|
|
2676
|
-
promoteMemory(db, candidate.id, "repeat_correction");
|
|
2677
|
-
const after = getMemory(db, candidate.id);
|
|
2678
|
-
recordAuditWithSnapshot(
|
|
2679
|
-
db,
|
|
2680
|
-
candidate.id,
|
|
2681
|
-
"promoted",
|
|
2682
|
-
"system",
|
|
2683
|
-
`repetition:group_followed:${followedCount}`,
|
|
2684
|
-
before,
|
|
2685
|
-
after ?? null
|
|
2686
|
-
);
|
|
2687
|
-
}
|
|
2688
2763
|
function buildCaptureContext(ctx) {
|
|
2689
2764
|
const recentToolCalls = (ctx.recent_tool_calls ?? []).slice(-5).map((toolCall) => ({
|
|
2690
2765
|
name: toolCall.name,
|
|
@@ -3083,6 +3158,9 @@ function applyExtractRulesFromPrompt(db, task, result) {
|
|
|
3083
3158
|
const reinforcedIds = [];
|
|
3084
3159
|
const sessionId = payload.session_id ?? "unknown";
|
|
3085
3160
|
for (const rule of result.rules) {
|
|
3161
|
+
if (rule.scope === "session" || rule.durability === "ephemeral" || rule.durability === "ambiguous" || rule.durability !== "durable" && isEphemeralTaskConstraint(rule.text, payload.raw_prompt ?? "")) {
|
|
3162
|
+
continue;
|
|
3163
|
+
}
|
|
3086
3164
|
const evidence = {
|
|
3087
3165
|
type: "session_correction",
|
|
3088
3166
|
session: sessionId,
|
|
@@ -3778,6 +3856,10 @@ var ExtractedRule = z.object({
|
|
|
3778
3856
|
scope: MemoryScope,
|
|
3779
3857
|
path_scope: z.string().max(512).nullable().optional(),
|
|
3780
3858
|
confidence: z.number().min(0).max(1),
|
|
3859
|
+
// Optional for compatibility with already-queued tasks and older model
|
|
3860
|
+
// responses. New extraction prompts require this semantic judgment.
|
|
3861
|
+
durability: z.enum(["durable", "ephemeral", "ambiguous"]).optional(),
|
|
3862
|
+
durability_evidence: z.string().max(500).nullable().optional(),
|
|
3781
3863
|
is_destructive_risky: z.boolean().optional(),
|
|
3782
3864
|
rationale: z.string().max(500).nullable().optional()
|
|
3783
3865
|
});
|
|
@@ -4008,6 +4090,7 @@ export {
|
|
|
4008
4090
|
buildPrompt,
|
|
4009
4091
|
formatDispatchReport,
|
|
4010
4092
|
inferScope,
|
|
4093
|
+
countContradictionCandidates,
|
|
4011
4094
|
detectContradictions,
|
|
4012
4095
|
resolveContradiction,
|
|
4013
4096
|
autoResolveContradictions,
|
|
@@ -4035,4 +4118,4 @@ export {
|
|
|
4035
4118
|
processCorrection,
|
|
4036
4119
|
processReviewFeedback
|
|
4037
4120
|
};
|
|
4038
|
-
//# sourceMappingURL=chunk-
|
|
4121
|
+
//# sourceMappingURL=chunk-65XK27KK.js.map
|