@hivelore/core 0.39.2 → 0.42.1
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/index.d.ts +182 -61
- package/dist/index.js +296 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -28,8 +28,13 @@ declare const AnchorSchema: z.ZodObject<{
|
|
|
28
28
|
* (they require I/O and must run from the CLI, not core).
|
|
29
29
|
*/
|
|
30
30
|
declare const SensorSchema: z.ZodObject<{
|
|
31
|
-
kind: z.ZodDefault<z.ZodEnum<["regex", "shell", "test"]>>;
|
|
32
|
-
/**
|
|
31
|
+
kind: z.ZodDefault<z.ZodEnum<["regex", "ast", "shell", "test"]>>;
|
|
32
|
+
/**
|
|
33
|
+
* kind=regex: regex source, matched against added diff lines / file content.
|
|
34
|
+
* kind=ast: an ast-grep structural pattern (e.g. `stripe.paymentIntents.create($$$)`) — matched
|
|
35
|
+
* on the AST of changed files, so comments and string literals can never false-positive. Requires
|
|
36
|
+
* the optional `@ast-grep/napi` engine; without it the sensor is unrunnable (warn, never block).
|
|
37
|
+
*/
|
|
33
38
|
pattern: z.ZodOptional<z.ZodString>;
|
|
34
39
|
/**
|
|
35
40
|
* Optional "correct-usage" regex (kind=regex). When `pattern` (the risky call) matches but this
|
|
@@ -56,6 +61,13 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
56
61
|
* the incident the test exists to prevent". Surfaced in the block message and the prevention receipt.
|
|
57
62
|
*/
|
|
58
63
|
incident: z.ZodOptional<z.ZodString>;
|
|
64
|
+
/**
|
|
65
|
+
* kind=shell|test only: the oracle was PROVEN to fail (RED) on the incident state at arming time
|
|
66
|
+
* (`sensors propose --red-ref`): the command passed on the presumed-correct tree AND failed on
|
|
67
|
+
* the replayed incident tree. Distinguishes "a test is routed" from "the test demonstrably
|
|
68
|
+
* catches the incident". Surfaced in the prevention receipt.
|
|
69
|
+
*/
|
|
70
|
+
red_proven: z.ZodOptional<z.ZodBoolean>;
|
|
59
71
|
/** `warn` surfaces in review; `block` can hard-block the commit (only when the gate opts in). */
|
|
60
72
|
severity: z.ZodDefault<z.ZodEnum<["warn", "block"]>>;
|
|
61
73
|
/** True when Hivelore generated this sensor automatically (vs. hand-authored). */
|
|
@@ -72,7 +84,7 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
72
84
|
}, "strip", z.ZodTypeAny, {
|
|
73
85
|
message: string;
|
|
74
86
|
paths: string[];
|
|
75
|
-
kind: "regex" | "shell" | "test";
|
|
87
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
76
88
|
severity: "warn" | "block";
|
|
77
89
|
autogen: boolean;
|
|
78
90
|
last_fired: string | null;
|
|
@@ -82,17 +94,19 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
82
94
|
command?: string | undefined;
|
|
83
95
|
timeout_ms?: number | undefined;
|
|
84
96
|
incident?: string | undefined;
|
|
97
|
+
red_proven?: boolean | undefined;
|
|
85
98
|
promoted_at?: string | undefined;
|
|
86
99
|
}, {
|
|
87
100
|
message: string;
|
|
88
101
|
paths?: string[] | undefined;
|
|
89
|
-
kind?: "regex" | "shell" | "test" | undefined;
|
|
102
|
+
kind?: "regex" | "ast" | "shell" | "test" | undefined;
|
|
90
103
|
pattern?: string | undefined;
|
|
91
104
|
absent?: string | undefined;
|
|
92
105
|
flags?: string | undefined;
|
|
93
106
|
command?: string | undefined;
|
|
94
107
|
timeout_ms?: number | undefined;
|
|
95
108
|
incident?: string | undefined;
|
|
109
|
+
red_proven?: boolean | undefined;
|
|
96
110
|
severity?: "warn" | "block" | undefined;
|
|
97
111
|
autogen?: boolean | undefined;
|
|
98
112
|
last_fired?: string | null | undefined;
|
|
@@ -145,8 +159,13 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
145
159
|
}>>;
|
|
146
160
|
/** Optional executable check derived from this memory (feedback computational layer). */
|
|
147
161
|
sensor: z.ZodOptional<z.ZodObject<{
|
|
148
|
-
kind: z.ZodDefault<z.ZodEnum<["regex", "shell", "test"]>>;
|
|
149
|
-
/**
|
|
162
|
+
kind: z.ZodDefault<z.ZodEnum<["regex", "ast", "shell", "test"]>>;
|
|
163
|
+
/**
|
|
164
|
+
* kind=regex: regex source, matched against added diff lines / file content.
|
|
165
|
+
* kind=ast: an ast-grep structural pattern (e.g. `stripe.paymentIntents.create($$$)`) — matched
|
|
166
|
+
* on the AST of changed files, so comments and string literals can never false-positive. Requires
|
|
167
|
+
* the optional `@ast-grep/napi` engine; without it the sensor is unrunnable (warn, never block).
|
|
168
|
+
*/
|
|
150
169
|
pattern: z.ZodOptional<z.ZodString>;
|
|
151
170
|
/**
|
|
152
171
|
* Optional "correct-usage" regex (kind=regex). When `pattern` (the risky call) matches but this
|
|
@@ -173,6 +192,13 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
173
192
|
* the incident the test exists to prevent". Surfaced in the block message and the prevention receipt.
|
|
174
193
|
*/
|
|
175
194
|
incident: z.ZodOptional<z.ZodString>;
|
|
195
|
+
/**
|
|
196
|
+
* kind=shell|test only: the oracle was PROVEN to fail (RED) on the incident state at arming time
|
|
197
|
+
* (`sensors propose --red-ref`): the command passed on the presumed-correct tree AND failed on
|
|
198
|
+
* the replayed incident tree. Distinguishes "a test is routed" from "the test demonstrably
|
|
199
|
+
* catches the incident". Surfaced in the prevention receipt.
|
|
200
|
+
*/
|
|
201
|
+
red_proven: z.ZodOptional<z.ZodBoolean>;
|
|
176
202
|
/** `warn` surfaces in review; `block` can hard-block the commit (only when the gate opts in). */
|
|
177
203
|
severity: z.ZodDefault<z.ZodEnum<["warn", "block"]>>;
|
|
178
204
|
/** True when Hivelore generated this sensor automatically (vs. hand-authored). */
|
|
@@ -189,7 +215,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
189
215
|
}, "strip", z.ZodTypeAny, {
|
|
190
216
|
message: string;
|
|
191
217
|
paths: string[];
|
|
192
|
-
kind: "regex" | "shell" | "test";
|
|
218
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
193
219
|
severity: "warn" | "block";
|
|
194
220
|
autogen: boolean;
|
|
195
221
|
last_fired: string | null;
|
|
@@ -199,17 +225,19 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
199
225
|
command?: string | undefined;
|
|
200
226
|
timeout_ms?: number | undefined;
|
|
201
227
|
incident?: string | undefined;
|
|
228
|
+
red_proven?: boolean | undefined;
|
|
202
229
|
promoted_at?: string | undefined;
|
|
203
230
|
}, {
|
|
204
231
|
message: string;
|
|
205
232
|
paths?: string[] | undefined;
|
|
206
|
-
kind?: "regex" | "shell" | "test" | undefined;
|
|
233
|
+
kind?: "regex" | "ast" | "shell" | "test" | undefined;
|
|
207
234
|
pattern?: string | undefined;
|
|
208
235
|
absent?: string | undefined;
|
|
209
236
|
flags?: string | undefined;
|
|
210
237
|
command?: string | undefined;
|
|
211
238
|
timeout_ms?: number | undefined;
|
|
212
239
|
incident?: string | undefined;
|
|
240
|
+
red_proven?: boolean | undefined;
|
|
213
241
|
severity?: "warn" | "block" | undefined;
|
|
214
242
|
autogen?: boolean | undefined;
|
|
215
243
|
last_fired?: string | null | undefined;
|
|
@@ -284,7 +312,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
284
312
|
sensor?: {
|
|
285
313
|
message: string;
|
|
286
314
|
paths: string[];
|
|
287
|
-
kind: "regex" | "shell" | "test";
|
|
315
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
288
316
|
severity: "warn" | "block";
|
|
289
317
|
autogen: boolean;
|
|
290
318
|
last_fired: string | null;
|
|
@@ -294,6 +322,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
294
322
|
command?: string | undefined;
|
|
295
323
|
timeout_ms?: number | undefined;
|
|
296
324
|
incident?: string | undefined;
|
|
325
|
+
red_proven?: boolean | undefined;
|
|
297
326
|
promoted_at?: string | undefined;
|
|
298
327
|
} | undefined;
|
|
299
328
|
activation?: {
|
|
@@ -319,13 +348,14 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
319
348
|
sensor?: {
|
|
320
349
|
message: string;
|
|
321
350
|
paths?: string[] | undefined;
|
|
322
|
-
kind?: "regex" | "shell" | "test" | undefined;
|
|
351
|
+
kind?: "regex" | "ast" | "shell" | "test" | undefined;
|
|
323
352
|
pattern?: string | undefined;
|
|
324
353
|
absent?: string | undefined;
|
|
325
354
|
flags?: string | undefined;
|
|
326
355
|
command?: string | undefined;
|
|
327
356
|
timeout_ms?: number | undefined;
|
|
328
357
|
incident?: string | undefined;
|
|
358
|
+
red_proven?: boolean | undefined;
|
|
329
359
|
severity?: "warn" | "block" | undefined;
|
|
330
360
|
autogen?: boolean | undefined;
|
|
331
361
|
last_fired?: string | null | undefined;
|
|
@@ -372,7 +402,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
372
402
|
sensor?: {
|
|
373
403
|
message: string;
|
|
374
404
|
paths: string[];
|
|
375
|
-
kind: "regex" | "shell" | "test";
|
|
405
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
376
406
|
severity: "warn" | "block";
|
|
377
407
|
autogen: boolean;
|
|
378
408
|
last_fired: string | null;
|
|
@@ -382,6 +412,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
382
412
|
command?: string | undefined;
|
|
383
413
|
timeout_ms?: number | undefined;
|
|
384
414
|
incident?: string | undefined;
|
|
415
|
+
red_proven?: boolean | undefined;
|
|
385
416
|
promoted_at?: string | undefined;
|
|
386
417
|
} | undefined;
|
|
387
418
|
activation?: {
|
|
@@ -407,13 +438,14 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
407
438
|
sensor?: {
|
|
408
439
|
message: string;
|
|
409
440
|
paths?: string[] | undefined;
|
|
410
|
-
kind?: "regex" | "shell" | "test" | undefined;
|
|
441
|
+
kind?: "regex" | "ast" | "shell" | "test" | undefined;
|
|
411
442
|
pattern?: string | undefined;
|
|
412
443
|
absent?: string | undefined;
|
|
413
444
|
flags?: string | undefined;
|
|
414
445
|
command?: string | undefined;
|
|
415
446
|
timeout_ms?: number | undefined;
|
|
416
447
|
incident?: string | undefined;
|
|
448
|
+
red_proven?: boolean | undefined;
|
|
417
449
|
severity?: "warn" | "block" | undefined;
|
|
418
450
|
autogen?: boolean | undefined;
|
|
419
451
|
last_fired?: string | null | undefined;
|
|
@@ -697,7 +729,7 @@ interface PreventionEvent {
|
|
|
697
729
|
/** Which gate path recorded it. */
|
|
698
730
|
source: PreventionSource;
|
|
699
731
|
/** Optional detail for receipts; absent on logs written before v0.35.0. */
|
|
700
|
-
kind?: "regex" | "shell" | "test";
|
|
732
|
+
kind?: "regex" | "ast" | "shell" | "test";
|
|
701
733
|
stage?: "pre-commit" | "pre-push" | "ci" | "manual";
|
|
702
734
|
exit_code?: number;
|
|
703
735
|
}
|
|
@@ -723,12 +755,14 @@ interface PreventionReceiptRow {
|
|
|
723
755
|
id: string;
|
|
724
756
|
title: string;
|
|
725
757
|
source: PreventionSource;
|
|
726
|
-
kind: "regex" | "shell" | "test" | null;
|
|
758
|
+
kind: "regex" | "ast" | "shell" | "test" | null;
|
|
727
759
|
stage: "pre-commit" | "pre-push" | "ci" | "manual" | null;
|
|
728
760
|
exit_code: number | null;
|
|
729
761
|
message: string | null;
|
|
730
762
|
/** Incident provenance from the sensor frontmatter — the behaviour-harness link, when present. */
|
|
731
763
|
incident: string | null;
|
|
764
|
+
/** The oracle was proven RED on the incident state at arming time (red_ref replay). */
|
|
765
|
+
red_proven: boolean;
|
|
732
766
|
}
|
|
733
767
|
interface PreventionReceipt {
|
|
734
768
|
generated_at: string;
|
|
@@ -836,6 +870,50 @@ declare function projectContextRecentlyEmitted(paths: HaivePaths, hash: string,
|
|
|
836
870
|
/** Record that this exact project-context body was just emitted. Best-effort. */
|
|
837
871
|
declare function recordProjectContextEmission(paths: HaivePaths, hash: string, now?: number): Promise<void>;
|
|
838
872
|
|
|
873
|
+
type MemoryPriority = "must_read" | "useful" | "background";
|
|
874
|
+
/**
|
|
875
|
+
* Normalized priority evidence. A caller fills only the signals it can compute; unknown ones default
|
|
876
|
+
* to false (see {@link DEFAULT_PRIORITY_SIGNALS}). The MCP path has semantic scores; the CLI path has
|
|
877
|
+
* lexical scores — both reduce to these booleans.
|
|
878
|
+
*/
|
|
879
|
+
interface PrioritySignals {
|
|
880
|
+
/** Memory type (attempt, gotcha, skill, decision, …). */
|
|
881
|
+
type: string;
|
|
882
|
+
/** Memory tags — used for the stack-pack / env-workaround down-rank. */
|
|
883
|
+
tags: string[];
|
|
884
|
+
/** The memory demands explicit human approval — always surface first. */
|
|
885
|
+
requiresHumanApproval: boolean;
|
|
886
|
+
/** Anchored to a file the agent is editing. */
|
|
887
|
+
directAnchor: boolean;
|
|
888
|
+
/** Anchored to a symbol the agent requested. */
|
|
889
|
+
directSymbol: boolean;
|
|
890
|
+
/** Exact/literal task match (semantic match_quality "exact", or an exact lexical task hit). */
|
|
891
|
+
exactTaskMatch: boolean;
|
|
892
|
+
/** Strong semantic relevance (cosine ≥ 0.65). CLI has no embeddings → passes false. */
|
|
893
|
+
strongSemantic: boolean;
|
|
894
|
+
/** Useful-level relevance: semantic ≥ 0.35, a partial task hit, or a high lexical score. */
|
|
895
|
+
usefulSemantic: boolean;
|
|
896
|
+
/** Matched an inferred module or domain from the touched files. */
|
|
897
|
+
moduleOrDomainMatch: boolean;
|
|
898
|
+
/** A memory tag matched a task token. */
|
|
899
|
+
tagTaskMatch: boolean;
|
|
900
|
+
}
|
|
901
|
+
declare const DEFAULT_PRIORITY_SIGNALS: PrioritySignals;
|
|
902
|
+
/** Convenience: build a full signal set from a partial one. */
|
|
903
|
+
declare function prioritySignals(partial: Partial<PrioritySignals>): PrioritySignals;
|
|
904
|
+
/**
|
|
905
|
+
* Classify a memory's briefing priority from its signals. Order matters:
|
|
906
|
+
* 1. must_read — human-approval gates, direct anchor/symbol matches, and exact/strong hits on
|
|
907
|
+
* negative (attempt) or skill memories: the things an agent must not miss.
|
|
908
|
+
* 2. background (down-rank) — generic stack-pack seeds and local dev-environment workarounds never
|
|
909
|
+
* claim `useful` on a semantic/tag match alone; they'd crowd out repo-specific knowledge. (A
|
|
910
|
+
* direct anchor already promoted them to must_read above, so genuinely-relevant ones still rank.)
|
|
911
|
+
* 3. useful — skills, module/domain matches, exact hits, and useful-level relevance.
|
|
912
|
+
* 4. background — everything else.
|
|
913
|
+
*/
|
|
914
|
+
declare function classifyMemoryPriority(signals: PrioritySignals): MemoryPriority;
|
|
915
|
+
declare function priorityRank(priority: MemoryPriority): number;
|
|
916
|
+
|
|
839
917
|
/**
|
|
840
918
|
* A rigorous, model-free, repeatable evaluation of Hivelore's core promise: surfacing
|
|
841
919
|
* the right knowledge and guardrails at the right moment. Unlike the agent benchmark
|
|
@@ -967,6 +1045,31 @@ interface SelfEvalOptions {
|
|
|
967
1045
|
*/
|
|
968
1046
|
declare function synthesizeSelfEvalCases(memories: LoadedMemory[], options?: SelfEvalOptions): RetrievalCase[];
|
|
969
1047
|
|
|
1048
|
+
/** spec.json superset: `proposed_retrieval` holds candidate cases that are NOT scored until approved. */
|
|
1049
|
+
interface ProposedEvalSpec extends EvalSpec {
|
|
1050
|
+
proposed_retrieval?: RetrievalCase[];
|
|
1051
|
+
}
|
|
1052
|
+
/** Merge new proposed cases into a spec.json payload (dedup by name). Returns pretty JSON. */
|
|
1053
|
+
declare function appendProposedRetrievalCases(specRaw: string | null, cases: RetrievalCase[]): string;
|
|
1054
|
+
/** Approve every proposed case into the scored `retrieval` set. */
|
|
1055
|
+
declare function approveProposedCases(specRaw: string): {
|
|
1056
|
+
raw: string;
|
|
1057
|
+
approved: number;
|
|
1058
|
+
};
|
|
1059
|
+
interface TierContractCheck {
|
|
1060
|
+
name: string;
|
|
1061
|
+
expected: MemoryPriority;
|
|
1062
|
+
actual: MemoryPriority;
|
|
1063
|
+
pass: boolean;
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Ranking tier contract — the DESIGNED tier for each memory category under fixed evidence,
|
|
1067
|
+
* exercised against the INSTALLED classifier at eval time (so a packaging/regression slip fails CI,
|
|
1068
|
+
* not just the repo's own unit tests). This family is exactly what would have caught the
|
|
1069
|
+
* stack-pack dead-escape-hatch bug (see 2026-07-04-decision-stack-pack-rescue-strong-task-evidence).
|
|
1070
|
+
*/
|
|
1071
|
+
declare function runTierContract(): TierContractCheck[];
|
|
1072
|
+
|
|
970
1073
|
type ConfidenceLevel = "unverified" | "low" | "trusted" | "authoritative" | "stale";
|
|
971
1074
|
interface ConfidenceThresholds {
|
|
972
1075
|
trustedReads: number;
|
|
@@ -1973,6 +2076,7 @@ interface CommandSensorSpec {
|
|
|
1973
2076
|
/** Max runtime in ms (executor default applies when unset). */
|
|
1974
2077
|
timeout_ms?: number;
|
|
1975
2078
|
}
|
|
2079
|
+
declare function scrubbedCommandEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
1976
2080
|
/**
|
|
1977
2081
|
* Render the incident-provenance suffix appended to a fired sensor's message. Empty when the sensor
|
|
1978
2082
|
* carries no `incident` — so the behaviour-harness link ("guards the incident this test exists for")
|
|
@@ -1984,6 +2088,12 @@ declare function incidentSuffix(incident?: string): string;
|
|
|
1984
2088
|
* scoped to everywhere) the sensor is selected unconditionally. Pure: the caller executes commands.
|
|
1985
2089
|
*/
|
|
1986
2090
|
declare function selectCommandSensors(memories: Memory[], changedPaths: string[]): CommandSensorSpec[];
|
|
2091
|
+
/**
|
|
2092
|
+
* Per-file NEW-side line numbers of added lines in a unified diff. AST sensors match on the full
|
|
2093
|
+
* (parsed) file content, but must only FIRE on introductions — a hit counts when the matched
|
|
2094
|
+
* node's line range intersects the added lines of that file. Pure hunk-header arithmetic.
|
|
2095
|
+
*/
|
|
2096
|
+
declare function addedLineNumbersFromDiff(diff: string): Map<string, Set<number>>;
|
|
1987
2097
|
/** Split a unified diff into per-file targets containing only added lines. */
|
|
1988
2098
|
declare function sensorTargetsFromDiff(diff: string): SensorTarget[];
|
|
1989
2099
|
/**
|
|
@@ -2088,7 +2198,7 @@ type SensorEvaluationOutcome = "fired" | "silent" | "unrunnable";
|
|
|
2088
2198
|
interface SensorEvaluation {
|
|
2089
2199
|
at: string;
|
|
2090
2200
|
memory_id: string;
|
|
2091
|
-
kind: "regex" | "shell" | "test";
|
|
2201
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
2092
2202
|
stage: SensorEvaluationStage;
|
|
2093
2203
|
head_sha: string;
|
|
2094
2204
|
scope_hash: string;
|
|
@@ -2309,7 +2419,7 @@ declare function assessScaffoldLoop(files: Array<{
|
|
|
2309
2419
|
content: string;
|
|
2310
2420
|
}>, memories: Array<{
|
|
2311
2421
|
id: string;
|
|
2312
|
-
sensorKind?: "regex" | "shell" | "test" | null;
|
|
2422
|
+
sensorKind?: "regex" | "ast" | "shell" | "test" | null;
|
|
2313
2423
|
}>): ScaffoldLoopGap[];
|
|
2314
2424
|
|
|
2315
2425
|
/**
|
|
@@ -2685,6 +2795,29 @@ interface FailureCoverageOptions {
|
|
|
2685
2795
|
* @param captureTimes ISO created_at of every attempt/gotcha memory in the corpus
|
|
2686
2796
|
*/
|
|
2687
2797
|
declare function findUncapturedFailures(failures: FailureObservation[], captureTimes: string[], options?: FailureCoverageOptions): UncapturedFailure[];
|
|
2798
|
+
interface DistilledFailureLesson {
|
|
2799
|
+
/** Lesson title — becomes the attempt's `# what` heading and its dedup key. */
|
|
2800
|
+
what: string;
|
|
2801
|
+
/** The observed error, verbatim-ish (truncated). */
|
|
2802
|
+
why_failed: string;
|
|
2803
|
+
/** Anchor paths observed on the failing calls (project-relative, caller-normalized). */
|
|
2804
|
+
paths: string[];
|
|
2805
|
+
/** How many times this failure (same normalized summary) was observed — retries included. */
|
|
2806
|
+
occurrences: number;
|
|
2807
|
+
}
|
|
2808
|
+
/**
|
|
2809
|
+
* Cluster failure observations by normalized summary and template the top ones into PROPOSED
|
|
2810
|
+
* lesson drafts — the deterministic last leg of the passive-capture pipeline (claude-mem captures
|
|
2811
|
+
* passively; Hivelore additionally turns the failures into REVIEWABLE corpus candidates).
|
|
2812
|
+
*
|
|
2813
|
+
* Deterministic templating only — no LLM. Exploratory lookups (a grep that found nothing) are
|
|
2814
|
+
* dropped; the caller dedups against the corpus and enforces the per-session cap.
|
|
2815
|
+
*/
|
|
2816
|
+
declare function distillFailureObservations(failures: Array<FailureObservation & {
|
|
2817
|
+
files?: string[];
|
|
2818
|
+
}>, options?: {
|
|
2819
|
+
max?: number;
|
|
2820
|
+
}): DistilledFailureLesson[];
|
|
2688
2821
|
|
|
2689
2822
|
/**
|
|
2690
2823
|
* Harness coverage-gap detection — "which churny files have NO team knowledge on them?".
|
|
@@ -3013,50 +3146,6 @@ declare function readSessionHandoff(root: string): Promise<string | null>;
|
|
|
3013
3146
|
/** Age of the handoff file in milliseconds (by mtime), or null if it does not exist. */
|
|
3014
3147
|
declare function handoffAgeMs(root: string, now?: Date): Promise<number | null>;
|
|
3015
3148
|
|
|
3016
|
-
type MemoryPriority = "must_read" | "useful" | "background";
|
|
3017
|
-
/**
|
|
3018
|
-
* Normalized priority evidence. A caller fills only the signals it can compute; unknown ones default
|
|
3019
|
-
* to false (see {@link DEFAULT_PRIORITY_SIGNALS}). The MCP path has semantic scores; the CLI path has
|
|
3020
|
-
* lexical scores — both reduce to these booleans.
|
|
3021
|
-
*/
|
|
3022
|
-
interface PrioritySignals {
|
|
3023
|
-
/** Memory type (attempt, gotcha, skill, decision, …). */
|
|
3024
|
-
type: string;
|
|
3025
|
-
/** Memory tags — used for the stack-pack / env-workaround down-rank. */
|
|
3026
|
-
tags: string[];
|
|
3027
|
-
/** The memory demands explicit human approval — always surface first. */
|
|
3028
|
-
requiresHumanApproval: boolean;
|
|
3029
|
-
/** Anchored to a file the agent is editing. */
|
|
3030
|
-
directAnchor: boolean;
|
|
3031
|
-
/** Anchored to a symbol the agent requested. */
|
|
3032
|
-
directSymbol: boolean;
|
|
3033
|
-
/** Exact/literal task match (semantic match_quality "exact", or an exact lexical task hit). */
|
|
3034
|
-
exactTaskMatch: boolean;
|
|
3035
|
-
/** Strong semantic relevance (cosine ≥ 0.65). CLI has no embeddings → passes false. */
|
|
3036
|
-
strongSemantic: boolean;
|
|
3037
|
-
/** Useful-level relevance: semantic ≥ 0.35, a partial task hit, or a high lexical score. */
|
|
3038
|
-
usefulSemantic: boolean;
|
|
3039
|
-
/** Matched an inferred module or domain from the touched files. */
|
|
3040
|
-
moduleOrDomainMatch: boolean;
|
|
3041
|
-
/** A memory tag matched a task token. */
|
|
3042
|
-
tagTaskMatch: boolean;
|
|
3043
|
-
}
|
|
3044
|
-
declare const DEFAULT_PRIORITY_SIGNALS: PrioritySignals;
|
|
3045
|
-
/** Convenience: build a full signal set from a partial one. */
|
|
3046
|
-
declare function prioritySignals(partial: Partial<PrioritySignals>): PrioritySignals;
|
|
3047
|
-
/**
|
|
3048
|
-
* Classify a memory's briefing priority from its signals. Order matters:
|
|
3049
|
-
* 1. must_read — human-approval gates, direct anchor/symbol matches, and exact/strong hits on
|
|
3050
|
-
* negative (attempt) or skill memories: the things an agent must not miss.
|
|
3051
|
-
* 2. background (down-rank) — generic stack-pack seeds and local dev-environment workarounds never
|
|
3052
|
-
* claim `useful` on a semantic/tag match alone; they'd crowd out repo-specific knowledge. (A
|
|
3053
|
-
* direct anchor already promoted them to must_read above, so genuinely-relevant ones still rank.)
|
|
3054
|
-
* 3. useful — skills, module/domain matches, exact hits, and useful-level relevance.
|
|
3055
|
-
* 4. background — everything else.
|
|
3056
|
-
*/
|
|
3057
|
-
declare function classifyMemoryPriority(signals: PrioritySignals): MemoryPriority;
|
|
3058
|
-
declare function priorityRank(priority: MemoryPriority): number;
|
|
3059
|
-
|
|
3060
3149
|
/**
|
|
3061
3150
|
* Native bridge generator — produces agent-harness-specific config files
|
|
3062
3151
|
* from the Hivelore corpus (validated memories + block sensors).
|
|
@@ -3160,4 +3249,36 @@ interface AgentContext {
|
|
|
3160
3249
|
}
|
|
3161
3250
|
declare function detectAgentContext(env?: Record<string, string | undefined>): AgentContext;
|
|
3162
3251
|
|
|
3163
|
-
|
|
3252
|
+
interface ReviewLearning {
|
|
3253
|
+
/** Root comment id of the thread — the dedup unit. */
|
|
3254
|
+
thread_id: number;
|
|
3255
|
+
/** Id of the comment that carried the instruction. */
|
|
3256
|
+
comment_id: number;
|
|
3257
|
+
/** File the thread is attached to (repo-relative), when present. */
|
|
3258
|
+
path?: string;
|
|
3259
|
+
line?: number;
|
|
3260
|
+
author: string;
|
|
3261
|
+
/** The instruction text (trimmed, capped). */
|
|
3262
|
+
instruction: string;
|
|
3263
|
+
url?: string;
|
|
3264
|
+
pr_number?: number;
|
|
3265
|
+
}
|
|
3266
|
+
/** Explicit opt-in marker — a reply carrying it is ALWAYS a learning, whatever its shape. */
|
|
3267
|
+
declare const REVIEW_LEARNING_MARKER: RegExp;
|
|
3268
|
+
/**
|
|
3269
|
+
* Extract learnings from a GitHub pull-request review-comments payload.
|
|
3270
|
+
* Kept: human-authored comments that either carry the `hivelore:`/`/hivelore remember` marker or
|
|
3271
|
+
* read as an instruction. Bots are dropped (their guidance belongs to their own config), as are
|
|
3272
|
+
* short reactions. One learning per comment; the thread id ties replies to their root.
|
|
3273
|
+
*/
|
|
3274
|
+
declare function extractReviewLearnings(payload: unknown): ReviewLearning[];
|
|
3275
|
+
interface ReviewDraftOptions {
|
|
3276
|
+
scope?: "personal" | "team" | "module";
|
|
3277
|
+
module?: string;
|
|
3278
|
+
author?: string;
|
|
3279
|
+
limit?: number;
|
|
3280
|
+
}
|
|
3281
|
+
/** Template review learnings into proposed-memory drafts (reuses the scanner-ingest draft shape). */
|
|
3282
|
+
declare function reviewLearningsToDrafts(learnings: ReviewLearning[], options?: ReviewDraftOptions): MemoryDraft[];
|
|
3283
|
+
|
|
3284
|
+
export { AUTOPILOT_DEFAULTS, type Activation, type ActivationContext, ActivationSchema, type AgentContext, type Anchor, AnchorSchema, type AntiPatternGate, type AppliedConflictResolution, type AstExport, type AutoPromoteRule, BRIDGE_MARKERS, BRIDGE_TARGETS, BRIDGE_TARGET_PATH, BRIEFING_MARKER_TTL_MS, BRIEFING_PRESET_DEFAULTS, type BootstrapAssessment, type BootstrapGap, type BootstrapGate, type BootstrapMetrics, type BootstrapState, type BootstrapStateInput, type BreakingChange, type BridgeFileOutput, type BridgeMemoryEntry, type BridgeSensor, type BridgeTarget, type BriefingBudgetNumbers, type BriefingBudgetPreset, type BriefingMarker, type BriefingProofLineOptions, type BudgetPart, type BudgetSlice, type BuildCodeMapOptions, CHARS_PER_TOKEN, CODE_MAP_DEFAULT_EXCLUDE, CODE_MAP_DEFAULT_INCLUDE, CODE_MAP_FILE, CODE_STOPWORDS, CONFIG_FILE, type CaughtForYouOptions, type CaughtForYouRow, type CaughtForYouSummary, type CodeExport, type CodeExportKind, type CodeFileEntry, type CodeMap, type CodeMapQueryOptions, type CollectTimelineOpts, type CommandSensorSpec, type ConfidenceLevel, type ConfidenceThresholds, type ConflictCandidatePair, type ConflictCandidatesOpts, type ConflictResolution, type ContractDiffResult, type ContractFile, type ContractSnapshot, type CoverageGap, type CoverageOptions, CrossRepoProvenanceSchema, type CrossRepoReport, type CrossRepoSource, DECAY_DAYS, DEFAULT_AUTO_PROMOTE_RULE, DEFAULT_BRIEFING_EXCLUDE_TAGS, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_CONFIG, DEFAULT_DORMANT_DAYS, DEFAULT_PRIORITY_SIGNALS, type DashboardOptions, type DashboardReport, type DepChange, type DepTrackResult, type DependencySnapshot, type DetectStacksInput, type DetectableStack, type DistilledFailureLesson, type DocFrequency, type DormantRow, type DraftOptions, type DraftsOptions, ENV_WORKAROUND_TAGS, type EvalDelta, type EvalHistoryEntry, type EvalReport, type EvalSpec, type EvalTrend, type FailureCoverageOptions, type FailureObservation, type FeedbackAdjustment, type FeedbackAdjustmentAction, type FeedbackAdjustmentOptions, type Finding, type FindingFormat, type FindingSeverity, GUESSABLE_THRESHOLD, type GateMissProposal, type GatePrecision, type GatePrecisionDelta, type GatePrecisionMetricDelta, type GateTuningSuggestion, type GenerateBridgesOptions, type GitCommit, type GitWatchPlan, type GitWatchState, HAIVE_DIR, HAIVE_OWNED_FILES, HANDOFF_FILENAME, HIVELORE_ATTRIBUTION, type HaiveConfig, type HaivePaths, type HotFile, type HotFileSource, type ImpactOptions, type ImpactRow, type ImpactScore, type ImpactSummary, type ImpactTier, type InvalidMemoryFile, type LexicalRankResult, type LoadedMemory, MEMORIES_DIR, MIN_WORD_LEN, type Memory, type MemoryDraft, type MemoryFrontmatter, MemoryFrontmatterSchema, type MemoryPriority, type MemoryScope, MemoryScopeSchema, type MemoryStatus, MemoryStatusSchema, type MemoryType, MemoryTypeSchema, type MemoryUsage, type MergeResult, type MetricDelta, PREVENTION_DEBOUNCE_MS, PROJECT_CONTEXT_FILE, PROJECT_CONTEXT_THROTTLE_MS, type PostIncidentLesson, type PreventionEvent, type PreventionEventDetail, type PreventionReceipt, type PreventionReceiptRow, type PreventionRow, type PreventionSource, type PreventionTrend, type PrioritySignals, type ProposedEvalSpec, type ProposedSensorVerdict, REVIEW_LEARNING_MARKER, RUNTIME_JOURNAL_FILENAME, type RecurrenceReport, type RecurrenceRow, type ResolveProjectInfo, type RetirementSignal, type RetrievalAggregate, type RetrievalCase, type RetrievalCaseResult, type ReviewDraftOptions, type ReviewLearning, type RuntimeJournalEntry, SCAFFOLD_MARKER_RE, SEED_QUALITY_FLOOR, SENSOR_ABSENT_LOOKBACK, SENSOR_ABSENT_WINDOW, SESSION_RECAP_TTL_MS, STACK_PACK_TAG, type ScaffoldLoopGap, type ScaffoldOptions, type SeedProposal, type SelfEvalOptions, type Sensor, type SensorAggregate, type SensorCase, type SensorCaseResult, type SensorEvaluation, type SensorEvaluationOutcome, type SensorEvaluationStage, type SensorFlap, type SensorHealth, type SensorHit, type SensorRow, SensorSchema, type SensorSeed, type SensorSelfCheck, type SensorSuggestionOptions, type SensorTarget, type SensorWeakening, type SessionHandoffData, type SkillActivation, TEST_FRAMEWORKS, type TestFramework, type TestScaffold, type TierContractCheck, type TimelineEntry, type TopicStatusPair, type TruncateOptions, type TruncateResult, USAGE_FILE, USAGE_LOG_DIR, USAGE_LOG_FILE, type UncapturedFailure, type UsageAggregate, type UsageEvent, type UsageIndex, type VerifyOptions, type VerifyResult, addedLineNumbersFromDiff, addedLinesFromDiff, aggregateRetrieval, aggregateSensors, aggregateUsage, allocateBudget, antiPatternGateParams, appendEvalHistory, appendPreventionEvent, appendProposedRetrievalCases, appendRuntimeJournalEntry, appendSensorEvaluations, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, approveProposedCases, assessBootstrapState, assessScaffoldLoop, assessSensorHealth, bridgeMemorySummary, briefingMarkerPath, briefingMarkersDir, briefingProofLine, buildCodeMap, buildCoverageIndex, buildDashboard, buildDocFrequency, buildFrontmatter, buildHandoffMarkdown, buildPreventionReceipt, buildProposeCommand, buildReport, bumpRead, classifyMemoryPriority, codeMapPath, collectTimelineEntries, compactAutoRecapBody, compareEvalReports, compareGatePrecision, compareImpact, compileRegexSensor, componentOf, computeEvalTrend, computeGatePrecision, computeImpact, computePreventionTrend, computeRecurrence, computeScopeHash, configPath, contractLockPath, countSourceFilesOnDisk, deriveConfidence, detectAgentContext, detectSensorWeakening, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distillFailureObservations, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, existingGateMissShas, extractActionsBriefBody, extractReferencedPaths, extractReviewLearnings, extractSensorExamples, extractSnippet, extractTestFilePathsFromCommand, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, gatePassedShas, generateBridges, getUsage, globToRegExp, handoffAgeMs, handoffFilePath, hasPendingTestMarker, hasRecentBriefingMarker, hashProjectContext, incidentSuffix, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isLikelyGuessable, isNoiseSubject, isRetiredMemory, isSensorScannablePath, isSkill, isSkillSuppressed, isStackPackSeed, isStylisticRule, isTemplateProjectContext, judgeProposedSensor, lessonShortName, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadConfigSync, loadEvalHistory, loadMemoriesFromDir, loadMemoriesFromDirDetailed, loadMemory, loadPreventionEvents, loadSensorLedger, loadUsageIndex, looksLikeGenericAdvice, meetsSeedQualityFloor, memoryFilePath, memoryHasExcludedTag, memoryMatchesAnchorPaths, mergeHotFiles, mergeMemoryVersions, moduleNameOf, newMemoryId, normalizeFindingSeverity, normalizeFramework, normalizeSessionId, overallScore, parseEslintJson, parseFileAst, parseFindings, parseLessonFields, parseMemory, parseNpmAudit, parseSarif, parseSince, parseSonar, pathsOverlap, pickSnippetNeedle, pickTestFramework, planConflictResolution, planGitWatch, prepareBridgeData, preventionLogPath, priorityRank, prioritySignals, projectContextRecentlyEmitted, proposeGateMissDrafts, proposeSeedsFromCommits, pullCrossRepoSources, quarantineNote, queryCodeMap, rankMemoriesLexical, readRecentBriefingMarker, readRuntimeJournalTail, readSessionHandoff, readUsageEvents, recommendFeedbackAdjustment, recordApplied, recordPrevention, recordPreventionHits, recordProjectContextEmission, recordRejection, relPathFrom, renderBootstrapChecklist, renderCaughtForYou, renderPreventionReceipt, renderPreventionReceiptShare, resolveBriefingBudget, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, revertedShaFromCommit, reviewLearningsToDrafts, runRegexSensor, runSensors, runTierContract, runtimeJournalPath, saveCodeMap, saveConfig, saveUsageIndex, scaffoldPostIncidentTest, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, scrubbedCommandEnv, selectCommandSensors, sensorAppliesToPath, sensorLedgerPath, sensorPatternBrittleness, sensorPromotedAtMap, sensorSelfCheck, sensorTargetsFromDiff, serializeMemory, snapshotContract, specificityScore, stripPrivate, suggestGate, suggestSensorFromMemory, suggestSensorSeed, suggestTopicKey, summarizeCaughtForYou, summarizeImpact, synthesizeSelfEvalCases, tallyHotFiles, titleFromBody, tokenizeQuery, tokenizeWords, trackDependencies, trackReads, truncateToTokens, usageLogPath, usageLogSize, usagePath, verifyAnchor, watchContracts, withQuarantineNote, withoutQuarantineNote, writeBriefingMarker, writeSessionHandoff };
|