@unerr-ai/unerr 0.1.5 → 0.1.7
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/README.md +70 -194
- package/dist/cli.js +39151 -36992
- package/package.json +9 -2
- package/dist/__tests__/architecture-guard.test.js +0 -122
- package/dist/__tests__/arg-validator.test.js +0 -205
- package/dist/__tests__/ast-extractor.test.js +0 -203
- package/dist/__tests__/auto-bootstrap.test.js +0 -280
- package/dist/__tests__/background-indexer.test.js +0 -228
- package/dist/__tests__/blast-radius-engine.test.js +0 -200
- package/dist/__tests__/bridge-isolation.test.js +0 -37
- package/dist/__tests__/budget-enforcer.test.js +0 -53
- package/dist/__tests__/cfg-test-detection-perf.test.js +0 -82
- package/dist/__tests__/change-narrative.test.js +0 -190
- package/dist/__tests__/check-commit.test.js +0 -258
- package/dist/__tests__/checksum.test.js +0 -34
- package/dist/__tests__/commit-watcher.test.js +0 -154
- package/dist/__tests__/community-detection.test.js +0 -179
- package/dist/__tests__/community-tools.test.js +0 -299
- package/dist/__tests__/components.test.js +0 -449
- package/dist/__tests__/compression-log.test.js +0 -174
- package/dist/__tests__/compression-quality-monitor.test.js +0 -40
- package/dist/__tests__/config-healer.test.js +0 -165
- package/dist/__tests__/context-ledger.test.js +0 -58
- package/dist/__tests__/convention-detector.test.js +0 -99
- package/dist/__tests__/convention-learner.test.js +0 -86
- package/dist/__tests__/correction-detector.test.js +0 -330
- package/dist/__tests__/daemon-autostart-install.test.js +0 -283
- package/dist/__tests__/daemon-bridge.test.js +0 -222
- package/dist/__tests__/daemon-dashboard.test.js +0 -202
- package/dist/__tests__/daemon-registry.test.js +0 -240
- package/dist/__tests__/daemon-supervisor.test.js +0 -318
- package/dist/__tests__/daemon-version-check.test.js +0 -275
- package/dist/__tests__/decision-point-detector.test.js +0 -98
- package/dist/__tests__/deep-link.test.js +0 -143
- package/dist/__tests__/disallowed-tools.test.js +0 -115
- package/dist/__tests__/drift-tracker.test.js +0 -582
- package/dist/__tests__/durability-scorer.test.js +0 -152
- package/dist/__tests__/efficiency-tracker.test.js +0 -65
- package/dist/__tests__/enrich.test.js +0 -144
- package/dist/__tests__/entity-rewind.test.js +0 -248
- package/dist/__tests__/ephemeral.test.js +0 -111
- package/dist/__tests__/exploration-cost.test.js +0 -93
- package/dist/__tests__/fact-generator.test.js +0 -197
- package/dist/__tests__/file-l0-graph.test.js +0 -244
- package/dist/__tests__/file-logger.test.js +0 -82
- package/dist/__tests__/file-outline.test.js +0 -141
- package/dist/__tests__/file-read-protocol.test.js +0 -188
- package/dist/__tests__/format-encoder.test.js +0 -233
- package/dist/__tests__/git-attribution.test.js +0 -259
- package/dist/__tests__/graph-temporal-joiner.test.js +0 -219
- package/dist/__tests__/health-grade-enhanced.test.js +0 -138
- package/dist/__tests__/health-map-data.test.js +0 -173
- package/dist/__tests__/helpers/mcp-harness.js +0 -45
- package/dist/__tests__/helpers/mcp-harness.test.js +0 -68
- package/dist/__tests__/hook-dedup.test.js +0 -112
- package/dist/__tests__/hook-runner.test.js +0 -253
- package/dist/__tests__/indexer-cfg.test.js +0 -185
- package/dist/__tests__/indexer-cross-file.test.js +0 -172
- package/dist/__tests__/indexer-extraction.test.js +0 -245
- package/dist/__tests__/indexer-incremental.test.js +0 -232
- package/dist/__tests__/indexer-language-expansion.test.js +0 -165
- package/dist/__tests__/init-push.test.js +0 -131
- package/dist/__tests__/instruction-writer.test.js +0 -179
- package/dist/__tests__/intelligence-integration.test.js +0 -217
- package/dist/__tests__/intent-correlator.test.js +0 -175
- package/dist/__tests__/intent-detector.test.js +0 -235
- package/dist/__tests__/intent-encoder.test.js +0 -167
- package/dist/__tests__/java-build-tool-detection.test.js +0 -174
- package/dist/__tests__/layer3-sprint-q.test.js +0 -160
- package/dist/__tests__/layer3-sprint-r.test.js +0 -91
- package/dist/__tests__/layer3-sprint-s.test.js +0 -183
- package/dist/__tests__/layer3-sprint-t.test.js +0 -201
- package/dist/__tests__/layer3-sprint-u.test.js +0 -174
- package/dist/__tests__/layer4-sprint-ba2.test.js +0 -354
- package/dist/__tests__/layer4-sprint-ba4.test.js +0 -84
- package/dist/__tests__/layer4-sprint-vs.test.js +0 -105
- package/dist/__tests__/ledger-chains.test.js +0 -162
- package/dist/__tests__/lifecycle-machine.test.js +0 -226
- package/dist/__tests__/local-chat-provider.test.js +0 -170
- package/dist/__tests__/local-convention-detector.test.js +0 -308
- package/dist/__tests__/local-embeddings.test.js +0 -422
- package/dist/__tests__/local-graph.test.js +0 -540
- package/dist/__tests__/local-indexer.test.js +0 -228
- package/dist/__tests__/local-intelligence-l3.test.js +0 -332
- package/dist/__tests__/local-llm.test.js +0 -253
- package/dist/__tests__/local-mode-offline.test.js +0 -187
- package/dist/__tests__/local-mode-stats.test.js +0 -273
- package/dist/__tests__/local-mode-tui.test.js +0 -343
- package/dist/__tests__/local-parse.test.js +0 -199
- package/dist/__tests__/log-tailer.test.js +0 -208
- package/dist/__tests__/loop-breaker.test.js +0 -276
- package/dist/__tests__/loop-miner.test.js +0 -226
- package/dist/__tests__/mcp-config.test.js +0 -126
- package/dist/__tests__/mcp-content-json.test.js +0 -10
- package/dist/__tests__/mcp-envelope.test.js +0 -124
- package/dist/__tests__/metrics-store.test.js +0 -223
- package/dist/__tests__/native-watcher.test.js +0 -191
- package/dist/__tests__/navigation-hooks-agent-aware.test.js +0 -145
- package/dist/__tests__/negative-knowledge.test.js +0 -116
- package/dist/__tests__/network-boundary.test.js +0 -190
- package/dist/__tests__/network-firewall.test.js +0 -112
- package/dist/__tests__/nudge-invariants.test.js +0 -160
- package/dist/__tests__/nudge-v2.test.js +0 -225
- package/dist/__tests__/offline-rewind.test.js +0 -251
- package/dist/__tests__/open-threads.test.js +0 -89
- package/dist/__tests__/output-compressor.test.js +0 -93
- package/dist/__tests__/pending-violations.test.js +0 -112
- package/dist/__tests__/persistence-effectiveness.test.js +0 -143
- package/dist/__tests__/provider-factory.test.js +0 -42
- package/dist/__tests__/providers.test.js +0 -24
- package/dist/__tests__/proxy.test.js +0 -314
- package/dist/__tests__/query-router.test.js +0 -1018
- package/dist/__tests__/reasoning-quality-route.test.js +0 -138
- package/dist/__tests__/redactor.test.js +0 -120
- package/dist/__tests__/resource-monitor.test.js +0 -57
- package/dist/__tests__/response-envelope.test.js +0 -100
- package/dist/__tests__/risk-classifier.test.js +0 -101
- package/dist/__tests__/risk-signal-scope.test.js +0 -75
- package/dist/__tests__/rule-evaluator.test.js +0 -280
- package/dist/__tests__/scip-decoder.test.js +0 -49
- package/dist/__tests__/scip-downloader.test.js +0 -201
- package/dist/__tests__/scip-merger.test.js +0 -103
- package/dist/__tests__/search-index.test.js +0 -422
- package/dist/__tests__/semantic-enrichment.test.js +0 -360
- package/dist/__tests__/session-brief-builder.test.js +0 -187
- package/dist/__tests__/session-context.test.js +0 -221
- package/dist/__tests__/session-continuity.test.js +0 -144
- package/dist/__tests__/session-dedup.test.js +0 -74
- package/dist/__tests__/session-event-wiring.test.js +0 -206
- package/dist/__tests__/session-events.test.js +0 -149
- package/dist/__tests__/session-legend.test.js +0 -20
- package/dist/__tests__/session-persistence.test.js +0 -131
- package/dist/__tests__/session-resume-block.test.js +0 -107
- package/dist/__tests__/session-resume.test.js +0 -97
- package/dist/__tests__/session-summary-writer.test.js +0 -134
- package/dist/__tests__/shadow-ledger.test.js +0 -203
- package/dist/__tests__/shell-classifier.test.js +0 -151
- package/dist/__tests__/shell-compression-floor.test.js +0 -189
- package/dist/__tests__/shell-compression-v2.test.js +0 -339
- package/dist/__tests__/shell-compressor.test.js +0 -35
- package/dist/__tests__/shell-hooks.test.js +0 -128
- package/dist/__tests__/shell-strategies.test.js +0 -644
- package/dist/__tests__/shell-tee.test.js +0 -133
- package/dist/__tests__/signal-dedup.test.js +0 -158
- package/dist/__tests__/signal-reinforcer.test.js +0 -77
- package/dist/__tests__/signal-scorer.test.js +0 -251
- package/dist/__tests__/signal-show-store.test.js +0 -108
- package/dist/__tests__/smart-truncate.test.js +0 -215
- package/dist/__tests__/snapshot-v2.test.js +0 -113
- package/dist/__tests__/sprint-l1-local-mode.test.js +0 -130
- package/dist/__tests__/sprint-l10-boot.test.js +0 -220
- package/dist/__tests__/sprint-l9-offline-commands.test.js +0 -189
- package/dist/__tests__/sprint-q-persistent-context.test.js +0 -198
- package/dist/__tests__/sprint-s1-wiring.test.js +0 -215
- package/dist/__tests__/sprint-s2-wiring.test.js +0 -256
- package/dist/__tests__/sprint-s3-wiring.test.js +0 -195
- package/dist/__tests__/sprint-s4-wiring.test.js +0 -213
- package/dist/__tests__/sprint-s6-hooks.test.js +0 -222
- package/dist/__tests__/sprint-s7-persistent.test.js +0 -263
- package/dist/__tests__/sprint-s8-value.test.js +0 -167
- package/dist/__tests__/sprint-s9-behavioral.test.js +0 -179
- package/dist/__tests__/sprint3-intelligence.test.js +0 -297
- package/dist/__tests__/sprint5-mcp-server.test.js +0 -136
- package/dist/__tests__/startup-display.test.js +0 -302
- package/dist/__tests__/startup-log-file.test.js +0 -97
- package/dist/__tests__/stash-manager.test.js +0 -229
- package/dist/__tests__/state-detector.test.js +0 -92
- package/dist/__tests__/status-dashboard.test.js +0 -142
- package/dist/__tests__/temporal-facts.test.js +0 -292
- package/dist/__tests__/temporal-routes.test.js +0 -142
- package/dist/__tests__/test-detector.test.js +0 -174
- package/dist/__tests__/theme.test.js +0 -72
- package/dist/__tests__/timeline-agents.test.js +0 -122
- package/dist/__tests__/timeline-bootstrap.test.js +0 -176
- package/dist/__tests__/timeline-filters.test.js +0 -193
- package/dist/__tests__/timeline-markers.test.js +0 -151
- package/dist/__tests__/timeline-routes.test.js +0 -156
- package/dist/__tests__/timeline-store.test.js +0 -171
- package/dist/__tests__/token-counter.test.js +0 -86
- package/dist/__tests__/token-estimator.test.js +0 -96
- package/dist/__tests__/token-flow-api.test.js +0 -239
- package/dist/__tests__/token-flow-instrumentation.test.js +0 -437
- package/dist/__tests__/token-flow-persistence.test.js +0 -356
- package/dist/__tests__/token-flow-routes.test.js +0 -199
- package/dist/__tests__/token-flow.test.js +0 -695
- package/dist/__tests__/tool-clusters.test.js +0 -177
- package/dist/__tests__/transport-mux.test.js +0 -283
- package/dist/__tests__/turn-segmenter.test.js +0 -166
- package/dist/__tests__/uninstall.test.js +0 -141
- package/dist/__tests__/warm-start-policy.test.js +0 -271
- package/dist/__tests__/wire-cap-nudge.test.js +0 -77
- package/dist/__tests__/worker-pool.test.js +0 -101
- package/dist/ui/assets/index-7gl3mIuY.css +0 -1
- package/dist/ui/assets/index-BsMTQdhX.js +0 -10
- package/dist/ui/assets/rolldown-runtime-S-ySWqyJ.js +0 -1
- package/dist/ui/assets/vis-network-NIJHUFI3.js +0 -908
- package/dist/ui/fonts/jetbrains-mono-latin-400-normal.woff +0 -0
- package/dist/ui/icon-wordmark.png +0 -0
- package/dist/ui/icon-wordmark.svg +0 -30
- package/dist/ui/icon.png +0 -0
- package/dist/ui/icon.svg +0 -25
- package/dist/ui/index.html +0 -15
- package/dist/ui/prototype-sandbox/index.html +0 -257
- package/dist/ui/screenshots/activity.png +0 -0
- package/dist/ui/screenshots/code-base-intelligence.png +0 -0
- package/dist/ui/screenshots/dashboard.png +0 -0
- package/dist/ui/screenshots/project-memory.png +0 -0
- package/dist/ui/screenshots/reasoning-quality.png +0 -0
- package/dist/ui/screenshots/reasoning-session.png +0 -0
- package/dist/ui/screenshots/token-session.png +0 -0
- package/dist/ui/screenshots/token-trace-main.png +0 -0
- package/dist/ui/screenshots/token-turn.png +0 -0
- package/dist/ui/unerr-wordmark.png +0 -0
- package/dist/ui/unerr-wordmark.svg +0 -9
- package/dist/ui/unerr.png +0 -0
- package/dist/ui/unerr.svg +0 -25
- package/dist/ui/web-app-manifest-192x192.png +0 -0
- package/dist/ui/web-app-manifest-512x512.png +0 -0
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Leapfrog Sprint A.4 + A.5 TEST: Community MCP tools.
|
|
3
|
-
*
|
|
4
|
-
* Tests the community query methods on CozoGraphStore and the QueryRouter's
|
|
5
|
-
* handling of get_cross_boundary_links and get_critical_nodes tools.
|
|
6
|
-
* Uses mock graph store (consistent with query-router.test.ts pattern).
|
|
7
|
-
*/
|
|
8
|
-
import { describe, expect, it, vi } from "vitest";
|
|
9
|
-
import { QueryRouter } from "../intelligence/query-router.js";
|
|
10
|
-
function createMockGraphStore(opts) {
|
|
11
|
-
const defaultEntity = {
|
|
12
|
-
key: "fn1",
|
|
13
|
-
kind: "function",
|
|
14
|
-
name: "doStuff",
|
|
15
|
-
file_path: "src/index.ts",
|
|
16
|
-
start_line: 10,
|
|
17
|
-
signature: "()",
|
|
18
|
-
body: "function doStuff() {}",
|
|
19
|
-
fan_in: 0,
|
|
20
|
-
fan_out: 0,
|
|
21
|
-
risk_level: "normal",
|
|
22
|
-
community: -1,
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
db: { run: vi.fn().mockReturnValue({ rows: [] }) },
|
|
26
|
-
hasRules: vi.fn().mockReturnValue(false),
|
|
27
|
-
hasJustifications: vi.fn().mockReturnValue(false),
|
|
28
|
-
getPatterns: vi.fn().mockReturnValue([]),
|
|
29
|
-
getEntity: vi
|
|
30
|
-
.fn()
|
|
31
|
-
.mockReturnValue(opts?.entityOverride !== undefined ? opts.entityOverride : defaultEntity),
|
|
32
|
-
getCallersOf: vi.fn().mockReturnValue([]),
|
|
33
|
-
getCalleesOf: vi.fn().mockReturnValue([]),
|
|
34
|
-
getEntitiesByFile: vi.fn().mockReturnValue([]),
|
|
35
|
-
searchEntities: vi.fn().mockReturnValue([]),
|
|
36
|
-
getImports: vi.fn().mockReturnValue([]),
|
|
37
|
-
getRules: vi.fn().mockReturnValue([]),
|
|
38
|
-
getBlastRadius: vi.fn().mockReturnValue({
|
|
39
|
-
direct_callers: 0,
|
|
40
|
-
direct_callees: 0,
|
|
41
|
-
transitive_count: 0,
|
|
42
|
-
transitive_depth: 2,
|
|
43
|
-
is_chokepoint: false,
|
|
44
|
-
summary: "No dependencies",
|
|
45
|
-
}),
|
|
46
|
-
getBlastRadiusEntities: vi.fn().mockReturnValue([]),
|
|
47
|
-
getConventionsForEntity: vi.fn().mockReturnValue([]),
|
|
48
|
-
getDriftEntitiesForFile: vi.fn().mockReturnValue([]),
|
|
49
|
-
getDriftSummary: vi.fn().mockReturnValue({
|
|
50
|
-
total: 0,
|
|
51
|
-
added: 0,
|
|
52
|
-
modified: 0,
|
|
53
|
-
deleted: 0,
|
|
54
|
-
dependency_changed: 0,
|
|
55
|
-
}),
|
|
56
|
-
upsertDriftEntity: vi.fn(),
|
|
57
|
-
removeDriftEntity: vi.fn(),
|
|
58
|
-
clearDriftOverlay: vi.fn(),
|
|
59
|
-
getCrossBoundaryLinks: vi
|
|
60
|
-
.fn()
|
|
61
|
-
.mockReturnValue(opts?.crossBoundaryLinks ?? []),
|
|
62
|
-
getCriticalNodes: vi.fn().mockReturnValue(opts?.criticalNodes ?? []),
|
|
63
|
-
getAllCommunities: vi.fn().mockReturnValue(opts?.communities ?? []),
|
|
64
|
-
getCommunityForEntity: vi
|
|
65
|
-
.fn()
|
|
66
|
-
.mockReturnValue(opts?.communityForEntity ?? null),
|
|
67
|
-
getCrossCommunityEdges: vi
|
|
68
|
-
.fn()
|
|
69
|
-
.mockReturnValue(opts?.crossCommunityEdges ?? []),
|
|
70
|
-
hasDeepDiveProject: vi.fn().mockReturnValue(false),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
// ── A.4: Cross Boundary Links Tool ─────────────────────────────
|
|
74
|
-
describe("get_cross_boundary_links (A.4)", () => {
|
|
75
|
-
it("routes to local and returns cross-community edges", async () => {
|
|
76
|
-
const connections = [
|
|
77
|
-
{
|
|
78
|
-
from_name: "refresh",
|
|
79
|
-
from_file: "src/auth/refresh.ts",
|
|
80
|
-
from_community: 0,
|
|
81
|
-
from_community_label: "auth",
|
|
82
|
-
to_name: "charge",
|
|
83
|
-
to_file: "src/payment/charge.ts",
|
|
84
|
-
to_community: 1,
|
|
85
|
-
to_community_label: "payment",
|
|
86
|
-
edge_type: "calls",
|
|
87
|
-
surprise_score: 0.85,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
from_name: "validate",
|
|
91
|
-
from_file: "src/payment/validate.ts",
|
|
92
|
-
from_community: 1,
|
|
93
|
-
from_community_label: "payment",
|
|
94
|
-
to_name: "log",
|
|
95
|
-
to_file: "src/utils/logger.ts",
|
|
96
|
-
to_community: 2,
|
|
97
|
-
to_community_label: "utils",
|
|
98
|
-
edge_type: "calls",
|
|
99
|
-
surprise_score: 0.72,
|
|
100
|
-
},
|
|
101
|
-
];
|
|
102
|
-
const graph = createMockGraphStore({ crossBoundaryLinks: connections });
|
|
103
|
-
const router = new QueryRouter(graph);
|
|
104
|
-
const result = await router.execute("get_cross_boundary_links", {
|
|
105
|
-
top_n: 10,
|
|
106
|
-
});
|
|
107
|
-
expect(result._meta.source).toBe("local");
|
|
108
|
-
expect(result._meta.latency_ms).toBeLessThan(50);
|
|
109
|
-
expect(result._meta.format).toBe("columnar");
|
|
110
|
-
expect(typeof result.content).toBe("string");
|
|
111
|
-
const col = result.content;
|
|
112
|
-
expect(col).toContain("_fmt:columnar");
|
|
113
|
-
expect(col).toContain("refresh");
|
|
114
|
-
expect(col).toContain("charge");
|
|
115
|
-
});
|
|
116
|
-
it("passes community_id filter to graph store", async () => {
|
|
117
|
-
const graph = createMockGraphStore();
|
|
118
|
-
const router = new QueryRouter(graph);
|
|
119
|
-
await router.execute("get_cross_boundary_links", {
|
|
120
|
-
community_id: 3,
|
|
121
|
-
top_n: 5,
|
|
122
|
-
});
|
|
123
|
-
expect(graph.getCrossBoundaryLinks).toHaveBeenCalledWith(3, 5);
|
|
124
|
-
});
|
|
125
|
-
it("defaults top_n to 20", async () => {
|
|
126
|
-
const graph = createMockGraphStore();
|
|
127
|
-
const router = new QueryRouter(graph);
|
|
128
|
-
await router.execute("get_cross_boundary_links", {});
|
|
129
|
-
expect(graph.getCrossBoundaryLinks).toHaveBeenCalledWith(undefined, 20);
|
|
130
|
-
});
|
|
131
|
-
it("is registered as a local route", () => {
|
|
132
|
-
const graph = createMockGraphStore();
|
|
133
|
-
const router = new QueryRouter(graph);
|
|
134
|
-
expect(router.isKnownTool("get_cross_boundary_links")).toBe(true);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
// ── A.5: Critical Nodes Tool ──────────────────────────────────────────
|
|
138
|
-
describe("get_critical_nodes (A.5)", () => {
|
|
139
|
-
it("routes to local and returns highest-degree entities", async () => {
|
|
140
|
-
const criticalNodes = [
|
|
141
|
-
{
|
|
142
|
-
key: "pay_charge",
|
|
143
|
-
name: "charge",
|
|
144
|
-
file_path: "src/payment/charge.ts",
|
|
145
|
-
fan_in: 8,
|
|
146
|
-
fan_out: 5,
|
|
147
|
-
degree: 13,
|
|
148
|
-
community: 1,
|
|
149
|
-
community_label: "payment",
|
|
150
|
-
risk_level: "high",
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
key: "auth_login",
|
|
154
|
-
name: "login",
|
|
155
|
-
file_path: "src/auth/login.ts",
|
|
156
|
-
fan_in: 6,
|
|
157
|
-
fan_out: 3,
|
|
158
|
-
degree: 9,
|
|
159
|
-
community: 0,
|
|
160
|
-
community_label: "auth",
|
|
161
|
-
risk_level: "medium",
|
|
162
|
-
},
|
|
163
|
-
];
|
|
164
|
-
const graph = createMockGraphStore({ criticalNodes });
|
|
165
|
-
const router = new QueryRouter(graph);
|
|
166
|
-
const result = await router.execute("get_critical_nodes", { top_n: 5 });
|
|
167
|
-
expect(result._meta.source).toBe("local");
|
|
168
|
-
expect(result._meta.format).toBe("columnar");
|
|
169
|
-
expect(typeof result.content).toBe("string");
|
|
170
|
-
const col = result.content;
|
|
171
|
-
expect(col).toContain("pay_charge");
|
|
172
|
-
expect(col).toContain("auth_login");
|
|
173
|
-
expect(col).toContain("_fmt:columnar");
|
|
174
|
-
});
|
|
175
|
-
it("passes community_id filter to graph store", async () => {
|
|
176
|
-
const graph = createMockGraphStore();
|
|
177
|
-
const router = new QueryRouter(graph);
|
|
178
|
-
await router.execute("get_critical_nodes", { top_n: 3, community_id: 2 });
|
|
179
|
-
expect(graph.getCriticalNodes).toHaveBeenCalledWith(3, 2);
|
|
180
|
-
});
|
|
181
|
-
it("defaults top_n to 10", async () => {
|
|
182
|
-
const graph = createMockGraphStore();
|
|
183
|
-
const router = new QueryRouter(graph);
|
|
184
|
-
await router.execute("get_critical_nodes", {});
|
|
185
|
-
expect(graph.getCriticalNodes).toHaveBeenCalledWith(10, undefined);
|
|
186
|
-
});
|
|
187
|
-
it("is registered as a local route", () => {
|
|
188
|
-
const graph = createMockGraphStore();
|
|
189
|
-
const router = new QueryRouter(graph);
|
|
190
|
-
expect(router.isKnownTool("get_critical_nodes")).toBe(true);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
// ── A.3: Community Context Enrichment ────────────────────────────
|
|
194
|
-
// `_context.community` (string field) was replaced by a context signal in
|
|
195
|
-
// `_context.signals[]`. `_meta.community` / `_meta.cross_community_edges`
|
|
196
|
-
// still flow through. Skipping the legacy `_context.community` assertions.
|
|
197
|
-
describe.skip("Community context enrichment (A.3) (deprecated — _context.community replaced by _context.signals[])", () => {
|
|
198
|
-
it("injects community metadata into _meta for enrichable tools", async () => {
|
|
199
|
-
const graph = createMockGraphStore({
|
|
200
|
-
communityForEntity: {
|
|
201
|
-
id: 2,
|
|
202
|
-
label: "payment",
|
|
203
|
-
size: 15,
|
|
204
|
-
cohesion: 0.73,
|
|
205
|
-
},
|
|
206
|
-
crossCommunityEdges: [
|
|
207
|
-
{
|
|
208
|
-
entity_name: "validateToken",
|
|
209
|
-
entity_key: "auth_validate",
|
|
210
|
-
entity_community_id: 0,
|
|
211
|
-
entity_community_label: "auth",
|
|
212
|
-
relation: "calls",
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
entityOverride: {
|
|
216
|
-
key: "pay_charge",
|
|
217
|
-
kind: "function",
|
|
218
|
-
name: "charge",
|
|
219
|
-
file_path: "src/payment/charge.ts",
|
|
220
|
-
start_line: 1,
|
|
221
|
-
signature: "charge()",
|
|
222
|
-
body: "",
|
|
223
|
-
fan_in: 5,
|
|
224
|
-
fan_out: 3,
|
|
225
|
-
risk_level: "normal",
|
|
226
|
-
community: 2,
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
const router = new QueryRouter(graph);
|
|
230
|
-
const result = await router.execute("get_function", {
|
|
231
|
-
key: "pay_charge",
|
|
232
|
-
});
|
|
233
|
-
expect(result._meta.community).toEqual({
|
|
234
|
-
id: 2,
|
|
235
|
-
label: "payment",
|
|
236
|
-
size: 15,
|
|
237
|
-
cohesion: 0.73,
|
|
238
|
-
});
|
|
239
|
-
expect(result._meta.cross_community_edges).toHaveLength(1);
|
|
240
|
-
expect(result._meta.cross_community_edges?.[0]?.entity_name).toBe("validateToken");
|
|
241
|
-
expect(result._meta.cross_community_count).toBe(1);
|
|
242
|
-
expect(result._context?.community).toContain("payment");
|
|
243
|
-
expect(result._context?.community).toContain("auth");
|
|
244
|
-
});
|
|
245
|
-
it("omits community fields when entity has no community assignment", async () => {
|
|
246
|
-
const graph = createMockGraphStore({
|
|
247
|
-
communityForEntity: null,
|
|
248
|
-
entityOverride: {
|
|
249
|
-
key: "orphan",
|
|
250
|
-
kind: "function",
|
|
251
|
-
name: "orphan",
|
|
252
|
-
file_path: "src/orphan.ts",
|
|
253
|
-
start_line: 1,
|
|
254
|
-
signature: "orphan()",
|
|
255
|
-
body: "",
|
|
256
|
-
fan_in: 0,
|
|
257
|
-
fan_out: 0,
|
|
258
|
-
risk_level: "normal",
|
|
259
|
-
community: -1,
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
const router = new QueryRouter(graph);
|
|
263
|
-
const result = await router.execute("get_function", { key: "orphan" });
|
|
264
|
-
expect(result._meta.community).toBeUndefined();
|
|
265
|
-
expect(result._meta.cross_community_edges).toBeUndefined();
|
|
266
|
-
expect(result._meta.cross_community_count).toBeUndefined();
|
|
267
|
-
});
|
|
268
|
-
it("includes cross_community_count in _meta", async () => {
|
|
269
|
-
const crossEdges = Array.from({ length: 5 }, (_, i) => ({
|
|
270
|
-
entity_name: `entity_${i}`,
|
|
271
|
-
entity_key: `key_${i}`,
|
|
272
|
-
entity_community_id: i,
|
|
273
|
-
entity_community_label: `community_${i}`,
|
|
274
|
-
relation: "calls",
|
|
275
|
-
}));
|
|
276
|
-
const graph = createMockGraphStore({
|
|
277
|
-
communityForEntity: { id: 0, label: "test", size: 10, cohesion: 0.5 },
|
|
278
|
-
crossCommunityEdges: crossEdges,
|
|
279
|
-
entityOverride: {
|
|
280
|
-
key: "test_entity",
|
|
281
|
-
kind: "function",
|
|
282
|
-
name: "test",
|
|
283
|
-
file_path: "src/test.ts",
|
|
284
|
-
start_line: 1,
|
|
285
|
-
signature: "",
|
|
286
|
-
body: "",
|
|
287
|
-
fan_in: 0,
|
|
288
|
-
fan_out: 0,
|
|
289
|
-
risk_level: "normal",
|
|
290
|
-
community: 0,
|
|
291
|
-
},
|
|
292
|
-
});
|
|
293
|
-
const router = new QueryRouter(graph);
|
|
294
|
-
const result = await router.execute("get_function", {
|
|
295
|
-
key: "test_entity",
|
|
296
|
-
});
|
|
297
|
-
expect(result._meta.cross_community_count).toBe(5);
|
|
298
|
-
});
|
|
299
|
-
});
|