@hivelore/core 0.35.1 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -49,6 +49,13 @@ declare const SensorSchema: z.ZodObject<{
49
49
  paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
50
50
  /** LLM-facing self-correction message: what was done wrong and what to do instead. */
51
51
  message: z.ZodString;
52
+ /**
53
+ * Optional provenance: the real incident this sensor guards against — a ticket ref, a prod
54
+ * incident id, a date ("prod #442", "INC-1029", "2026-06 refund overcharge"). This is the
55
+ * behaviour-harness link a plain test can't carry: it turns "a test failed" into "this reproduces
56
+ * the incident the test exists to prevent". Surfaced in the block message and the prevention receipt.
57
+ */
58
+ incident: z.ZodOptional<z.ZodString>;
52
59
  /** `warn` surfaces in review; `block` can hard-block the commit (only when the gate opts in). */
53
60
  severity: z.ZodDefault<z.ZodEnum<["warn", "block"]>>;
54
61
  /** True when Hivelore generated this sensor automatically (vs. hand-authored). */
@@ -74,6 +81,7 @@ declare const SensorSchema: z.ZodObject<{
74
81
  flags?: string | undefined;
75
82
  command?: string | undefined;
76
83
  timeout_ms?: number | undefined;
84
+ incident?: string | undefined;
77
85
  promoted_at?: string | undefined;
78
86
  }, {
79
87
  message: string;
@@ -84,6 +92,7 @@ declare const SensorSchema: z.ZodObject<{
84
92
  flags?: string | undefined;
85
93
  command?: string | undefined;
86
94
  timeout_ms?: number | undefined;
95
+ incident?: string | undefined;
87
96
  severity?: "warn" | "block" | undefined;
88
97
  autogen?: boolean | undefined;
89
98
  last_fired?: string | null | undefined;
@@ -157,6 +166,13 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
157
166
  paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
158
167
  /** LLM-facing self-correction message: what was done wrong and what to do instead. */
159
168
  message: z.ZodString;
169
+ /**
170
+ * Optional provenance: the real incident this sensor guards against — a ticket ref, a prod
171
+ * incident id, a date ("prod #442", "INC-1029", "2026-06 refund overcharge"). This is the
172
+ * behaviour-harness link a plain test can't carry: it turns "a test failed" into "this reproduces
173
+ * the incident the test exists to prevent". Surfaced in the block message and the prevention receipt.
174
+ */
175
+ incident: z.ZodOptional<z.ZodString>;
160
176
  /** `warn` surfaces in review; `block` can hard-block the commit (only when the gate opts in). */
161
177
  severity: z.ZodDefault<z.ZodEnum<["warn", "block"]>>;
162
178
  /** True when Hivelore generated this sensor automatically (vs. hand-authored). */
@@ -182,6 +198,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
182
198
  flags?: string | undefined;
183
199
  command?: string | undefined;
184
200
  timeout_ms?: number | undefined;
201
+ incident?: string | undefined;
185
202
  promoted_at?: string | undefined;
186
203
  }, {
187
204
  message: string;
@@ -192,6 +209,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
192
209
  flags?: string | undefined;
193
210
  command?: string | undefined;
194
211
  timeout_ms?: number | undefined;
212
+ incident?: string | undefined;
195
213
  severity?: "warn" | "block" | undefined;
196
214
  autogen?: boolean | undefined;
197
215
  last_fired?: string | null | undefined;
@@ -275,6 +293,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
275
293
  flags?: string | undefined;
276
294
  command?: string | undefined;
277
295
  timeout_ms?: number | undefined;
296
+ incident?: string | undefined;
278
297
  promoted_at?: string | undefined;
279
298
  } | undefined;
280
299
  activation?: {
@@ -306,6 +325,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
306
325
  flags?: string | undefined;
307
326
  command?: string | undefined;
308
327
  timeout_ms?: number | undefined;
328
+ incident?: string | undefined;
309
329
  severity?: "warn" | "block" | undefined;
310
330
  autogen?: boolean | undefined;
311
331
  last_fired?: string | null | undefined;
@@ -361,6 +381,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
361
381
  flags?: string | undefined;
362
382
  command?: string | undefined;
363
383
  timeout_ms?: number | undefined;
384
+ incident?: string | undefined;
364
385
  promoted_at?: string | undefined;
365
386
  } | undefined;
366
387
  activation?: {
@@ -392,6 +413,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
392
413
  flags?: string | undefined;
393
414
  command?: string | undefined;
394
415
  timeout_ms?: number | undefined;
416
+ incident?: string | undefined;
395
417
  severity?: "warn" | "block" | undefined;
396
418
  autogen?: boolean | undefined;
397
419
  last_fired?: string | null | undefined;
@@ -705,6 +727,8 @@ interface PreventionReceiptRow {
705
727
  stage: "pre-commit" | "pre-push" | "ci" | "manual" | null;
706
728
  exit_code: number | null;
707
729
  message: string | null;
730
+ /** Incident provenance from the sensor frontmatter — the behaviour-harness link, when present. */
731
+ incident: string | null;
708
732
  }
709
733
  interface PreventionReceipt {
710
734
  generated_at: string;
@@ -722,6 +746,19 @@ declare function buildPreventionReceipt(events: PreventionEvent[], memories: Loa
722
746
  now?: Date;
723
747
  }): PreventionReceipt;
724
748
  declare function renderPreventionReceipt(receipt: PreventionReceipt): string;
749
+ /**
750
+ * Attribution footer for shared receipts — the growth loop. Every time a team pastes proof of
751
+ * prevented mistakes into Slack or a PR, the artifact names the tool that produced it. Kept as one
752
+ * constant so the CLI `--share` output and the CI PR comment carry identical wording.
753
+ */
754
+ declare const HIVELORE_ATTRIBUTION = "\uD83D\uDEE1\uFE0F Generated by [Hivelore](https://github.com/Doucs91/hivelore) \u2014 the deterministic policy gate for agent-written code.";
755
+ /**
756
+ * Markdown rendering of the receipt for `hivelore stats receipt --share` and the CI PR comment —
757
+ * ready to paste into Slack or a review. Includes incident provenance and the attribution footer.
758
+ * An empty window is NOT a dead end: it renders a forward CTA (turn an incident into a guardrail),
759
+ * so the receipt is useful on day one, before any prevention has been recorded.
760
+ */
761
+ declare function renderPreventionReceiptShare(receipt: PreventionReceipt): string;
725
762
  /** Read all catch events (skips malformed lines). */
726
763
  declare function loadPreventionEvents(paths: HaivePaths): Promise<PreventionEvent[]>;
727
764
  interface PreventionTrend {
@@ -1929,11 +1966,19 @@ interface CommandSensorSpec {
1929
1966
  severity: Sensor["severity"];
1930
1967
  /** LLM-facing self-correction message carried from the sensor. */
1931
1968
  message: string;
1969
+ /** Optional incident provenance carried from the sensor (ticket/prod ref this test guards). */
1970
+ incident?: string;
1932
1971
  /** Anchor/scoped paths this sensor cares about (for reporting). */
1933
1972
  paths: string[];
1934
1973
  /** Max runtime in ms (executor default applies when unset). */
1935
1974
  timeout_ms?: number;
1936
1975
  }
1976
+ /**
1977
+ * Render the incident-provenance suffix appended to a fired sensor's message. Empty when the sensor
1978
+ * carries no `incident` — so the behaviour-harness link ("guards the incident this test exists for")
1979
+ * shows up wherever a sensor speaks, without every call site re-deriving the copy.
1980
+ */
1981
+ declare function incidentSuffix(incident?: string): string;
1937
1982
  /**
1938
1983
  * Select the shell/test sensors that apply to `changedPaths`. With no changed paths (or a sensor
1939
1984
  * scoped to everywhere) the sensor is selected unconditionally. Pure: the caller executes commands.
@@ -2969,4 +3014,4 @@ interface AgentContext {
2969
3014
  }
2970
3015
  declare function detectAgentContext(env?: Record<string, string | undefined>): AgentContext;
2971
3016
 
2972
- 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 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, 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 PreventionEvent, type PreventionEventDetail, type PreventionReceipt, type PreventionReceiptRow, type PreventionRow, type PreventionSource, type PreventionTrend, type PrioritySignals, type ProposedSensorVerdict, RUNTIME_JOURNAL_FILENAME, type RecurrenceReport, type RecurrenceRow, type ResolveProjectInfo, type RetirementSignal, type RetrievalAggregate, type RetrievalCase, type RetrievalCaseResult, type RuntimeJournalEntry, SEED_QUALITY_FLOOR, SENSOR_ABSENT_LOOKBACK, SENSOR_ABSENT_WINDOW, SESSION_RECAP_TTL_MS, STACK_PACK_TAG, 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 SessionHandoffData, type SkillActivation, 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, addedLinesFromDiff, aggregateRetrieval, aggregateSensors, aggregateUsage, allocateBudget, antiPatternGateParams, appendEvalHistory, appendPreventionEvent, appendRuntimeJournalEntry, appendSensorEvaluations, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, assessBootstrapState, assessSensorHealth, bridgeMemorySummary, briefingMarkerPath, briefingMarkersDir, briefingProofLine, buildCodeMap, buildCoverageIndex, buildDashboard, buildDocFrequency, buildFrontmatter, buildHandoffMarkdown, buildPreventionReceipt, buildReport, bumpRead, classifyMemoryPriority, codeMapPath, collectTimelineEntries, compactAutoRecapBody, compareEvalReports, compareGatePrecision, compareImpact, compileRegexSensor, componentOf, computeEvalTrend, computeGatePrecision, computeImpact, computePreventionTrend, computeRecurrence, computeScopeHash, configPath, contractLockPath, countSourceFilesOnDisk, deriveConfidence, detectAgentContext, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, existingGateMissShas, extractActionsBriefBody, extractReferencedPaths, extractSensorExamples, extractSnippet, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, gatePassedShas, generateBridges, getUsage, globToRegExp, handoffAgeMs, handoffFilePath, hasRecentBriefingMarker, hashProjectContext, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isLikelyGuessable, isNoiseSubject, isRetiredMemory, isSensorScannablePath, isSkill, isSkillSuppressed, isStackPackSeed, isStylisticRule, isTemplateProjectContext, judgeProposedSensor, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadConfigSync, loadEvalHistory, loadMemoriesFromDir, loadMemoriesFromDirDetailed, loadMemory, loadPreventionEvents, loadSensorLedger, loadUsageIndex, looksLikeGenericAdvice, meetsSeedQualityFloor, memoryFilePath, memoryHasExcludedTag, memoryMatchesAnchorPaths, mergeHotFiles, mergeMemoryVersions, moduleNameOf, newMemoryId, normalizeFindingSeverity, normalizeSessionId, overallScore, parseEslintJson, parseFileAst, parseFindings, parseMemory, parseNpmAudit, parseSarif, parseSince, parseSonar, pathsOverlap, pickSnippetNeedle, 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, resolveBriefingBudget, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, revertedShaFromCommit, runRegexSensor, runSensors, runtimeJournalPath, saveCodeMap, saveConfig, saveUsageIndex, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, 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 };
3017
+ 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 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 PreventionEvent, type PreventionEventDetail, type PreventionReceipt, type PreventionReceiptRow, type PreventionRow, type PreventionSource, type PreventionTrend, type PrioritySignals, type ProposedSensorVerdict, RUNTIME_JOURNAL_FILENAME, type RecurrenceReport, type RecurrenceRow, type ResolveProjectInfo, type RetirementSignal, type RetrievalAggregate, type RetrievalCase, type RetrievalCaseResult, type RuntimeJournalEntry, SEED_QUALITY_FLOOR, SENSOR_ABSENT_LOOKBACK, SENSOR_ABSENT_WINDOW, SESSION_RECAP_TTL_MS, STACK_PACK_TAG, 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 SessionHandoffData, type SkillActivation, 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, addedLinesFromDiff, aggregateRetrieval, aggregateSensors, aggregateUsage, allocateBudget, antiPatternGateParams, appendEvalHistory, appendPreventionEvent, appendRuntimeJournalEntry, appendSensorEvaluations, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, assessBootstrapState, assessSensorHealth, bridgeMemorySummary, briefingMarkerPath, briefingMarkersDir, briefingProofLine, buildCodeMap, buildCoverageIndex, buildDashboard, buildDocFrequency, buildFrontmatter, buildHandoffMarkdown, buildPreventionReceipt, buildReport, bumpRead, classifyMemoryPriority, codeMapPath, collectTimelineEntries, compactAutoRecapBody, compareEvalReports, compareGatePrecision, compareImpact, compileRegexSensor, componentOf, computeEvalTrend, computeGatePrecision, computeImpact, computePreventionTrend, computeRecurrence, computeScopeHash, configPath, contractLockPath, countSourceFilesOnDisk, deriveConfidence, detectAgentContext, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, existingGateMissShas, extractActionsBriefBody, extractReferencedPaths, extractSensorExamples, extractSnippet, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, gatePassedShas, generateBridges, getUsage, globToRegExp, handoffAgeMs, handoffFilePath, hasRecentBriefingMarker, hashProjectContext, incidentSuffix, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isLikelyGuessable, isNoiseSubject, isRetiredMemory, isSensorScannablePath, isSkill, isSkillSuppressed, isStackPackSeed, isStylisticRule, isTemplateProjectContext, judgeProposedSensor, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadConfigSync, loadEvalHistory, loadMemoriesFromDir, loadMemoriesFromDirDetailed, loadMemory, loadPreventionEvents, loadSensorLedger, loadUsageIndex, looksLikeGenericAdvice, meetsSeedQualityFloor, memoryFilePath, memoryHasExcludedTag, memoryMatchesAnchorPaths, mergeHotFiles, mergeMemoryVersions, moduleNameOf, newMemoryId, normalizeFindingSeverity, normalizeSessionId, overallScore, parseEslintJson, parseFileAst, parseFindings, parseMemory, parseNpmAudit, parseSarif, parseSince, parseSonar, pathsOverlap, pickSnippetNeedle, 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, runRegexSensor, runSensors, runtimeJournalPath, saveCodeMap, saveConfig, saveUsageIndex, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, 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 };
package/dist/index.js CHANGED
@@ -49,6 +49,13 @@ var SensorSchema = z.object({
49
49
  paths: z.array(z.string()).default([]),
50
50
  /** LLM-facing self-correction message: what was done wrong and what to do instead. */
51
51
  message: z.string().min(1),
52
+ /**
53
+ * Optional provenance: the real incident this sensor guards against — a ticket ref, a prod
54
+ * incident id, a date ("prod #442", "INC-1029", "2026-06 refund overcharge"). This is the
55
+ * behaviour-harness link a plain test can't carry: it turns "a test failed" into "this reproduces
56
+ * the incident the test exists to prevent". Surfaced in the block message and the prevention receipt.
57
+ */
58
+ incident: z.string().optional(),
52
59
  /** `warn` surfaces in review; `block` can hard-block the commit (only when the gate opts in). */
53
60
  severity: z.enum(["warn", "block"]).default("warn"),
54
61
  /** True when Hivelore generated this sensor automatically (vs. hand-authored). */
@@ -943,7 +950,8 @@ function buildPreventionReceipt(events, memories, usage, options) {
943
950
  kind: event.kind ?? sensor?.kind ?? (event.source === "sensor" ? "regex" : null),
944
951
  stage: event.stage ?? null,
945
952
  exit_code: event.exit_code ?? null,
946
- message: sensor?.message ?? null
953
+ message: sensor?.message ?? null,
954
+ incident: sensor?.incident ?? null
947
955
  };
948
956
  }).sort((a, b) => b.at.localeCompare(a.at));
949
957
  const preventedCountTotal = Object.values(usage.by_id).reduce((sum, item) => sum + item.prevented_count, 0);
@@ -967,13 +975,44 @@ function renderPreventionReceipt(receipt) {
967
975
  const kind = row.kind ? `${row.kind} sensor` : row.source;
968
976
  const exit = row.exit_code === null ? "" : `, exit ${row.exit_code}`;
969
977
  const stage = row.stage ? ` \u2014 caught at ${row.stage}` : "";
970
- lines.push(` \u2717\u2192\u2713 ${row.at.slice(0, 10)} ${row.id.padEnd(32)} (${kind}${exit}${stage})`);
978
+ const incident = row.incident ? ` \u21A9 incident: ${row.incident}` : "";
979
+ lines.push(` \u2717\u2192\u2713 ${row.at.slice(0, 10)} ${row.id.padEnd(32)} (${kind}${exit}${stage})${incident}`);
971
980
  }
972
981
  lines.push(
973
982
  ` Trend: ${receipt.total} this window vs ${receipt.previous_total} previous window (${receipt.total <= receipt.previous_total ? "recurrences declining" : "recurrences rising"}).`
974
983
  );
975
984
  return lines.join("\n");
976
985
  }
986
+ var HIVELORE_ATTRIBUTION = "\u{1F6E1}\uFE0F Generated by [Hivelore](https://github.com/Doucs91/hivelore) \u2014 the deterministic policy gate for agent-written code.";
987
+ function renderPreventionReceiptShare(receipt) {
988
+ const lines = [`### \u{1F6E1}\uFE0F Hivelore prevention receipt \u2014 last ${receipt.window_days} days`, ""];
989
+ if (receipt.total === 0) {
990
+ lines.push(
991
+ "No repeat mistakes reached review in this window.",
992
+ "",
993
+ "Turn a past incident into a guardrail so it can never come back:",
994
+ '`hivelore memory tried \u2026 --sensor-command "<your test>"` (add `--incident <ref>` to link the incident it guards).'
995
+ );
996
+ } else {
997
+ lines.push(
998
+ `**${receipt.total} repeat mistake${receipt.total === 1 ? "" : "s"} refused before ${receipt.total === 1 ? "it" : "they"} reached review.**`,
999
+ ""
1000
+ );
1001
+ for (const row of receipt.events) {
1002
+ const kind = row.kind ? `${row.kind} sensor` : row.source;
1003
+ const exit = row.exit_code === null ? "" : `, exit ${row.exit_code}`;
1004
+ const stage = row.stage ? ` \u2014 caught at ${row.stage}` : "";
1005
+ const incident = row.incident ? ` \u21A9 incident: ${row.incident}` : "";
1006
+ lines.push(`- \u2717\u2192\u2713 \`${row.at.slice(0, 10)}\` **${row.title}** (${kind}${exit}${stage})${incident}`);
1007
+ }
1008
+ lines.push(
1009
+ "",
1010
+ `_Trend: ${receipt.total} this window vs ${receipt.previous_total} previous window (${receipt.total <= receipt.previous_total ? "recurrences declining" : "recurrences rising"})._`
1011
+ );
1012
+ }
1013
+ lines.push("", `<sub>${HIVELORE_ATTRIBUTION}</sub>`);
1014
+ return lines.join("\n");
1015
+ }
977
1016
  async function loadPreventionEvents(paths) {
978
1017
  const file = preventionLogPath(paths);
979
1018
  if (!existsSync4(file)) return [];
@@ -3919,6 +3958,10 @@ function runSensors(memories, targets) {
3919
3958
  }
3920
3959
  return hits;
3921
3960
  }
3961
+ function incidentSuffix(incident) {
3962
+ const ref = incident?.trim();
3963
+ return ref ? ` \u21A9 guards incident: ${ref}` : "";
3964
+ }
3922
3965
  function selectCommandSensors(memories, changedPaths) {
3923
3966
  const specs = [];
3924
3967
  for (const memory of memories) {
@@ -3936,6 +3979,7 @@ function selectCommandSensors(memories, changedPaths) {
3936
3979
  kind: sensor.kind,
3937
3980
  severity: sensor.severity,
3938
3981
  message: sensor.message,
3982
+ ...sensor.incident ? { incident: sensor.incident } : {},
3939
3983
  paths: sensor.paths.length > 0 ? sensor.paths : anchorPaths,
3940
3984
  ...sensor.timeout_ms ? { timeout_ms: sensor.timeout_ms } : {}
3941
3985
  });
@@ -5688,6 +5732,7 @@ export {
5688
5732
  HAIVE_DIR,
5689
5733
  HAIVE_OWNED_FILES,
5690
5734
  HANDOFF_FILENAME,
5735
+ HIVELORE_ATTRIBUTION,
5691
5736
  MEMORIES_DIR,
5692
5737
  MIN_WORD_LEN,
5693
5738
  MemoryFrontmatterSchema,
@@ -5788,6 +5833,7 @@ export {
5788
5833
  handoffFilePath,
5789
5834
  hasRecentBriefingMarker,
5790
5835
  hashProjectContext,
5836
+ incidentSuffix,
5791
5837
  inferModulesFromPaths,
5792
5838
  isAutoPromoteEligible,
5793
5839
  isAutoRecap,
@@ -5869,6 +5915,7 @@ export {
5869
5915
  renderBootstrapChecklist,
5870
5916
  renderCaughtForYou,
5871
5917
  renderPreventionReceipt,
5918
+ renderPreventionReceiptShare,
5872
5919
  resolveBriefingBudget,
5873
5920
  resolveHaivePaths,
5874
5921
  resolveManifestFiles,