@dimassetoid/septum-mcp 0.2.1 → 0.5.0

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.
Files changed (161) hide show
  1. package/README.md +46 -45
  2. package/package.json +8 -6
  3. package/src/cli/commands/check.ts +41 -26
  4. package/src/cli/commands/hook.ts +77 -105
  5. package/src/cli/commands/init.ts +35 -9
  6. package/src/cli/commands/stats.ts +33 -0
  7. package/src/cli/commands/sync-progress.ts +71 -0
  8. package/src/cli/commands/sync.ts +35 -9
  9. package/src/cli/hook-payload.ts +43 -0
  10. package/src/cli/index.ts +15 -51
  11. package/src/cli/scaffold/harness-config.ts +48 -8
  12. package/src/cli/templates/hooks.ts +51 -27
  13. package/src/cli/templates/rules.ts +34 -49
  14. package/src/cli/templates/skill.ts +46 -35
  15. package/src/core/boundary/audit.ts +383 -0
  16. package/src/core/boundary/evaluator.ts +299 -178
  17. package/src/core/boundary/staged-auditor.ts +188 -34
  18. package/src/core/config/domain-ownership.ts +47 -0
  19. package/src/core/config/domain-registration.ts +141 -0
  20. package/src/core/config/loader.ts +82 -54
  21. package/src/core/config/schema.ts +24 -46
  22. package/src/core/database/client.ts +2 -0
  23. package/src/core/database/repositories/dependency.repository.ts +326 -543
  24. package/src/core/database/repositories/domain.repository.ts +48 -4
  25. package/src/core/database/repositories/file.repository.ts +10 -0
  26. package/src/core/database/repositories/symbol.repository.ts +97 -259
  27. package/src/core/database/repository.ts +138 -24
  28. package/src/core/database/schema.ts +28 -33
  29. package/src/core/discovery/declarative-routes.ts +69 -0
  30. package/src/core/discovery/framework-detector.ts +149 -0
  31. package/src/core/discovery/navigation.ts +269 -0
  32. package/src/core/discovery/topology-detector.ts +153 -170
  33. package/src/core/errors.ts +19 -0
  34. package/src/core/ingestion/pipeline.ts +378 -212
  35. package/src/core/parser/behavioral-analyzer.ts +26 -22
  36. package/src/core/parser/boundary-tracker.ts +15 -0
  37. package/src/core/parser/extractors/base.ts +16 -4
  38. package/src/core/parser/extractors/csharp.ts +9 -5
  39. package/src/core/parser/extractors/django-routing.ts +163 -0
  40. package/src/core/parser/extractors/django-semantic.ts +400 -516
  41. package/src/core/parser/extractors/elysia-semantic.ts +172 -496
  42. package/src/core/parser/extractors/express-semantic.ts +195 -398
  43. package/src/core/parser/extractors/fastapi-semantic.ts +182 -399
  44. package/src/core/parser/extractors/fastify-semantic.ts +216 -732
  45. package/src/core/parser/extractors/flask-semantic.ts +92 -388
  46. package/src/core/parser/extractors/go-routing.ts +344 -0
  47. package/src/core/parser/extractors/go-semantic.ts +210 -508
  48. package/src/core/parser/extractors/go.ts +6 -3
  49. package/src/core/parser/extractors/graphql-entrypoint.ts +146 -0
  50. package/src/core/parser/extractors/hono-semantic.ts +132 -530
  51. package/src/core/parser/extractors/java.ts +7 -5
  52. package/src/core/parser/extractors/laravel-routing.ts +263 -0
  53. package/src/core/parser/extractors/laravel-semantic.ts +169 -333
  54. package/src/core/parser/extractors/manifest-helpers.ts +64 -0
  55. package/src/core/parser/extractors/mcp-cli-dispatch.ts +268 -0
  56. package/src/core/parser/extractors/mcp-cli-semantic.ts +84 -336
  57. package/src/core/parser/extractors/nestjs-semantic.ts +238 -510
  58. package/src/core/parser/extractors/nextjs-semantic.ts +164 -0
  59. package/src/core/parser/extractors/php-ast-helpers.ts +51 -0
  60. package/src/core/parser/extractors/php.ts +17 -1
  61. package/src/core/parser/extractors/python-route-ast.ts +249 -0
  62. package/src/core/parser/extractors/python.ts +9 -8
  63. package/src/core/parser/extractors/registry.ts +28 -5
  64. package/src/core/parser/extractors/route-prefixes.ts +43 -0
  65. package/src/core/parser/extractors/ruby.ts +10 -7
  66. package/src/core/parser/extractors/rust.ts +35 -17
  67. package/src/core/parser/extractors/semantic-extractor.interface.ts +3 -1
  68. package/src/core/parser/extractors/symfony-routing.ts +114 -0
  69. package/src/core/parser/extractors/symfony-semantic.ts +75 -262
  70. package/src/core/parser/extractors/typescript-bindings.ts +333 -0
  71. package/src/core/parser/extractors/typescript-compiler-fallback.ts +380 -0
  72. package/src/core/parser/extractors/typescript-fallback.ts +207 -0
  73. package/src/core/parser/extractors/typescript-route-context.ts +58 -0
  74. package/src/core/parser/extractors/typescript.ts +36 -216
  75. package/src/core/parser/implementation-fingerprint.ts +97 -0
  76. package/src/core/parser/language-capabilities.ts +23 -7
  77. package/src/core/parser/schema/providers/laravel-migration-provider.ts +77 -51
  78. package/src/core/parser/schema/schema-provider-registry.ts +1 -3
  79. package/src/core/parser/schema/schema-provider.interface.ts +2 -1
  80. package/src/core/parser/semantic-revision.ts +3 -0
  81. package/src/core/parser/static-string.ts +51 -0
  82. package/src/core/parser/wasm-loader.ts +6 -2
  83. package/src/core/resolver/ast-method-tracer.ts +230 -0
  84. package/src/core/resolver/call-graph-helpers.ts +72 -0
  85. package/src/core/resolver/call-graph-tracer.ts +375 -311
  86. package/src/core/resolver/dependency-analysis.ts +593 -0
  87. package/src/core/resolver/import-candidates.ts +120 -0
  88. package/src/core/resolver/import-evidence.ts +88 -0
  89. package/src/core/resolver/import-resolver.ts +162 -181
  90. package/src/core/resolver/interpretation-inputs.ts +65 -0
  91. package/src/core/resolver/languages/go.ts +103 -0
  92. package/src/core/resolver/languages/managed.ts +200 -0
  93. package/src/core/resolver/languages/python.ts +133 -0
  94. package/src/core/resolver/languages/ruby.ts +40 -0
  95. package/src/core/resolver/languages/rust.ts +127 -0
  96. package/src/core/resolver/languages/shared.ts +74 -0
  97. package/src/core/resolver/module-resolver.ts +18 -7
  98. package/src/core/resolver/path-resolver.ts +6 -3
  99. package/src/core/resolver/polyglot-slice-tracer.ts +197 -0
  100. package/src/core/resolver/slice-catalog.ts +94 -0
  101. package/src/core/resolver/slice-format.ts +22 -0
  102. package/src/core/resolver/slice-selection.ts +237 -0
  103. package/src/core/resolver/symbol-impact.ts +477 -0
  104. package/src/core/resolver/symbol-locator.ts +82 -15
  105. package/src/core/resolver/vertical-slice-tracer.ts +57 -278
  106. package/src/core/resources/ignore.ts +21 -1
  107. package/src/core/resources/limits.ts +2 -1
  108. package/src/core/resources/source-files.ts +143 -20
  109. package/src/core/resources/source-inventory.ts +55 -0
  110. package/src/core/resources/work-queue.ts +167 -4
  111. package/src/core/retrieval/context-page.ts +116 -0
  112. package/src/core/retrieval/context.ts +457 -0
  113. package/src/core/retrieval/resolution-warnings.ts +21 -0
  114. package/src/core/retrieval/source-context.ts +448 -0
  115. package/src/core/retrieval/symbol-details.ts +453 -0
  116. package/src/core/retrieval/symbol-evidence.ts +97 -0
  117. package/src/core/retrieval/typescript-references.ts +293 -0
  118. package/src/core/retrieval/universal-context.ts +182 -0
  119. package/src/core/telemetry/summary.ts +114 -0
  120. package/src/core/telemetry/telemetry.ts +225 -37
  121. package/src/index.ts +0 -3
  122. package/src/mcp/formatters/compact-text.ts +439 -0
  123. package/src/mcp/resources-and-prompts.ts +253 -0
  124. package/src/mcp/schemas/boundary.ts +145 -0
  125. package/src/mcp/schemas/map.ts +250 -0
  126. package/src/mcp/schemas/shared.ts +52 -0
  127. package/src/mcp/schemas/slice.ts +60 -0
  128. package/src/mcp/schemas/symbol.ts +268 -0
  129. package/src/mcp/schemas.ts +5 -1105
  130. package/src/mcp/server.ts +263 -597
  131. package/src/mcp/tool-catalog.ts +331 -0
  132. package/src/mcp/tools/boundary.ts +69 -4
  133. package/src/mcp/tools/map.ts +126 -0
  134. package/src/mcp/tools/slice.ts +101 -3
  135. package/src/mcp/tools/symbol.ts +480 -26
  136. package/src/mcp/ui/app-client.ts +899 -0
  137. package/src/mcp/ui/app.html +478 -0
  138. package/src/mcp/workflow-playbooks.ts +181 -0
  139. package/src/mcp/workspace-boundary.ts +50 -0
  140. package/src/mcp/workspace-manager.ts +102 -18
  141. package/src/mcp/workspace-watcher.ts +38 -19
  142. package/src/types/index.ts +47 -53
  143. package/src/cli/commands/topology.ts +0 -161
  144. package/src/core/database/repositories/environment.repository.ts +0 -207
  145. package/src/core/parser/schema/providers/prisma-schema-provider.ts +0 -90
  146. package/src/core/session/session-manager.ts +0 -107
  147. package/src/core/topology/environment-detector.ts +0 -973
  148. package/src/core/topology/types.ts +0 -83
  149. package/src/mcp/tools/check-boundary.ts +0 -387
  150. package/src/mcp/tools/domain.ts +0 -40
  151. package/src/mcp/tools/feature.ts +0 -67
  152. package/src/mcp/tools/get-domain-catalog.ts +0 -226
  153. package/src/mcp/tools/get-environment-topology.ts +0 -138
  154. package/src/mcp/tools/get-feature-context.ts +0 -224
  155. package/src/mcp/tools/get-symbol-hotspots.ts +0 -54
  156. package/src/mcp/tools/get-symbol-impact.ts +0 -64
  157. package/src/mcp/tools/get-symbol.ts +0 -175
  158. package/src/mcp/tools/locate-symbol.ts +0 -196
  159. package/src/mcp/tools/register-domain.ts +0 -75
  160. package/src/mcp/tools/register-feature.ts +0 -110
  161. package/src/mcp/tools/trace-vertical-slice.ts +0 -80
@@ -1,8 +1,5 @@
1
- import { readSourceFile } from "../resources/source-files.ts";
2
- import { computeContentHash } from "../ingestion/hasher.ts";
3
- import { assertPathContained } from "./path-resolver.ts";
4
- import { join, relative, resolve } from "node:path";
5
- import { collectSourceSkips } from "../resources/source-files.ts";
1
+ import { refreshSliceCatalog } from "./slice-catalog.ts";
2
+ import { selectSliceTarget } from "./slice-selection.ts";
6
3
  import type {
7
4
  ExecutionChainNode,
8
5
  VerticalSliceRecord,
@@ -10,74 +7,29 @@ import type {
10
7
  } from "../../types/index.ts";
11
8
  import type { SeptumRepository } from "../database/repository.ts";
12
9
  import { CallGraphTracer } from "./call-graph-tracer.ts";
13
- import { SemanticSliceExtractorRegistry } from "../parser/extractors/registry.ts";
14
- import { TopologyDetector } from "../discovery/topology-detector.ts";
15
- import { readdirSync } from "node:fs";
16
- import { ASTParserEngine } from "../parser/tree-sitter.ts";
17
- import { shouldIgnoreSourcePath } from "../resources/ignore.ts";
10
+ import { formatSliceNode, parseSliceChain, SLICE_RELATIONSHIP_LIMITS } from "./slice-format.ts";
18
11
 
19
12
  export class VerticalSliceTracer {
20
13
  constructor(private repo: SeptumRepository, private projectRoot: string = process.cwd(), private ignorePatterns: string[] = [], private verifyMembership = true) {}
21
14
 
22
- public async traceAsync(rawQuery: string, maxDepth = 5, signal?: AbortSignal): Promise<VerticalSliceTraceResponse> {
15
+ public async traceAsync(rawQuery: string, maxDepth = 5, signal?: AbortSignal, controllerFile?: string): Promise<VerticalSliceTraceResponse> {
23
16
  signal?.throwIfAborted();
24
17
  if (this.repo.getMeta("sync_state") === "error" || this.repo.getMeta("sync_state") === "running") {
25
18
  return { query: rawQuery, found: false, coverage: "partial", diagnostics: ["index_incomplete"], message: "Workspace synchronization is incomplete." };
26
19
  }
27
- let inputsChanged = false;
28
- let membershipChanged = false;
29
20
  try {
30
- const inputs = JSON.parse(this.repo.getMeta("semantic_inputs") || "[]") as Array<{path:string;hash:string}>;
31
- inputsChanged = inputs.some(input => {
32
- signal?.throwIfAborted();
33
- assertPathContained(input.path,this.projectRoot,"Semantic source");
34
- return computeContentHash(readSourceFile(resolve(this.projectRoot,input.path))) !== input.hash;
21
+ await refreshSliceCatalog(this.repo, this.projectRoot, {
22
+ ignorePatterns: this.ignorePatterns,
23
+ signal,
24
+ verifyMembership: this.verifyMembership,
35
25
  });
36
- if (this.verifyMembership) {
37
- const files = this.listSourceFiles(this.projectRoot);
38
- membershipChanged = JSON.stringify(files) !== (this.repo.getMeta("semantic_catalog_files") || "[]");
39
- }
40
- } catch { signal?.throwIfAborted(); inputsChanged = true; }
41
- if (inputsChanged || membershipChanged || this.repo.getAllVerticalSlices().length === 0 || this.repo.getMeta("slices_dirty") === "1") {
42
- try {
43
- const topology = TopologyDetector.detect(this.projectRoot);
44
- const extracted = await collectSourceSkips(this.projectRoot, async () => {
45
- const slices = await SemanticSliceExtractorRegistry.extractAllSlices(this.projectRoot,topology.framework,undefined,signal);
46
- return slices.length ? slices : new CallGraphTracer(this.repo,this.projectRoot).traceAllSlices(maxDepth);
47
- });
48
- signal?.throwIfAborted();
49
- if (extracted.skipped.length) throw new Error("Semantic source exceeds read limits; catalog is incomplete.");
50
- this.repo.runInTransaction(() => {
51
- signal?.throwIfAborted();
52
- this.repo.clearVerticalSlices();
53
- for (const slice of extracted.value) this.repo.upsertVerticalSlice(slice);
54
- this.repo.setMeta("slices_dirty", "");
55
- this.repo.setMeta("semantic_inputs", JSON.stringify(extracted.inputs));
56
- if (this.verifyMembership) this.repo.setMeta("semantic_catalog_files", JSON.stringify(this.listSourceFiles(this.projectRoot)));
57
- });
58
- } catch (error) {
59
- signal?.throwIfAborted();
60
- this.repo.setMeta("slices_dirty", "1");
61
- return { query: rawQuery, found: false, coverage: "partial", diagnostics: [error instanceof Error ? error.message : String(error)], message: "Semantic extraction failed; no complete catalog was published." };
62
- }
26
+ } catch (error) {
27
+ signal?.throwIfAborted();
28
+ return { query: rawQuery, found: false, coverage: "partial", diagnostics: [error instanceof Error ? error.message : String(error)], message: "Semantic extraction failed; no complete catalog was published." };
63
29
  }
64
- return this.trace(rawQuery,maxDepth);
30
+ return this.trace(rawQuery, maxDepth, controllerFile);
65
31
  }
66
32
 
67
- private listSourceFiles(root: string): string[] {
68
- const files: string[] = [];
69
- const walk = (dir: string) => {
70
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
71
- const fullPath = join(dir, entry.name);
72
- const relPath = relative(root, fullPath).replace(/\\/g, "/");
73
- if (shouldIgnoreSourcePath(relPath, this.ignorePatterns)) continue;
74
- if (entry.isDirectory()) walk(fullPath);
75
- else if (entry.isFile() && ASTParserEngine.isSourceFile(fullPath)) files.push(relPath);
76
- }
77
- };
78
- walk(root);
79
- return files.sort();
80
- }
81
33
 
82
34
  /**
83
35
  * Trace an end-to-end vertical slice from route/action/intent query.
@@ -91,188 +43,25 @@ export class VerticalSliceTracer {
91
43
  * - "Ubah status order di dashboard"
92
44
  */
93
45
  // Synchronous compatibility API reads persisted slices only; use traceAsync for on-demand extraction.
94
- public trace(rawQuery: string, maxDepth: number = 5): VerticalSliceTraceResponse {
46
+ public trace(rawQuery: string, maxDepth: number = 5, controllerFile?: string): VerticalSliceTraceResponse {
95
47
  const effectiveMaxDepth = Math.min(Math.max(Math.trunc(maxDepth || 5), 1), 8);
96
- const trimmed = rawQuery.trim();
97
- const lowerTrimmed = trimmed.toLowerCase();
98
- let allSlices = this.repo.getAllVerticalSlices();
99
-
100
- if (allSlices.length === 0) {
101
- return {
102
- query: trimmed,
103
- found: false,
104
- max_depth_applied: effectiveMaxDepth,
105
- message: "No vertical slices cataloged. Run 'septum sync' to extract framework routes and MVC slices.",
106
- };
107
- }
108
-
109
- // 1. Exact HTTP Method + URI match: "POST /orders/{id}/status" or "POST /api/orders"
110
- const methodUriMatch = trimmed.match(/^(GET|POST|PUT|PATCH|DELETE)\s+(\/[^\s]+)$/i);
111
- if (methodUriMatch) {
112
- const httpMethod = methodUriMatch[1].toUpperCase();
113
- const uri = methodUriMatch[2];
114
- const candidates = allSlices.filter((s) => s.http_method.toUpperCase() === httpMethod && this.urisMatch(s.route_uri, uri));
115
- const literal = candidates.filter(s => s.route_uri === uri);
116
- if (literal.length === 1) {
117
- return this.formatSuccessResponse(trimmed, literal[0], "exact", undefined, effectiveMaxDepth);
118
- }
119
- if (literal.length > 1 || candidates.length > 1) {
120
- return this.formatSuccessResponse(trimmed, literal[0] ?? candidates[0], "inferred", (literal.length ? literal : candidates).slice(1), effectiveMaxDepth);
121
- }
122
- if (candidates.length === 1) {
123
- return this.formatSuccessResponse(trimmed, candidates[0], "inferred", undefined, effectiveMaxDepth);
124
- }
125
- return { query: trimmed, found: false, max_depth_applied: effectiveMaxDepth, message: `No vertical slice found matching query '${trimmed}'.` };
48
+ const exactCandidates = typeof this.repo.findExactVerticalSlices === "function"
49
+ ? this.repo.findExactVerticalSlices(rawQuery, controllerFile)
50
+ : [];
51
+ const indexedCandidates = exactCandidates.length > 0
52
+ ? exactCandidates
53
+ : typeof this.repo.findVerticalSlices === "function"
54
+ ? this.repo.findVerticalSlices(rawQuery)
55
+ : [];
56
+ const filteredIndexed = controllerFile
57
+ ? indexedCandidates.filter(s => s.controller_file === controllerFile)
58
+ : indexedCandidates;
59
+ const slices = filteredIndexed.length > 0 ? filteredIndexed : this.repo.getAllVerticalSlices();
60
+ const selection = selectSliceTarget(slices, rawQuery, effectiveMaxDepth, controllerFile);
61
+ if ("record" in selection) {
62
+ return this.formatSuccessResponse(selection.query, selection.record, selection.confidence, selection.alternatives, effectiveMaxDepth);
126
63
  }
127
-
128
- // 2. URI-only match: "/orders" or "orders/{id}"
129
- const literalUriMatches = allSlices.filter((s) => s.route_uri === trimmed);
130
- const uriMatches = literalUriMatches.length ? literalUriMatches : allSlices.filter((s) => this.urisMatch(s.route_uri, trimmed));
131
- if (uriMatches.length > 0) {
132
- const confidence = literalUriMatches.length ? "exact" : "inferred";
133
- if (uriMatches.length === 1) {
134
- return this.formatSuccessResponse(trimmed, uriMatches[0], confidence, undefined, effectiveMaxDepth);
135
- }
136
- // Multiple matches (e.g. GET /orders and POST /orders) -> return primary with alternatives
137
- return this.formatSuccessResponse(trimmed, uriMatches[0], confidence, uriMatches.slice(1), effectiveMaxDepth);
138
- }
139
-
140
- // 3. Named Route match: "orders.status.update" or "admin.users.index"
141
- const nameMatch = allSlices.find(
142
- (s) => s.route_name && s.route_name.toLowerCase() === lowerTrimmed
143
- );
144
- if (nameMatch) {
145
- return this.formatSuccessResponse(trimmed, nameMatch, "exact", undefined, effectiveMaxDepth);
146
- }
147
-
148
- // 3b. Omni-Trigger Match: "JOB ProcessOrderJob", "job:ProcessOrderJob", "CLI order:cleanup", "EVENT OrderPlacedListener"
149
- const omniTriggerMatch = trimmed.match(/^(JOB|CLI|EVENT)\s+([A-Za-z0-9_:\-]+)$/i);
150
- if (omniTriggerMatch) {
151
- const triggerKind = omniTriggerMatch[1].toUpperCase();
152
- const targetName = omniTriggerMatch[2].toLowerCase();
153
- const exact = allSlices.find(
154
- (s) =>
155
- s.http_method.toUpperCase() === triggerKind &&
156
- (s.controller_class.toLowerCase() === targetName ||
157
- s.route_uri.toLowerCase() === targetName ||
158
- s.route_uri.toLowerCase() === `${triggerKind.toLowerCase()}:${targetName}`)
159
- );
160
- if (exact) {
161
- return this.formatSuccessResponse(trimmed, exact, "exact", undefined, effectiveMaxDepth);
162
- }
163
- }
164
-
165
- // 4. Controller@Action match: "OrderController@updateStatus" or "OrderController"
166
- const controllerActionMatch = trimmed.match(/^([A-Za-z0-9_\\/.]+?)(?:(?:@|::)([A-Za-z0-9_]+))?$/);
167
- if (controllerActionMatch) {
168
- const [, rawCtrl, act] = controllerActionMatch;
169
- const ctrl = rawCtrl.split(/[\\/]/).pop()?.replace(/\.(php|ts|js)$/i, "") || rawCtrl;
170
- const lowerCtrl = ctrl.toLowerCase();
171
- const lowerAct = act ? act.toLowerCase() : undefined;
172
-
173
- const exact = allSlices.find((s) => {
174
- const sCtrlLower = s.controller_class.toLowerCase();
175
- const ctrlMatch =
176
- sCtrlLower === lowerCtrl ||
177
- sCtrlLower.endsWith(`\\${lowerCtrl}`) ||
178
- sCtrlLower.endsWith(`/${lowerCtrl}`);
179
- if (!ctrlMatch) return false;
180
- if (lowerAct) return s.action_name.toLowerCase() === lowerAct;
181
- if (!act && !lowerCtrl.endsWith("controller") && sCtrlLower !== lowerCtrl) {
182
- return false;
183
- }
184
- return true;
185
- });
186
- if (exact) {
187
- return this.formatSuccessResponse(trimmed, exact, "exact", undefined, effectiveMaxDepth);
188
- }
189
- }
190
-
191
- // 5. Symbol Match in Execution Chain or Action Name (e.g. "createOrder", "CreateOrderUseCase", "OrderController")
192
- const symbolMatch = allSlices.find((s) => {
193
- if (s.action_name.toLowerCase() === lowerTrimmed) return true;
194
- if (s.controller_class.toLowerCase() === lowerTrimmed) return true;
195
- if (s.execution_chain_json) {
196
- try {
197
- const chain: ExecutionChainNode[] = JSON.parse(s.execution_chain_json);
198
- return chain.some(
199
- (node) =>
200
- node.symbol.toLowerCase() === lowerTrimmed ||
201
- node.symbol.toLowerCase().includes(lowerTrimmed) ||
202
- (node.file && node.file.toLowerCase().includes(lowerTrimmed))
203
- );
204
- } catch {
205
- return false;
206
- }
207
- }
208
- return false;
209
- });
210
- if (symbolMatch) {
211
- return this.formatSuccessResponse(trimmed, symbolMatch, "inferred", undefined, effectiveMaxDepth);
212
- }
213
-
214
- // 6. Semantic / Token Scoring for Natural Language (e.g. "Ubah status order di dashboard")
215
- const tokens = this.tokenize(trimmed);
216
- const scoredSlices = allSlices
217
- .map((slice) => {
218
- let score = 0;
219
- const textCorpus = [
220
- slice.route_uri,
221
- slice.route_name || "",
222
- slice.controller_class,
223
- slice.action_name,
224
- slice.execution_chain_json || "",
225
- ].join(" ").toLowerCase();
226
-
227
- for (const token of tokens) {
228
- if (textCorpus.includes(token)) {
229
- score += 1;
230
- if (slice.route_uri.toLowerCase().includes(token)) score += 2;
231
- if (slice.action_name.toLowerCase().includes(token)) score += 2;
232
- }
233
- }
234
- return { slice, score };
235
- })
236
- .filter((item) => item.score > 0)
237
- .sort((a, b) => b.score - a.score);
238
-
239
- if (scoredSlices.length > 0) {
240
- const primary = scoredSlices[0].slice;
241
- const alternatives = scoredSlices.slice(1, 4).map((item) => item.slice);
242
- return this.formatSuccessResponse(trimmed, primary, "inferred", alternatives, effectiveMaxDepth);
243
- }
244
-
245
- return {
246
- query: trimmed,
247
- found: false,
248
- max_depth_applied: effectiveMaxDepth,
249
- alternatives: allSlices.slice(0, 5).map((s) => ({
250
- method: s.http_method,
251
- uri: s.route_uri,
252
- controller: s.controller_class,
253
- action: s.action_name,
254
- })),
255
- message: `No vertical slice found matching query '${trimmed}'.`,
256
- };
257
- }
258
-
259
- private urisMatch(uriA: string, uriB: string): boolean {
260
- const normA = uriA
261
- .replace(/\{[^}]+\}/g, ":param")
262
- .replace(/:[a-zA-Z0-9_]+/g, ":param");
263
- const normB = uriB
264
- .replace(/\{[^}]+\}/g, ":param")
265
- .replace(/:[a-zA-Z0-9_]+/g, ":param");
266
- return normA === normB;
267
- }
268
-
269
- private tokenize(str: string): string[] {
270
- return str
271
- .replace(/([a-z])([A-Z])/g, "$1 $2")
272
- .toLowerCase()
273
- .replace(/[^a-z0-9_]+/g, " ")
274
- .split(/\s+/)
275
- .filter((t) => t.length > 2 && !["ubah", "di", "dan", "yang", "the", "for", "and"].includes(t));
64
+ return selection;
276
65
  }
277
66
 
278
67
  private formatSuccessResponse(
@@ -283,62 +72,52 @@ export class VerticalSliceTracer {
283
72
  effectiveMaxDepth: number = 5
284
73
  ): VerticalSliceTraceResponse {
285
74
  let chain: ExecutionChainNode[] = [];
286
- if (record.execution_chain_json) {
287
- try {
288
- chain = JSON.parse(record.execution_chain_json);
289
- } catch (err: unknown) {
290
- const msg = err instanceof Error ? err.message : String(err);
291
- console.error(`[Septum Slice Error] Corrupted execution chain JSON for slice ${record.id}: ${msg}`);
292
- }
75
+ const diagnostics: string[] = [];
76
+ try {
77
+ chain = parseSliceChain(record.execution_chain_json);
78
+ } catch {
79
+ diagnostics.push("invalid_execution_chain");
293
80
  }
294
81
 
295
82
  // Import expansion is derived per request, so cached depth cannot override the requested hop limit.
296
83
  chain = chain.filter(node => node.relationship?.kind !== "imports" && !node.description?.includes("(dependency)"));
84
+ // Go imports resolve whole packages; expanding them injects unrelated handlers/services.
297
85
  if (
298
- record.controller_file &&
86
+ record.architecture_style !== "go-http" && !diagnostics.length && record.controller_file &&
299
87
  typeof (this.repo as any).getAllFiles === "function"
300
88
  ) {
301
89
  try {
302
90
  const callGraphTracer = new CallGraphTracer(this.repo, this.projectRoot);
303
- chain = callGraphTracer.expandChainFromFile(
304
- record.controller_file,
305
- chain,
306
- effectiveMaxDepth
307
- );
91
+ chain = record.action_name
92
+ ? callGraphTracer.expandChainFromMethod(
93
+ record.controller_file,
94
+ record.action_name,
95
+ chain,
96
+ effectiveMaxDepth
97
+ )
98
+ : callGraphTracer.expandChainFromFile(
99
+ record.controller_file,
100
+ chain,
101
+ effectiveMaxDepth
102
+ );
308
103
  } catch {
309
- // Ignore expansion errors on mock/partial repositories
104
+ diagnostics.push("dependency_expansion_failed");
310
105
  }
311
106
  }
312
107
 
313
- let message = `Vertical slice resolved (${confidence}): ${record.http_method} ${record.route_uri} -> ${record.controller_class}@${record.action_name}`;
314
- if (chain.length > 0) {
315
- const stageLines = chain.map((node) => {
316
- const stageLabel = `[${node.stage.toUpperCase()}]`.padEnd(14, " ");
317
- const loc = node.file ? ` (${node.file}${node.line ? `:${node.line}` : ""})` : "";
318
- let extra = "";
319
- if (node.table) {
320
- extra += ` [table: ${node.table}]`;
321
- }
322
- if (node.columns_summary) {
323
- extra += ` {${node.columns_summary}}`;
324
- }
325
- if (node.guards && node.guards.length > 0 && node.stage !== "guard") {
326
- extra += ` [guards: ${node.guards.join(", ")}]`;
327
- }
328
- if (node.mutations && node.mutations.length > 0 && node.stage !== "side_effect") {
329
- extra += ` [mutates: ${node.mutations.join(", ")}]`;
330
- }
331
- if (node.transactions && node.stage !== "transaction") {
332
- extra += ` [tx: active]`;
333
- }
334
- return `${stageLabel} ${node.symbol}${loc}${extra}`;
335
- });
336
- message = `=== VERTICAL SLICE TRACE (${confidence.toUpperCase()}) ===\n` + stageLines.join("\n");
108
+ if (chain.some(node => node.stage === "ingress" && node.relationship?.derivation === "inferred")) confidence = "inferred";
109
+ let message = `Vertical slice target match (${confidence}): ${record.http_method} ${record.route_uri} -> ${record.controller_class}@${record.action_name} (${chain.length} node(s)).`;
110
+ if (record.architecture_style === "go-http") {
111
+ message += " Go package import expansion is omitted; extracted handler/service relationships remain lexical and partial.";
337
112
  }
113
+ if (diagnostics.length) message += ` Analysis incomplete: ${diagnostics.join(", ")}. Run septum sync and retry; inspect source if it persists.`;
338
114
 
339
115
  return {
340
116
  query,
341
117
  found: true,
118
+ coverage: "partial",
119
+ diagnostics: diagnostics.length ? diagnostics : undefined,
120
+ next: diagnostics.length ? ["Run septum sync to rebuild analysis; retry the query. Inspect source directly if the diagnostic persists."] : undefined,
342
121
  confidence,
343
122
  is_exact_match: confidence === "exact",
344
123
  architecture_style: record.architecture_style,
@@ -4,10 +4,21 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
4
4
  "vendor",
5
5
  "bower_components",
6
6
  "jspm_packages",
7
+ "deps",
8
+ ".bundle",
9
+ ".cargo",
10
+ ".gradle",
11
+ ".m2",
12
+ ".mvn",
13
+ ".nuget",
14
+ ".dart_tool",
15
+ ".pub-cache",
16
+ ".pub",
7
17
 
8
18
  // Build, bundle & compilation outputs (visible & hidden)
9
19
  "dist",
10
20
  "build",
21
+ "_build",
11
22
  "out",
12
23
  "output",
13
24
  ".output",
@@ -15,6 +26,8 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
15
26
  "obj",
16
27
  "bin",
17
28
  "scripts",
29
+ "zig-out",
30
+ ".zig-cache",
18
31
  ".next",
19
32
  ".nuxt",
20
33
  ".turbo",
@@ -23,7 +36,7 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
23
36
  ".astro",
24
37
  ".docusaurus",
25
38
 
26
- // Python virtual environments and bytecode caches
39
+ // Python virtual environments, packaging and bytecode caches
27
40
  ".venv",
28
41
  "venv",
29
42
  "env",
@@ -34,6 +47,8 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
34
47
  ".mypy_cache",
35
48
  ".ruff_cache",
36
49
  ".tox",
50
+ ".nox",
51
+ ".eggs",
37
52
 
38
53
  // Test coverage
39
54
  "coverage",
@@ -64,11 +79,16 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
64
79
  ".antigravity",
65
80
  ".cline",
66
81
  ".roo",
82
+ ".toolbench",
67
83
  ".windsurf",
68
84
  ".continue",
69
85
  ".copilot",
70
86
  ".chat",
71
87
 
88
+ // Framework storage & uploads
89
+ "storage",
90
+ "public/storage",
91
+
72
92
  // Cache & Temp
73
93
  ".cache",
74
94
  "tmp",
@@ -1,7 +1,7 @@
1
1
  export const RESOURCE_LIMITS = Object.freeze({
2
2
  workspaces: 4,
3
3
  workspaceIdleMs: 10 * 60_000,
4
- watches: 2048,
4
+ watches: 8192,
5
5
  pendingPaths: 1000,
6
6
  debounceMs: 300,
7
7
  pollMs: 5000,
@@ -10,5 +10,6 @@ export const RESOURCE_LIMITS = Object.freeze({
10
10
  batchFiles: 50,
11
11
  batchBytes: 1024 * 1024,
12
12
  maxQueuePending: 50,
13
+ requestTimeoutMs: 120_000,
13
14
  shutdownMs: 5000,
14
15
  });