agent-inspect 6.29.4 → 6.29.5
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/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/docs/LIMITATIONS.md +1 -1
- package/docs/TRACE-CONTRACTS.md +1 -1
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-FJRUJSST.mjs → chunk-XWQEHKGB.mjs} +41 -29
- package/packages/cli/dist/chunk-XWQEHKGB.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +194 -70
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +146 -43
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-GZQVDREP.mjs → src-XNC4EUN3.mjs} +3 -3
- package/packages/cli/dist/{src-GZQVDREP.mjs.map → src-XNC4EUN3.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +20 -9
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.d.cts +10 -10
- package/packages/core/dist/advanced.d.ts +10 -10
- package/packages/core/dist/advanced.mjs +15 -14
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.cjs +45 -31
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.d.cts +7 -7
- package/packages/core/dist/checks.d.ts +7 -7
- package/packages/core/dist/checks.mjs +5 -5
- package/packages/core/dist/{chunk-7LSVGXCN.mjs → chunk-26YJSETN.mjs} +3 -3
- package/packages/core/dist/{chunk-7LSVGXCN.mjs.map → chunk-26YJSETN.mjs.map} +1 -1
- package/packages/core/dist/{chunk-5M4QUYFH.mjs → chunk-BGF5JDJN.mjs} +3 -3
- package/packages/core/dist/{chunk-5M4QUYFH.mjs.map → chunk-BGF5JDJN.mjs.map} +1 -1
- package/packages/core/dist/{chunk-3I6KX32E.mjs → chunk-EE5Z2GQ3.mjs} +20 -12
- package/packages/core/dist/chunk-EE5Z2GQ3.mjs.map +1 -0
- package/packages/core/dist/{chunk-FKVCTIP6.mjs → chunk-KWBO36PH.mjs} +4 -4
- package/packages/core/dist/{chunk-FKVCTIP6.mjs.map → chunk-KWBO36PH.mjs.map} +1 -1
- package/packages/core/dist/{chunk-BMRK6XHO.mjs → chunk-PBNBQRXV.mjs} +4 -4
- package/packages/core/dist/{chunk-BMRK6XHO.mjs.map → chunk-PBNBQRXV.mjs.map} +1 -1
- package/packages/core/dist/{chunk-KNRY24RS.mjs → chunk-Q5SLKV2Y.mjs} +3 -3
- package/packages/core/dist/{chunk-KNRY24RS.mjs.map → chunk-Q5SLKV2Y.mjs.map} +1 -1
- package/packages/core/dist/{chunk-XPDNO3KH.mjs → chunk-TU47EKKS.mjs} +29 -34
- package/packages/core/dist/chunk-TU47EKKS.mjs.map +1 -0
- package/packages/core/dist/{chunk-AT7TICCQ.mjs → chunk-WN5PT4GV.mjs} +4 -4
- package/packages/core/dist/{chunk-AT7TICCQ.mjs.map → chunk-WN5PT4GV.mjs.map} +1 -1
- package/packages/core/dist/{chunk-DZBNXCLA.mjs → chunk-ZFJ2ICTC.mjs} +5 -5
- package/packages/core/dist/{chunk-DZBNXCLA.mjs.map → chunk-ZFJ2ICTC.mjs.map} +1 -1
- package/packages/core/dist/{context-B8zzsmjX.d.ts → context-B7DqUmsJ.d.ts} +3 -3
- package/packages/core/dist/{context-BhaVHtOT.d.cts → context-rR_jW9TH.d.cts} +3 -3
- package/packages/core/dist/diff.d.cts +3 -3
- package/packages/core/dist/diff.d.ts +3 -3
- package/packages/core/dist/exporters.d.cts +3 -3
- package/packages/core/dist/exporters.d.ts +3 -3
- package/packages/core/dist/exporters.mjs +5 -5
- package/packages/core/dist/{index-BT3KcO6-.d.cts → index-Cdww9h50.d.cts} +2 -2
- package/packages/core/dist/{index-BaQ48jrq.d.cts → index-DKv7esIo.d.cts} +4 -4
- package/packages/core/dist/{index-CrnEOoRu.d.ts → index-DvSbXNot.d.ts} +4 -4
- package/packages/core/dist/{index-reskZCVW.d.ts → index-xUbdpcrP.d.ts} +2 -2
- package/packages/core/dist/index.cjs +11 -9
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.d.cts +6 -6
- package/packages/core/dist/index.d.ts +6 -6
- package/packages/core/dist/index.mjs +6 -6
- package/packages/core/dist/{inspect-event-CDqjcrG_.d.cts → inspect-event-ClM5Z8om.d.cts} +6 -1
- package/packages/core/dist/{inspect-event-CDqjcrG_.d.ts → inspect-event-ClM5Z8om.d.ts} +6 -1
- package/packages/core/dist/{log-config-DcjV8ZjF.d.cts → log-config-CyRGaaWd.d.cts} +1 -1
- package/packages/core/dist/{log-config-N_c5AE09.d.ts → log-config-DAV_sR9A.d.ts} +1 -1
- package/packages/core/dist/logs.d.cts +3 -3
- package/packages/core/dist/logs.d.ts +3 -3
- package/packages/core/dist/{persisted-inspect-event-BMwvGIB8.d.ts → persisted-inspect-event-DG02LhEP.d.ts} +1 -1
- package/packages/core/dist/{persisted-inspect-event-DPaCiars.d.cts → persisted-inspect-event-q2ViiBW6.d.cts} +1 -1
- package/packages/core/dist/persisted.cjs +11 -9
- package/packages/core/dist/persisted.cjs.map +1 -1
- package/packages/core/dist/persisted.d.cts +5 -5
- package/packages/core/dist/persisted.d.ts +5 -5
- package/packages/core/dist/persisted.mjs +3 -3
- package/packages/core/dist/readers.cjs +11 -9
- package/packages/core/dist/readers.cjs.map +1 -1
- package/packages/core/dist/readers.d.cts +3 -3
- package/packages/core/dist/readers.d.ts +3 -3
- package/packages/core/dist/readers.mjs +4 -4
- package/packages/core/dist/{types-C5Y8Idle.d.ts → types-BX1EPji1.d.ts} +1 -1
- package/packages/core/dist/{types-BSzhK7Z1.d.cts → types-bwL8cBv5.d.cts} +1 -1
- package/packages/core/dist/writers.cjs +11 -9
- package/packages/core/dist/writers.cjs.map +1 -1
- package/packages/core/dist/writers.d.cts +2 -2
- package/packages/core/dist/writers.d.ts +2 -2
- package/packages/core/dist/writers.mjs +3 -3
- package/packages/cli/dist/chunk-FJRUJSST.mjs.map +0 -1
- package/packages/core/dist/chunk-3I6KX32E.mjs.map +0 -1
- package/packages/core/dist/chunk-XPDNO3KH.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, resolveBundleRunIds, getTraceFilePath, openTrace, sha256Hex, collectTraceSchemaVersions, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceHtmlShell, buildEvidenceProvenanceViewHtml, EVIDENCE_FORMAT_VERSION, inferEvidenceFileRole, buildEvidenceSafetyViewHtml, buildEvidenceDiffViewHtml, buildEvidenceCircuitViewHtml, buildEvidenceOutcomesViewHtml, buildEvidenceContractsViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceCausalFailureViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceTreeViewHtml, buildEvidenceManifest, serializeEvidenceManifest, buildZipArchive, assertBundlePathContained, enrichSessionRunRecord, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, runTraceChecks, assertEvidenceRelativePath, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, TraceReadError, resolveRedactionProfile, applyProfileMetadataCaps, Redactor, flattenTree, escapeHtml, safeString, compactAttributes, stableJson, escapeMarkdown, truncateStringForProfile, extractMetadata, filterTraces, truncateName, buildRunSummary, formatDuration, formatTimestamp, renderErrorLine, isAgentInspectTrace, filterMetasBySessionScope, aggregateSessionCheckResults, createBaselineRegressionRule, summarizeSemanticParity, buildEvidenceCiPackage, verifyEvidenceDirectory, diffTraceEvents, renderRunDiff, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, formatStepLabel, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, getIndent, TreeBuilder, zeroKinds, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, diffRuns, manualTraceEventsToComparableRun } from './chunk-
|
|
2
|
+
import { ATTRIBUTION_CONFIDENCES, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, resolveBundleRunIds, getTraceFilePath, openTrace, sha256Hex, collectTraceSchemaVersions, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceHtmlShell, buildEvidenceProvenanceViewHtml, EVIDENCE_FORMAT_VERSION, inferEvidenceFileRole, buildEvidenceSafetyViewHtml, buildEvidenceDiffViewHtml, buildEvidenceCircuitViewHtml, buildEvidenceOutcomesViewHtml, buildEvidenceContractsViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceCausalFailureViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceTreeViewHtml, buildEvidenceManifest, serializeEvidenceManifest, buildZipArchive, assertBundlePathContained, enrichSessionRunRecord, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, runTraceChecks, assertEvidenceRelativePath, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, TraceReadError, resolveRedactionProfile, applyProfileMetadataCaps, Redactor, flattenTree, escapeHtml, safeString, compactAttributes, stableJson, escapeMarkdown, truncateStringForProfile, extractMetadata, filterTraces, truncateName, buildRunSummary, formatDuration, formatTimestamp, renderErrorLine, isAgentInspectTrace, filterMetasBySessionScope, aggregateSessionCheckResults, createBaselineRegressionRule, summarizeSemanticParity, buildEvidenceCiPackage, verifyEvidenceDirectory, diffTraceEvents, renderRunDiff, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, formatStepLabel, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, getIndent, TreeBuilder, zeroKinds, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, projectLogicalEvents, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, isAttributionConfidence, diffRuns, manualTraceEventsToComparableRun } from './chunk-XWQEHKGB.mjs';
|
|
3
3
|
import { realpathSync, constants as constants$1, existsSync, readFileSync } from 'fs';
|
|
4
4
|
import path19 from 'path';
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
@@ -13,7 +13,7 @@ import { createServer } from 'http';
|
|
|
13
13
|
import { createRequire } from 'module';
|
|
14
14
|
|
|
15
15
|
// package.json
|
|
16
|
-
var version = "6.29.
|
|
16
|
+
var version = "6.29.5";
|
|
17
17
|
|
|
18
18
|
// packages/cli/src/trace-dir-scale.ts
|
|
19
19
|
var TRACE_COUNT_WARN = 1e3;
|
|
@@ -3397,7 +3397,7 @@ async function newestTraceMtimeMs(traceDir) {
|
|
|
3397
3397
|
}
|
|
3398
3398
|
async function loadSessionRuns(traceDir) {
|
|
3399
3399
|
try {
|
|
3400
|
-
const mod = await import('./src-
|
|
3400
|
+
const mod = await import('./src-XNC4EUN3.mjs');
|
|
3401
3401
|
const dbPath = mod.resolveIndexDbPath(traceDir);
|
|
3402
3402
|
const status = mod.indexStatus(dbPath);
|
|
3403
3403
|
if (!status.healthy) {
|
|
@@ -5959,12 +5959,22 @@ function open2(ruleId, message, evidence, severity = "error") {
|
|
|
5959
5959
|
};
|
|
5960
5960
|
}
|
|
5961
5961
|
function isToolEvent(event) {
|
|
5962
|
+
const kind = typeof event.kind === "string" ? event.kind.toLowerCase() : "";
|
|
5963
|
+
if (kind === "tool") return true;
|
|
5964
|
+
if (kind === "llm" || kind === "run" || kind === "agent" || kind === "logic" || kind === "log" || kind === "outcome" || kind === "chain" || kind === "retriever" || kind === "decision" || kind === "result" || kind === "error") {
|
|
5965
|
+
return false;
|
|
5966
|
+
}
|
|
5962
5967
|
const name = event.name.toLowerCase();
|
|
5963
|
-
return
|
|
5968
|
+
return name.startsWith("tool:") || name.startsWith("function:") || name.includes(".tool.") || name.startsWith("mcp:");
|
|
5964
5969
|
}
|
|
5965
5970
|
function isLlmEvent(event) {
|
|
5971
|
+
const kind = typeof event.kind === "string" ? event.kind.toLowerCase() : "";
|
|
5972
|
+
if (kind === "llm") return true;
|
|
5973
|
+
if (kind === "tool" || kind === "run" || kind === "agent" || kind === "logic" || kind === "log" || kind === "outcome" || kind === "chain" || kind === "retriever" || kind === "decision" || kind === "result" || kind === "error") {
|
|
5974
|
+
return false;
|
|
5975
|
+
}
|
|
5966
5976
|
const name = event.name.toLowerCase();
|
|
5967
|
-
return
|
|
5977
|
+
return name.startsWith("llm:") || name.includes(".llm.") || name.includes("generation");
|
|
5968
5978
|
}
|
|
5969
5979
|
function toolLabel(event) {
|
|
5970
5980
|
const attrs = event.attributes ?? {};
|
|
@@ -6409,6 +6419,14 @@ var CIRCUIT_ALIASES = {
|
|
|
6409
6419
|
"runaway-llm-loop": "circuit.runaway-llm-loop",
|
|
6410
6420
|
"excessive-branch-width": "circuit.excessive-branch-width"
|
|
6411
6421
|
};
|
|
6422
|
+
var KNOWN_CIRCUIT_RULES = /* @__PURE__ */ new Set([
|
|
6423
|
+
...Object.values(CIRCUIT_ALIASES),
|
|
6424
|
+
...ALL_RULES
|
|
6425
|
+
]);
|
|
6426
|
+
var KNOWN_GUARDRAIL_RULES = /* @__PURE__ */ new Set([
|
|
6427
|
+
...Object.values(GUARDRAIL_ALIASES),
|
|
6428
|
+
...ALL_RULES2
|
|
6429
|
+
]);
|
|
6412
6430
|
function parseGuardrailRules(values) {
|
|
6413
6431
|
if (!values?.length) return void 0;
|
|
6414
6432
|
return values.map((value) => {
|
|
@@ -6471,16 +6489,21 @@ function eventToCircuit(event) {
|
|
|
6471
6489
|
status: event.status
|
|
6472
6490
|
};
|
|
6473
6491
|
}
|
|
6474
|
-
function
|
|
6492
|
+
function scopedEvents(read, runId) {
|
|
6493
|
+
if (runId === void 0) return [...read.events];
|
|
6494
|
+
return read.events.filter((event) => event.runId === runId);
|
|
6495
|
+
}
|
|
6496
|
+
function collectGuardrailInputs(events) {
|
|
6475
6497
|
const inputs = [];
|
|
6476
|
-
for (const event of
|
|
6498
|
+
for (const event of events) {
|
|
6477
6499
|
const attrs = event.attributes ?? {};
|
|
6478
6500
|
for (const key of ["output", "answer", "text", "content", "message"]) {
|
|
6479
6501
|
const value = attrs[key];
|
|
6480
6502
|
if (typeof value === "string") inputs.push({ text: value });
|
|
6481
6503
|
else if (value !== void 0) inputs.push({ value });
|
|
6482
6504
|
}
|
|
6483
|
-
|
|
6505
|
+
const kind = typeof event.kind === "string" ? event.kind.toLowerCase() : "";
|
|
6506
|
+
if (kind === "tool" || event.name.startsWith("tool:")) {
|
|
6484
6507
|
inputs.push({
|
|
6485
6508
|
toolName: String(attrs.toolName ?? attrs.tool ?? event.name),
|
|
6486
6509
|
toolArgs: attrs.arguments ?? attrs.args ?? attrs.input
|
|
@@ -6489,6 +6512,21 @@ function collectGuardrailInputs(read) {
|
|
|
6489
6512
|
}
|
|
6490
6513
|
return inputs;
|
|
6491
6514
|
}
|
|
6515
|
+
function classifyExtensionExecution(findings, errored) {
|
|
6516
|
+
if (errored) return "error";
|
|
6517
|
+
if (findings.some((finding) => finding.status === "fail")) return "fail";
|
|
6518
|
+
if (findings.some((finding) => finding.status === "warning")) return "warning";
|
|
6519
|
+
return "pass";
|
|
6520
|
+
}
|
|
6521
|
+
function extensionExecution(ruleId, findings, options) {
|
|
6522
|
+
return {
|
|
6523
|
+
ruleId,
|
|
6524
|
+
category: "safety",
|
|
6525
|
+
status: classifyExtensionExecution(findings, options.errored === true),
|
|
6526
|
+
findingCount: findings.length,
|
|
6527
|
+
...options.runId !== void 0 ? { runId: options.runId } : {}
|
|
6528
|
+
};
|
|
6529
|
+
}
|
|
6492
6530
|
var DEFAULT_GUARDRAIL_OPTIONS = {
|
|
6493
6531
|
bannedPhrase: { phrases: ["delete all data", "ignore all instructions"] },
|
|
6494
6532
|
promptInjection: {},
|
|
@@ -6505,53 +6543,116 @@ var DEFAULT_CIRCUIT_OPTIONS = {
|
|
|
6505
6543
|
};
|
|
6506
6544
|
function mergeSafetyExtensions(result, read, options) {
|
|
6507
6545
|
const findings = [...result.findings];
|
|
6546
|
+
const ruleExecutions = [...result.ruleExecutions ?? []];
|
|
6508
6547
|
let failed = result.summary.failed;
|
|
6509
6548
|
let warnings = result.summary.warnings;
|
|
6510
6549
|
let passed = result.summary.passed;
|
|
6550
|
+
let errors = result.summary.errors;
|
|
6551
|
+
const events = scopedEvents(read, options.runId);
|
|
6552
|
+
const runId = options.runId;
|
|
6511
6553
|
const guardrailRules = parseGuardrailRules(options.guardrails);
|
|
6512
6554
|
if (guardrailRules) {
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6555
|
+
const inputs = collectGuardrailInputs(events);
|
|
6556
|
+
for (const ruleId of guardrailRules) {
|
|
6557
|
+
if (!KNOWN_GUARDRAIL_RULES.has(ruleId)) {
|
|
6558
|
+
const finding = {
|
|
6559
|
+
ruleId,
|
|
6560
|
+
severity: "error",
|
|
6561
|
+
status: "fail",
|
|
6562
|
+
message: `Unknown guardrail rule: ${ruleId}.`,
|
|
6563
|
+
evidence: []
|
|
6564
|
+
};
|
|
6520
6565
|
findings.push(finding);
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6566
|
+
failed += 1;
|
|
6567
|
+
ruleExecutions.push(extensionExecution(ruleId, [finding], { runId, errored: true }));
|
|
6568
|
+
errors += 1;
|
|
6569
|
+
continue;
|
|
6570
|
+
}
|
|
6571
|
+
const ruleFindings = [];
|
|
6572
|
+
if (inputs.length === 0) {
|
|
6573
|
+
ruleExecutions.push(extensionExecution(ruleId, [], { runId }));
|
|
6574
|
+
continue;
|
|
6524
6575
|
}
|
|
6576
|
+
for (const input3 of inputs) {
|
|
6577
|
+
const run = runGuardrails(input3, {
|
|
6578
|
+
...DEFAULT_GUARDRAIL_OPTIONS,
|
|
6579
|
+
rules: [ruleId]
|
|
6580
|
+
});
|
|
6581
|
+
for (const item of run.results) {
|
|
6582
|
+
const finding = guardrailFinding(item);
|
|
6583
|
+
ruleFindings.push(finding);
|
|
6584
|
+
findings.push(finding);
|
|
6585
|
+
if (finding.status === "fail") failed += 1;
|
|
6586
|
+
else if (finding.status === "warning") warnings += 1;
|
|
6587
|
+
else passed += 1;
|
|
6588
|
+
}
|
|
6589
|
+
}
|
|
6590
|
+
ruleExecutions.push(extensionExecution(ruleId, ruleFindings, { runId }));
|
|
6525
6591
|
}
|
|
6526
6592
|
}
|
|
6527
6593
|
const circuitRules = parseCircuitRules(options.circuits);
|
|
6528
6594
|
if (circuitRules) {
|
|
6529
|
-
const
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6595
|
+
const projected = projectLogicalEvents(events);
|
|
6596
|
+
const circuitEvents = projected.logicalEvents.map(eventToCircuit);
|
|
6597
|
+
for (const ruleId of circuitRules) {
|
|
6598
|
+
if (!KNOWN_CIRCUIT_RULES.has(ruleId)) {
|
|
6599
|
+
const finding = {
|
|
6600
|
+
ruleId,
|
|
6601
|
+
severity: "error",
|
|
6602
|
+
status: "fail",
|
|
6603
|
+
message: `Unknown circuit rule: ${ruleId}.`,
|
|
6604
|
+
evidence: []
|
|
6605
|
+
};
|
|
6606
|
+
findings.push(finding);
|
|
6607
|
+
failed += 1;
|
|
6608
|
+
errors += 1;
|
|
6609
|
+
ruleExecutions.push(extensionExecution(ruleId, [finding], { runId, errored: true }));
|
|
6610
|
+
continue;
|
|
6611
|
+
}
|
|
6612
|
+
const circuitRun = runCircuits(circuitEvents, {
|
|
6613
|
+
...DEFAULT_CIRCUIT_OPTIONS,
|
|
6614
|
+
rules: [ruleId]
|
|
6615
|
+
});
|
|
6616
|
+
if (circuitRun.results.length === 0) {
|
|
6617
|
+
const finding = {
|
|
6618
|
+
ruleId,
|
|
6619
|
+
severity: "error",
|
|
6620
|
+
status: "fail",
|
|
6621
|
+
message: `Circuit rule ${ruleId} produced no evaluation result.`,
|
|
6622
|
+
evidence: []
|
|
6623
|
+
};
|
|
6624
|
+
findings.push(finding);
|
|
6625
|
+
failed += 1;
|
|
6626
|
+
errors += 1;
|
|
6627
|
+
ruleExecutions.push(extensionExecution(ruleId, [finding], { runId, errored: true }));
|
|
6628
|
+
continue;
|
|
6629
|
+
}
|
|
6630
|
+
const ruleFindings = [];
|
|
6631
|
+
for (const item of circuitRun.results) {
|
|
6632
|
+
const finding = circuitFinding(item);
|
|
6633
|
+
ruleFindings.push(finding);
|
|
6634
|
+
findings.push(finding);
|
|
6635
|
+
if (finding.status === "fail") failed += 1;
|
|
6636
|
+
else if (finding.status === "warning") warnings += 1;
|
|
6637
|
+
else passed += 1;
|
|
6638
|
+
}
|
|
6639
|
+
ruleExecutions.push(extensionExecution(ruleId, ruleFindings, { runId }));
|
|
6539
6640
|
}
|
|
6540
6641
|
}
|
|
6541
|
-
const
|
|
6642
|
+
const status = result.status === "error" || errors > 0 ? "error" : failed > 0 ? "fail" : result.status;
|
|
6542
6643
|
return {
|
|
6543
6644
|
...result,
|
|
6544
|
-
ok,
|
|
6545
|
-
status
|
|
6645
|
+
ok: status === "pass",
|
|
6646
|
+
status,
|
|
6546
6647
|
summary: {
|
|
6547
6648
|
passed,
|
|
6548
6649
|
failed,
|
|
6549
6650
|
warnings,
|
|
6550
|
-
errors
|
|
6551
|
-
rulesEvaluated:
|
|
6651
|
+
errors,
|
|
6652
|
+
rulesEvaluated: ruleExecutions.length
|
|
6552
6653
|
},
|
|
6553
6654
|
findings,
|
|
6554
|
-
ruleExecutions
|
|
6655
|
+
ruleExecutions
|
|
6555
6656
|
};
|
|
6556
6657
|
}
|
|
6557
6658
|
|
|
@@ -6755,7 +6856,7 @@ var SAFETY_KEYS = /* @__PURE__ */ new Set([
|
|
|
6755
6856
|
"maxFindings"
|
|
6756
6857
|
]);
|
|
6757
6858
|
var RUN_EXPECTED = /* @__PURE__ */ new Set(["ok", "error", "running"]);
|
|
6758
|
-
var
|
|
6859
|
+
var CONFIDENCE_LIST = ATTRIBUTION_CONFIDENCES.join(", ");
|
|
6759
6860
|
var CheckConfigError = class extends Error {
|
|
6760
6861
|
code;
|
|
6761
6862
|
constructor(code, message) {
|
|
@@ -6897,10 +6998,10 @@ function parseStructureSection(value) {
|
|
|
6897
6998
|
rejectUnknownKeys(record, STRUCTURE_KEYS, "checks.structure");
|
|
6898
6999
|
const out = {};
|
|
6899
7000
|
if (record.minConfidence !== void 0) {
|
|
6900
|
-
if (
|
|
7001
|
+
if (!isAttributionConfidence(record.minConfidence)) {
|
|
6901
7002
|
throw new CheckConfigError(
|
|
6902
7003
|
"AI_CHECK_CONFIG_INVALID_VALUE",
|
|
6903
|
-
`checks.structure.minConfidence must be one of:
|
|
7004
|
+
`checks.structure.minConfidence must be one of: ${CONFIDENCE_LIST}.`
|
|
6904
7005
|
);
|
|
6905
7006
|
}
|
|
6906
7007
|
out.minConfidence = record.minConfidence;
|
|
@@ -7410,7 +7511,8 @@ async function checkCommand(target, options = {}, stdin = process.stdin) {
|
|
|
7410
7511
|
read,
|
|
7411
7512
|
{
|
|
7412
7513
|
...options.guardrails ? { guardrails: options.guardrails } : {},
|
|
7413
|
-
...options.circuit ? { circuits: options.circuit } : {}
|
|
7514
|
+
...options.circuit ? { circuits: options.circuit } : {},
|
|
7515
|
+
runId: meta.runId
|
|
7414
7516
|
}
|
|
7415
7517
|
)
|
|
7416
7518
|
);
|
|
@@ -7463,7 +7565,8 @@ async function checkCommand(target, options = {}, stdin = process.stdin) {
|
|
|
7463
7565
|
read,
|
|
7464
7566
|
{
|
|
7465
7567
|
...options.guardrails ? { guardrails: options.guardrails } : {},
|
|
7466
|
-
...options.circuit ? { circuits: options.circuit } : {}
|
|
7568
|
+
...options.circuit ? { circuits: options.circuit } : {},
|
|
7569
|
+
...options.run !== void 0 ? { runId: options.run } : {}
|
|
7467
7570
|
}
|
|
7468
7571
|
);
|
|
7469
7572
|
}
|
|
@@ -9632,10 +9735,10 @@ function selectRun4(read, runId) {
|
|
|
9632
9735
|
}
|
|
9633
9736
|
function summarizeTrace(read, run) {
|
|
9634
9737
|
const runId = run?.runId;
|
|
9635
|
-
const
|
|
9738
|
+
const scopedEvents2 = runId === void 0 ? read.events : read.events.filter((event) => event.runId === runId);
|
|
9636
9739
|
const eventsByKind = {};
|
|
9637
9740
|
const eventsByStatus = {};
|
|
9638
|
-
for (const event of
|
|
9741
|
+
for (const event of scopedEvents2) {
|
|
9639
9742
|
increment(eventsByKind, event.kind);
|
|
9640
9743
|
increment(eventsByStatus, event.status);
|
|
9641
9744
|
}
|
|
@@ -9645,7 +9748,7 @@ function summarizeTrace(read, run) {
|
|
|
9645
9748
|
...run?.status !== void 0 ? { runStatus: run.status } : {},
|
|
9646
9749
|
...run?.durationMs !== void 0 ? { runDurationMs: run.durationMs } : {},
|
|
9647
9750
|
runCount: read.runs.length,
|
|
9648
|
-
eventCount:
|
|
9751
|
+
eventCount: scopedEvents2.length,
|
|
9649
9752
|
eventsByKind: Object.fromEntries(Object.entries(eventsByKind).sort()),
|
|
9650
9753
|
eventsByStatus: Object.fromEntries(Object.entries(eventsByStatus).sort()),
|
|
9651
9754
|
readerWarnings: read.warnings.length,
|
|
@@ -12070,7 +12173,7 @@ function isModuleNotFound4(e) {
|
|
|
12070
12173
|
}
|
|
12071
12174
|
async function loadIndexSqlite() {
|
|
12072
12175
|
try {
|
|
12073
|
-
return await import('./src-
|
|
12176
|
+
return await import('./src-XNC4EUN3.mjs');
|
|
12074
12177
|
} catch (e) {
|
|
12075
12178
|
if (isModuleNotFound4(e)) {
|
|
12076
12179
|
console.error(
|