@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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  routeSpanToProject,
3
3
  startDaemon
4
- } from "./chunk-EMFX3V77.js";
4
+ } from "./chunk-ECBRGTB2.js";
5
5
  import {
6
6
  buildApi,
7
7
  checkCompatibility,
@@ -25,7 +25,7 @@ import {
25
25
  startStalenessLoop,
26
26
  stitchTrace,
27
27
  thresholdForEdgeType
28
- } from "./chunk-6QMWJAWR.js";
28
+ } from "./chunk-H2BAPN33.js";
29
29
  import {
30
30
  ProjectNameCollisionError,
31
31
  addProject,
package/dist/neatd.cjs CHANGED
@@ -18008,10 +18008,11 @@ function locusOf(graph, ev) {
18008
18008
  const rawLine = ev.attributes?.[CODE_LINENO_ATTR2];
18009
18009
  const line = typeof rawLine === "number" ? rawLine : Number(rawLine);
18010
18010
  const node = graph.hasNode(ev.affectedNode) ? graph.getNodeAttributes(ev.affectedNode) : void 0;
18011
+ const symbol = node?.type === "SymbolNode" ? node.qualname : void 0;
18011
18012
  return {
18012
18013
  file,
18013
18014
  ...Number.isFinite(line) ? { lineStart: line, lineEnd: line } : {},
18014
- ...node?.name ? { symbol: node.name } : {},
18015
+ ...symbol ? { symbol } : {},
18015
18016
  service: node?.service ?? ev.service,
18016
18017
  provenance: import_types61.Provenance.OBSERVED
18017
18018
  };
@@ -18107,7 +18108,8 @@ function buildIncidentCard(graph, errorEvent, incidents, policies) {
18107
18108
  const policyCards = applicable.map((p) => ({
18108
18109
  policyName: p.policyName,
18109
18110
  severity: p.severity,
18110
- message: p.reason
18111
+ message: p.reason,
18112
+ onViolation: p.onViolation
18111
18113
  }));
18112
18114
  const divergences = inGraph ? computeDivergences(graph, { node: affected, incidents }).divergences.map((d) => ({
18113
18115
  type: d.type,
@@ -18134,8 +18136,111 @@ function buildIncidentCard(graph, errorEvent, incidents, policies) {
18134
18136
  ...divergences.length > 0 ? { divergence: divergences } : {},
18135
18137
  headline: renderHeadline(graph, errorEvent, locus, rootCause?.node ?? null)
18136
18138
  };
18139
+ card.grade = gradeIncidentCard(card);
18137
18140
  return import_types61.IncidentCardSchema.parse(card);
18138
18141
  }
18142
+ var GRADE_PRIORS_VERSION = "sniper-architecture-priors-2026-10-08";
18143
+ var GRADE_WEIGHTS = {
18144
+ evidence: 3,
18145
+ locus: 2,
18146
+ tests: 2,
18147
+ reach: 1.5,
18148
+ kind: 1.5,
18149
+ chain: 1,
18150
+ recur: 1,
18151
+ div: 1
18152
+ };
18153
+ var PROVENANCE_WEIGHT = {
18154
+ OBSERVED: 1,
18155
+ EXTRACTED: 0.8,
18156
+ INFERRED: 0.4,
18157
+ FRONTIER: 0.3,
18158
+ STALE: 0.2
18159
+ };
18160
+ var REACH_NODES_MAX = 50;
18161
+ var TIMEOUT = /timeout|timed out|deadline/i;
18162
+ var round2 = (n) => Math.round(n * 1e4) / 1e4;
18163
+ function factor(name, value, evidence, reason) {
18164
+ return {
18165
+ value: value === null ? null : round2(value),
18166
+ weight: GRADE_WEIGHTS[name],
18167
+ evidence,
18168
+ ...reason ? { reason } : {}
18169
+ };
18170
+ }
18171
+ function gradeIncidentCard(card) {
18172
+ const rc = card.rootCause;
18173
+ const chain = rc?.chain ?? [];
18174
+ const gates = {
18175
+ policyNotBlock: {
18176
+ passed: !(card.policies ?? []).some((p) => p.onViolation === "block"),
18177
+ evidence: ["policies[].onViolation"]
18178
+ },
18179
+ notSymptomOnly: {
18180
+ passed: rc?.classification !== "symptom-only",
18181
+ evidence: ["rootCause.classification"]
18182
+ },
18183
+ locusResolves: { passed: card.locus !== null, evidence: ["locus"] }
18184
+ };
18185
+ const gamma = Object.values(gates).every((g) => g.passed) ? 1 : 0;
18186
+ const carrying = chain.some((h) => h.carriesSignal === true) ? chain.filter((h) => h.carriesSignal === true) : chain;
18187
+ const hopWeights = carrying.map((h) => PROVENANCE_WEIGHT[h.provenance]);
18188
+ 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"]);
18189
+ 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)");
18190
+ const tests = factor(
18191
+ "tests",
18192
+ null,
18193
+ [],
18194
+ "the card carries no test-file classification or test-to-symbol edges"
18195
+ );
18196
+ const reach = card.blastRadius ? factor(
18197
+ "reach",
18198
+ Math.max(0, 1 - card.blastRadius.totalAffected / REACH_NODES_MAX),
18199
+ ["blastRadius.totalAffected"],
18200
+ `nodes in the blast radius against a prior bound of ${REACH_NODES_MAX}`
18201
+ ) : factor("reach", null, ["blastRadius"], "no blast radius on the card");
18202
+ const timeout = TIMEOUT.test(`${card.exceptionType ?? ""} ${card.message}`);
18203
+ 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;
18204
+ const kind = factor("kind", kindValue, ["incidentKind", "exceptionType", "message"]);
18205
+ const chainFactor = rc ? factor(
18206
+ "chain",
18207
+ 1 / (1 + 0.25 * (Math.max(1, chain.length - 1) - 1)),
18208
+ ["rootCause.chain"]
18209
+ ) : factor("chain", null, ["rootCause"], "no root cause on the card");
18210
+ const occurrences = card.count ?? 1;
18211
+ const recurValue = Math.min(1, Math.log(1 + occurrences) / Math.log(11));
18212
+ const recur = factor(
18213
+ "recur",
18214
+ recurValue,
18215
+ ["count"],
18216
+ card.count === void 0 ? "no coalesced count; one recorded occurrence" : void 0
18217
+ );
18218
+ const div = factor("div", (card.divergence ?? []).length > 0 ? 1 : 0.7, ["divergence"]);
18219
+ const factors = { evidence, locus, tests, reach, kind, chain: chainFactor, recur, div };
18220
+ let weighted = 0;
18221
+ let total = 0;
18222
+ for (const f of Object.values(factors)) {
18223
+ if (f.value === null) continue;
18224
+ weighted += f.weight * f.value;
18225
+ total += f.weight;
18226
+ }
18227
+ const C = round2(weighted / total);
18228
+ const G = round2(gamma * C);
18229
+ const band = gamma === 0 || G < 0.5 ? "out" : G >= 0.75 ? "full" : "diagnose-only";
18230
+ return {
18231
+ G,
18232
+ gamma,
18233
+ gates,
18234
+ C,
18235
+ factors,
18236
+ band,
18237
+ urgency: {
18238
+ value: null,
18239
+ reason: "f_fresh needs the time of the last OBSERVED signal at the node, which the card does not carry"
18240
+ },
18241
+ priorsVersion: GRADE_PRIORS_VERSION
18242
+ };
18243
+ }
18139
18244
 
18140
18245
  // src/ask.ts
18141
18246
  init_cjs_shims();