@neat.is/core 0.9.2 → 0.9.3-dev.20260823

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-TMHCS4ZY.js";
4
+ } from "./chunk-WJGZYEUG.js";
5
5
  import {
6
6
  ProjectNameCollisionError,
7
7
  addProject,
@@ -37,7 +37,7 @@ import {
37
37
  thresholdForEdgeType,
38
38
  touchLastSeen,
39
39
  writeAtomically
40
- } from "./chunk-HD5X5TWY.js";
40
+ } from "./chunk-LRYPKC3B.js";
41
41
  import {
42
42
  startOtelGrpcReceiver
43
43
  } from "./chunk-ERE47MCR.js";
package/dist/neatd.cjs CHANGED
@@ -9852,12 +9852,12 @@ async function resolveConfigs(literals, keys, serviceDir, looksLike, parse11) {
9852
9852
  const value = await interpolateEnvRefs(raw, serviceDir);
9853
9853
  if (!looksLike(value)) continue;
9854
9854
  const parsed = parse11(value);
9855
- if (parsed) out.push(parsed);
9855
+ if (parsed) out.push({ ...parsed, hostSource: "config" });
9856
9856
  }
9857
9857
  for (const lit of literals) {
9858
9858
  if (!looksLike(lit)) continue;
9859
9859
  const parsed = parse11(lit);
9860
- if (parsed) out.push(parsed);
9860
+ if (parsed) out.push({ ...parsed, hostSource: "literal" });
9861
9861
  }
9862
9862
  return out;
9863
9863
  }
@@ -10126,7 +10126,10 @@ async function addDatabasesAndCompat(graph, services, scanPath) {
10126
10126
  type: import_types23.EdgeType.CONNECTS_TO,
10127
10127
  provenance: import_types23.Provenance.EXTRACTED,
10128
10128
  confidence: (0, import_types23.confidenceForExtracted)("structural"),
10129
- evidence: { file: evidenceFile }
10129
+ // Carry how the host was recovered (ADR-213) so the divergence ranker
10130
+ // can tell a real declared store from a hardcoded fault-injection /
10131
+ // flag-gated probe. Only set when the parser distinguished the two.
10132
+ evidence: config.hostSource ? { file: evidenceFile, hostSource: config.hostSource } : { file: evidenceFile }
10130
10133
  };
10131
10134
  if (!graph.hasEdge(edge.id)) {
10132
10135
  graph.addEdgeWithKey(edge.id, edge.source, edge.target, edge);
@@ -16455,6 +16458,53 @@ function detectColumnDrift(node) {
16455
16458
  function involvesNode(d, nodeId) {
16456
16459
  return d.source === nodeId || d.target === nodeId;
16457
16460
  }
16461
+ function datastoreEverObserved(graph, nodeId) {
16462
+ if (!graph.hasNode(nodeId)) return false;
16463
+ const n = graph.getNodeAttributes(nodeId);
16464
+ if (n.type === import_types58.NodeType.DatabaseNode) {
16465
+ const via = n.discoveredVia;
16466
+ if (via === "otel" || via === "merged") return true;
16467
+ }
16468
+ for (const edgeId of graph.inboundEdges(nodeId)) {
16469
+ const e = graph.getEdgeAttributes(edgeId);
16470
+ if (e.provenance === import_types58.Provenance.OBSERVED || e.provenance === import_types58.Provenance.STALE) return true;
16471
+ }
16472
+ return false;
16473
+ }
16474
+ function serviceHasObservedSameEngineStore(graph, buckets2, serviceId16, engine, excludeTarget) {
16475
+ for (const bucket of buckets2.values()) {
16476
+ if (bucket.type !== import_types58.EdgeType.CONNECTS_TO) continue;
16477
+ if (bucket.source !== serviceId16) continue;
16478
+ if (bucket.target === excludeTarget) continue;
16479
+ if (!graph.hasNode(bucket.target)) continue;
16480
+ const target = graph.getNodeAttributes(bucket.target);
16481
+ if (target.type !== import_types58.NodeType.DatabaseNode) continue;
16482
+ if (target.engine !== engine) continue;
16483
+ if (bucket.observed || datastoreEverObserved(graph, bucket.target)) return true;
16484
+ }
16485
+ return false;
16486
+ }
16487
+ var DEAD_CODE_PROBE_CONFIDENCE = 0.1;
16488
+ function dampenDeadCodeProbes(graph, buckets2, all) {
16489
+ return all.map((d) => {
16490
+ if (d.type !== "missing-observed") return d;
16491
+ if (!d.extracted || d.edgeType !== import_types58.EdgeType.CONNECTS_TO) return d;
16492
+ if (!graph.hasNode(d.target)) return d;
16493
+ const target = graph.getNodeAttributes(d.target);
16494
+ if (target.type !== import_types58.NodeType.DatabaseNode) return d;
16495
+ if (d.extracted.evidence?.hostSource !== "literal") return d;
16496
+ if (datastoreEverObserved(graph, d.target)) return d;
16497
+ const engine = target.engine;
16498
+ if (!serviceHasObservedSameEngineStore(graph, buckets2, d.source, engine, d.target)) return d;
16499
+ const host = target.host ?? target.name;
16500
+ return {
16501
+ ...d,
16502
+ confidence: Math.min(d.confidence, DEAD_CODE_PROBE_CONFIDENCE),
16503
+ reason: `${d.source} declares a ${engine} connection to a hardcoded-literal host (${host}) that production has never observed, while it does observe another ${engine} store \u2014 this reads as a flag-gated or dead-code declaration (e.g. a fault-injection probe), not a real declared-vs-observed gap.`,
16504
+ recommendation: "Confirm this is an intentional dead alternate \u2014 a fault-injection probe or a flag-gated branch. If it is meant to run in production, check the feature flag or conditional that gates it; if not, it can be ignored or removed."
16505
+ };
16506
+ });
16507
+ }
16458
16508
  function suppressHostMismatchHalves(all) {
16459
16509
  const observedHalf = /* @__PURE__ */ new Set();
16460
16510
  const declaredHalf = /* @__PURE__ */ new Set();
@@ -16491,7 +16541,8 @@ function computeDivergences(graph, opts = {}) {
16491
16541
  }
16492
16542
  });
16493
16543
  const reconciled = suppressHostMismatchHalves(all);
16494
- let filtered = reconciled;
16544
+ const dampened = dampenDeadCodeProbes(graph, buckets2, reconciled);
16545
+ let filtered = dampened;
16495
16546
  if (opts.type) {
16496
16547
  const allowed = opts.type;
16497
16548
  filtered = filtered.filter((d) => allowed.has(d.type));