MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / runOneInvariantInto

Function runOneInvariantInto

server/src/audit/integrity/runner.ts:65–99  ·  view source on GitHub ↗
(
  invariant: Invariant,
  ctx: InvariantContext,
  appendViolationsTo: Violation[],
)

Source from the content-addressed store, hash-verified

63}
64
65async function runOneInvariantInto(
66 invariant: Invariant,
67 ctx: InvariantContext,
68 appendViolationsTo: Violation[],
69): Promise<InvariantRunStats> {
70 const t0 = Date.now();
71 try {
72 const result = await invariant.check(ctx);
73 appendViolationsTo.push(...result.violations);
74 return {
75 ms: Date.now() - t0,
76 checked: result.checked,
77 violations: result.violations.length,
78 };
79 } catch (err) {
80 const error = err instanceof Error ? err.message : String(err);
81 ctx.logger.error({ err, invariant: invariant.name }, 'Invariant check threw');
82 // Record a meta-violation so the failure is visible in the report
83 // and operators don't see a silently-incomplete check.
84 const metaViolation: Violation = {
85 invariant: invariant.name,
86 severity: 'warning',
87 subject_type: 'configuration',
88 subject_id: invariant.name,
89 message: `Invariant check failed to run: ${error}`,
90 };
91 appendViolationsTo.push(metaViolation);
92 return {
93 ms: Date.now() - t0,
94 checked: 0,
95 violations: 1,
96 error,
97 };
98 }
99}

Callers 1

runAllInvariantsFunction · 0.85

Calls 2

nowMethod · 0.80
checkMethod · 0.45

Tested by

no test coverage detected