@hivelore/core 0.39.2 → 0.43.2
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 +213 -61
- package/dist/index.js +311 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -28,9 +28,18 @@ 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>;
|
|
39
|
+
/** kind=ast: full ast-grep Rule object (`kind`, `inside`, `has`, `not`, `all`, `any`, …). */
|
|
40
|
+
rule: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
41
|
+
/** kind=ast: explicit language name for extensionless/non-standard files (e.g. python, go). */
|
|
42
|
+
language: z.ZodOptional<z.ZodString>;
|
|
34
43
|
/**
|
|
35
44
|
* Optional "correct-usage" regex (kind=regex). When `pattern` (the risky call) matches but this
|
|
36
45
|
* regex ALSO appears within a small window around the match, the catch is SUPPRESSED — the diff
|
|
@@ -56,6 +65,13 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
56
65
|
* the incident the test exists to prevent". Surfaced in the block message and the prevention receipt.
|
|
57
66
|
*/
|
|
58
67
|
incident: z.ZodOptional<z.ZodString>;
|
|
68
|
+
/**
|
|
69
|
+
* kind=shell|test only: the oracle was PROVEN to fail (RED) on the incident state at arming time
|
|
70
|
+
* (`sensors propose --red-ref`): the command passed on the presumed-correct tree AND failed on
|
|
71
|
+
* the replayed incident tree. Distinguishes "a test is routed" from "the test demonstrably
|
|
72
|
+
* catches the incident". Surfaced in the prevention receipt.
|
|
73
|
+
*/
|
|
74
|
+
red_proven: z.ZodOptional<z.ZodBoolean>;
|
|
59
75
|
/** `warn` surfaces in review; `block` can hard-block the commit (only when the gate opts in). */
|
|
60
76
|
severity: z.ZodDefault<z.ZodEnum<["warn", "block"]>>;
|
|
61
77
|
/** True when Hivelore generated this sensor automatically (vs. hand-authored). */
|
|
@@ -72,27 +88,33 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
72
88
|
}, "strip", z.ZodTypeAny, {
|
|
73
89
|
message: string;
|
|
74
90
|
paths: string[];
|
|
75
|
-
kind: "regex" | "shell" | "test";
|
|
91
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
76
92
|
severity: "warn" | "block";
|
|
77
93
|
autogen: boolean;
|
|
78
94
|
last_fired: string | null;
|
|
79
95
|
pattern?: string | undefined;
|
|
96
|
+
rule?: Record<string, unknown> | undefined;
|
|
97
|
+
language?: string | undefined;
|
|
80
98
|
absent?: string | undefined;
|
|
81
99
|
flags?: string | undefined;
|
|
82
100
|
command?: string | undefined;
|
|
83
101
|
timeout_ms?: number | undefined;
|
|
84
102
|
incident?: string | undefined;
|
|
103
|
+
red_proven?: boolean | undefined;
|
|
85
104
|
promoted_at?: string | undefined;
|
|
86
105
|
}, {
|
|
87
106
|
message: string;
|
|
88
107
|
paths?: string[] | undefined;
|
|
89
|
-
kind?: "regex" | "shell" | "test" | undefined;
|
|
108
|
+
kind?: "regex" | "ast" | "shell" | "test" | undefined;
|
|
90
109
|
pattern?: string | undefined;
|
|
110
|
+
rule?: Record<string, unknown> | undefined;
|
|
111
|
+
language?: string | undefined;
|
|
91
112
|
absent?: string | undefined;
|
|
92
113
|
flags?: string | undefined;
|
|
93
114
|
command?: string | undefined;
|
|
94
115
|
timeout_ms?: number | undefined;
|
|
95
116
|
incident?: string | undefined;
|
|
117
|
+
red_proven?: boolean | undefined;
|
|
96
118
|
severity?: "warn" | "block" | undefined;
|
|
97
119
|
autogen?: boolean | undefined;
|
|
98
120
|
last_fired?: string | null | undefined;
|
|
@@ -145,9 +167,18 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
145
167
|
}>>;
|
|
146
168
|
/** Optional executable check derived from this memory (feedback computational layer). */
|
|
147
169
|
sensor: z.ZodOptional<z.ZodObject<{
|
|
148
|
-
kind: z.ZodDefault<z.ZodEnum<["regex", "shell", "test"]>>;
|
|
149
|
-
/**
|
|
170
|
+
kind: z.ZodDefault<z.ZodEnum<["regex", "ast", "shell", "test"]>>;
|
|
171
|
+
/**
|
|
172
|
+
* kind=regex: regex source, matched against added diff lines / file content.
|
|
173
|
+
* kind=ast: an ast-grep structural pattern (e.g. `stripe.paymentIntents.create($$$)`) — matched
|
|
174
|
+
* on the AST of changed files, so comments and string literals can never false-positive. Requires
|
|
175
|
+
* the optional `@ast-grep/napi` engine; without it the sensor is unrunnable (warn, never block).
|
|
176
|
+
*/
|
|
150
177
|
pattern: z.ZodOptional<z.ZodString>;
|
|
178
|
+
/** kind=ast: full ast-grep Rule object (`kind`, `inside`, `has`, `not`, `all`, `any`, …). */
|
|
179
|
+
rule: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
180
|
+
/** kind=ast: explicit language name for extensionless/non-standard files (e.g. python, go). */
|
|
181
|
+
language: z.ZodOptional<z.ZodString>;
|
|
151
182
|
/**
|
|
152
183
|
* Optional "correct-usage" regex (kind=regex). When `pattern` (the risky call) matches but this
|
|
153
184
|
* regex ALSO appears within a small window around the match, the catch is SUPPRESSED — the diff
|
|
@@ -173,6 +204,13 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
173
204
|
* the incident the test exists to prevent". Surfaced in the block message and the prevention receipt.
|
|
174
205
|
*/
|
|
175
206
|
incident: z.ZodOptional<z.ZodString>;
|
|
207
|
+
/**
|
|
208
|
+
* kind=shell|test only: the oracle was PROVEN to fail (RED) on the incident state at arming time
|
|
209
|
+
* (`sensors propose --red-ref`): the command passed on the presumed-correct tree AND failed on
|
|
210
|
+
* the replayed incident tree. Distinguishes "a test is routed" from "the test demonstrably
|
|
211
|
+
* catches the incident". Surfaced in the prevention receipt.
|
|
212
|
+
*/
|
|
213
|
+
red_proven: z.ZodOptional<z.ZodBoolean>;
|
|
176
214
|
/** `warn` surfaces in review; `block` can hard-block the commit (only when the gate opts in). */
|
|
177
215
|
severity: z.ZodDefault<z.ZodEnum<["warn", "block"]>>;
|
|
178
216
|
/** True when Hivelore generated this sensor automatically (vs. hand-authored). */
|
|
@@ -189,27 +227,33 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
189
227
|
}, "strip", z.ZodTypeAny, {
|
|
190
228
|
message: string;
|
|
191
229
|
paths: string[];
|
|
192
|
-
kind: "regex" | "shell" | "test";
|
|
230
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
193
231
|
severity: "warn" | "block";
|
|
194
232
|
autogen: boolean;
|
|
195
233
|
last_fired: string | null;
|
|
196
234
|
pattern?: string | undefined;
|
|
235
|
+
rule?: Record<string, unknown> | undefined;
|
|
236
|
+
language?: string | undefined;
|
|
197
237
|
absent?: string | undefined;
|
|
198
238
|
flags?: string | undefined;
|
|
199
239
|
command?: string | undefined;
|
|
200
240
|
timeout_ms?: number | undefined;
|
|
201
241
|
incident?: string | undefined;
|
|
242
|
+
red_proven?: boolean | undefined;
|
|
202
243
|
promoted_at?: string | undefined;
|
|
203
244
|
}, {
|
|
204
245
|
message: string;
|
|
205
246
|
paths?: string[] | undefined;
|
|
206
|
-
kind?: "regex" | "shell" | "test" | undefined;
|
|
247
|
+
kind?: "regex" | "ast" | "shell" | "test" | undefined;
|
|
207
248
|
pattern?: string | undefined;
|
|
249
|
+
rule?: Record<string, unknown> | undefined;
|
|
250
|
+
language?: string | undefined;
|
|
208
251
|
absent?: string | undefined;
|
|
209
252
|
flags?: string | undefined;
|
|
210
253
|
command?: string | undefined;
|
|
211
254
|
timeout_ms?: number | undefined;
|
|
212
255
|
incident?: string | undefined;
|
|
256
|
+
red_proven?: boolean | undefined;
|
|
213
257
|
severity?: "warn" | "block" | undefined;
|
|
214
258
|
autogen?: boolean | undefined;
|
|
215
259
|
last_fired?: string | null | undefined;
|
|
@@ -284,16 +328,19 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
284
328
|
sensor?: {
|
|
285
329
|
message: string;
|
|
286
330
|
paths: string[];
|
|
287
|
-
kind: "regex" | "shell" | "test";
|
|
331
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
288
332
|
severity: "warn" | "block";
|
|
289
333
|
autogen: boolean;
|
|
290
334
|
last_fired: string | null;
|
|
291
335
|
pattern?: string | undefined;
|
|
336
|
+
rule?: Record<string, unknown> | undefined;
|
|
337
|
+
language?: string | undefined;
|
|
292
338
|
absent?: string | undefined;
|
|
293
339
|
flags?: string | undefined;
|
|
294
340
|
command?: string | undefined;
|
|
295
341
|
timeout_ms?: number | undefined;
|
|
296
342
|
incident?: string | undefined;
|
|
343
|
+
red_proven?: boolean | undefined;
|
|
297
344
|
promoted_at?: string | undefined;
|
|
298
345
|
} | undefined;
|
|
299
346
|
activation?: {
|
|
@@ -319,13 +366,16 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
319
366
|
sensor?: {
|
|
320
367
|
message: string;
|
|
321
368
|
paths?: string[] | undefined;
|
|
322
|
-
kind?: "regex" | "shell" | "test" | undefined;
|
|
369
|
+
kind?: "regex" | "ast" | "shell" | "test" | undefined;
|
|
323
370
|
pattern?: string | undefined;
|
|
371
|
+
rule?: Record<string, unknown> | undefined;
|
|
372
|
+
language?: string | undefined;
|
|
324
373
|
absent?: string | undefined;
|
|
325
374
|
flags?: string | undefined;
|
|
326
375
|
command?: string | undefined;
|
|
327
376
|
timeout_ms?: number | undefined;
|
|
328
377
|
incident?: string | undefined;
|
|
378
|
+
red_proven?: boolean | undefined;
|
|
329
379
|
severity?: "warn" | "block" | undefined;
|
|
330
380
|
autogen?: boolean | undefined;
|
|
331
381
|
last_fired?: string | null | undefined;
|
|
@@ -372,16 +422,19 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
372
422
|
sensor?: {
|
|
373
423
|
message: string;
|
|
374
424
|
paths: string[];
|
|
375
|
-
kind: "regex" | "shell" | "test";
|
|
425
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
376
426
|
severity: "warn" | "block";
|
|
377
427
|
autogen: boolean;
|
|
378
428
|
last_fired: string | null;
|
|
379
429
|
pattern?: string | undefined;
|
|
430
|
+
rule?: Record<string, unknown> | undefined;
|
|
431
|
+
language?: string | undefined;
|
|
380
432
|
absent?: string | undefined;
|
|
381
433
|
flags?: string | undefined;
|
|
382
434
|
command?: string | undefined;
|
|
383
435
|
timeout_ms?: number | undefined;
|
|
384
436
|
incident?: string | undefined;
|
|
437
|
+
red_proven?: boolean | undefined;
|
|
385
438
|
promoted_at?: string | undefined;
|
|
386
439
|
} | undefined;
|
|
387
440
|
activation?: {
|
|
@@ -407,13 +460,16 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
407
460
|
sensor?: {
|
|
408
461
|
message: string;
|
|
409
462
|
paths?: string[] | undefined;
|
|
410
|
-
kind?: "regex" | "shell" | "test" | undefined;
|
|
463
|
+
kind?: "regex" | "ast" | "shell" | "test" | undefined;
|
|
411
464
|
pattern?: string | undefined;
|
|
465
|
+
rule?: Record<string, unknown> | undefined;
|
|
466
|
+
language?: string | undefined;
|
|
412
467
|
absent?: string | undefined;
|
|
413
468
|
flags?: string | undefined;
|
|
414
469
|
command?: string | undefined;
|
|
415
470
|
timeout_ms?: number | undefined;
|
|
416
471
|
incident?: string | undefined;
|
|
472
|
+
red_proven?: boolean | undefined;
|
|
417
473
|
severity?: "warn" | "block" | undefined;
|
|
418
474
|
autogen?: boolean | undefined;
|
|
419
475
|
last_fired?: string | null | undefined;
|
|
@@ -697,7 +753,7 @@ interface PreventionEvent {
|
|
|
697
753
|
/** Which gate path recorded it. */
|
|
698
754
|
source: PreventionSource;
|
|
699
755
|
/** Optional detail for receipts; absent on logs written before v0.35.0. */
|
|
700
|
-
kind?: "regex" | "shell" | "test";
|
|
756
|
+
kind?: "regex" | "ast" | "shell" | "test";
|
|
701
757
|
stage?: "pre-commit" | "pre-push" | "ci" | "manual";
|
|
702
758
|
exit_code?: number;
|
|
703
759
|
}
|
|
@@ -723,12 +779,14 @@ interface PreventionReceiptRow {
|
|
|
723
779
|
id: string;
|
|
724
780
|
title: string;
|
|
725
781
|
source: PreventionSource;
|
|
726
|
-
kind: "regex" | "shell" | "test" | null;
|
|
782
|
+
kind: "regex" | "ast" | "shell" | "test" | null;
|
|
727
783
|
stage: "pre-commit" | "pre-push" | "ci" | "manual" | null;
|
|
728
784
|
exit_code: number | null;
|
|
729
785
|
message: string | null;
|
|
730
786
|
/** Incident provenance from the sensor frontmatter — the behaviour-harness link, when present. */
|
|
731
787
|
incident: string | null;
|
|
788
|
+
/** The oracle was proven RED on the incident state at arming time (red_ref replay). */
|
|
789
|
+
red_proven: boolean;
|
|
732
790
|
}
|
|
733
791
|
interface PreventionReceipt {
|
|
734
792
|
generated_at: string;
|
|
@@ -836,6 +894,50 @@ declare function projectContextRecentlyEmitted(paths: HaivePaths, hash: string,
|
|
|
836
894
|
/** Record that this exact project-context body was just emitted. Best-effort. */
|
|
837
895
|
declare function recordProjectContextEmission(paths: HaivePaths, hash: string, now?: number): Promise<void>;
|
|
838
896
|
|
|
897
|
+
type MemoryPriority = "must_read" | "useful" | "background";
|
|
898
|
+
/**
|
|
899
|
+
* Normalized priority evidence. A caller fills only the signals it can compute; unknown ones default
|
|
900
|
+
* to false (see {@link DEFAULT_PRIORITY_SIGNALS}). The MCP path has semantic scores; the CLI path has
|
|
901
|
+
* lexical scores — both reduce to these booleans.
|
|
902
|
+
*/
|
|
903
|
+
interface PrioritySignals {
|
|
904
|
+
/** Memory type (attempt, gotcha, skill, decision, …). */
|
|
905
|
+
type: string;
|
|
906
|
+
/** Memory tags — used for the stack-pack / env-workaround down-rank. */
|
|
907
|
+
tags: string[];
|
|
908
|
+
/** The memory demands explicit human approval — always surface first. */
|
|
909
|
+
requiresHumanApproval: boolean;
|
|
910
|
+
/** Anchored to a file the agent is editing. */
|
|
911
|
+
directAnchor: boolean;
|
|
912
|
+
/** Anchored to a symbol the agent requested. */
|
|
913
|
+
directSymbol: boolean;
|
|
914
|
+
/** Exact/literal task match (semantic match_quality "exact", or an exact lexical task hit). */
|
|
915
|
+
exactTaskMatch: boolean;
|
|
916
|
+
/** Strong semantic relevance (cosine ≥ 0.65). CLI has no embeddings → passes false. */
|
|
917
|
+
strongSemantic: boolean;
|
|
918
|
+
/** Useful-level relevance: semantic ≥ 0.35, a partial task hit, or a high lexical score. */
|
|
919
|
+
usefulSemantic: boolean;
|
|
920
|
+
/** Matched an inferred module or domain from the touched files. */
|
|
921
|
+
moduleOrDomainMatch: boolean;
|
|
922
|
+
/** A memory tag matched a task token. */
|
|
923
|
+
tagTaskMatch: boolean;
|
|
924
|
+
}
|
|
925
|
+
declare const DEFAULT_PRIORITY_SIGNALS: PrioritySignals;
|
|
926
|
+
/** Convenience: build a full signal set from a partial one. */
|
|
927
|
+
declare function prioritySignals(partial: Partial<PrioritySignals>): PrioritySignals;
|
|
928
|
+
/**
|
|
929
|
+
* Classify a memory's briefing priority from its signals. Order matters:
|
|
930
|
+
* 1. must_read — human-approval gates, direct anchor/symbol matches, and exact/strong hits on
|
|
931
|
+
* negative (attempt) or skill memories: the things an agent must not miss.
|
|
932
|
+
* 2. background (down-rank) — generic stack-pack seeds and local dev-environment workarounds never
|
|
933
|
+
* claim `useful` on a semantic/tag match alone; they'd crowd out repo-specific knowledge. (A
|
|
934
|
+
* direct anchor already promoted them to must_read above, so genuinely-relevant ones still rank.)
|
|
935
|
+
* 3. useful — skills, module/domain matches, exact hits, and useful-level relevance.
|
|
936
|
+
* 4. background — everything else.
|
|
937
|
+
*/
|
|
938
|
+
declare function classifyMemoryPriority(signals: PrioritySignals): MemoryPriority;
|
|
939
|
+
declare function priorityRank(priority: MemoryPriority): number;
|
|
940
|
+
|
|
839
941
|
/**
|
|
840
942
|
* A rigorous, model-free, repeatable evaluation of Hivelore's core promise: surfacing
|
|
841
943
|
* the right knowledge and guardrails at the right moment. Unlike the agent benchmark
|
|
@@ -967,6 +1069,31 @@ interface SelfEvalOptions {
|
|
|
967
1069
|
*/
|
|
968
1070
|
declare function synthesizeSelfEvalCases(memories: LoadedMemory[], options?: SelfEvalOptions): RetrievalCase[];
|
|
969
1071
|
|
|
1072
|
+
/** spec.json superset: `proposed_retrieval` holds candidate cases that are NOT scored until approved. */
|
|
1073
|
+
interface ProposedEvalSpec extends EvalSpec {
|
|
1074
|
+
proposed_retrieval?: RetrievalCase[];
|
|
1075
|
+
}
|
|
1076
|
+
/** Merge new proposed cases into a spec.json payload (dedup by name). Returns pretty JSON. */
|
|
1077
|
+
declare function appendProposedRetrievalCases(specRaw: string | null, cases: RetrievalCase[]): string;
|
|
1078
|
+
/** Approve every proposed case into the scored `retrieval` set. */
|
|
1079
|
+
declare function approveProposedCases(specRaw: string): {
|
|
1080
|
+
raw: string;
|
|
1081
|
+
approved: number;
|
|
1082
|
+
};
|
|
1083
|
+
interface TierContractCheck {
|
|
1084
|
+
name: string;
|
|
1085
|
+
expected: MemoryPriority;
|
|
1086
|
+
actual: MemoryPriority;
|
|
1087
|
+
pass: boolean;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Ranking tier contract — the DESIGNED tier for each memory category under fixed evidence,
|
|
1091
|
+
* exercised against the INSTALLED classifier at eval time (so a packaging/regression slip fails CI,
|
|
1092
|
+
* not just the repo's own unit tests). This family is exactly what would have caught the
|
|
1093
|
+
* stack-pack dead-escape-hatch bug (see 2026-07-04-decision-stack-pack-rescue-strong-task-evidence).
|
|
1094
|
+
*/
|
|
1095
|
+
declare function runTierContract(): TierContractCheck[];
|
|
1096
|
+
|
|
970
1097
|
type ConfidenceLevel = "unverified" | "low" | "trusted" | "authoritative" | "stale";
|
|
971
1098
|
interface ConfidenceThresholds {
|
|
972
1099
|
trustedReads: number;
|
|
@@ -1488,6 +1615,13 @@ interface HaiveConfig {
|
|
|
1488
1615
|
* (or pass `--commands`) once the team trusts the sensors. Regex sensors always run. Default false.
|
|
1489
1616
|
*/
|
|
1490
1617
|
runCommandSensors?: boolean;
|
|
1618
|
+
/**
|
|
1619
|
+
* CI/strict-gate handling when a shell/test sensor cannot execute. `warn` preserves the
|
|
1620
|
+
* fail-open developer default; `block` treats any configured but broken oracle as a broken harness.
|
|
1621
|
+
*/
|
|
1622
|
+
commandSensorUnrunnable?: "warn" | "block";
|
|
1623
|
+
/** Require explicit resolution of a diff that demotes, rewrites, or removes a BLOCK sensor. */
|
|
1624
|
+
sensorWeakeningGate?: "warn" | "block";
|
|
1491
1625
|
/**
|
|
1492
1626
|
* How `hivelore enforce finish` reacts to hard failures observed this session that were never
|
|
1493
1627
|
* captured as a lesson (`mem_tried`):
|
|
@@ -1973,6 +2107,7 @@ interface CommandSensorSpec {
|
|
|
1973
2107
|
/** Max runtime in ms (executor default applies when unset). */
|
|
1974
2108
|
timeout_ms?: number;
|
|
1975
2109
|
}
|
|
2110
|
+
declare function scrubbedCommandEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
1976
2111
|
/**
|
|
1977
2112
|
* Render the incident-provenance suffix appended to a fired sensor's message. Empty when the sensor
|
|
1978
2113
|
* carries no `incident` — so the behaviour-harness link ("guards the incident this test exists for")
|
|
@@ -1984,6 +2119,12 @@ declare function incidentSuffix(incident?: string): string;
|
|
|
1984
2119
|
* scoped to everywhere) the sensor is selected unconditionally. Pure: the caller executes commands.
|
|
1985
2120
|
*/
|
|
1986
2121
|
declare function selectCommandSensors(memories: Memory[], changedPaths: string[]): CommandSensorSpec[];
|
|
2122
|
+
/**
|
|
2123
|
+
* Per-file NEW-side line numbers of added lines in a unified diff. AST sensors match on the full
|
|
2124
|
+
* (parsed) file content, but must only FIRE on introductions — a hit counts when the matched
|
|
2125
|
+
* node's line range intersects the added lines of that file. Pure hunk-header arithmetic.
|
|
2126
|
+
*/
|
|
2127
|
+
declare function addedLineNumbersFromDiff(diff: string): Map<string, Set<number>>;
|
|
1987
2128
|
/** Split a unified diff into per-file targets containing only added lines. */
|
|
1988
2129
|
declare function sensorTargetsFromDiff(diff: string): SensorTarget[];
|
|
1989
2130
|
/**
|
|
@@ -2088,7 +2229,7 @@ type SensorEvaluationOutcome = "fired" | "silent" | "unrunnable";
|
|
|
2088
2229
|
interface SensorEvaluation {
|
|
2089
2230
|
at: string;
|
|
2090
2231
|
memory_id: string;
|
|
2091
|
-
kind: "regex" | "shell" | "test";
|
|
2232
|
+
kind: "regex" | "ast" | "shell" | "test";
|
|
2092
2233
|
stage: SensorEvaluationStage;
|
|
2093
2234
|
head_sha: string;
|
|
2094
2235
|
scope_hash: string;
|
|
@@ -2309,7 +2450,7 @@ declare function assessScaffoldLoop(files: Array<{
|
|
|
2309
2450
|
content: string;
|
|
2310
2451
|
}>, memories: Array<{
|
|
2311
2452
|
id: string;
|
|
2312
|
-
sensorKind?: "regex" | "shell" | "test" | null;
|
|
2453
|
+
sensorKind?: "regex" | "ast" | "shell" | "test" | null;
|
|
2313
2454
|
}>): ScaffoldLoopGap[];
|
|
2314
2455
|
|
|
2315
2456
|
/**
|
|
@@ -2685,6 +2826,29 @@ interface FailureCoverageOptions {
|
|
|
2685
2826
|
* @param captureTimes ISO created_at of every attempt/gotcha memory in the corpus
|
|
2686
2827
|
*/
|
|
2687
2828
|
declare function findUncapturedFailures(failures: FailureObservation[], captureTimes: string[], options?: FailureCoverageOptions): UncapturedFailure[];
|
|
2829
|
+
interface DistilledFailureLesson {
|
|
2830
|
+
/** Lesson title — becomes the attempt's `# what` heading and its dedup key. */
|
|
2831
|
+
what: string;
|
|
2832
|
+
/** The observed error, verbatim-ish (truncated). */
|
|
2833
|
+
why_failed: string;
|
|
2834
|
+
/** Anchor paths observed on the failing calls (project-relative, caller-normalized). */
|
|
2835
|
+
paths: string[];
|
|
2836
|
+
/** How many times this failure (same normalized summary) was observed — retries included. */
|
|
2837
|
+
occurrences: number;
|
|
2838
|
+
}
|
|
2839
|
+
/**
|
|
2840
|
+
* Cluster failure observations by normalized summary and template the top ones into PROPOSED
|
|
2841
|
+
* lesson drafts — the deterministic last leg of the passive-capture pipeline (claude-mem captures
|
|
2842
|
+
* passively; Hivelore additionally turns the failures into REVIEWABLE corpus candidates).
|
|
2843
|
+
*
|
|
2844
|
+
* Deterministic templating only — no LLM. Exploratory lookups (a grep that found nothing) are
|
|
2845
|
+
* dropped; the caller dedups against the corpus and enforces the per-session cap.
|
|
2846
|
+
*/
|
|
2847
|
+
declare function distillFailureObservations(failures: Array<FailureObservation & {
|
|
2848
|
+
files?: string[];
|
|
2849
|
+
}>, options?: {
|
|
2850
|
+
max?: number;
|
|
2851
|
+
}): DistilledFailureLesson[];
|
|
2688
2852
|
|
|
2689
2853
|
/**
|
|
2690
2854
|
* Harness coverage-gap detection — "which churny files have NO team knowledge on them?".
|
|
@@ -3013,50 +3177,6 @@ declare function readSessionHandoff(root: string): Promise<string | null>;
|
|
|
3013
3177
|
/** Age of the handoff file in milliseconds (by mtime), or null if it does not exist. */
|
|
3014
3178
|
declare function handoffAgeMs(root: string, now?: Date): Promise<number | null>;
|
|
3015
3179
|
|
|
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
3180
|
/**
|
|
3061
3181
|
* Native bridge generator — produces agent-harness-specific config files
|
|
3062
3182
|
* from the Hivelore corpus (validated memories + block sensors).
|
|
@@ -3160,4 +3280,36 @@ interface AgentContext {
|
|
|
3160
3280
|
}
|
|
3161
3281
|
declare function detectAgentContext(env?: Record<string, string | undefined>): AgentContext;
|
|
3162
3282
|
|
|
3163
|
-
|
|
3283
|
+
interface ReviewLearning {
|
|
3284
|
+
/** Root comment id of the thread — the dedup unit. */
|
|
3285
|
+
thread_id: number;
|
|
3286
|
+
/** Id of the comment that carried the instruction. */
|
|
3287
|
+
comment_id: number;
|
|
3288
|
+
/** File the thread is attached to (repo-relative), when present. */
|
|
3289
|
+
path?: string;
|
|
3290
|
+
line?: number;
|
|
3291
|
+
author: string;
|
|
3292
|
+
/** The instruction text (trimmed, capped). */
|
|
3293
|
+
instruction: string;
|
|
3294
|
+
url?: string;
|
|
3295
|
+
pr_number?: number;
|
|
3296
|
+
}
|
|
3297
|
+
/** Explicit opt-in marker — a reply carrying it is ALWAYS a learning, whatever its shape. */
|
|
3298
|
+
declare const REVIEW_LEARNING_MARKER: RegExp;
|
|
3299
|
+
/**
|
|
3300
|
+
* Extract learnings from a GitHub pull-request review-comments payload.
|
|
3301
|
+
* Kept: human-authored comments that either carry the `hivelore:`/`/hivelore remember` marker or
|
|
3302
|
+
* read as an instruction. Bots are dropped (their guidance belongs to their own config), as are
|
|
3303
|
+
* short reactions. One learning per comment; the thread id ties replies to their root.
|
|
3304
|
+
*/
|
|
3305
|
+
declare function extractReviewLearnings(payload: unknown): ReviewLearning[];
|
|
3306
|
+
interface ReviewDraftOptions {
|
|
3307
|
+
scope?: "personal" | "team" | "module";
|
|
3308
|
+
module?: string;
|
|
3309
|
+
author?: string;
|
|
3310
|
+
limit?: number;
|
|
3311
|
+
}
|
|
3312
|
+
/** Template review learnings into proposed-memory drafts (reuses the scanner-ingest draft shape). */
|
|
3313
|
+
declare function reviewLearningsToDrafts(learnings: ReviewLearning[], options?: ReviewDraftOptions): MemoryDraft[];
|
|
3314
|
+
|
|
3315
|
+
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 };
|