@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/neatd.js CHANGED
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  reconcileDaemonRecordSync,
4
4
  startDaemon
5
- } from "./chunk-TMHCS4ZY.js";
5
+ } from "./chunk-WJGZYEUG.js";
6
6
  import {
7
7
  listProjects,
8
8
  registryPath
9
- } from "./chunk-HD5X5TWY.js";
9
+ } from "./chunk-LRYPKC3B.js";
10
10
  import {
11
11
  BindAuthorityError,
12
12
  __require
package/dist/server.cjs CHANGED
@@ -7399,6 +7399,53 @@ function detectColumnDrift(node) {
7399
7399
  function involvesNode(d, nodeId) {
7400
7400
  return d.source === nodeId || d.target === nodeId;
7401
7401
  }
7402
+ function datastoreEverObserved(graph, nodeId) {
7403
+ if (!graph.hasNode(nodeId)) return false;
7404
+ const n = graph.getNodeAttributes(nodeId);
7405
+ if (n.type === import_types9.NodeType.DatabaseNode) {
7406
+ const via = n.discoveredVia;
7407
+ if (via === "otel" || via === "merged") return true;
7408
+ }
7409
+ for (const edgeId of graph.inboundEdges(nodeId)) {
7410
+ const e = graph.getEdgeAttributes(edgeId);
7411
+ if (e.provenance === import_types9.Provenance.OBSERVED || e.provenance === import_types9.Provenance.STALE) return true;
7412
+ }
7413
+ return false;
7414
+ }
7415
+ function serviceHasObservedSameEngineStore(graph, buckets2, serviceId16, engine, excludeTarget) {
7416
+ for (const bucket of buckets2.values()) {
7417
+ if (bucket.type !== import_types9.EdgeType.CONNECTS_TO) continue;
7418
+ if (bucket.source !== serviceId16) continue;
7419
+ if (bucket.target === excludeTarget) continue;
7420
+ if (!graph.hasNode(bucket.target)) continue;
7421
+ const target = graph.getNodeAttributes(bucket.target);
7422
+ if (target.type !== import_types9.NodeType.DatabaseNode) continue;
7423
+ if (target.engine !== engine) continue;
7424
+ if (bucket.observed || datastoreEverObserved(graph, bucket.target)) return true;
7425
+ }
7426
+ return false;
7427
+ }
7428
+ var DEAD_CODE_PROBE_CONFIDENCE = 0.1;
7429
+ function dampenDeadCodeProbes(graph, buckets2, all) {
7430
+ return all.map((d) => {
7431
+ if (d.type !== "missing-observed") return d;
7432
+ if (!d.extracted || d.edgeType !== import_types9.EdgeType.CONNECTS_TO) return d;
7433
+ if (!graph.hasNode(d.target)) return d;
7434
+ const target = graph.getNodeAttributes(d.target);
7435
+ if (target.type !== import_types9.NodeType.DatabaseNode) return d;
7436
+ if (d.extracted.evidence?.hostSource !== "literal") return d;
7437
+ if (datastoreEverObserved(graph, d.target)) return d;
7438
+ const engine = target.engine;
7439
+ if (!serviceHasObservedSameEngineStore(graph, buckets2, d.source, engine, d.target)) return d;
7440
+ const host = target.host ?? target.name;
7441
+ return {
7442
+ ...d,
7443
+ confidence: Math.min(d.confidence, DEAD_CODE_PROBE_CONFIDENCE),
7444
+ 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.`,
7445
+ 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."
7446
+ };
7447
+ });
7448
+ }
7402
7449
  function suppressHostMismatchHalves(all) {
7403
7450
  const observedHalf = /* @__PURE__ */ new Set();
7404
7451
  const declaredHalf = /* @__PURE__ */ new Set();
@@ -7435,7 +7482,8 @@ function computeDivergences(graph, opts = {}) {
7435
7482
  }
7436
7483
  });
7437
7484
  const reconciled = suppressHostMismatchHalves(all);
7438
- let filtered = reconciled;
7485
+ const dampened = dampenDeadCodeProbes(graph, buckets2, reconciled);
7486
+ let filtered = dampened;
7439
7487
  if (opts.type) {
7440
7488
  const allowed = opts.type;
7441
7489
  filtered = filtered.filter((d) => allowed.has(d.type));
@@ -10471,12 +10519,12 @@ async function resolveConfigs(literals, keys, serviceDir, looksLike, parse11) {
10471
10519
  const value = await interpolateEnvRefs(raw, serviceDir);
10472
10520
  if (!looksLike(value)) continue;
10473
10521
  const parsed = parse11(value);
10474
- if (parsed) out.push(parsed);
10522
+ if (parsed) out.push({ ...parsed, hostSource: "config" });
10475
10523
  }
10476
10524
  for (const lit of literals) {
10477
10525
  if (!looksLike(lit)) continue;
10478
10526
  const parsed = parse11(lit);
10479
- if (parsed) out.push(parsed);
10527
+ if (parsed) out.push({ ...parsed, hostSource: "literal" });
10480
10528
  }
10481
10529
  return out;
10482
10530
  }
@@ -10745,7 +10793,10 @@ async function addDatabasesAndCompat(graph, services, scanPath) {
10745
10793
  type: import_types24.EdgeType.CONNECTS_TO,
10746
10794
  provenance: import_types24.Provenance.EXTRACTED,
10747
10795
  confidence: (0, import_types24.confidenceForExtracted)("structural"),
10748
- evidence: { file: evidenceFile }
10796
+ // Carry how the host was recovered (ADR-213) so the divergence ranker
10797
+ // can tell a real declared store from a hardcoded fault-injection /
10798
+ // flag-gated probe. Only set when the parser distinguished the two.
10799
+ evidence: config.hostSource ? { file: evidenceFile, hostSource: config.hostSource } : { file: evidenceFile }
10749
10800
  };
10750
10801
  if (!graph.hasEdge(edge.id)) {
10751
10802
  graph.addEdgeWithKey(edge.id, edge.source, edge.target, edge);