@dzhechkov/harness-core 0.8.5 → 0.8.10
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/.dz-manifest.json +286 -82
- package/README.md +54 -2
- package/dist/amendment-trace.d.ts.map +1 -1
- package/dist/amendment-trace.js +12 -1
- package/dist/amendment-trace.js.map +1 -1
- package/dist/compounding.d.ts +54 -0
- package/dist/compounding.d.ts.map +1 -1
- package/dist/compounding.js +221 -1
- package/dist/compounding.js.map +1 -1
- package/dist/eta.d.ts +92 -0
- package/dist/eta.d.ts.map +1 -0
- package/dist/eta.js +488 -0
- package/dist/eta.js.map +1 -0
- package/dist/feature-adr-checkpoints.d.ts +11 -2
- package/dist/feature-adr-checkpoints.d.ts.map +1 -1
- package/dist/feature-adr-checkpoints.js +38 -3
- package/dist/feature-adr-checkpoints.js.map +1 -1
- package/dist/feature-adr-decision-recall.d.ts +167 -0
- package/dist/feature-adr-decision-recall.d.ts.map +1 -0
- package/dist/feature-adr-decision-recall.js +519 -0
- package/dist/feature-adr-decision-recall.js.map +1 -0
- package/dist/feature-adr-landing.d.ts +37 -0
- package/dist/feature-adr-landing.d.ts.map +1 -0
- package/dist/feature-adr-landing.js +59 -0
- package/dist/feature-adr-landing.js.map +1 -0
- package/dist/feature-adr-routing.d.ts +58 -23
- package/dist/feature-adr-routing.d.ts.map +1 -1
- package/dist/feature-adr-routing.js +194 -69
- package/dist/feature-adr-routing.js.map +1 -1
- package/dist/guard-promotion.d.ts +41 -0
- package/dist/guard-promotion.d.ts.map +1 -1
- package/dist/guard-promotion.js +218 -4
- package/dist/guard-promotion.js.map +1 -1
- package/dist/guard-volume.d.ts +108 -0
- package/dist/guard-volume.d.ts.map +1 -0
- package/dist/guard-volume.js +536 -0
- package/dist/guard-volume.js.map +1 -0
- package/dist/guard.d.ts +34 -0
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +113 -4
- package/dist/guard.js.map +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/integration-apply.d.ts +25 -0
- package/dist/integration-apply.d.ts.map +1 -0
- package/dist/integration-apply.js +299 -0
- package/dist/integration-apply.js.map +1 -0
- package/dist/integration-evidence.d.ts +46 -0
- package/dist/integration-evidence.d.ts.map +1 -0
- package/dist/integration-evidence.js +44 -0
- package/dist/integration-evidence.js.map +1 -0
- package/dist/integration-probe-worker.d.ts +22 -0
- package/dist/integration-probe-worker.d.ts.map +1 -0
- package/dist/integration-probe-worker.js +334 -0
- package/dist/integration-probe-worker.js.map +1 -0
- package/dist/integrations-verify.d.ts +60 -0
- package/dist/integrations-verify.d.ts.map +1 -0
- package/dist/integrations-verify.js +194 -0
- package/dist/integrations-verify.js.map +1 -0
- package/dist/lesson-generalization.d.ts +29 -0
- package/dist/lesson-generalization.d.ts.map +1 -0
- package/dist/lesson-generalization.js +84 -0
- package/dist/lesson-generalization.js.map +1 -0
- package/dist/loop-blobs.generated.js +8 -8
- package/dist/loop-blobs.generated.js.map +1 -1
- package/dist/loop-plan.d.ts +13 -1
- package/dist/loop-plan.d.ts.map +1 -1
- package/dist/loop-plan.js +15 -1
- package/dist/loop-plan.js.map +1 -1
- package/dist/loop-render.d.ts.map +1 -1
- package/dist/loop-render.js +51 -6
- package/dist/loop-render.js.map +1 -1
- package/dist/loop-trace.d.ts +20 -1
- package/dist/loop-trace.d.ts.map +1 -1
- package/dist/loop-trace.js +83 -1
- package/dist/loop-trace.js.map +1 -1
- package/dist/model-recommender.d.ts +8 -0
- package/dist/model-recommender.d.ts.map +1 -1
- package/dist/model-recommender.js +31 -4
- package/dist/model-recommender.js.map +1 -1
- package/dist/operations.d.ts +27 -0
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +178 -2
- package/dist/operations.js.map +1 -1
- package/dist/patterns.d.ts +27 -1
- package/dist/patterns.d.ts.map +1 -1
- package/dist/patterns.js +211 -45
- package/dist/patterns.js.map +1 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +20 -17
- package/dist/setup.js.map +1 -1
- package/dist/target-integrations.d.ts +65 -0
- package/dist/target-integrations.d.ts.map +1 -0
- package/dist/target-integrations.js +152 -0
- package/dist/target-integrations.js.map +1 -0
- package/dist/vector-tier.d.ts +6 -1
- package/dist/vector-tier.d.ts.map +1 -1
- package/dist/vector-tier.js +32 -7
- package/dist/vector-tier.js.map +1 -1
- package/dist/workflow-run.d.ts.map +1 -1
- package/dist/workflow-run.js +18 -12
- package/dist/workflow-run.js.map +1 -1
- package/package.json +19 -15
- package/sbom.json +591 -81
- package/src/amendment-trace.ts +12 -1
- package/src/compounding.ts +300 -1
- package/src/eta.ts +590 -0
- package/src/feature-adr-checkpoints.ts +39 -3
- package/src/feature-adr-decision-recall.ts +652 -0
- package/src/feature-adr-landing.ts +109 -0
- package/src/feature-adr-routing.ts +224 -65
- package/src/guard-promotion.ts +245 -4
- package/src/guard-volume.ts +752 -0
- package/src/guard.ts +148 -4
- package/src/index.ts +65 -3
- package/src/integration-apply.ts +332 -0
- package/src/integration-evidence.ts +89 -0
- package/src/integration-probe-worker.ts +310 -0
- package/src/integration-receipts/claude-code/mcp/2.1.235.json +35 -0
- package/src/integrations-verify.ts +258 -0
- package/src/lesson-generalization.ts +115 -0
- package/src/loop-blobs.generated.ts +8 -8
- package/src/loop-plan.ts +36 -3
- package/src/loop-render.ts +50 -6
- package/src/loop-trace.ts +91 -2
- package/src/model-recommender.ts +35 -4
- package/src/operations.ts +199 -2
- package/src/patterns.ts +252 -43
- package/src/setup.ts +20 -17
- package/src/target-integrations.ts +225 -0
- package/src/vector-tier.ts +44 -14
- package/src/workflow-run.ts +18 -11
package/dist/patterns.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH,OAAO,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 -29,6 +29,7 @@ import { resolveAgentdbPath } from './agentdb-index.js';
|
|
|
29
29
|
import { rankLessonsByDelta } from './safla-delta.js';
|
|
30
30
|
import { withStoreLock, withStoreLockSync, StoreLockTimeoutError, StoreLockCompromisedError } from './store-lock.js';
|
|
31
31
|
import { describeNativeDep, exerciseSqliteOpen, probeNativeDep } from './native-dep-probe.js';
|
|
32
|
+
import { lessonPairIdOf, mergeLessonFormHits, validateClassTemplate, } from './lesson-generalization.js';
|
|
32
33
|
/** Maximum total boost a learned-pattern set can add to one skill's score. */
|
|
33
34
|
export const BOOST_CAP = 50;
|
|
34
35
|
/** Points awarded per matching pattern, scaled by its reward (≈ one keyword topic). */
|
|
@@ -263,6 +264,25 @@ function storePath(projectRoot) {
|
|
|
263
264
|
function sqlitePath(projectRoot) {
|
|
264
265
|
return join(projectRoot, '.dz', 'memory', 'patterns.sqlite');
|
|
265
266
|
}
|
|
267
|
+
function classFormMarkerPath(projectRoot) {
|
|
268
|
+
return join(projectRoot, '.dz', 'memory', '.class-forms-present');
|
|
269
|
+
}
|
|
270
|
+
function ensureClassFormMarker(projectRoot) {
|
|
271
|
+
const marker = classFormMarkerPath(projectRoot);
|
|
272
|
+
if (existsSync(marker))
|
|
273
|
+
return;
|
|
274
|
+
mkdirSync(dirname(marker), { recursive: true });
|
|
275
|
+
try {
|
|
276
|
+
writeFileSync(marker, 'lesson-class-forms/1\n', { flag: 'wx' });
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
if (error.code !== 'EEXIST')
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function classFormIndexPresent(projectRoot) {
|
|
284
|
+
return existsSync(classFormMarkerPath(projectRoot));
|
|
285
|
+
}
|
|
266
286
|
/**
|
|
267
287
|
* Open the SQLite store backend if the configured mode allows it AND the native
|
|
268
288
|
* `better-sqlite3` is loadable. Returns `undefined` to fall back to JSON (the
|
|
@@ -296,7 +316,11 @@ function tryOpenSqlite(projectRoot, mode) {
|
|
|
296
316
|
* identity, keeping migration/import an idempotent upsert.
|
|
297
317
|
*/
|
|
298
318
|
function patternIdentity(p) {
|
|
299
|
-
|
|
319
|
+
const legacy = `${p.pattern}|${p.ts}|${p.reward}|${p.domain}|${p.type}`;
|
|
320
|
+
// Existing rows must retain their historical ids; only a complete pair identity changes the key.
|
|
321
|
+
return p.lessonPairId !== undefined && p.lessonForm !== undefined
|
|
322
|
+
? `${legacy}|${p.lessonForm}|${p.lessonPairId}`
|
|
323
|
+
: legacy;
|
|
300
324
|
}
|
|
301
325
|
/** Deterministic store id derived from the full-content {@link patternIdentity}. */
|
|
302
326
|
function recordId(p) {
|
|
@@ -320,6 +344,9 @@ function recordIdentity(r) {
|
|
|
320
344
|
const PATTERN_TYPES = new Set(['rule', 'success-pattern', 'lesson-learned']);
|
|
321
345
|
/** Anti-corruption mapping: harness `PatternRecord` → canonical `MemoryRecord`. */
|
|
322
346
|
export function patternToRecord(p) {
|
|
347
|
+
const pairMetadata = p.lessonPairId !== undefined && p.lessonForm !== undefined
|
|
348
|
+
? { lessonForm: p.lessonForm, lessonPairId: p.lessonPairId }
|
|
349
|
+
: {};
|
|
323
350
|
return {
|
|
324
351
|
id: recordId(p),
|
|
325
352
|
skillId: '', // taught patterns are free-text, not tied to one skill
|
|
@@ -333,11 +360,17 @@ export function patternToRecord(p) {
|
|
|
333
360
|
// the learn-loop write path.
|
|
334
361
|
outcome: PATTERN_TYPES.has(p.type) ? p.type : 'lesson-learned',
|
|
335
362
|
timestamp: p.ts,
|
|
336
|
-
metadata: { domain: p.domain ?? 'general', source: p.source ?? 'dz-teach' },
|
|
363
|
+
metadata: { domain: p.domain ?? 'general', source: p.source ?? 'dz-teach', ...pairMetadata },
|
|
337
364
|
};
|
|
338
365
|
}
|
|
339
366
|
/** Anti-corruption mapping: canonical `MemoryRecord` → harness `PatternRecord`. */
|
|
340
367
|
export function recordToPattern(r) {
|
|
368
|
+
const lessonForm = r.metadata?.['lessonForm'];
|
|
369
|
+
const lessonPairId = r.metadata?.['lessonPairId'];
|
|
370
|
+
const pair = (lessonForm === 'specific' || lessonForm === 'class')
|
|
371
|
+
&& typeof lessonPairId === 'string' && lessonPairId !== ''
|
|
372
|
+
? { lessonForm, lessonPairId }
|
|
373
|
+
: {};
|
|
341
374
|
return {
|
|
342
375
|
pattern: r.text,
|
|
343
376
|
type: PATTERN_TYPES.has(r.outcome) ? r.outcome : 'lesson-learned',
|
|
@@ -345,6 +378,7 @@ export function recordToPattern(r) {
|
|
|
345
378
|
domain: r.metadata?.['domain'] ?? 'general',
|
|
346
379
|
ts: r.timestamp,
|
|
347
380
|
source: r.metadata?.['source'] ?? 'dz-teach',
|
|
381
|
+
...pair,
|
|
348
382
|
};
|
|
349
383
|
}
|
|
350
384
|
export function readQuarantineState(r) {
|
|
@@ -518,6 +552,10 @@ async function reinforcePatternLocked(projectRoot, dzIdOrText, opts) {
|
|
|
518
552
|
const rec = records.find((r) => r.id === dzIdOrText || r.text === dzIdOrText);
|
|
519
553
|
if (rec === undefined)
|
|
520
554
|
return { ok: false, error: `no learned pattern matches ${JSON.stringify(dzIdOrText)}` };
|
|
555
|
+
const pairId = typeof rec.metadata?.['lessonPairId'] === 'string' ? rec.metadata['lessonPairId'] : undefined;
|
|
556
|
+
const targets = pairId === undefined
|
|
557
|
+
? [rec]
|
|
558
|
+
: records.filter((record) => record.metadata?.['lessonPairId'] === pairId);
|
|
521
559
|
const prev = readReinforcementState(rec);
|
|
522
560
|
const ts = opts.ts ?? new Date().toISOString();
|
|
523
561
|
const observed = opts.reward !== undefined && Number.isFinite(opts.reward) ? Math.max(0, Math.min(1, opts.reward)) : rec.score;
|
|
@@ -533,18 +571,16 @@ async function reinforcePatternLocked(projectRoot, dzIdOrText, opts) {
|
|
|
533
571
|
// EXPOSURE (a recall-hit sample) is not confirmation — stats update, quarantine stays (the
|
|
534
572
|
// no-promotion-by-exposure invariant; found by cross-model QE as a live hole: recall-hit
|
|
535
573
|
// flushes were routed through this same function and silently promoted every viewed lesson).
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
...
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
if ('error' in put)
|
|
547
|
-
return { ok: false, dzId: rec.id, error: put.error };
|
|
574
|
+
for (const target of targets) {
|
|
575
|
+
const promotedMeta = { ...(target.metadata ?? {}), ...encodeReinforcementState(nextState) };
|
|
576
|
+
if (opts.exposure !== true) {
|
|
577
|
+
delete promotedMeta['qStatus'];
|
|
578
|
+
delete promotedMeta['quarantinedAt'];
|
|
579
|
+
}
|
|
580
|
+
const put = await putStoreRecord(projectRoot, { ...target, metadata: promotedMeta });
|
|
581
|
+
if ('error' in put)
|
|
582
|
+
return { ok: false, dzId: rec.id, error: put.error };
|
|
583
|
+
}
|
|
548
584
|
try {
|
|
549
585
|
appendFileSync(join(projectRoot, '.dz', 'sessions.jsonl'), JSON.stringify({ event: 'reinforce', ts, dzId: rec.id, uses: nextState.uses }) + '\n');
|
|
550
586
|
}
|
|
@@ -554,16 +590,20 @@ async function reinforcePatternLocked(projectRoot, dzIdOrText, opts) {
|
|
|
554
590
|
export async function updateReinforcementState(projectRoot, dzId, state) {
|
|
555
591
|
try {
|
|
556
592
|
return await withStoreLock(projectRoot, async () => {
|
|
557
|
-
const
|
|
593
|
+
const records = loadStoreRecords(projectRoot);
|
|
594
|
+
const rec = records.find((r) => r.id === dzId);
|
|
558
595
|
if (rec === undefined)
|
|
559
596
|
return { ok: false, error: `no learned pattern matches ${JSON.stringify(dzId)}` };
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
597
|
+
const pairId = typeof rec.metadata?.['lessonPairId'] === 'string' ? rec.metadata['lessonPairId'] : undefined;
|
|
598
|
+
const targets = pairId === undefined ? [rec] : records.filter((r) => r.metadata?.['lessonPairId'] === pairId);
|
|
599
|
+
for (const target of targets) {
|
|
600
|
+
const put = await putStoreRecord(projectRoot, {
|
|
601
|
+
...target,
|
|
602
|
+
metadata: { ...(target.metadata ?? {}), ...encodeReinforcementState(state) },
|
|
603
|
+
});
|
|
604
|
+
if ('error' in put)
|
|
605
|
+
return { ok: false, dzId, error: put.error };
|
|
606
|
+
}
|
|
567
607
|
return { ok: true, dzId, uses: state.uses };
|
|
568
608
|
});
|
|
569
609
|
}
|
|
@@ -584,23 +624,30 @@ export async function promotePatterns(projectRoot, dzIds) {
|
|
|
584
624
|
const promoted = [];
|
|
585
625
|
const notFound = [];
|
|
586
626
|
const notQuarantined = [];
|
|
627
|
+
const handled = new Set();
|
|
587
628
|
for (const id of dzIds) {
|
|
588
629
|
const rec = records.find((r) => r.id === id);
|
|
589
630
|
if (rec === undefined) {
|
|
590
631
|
notFound.push(id);
|
|
591
632
|
continue;
|
|
592
633
|
}
|
|
593
|
-
|
|
634
|
+
const pairId = typeof rec.metadata?.['lessonPairId'] === 'string' ? rec.metadata['lessonPairId'] : undefined;
|
|
635
|
+
const targets = pairId === undefined ? [rec] : records.filter((r) => r.metadata?.['lessonPairId'] === pairId);
|
|
636
|
+
const pending = targets.filter((target) => !handled.has(target.id) && readQuarantineState(target).quarantined);
|
|
637
|
+
if (pending.length === 0) {
|
|
594
638
|
notQuarantined.push(id);
|
|
595
639
|
continue;
|
|
596
640
|
}
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
641
|
+
for (const target of pending) {
|
|
642
|
+
const meta = { ...(target.metadata ?? {}) };
|
|
643
|
+
delete meta['qStatus'];
|
|
644
|
+
delete meta['quarantinedAt'];
|
|
645
|
+
const put = await putStoreRecord(projectRoot, { ...target, metadata: meta });
|
|
646
|
+
if ('error' in put)
|
|
647
|
+
return { ok: false, promoted, notFound, notQuarantined, error: put.error };
|
|
648
|
+
handled.add(target.id);
|
|
649
|
+
promoted.push(target.id);
|
|
650
|
+
}
|
|
604
651
|
}
|
|
605
652
|
return { ok: true, promoted, notFound, notQuarantined };
|
|
606
653
|
});
|
|
@@ -806,6 +853,8 @@ function migrationRecords(projectRoot) {
|
|
|
806
853
|
* JSON file is never deleted. Returns the total record count after the write.
|
|
807
854
|
*/
|
|
808
855
|
export async function recordPattern(projectRoot, p, opts = {}) {
|
|
856
|
+
if (p.lessonForm === 'class')
|
|
857
|
+
ensureClassFormMarker(projectRoot);
|
|
809
858
|
const { sqliteBackend } = readLearningConfig(projectRoot);
|
|
810
859
|
// lesson-quarantine: a fresh lesson is a HYPOTHESIS — mark it when the feature is on. Folded
|
|
811
860
|
// legacy records are NEVER marked (they predate the feature: grandfathered as promoted).
|
|
@@ -839,23 +888,127 @@ export async function recordPattern(projectRoot, p, opts = {}) {
|
|
|
839
888
|
return backend.count();
|
|
840
889
|
});
|
|
841
890
|
}
|
|
891
|
+
export async function recordLessonForms(projectRoot, specific, classTemplate, opts = {}) {
|
|
892
|
+
const persist = opts.writeRecord ?? recordPattern;
|
|
893
|
+
const persistOptions = opts.quarantine === true ? { quarantine: true } : {};
|
|
894
|
+
const proposed = classTemplate?.trim();
|
|
895
|
+
if (proposed === undefined || proposed === '') {
|
|
896
|
+
const count = await persist(projectRoot, specific, persistOptions);
|
|
897
|
+
return { count, specific: 'stored', class: 'absent', records: [specific] };
|
|
898
|
+
}
|
|
899
|
+
const validation = proposed === specific.pattern
|
|
900
|
+
? { ok: true }
|
|
901
|
+
: validateClassTemplate(specific.pattern, proposed);
|
|
902
|
+
if (!validation.ok) {
|
|
903
|
+
const count = await persist(projectRoot, specific, persistOptions);
|
|
904
|
+
return { count, specific: 'stored', class: 'rejected', reason: validation.reason, records: [specific] };
|
|
905
|
+
}
|
|
906
|
+
const lessonPairId = lessonPairIdOf(specific.pattern, proposed, specific.ts);
|
|
907
|
+
const specificRow = { ...specific, lessonForm: 'specific', lessonPairId };
|
|
908
|
+
const classRow = {
|
|
909
|
+
...specific,
|
|
910
|
+
pattern: proposed,
|
|
911
|
+
source: 'dz-teach-class',
|
|
912
|
+
lessonForm: 'class',
|
|
913
|
+
lessonPairId,
|
|
914
|
+
};
|
|
915
|
+
const firstCount = await persist(projectRoot, specificRow, persistOptions);
|
|
916
|
+
try {
|
|
917
|
+
const count = await persist(projectRoot, classRow, persistOptions);
|
|
918
|
+
return { count, specific: 'stored', class: 'stored', records: [specificRow, classRow] };
|
|
919
|
+
}
|
|
920
|
+
catch (error) {
|
|
921
|
+
return {
|
|
922
|
+
count: firstCount,
|
|
923
|
+
specific: 'stored',
|
|
924
|
+
class: 'failed',
|
|
925
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
926
|
+
records: [specificRow],
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
function mergeRecallRows(records, ranked, backend, query, limit, opts) {
|
|
931
|
+
const pairRows = new Map();
|
|
932
|
+
for (const record of records) {
|
|
933
|
+
const pattern = recordToPattern(record);
|
|
934
|
+
if (pattern.lessonPairId === undefined || pattern.lessonForm === undefined)
|
|
935
|
+
continue;
|
|
936
|
+
const pair = pairRows.get(pattern.lessonPairId) ?? {};
|
|
937
|
+
if (pattern.lessonForm === 'specific')
|
|
938
|
+
pair.specific = record;
|
|
939
|
+
else
|
|
940
|
+
pair.classRow = record;
|
|
941
|
+
pairRows.set(pattern.lessonPairId, pair);
|
|
942
|
+
}
|
|
943
|
+
const rankedIds = new Set(ranked.map((record) => record.id));
|
|
944
|
+
const specificHits = [];
|
|
945
|
+
const rankedClassRows = [];
|
|
946
|
+
const logicalHit = (record) => {
|
|
947
|
+
const source = recordToPattern(record);
|
|
948
|
+
const pair = source.lessonPairId === undefined ? undefined : pairRows.get(source.lessonPairId);
|
|
949
|
+
const specificRecord = source.lessonForm === 'class' ? pair?.specific : record;
|
|
950
|
+
const classRecord = source.lessonForm === 'class' ? record : pair?.classRow;
|
|
951
|
+
const base = recordToPattern(specificRecord ?? record);
|
|
952
|
+
const pattern = classRecord === undefined ? base : { ...base, classForm: classRecord.text };
|
|
953
|
+
const quarantined = readQuarantineState(specificRecord ?? record).quarantined
|
|
954
|
+
|| (classRecord !== undefined && readQuarantineState(classRecord).quarantined);
|
|
955
|
+
return { pattern, backend, ...(quarantined ? { quarantined: true } : {}) };
|
|
956
|
+
};
|
|
957
|
+
for (const record of ranked) {
|
|
958
|
+
const pattern = recordToPattern(record);
|
|
959
|
+
const key = pattern.lessonPairId ?? record.id;
|
|
960
|
+
if (pattern.lessonForm === 'class')
|
|
961
|
+
rankedClassRows.push(record);
|
|
962
|
+
else
|
|
963
|
+
specificHits.push({ key, value: logicalHit(record), matchedForm: 'specific' });
|
|
964
|
+
}
|
|
965
|
+
const finish = (classHits) => sinkQuarantined(mergeLessonFormHits(specificHits, classHits, limit * 2).map((hit) => ({ ...hit.value, matchedForm: hit.matchedForm })), limit);
|
|
966
|
+
try {
|
|
967
|
+
const classHits = rankedClassRows.map((record) => {
|
|
968
|
+
const pattern = recordToPattern(record);
|
|
969
|
+
return { key: pattern.lessonPairId ?? record.id, value: logicalHit(record), matchedForm: 'class' };
|
|
970
|
+
});
|
|
971
|
+
const classMatcher = opts.classMatcher ?? validateClassTemplate;
|
|
972
|
+
for (const record of records) {
|
|
973
|
+
const pattern = recordToPattern(record);
|
|
974
|
+
if (pattern.lessonForm !== 'class' || rankedIds.has(record.id))
|
|
975
|
+
continue;
|
|
976
|
+
if (classMatcher(query, pattern.pattern).ok) {
|
|
977
|
+
classHits.push({ key: pattern.lessonPairId ?? record.id, value: logicalHit(record), matchedForm: 'class' });
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
return finish(classHits);
|
|
981
|
+
}
|
|
982
|
+
catch (error) {
|
|
983
|
+
const message = `class-form search degraded: ${error instanceof Error ? error.message : String(error)}`;
|
|
984
|
+
try {
|
|
985
|
+
opts.onClassDegraded?.(message);
|
|
986
|
+
}
|
|
987
|
+
catch { /* an advisory sink may not suppress specific recall */ }
|
|
988
|
+
return finish([]);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
842
991
|
/**
|
|
843
992
|
* Ranked recall over the store (Tier-3): SQLite **FTS5** full-text ranking when
|
|
844
993
|
* available, else JSON keyword-overlap. The synchronous CLI analogue of semantic
|
|
845
994
|
* recall — note it is *lexical*, not vector similarity (true embedding/HNSW recall
|
|
846
995
|
* lives in the `agentdb-memory` MCP skill, MCP-host only). Graceful: `[]` on failure.
|
|
847
996
|
*/
|
|
848
|
-
export function recallPatterns(projectRoot, query, limit = 10) {
|
|
997
|
+
export function recallPatterns(projectRoot, query, limit = 10, opts = {}) {
|
|
849
998
|
const { sqliteBackend } = readLearningConfig(projectRoot);
|
|
850
999
|
if (sqliteBackend !== 'json' && existsSync(sqlitePath(projectRoot))) {
|
|
851
1000
|
try {
|
|
852
1001
|
const db = SqliteBackend.open(sqlitePath(projectRoot));
|
|
853
1002
|
try {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
1003
|
+
if (!classFormIndexPresent(projectRoot)) {
|
|
1004
|
+
return sinkQuarantined(db.querySync({ text: query, limit: limit * 2 }).map((r) => ({
|
|
1005
|
+
pattern: recordToPattern(r),
|
|
1006
|
+
backend: 'sqlite',
|
|
1007
|
+
...(readQuarantineState(r).quarantined ? { quarantined: true } : {}),
|
|
1008
|
+
})), limit);
|
|
1009
|
+
}
|
|
1010
|
+
const records = db.allSync();
|
|
1011
|
+
return mergeRecallRows(records, db.querySync({ text: query, limit: limit * 4 }), 'sqlite', query, limit, opts);
|
|
859
1012
|
}
|
|
860
1013
|
finally {
|
|
861
1014
|
db.close();
|
|
@@ -864,13 +1017,16 @@ export function recallPatterns(projectRoot, query, limit = 10) {
|
|
|
864
1017
|
catch { /* fall through to JSON */ }
|
|
865
1018
|
}
|
|
866
1019
|
try {
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
.map((r) => ({
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
1020
|
+
const backend = JsonFileBackend.openSync(storePath(projectRoot));
|
|
1021
|
+
if (!classFormIndexPresent(projectRoot)) {
|
|
1022
|
+
return sinkQuarantined(backend.querySync({ text: query, limit: limit * 2 }).map((r) => ({
|
|
1023
|
+
pattern: recordToPattern(r),
|
|
1024
|
+
backend: 'json',
|
|
1025
|
+
...(readQuarantineState(r).quarantined ? { quarantined: true } : {}),
|
|
1026
|
+
})), limit);
|
|
1027
|
+
}
|
|
1028
|
+
const records = backend.allSync();
|
|
1029
|
+
return mergeRecallRows(records, backend.querySync({ text: query, limit: limit * 4 }), 'json', query, limit, opts);
|
|
874
1030
|
}
|
|
875
1031
|
catch {
|
|
876
1032
|
return [];
|
|
@@ -1186,6 +1342,16 @@ export function pruneNoisePatterns(projectRoot, opts = {}) {
|
|
|
1186
1342
|
export function removePatternsByIds(projectRoot, ids) {
|
|
1187
1343
|
if (ids.size === 0)
|
|
1188
1344
|
return { removed: 0 };
|
|
1345
|
+
const expandedIds = new Set(ids);
|
|
1346
|
+
const records = loadStoreRecords(projectRoot);
|
|
1347
|
+
const selectedPairs = new Set(records
|
|
1348
|
+
.filter((record) => ids.has(record.id) && typeof record.metadata?.['lessonPairId'] === 'string')
|
|
1349
|
+
.map((record) => record.metadata?.['lessonPairId']));
|
|
1350
|
+
for (const record of records) {
|
|
1351
|
+
if (typeof record.metadata?.['lessonPairId'] === 'string' && selectedPairs.has(record.metadata['lessonPairId'])) {
|
|
1352
|
+
expandedIds.add(record.id);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1189
1355
|
let removed = 0;
|
|
1190
1356
|
const errors = [];
|
|
1191
1357
|
// Lexical store, SQLite tier
|
|
@@ -1195,7 +1361,7 @@ export function removePatternsByIds(projectRoot, ids) {
|
|
|
1195
1361
|
const db = SqliteBackend.open(sqlitePath(projectRoot));
|
|
1196
1362
|
try {
|
|
1197
1363
|
for (const r of db.allSync()) {
|
|
1198
|
-
if (
|
|
1364
|
+
if (expandedIds.has(r.id)) {
|
|
1199
1365
|
db.removeSync(r.id);
|
|
1200
1366
|
removed += 1;
|
|
1201
1367
|
}
|
|
@@ -1220,7 +1386,7 @@ export function removePatternsByIds(projectRoot, ids) {
|
|
|
1220
1386
|
const backend = JsonFileBackend.openSync(storePath(projectRoot));
|
|
1221
1387
|
let localRemoved = 0;
|
|
1222
1388
|
for (const r of backend.allSync()) {
|
|
1223
|
-
if (
|
|
1389
|
+
if (expandedIds.has(r.id)) {
|
|
1224
1390
|
backend.removeSync(r.id);
|
|
1225
1391
|
localRemoved += 1;
|
|
1226
1392
|
}
|