@neat.is/core 0.10.6-dev.20261008 → 0.10.6-dev.20261009

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.
@@ -28,7 +28,7 @@ import {
28
28
  startConnectorPolling,
29
29
  startPersistLoop,
30
30
  startStalenessLoop
31
- } from "./chunk-6QMWJAWR.js";
31
+ } from "./chunk-H2BAPN33.js";
32
32
  import {
33
33
  listProjects,
34
34
  pruneRegistry,
@@ -1802,4 +1802,4 @@ export {
1802
1802
  resolveHost,
1803
1803
  startDaemon
1804
1804
  };
1805
- //# sourceMappingURL=chunk-EMFX3V77.js.map
1805
+ //# sourceMappingURL=chunk-ECBRGTB2.js.map
@@ -17374,10 +17374,11 @@ function locusOf(graph, ev) {
17374
17374
  const rawLine = ev.attributes?.[CODE_LINENO_ATTR2];
17375
17375
  const line = typeof rawLine === "number" ? rawLine : Number(rawLine);
17376
17376
  const node = graph.hasNode(ev.affectedNode) ? graph.getNodeAttributes(ev.affectedNode) : void 0;
17377
+ const symbol = node?.type === "SymbolNode" ? node.qualname : void 0;
17377
17378
  return {
17378
17379
  file,
17379
17380
  ...Number.isFinite(line) ? { lineStart: line, lineEnd: line } : {},
17380
- ...node?.name ? { symbol: node.name } : {},
17381
+ ...symbol ? { symbol } : {},
17381
17382
  service: node?.service ?? ev.service,
17382
17383
  provenance: Provenance26.OBSERVED
17383
17384
  };
@@ -17473,7 +17474,8 @@ function buildIncidentCard(graph, errorEvent, incidents, policies) {
17473
17474
  const policyCards = applicable.map((p) => ({
17474
17475
  policyName: p.policyName,
17475
17476
  severity: p.severity,
17476
- message: p.reason
17477
+ message: p.reason,
17478
+ onViolation: p.onViolation
17477
17479
  }));
17478
17480
  const divergences = inGraph ? computeDivergences(graph, { node: affected, incidents }).divergences.map((d) => ({
17479
17481
  type: d.type,
@@ -17500,8 +17502,111 @@ function buildIncidentCard(graph, errorEvent, incidents, policies) {
17500
17502
  ...divergences.length > 0 ? { divergence: divergences } : {},
17501
17503
  headline: renderHeadline(graph, errorEvent, locus, rootCause?.node ?? null)
17502
17504
  };
17505
+ card.grade = gradeIncidentCard(card);
17503
17506
  return IncidentCardSchema.parse(card);
17504
17507
  }
17508
+ var GRADE_PRIORS_VERSION = "sniper-architecture-priors-2026-10-08";
17509
+ var GRADE_WEIGHTS = {
17510
+ evidence: 3,
17511
+ locus: 2,
17512
+ tests: 2,
17513
+ reach: 1.5,
17514
+ kind: 1.5,
17515
+ chain: 1,
17516
+ recur: 1,
17517
+ div: 1
17518
+ };
17519
+ var PROVENANCE_WEIGHT = {
17520
+ OBSERVED: 1,
17521
+ EXTRACTED: 0.8,
17522
+ INFERRED: 0.4,
17523
+ FRONTIER: 0.3,
17524
+ STALE: 0.2
17525
+ };
17526
+ var REACH_NODES_MAX = 50;
17527
+ var TIMEOUT = /timeout|timed out|deadline/i;
17528
+ var round2 = (n) => Math.round(n * 1e4) / 1e4;
17529
+ function factor(name, value, evidence, reason) {
17530
+ return {
17531
+ value: value === null ? null : round2(value),
17532
+ weight: GRADE_WEIGHTS[name],
17533
+ evidence,
17534
+ ...reason ? { reason } : {}
17535
+ };
17536
+ }
17537
+ function gradeIncidentCard(card) {
17538
+ const rc = card.rootCause;
17539
+ const chain = rc?.chain ?? [];
17540
+ const gates = {
17541
+ policyNotBlock: {
17542
+ passed: !(card.policies ?? []).some((p) => p.onViolation === "block"),
17543
+ evidence: ["policies[].onViolation"]
17544
+ },
17545
+ notSymptomOnly: {
17546
+ passed: rc?.classification !== "symptom-only",
17547
+ evidence: ["rootCause.classification"]
17548
+ },
17549
+ locusResolves: { passed: card.locus !== null, evidence: ["locus"] }
17550
+ };
17551
+ const gamma = Object.values(gates).every((g) => g.passed) ? 1 : 0;
17552
+ const carrying = chain.some((h) => h.carriesSignal === true) ? chain.filter((h) => h.carriesSignal === true) : chain;
17553
+ const hopWeights = carrying.map((h) => PROVENANCE_WEIGHT[h.provenance]);
17554
+ const evidence = hopWeights.length === 0 ? factor("evidence", null, ["rootCause.chain[].provenance"], "no root-cause chain on the card") : hopWeights.some((w) => w === void 0) ? factor("evidence", null, ["rootCause.chain[].provenance"], "a chain hop has a provenance with no weight") : factor("evidence", Math.min(...hopWeights), ["rootCause.chain[].provenance"]);
17555
+ const locus = card.locus ? factor("locus", card.locus.symbol ? 1 : 0.6, ["locus.symbol", "locus.file"]) : factor("locus", null, ["locus"], "no locus on the card (the locus gate fails)");
17556
+ const tests = factor(
17557
+ "tests",
17558
+ null,
17559
+ [],
17560
+ "the card carries no test-file classification or test-to-symbol edges"
17561
+ );
17562
+ const reach = card.blastRadius ? factor(
17563
+ "reach",
17564
+ Math.max(0, 1 - card.blastRadius.totalAffected / REACH_NODES_MAX),
17565
+ ["blastRadius.totalAffected"],
17566
+ `nodes in the blast radius against a prior bound of ${REACH_NODES_MAX}`
17567
+ ) : factor("reach", null, ["blastRadius"], "no blast radius on the card");
17568
+ const timeout = TIMEOUT.test(`${card.exceptionType ?? ""} ${card.message}`);
17569
+ const kindValue = timeout ? 0.3 : card.incidentKind === "exception" ? 1 : card.incidentKind === "5xx" || card.incidentKind === "status-error" ? 0.7 : card.incidentKind === "connector" ? 0.6 : 0.4;
17570
+ const kind = factor("kind", kindValue, ["incidentKind", "exceptionType", "message"]);
17571
+ const chainFactor = rc ? factor(
17572
+ "chain",
17573
+ 1 / (1 + 0.25 * (Math.max(1, chain.length - 1) - 1)),
17574
+ ["rootCause.chain"]
17575
+ ) : factor("chain", null, ["rootCause"], "no root cause on the card");
17576
+ const occurrences = card.count ?? 1;
17577
+ const recurValue = Math.min(1, Math.log(1 + occurrences) / Math.log(11));
17578
+ const recur = factor(
17579
+ "recur",
17580
+ recurValue,
17581
+ ["count"],
17582
+ card.count === void 0 ? "no coalesced count; one recorded occurrence" : void 0
17583
+ );
17584
+ const div = factor("div", (card.divergence ?? []).length > 0 ? 1 : 0.7, ["divergence"]);
17585
+ const factors = { evidence, locus, tests, reach, kind, chain: chainFactor, recur, div };
17586
+ let weighted = 0;
17587
+ let total = 0;
17588
+ for (const f of Object.values(factors)) {
17589
+ if (f.value === null) continue;
17590
+ weighted += f.weight * f.value;
17591
+ total += f.weight;
17592
+ }
17593
+ const C = round2(weighted / total);
17594
+ const G = round2(gamma * C);
17595
+ const band = gamma === 0 || G < 0.5 ? "out" : G >= 0.75 ? "full" : "diagnose-only";
17596
+ return {
17597
+ G,
17598
+ gamma,
17599
+ gates,
17600
+ C,
17601
+ factors,
17602
+ band,
17603
+ urgency: {
17604
+ value: null,
17605
+ reason: "f_fresh needs the time of the last OBSERVED signal at the node, which the card does not carry"
17606
+ },
17607
+ priorsVersion: GRADE_PRIORS_VERSION
17608
+ };
17609
+ }
17505
17610
 
17506
17611
  // src/ask.ts
17507
17612
  import { AskResultSchema, NodeType as NodeType32, Provenance as Provenance27, serviceId as serviceId15 } from "@neat.is/types";
@@ -24052,4 +24157,4 @@ export {
24052
24157
  deprovisionConnector,
24053
24158
  buildApi
24054
24159
  };
24055
- //# sourceMappingURL=chunk-6QMWJAWR.js.map
24160
+ //# sourceMappingURL=chunk-H2BAPN33.js.map