agent-inspect 6.18.0 → 6.19.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/docs/API.md +2 -1
  4. package/package.json +1 -1
  5. package/packages/cli/dist/{chunk-S4TLTLXN.mjs → chunk-R7Y5SGH5.mjs} +348 -27
  6. package/packages/cli/dist/chunk-R7Y5SGH5.mjs.map +1 -0
  7. package/packages/cli/dist/index.cjs +375 -46
  8. package/packages/cli/dist/index.cjs.map +1 -1
  9. package/packages/cli/dist/index.mjs +6 -5
  10. package/packages/cli/dist/index.mjs.map +1 -1
  11. package/packages/cli/dist/{src-R6V5EZZH.mjs → src-T4EZERCX.mjs} +3 -3
  12. package/packages/cli/dist/{src-R6V5EZZH.mjs.map → src-T4EZERCX.mjs.map} +1 -1
  13. package/packages/core/dist/advanced.cjs.map +1 -1
  14. package/packages/core/dist/advanced.d.cts +13 -2
  15. package/packages/core/dist/advanced.d.ts +13 -2
  16. package/packages/core/dist/advanced.mjs +1 -1
  17. package/packages/core/dist/advanced.mjs.map +1 -1
  18. package/packages/core/dist/checks.cjs +334 -5
  19. package/packages/core/dist/checks.cjs.map +1 -1
  20. package/packages/core/dist/checks.d.cts +81 -4
  21. package/packages/core/dist/checks.d.ts +81 -4
  22. package/packages/core/dist/checks.mjs +1 -1
  23. package/packages/core/dist/{chunk-LQC7IED3.mjs → chunk-NABMW5DX.mjs} +336 -8
  24. package/packages/core/dist/chunk-NABMW5DX.mjs.map +1 -0
  25. package/packages/core/dist/{index-B9ZGvUVL.d.ts → index-AMAGuO_i.d.ts} +1 -1
  26. package/packages/core/dist/{index-DWu54Y28.d.cts → index-DCR816Yt.d.cts} +2 -2
  27. package/packages/core/dist/{index-DlwbVqEs.d.ts → index-DKwuGSe-.d.ts} +2 -2
  28. package/packages/core/dist/{index-B259NKkH.d.cts → index-vqr-g6ev.d.cts} +1 -1
  29. package/packages/core/dist/readers.d.cts +1 -1
  30. package/packages/core/dist/readers.d.ts +1 -1
  31. package/packages/cli/dist/chunk-S4TLTLXN.mjs.map +0 -1
  32. package/packages/core/dist/chunk-LQC7IED3.mjs.map +0 -1
@@ -1,11 +1,70 @@
1
- import { L as LogicalProjectionDiagnostic, a as LogicalTraceEvent, T as TraceCheckInput, b as TraceCheckResult } from './index-DWu54Y28.cjs';
2
- export { B as BaselineRegressionRuleOptions, D as DecisionRuleOptions, G as GuardrailRuleOptions, c as LlmUsageRuleOptions, M as MaxStepDurationRuleOptions, O as ObservedOutcomeRuleOptions, R as RetrievalRuleOptions, d as RunDepthRuleOptions, e as RunDurationRuleOptions, f as RunEventCountRuleOptions, g as RunStatusRuleOptions, h as RunTraceChecksOptions, S as SafetyFindingCategory, i as SafetyFindingConfidence, j as SafetyOversizedAttributeRuleOptions, k as SafetyRawContentRuleOptions, l as SafetyRedactionRuleOptions, m as SafetySecretPattern, n as SafetySecretPatternRuleOptions, o as StallDetectionRuleOptions, p as StructureIncompleteRuleOptions, q as StructureOrphanRuleOptions, r as StructureParallelWidthRuleOptions, s as StructureRelationshipRuleOptions, t as ToolFailureRuleOptions, u as ToolOrderingRuleOptions, v as ToolUsageRuleOptions, w as TraceCheckContext, x as TraceCheckDiagnostic, y as TraceCheckDiagnosticCode, z as TraceCheckEvidence, A as TraceCheckFacts, C as TraceCheckFinding, E as TraceCheckFindingStatus, F as TraceCheckRule, H as TraceCheckRuleCategory, I as TraceCheckRuleExecution, J as TraceCheckRuleExecutionStatus, K as TraceCheckSeverity, N as TraceCheckStatus, P as TraceCheckSummary, Q as TraceSignalRuleOptions, U as createBaselineRegressionRule, V as createDecisionRule, W as createGuardrailRule, X as createLlmUsageRule, Y as createMaxStepDurationRule, Z as createObservedOutcomeRule, _ as createRequireCompletedRule, $ as createRetrievalRule, a0 as createRunDepthRule, a1 as createRunDurationRule, a2 as createRunEventCountRule, a3 as createRunStatusRule, a4 as createSafetyOversizedAttributeRule, a5 as createSafetyRawContentRule, a6 as createSafetyRedactionRule, a7 as createSafetySecretPatternRule, a8 as createStallDetectionRule, a9 as createStructureCycleRule, aa as createStructureIncompleteRule, ab as createStructureOrphanRule, ac as createStructureParallelWidthRule, ad as createStructureRelationshipRule, ae as createToolFailureRule, af as createToolOrderingRule, ag as createToolUsageRule, ah as projectLogicalEvents, ai as resolveCanonicalToolName, aj as runTraceChecks } from './index-DWu54Y28.cjs';
1
+ import { L as LogicalTraceEvent, a as LogicalProjectionDiagnostic, T as TraceCheckInput, b as TraceCheckResult } from './index-DCR816Yt.cjs';
2
+ export { B as BaselineRegressionRuleOptions, D as DecisionRuleOptions, G as GuardrailRuleOptions, c as LlmUsageRuleOptions, M as MaxStepDurationRuleOptions, O as ObservedOutcomeRuleOptions, R as RetrievalRuleOptions, d as RunDepthRuleOptions, e as RunDurationRuleOptions, f as RunEventCountRuleOptions, g as RunStatusRuleOptions, h as RunTraceChecksOptions, S as SafetyFindingCategory, i as SafetyFindingConfidence, j as SafetyOversizedAttributeRuleOptions, k as SafetyRawContentRuleOptions, l as SafetyRedactionRuleOptions, m as SafetySecretPattern, n as SafetySecretPatternRuleOptions, o as StallDetectionRuleOptions, p as StructureIncompleteRuleOptions, q as StructureOrphanRuleOptions, r as StructureParallelWidthRuleOptions, s as StructureRelationshipRuleOptions, t as ToolFailureRuleOptions, u as ToolOrderingRuleOptions, v as ToolUsageRuleOptions, w as TraceCheckContext, x as TraceCheckDiagnostic, y as TraceCheckDiagnosticCode, z as TraceCheckEvidence, A as TraceCheckFacts, C as TraceCheckFinding, E as TraceCheckFindingStatus, F as TraceCheckRule, H as TraceCheckRuleCategory, I as TraceCheckRuleExecution, J as TraceCheckRuleExecutionStatus, K as TraceCheckSeverity, N as TraceCheckStatus, P as TraceCheckSummary, Q as TraceSignalRuleOptions, U as createBaselineRegressionRule, V as createDecisionRule, W as createGuardrailRule, X as createLlmUsageRule, Y as createMaxStepDurationRule, Z as createObservedOutcomeRule, _ as createRequireCompletedRule, $ as createRetrievalRule, a0 as createRunDepthRule, a1 as createRunDurationRule, a2 as createRunEventCountRule, a3 as createRunStatusRule, a4 as createSafetyOversizedAttributeRule, a5 as createSafetyRawContentRule, a6 as createSafetyRedactionRule, a7 as createSafetySecretPatternRule, a8 as createStallDetectionRule, a9 as createStructureCycleRule, aa as createStructureIncompleteRule, ab as createStructureOrphanRule, ac as createStructureParallelWidthRule, ad as createStructureRelationshipRule, ae as createToolFailureRule, af as createToolOrderingRule, ag as createToolUsageRule, ah as projectLogicalEvents, ai as resolveCanonicalToolName, aj as runTraceChecks } from './index-DCR816Yt.cjs';
3
3
  export { PROGRAMMATIC_DIAGNOSTIC_SPECS, ProgrammaticDiagnosticCode, ProgrammaticDiagnosticSpec, formatProgrammaticDiagnostic } from './readers.cjs';
4
- import { T as TraceReadResult } from './index-B259NKkH.cjs';
4
+ import { a as TraceReadResult } from './index-vqr-g6ev.cjs';
5
5
  import { P as PersistedInspectEvent } from './persisted-inspect-event-CVZWZldL.cjs';
6
6
  import './inspect-event-DRthdZlf.cjs';
7
7
  import './types-B562HgN_.cjs';
8
8
 
9
+ /**
10
+ * Read-time derived failure roles for TraceFacts (6.19).
11
+ *
12
+ * Failure roles classify recorded error events using explicit or conservatively
13
+ * correlated retry/recovery relationships. They never rewrite persisted status.
14
+ *
15
+ * @experimental Available through `agent-inspect/checks`.
16
+ */
17
+
18
+ /**
19
+ * Derived classification of a recorded failure.
20
+ *
21
+ * @experimental
22
+ */
23
+ type DerivedFailureRole = "transient" | "recovered" | "terminal" | "unknown";
24
+ /**
25
+ * Confidence for a derived failure classification.
26
+ *
27
+ * @experimental
28
+ */
29
+ type DerivedFailureConfidence = "explicit" | "correlated" | "unknown";
30
+ /**
31
+ * One derived failure fact over a logical error event.
32
+ *
33
+ * @experimental
34
+ */
35
+ interface DerivedFailureFact {
36
+ readonly eventId: string;
37
+ readonly runId: string;
38
+ readonly name: string;
39
+ readonly kind: LogicalTraceEvent["kind"];
40
+ readonly role: DerivedFailureRole;
41
+ readonly confidence: DerivedFailureConfidence;
42
+ readonly basis: readonly string[];
43
+ readonly recoveryEventIds: readonly string[];
44
+ readonly retryRunIds: readonly string[];
45
+ }
46
+ /**
47
+ * Bounded role counts for MCP / Evidence parity.
48
+ *
49
+ * @experimental
50
+ */
51
+ interface FailureRoleCounts {
52
+ readonly transient: number;
53
+ readonly recovered: number;
54
+ readonly terminal: number;
55
+ readonly unknown: number;
56
+ }
57
+ /**
58
+ * Derive conservative failure roles over logical events.
59
+ *
60
+ * @experimental
61
+ */
62
+ declare function deriveFailureFacts(logicalEvents: readonly LogicalTraceEvent[]): {
63
+ failureFacts: readonly DerivedFailureFact[];
64
+ failuresByRole: ReadonlyMap<DerivedFailureRole, readonly DerivedFailureFact[]>;
65
+ failureRoleCounts: FailureRoleCounts;
66
+ };
67
+
9
68
  /**
10
69
  * Shared semantic parity summary over logical lifecycle projection.
11
70
  *
@@ -26,6 +85,12 @@ interface SemanticParitySummary {
26
85
  readonly pairedCount: number;
27
86
  readonly parentRemapCount: number;
28
87
  readonly diagnostics: readonly LogicalProjectionDiagnostic[];
88
+ /**
89
+ * Bounded derived failure role counts (6.19+). Additive; older readers ignore.
90
+ *
91
+ * @experimental
92
+ */
93
+ readonly failureRoleCounts?: FailureRoleCounts;
29
94
  }
30
95
  /**
31
96
  * Summarize logical projection for cross-surface parity assertions.
@@ -48,6 +113,18 @@ interface TraceFacts {
48
113
  readonly llmEvents: readonly LogicalTraceEvent[];
49
114
  readonly outcomeEvents: readonly LogicalTraceEvent[];
50
115
  readonly summary: SemanticParitySummary;
116
+ /**
117
+ * Read-time derived failure classifications. Does not rewrite persisted status.
118
+ *
119
+ * @experimental Additive in 6.19.
120
+ */
121
+ readonly failureFacts: readonly DerivedFailureFact[];
122
+ /**
123
+ * Derived failure facts grouped by role.
124
+ *
125
+ * @experimental Additive in 6.19.
126
+ */
127
+ readonly failuresByRole: ReadonlyMap<DerivedFailureRole, readonly DerivedFailureFact[]>;
51
128
  }
52
129
  /**
53
130
  * Build TraceFacts from a TraceReadResult or normalized persisted events.
@@ -146,4 +223,4 @@ declare function evaluateTraceContractRead(read: TraceReadResult, contract: Trac
146
223
  runId?: string;
147
224
  }): TraceCheckResult;
148
225
 
149
- export { LogicalProjectionDiagnostic, LogicalTraceEvent, type SemanticParitySummary, TraceCheckInput, TraceCheckResult, type TraceContract, type TraceContractInput, type TraceContractLlmRules, type TraceContractObservationRules, type TraceContractRunRules, type TraceContractToolRules, type TraceFacts, buildTraceFacts, defineTraceContract, evaluateTraceContract, evaluateTraceContractRead, summarizeSemanticParity };
226
+ export { type DerivedFailureConfidence, type DerivedFailureFact, type DerivedFailureRole, type FailureRoleCounts, LogicalProjectionDiagnostic, LogicalTraceEvent, type SemanticParitySummary, TraceCheckInput, TraceCheckResult, type TraceContract, type TraceContractInput, type TraceContractLlmRules, type TraceContractObservationRules, type TraceContractRunRules, type TraceContractToolRules, type TraceFacts, buildTraceFacts, defineTraceContract, deriveFailureFacts, evaluateTraceContract, evaluateTraceContractRead, summarizeSemanticParity };
@@ -1,11 +1,70 @@
1
- import { L as LogicalProjectionDiagnostic, a as LogicalTraceEvent, T as TraceCheckInput, b as TraceCheckResult } from './index-DlwbVqEs.js';
2
- export { B as BaselineRegressionRuleOptions, D as DecisionRuleOptions, G as GuardrailRuleOptions, c as LlmUsageRuleOptions, M as MaxStepDurationRuleOptions, O as ObservedOutcomeRuleOptions, R as RetrievalRuleOptions, d as RunDepthRuleOptions, e as RunDurationRuleOptions, f as RunEventCountRuleOptions, g as RunStatusRuleOptions, h as RunTraceChecksOptions, S as SafetyFindingCategory, i as SafetyFindingConfidence, j as SafetyOversizedAttributeRuleOptions, k as SafetyRawContentRuleOptions, l as SafetyRedactionRuleOptions, m as SafetySecretPattern, n as SafetySecretPatternRuleOptions, o as StallDetectionRuleOptions, p as StructureIncompleteRuleOptions, q as StructureOrphanRuleOptions, r as StructureParallelWidthRuleOptions, s as StructureRelationshipRuleOptions, t as ToolFailureRuleOptions, u as ToolOrderingRuleOptions, v as ToolUsageRuleOptions, w as TraceCheckContext, x as TraceCheckDiagnostic, y as TraceCheckDiagnosticCode, z as TraceCheckEvidence, A as TraceCheckFacts, C as TraceCheckFinding, E as TraceCheckFindingStatus, F as TraceCheckRule, H as TraceCheckRuleCategory, I as TraceCheckRuleExecution, J as TraceCheckRuleExecutionStatus, K as TraceCheckSeverity, N as TraceCheckStatus, P as TraceCheckSummary, Q as TraceSignalRuleOptions, U as createBaselineRegressionRule, V as createDecisionRule, W as createGuardrailRule, X as createLlmUsageRule, Y as createMaxStepDurationRule, Z as createObservedOutcomeRule, _ as createRequireCompletedRule, $ as createRetrievalRule, a0 as createRunDepthRule, a1 as createRunDurationRule, a2 as createRunEventCountRule, a3 as createRunStatusRule, a4 as createSafetyOversizedAttributeRule, a5 as createSafetyRawContentRule, a6 as createSafetyRedactionRule, a7 as createSafetySecretPatternRule, a8 as createStallDetectionRule, a9 as createStructureCycleRule, aa as createStructureIncompleteRule, ab as createStructureOrphanRule, ac as createStructureParallelWidthRule, ad as createStructureRelationshipRule, ae as createToolFailureRule, af as createToolOrderingRule, ag as createToolUsageRule, ah as projectLogicalEvents, ai as resolveCanonicalToolName, aj as runTraceChecks } from './index-DlwbVqEs.js';
1
+ import { L as LogicalTraceEvent, a as LogicalProjectionDiagnostic, T as TraceCheckInput, b as TraceCheckResult } from './index-DKwuGSe-.js';
2
+ export { B as BaselineRegressionRuleOptions, D as DecisionRuleOptions, G as GuardrailRuleOptions, c as LlmUsageRuleOptions, M as MaxStepDurationRuleOptions, O as ObservedOutcomeRuleOptions, R as RetrievalRuleOptions, d as RunDepthRuleOptions, e as RunDurationRuleOptions, f as RunEventCountRuleOptions, g as RunStatusRuleOptions, h as RunTraceChecksOptions, S as SafetyFindingCategory, i as SafetyFindingConfidence, j as SafetyOversizedAttributeRuleOptions, k as SafetyRawContentRuleOptions, l as SafetyRedactionRuleOptions, m as SafetySecretPattern, n as SafetySecretPatternRuleOptions, o as StallDetectionRuleOptions, p as StructureIncompleteRuleOptions, q as StructureOrphanRuleOptions, r as StructureParallelWidthRuleOptions, s as StructureRelationshipRuleOptions, t as ToolFailureRuleOptions, u as ToolOrderingRuleOptions, v as ToolUsageRuleOptions, w as TraceCheckContext, x as TraceCheckDiagnostic, y as TraceCheckDiagnosticCode, z as TraceCheckEvidence, A as TraceCheckFacts, C as TraceCheckFinding, E as TraceCheckFindingStatus, F as TraceCheckRule, H as TraceCheckRuleCategory, I as TraceCheckRuleExecution, J as TraceCheckRuleExecutionStatus, K as TraceCheckSeverity, N as TraceCheckStatus, P as TraceCheckSummary, Q as TraceSignalRuleOptions, U as createBaselineRegressionRule, V as createDecisionRule, W as createGuardrailRule, X as createLlmUsageRule, Y as createMaxStepDurationRule, Z as createObservedOutcomeRule, _ as createRequireCompletedRule, $ as createRetrievalRule, a0 as createRunDepthRule, a1 as createRunDurationRule, a2 as createRunEventCountRule, a3 as createRunStatusRule, a4 as createSafetyOversizedAttributeRule, a5 as createSafetyRawContentRule, a6 as createSafetyRedactionRule, a7 as createSafetySecretPatternRule, a8 as createStallDetectionRule, a9 as createStructureCycleRule, aa as createStructureIncompleteRule, ab as createStructureOrphanRule, ac as createStructureParallelWidthRule, ad as createStructureRelationshipRule, ae as createToolFailureRule, af as createToolOrderingRule, ag as createToolUsageRule, ah as projectLogicalEvents, ai as resolveCanonicalToolName, aj as runTraceChecks } from './index-DKwuGSe-.js';
3
3
  export { PROGRAMMATIC_DIAGNOSTIC_SPECS, ProgrammaticDiagnosticCode, ProgrammaticDiagnosticSpec, formatProgrammaticDiagnostic } from './readers.js';
4
- import { T as TraceReadResult } from './index-B9ZGvUVL.js';
4
+ import { a as TraceReadResult } from './index-AMAGuO_i.js';
5
5
  import { P as PersistedInspectEvent } from './persisted-inspect-event-BVucFVrP.js';
6
6
  import './inspect-event-DRthdZlf.js';
7
7
  import './types-B562HgN_.js';
8
8
 
9
+ /**
10
+ * Read-time derived failure roles for TraceFacts (6.19).
11
+ *
12
+ * Failure roles classify recorded error events using explicit or conservatively
13
+ * correlated retry/recovery relationships. They never rewrite persisted status.
14
+ *
15
+ * @experimental Available through `agent-inspect/checks`.
16
+ */
17
+
18
+ /**
19
+ * Derived classification of a recorded failure.
20
+ *
21
+ * @experimental
22
+ */
23
+ type DerivedFailureRole = "transient" | "recovered" | "terminal" | "unknown";
24
+ /**
25
+ * Confidence for a derived failure classification.
26
+ *
27
+ * @experimental
28
+ */
29
+ type DerivedFailureConfidence = "explicit" | "correlated" | "unknown";
30
+ /**
31
+ * One derived failure fact over a logical error event.
32
+ *
33
+ * @experimental
34
+ */
35
+ interface DerivedFailureFact {
36
+ readonly eventId: string;
37
+ readonly runId: string;
38
+ readonly name: string;
39
+ readonly kind: LogicalTraceEvent["kind"];
40
+ readonly role: DerivedFailureRole;
41
+ readonly confidence: DerivedFailureConfidence;
42
+ readonly basis: readonly string[];
43
+ readonly recoveryEventIds: readonly string[];
44
+ readonly retryRunIds: readonly string[];
45
+ }
46
+ /**
47
+ * Bounded role counts for MCP / Evidence parity.
48
+ *
49
+ * @experimental
50
+ */
51
+ interface FailureRoleCounts {
52
+ readonly transient: number;
53
+ readonly recovered: number;
54
+ readonly terminal: number;
55
+ readonly unknown: number;
56
+ }
57
+ /**
58
+ * Derive conservative failure roles over logical events.
59
+ *
60
+ * @experimental
61
+ */
62
+ declare function deriveFailureFacts(logicalEvents: readonly LogicalTraceEvent[]): {
63
+ failureFacts: readonly DerivedFailureFact[];
64
+ failuresByRole: ReadonlyMap<DerivedFailureRole, readonly DerivedFailureFact[]>;
65
+ failureRoleCounts: FailureRoleCounts;
66
+ };
67
+
9
68
  /**
10
69
  * Shared semantic parity summary over logical lifecycle projection.
11
70
  *
@@ -26,6 +85,12 @@ interface SemanticParitySummary {
26
85
  readonly pairedCount: number;
27
86
  readonly parentRemapCount: number;
28
87
  readonly diagnostics: readonly LogicalProjectionDiagnostic[];
88
+ /**
89
+ * Bounded derived failure role counts (6.19+). Additive; older readers ignore.
90
+ *
91
+ * @experimental
92
+ */
93
+ readonly failureRoleCounts?: FailureRoleCounts;
29
94
  }
30
95
  /**
31
96
  * Summarize logical projection for cross-surface parity assertions.
@@ -48,6 +113,18 @@ interface TraceFacts {
48
113
  readonly llmEvents: readonly LogicalTraceEvent[];
49
114
  readonly outcomeEvents: readonly LogicalTraceEvent[];
50
115
  readonly summary: SemanticParitySummary;
116
+ /**
117
+ * Read-time derived failure classifications. Does not rewrite persisted status.
118
+ *
119
+ * @experimental Additive in 6.19.
120
+ */
121
+ readonly failureFacts: readonly DerivedFailureFact[];
122
+ /**
123
+ * Derived failure facts grouped by role.
124
+ *
125
+ * @experimental Additive in 6.19.
126
+ */
127
+ readonly failuresByRole: ReadonlyMap<DerivedFailureRole, readonly DerivedFailureFact[]>;
51
128
  }
52
129
  /**
53
130
  * Build TraceFacts from a TraceReadResult or normalized persisted events.
@@ -146,4 +223,4 @@ declare function evaluateTraceContractRead(read: TraceReadResult, contract: Trac
146
223
  runId?: string;
147
224
  }): TraceCheckResult;
148
225
 
149
- export { LogicalProjectionDiagnostic, LogicalTraceEvent, type SemanticParitySummary, TraceCheckInput, TraceCheckResult, type TraceContract, type TraceContractInput, type TraceContractLlmRules, type TraceContractObservationRules, type TraceContractRunRules, type TraceContractToolRules, type TraceFacts, buildTraceFacts, defineTraceContract, evaluateTraceContract, evaluateTraceContractRead, summarizeSemanticParity };
226
+ export { type DerivedFailureConfidence, type DerivedFailureFact, type DerivedFailureRole, type FailureRoleCounts, LogicalProjectionDiagnostic, LogicalTraceEvent, type SemanticParitySummary, TraceCheckInput, TraceCheckResult, type TraceContract, type TraceContractInput, type TraceContractLlmRules, type TraceContractObservationRules, type TraceContractRunRules, type TraceContractToolRules, type TraceFacts, buildTraceFacts, defineTraceContract, deriveFailureFacts, evaluateTraceContract, evaluateTraceContractRead, summarizeSemanticParity };
@@ -1,4 +1,4 @@
1
- export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, evaluateTraceContract, evaluateTraceContractRead, projectLogicalEvents, resolveCanonicalToolName, runTraceChecks, summarizeSemanticParity } from './chunk-LQC7IED3.mjs';
1
+ export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, deriveFailureFacts, evaluateTraceContract, evaluateTraceContractRead, projectLogicalEvents, resolveCanonicalToolName, runTraceChecks, summarizeSemanticParity } from './chunk-NABMW5DX.mjs';
2
2
  import './chunk-VFO76UH3.mjs';
3
3
  import './chunk-ULCGIRTC.mjs';
4
4
  import './chunk-VU6O5QAH.mjs';
@@ -300,6 +300,325 @@ function pickString(record, keys) {
300
300
  return void 0;
301
301
  }
302
302
 
303
+ // packages/core/src/checks/derived-failure.ts
304
+ function isRecord2(value) {
305
+ return typeof value === "object" && value !== null && !Array.isArray(value);
306
+ }
307
+ function pickString2(record, keys) {
308
+ if (!record) return void 0;
309
+ for (const key of keys) {
310
+ const value = record[key];
311
+ if (typeof value === "string" && value.trim() !== "") return value;
312
+ }
313
+ return void 0;
314
+ }
315
+ function pickNumber(record, keys) {
316
+ if (!record) return void 0;
317
+ for (const key of keys) {
318
+ const value = record[key];
319
+ if (typeof value === "number" && Number.isFinite(value) && value > 0) {
320
+ return value;
321
+ }
322
+ }
323
+ return void 0;
324
+ }
325
+ function eventMetadata(event) {
326
+ const attrs = isRecord2(event.attributes) ? event.attributes : void 0;
327
+ const nested = attrs !== void 0 && isRecord2(attrs.metadata) ? attrs.metadata : void 0;
328
+ return {
329
+ ...attrs ?? {},
330
+ ...nested ?? {}
331
+ };
332
+ }
333
+ function canonicalName(event) {
334
+ if (event.kind === "TOOL") return resolveCanonicalToolName(event);
335
+ return event.name;
336
+ }
337
+ function linkKeys(event) {
338
+ const meta = eventMetadata(event);
339
+ const keys = [];
340
+ for (const key of ["linkedStepId", "toolCallId", "mcpToolCallId"]) {
341
+ const value = pickString2(meta, [key]);
342
+ if (value !== void 0) keys.push(`${key}:${value}`);
343
+ }
344
+ const stepId = pickString2(meta, ["stepId"]);
345
+ if (stepId !== void 0) keys.push(`stepId:${stepId}`);
346
+ return keys;
347
+ }
348
+ function buildRunContexts(logicalEvents) {
349
+ const byRun = /* @__PURE__ */ new Map();
350
+ for (const event of logicalEvents) {
351
+ const existing = byRun.get(event.runId) ?? {
352
+ runId: event.runId,
353
+ name: event.name
354
+ };
355
+ const meta = eventMetadata(event);
356
+ if (event.kind === "RUN" || existing.name === event.runId) {
357
+ existing.name = event.name || existing.name;
358
+ }
359
+ if (event.kind === "RUN" && event.status !== void 0 && event.status !== "running") {
360
+ existing.status = event.status;
361
+ }
362
+ existing.retryOf ??= pickString2(meta, ["retryOf"]);
363
+ existing.attempt ??= pickNumber(meta, ["attempt", "retryAttempt", "retryCount"]);
364
+ existing.sessionId ??= pickString2(meta, ["sessionId", "conversationId"]);
365
+ existing.groupId ??= pickString2(meta, ["groupId"]);
366
+ existing.parentGroupId ??= pickString2(meta, ["parentGroupId"]);
367
+ existing.fallbackOf ??= pickString2(meta, ["fallbackOf", "fallbackFrom"]);
368
+ byRun.set(event.runId, existing);
369
+ }
370
+ return byRun;
371
+ }
372
+ function sameCorrelationScope(a, b) {
373
+ if (a.sessionId && b.sessionId && a.sessionId === b.sessionId) return true;
374
+ if (a.groupId && b.groupId && a.groupId === b.groupId) return true;
375
+ if (a.parentGroupId && b.parentGroupId && a.parentGroupId === b.parentGroupId) {
376
+ return true;
377
+ }
378
+ return false;
379
+ }
380
+ function isSuccessful(event) {
381
+ return event.status === "ok";
382
+ }
383
+ function isFailure(event) {
384
+ return event.status === "error";
385
+ }
386
+ function compareEventOrder(a, b) {
387
+ const byTime = a.timestamp.localeCompare(b.timestamp);
388
+ if (byTime !== 0) return byTime;
389
+ return a.eventId.localeCompare(b.eventId);
390
+ }
391
+ function collectCandidates(failure, logicalEvents, runs) {
392
+ const failureRun = runs.get(failure.runId);
393
+ const failureLinks = new Set(linkKeys(failure));
394
+ const failureName = canonicalName(failure);
395
+ const failureAttempt = pickNumber(eventMetadata(failure), ["attempt", "retryAttempt", "retryCount"]) ?? failureRun?.attempt;
396
+ const candidates = [];
397
+ for (const event of logicalEvents) {
398
+ if (event.eventId === failure.eventId) continue;
399
+ if (event.status === "running") continue;
400
+ const eventRun = runs.get(event.runId);
401
+ const eventMeta = eventMetadata(event);
402
+ const sameRun = event.runId === failure.runId;
403
+ if (eventRun?.retryOf === failure.runId) {
404
+ candidates.push({
405
+ event,
406
+ basis: "retryOf",
407
+ confidence: "explicit",
408
+ viaRunId: event.runId
409
+ });
410
+ continue;
411
+ }
412
+ if (eventRun?.fallbackOf === failure.runId || pickString2(eventMeta, ["fallbackOf", "fallbackFrom"]) === failure.runId) {
413
+ candidates.push({
414
+ event,
415
+ basis: "fallbackOf",
416
+ confidence: "explicit",
417
+ viaRunId: event.runId
418
+ });
419
+ continue;
420
+ }
421
+ if (sameRun && compareEventOrder(failure, event) >= 0) continue;
422
+ const eventLinks = linkKeys(event);
423
+ const sharedLink = eventLinks.find((key) => failureLinks.has(key));
424
+ if (sharedLink !== void 0) {
425
+ candidates.push({
426
+ event,
427
+ basis: sharedLink.split(":")[0] ?? "linkedId",
428
+ confidence: "explicit"
429
+ });
430
+ continue;
431
+ }
432
+ const eventAttempt = pickNumber(eventMeta, ["attempt", "retryAttempt", "retryCount"]) ?? eventRun?.attempt;
433
+ const sameParent = failure.parentId !== void 0 && event.parentId !== void 0 && failure.parentId === event.parentId;
434
+ const differentParent = failure.parentId !== void 0 && event.parentId !== void 0 && failure.parentId !== event.parentId;
435
+ const sessionScoped = failureRun !== void 0 && eventRun !== void 0 && sameCorrelationScope(failureRun, eventRun);
436
+ if (canonicalName(event) === failureName && failureAttempt !== void 0 && eventAttempt !== void 0 && eventAttempt > failureAttempt && !differentParent && (sameParent || sessionScoped || sameRun)) {
437
+ candidates.push({
438
+ event,
439
+ basis: "attempt-progression",
440
+ confidence: "correlated",
441
+ ...event.runId !== failure.runId ? { viaRunId: event.runId } : {}
442
+ });
443
+ }
444
+ }
445
+ const byId = /* @__PURE__ */ new Map();
446
+ for (const candidate of candidates) {
447
+ const prev = byId.get(candidate.event.eventId);
448
+ if (!prev || prev.confidence !== "explicit" && candidate.confidence === "explicit") {
449
+ byId.set(candidate.event.eventId, candidate);
450
+ }
451
+ }
452
+ return [...byId.values()].sort((a, b) => compareEventOrder(a.event, b.event));
453
+ }
454
+ function classifyFailure(failure, candidates, runs, logicalEvents) {
455
+ const successful = candidates.filter((c) => isSuccessful(c.event));
456
+ const unsuccessful = candidates.filter((c) => !isSuccessful(c.event));
457
+ const retryRunIds = Object.freeze(
458
+ [...new Set(candidates.map((c) => c.viaRunId).filter((id) => id !== void 0))].sort(
459
+ (a, b) => a.localeCompare(b)
460
+ )
461
+ );
462
+ if (successful.length > 1) {
463
+ const distinctRuns = new Set(successful.map((c) => c.event.runId));
464
+ const distinctParents = new Set(
465
+ successful.map((c) => c.event.parentId ?? "").filter((id) => id !== "")
466
+ );
467
+ if (distinctRuns.size > 1 || distinctParents.size > 1) {
468
+ return {
469
+ eventId: failure.eventId,
470
+ runId: failure.runId,
471
+ name: failure.name,
472
+ kind: failure.kind,
473
+ role: "unknown",
474
+ confidence: "unknown",
475
+ basis: Object.freeze(["ambiguous-recovery-candidates"]),
476
+ recoveryEventIds: Object.freeze(
477
+ successful.map((c) => c.event.eventId).sort((a, b) => a.localeCompare(b))
478
+ ),
479
+ retryRunIds
480
+ };
481
+ }
482
+ }
483
+ if (successful.length >= 1) {
484
+ const best = successful[0];
485
+ return {
486
+ eventId: failure.eventId,
487
+ runId: failure.runId,
488
+ name: failure.name,
489
+ kind: failure.kind,
490
+ role: "recovered",
491
+ confidence: best.confidence,
492
+ basis: Object.freeze([best.basis]),
493
+ recoveryEventIds: Object.freeze(
494
+ successful.map((c) => c.event.eventId).sort((a, b) => a.localeCompare(b))
495
+ ),
496
+ retryRunIds
497
+ };
498
+ }
499
+ if (candidates.length > 0) {
500
+ const best = candidates[0];
501
+ return {
502
+ eventId: failure.eventId,
503
+ runId: failure.runId,
504
+ name: failure.name,
505
+ kind: failure.kind,
506
+ role: "transient",
507
+ confidence: best.confidence,
508
+ basis: Object.freeze([
509
+ best.basis,
510
+ unsuccessful.some((c) => c.event.status === void 0) ? "retry-incomplete" : "retry-without-success"
511
+ ]),
512
+ recoveryEventIds: Object.freeze([]),
513
+ retryRunIds
514
+ };
515
+ }
516
+ const failureMeta = eventMetadata(failure);
517
+ const declaredSuccessor = pickString2(failureMeta, [
518
+ "retriedBy",
519
+ "nextRetryRunId",
520
+ "retryRunId"
521
+ ]);
522
+ if (declaredSuccessor !== void 0 && !runs.has(declaredSuccessor)) {
523
+ return {
524
+ eventId: failure.eventId,
525
+ runId: failure.runId,
526
+ name: failure.name,
527
+ kind: failure.kind,
528
+ role: "transient",
529
+ confidence: "explicit",
530
+ basis: Object.freeze(["retry-declared", "retry-run-missing"]),
531
+ recoveryEventIds: Object.freeze([]),
532
+ retryRunIds: Object.freeze([declaredSuccessor])
533
+ };
534
+ }
535
+ for (const run of runs.values()) {
536
+ if (run.retryOf === failure.runId) {
537
+ return {
538
+ eventId: failure.eventId,
539
+ runId: failure.runId,
540
+ name: failure.name,
541
+ kind: failure.kind,
542
+ role: "transient",
543
+ confidence: "explicit",
544
+ basis: Object.freeze(["retryOf", "retry-run-missing-or-empty"]),
545
+ recoveryEventIds: Object.freeze([]),
546
+ retryRunIds: Object.freeze([run.runId])
547
+ };
548
+ }
549
+ }
550
+ const failureRun = runs.get(failure.runId);
551
+ const hasSuccessorDeclared = [...runs.values()].some((run) => run.retryOf === failure.runId);
552
+ const isFinalInChain = failureRun !== void 0 && !hasSuccessorDeclared && (failureRun.retryOf !== void 0 || failureRun.attempt !== void 0 && failureRun.attempt > 1 || pickNumber(eventMetadata(failure), ["attempt"]) !== void 0);
553
+ if (isFinalInChain && failureRun?.status === "error" && !logicalEvents.some(
554
+ (event) => event.runId === failure.runId && event.eventId !== failure.eventId && isSuccessful(event) && canonicalName(event) === canonicalName(failure)
555
+ )) {
556
+ return {
557
+ eventId: failure.eventId,
558
+ runId: failure.runId,
559
+ name: failure.name,
560
+ kind: failure.kind,
561
+ role: "terminal",
562
+ confidence: failureRun.retryOf !== void 0 ? "explicit" : "correlated",
563
+ basis: Object.freeze(["final-retry-chain-member", "enclosing-run-error"]),
564
+ recoveryEventIds: Object.freeze([]),
565
+ retryRunIds: Object.freeze(
566
+ failureRun.retryOf !== void 0 ? [failureRun.retryOf] : []
567
+ )
568
+ };
569
+ }
570
+ return {
571
+ eventId: failure.eventId,
572
+ runId: failure.runId,
573
+ name: failure.name,
574
+ kind: failure.kind,
575
+ role: "unknown",
576
+ confidence: "unknown",
577
+ basis: Object.freeze(["no-explicit-or-correlated-recovery"]),
578
+ recoveryEventIds: Object.freeze([]),
579
+ retryRunIds: Object.freeze([])
580
+ };
581
+ }
582
+ function deriveFailureFacts(logicalEvents) {
583
+ const runs = buildRunContexts(logicalEvents);
584
+ const failures = logicalEvents.filter((event) => isFailure(event)).sort(compareEventOrder);
585
+ const failureFacts = failures.map(
586
+ (failure) => classifyFailure(failure, collectCandidates(failure, logicalEvents, runs), runs, logicalEvents)
587
+ );
588
+ const byRole = /* @__PURE__ */ new Map([
589
+ ["transient", []],
590
+ ["recovered", []],
591
+ ["terminal", []],
592
+ ["unknown", []]
593
+ ]);
594
+ for (const fact of failureFacts) {
595
+ byRole.get(fact.role).push(fact);
596
+ }
597
+ for (const [role, list] of byRole) {
598
+ byRole.set(
599
+ role,
600
+ Object.freeze(
601
+ [...list].sort((a, b) => {
602
+ const byRun = a.runId.localeCompare(b.runId);
603
+ if (byRun !== 0) return byRun;
604
+ return a.eventId.localeCompare(b.eventId);
605
+ })
606
+ )
607
+ );
608
+ }
609
+ const failureRoleCounts = {
610
+ transient: byRole.get("transient").length,
611
+ recovered: byRole.get("recovered").length,
612
+ terminal: byRole.get("terminal").length,
613
+ unknown: byRole.get("unknown").length
614
+ };
615
+ return {
616
+ failureFacts: Object.freeze(failureFacts),
617
+ failuresByRole: byRole,
618
+ failureRoleCounts
619
+ };
620
+ }
621
+
303
622
  // packages/core/src/checks/trace-facts.ts
304
623
  function summarizeSemanticParity(events) {
305
624
  const projection = projectLogicalEvents(events);
@@ -310,6 +629,7 @@ function summarizeSemanticParity(events) {
310
629
  const finishedToolNames = Object.freeze(
311
630
  finishedTools.map((event) => resolveCanonicalToolName(event)).sort((a, b) => a.localeCompare(b))
312
631
  );
632
+ const derived = deriveFailureFacts(logical);
313
633
  return {
314
634
  rawEventCount: events.length,
315
635
  logicalEventCount: logical.length,
@@ -320,7 +640,8 @@ function summarizeSemanticParity(events) {
320
640
  parentRemapCount: projection.diagnostics.filter(
321
641
  (item) => item.code === "AI_LOGICAL_PARENT_REMAPPED"
322
642
  ).length,
323
- diagnostics: projection.diagnostics
643
+ diagnostics: projection.diagnostics,
644
+ failureRoleCounts: derived.failureRoleCounts
324
645
  };
325
646
  }
326
647
  var TRACE_FACTS_INPUT_NOT_NORMALIZED = formatProgrammaticDiagnostic(
@@ -383,6 +704,8 @@ function buildTraceFacts(input) {
383
704
  for (const [name, list] of [...toolsByName.entries()]) {
384
705
  toolsByName.set(name, Object.freeze([...list]));
385
706
  }
707
+ const derived = deriveFailureFacts(projection.logicalEvents);
708
+ const summary = summarizeSemanticParity(events);
386
709
  return {
387
710
  rawEvents: Object.freeze([...events]),
388
711
  logicalEvents: projection.logicalEvents,
@@ -390,7 +713,12 @@ function buildTraceFacts(input) {
390
713
  toolsByName,
391
714
  llmEvents: Object.freeze(llmEvents),
392
715
  outcomeEvents: Object.freeze(outcomeEvents),
393
- summary: summarizeSemanticParity(events)
716
+ summary: {
717
+ ...summary,
718
+ failureRoleCounts: derived.failureRoleCounts
719
+ },
720
+ failureFacts: derived.failureFacts,
721
+ failuresByRole: derived.failuresByRole
394
722
  };
395
723
  }
396
724
 
@@ -867,7 +1195,7 @@ function firstIndexByName(events) {
867
1195
  }
868
1196
  return index;
869
1197
  }
870
- function isRecord2(value) {
1198
+ function isRecord3(value) {
871
1199
  return typeof value === "object" && value !== null && !Array.isArray(value);
872
1200
  }
873
1201
  function eventMap(events) {
@@ -921,7 +1249,7 @@ function pushValueEntries(entries, event, value, path, key, depth = 0) {
921
1249
  }
922
1250
  return;
923
1251
  }
924
- if (!isRecord2(value)) return;
1252
+ if (!isRecord3(value)) return;
925
1253
  for (const nestedKey of Object.keys(value).sort((a, b) => a.localeCompare(b))) {
926
1254
  pushValueEntries(
927
1255
  entries,
@@ -2016,7 +2344,7 @@ function createSafetyOversizedAttributeRule(options) {
2016
2344
  )
2017
2345
  );
2018
2346
  }
2019
- if (isRecord2(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
2347
+ if (isRecord3(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
2020
2348
  findings.push(
2021
2349
  failFinding(
2022
2350
  "safety.oversizedAttribute",
@@ -2492,6 +2820,6 @@ function evaluateTraceContractRead(read, contract, options = {}) {
2492
2820
  return evaluateTraceContract({ read }, contract, options);
2493
2821
  }
2494
2822
 
2495
- export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, evaluateTraceContract, evaluateTraceContractRead, projectLogicalEvents, resolveCanonicalToolName, runTraceChecks, summarizeSemanticParity };
2496
- //# sourceMappingURL=chunk-LQC7IED3.mjs.map
2497
- //# sourceMappingURL=chunk-LQC7IED3.mjs.map
2823
+ export { buildTraceFacts, createBaselineRegressionRule, createDecisionRule, createGuardrailRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRetrievalRule, createRunDepthRule, createRunDurationRule, createRunEventCountRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStructureCycleRule, createStructureIncompleteRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolFailureRule, createToolOrderingRule, createToolUsageRule, defineTraceContract, deriveFailureFacts, evaluateTraceContract, evaluateTraceContractRead, projectLogicalEvents, resolveCanonicalToolName, runTraceChecks, summarizeSemanticParity };
2824
+ //# sourceMappingURL=chunk-NABMW5DX.mjs.map
2825
+ //# sourceMappingURL=chunk-NABMW5DX.mjs.map