@saptools/service-flow 0.1.15 → 0.1.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.16
4
+
5
+ - Index class property arrow/function members as executable symbols so outbound calls inside handler helper properties receive precise source-symbol ownership.
6
+ - Add conservative synthetic callback symbols for top-level CAP lifecycle, route, and event callbacks that contain supported outbound calls.
7
+ - Harden proxy-member symbol-call resolution with richer evidence and avoid ambiguous repository-wide member-name fallback.
8
+ - Split `service-flow link` operation-call output into remote resolved, local resolved, unresolved, ambiguous, dynamic, and terminal buckets.
9
+ - Extend strict doctor ownership diagnostics with ownerless outbound-call details by call type and syntactic gap.
10
+ - Keep `OutboundCallFact.sourceSymbolQualifiedName` aligned with persistence by preferring explicit qualified names before line-range fallback.
11
+
3
12
  ## 0.1.15
4
13
 
5
14
  - Fixed `symbol_calls.evidence_json` persistence so inserted rows store the parser evidence object instead of a numeric repository id, with explicit initial resolved/unresolved statuses.
package/README.md CHANGED
@@ -18,9 +18,9 @@ Index independent Git repositories, persist CAP/CDS facts in SQLite, resolve cro
18
18
 
19
19
  ---
20
20
 
21
- ## 0.1.15 quality update
21
+ ## 0.1.16 quality update
22
22
 
23
- `service-flow` 0.1.15 fixes symbol-call evidence persistence so fresh databases store object-shaped parser evidence, extends strict doctor checks for evidence and parser-quality ratios, and conservatively resolves exported static class-member and exported shorthand object-map helper flows through relative imports without restoring broad symbol-call fallback noise.
23
+ `service-flow` 0.1.16 tightens source ownership and proxy evidence after the 0.1.15 audit. It indexes class property arrow/function members, creates conservative synthetic callback symbols only for top-level framework callbacks containing supported outbound calls, prefers explicit outbound source-symbol names when provided, hardens proxy-member resolution away from ambiguous global name-only matches, and splits link output into remote/local/unresolved/ambiguous/dynamic/terminal operation-call buckets.
24
24
 
25
25
  ## ✨ Features
26
26
 
@@ -135,7 +135,7 @@ service-flow index --workspace /path/to/workspace --repo identity-service --forc
135
135
 
136
136
  ### 🔗 `service-flow link`
137
137
 
138
- Resolve indexed outbound calls after repositories have been indexed. This rebuilds the `graph_edges` table for the workspace.
138
+ Resolve indexed outbound calls after repositories have been indexed. This rebuilds the `graph_edges` table for the workspace. The summary separates remote operation calls resolved, local operation calls resolved, unresolved operation calls, ambiguous operation calls, dynamic operation calls, and terminal call edges so local CAP service resolutions are not labeled as remote.
139
139
 
140
140
  ```bash
141
141
  service-flow link --workspace /path/to/workspace
@@ -155,7 +155,7 @@ target handler up to `--depth` instead of showing only calls in the first file.
155
155
 
156
156
  ### Symbol-scoped helper traversal
157
157
 
158
- `service-flow trace` starts from the selected handler method symbol, renders outbound calls owned by that symbol, and follows conservative local helper-call facts. Supported helper edges include same-file functions, `this.method()` calls, and exactly mapped relative imports/exports that resolve to an indexed executable symbol. Calls from unrelated functions in the same source file are not included merely because the file path matches.
158
+ `service-flow trace` starts from the selected handler method symbol, renders outbound calls owned by that symbol, and follows conservative local helper-call facts. Handler helper properties such as `helper = async () => { ... }` and `helper = function () { ... }` are indexed as `ClassName.helper`; top-level CAP lifecycle, route, and event callbacks receive synthetic `module:<file>#callback:<line>` owners only when their body contains a supported outbound call or event subscription. Supported helper edges include same-file functions, `this.method()` calls, and exactly mapped relative imports/exports that resolve to an indexed executable symbol. Proxy-member calls keep factory/import evidence and avoid resolving by repository-wide member name alone when the target is ambiguous. Calls from unrelated functions in the same source file are not included merely because the file path matches.
159
159
 
160
160
  Local CAP calls through `cds.services.<Service>.<operation>()`, bracket service lookups, and simple aliases are indexed as local operation calls. Linking first stays within the same repository and matches the target operation by exact qualified CDS service name, exact simple service name, exact service path, or an unambiguous service-path suffix. If no same-repository service exists, the linker can use implementation-context evidence to resolve model-package operations for helper packages: a resolved/ambiguous implementation candidate, registration package, or dependency/import edge must tie the caller repository to the model operation. Name-only global matches are preserved as unresolved candidate evidence rather than guessed links. Entity accessors such as `cds.services.db.entities(...)` are treated as entity metadata access, not operation calls.
161
161
 
package/TECHNICAL-NOTE.md CHANGED
@@ -6,6 +6,14 @@
6
6
  - Trace cycle safety: trace queues carry repository IDs, visited scope keys are independent of depth, graph edge IDs are emitted once, and revisiting an already-seen downstream operation scope creates a cycle marker instead of recursive expansion.
7
7
  - SQLite reliability: the package uses a persistent SQLite connection per opened database, bound parameters, transactions, WAL, busy timeouts, read-only openings for query commands, and connection-local foreign-key enforcement. Native driver loading failures produce an actionable startup error before output rendering.
8
8
 
9
+ ## 0.1.16 audit follow-up notes
10
+
11
+ - Executable symbol parsing now treats class property arrow functions and function-expression initializers as method-like symbols with `ClassName.memberName` qualified names. Their body ranges are persisted so outbound-call ownership can use the existing shortest enclosing range lookup.
12
+ - Synthetic callback symbols are intentionally narrow: only top-level CAP lifecycle, route, and event-registration callbacks whose bodies contain supported outbound calls/subscriptions are indexed as `module:<relative-file>#callback:<line>`. Ordinary anonymous callbacks remain out of scope to avoid broad call-graph noise.
13
+ - Proxy-member calls record proxy variable, factory expression, factory import source, and candidate strategy. Resolution prefers explicit object-map evidence and treats ambiguous repository-wide member-name matches as ambiguous instead of picking the first symbol row. Full whole-program TypeScript data-flow remains a non-goal.
14
+ - `link` summaries now distinguish remote and local operation-call resolutions, while retaining the aggregate `resolvedCount` in the programmatic result for compatibility.
15
+ - Strict doctor source-ownership diagnostics include ownerless groupings by call type and syntactic gap so remaining ownerless calls can be audited without weakening the threshold.
16
+
9
17
  ## 0.1.15 audit follow-up notes
10
18
 
11
19
  - Symbol-call rows now require object-shaped parser evidence in strict doctor; this catches numeric JSON regressions that `json_valid()` alone would miss.
@@ -1318,6 +1318,8 @@ function linkCalls(db, workspaceId, vars, generation) {
1318
1318
  let edgeCount = 0;
1319
1319
  let unresolvedCount = 0;
1320
1320
  let resolvedCount = 0;
1321
+ let remoteResolvedCount = 0;
1322
+ let localResolvedCount = 0;
1321
1323
  let ambiguousCount = 0;
1322
1324
  let dynamicCount = 0;
1323
1325
  let terminalCount = 0;
@@ -1326,12 +1328,14 @@ function linkCalls(db, workspaceId, vars, generation) {
1326
1328
  const result = insertCallEdge(db, workspaceId, call, vars, generation);
1327
1329
  edgeCount += 1;
1328
1330
  resolvedCount += result.status === "resolved" ? 1 : 0;
1331
+ remoteResolvedCount += result.status === "resolved" && result.callType !== "local_service_call" ? 1 : 0;
1332
+ localResolvedCount += result.status === "resolved" && result.callType === "local_service_call" ? 1 : 0;
1329
1333
  unresolvedCount += result.status === "unresolved" ? 1 : 0;
1330
1334
  ambiguousCount += result.status === "ambiguous" ? 1 : 0;
1331
1335
  dynamicCount += result.status === "dynamic" ? 1 : 0;
1332
1336
  terminalCount += result.status === "terminal" ? 1 : 0;
1333
1337
  }
1334
- return { edgeCount, unresolvedCount, resolvedCount, ambiguousCount, dynamicCount, terminalCount };
1338
+ return { edgeCount, unresolvedCount, resolvedCount, remoteResolvedCount, localResolvedCount, ambiguousCount, dynamicCount, terminalCount };
1335
1339
  }
1336
1340
  function insertCallEdge(db, workspaceId, call, vars, generation) {
1337
1341
  const callType = String(call.call_type);
@@ -1344,11 +1348,11 @@ function insertCallEdge(db, workspaceId, call, vars, generation) {
1344
1348
  const evidence = callEvidence(call, resolution, servicePath, op, destination ? applyVariables(destination, vars) : void 0);
1345
1349
  if (callType === "local_service_call" && call.unresolved_reason === "transport_client_method" && !resolution.target && resolution.candidates.length === 0) {
1346
1350
  db.prepare("INSERT INTO graph_edges(workspace_id,edge_type,status,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,generation) VALUES(?,?,?,?,?,?,?,?,?,?,?)").run(workspaceId, "HANDLER_CALLS_EXTERNAL_HTTP", "terminal", "call", String(call.id), "external", String(op || "transport_client_method"), Number(call.confidence ?? 0.5), JSON.stringify({ ...evidence, classification: "transport_client_method" }), 0, generation);
1347
- return { status: "terminal" };
1351
+ return { status: "terminal", callType };
1348
1352
  }
1349
1353
  if (resolution.target) {
1350
1354
  db.prepare("INSERT INTO graph_edges(workspace_id,edge_type,status,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,generation) VALUES(?,?,?,?,?,?,?,?,?,?,?)").run(workspaceId, callType === "local_service_call" ? "LOCAL_CALL_RESOLVES_TO_OPERATION" : "REMOTE_CALL_RESOLVES_TO_OPERATION", "resolved", "call", String(call.id), "operation", String(resolution.target.operationId), resolution.target.score, JSON.stringify(evidence), isDynamic ? 1 : 0, generation);
1351
- return { status: "resolved" };
1355
+ return { status: "resolved", callType };
1352
1356
  }
1353
1357
  const edgeType = callType === "local_db_query" ? "HANDLER_RUNS_DB_QUERY" : callType === "external_http" ? "HANDLER_CALLS_EXTERNAL_HTTP" : callType === "async_emit" ? "HANDLER_EMITS_EVENT" : callType === "async_subscribe" ? "EVENT_CONSUMED_BY_HANDLER" : resolution.status === "dynamic" ? "DYNAMIC_EDGE_CANDIDATE" : "UNRESOLVED_EDGE";
1354
1358
  const status = edgeType === "DYNAMIC_EDGE_CANDIDATE" ? "dynamic" : resolution.status === "ambiguous" ? "ambiguous" : edgeType === "UNRESOLVED_EDGE" ? "unresolved" : "terminal";
@@ -1356,7 +1360,7 @@ function insertCallEdge(db, workspaceId, call, vars, generation) {
1356
1360
  const targetKind = callType === "local_db_query" ? "db_entity" : callType.startsWith("async_") ? "event" : "external";
1357
1361
  const targetId = callType === "local_db_query" ? String(call.query_entity ?? "unknown") : String(call.event_name_expr ?? op ?? call.id);
1358
1362
  db.prepare("INSERT INTO graph_edges(workspace_id,edge_type,status,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,unresolved_reason,generation) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)").run(workspaceId, edgeType, status, "call", String(call.id), targetKind, targetId, Number(call.confidence ?? 0.2), JSON.stringify(evidence), isDynamic || resolution.status === "dynamic" ? 1 : 0, unresolvedReason, generation);
1359
- return { status };
1363
+ return { status, callType };
1360
1364
  }
1361
1365
  function callEvidence(call, resolution, servicePath, op, destination) {
1362
1366
  return { sourceFile: call.source_file, sourceLine: call.source_line, file: call.source_file, line: call.source_line, callId: call.id, repo: call.repoName, serviceAlias: call.alias, serviceAliasExpr: call.aliasExpr, destination, servicePath, operationPath: op, localServiceName: call.local_service_name, localServiceLookup: call.local_service_lookup, aliasChain: call.alias_chain_json ? JSON.parse(String(call.alias_chain_json)) : void 0, transport: call.call_type === "local_service_call" ? "local" : void 0, targetRepo: resolution.target?.repoName, targetOperation: resolution.target?.operationName, helperChain: call.helperChainJson ? JSON.parse(String(call.helperChainJson)) : void 0, candidates: resolution.candidates, candidateCount: resolution.candidates.length, resolutionStatus: resolution.status, resolutionReasons: resolution.reasons, analysisCompleteness: call.unresolved_reason ? "partial" : "complete", parserWarning: call.unresolved_reason ? { code: "parser_warning", message: call.unresolved_reason } : void 0 };
@@ -1991,4 +1995,4 @@ export {
1991
1995
  linkWorkspace,
1992
1996
  trace
1993
1997
  };
1994
- //# sourceMappingURL=chunk-ZSUL2X77.js.map
1998
+ //# sourceMappingURL=chunk-SSSBQIMK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/discovery/discover-repositories.ts","../src/utils/path-utils.ts","../src/parsers/package-json-parser.ts","../src/parsers/cds-parser.ts","../src/parsers/decorator-parser.ts","../src/parsers/ts-project.ts","../src/parsers/handler-registration-parser.ts","../src/utils/redaction.ts","../src/parsers/outbound-call-parser.ts","../src/parsers/service-binding-parser.ts","../src/linker/dynamic-edge-resolver.ts","../src/linker/service-resolver.ts","../src/linker/helper-package-linker.ts","../src/linker/cross-repo-linker.ts","../src/trace/trace-engine.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { DiscoveredRepository } from '../types.js';\nimport { relativePath } from '../utils/path-utils.js';\nexport async function discoverRepositories(\n rootPath: string,\n ignore: readonly string[]\n): Promise<DiscoveredRepository[]> {\n const root = path.resolve(rootPath);\n const ignored = new Set(ignore);\n const found: DiscoveredRepository[] = [];\n async function isRealGitMarker(dir: string): Promise<boolean> {\n const gitPath = path.join(dir, '.git');\n try {\n const st = await fs.stat(gitPath);\n if (st.isDirectory()) {\n const children = await fs.readdir(gitPath);\n return children.includes('HEAD') || children.includes('config');\n }\n if (st.isFile()) {\n const text = await fs.readFile(gitPath, 'utf8');\n return text.trimStart().startsWith('gitdir:');\n }\n } catch {\n /* not a normal git marker */\n }\n try {\n const fixture = await fs.stat(path.join(dir, '.git-fixture'));\n return fixture.isFile() || fixture.isDirectory();\n } catch {\n return false;\n }\n }\n async function walk(dir: string): Promise<void> {\n const rel = relativePath(root, dir);\n if (rel !== '.' && rel.split('/').some((part) => ignored.has(part))) return;\n let entries: Array<{ name: string; isDirectory: () => boolean }>;\n try {\n entries = await fs.readdir(dir, { withFileTypes: true });\n } catch {\n return;\n }\n const hasMarker = entries.some((e) => e.name === '.git' || e.name === '.git-fixture');\n if (hasMarker && await isRealGitMarker(dir)) {\n found.push({\n name: path.basename(dir),\n absolutePath: dir,\n relativePath: relativePath(root, dir),\n isGitRepo: true\n });\n }\n for (const entry of entries)\n if (entry.isDirectory() && !ignore.includes(entry.name))\n await walk(path.join(dir, entry.name));\n }\n await walk(root);\n return found.sort((a, b) => a.relativePath.localeCompare(b.relativePath));\n}\n","import path from 'node:path';\nexport function normalizePath(value: string): string {\n return value.split(path.sep).join('/');\n}\nexport function relativePath(root: string, value: string): string {\n return normalizePath(path.relative(root, value) || '.');\n}\nexport function ensureLeadingSlash(value: string): string {\n return value.startsWith('/') ? value : `/${value}`;\n}\nexport function stripQuotes(value: string): string {\n return value.replace(/^['\"`]|['\"`]$/g, '');\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { CdsRequire, PackageFacts } from '../types.js';\nfunction recordOfString(value: unknown): Record<string, string> {\n if (!value || typeof value !== 'object') return {};\n return Object.fromEntries(\n Object.entries(value).filter(([, v]) => typeof v === 'string')\n ) as Record<string, string>;\n}\nfunction readRequires(cds: unknown): CdsRequire[] {\n const requires =\n cds && typeof cds === 'object' && 'requires' in cds\n ? (cds as { requires?: unknown }).requires\n : undefined;\n if (!requires || typeof requires !== 'object') return [];\n return Object.entries(requires).flatMap(([alias, raw]) => {\n if (!raw || typeof raw !== 'object') return [];\n const obj = raw as Record<string, unknown>;\n const credentials =\n obj.credentials && typeof obj.credentials === 'object'\n ? (obj.credentials as Record<string, unknown>)\n : {};\n return [\n {\n alias,\n kind: typeof obj.kind === 'string' ? obj.kind : undefined,\n model: typeof obj.model === 'string' ? obj.model : undefined,\n destination:\n typeof credentials.destination === 'string'\n ? credentials.destination\n : undefined,\n servicePath:\n typeof credentials.path === 'string' ? credentials.path : undefined,\n requestTimeout:\n typeof credentials.requestTimeout === 'number'\n ? credentials.requestTimeout\n : undefined,\n rawJson: JSON.stringify(raw)\n }\n ];\n });\n}\nexport async function parsePackageJson(\n repoPath: string\n): Promise<PackageFacts> {\n try {\n const raw = await fs.readFile(path.join(repoPath, 'package.json'), 'utf8');\n const json = JSON.parse(raw) as Record<string, unknown>;\n return {\n packageName: typeof json.name === 'string' ? json.name : undefined,\n packageVersion:\n typeof json.version === 'string' ? json.version : undefined,\n dependencies: {\n ...recordOfString(json.dependencies),\n ...recordOfString(json.devDependencies)\n },\n cdsRequires: readRequires(json.cds),\n scripts: recordOfString(json.scripts)\n };\n } catch {\n return { dependencies: {}, cdsRequires: [], scripts: {} };\n }\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { CdsOperationFact, CdsServiceFact } from '../types.js';\nimport { ensureLeadingSlash, normalizePath } from '../utils/path-utils.js';\n\nfunction lineOf(text: string, index: number): number {\n return text.slice(0, index).split('\\n').length;\n}\n\nfunction maskCommentsAndStrings(text: string): string {\n let out = '';\n let mode: 'code' | 'line' | 'block' | 'single' | 'double' | 'template' =\n 'code';\n for (let i = 0; i < text.length; i += 1) {\n const c = text[i] ?? '';\n const n = text[i + 1] ?? '';\n if (mode === 'code' && c === '/' && n === '/') {\n mode = 'line';\n out += ' ';\n i += 1;\n continue;\n }\n if (mode === 'code' && c === '/' && n === '*') {\n mode = 'block';\n out += ' ';\n i += 1;\n continue;\n }\n if (mode === 'line' && c === '\\n') mode = 'code';\n if (mode === 'block' && c === '*' && n === '/') {\n mode = 'code';\n out += ' ';\n i += 1;\n continue;\n }\n if (mode === 'code' && (c === \"'\" || c === '\"' || c === '`')) {\n mode = c === \"'\" ? 'single' : c === '\"' ? 'double' : 'template';\n out += ' ';\n continue;\n }\n if ((mode === 'single' && c === \"'\") || (mode === 'double' && c === '\"') || (mode === 'template' && c === '`'))\n mode = 'code';\n out += mode === 'code' || c === '\\n' ? c : ' ';\n }\n return out;\n}\n\nfunction readAnnotation(text: string, index: number): { end: number; raw: string } | undefined {\n if (text[index] !== '@') return undefined;\n let i = index + 1;\n while (/\\s/.test(text[i] ?? '')) i += 1;\n if (text[i] !== '(') return undefined;\n let depth = 0;\n for (; i < text.length; i += 1) {\n if (text[i] === '(') depth += 1;\n if (text[i] === ')') depth -= 1;\n if (depth === 0) return { end: i + 1, raw: text.slice(index, i + 1) };\n }\n return undefined;\n}\n\nfunction collectAnnotations(text: string, index: number): { end: number; raw: string } {\n let i = index;\n let raw = '';\n while (i < text.length) {\n while (/\\s/.test(text[i] ?? '')) i += 1;\n const annotation = readAnnotation(text, i);\n if (!annotation) break;\n raw += annotation.raw;\n i = annotation.end;\n }\n return { end: i, raw };\n}\n\nfunction pathAnnotation(raw: string): string | undefined {\n return /path\\s*:\\s*['\"]([^'\"]+)['\"]/s.exec(raw)?.[1];\n}\n\nfunction matchingBrace(text: string, open: number): number {\n let depth = 0;\n for (let i = open; i < text.length; i += 1) {\n if (text[i] === '{') depth += 1;\n if (text[i] === '}') depth -= 1;\n if (depth === 0) return i;\n }\n return text.length - 1;\n}\n\nfunction operationsFromBody(text: string, maskedBody: string, bodyOffset: number, filePath: string): CdsOperationFact[] {\n return [...maskedBody.matchAll(/\\b(action|function|event)\\s+(\\w+)\\s*(?:\\(([^)]*)\\))?\\s*(?:returns\\s+([^;{]+))?/g)].map((m) => ({\n operationType: (m[1] as 'action' | 'function' | 'event') ?? 'action',\n operationName: m[2] ?? 'unknown',\n operationPath: ensureLeadingSlash(m[2] ?? 'unknown'),\n paramsJson: JSON.stringify((m[3] ?? '').split(',').map((part) => part.trim()).filter(Boolean)),\n returnType: m[4]?.trim(),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, bodyOffset + (m.index ?? 0))\n }));\n}\n\nexport async function parseCdsFile(repoPath: string, filePath: string): Promise<CdsServiceFact[]> {\n const absolute = path.join(repoPath, filePath);\n const text = await fs.readFile(absolute, 'utf8');\n const masked = maskCommentsAndStrings(text);\n const namespace = /namespace\\s+([\\w.]+)\\s*;/.exec(masked)?.[1];\n const services: CdsServiceFact[] = [];\n const pendingAnnotations: Array<{ end: number; raw: string }> = [];\n for (const a of masked.matchAll(/@\\s*\\(/g)) {\n const annotation = collectAnnotations(masked, a.index ?? 0);\n pendingAnnotations.push(annotation);\n }\n const serviceRegex = /\\b(extend\\s+)?service\\s+([\\w.]+)\\b/g;\n let match: RegExpExecArray | null;\n while ((match = serviceRegex.exec(masked))) {\n const afterName = collectAnnotations(masked, serviceRegex.lastIndex);\n const open = masked.indexOf('{', afterName.end);\n if (open === -1) continue;\n const matchIndex = match.index;\n const prefix = pendingAnnotations\n .filter((a) => a.end <= matchIndex && matchIndex - a.end < 8)\n .map((a) => a.raw)\n .join('');\n const annotations = `${prefix}${afterName.raw}`;\n const end = matchingBrace(masked, open);\n const body = masked.slice(open + 1, end);\n const name = match[2] ?? 'UnknownService';\n const serviceName = name.split('.').pop() ?? name;\n const servicePath = ensureLeadingSlash(pathAnnotation(annotations) ?? serviceName);\n services.push({\n namespace,\n serviceName,\n qualifiedName: name.includes('.') ? name : namespace ? `${namespace}.${name}` : name,\n servicePath,\n isExtend: Boolean(match[1]),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, match.index),\n operations: operationsFromBody(text, body, open + 1, filePath)\n });\n serviceRegex.lastIndex = end + 1;\n }\n const baseOps = new Map(services.filter((s) => !s.isExtend).map((s) => [s.qualifiedName, s.operations]));\n for (const service of services.filter((s) => s.isExtend && s.operations.length === 0)) {\n const inherited = baseOps.get(service.qualifiedName) ?? baseOps.get(service.serviceName);\n if (inherited) service.operations = inherited.map((op) => ({ ...op, sourceFile: service.sourceFile, sourceLine: service.sourceLine }));\n }\n return services;\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport ts from 'typescript';\nimport type { HandlerClassFact } from '../types.js';\nimport { createSourceFile } from './ts-project.js';\nimport { normalizePath, stripQuotes } from '../utils/path-utils.js';\nfunction line(sf: ts.SourceFile, pos: number): number {\n return sf.getLineAndCharacterOfPosition(pos).line + 1;\n}\nfunction decs(node: ts.Node): ts.Decorator[] {\n return ts.canHaveDecorators(node) ? [...(ts.getDecorators(node) ?? [])] : [];\n}\nfunction callName(d: ts.Decorator): string {\n const e = d.expression;\n return ts.isCallExpression(e) ? e.expression.getText() : e.getText();\n}\nfunction firstArg(d: ts.Decorator): string {\n const e = d.expression;\n return ts.isCallExpression(e) && e.arguments[0]\n ? e.arguments[0].getText()\n : '';\n}\nexport async function parseDecorators(\n repoPath: string,\n filePath: string\n): Promise<HandlerClassFact[]> {\n const text = await fs.readFile(path.join(repoPath, filePath), 'utf8');\n const sf = createSourceFile(filePath, text);\n const constants = new Map<string, string>();\n const handlers: HandlerClassFact[] = [];\n function visit(node: ts.Node): void {\n if (\n ts.isVariableDeclaration(node) &&\n ts.isIdentifier(node.name) &&\n node.initializer &&\n ts.isStringLiteralLike(node.initializer)\n )\n constants.set(node.name.text, node.initializer.text);\n if (ts.isClassDeclaration(node)) {\n const className = node.name?.text ?? 'AnonymousHandler';\n const hasHandler = decs(node).some((d) => callName(d) === 'Handler');\n const methods = node.members.filter(ts.isMethodDeclaration).flatMap((m) =>\n decs(m)\n .filter((d) =>\n ['Func', 'Action', 'On', 'Event'].includes(callName(d))\n )\n .map((d) => {\n const raw = firstArg(d);\n const value =\n raw.startsWith('\"') || raw.startsWith(\"'\") || raw.startsWith('`')\n ? stripQuotes(raw)\n : (constants.get(raw) ??\n (raw.endsWith('.name') ? raw.split('.').at(-2) : undefined));\n return {\n methodName: m.name.getText(),\n decoratorKind: callName(d),\n decoratorValue: value,\n decoratorRawExpression: raw,\n sourceFile: normalizePath(filePath),\n sourceLine: line(sf, m.getStart())\n };\n })\n );\n if (hasHandler || methods.length > 0)\n handlers.push({\n className,\n sourceFile: normalizePath(filePath),\n sourceLine: line(sf, node.getStart()),\n methods\n });\n }\n ts.forEachChild(node, visit);\n }\n visit(sf);\n return handlers;\n}\n","import ts from 'typescript';\nexport function createSourceFile(\n filePath: string,\n text: string\n): ts.SourceFile {\n return ts.createSourceFile(\n filePath,\n text,\n ts.ScriptTarget.Latest,\n true,\n filePath.endsWith('.js') ? ts.ScriptKind.JS : ts.ScriptKind.TS\n );\n}\n","import fsSync from 'node:fs';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport ts from 'typescript';\nimport type { HandlerRegistrationFact } from '../types.js';\nimport { normalizePath } from '../utils/path-utils.js';\n\ninterface ImportEvidence { importedName: string; source: string }\ninterface ClassEvidence { className: string; importSource?: string }\ninterface FileExports { arrays: Map<string, ClassEvidence[]>; defaultArray?: ClassEvidence[]; aliases: Map<string, string> }\n\nconst MAX_EXPORT_DEPTH = 5;\n\nfunction lineOf(sourceFile: ts.SourceFile, node: ts.Node): number {\n return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;\n}\nfunction isRelative(source: string): boolean {\n return source.startsWith('./') || source.startsWith('../');\n}\nfunction sourceText(node: ts.PropertyName, sourceFile: ts.SourceFile): string | undefined {\n if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node)) return node.text;\n return node.getText(sourceFile);\n}\nfunction importSourceFor(identifier: string, imports: Map<string, ImportEvidence>): string | undefined {\n const evidence = imports.get(identifier);\n return evidence ? `${evidence.source}#${evidence.importedName}` : undefined;\n}\n\nexport async function parseHandlerRegistrations(repoPath: string, filePath: string): Promise<HandlerRegistrationFact[]> {\n const absolutePath = path.join(repoPath, filePath);\n const text = await fs.readFile(absolutePath, 'utf8');\n const sourceFile = ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);\n const imports = collectImports(sourceFile);\n const localArrays = collectLocalArrays(sourceFile, imports, new Map(), repoPath, filePath);\n const out: HandlerRegistrationFact[] = [];\n\n function emitFromExpression(expression: ts.Expression, call: ts.CallExpression): void {\n const classes = resolveArrayExpression(expression, localArrays, imports, repoPath, filePath, new Set());\n for (const cls of classes) {\n out.push({\n className: cls.className,\n importSource: cls.importSource,\n registrationFile: normalizePath(filePath),\n registrationLine: lineOf(sourceFile, call),\n registrationKind: 'combined-handler-class',\n confidence: 0.95,\n });\n }\n if (classes.length === 0) {\n out.push({\n registrationFile: normalizePath(filePath),\n registrationLine: lineOf(sourceFile, call),\n registrationKind: 'combined-handler',\n confidence: 0.75,\n });\n }\n }\n\n function visit(node: ts.Node): void {\n if (ts.isCallExpression(node) && isRegistrationCall(node)) {\n const handlerExpr = handlerExpression(node, sourceFile);\n if (handlerExpr) emitFromExpression(handlerExpr, node);\n else out.push({ registrationFile: normalizePath(filePath), registrationLine: lineOf(sourceFile, node), registrationKind: 'combined-handler', confidence: 0.75 });\n }\n ts.forEachChild(node, visit);\n }\n visit(sourceFile);\n return out;\n}\n\nfunction isRegistrationCall(call: ts.CallExpression): boolean {\n const text = call.expression.getText();\n return text.endsWith('createCombinedHandler') || text.endsWith('srv.prepend') || text.endsWith('cds.serve');\n}\nfunction handlerExpression(call: ts.CallExpression, sourceFile: ts.SourceFile): ts.Expression | undefined {\n for (const arg of call.arguments) {\n if (!ts.isObjectLiteralExpression(arg)) continue;\n for (const prop of arg.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n if (sourceText(prop.name, sourceFile) === 'handler') return prop.initializer;\n }\n }\n return undefined;\n}\nfunction collectImports(sourceFile: ts.SourceFile): Map<string, ImportEvidence> {\n const imports = new Map<string, ImportEvidence>();\n for (const statement of sourceFile.statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;\n const source = statement.moduleSpecifier.text;\n const clause = statement.importClause;\n if (!clause) continue;\n if (clause.name) imports.set(clause.name.text, { importedName: 'default', source });\n const named = clause.namedBindings;\n if (named && ts.isNamedImports(named)) {\n for (const element of named.elements) imports.set(element.name.text, { importedName: element.propertyName?.text ?? element.name.text, source });\n }\n if (named && ts.isNamespaceImport(named)) imports.set(named.name.text, { importedName: '*', source });\n }\n return imports;\n}\nfunction collectLocalArrays(sourceFile: ts.SourceFile, imports: Map<string, ImportEvidence>, seed: Map<string, ClassEvidence[]>, repoPath = '', fromFile = ''): Map<string, ClassEvidence[]> {\n const arrays = new Map(seed);\n for (const statement of sourceFile.statements) {\n if (ts.isVariableStatement(statement)) {\n for (const decl of statement.declarationList.declarations) {\n if (ts.isIdentifier(decl.name) && decl.initializer && ts.isArrayLiteralExpression(decl.initializer)) {\n arrays.set(decl.name.text, resolveArrayLiteral(decl.initializer, arrays, imports, repoPath, fromFile, new Set()));\n }\n }\n }\n }\n return arrays;\n}\nfunction resolveArrayExpression(expr: ts.Expression, arrays: Map<string, ClassEvidence[]>, imports: Map<string, ImportEvidence>, repoPath: string, fromFile: string, seen: Set<string>): ClassEvidence[] {\n if (ts.isArrayLiteralExpression(expr)) return resolveArrayLiteral(expr, arrays, imports, repoPath, fromFile, seen);\n if (ts.isIdentifier(expr)) {\n const local = arrays.get(expr.text);\n if (local) return local;\n const evidence = imports.get(expr.text);\n if (evidence && isRelative(evidence.source)) return resolveImportedArray(repoPath, fromFile, evidence, seen);\n if (evidence) return [{ className: evidence.importedName === 'default' ? expr.text : evidence.importedName, importSource: `${evidence.source}#${evidence.importedName}` }];\n }\n return [];\n}\nfunction resolveArrayLiteral(array: ts.ArrayLiteralExpression, arrays: Map<string, ClassEvidence[]>, imports: Map<string, ImportEvidence>, repoPath: string, fromFile: string, seen: Set<string>): ClassEvidence[] {\n const out: ClassEvidence[] = [];\n for (const element of array.elements) {\n if (ts.isSpreadElement(element)) out.push(...resolveArrayExpression(element.expression, arrays, imports, repoPath, fromFile, seen));\n else if (ts.isIdentifier(element)) out.push({ className: element.text, importSource: importSourceFor(element.text, imports) });\n }\n return out;\n}\nfunction resolveImportedArray(repoPath: string, fromFile: string, evidence: ImportEvidence, seen: Set<string>): ClassEvidence[] {\n const moduleFile = resolveRelativeModule(repoPath, fromFile, evidence.source);\n if (!moduleFile) return [];\n const key = `${moduleFile}:${evidence.importedName}`;\n if (seen.has(key) || seen.size > MAX_EXPORT_DEPTH) return [];\n seen.add(key);\n const exports = readExports(repoPath, moduleFile, seen);\n if (evidence.importedName === 'default') return exports.defaultArray ?? [];\n return exports.arrays.get(evidence.importedName) ?? exports.arrays.get(exports.aliases.get(evidence.importedName) ?? evidence.importedName) ?? [];\n}\nfunction resolveRelativeModule(repoPath: string, fromFile: string, specifier: string): string | undefined {\n const base = path.resolve(repoPath, path.dirname(fromFile), specifier);\n for (const candidate of [base, `${base}.ts`, `${base}.js`, path.join(base, 'index.ts'), path.join(base, 'index.js')]) {\n try {\n const stat = fsSync.statSync(candidate);\n if (stat.isFile()) return normalizePath(path.relative(repoPath, candidate));\n } catch { /* ignore missing candidate */ }\n }\n return undefined;\n}\nfunction readExports(repoPath: string, filePath: string, seen: Set<string>): FileExports {\n const absolute = path.join(repoPath, filePath);\n let text: string;\n try { text = fsSync.readFileSync(absolute, 'utf8'); } catch { return { arrays: new Map(), aliases: new Map() }; }\n const sourceFile = ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);\n const imports = collectImports(sourceFile);\n const arrays = collectLocalArrays(sourceFile, imports, new Map(), repoPath, filePath);\n const aliases = new Map<string, string>();\n let defaultArray: ClassEvidence[] | undefined;\n for (const statement of sourceFile.statements) {\n if (ts.isExportAssignment(statement) && ts.isIdentifier(statement.expression)) defaultArray = arrays.get(statement.expression.text);\n if (ts.isExportDeclaration(statement) && statement.exportClause && ts.isNamedExports(statement.exportClause)) {\n const module = statement.moduleSpecifier && ts.isStringLiteral(statement.moduleSpecifier) ? statement.moduleSpecifier.text : undefined;\n for (const element of statement.exportClause.elements) {\n const local = element.propertyName?.text ?? element.name.text;\n aliases.set(element.name.text, local);\n if (module && isRelative(module)) {\n const imported = resolveImportedArray(repoPath, filePath, { source: module, importedName: local }, seen);\n if (imported.length > 0) arrays.set(element.name.text, imported);\n }\n }\n }\n }\n return { arrays, defaultArray, aliases };\n}\n","const SENSITIVE = /authorization|cookie|token|secret|password|key|credential/i;\nexport function redactText(text: string): string {\n return text.replace(\n /(authorization|cookie|token|secret|password|key|credential)\\s*[:=]\\s*(['\"`]?)[^,'\"`}\\s]+\\2/gi,\n '$1: [REDACTED]'\n );\n}\nexport function redactValue(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(redactValue);\n if (value && typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value))\n out[k] = SENSITIVE.test(k) ? '[REDACTED]' : redactValue(v);\n return out;\n }\n return typeof value === 'string' ? redactText(value) : value;\n}\nexport function summarizeExpression(text: string): string {\n return redactText(text).slice(0, 240);\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport ts from 'typescript';\nimport type { OutboundCallFact } from '../types.js';\nimport { normalizePath, stripQuotes } from '../utils/path-utils.js';\nimport { summarizeExpression } from '../utils/redaction.js';\nfunction lineOf(text: string, idx: number): number {\n return text.slice(0, idx).split('\\n').length;\n}\nfunction firstArg(body: string, key: string): string | undefined {\n return new RegExp(`${key}\\\\s*:\\\\s*([^,}\\\\n]+)`).exec(body)?.[1]?.trim();\n}\nfunction matchingParen(text: string, open: number): number {\n let depth = 0;\n let quote: string | undefined;\n let escaped = false;\n for (let i = open; i < text.length; i += 1) {\n const ch = text[i] ?? '';\n if (quote) {\n if (escaped) escaped = false;\n else if (ch === '\\\\') escaped = true;\n else if (ch === quote) quote = undefined;\n continue;\n }\n if (ch === '\"' || ch === \"'\" || ch === '`') {\n quote = ch;\n continue;\n }\n if (ch === '(') depth += 1;\n if (ch === ')') {\n depth -= 1;\n if (depth === 0) return i;\n }\n }\n return -1;\n}\nfunction entityFromExpression(expr: ts.Expression | undefined): string | undefined {\n if (!expr) return undefined;\n if (ts.isIdentifier(expr) || ts.isStringLiteral(expr) || ts.isNoSubstitutionTemplateLiteral(expr)) return expr.text;\n if (ts.isPropertyAccessExpression(expr) && expr.expression.kind === ts.SyntaxKind.ThisKeyword) return expr.name.text;\n if (ts.isElementAccessExpression(expr) && expr.argumentExpression && (ts.isStringLiteral(expr.argumentExpression) || ts.isNoSubstitutionTemplateLiteral(expr.argumentExpression))) return expr.argumentExpression.text;\n return undefined;\n}\nfunction expressionName(expr: ts.Expression): string {\n if (ts.isIdentifier(expr)) return expr.text;\n if (ts.isPropertyAccessExpression(expr)) return `${expressionName(expr.expression)}.${expr.name.text}`;\n return expr.getText();\n}\nfunction variableInitializers(source: ts.SourceFile): Map<string, ts.Expression> {\n const initializers = new Map<string, ts.Expression>();\n const visit = (node: ts.Node): void => {\n if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer && (node.parent.flags & ts.NodeFlags.Const) !== 0) initializers.set(node.name.text, node.initializer);\n ts.forEachChild(node, visit);\n };\n visit(source);\n return initializers;\n}\nfunction queryEntityFromAst(expr: ts.Expression, initializers = new Map<string, ts.Expression>()): string | undefined {\n if (ts.isParenthesizedExpression(expr) || ts.isAwaitExpression(expr)) return queryEntityFromAst(expr.expression, initializers);\n if (ts.isIdentifier(expr) && initializers.has(expr.text)) return queryEntityFromAst(initializers.get(expr.text) as ts.Expression, initializers);\n if (ts.isCallExpression(expr)) {\n const name = expressionName(expr.expression);\n if (name === 'cds.run') return queryEntityFromAst(expr.arguments[0], initializers);\n if (['SELECT.one.from', 'SELECT.from', 'SELECT.one', 'INSERT.into', 'UPSERT.into', 'DELETE.from', 'UPDATE.entity'].includes(name)) return entityFromExpression(expr.arguments[0]);\n if (name === 'UPDATE') return entityFromExpression(expr.arguments[0]);\n const receiver = ts.isPropertyAccessExpression(expr.expression) ? expr.expression.expression : undefined;\n if (receiver) return queryEntityFromAst(receiver, initializers);\n }\n return undefined;\n}\nfunction extractQueryEntity(expr: string): string | undefined {\n const source = ts.createSourceFile('query.ts', `const __query = (${expr});`, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);\n const initializers = variableInitializers(source);\n let found: string | undefined;\n const visit = (node: ts.Node): void => {\n if (found) return;\n if (ts.isParenthesizedExpression(node)) found = queryEntityFromAst(node.expression, initializers);\n ts.forEachChild(node, visit);\n };\n visit(source);\n return found;\n}\nfunction queryWarning(expr: string): string {\n if (/^\\s*[`'\"]/.test(expr)) return 'raw_sql_or_cql_expression';\n if (/^\\s*\\w+\\s*$/.test(expr)) return 'query_variable_without_static_initializer';\n return 'dynamic_entity_expression';\n}\nexport async function parseOutboundCalls(\n repoPath: string,\n filePath: string,\n): Promise<OutboundCallFact[]> {\n const text = await fs.readFile(path.join(repoPath, filePath), 'utf8');\n const out: OutboundCallFact[] = [];\n for (const m of text.matchAll(/(\\w+)\\.send\\s*\\(\\s*\\{([\\s\\S]*?)\\}\\s*\\)/g)) {\n const body = m[2] ?? '';\n const query = firstArg(body, 'query');\n const op = firstArg(body, 'path') ?? firstArg(body, 'event');\n out.push({\n callType: query ? 'remote_query' : 'remote_action',\n serviceVariableName: m[1],\n method: stripQuotes(firstArg(body, 'method') ?? 'POST'),\n operationPathExpr: op\n ? `/${stripQuotes(op).replace(/^\\//, '')}`\n : undefined,\n queryEntity: extractQueryEntity(query ?? ''),\n payloadSummary: summarizeExpression(body),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0),\n confidence: op || query ? 0.8 : 0.4,\n });\n }\n for (const m of text.matchAll(/cds\\.run\\s*\\(/g)) {\n const open = (m.index ?? 0) + m[0].lastIndexOf('(');\n const close = matchingParen(text, open);\n const expr = close > open ? text.slice(open + 1, close) : '';\n const entity = extractQueryEntity(expr);\n out.push({\n callType: 'local_db_query',\n queryEntity: entity,\n payloadSummary: summarizeExpression(expr),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0),\n confidence: entity ? 0.9 : 0.55,\n unresolvedReason: entity ? undefined : queryWarning(expr),\n });\n }\n for (const m of text.matchAll(\n /(\\w+)\\.(emit|publish|on)\\s*\\(\\s*(['\"`])([^'\"`]+)\\3/g,\n ))\n out.push({\n callType: m[2] === 'on' ? 'async_subscribe' : 'async_emit',\n serviceVariableName: m[1],\n eventNameExpr: m[4],\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0),\n confidence: 0.8,\n });\n for (const m of text.matchAll(\n /(?:axios\\s*\\(|executeHttpRequest\\s*\\(|useOrFetchDestination\\s*\\()([\\s\\S]*?)\\)/g,\n ))\n out.push({\n callType: 'external_http',\n payloadSummary: summarizeExpression(m[1] ?? ''),\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, m.index ?? 0),\n confidence: 0.7,\n unresolvedReason:\n 'External HTTP destination is outside indexed CAP services',\n });\n out.push(...parseLocalServiceCalls(text, filePath));\n return out;\n}\nfunction parseLocalServiceCalls(text: string, filePath: string): OutboundCallFact[] {\n const source = ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true, filePath.endsWith('.ts') ? ts.ScriptKind.TS : ts.ScriptKind.JS);\n const aliases = new Map<string, { service: string; lookup: string; chain: string[] }>();\n const calls: OutboundCallFact[] = [];\n const visit = (node: ts.Node): void => {\n if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {\n const origin = serviceLookup(node.initializer, aliases);\n if (origin) aliases.set(node.name.text, { ...origin, chain: [...origin.chain, node.name.text] });\n }\n if (ts.isCallExpression(node)) {\n const parsed = serviceOperationCall(node.expression, aliases);\n if (parsed && parsed.operation !== 'entities') calls.push({\n callType: 'local_service_call',\n operationPathExpr: `/${parsed.operation}`,\n payloadSummary: parsed.service,\n localServiceName: parsed.service,\n localServiceLookup: parsed.lookup,\n aliasChain: parsed.chain,\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(text, node.getStart(source)),\n confidence: 0.9,\n unresolvedReason: ['send', 'emit', 'publish', 'on'].includes(parsed.operation) ? 'transport_client_method' : undefined,\n });\n }\n ts.forEachChild(node, visit);\n };\n visit(source);\n return calls;\n}\nfunction serviceLookup(expr: ts.Expression, aliases: Map<string, { service: string; lookup: string; chain: string[] }>): { service: string; lookup: string; chain: string[] } | undefined {\n if (ts.isIdentifier(expr)) return aliases.get(expr.text);\n if (ts.isPropertyAccessExpression(expr) && expr.expression.getText() === 'cds.services') return { service: expr.name.text, lookup: expr.getText(), chain: [expr.getText()] };\n if (ts.isElementAccessExpression(expr) && expr.expression.getText() === 'cds.services' && ts.isStringLiteral(expr.argumentExpression)) return { service: expr.argumentExpression.text, lookup: expr.getText(), chain: [expr.getText()] };\n return undefined;\n}\nfunction serviceOperationCall(expr: ts.Expression, aliases: Map<string, { service: string; lookup: string; chain: string[] }>): { service: string; lookup: string; chain: string[]; operation: string } | undefined {\n if (!ts.isPropertyAccessExpression(expr)) return undefined;\n const operation = expr.name.text;\n const origin = serviceLookup(expr.expression, aliases);\n if (!origin) return undefined;\n return { ...origin, operation };\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport ts from 'typescript';\nimport type { ServiceBindingFact } from '../types.js';\nimport { normalizePath } from '../utils/path-utils.js';\n\ninterface HelperBinding {\n exportedName: string;\n alias?: string;\n aliasExpr?: string;\n destinationExpr?: string;\n servicePathExpr?: string;\n isDynamic: boolean;\n placeholders: string[];\n sourceFile: string;\n sourceLine: number;\n}\ninterface ImportBinding {\n localName: string;\n exportedName: string;\n sourceFile?: string;\n}\ninterface ClassHelperReturn {\n className: string;\n helperName: string;\n propertyName: string;\n variableName: string;\n fact: Omit<HelperBinding, 'exportedName' | 'sourceFile' | 'sourceLine'>;\n sourceLine: number;\n}\n\nfunction lineOf(sf: ts.SourceFile, node: ts.Node): number {\n return sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;\n}\nfunction stringValue(node: ts.Expression | undefined): string | undefined {\n if (!node) return undefined;\n if (ts.isStringLiteralLike(node) || ts.isNoSubstitutionTemplateLiteral(node))\n return node.text;\n if (ts.isTemplateExpression(node))\n return node.getText().replace(/^`|`$/g, '');\n return node.getText();\n}\nfunction placeholders(value?: string): string[] {\n return [...(value ?? '').matchAll(/\\$\\{\\s*(\\w+)\\s*\\}/g)]\n .map((m) => m[1] ?? '')\n .filter(Boolean);\n}\nfunction connectFactFromCall(\n call: ts.CallExpression,\n):\n | Omit<HelperBinding, 'exportedName' | 'sourceFile' | 'sourceLine'>\n | undefined {\n const expr = call.expression;\n if (!ts.isPropertyAccessExpression(expr) || expr.name.text !== 'to')\n return undefined;\n const inner = expr.expression;\n if (\n !ts.isPropertyAccessExpression(inner) ||\n inner.name.text !== 'connect' ||\n inner.expression.getText() !== 'cds'\n )\n return undefined;\n const first = call.arguments[0];\n if (!first) return undefined;\n const second = call.arguments[1];\n const objectArg = ts.isObjectLiteralExpression(first)\n ? first\n : second && ts.isObjectLiteralExpression(second)\n ? second\n : undefined;\n let alias: string | undefined;\n let aliasExpr: string | undefined;\n if (ts.isStringLiteralLike(first) || ts.isNoSubstitutionTemplateLiteral(first))\n alias = first.text;\n else if (!ts.isObjectLiteralExpression(first))\n aliasExpr = stringValue(first);\n if (\n (ts.isStringLiteralLike(first) || ts.isNoSubstitutionTemplateLiteral(first)) &&\n !objectArg\n )\n return { alias: first.text, isDynamic: false, placeholders: [] };\n if (!objectArg && aliasExpr)\n return {\n aliasExpr,\n isDynamic: true,\n placeholders: placeholders(aliasExpr),\n };\n let destinationExpr: string | undefined;\n let servicePathExpr: string | undefined;\n function visitObject(obj: ts.ObjectLiteralExpression): void {\n for (const prop of obj.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const name =\n ts.isIdentifier(prop.name) || ts.isStringLiteralLike(prop.name)\n ? prop.name.text\n : undefined;\n if (name === 'destination')\n destinationExpr = stringValue(prop.initializer);\n if (name === 'path' || name === 'servicePath')\n servicePathExpr = stringValue(prop.initializer);\n if (ts.isObjectLiteralExpression(prop.initializer))\n visitObject(prop.initializer);\n }\n }\n if (objectArg) visitObject(objectArg);\n const ph = [\n ...placeholders(aliasExpr ?? alias),\n ...placeholders(destinationExpr),\n ...placeholders(servicePathExpr),\n ];\n return {\n alias,\n aliasExpr,\n destinationExpr,\n servicePathExpr,\n isDynamic: ph.length > 0 || (!destinationExpr && !servicePathExpr),\n placeholders: ph,\n };\n}\nfunction unwrapCall(expr: ts.Expression): ts.CallExpression | undefined {\n if (ts.isAwaitExpression(expr)) return unwrapCall(expr.expression);\n if (ts.isCallExpression(expr)) return expr;\n return undefined;\n}\nfunction findConnectInExpression(\n expr: ts.Expression,\n):\n | Omit<HelperBinding, 'exportedName' | 'sourceFile' | 'sourceLine'>\n | undefined {\n const direct = unwrapCall(expr);\n if (direct) {\n const fact = connectFactFromCall(direct);\n if (fact) return fact;\n }\n let found:\n | Omit<HelperBinding, 'exportedName' | 'sourceFile' | 'sourceLine'>\n | undefined;\n function visit(node: ts.Node): void {\n if (found) return;\n if (ts.isCallExpression(node)) found = connectFactFromCall(node);\n if (!found) ts.forEachChild(node, visit);\n }\n visit(expr);\n return found;\n}\nasync function readSource(abs: string): Promise<ts.SourceFile | undefined> {\n try {\n const text = await fs.readFile(abs, 'utf8');\n return ts.createSourceFile(\n abs,\n text,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n } catch {\n return undefined;\n }\n}\nasync function resolveImport(\n repoPath: string,\n fromFile: string,\n spec: string,\n): Promise<string | undefined> {\n if (!spec.startsWith('.')) return undefined;\n const rawBase = path.resolve(repoPath, path.dirname(fromFile), spec);\n const parsed = path.parse(rawBase);\n const base = ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'].includes(parsed.ext)\n ? path.join(parsed.dir, parsed.name)\n : rawBase;\n for (const candidate of [\n base,\n `${base}.ts`,\n `${base}.js`,\n path.join(base, 'index.ts'),\n path.join(base, 'index.js'),\n ]) {\n try {\n const st = await fs.stat(candidate);\n if (st.isFile()) return normalizePath(path.relative(repoPath, candidate));\n } catch {\n /* continue */\n }\n }\n return undefined;\n}\nasync function importsFor(\n repoPath: string,\n filePath: string,\n sf: ts.SourceFile,\n): Promise<ImportBinding[]> {\n const imports: ImportBinding[] = [];\n for (const stmt of sf.statements) {\n if (\n !ts.isImportDeclaration(stmt) ||\n !ts.isStringLiteralLike(stmt.moduleSpecifier)\n )\n continue;\n const sourceFile = await resolveImport(\n repoPath,\n filePath,\n stmt.moduleSpecifier.text,\n );\n const clause = stmt.importClause;\n if (!clause) continue;\n if (clause.name)\n imports.push({\n localName: clause.name.text,\n exportedName: 'default',\n sourceFile,\n });\n const bindings = clause.namedBindings;\n if (bindings && ts.isNamedImports(bindings))\n for (const el of bindings.elements)\n imports.push({\n localName: el.name.text,\n exportedName: el.propertyName?.text ?? el.name.text,\n sourceFile,\n });\n }\n return imports;\n}\nfunction exportedLocalNames(sf: ts.SourceFile): Map<string, string> {\n const exports = new Map<string, string>();\n for (const stmt of sf.statements) {\n const direct = ts.canHaveModifiers(stmt)\n ? (ts\n .getModifiers(stmt)\n ?.some(\n (m: ts.ModifierLike) => m.kind === ts.SyntaxKind.ExportKeyword,\n ) ?? false)\n : false;\n if (direct && ts.isFunctionDeclaration(stmt) && stmt.name)\n exports.set(stmt.name.text, stmt.name.text);\n if (direct && ts.isVariableStatement(stmt))\n for (const decl of stmt.declarationList.declarations)\n if (ts.isIdentifier(decl.name)) exports.set(decl.name.text, decl.name.text);\n if (!ts.isExportDeclaration(stmt) || !stmt.exportClause) continue;\n if (!ts.isNamedExports(stmt.exportClause)) continue;\n for (const el of stmt.exportClause.elements)\n exports.set(el.name.text, el.propertyName?.text ?? el.name.text);\n }\n return exports;\n}\nasync function helperBindings(\n repoPath: string,\n filePath: string,\n): Promise<HelperBinding[]> {\n const sf = await readSource(path.join(repoPath, filePath));\n if (!sf) return [];\n const sourceFileAst = sf;\n const out: HelperBinding[] = [];\n const exportedLocals = exportedLocalNames(sf);\n const factsByLocal = new Map<\n string,\n Omit<HelperBinding, 'exportedName' | 'sourceFile' | 'sourceLine'> & {\n sourceLine: number;\n }\n >();\n for (const stmt of sf.statements) {\n if (ts.isFunctionDeclaration(stmt) && stmt.name) {\n let fact:\n | Omit<HelperBinding, 'exportedName' | 'sourceFile' | 'sourceLine'>\n | undefined;\n stmt.forEachChild(function visit(node): void {\n if (!fact && ts.isReturnStatement(node) && node.expression)\n fact = findConnectInExpression(node.expression);\n if (!fact) ts.forEachChild(node, visit);\n });\n if (fact) factsByLocal.set(stmt.name.text, { ...fact, sourceLine: lineOf(sf, stmt) });\n }\n if (ts.isVariableStatement(stmt))\n for (const decl of stmt.declarationList.declarations) {\n if (!ts.isIdentifier(decl.name) || !decl.initializer) continue;\n const fact = findConnectInExpression(decl.initializer);\n if (fact)\n factsByLocal.set(decl.name.text, {\n ...fact,\n sourceLine: lineOf(sourceFileAst, decl),\n });\n }\n }\n for (const [exportedName, localName] of exportedLocals) {\n const fact = factsByLocal.get(localName);\n if (fact)\n out.push({\n ...fact,\n exportedName,\n sourceFile: normalizePath(filePath),\n sourceLine: fact.sourceLine,\n });\n }\n return out;\n}\n\nexport async function parseServiceBindings(\n repoPath: string,\n filePath: string,\n): Promise<ServiceBindingFact[]> {\n const sf = await readSource(path.join(repoPath, filePath));\n if (!sf) return [];\n const sourceFileAst = sf;\n const out: ServiceBindingFact[] = [];\n const imports = await importsFor(repoPath, filePath, sf);\n const helperCache = new Map<string, HelperBinding[]>();\n const classHelpers = collectClassHelpers(sourceFileAst);\n async function importedHelper(\n localName: string,\n ): Promise<{ imp: ImportBinding; helper: HelperBinding } | undefined> {\n const imp = imports.find((i) => i.localName === localName && i.sourceFile);\n if (!imp?.sourceFile) return undefined;\n if (!helperCache.has(imp.sourceFile))\n helperCache.set(\n imp.sourceFile,\n await helperBindings(repoPath, imp.sourceFile),\n );\n const helper = helperCache\n .get(imp.sourceFile)\n ?.find((h) => h.exportedName === imp.exportedName);\n return helper ? { imp, helper } : undefined;\n }\n async function recordVariable(decl: ts.VariableDeclaration): Promise<void> {\n if (!ts.isIdentifier(decl.name) || !decl.initializer) return;\n const call = unwrapCall(decl.initializer);\n if (!call) return;\n const direct = connectFactFromCall(call);\n if (direct)\n out.push({\n variableName: decl.name.text,\n ...direct,\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(sourceFileAst, decl),\n });\n else if (ts.isIdentifier(call.expression)) {\n const resolved = await importedHelper(call.expression.text);\n if (resolved)\n out.push({\n variableName: decl.name.text,\n alias: resolved.helper.alias,\n aliasExpr: resolved.helper.aliasExpr,\n destinationExpr: resolved.helper.destinationExpr,\n servicePathExpr: resolved.helper.servicePathExpr,\n isDynamic: resolved.helper.isDynamic,\n placeholders: resolved.helper.placeholders,\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(sourceFileAst, decl),\n helperChain: [\n {\n callerVariable: decl.name.text,\n importedHelper: call.expression.text,\n importSource: resolved.imp.sourceFile,\n exportedSymbol: resolved.imp.exportedName,\n helperSourceFile: resolved.helper.sourceFile,\n helperSourceLine: resolved.helper.sourceLine,\n },\n ],\n });\n }\n }\n function recordDestructuredClassHelper(decl: ts.VariableDeclaration): void {\n if (!ts.isObjectBindingPattern(decl.name) || !decl.initializer) return;\n const call = unwrapCall(decl.initializer);\n if (!call || !ts.isPropertyAccessExpression(call.expression)) return;\n const target = call.expression;\n if (target.expression.kind !== ts.SyntaxKind.ThisKeyword) return;\n for (const el of decl.name.elements) {\n if (!ts.isIdentifier(el.name)) continue;\n const propertyName = el.propertyName && ts.isIdentifier(el.propertyName)\n ? el.propertyName.text\n : el.name.text;\n const helper = classHelpers.find(\n (h) => h.helperName === target.name.text && h.propertyName === propertyName,\n );\n if (!helper) continue;\n out.push({\n variableName: el.name.text,\n ...helper.fact,\n sourceFile: normalizePath(filePath),\n sourceLine: lineOf(sourceFileAst, decl),\n helperChain: [\n {\n callerVariable: el.name.text,\n className: helper.className,\n classHelper: helper.helperName,\n returnedProperty: helper.propertyName,\n helperVariable: helper.variableName,\n helperSourceFile: normalizePath(filePath),\n helperSourceLine: helper.sourceLine,\n },\n ],\n });\n }\n }\n const declarations: ts.VariableDeclaration[] = [];\n function collectDeclarations(node: ts.Node): void {\n if (ts.isVariableDeclaration(node)) declarations.push(node);\n ts.forEachChild(node, collectDeclarations);\n }\n collectDeclarations(sourceFileAst);\n for (const decl of declarations) {\n recordDestructuredClassHelper(decl);\n await recordVariable(decl);\n }\n return out;\n}\n\nfunction collectClassHelpers(sf: ts.SourceFile): ClassHelperReturn[] {\n const helpers: ClassHelperReturn[] = [];\n for (const stmt of sf.statements) {\n if (!ts.isClassDeclaration(stmt) || !stmt.name) continue;\n for (const member of stmt.members) {\n if (!ts.isPropertyDeclaration(member) || !member.initializer) continue;\n if (!ts.isIdentifier(member.name)) continue;\n const className = stmt.name.text;\n const helperName = member.name.text;\n const initializer = member.initializer;\n if (!ts.isArrowFunction(initializer) && !ts.isFunctionExpression(initializer))\n continue;\n const bindings = new Map<\n string,\n Omit<HelperBinding, 'exportedName' | 'sourceFile' | 'sourceLine'>\n >();\n function visit(node: ts.Node): void {\n if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {\n const fact = findConnectInExpression(node.initializer);\n if (fact) bindings.set(node.name.text, fact);\n }\n if (ts.isReturnStatement(node) && node.expression && ts.isObjectLiteralExpression(node.expression)) {\n for (const prop of node.expression.properties) {\n if (ts.isShorthandPropertyAssignment(prop)) {\n const fact = bindings.get(prop.name.text);\n if (fact)\n helpers.push({\n className,\n helperName,\n propertyName: prop.name.text,\n variableName: prop.name.text,\n fact,\n sourceLine: lineOf(sf, prop),\n });\n }\n if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.initializer)) {\n const propertyName =\n ts.isIdentifier(prop.name) || ts.isStringLiteralLike(prop.name)\n ? prop.name.text\n : undefined;\n const fact = propertyName ? bindings.get(prop.initializer.text) : undefined;\n if (propertyName && fact)\n helpers.push({\n className,\n helperName,\n propertyName,\n variableName: prop.initializer.text,\n fact,\n sourceLine: lineOf(sf, prop),\n });\n }\n }\n }\n ts.forEachChild(node, visit);\n }\n visit(initializer);\n }\n }\n return helpers;\n}\n","export interface RuntimeSubstitution {\n original?: string;\n effective?: string;\n placeholders: string[];\n missing: string[];\n supplied: string[];\n changed: boolean;\n}\n\nconst PLACEHOLDER = /\\$\\{\\s*(\\w+)\\s*\\}/g;\n\nexport function applyVariables(\n template: string | undefined,\n vars: Record<string, string>,\n): string | undefined {\n return substituteVariables(template, vars).effective;\n}\n\nexport function extractPlaceholders(template: string | undefined): string[] {\n return [...(template ?? '').matchAll(PLACEHOLDER)]\n .map((m) => m[1] ?? '')\n .filter(Boolean);\n}\n\nexport function substituteVariables(\n template: string | undefined,\n vars: Record<string, string>,\n): RuntimeSubstitution {\n if (!template) return { placeholders: [], missing: [], supplied: [], changed: false };\n const placeholders = [...new Set(extractPlaceholders(template))];\n const supplied = placeholders.filter((key) => Object.hasOwn(vars, key));\n const missing = placeholders.filter((key) => !Object.hasOwn(vars, key));\n const effective = template.replace(PLACEHOLDER, (_m, key: string) =>\n Object.hasOwn(vars, key) ? vars[key] ?? '' : `\\${${key}}`,\n );\n return {\n original: template,\n effective,\n placeholders,\n missing,\n supplied,\n changed: effective !== template,\n };\n}\n","import type { Db } from '../db/connection.js';\nexport interface OperationTarget {\n operationId: number;\n repoName: string;\n serviceName: string;\n qualifiedName: string;\n servicePath: string;\n operationPath: string;\n operationName: string;\n sourceFile: string;\n sourceLine: number;\n repoId?: number;\n packageName?: string | null;\n score: number;\n reasons: string[];\n}\nexport interface OperationResolution {\n status: 'resolved' | 'ambiguous' | 'unresolved' | 'dynamic';\n target?: OperationTarget;\n candidates: OperationTarget[];\n reasons: string[];\n}\nfunction rows(\n db: Db,\n operationPath: string,\n workspaceId?: number,\n): OperationTarget[] {\n return db\n .prepare(\n `SELECT o.id operationId,r.id repoId,r.name repoName,r.package_name packageName,s.service_name serviceName,s.qualified_name qualifiedName,s.service_path servicePath,o.operation_path operationPath,o.operation_name operationName,o.source_file sourceFile,o.source_line sourceLine,0 score,'' reasons\n FROM cds_operations o JOIN cds_services s ON s.id=o.service_id JOIN repositories r ON r.id=s.repo_id\n WHERE (? IS NULL OR r.workspace_id=?) AND (o.operation_path=? OR o.operation_name=?) ORDER BY r.name,s.service_path,o.operation_name`,\n )\n .all(\n workspaceId,\n workspaceId,\n operationPath,\n operationPath.replace(/^\\//, ''),\n ) as unknown as OperationTarget[];\n}\nexport function resolveOperation(\n db: Db,\n signals: {\n servicePath?: string;\n alias?: string;\n destination?: string;\n operationPath?: string;\n serviceName?: string;\n repoId?: number;\n hasExplicitOverride?: boolean;\n isDynamic?: boolean;\n localServiceLookup?: string;\n },\n workspaceId?: number,\n): OperationResolution {\n const missing = [signals.servicePath, signals.alias, signals.destination, signals.operationPath].flatMap((value) => [...(value ?? '').matchAll(/\\$\\{\\s*(\\w+)\\s*\\}/g)].map((match) => match[1] ?? '')).filter(Boolean);\n if (missing.length > 0)\n return {\n status: 'dynamic',\n candidates: signals.operationPath ? rows(db, signals.operationPath, workspaceId) : [],\n reasons: [...new Set(missing)].map((name) => `missing_variable:${name}`),\n };\n if (!signals.operationPath)\n return {\n status: 'unresolved',\n candidates: [],\n reasons: ['missing_operation_path'],\n };\n const allCandidates = rows(db, signals.operationPath, workspaceId).map((c) => ({\n ...c,\n score: 0.2,\n reasons: ['operation_path_match'],\n }));\n let candidates = allCandidates.filter((c) => matchesLocalRepo(db, c.operationId, signals.repoId));\n if (candidates.length === 0 && signals.repoId !== undefined && signals.serviceName) {\n candidates = implementationContextCandidates(db, allCandidates, signals.repoId, signals.serviceName);\n if (candidates.length === 0)\n return {\n status: 'unresolved',\n candidates: allCandidates.filter((c) => serviceMatches(c, signals.serviceName)),\n reasons: allCandidates.some((c) => serviceMatches(c, signals.serviceName)) ? ['local_service_candidate_without_caller_ownership'] : ['no_operation_candidates'],\n };\n }\n if (candidates.length === 0)\n return {\n status: 'unresolved',\n candidates: [],\n reasons: ['no_operation_candidates'],\n };\n const hasStrongSignal = Boolean(\n signals.servicePath ||\n signals.serviceName ||\n signals.alias ||\n signals.destination ||\n signals.hasExplicitOverride,\n );\n for (const c of candidates) {\n if (signals.servicePath && c.servicePath === signals.servicePath) {\n c.score += 0.75;\n c.reasons.push('exact_service_path');\n }\n if (signals.servicePath && c.servicePath !== signals.servicePath) {\n c.score -= 0.1;\n c.reasons.push('service_path_mismatch');\n }\n if (signals.serviceName) {\n const simple = signals.serviceName.split('.').at(-1) ?? signals.serviceName;\n if (c.qualifiedName === signals.serviceName) {\n c.score += 0.8;\n c.reasons.push('exact_local_qualified_service_name');\n } else if (c.serviceName === signals.serviceName || c.serviceName === simple) {\n c.score += 0.75;\n c.reasons.push('exact_local_simple_service_name');\n } else if (c.servicePath === signals.serviceName || c.servicePath === `/${signals.serviceName}` || c.servicePath === `/${simple}`) {\n c.score += 0.7;\n c.reasons.push('exact_local_service_path');\n } else if (c.servicePath.endsWith(`/${simple}`)) {\n c.score += candidates.filter((candidate) => candidate.servicePath.endsWith(`/${simple}`)).length === 1 ? 0.65 : 0.2;\n c.reasons.push('suffix_local_service_path');\n } else c.reasons.push('local_service_name_mismatch');\n }\n if (signals.hasExplicitOverride) {\n c.score += 0.2;\n c.reasons.push(signals.repoId !== undefined ? 'explicit_local_service_call' : 'explicit_dynamic_override');\n }\n if (signals.repoId !== undefined && candidates.length === 1 && signals.serviceName && c.reasons.includes('local_service_name_mismatch') && (c.operationPath === signals.operationPath || c.operationName === signals.operationPath.replace(/^\\//, ''))) {\n c.score = Math.max(c.score, 0.9);\n c.reasons.push('same_repo_unique_operation_path_with_lookup_mismatch');\n }\n }\n for (const c of candidates) c.score = Math.max(0, Math.min(1, c.score));\n candidates.sort(\n (a, b) => b.score - a.score || a.repoName.localeCompare(b.repoName),\n );\n const best = candidates[0];\n const second = candidates[1];\n if (signals.isDynamic && !signals.hasExplicitOverride && !signals.servicePath)\n return {\n status: 'dynamic',\n candidates,\n reasons: ['dynamic_target_without_override'],\n };\n if (!hasStrongSignal)\n return {\n status: candidates.length > 1 ? 'ambiguous' : 'unresolved',\n candidates,\n reasons: ['operation_path_only_has_no_strong_target_signal'],\n };\n if (\n best &&\n best.score >= 0.9 &&\n (best.servicePath === signals.servicePath || Boolean(signals.serviceName && (!best.reasons.includes('local_service_name_mismatch') || best.reasons.includes('same_repo_unique_operation_path_with_lookup_mismatch')))) &&\n (best.operationPath === signals.operationPath || best.operationName === signals.operationPath.replace(/^\\//, '')) &&\n (!second || best.score - second.score >= 0.25)\n )\n return {\n status: 'resolved',\n target: best,\n candidates,\n reasons: best.reasons,\n };\n return {\n status: candidates.length > 1 ? 'ambiguous' : 'unresolved',\n candidates,\n reasons: ['candidate_score_below_resolution_threshold'],\n };\n}\nfunction serviceMatches(candidate: OperationTarget, serviceName: string | undefined): boolean {\n if (!serviceName) return false;\n const simple = serviceName.split('.').at(-1) ?? serviceName;\n return candidate.qualifiedName === serviceName || candidate.serviceName === serviceName || candidate.serviceName === simple || candidate.servicePath === serviceName || candidate.servicePath === `/${serviceName}` || candidate.servicePath === `/${simple}` || candidate.servicePath.endsWith(`/${simple}`);\n}\nfunction implementationContextCandidates(db: Db, candidates: OperationTarget[], callerRepoId: number, serviceName: string): OperationTarget[] {\n const matching = candidates.filter((candidate) => serviceMatches(candidate, serviceName));\n const owned = matching.map((candidate) => ownershipReason(db, candidate, callerRepoId)).filter((item): item is { candidate: OperationTarget; reason: string } => Boolean(item));\n if (owned.length === 0) return [];\n const direct = owned.filter((item) => item.reason !== 'caller_depends_on_model_package');\n const chosen = direct.length > 0 ? direct : owned.length === 1 ? owned : [];\n return chosen.map((item) => ({ ...item.candidate, score: 0.95, reasons: [...item.candidate.reasons, 'implementation_context_caller_ownership', item.reason] }));\n}\nfunction ownershipReason(db: Db, candidate: OperationTarget, callerRepoId: number): { candidate: OperationTarget; reason: string } | undefined {\n const edge = db.prepare(\"SELECT status,evidence_json,to_id FROM graph_edges WHERE edge_type='OPERATION_IMPLEMENTED_BY_HANDLER' AND from_kind='operation' AND from_id=? ORDER BY CASE status WHEN 'resolved' THEN 0 WHEN 'ambiguous' THEN 1 ELSE 2 END LIMIT 1\").get(String(candidate.operationId)) as { status?: string; evidence_json?: string; to_id?: string } | undefined;\n if (edge?.status === 'resolved') {\n const row = db.prepare('SELECT hc.repo_id repoId FROM handler_methods hm JOIN handler_classes hc ON hc.id=hm.handler_class_id WHERE hm.id=?').get(edge.to_id) as { repoId?: number } | undefined;\n if (row?.repoId === callerRepoId) return { candidate, reason: 'resolved_implementation_handler_repo_matches_caller' };\n }\n if (edge?.evidence_json) {\n const evidence = JSON.parse(edge.evidence_json) as { candidates?: Array<{ accepted?: boolean; handlerPackage?: { id?: number }; applicationPackage?: { id?: number } }> };\n const hit = evidence.candidates?.find((item) => item.accepted && (Number(item.handlerPackage?.id) === callerRepoId || Number(item.applicationPackage?.id) === callerRepoId));\n if (hit) return { candidate, reason: edge.status === 'ambiguous' ? 'ambiguous_implementation_candidate_repo_matches_caller' : 'registration_package_matches_caller' };\n }\n const dep = db.prepare(\"SELECT 1 FROM graph_edges WHERE edge_type='REPO_IMPORTS_HELPER_PACKAGE' AND status='resolved' AND from_kind='repo' AND from_id=? AND to_id=?\").get(String(callerRepoId), String(candidate.repoId));\n if (dep) return { candidate, reason: 'caller_depends_on_model_package' };\n return undefined;\n}\n\nfunction matchesLocalRepo(db: Db, operationId: number, repoId: number | undefined): boolean {\n if (repoId === undefined) return true;\n const row = db.prepare('SELECT s.repo_id repoId FROM cds_operations o JOIN cds_services s ON s.id=o.service_id WHERE o.id=?').get(operationId) as { repoId?: number } | undefined;\n return row?.repoId === repoId;\n}\nexport function findOperation(\n db: Db,\n servicePath: string | undefined,\n operationPath: string | undefined,\n workspaceId?: number,\n): OperationTarget | undefined {\n return resolveOperation(db, { servicePath, operationPath }, workspaceId)\n .target;\n}\n","import type { Db } from '../db/connection.js';\n\ninterface RepoDependencyRow {\n id: number;\n name: string;\n package_name: string | null;\n dependencies_json: string;\n}\nexport interface DependencyLinkSummary {\n edgeCount: number;\n resolvedCount: number;\n ambiguousCount: number;\n}\ninterface CandidateResult {\n candidates: RepoDependencyRow[];\n strategy: 'exact_package_name' | 'normalized_directory';\n}\nfunction normalizeName(value: string): string {\n return value.toLowerCase().replace(/^@[^/]+\\//, '').replace(/[^a-z0-9]+/g, '');\n}\nfunction candidatesForDependency(repos: RepoDependencyRow[], dep: string, sourceId: number): CandidateResult {\n const exact = repos.filter((repo) => repo.id !== sourceId && repo.package_name === dep);\n if (exact.length > 0) return { candidates: exact, strategy: 'exact_package_name' };\n const normalized = normalizeName(dep);\n return { candidates: repos.filter((repo) => repo.id !== sourceId && normalizeName(repo.name) === normalized), strategy: 'normalized_directory' };\n}\nexport function linkHelperPackages(db: Db, workspaceId: number, generation: number): DependencyLinkSummary {\n const repos = db.prepare('SELECT id,name,package_name,dependencies_json FROM repositories WHERE workspace_id=?').all(workspaceId) as unknown as RepoDependencyRow[];\n const summary: DependencyLinkSummary = { edgeCount: 0, resolvedCount: 0, ambiguousCount: 0 };\n for (const repo of repos) {\n const deps = JSON.parse(repo.dependencies_json) as Record<string, string>;\n for (const dep of Object.keys(deps)) {\n const result = candidatesForDependency(repos, dep, repo.id);\n if (result.candidates.length === 0) continue;\n const status = result.candidates.length === 1 ? 'resolved' : 'ambiguous';\n const helper = status === 'resolved' ? result.candidates[0] : undefined;\n db.prepare('INSERT INTO graph_edges(workspace_id,edge_type,status,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,unresolved_reason,generation) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)').run(\n workspaceId,\n 'REPO_IMPORTS_HELPER_PACKAGE',\n status,\n 'repo',\n String(repo.id),\n helper ? 'repo' : 'repo_candidates',\n helper ? String(helper.id) : result.candidates.map((candidate) => candidate.id).join(','),\n helper ? 1 : 0.5,\n JSON.stringify({ dependency: dep, candidates: result.candidates.map((candidate) => ({ id: candidate.id, name: candidate.name, packageName: candidate.package_name })), match: result.strategy }),\n 0,\n helper ? null : 'Ambiguous dependency package candidates',\n generation,\n );\n summary.edgeCount += 1;\n if (helper) summary.resolvedCount += 1;\n else summary.ambiguousCount += 1;\n }\n }\n return summary;\n}\n","import type { Db } from '../db/connection.js';\nimport { applyVariables } from './dynamic-edge-resolver.js';\nimport { resolveOperation } from './service-resolver.js';\nimport { linkHelperPackages } from './helper-package-linker.js';\nexport interface LinkWorkspaceResult {\n edgeCount: number;\n unresolvedCount: number;\n resolvedCount: number;\n remoteResolvedCount: number;\n localResolvedCount: number;\n ambiguousCount: number;\n dynamicCount: number;\n terminalCount: number;\n dependencyResolvedCount: number;\n dependencyAmbiguousCount: number;\n implementationResolvedCount: number;\n implementationAmbiguousCount: number;\n implementationUnresolvedCount: number;\n}\nexport function linkWorkspace(db: Db, workspaceId: number, vars: Record<string, string> = {}): LinkWorkspaceResult {\n return db.transaction(() => {\n const generation = nextGraphGeneration(db, workspaceId);\n db.prepare('DELETE FROM graph_edges WHERE workspace_id=?').run(workspaceId);\n const deps = linkHelperPackages(db, workspaceId, generation);\n const impl = linkImplementations(db, workspaceId, generation);\n const callSummary = linkCalls(db, workspaceId, vars, generation);\n db.prepare(\"UPDATE repositories SET graph_generation=?, graph_stale_reason=NULL, graph_stale_at=NULL WHERE workspace_id=?\").run(generation, workspaceId);\n return { ...callSummary, edgeCount: deps.edgeCount + callSummary.edgeCount + impl.edgeCount, dependencyResolvedCount: deps.resolvedCount, dependencyAmbiguousCount: deps.ambiguousCount, implementationResolvedCount: impl.resolvedCount, implementationAmbiguousCount: impl.ambiguousCount, implementationUnresolvedCount: impl.unresolvedCount };\n });\n}\nfunction nextGraphGeneration(db: Db, workspaceId: number): number {\n const row = db.prepare('SELECT COALESCE(MAX(graph_generation),0) generation FROM repositories WHERE workspace_id=?').get(workspaceId) as { generation?: number } | undefined;\n return Number(row?.generation ?? 0) + 1;\n}\nfunction linkCalls(db: Db, workspaceId: number, vars: Record<string, string>, generation: number): Omit<LinkWorkspaceResult, 'dependencyResolvedCount' | 'dependencyAmbiguousCount' | 'implementationResolvedCount' | 'implementationAmbiguousCount' | 'implementationUnresolvedCount'> {\n let edgeCount = 0;\n let unresolvedCount = 0;\n let resolvedCount = 0;\n let remoteResolvedCount = 0;\n let localResolvedCount = 0;\n let ambiguousCount = 0;\n let dynamicCount = 0;\n let terminalCount = 0;\n const calls = db.prepare(`SELECT c.*,r.name repoName,b.alias,b.alias_expr aliasExpr,b.destination_expr destinationExpr,b.service_path_expr servicePathExpr,b.is_dynamic isDynamic,b.placeholders_json placeholdersJson,b.helper_chain_json helperChainJson,req.service_path requireServicePath,req.destination requireDestination FROM outbound_calls c JOIN repositories r ON r.id=c.repo_id LEFT JOIN service_bindings b ON b.id=c.service_binding_id LEFT JOIN cds_requires req ON req.repo_id=c.repo_id AND req.alias=b.alias WHERE r.workspace_id=?`).all(workspaceId) as Array<Record<string, unknown>>;\n for (const call of calls) {\n const result = insertCallEdge(db, workspaceId, call, vars, generation);\n edgeCount += 1;\n resolvedCount += result.status === 'resolved' ? 1 : 0;\n remoteResolvedCount += result.status === 'resolved' && result.callType !== 'local_service_call' ? 1 : 0;\n localResolvedCount += result.status === 'resolved' && result.callType === 'local_service_call' ? 1 : 0;\n unresolvedCount += result.status === 'unresolved' ? 1 : 0;\n ambiguousCount += result.status === 'ambiguous' ? 1 : 0;\n dynamicCount += result.status === 'dynamic' ? 1 : 0;\n terminalCount += result.status === 'terminal' ? 1 : 0;\n }\n return { edgeCount, unresolvedCount, resolvedCount, remoteResolvedCount, localResolvedCount, ambiguousCount, dynamicCount, terminalCount };\n}\nfunction insertCallEdge(db: Db, workspaceId: number, call: Record<string, unknown>, vars: Record<string, string>, generation: number): { status: string; callType: string } {\n const callType = String(call.call_type);\n const op = applyVariables(String(call.operation_path_expr ?? ''), vars);\n const servicePath = applyVariables((call.servicePathExpr as string | undefined) ?? (call.requireServicePath as string | undefined), vars);\n const destination = (call.destinationExpr as string | undefined) ?? (call.requireDestination as string | undefined);\n const isDynamic = Boolean(Number(call.isDynamic ?? 0));\n const isOperationCall = callType.startsWith('remote') || callType === 'local_service_call';\n const resolution = isOperationCall ? resolveOperation(db, { servicePath, operationPath: op, serviceName: call.local_service_name as string | undefined, repoId: callType === 'local_service_call' ? Number(call.repo_id) : undefined, alias: applyVariables((call.aliasExpr as string | undefined) ?? (call.alias as string | undefined), vars), destination: destination ? applyVariables(destination, vars) : undefined, isDynamic, hasExplicitOverride: Object.keys(vars).length > 0 || callType === 'local_service_call' }, workspaceId) : { status: 'unresolved' as const, candidates: [], reasons: [] };\n const evidence = callEvidence(call, resolution, servicePath, op, destination ? applyVariables(destination, vars) : undefined);\n if (callType === 'local_service_call' && call.unresolved_reason === 'transport_client_method' && !resolution.target && resolution.candidates.length === 0) {\n db.prepare('INSERT INTO graph_edges(workspace_id,edge_type,status,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,generation) VALUES(?,?,?,?,?,?,?,?,?,?,?)').run(workspaceId, 'HANDLER_CALLS_EXTERNAL_HTTP', 'terminal', 'call', String(call.id), 'external', String(op || 'transport_client_method'), Number(call.confidence ?? 0.5), JSON.stringify({ ...evidence, classification: 'transport_client_method' }), 0, generation);\n return { status: 'terminal', callType };\n }\n if (resolution.target) {\n db.prepare('INSERT INTO graph_edges(workspace_id,edge_type,status,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,generation) VALUES(?,?,?,?,?,?,?,?,?,?,?)').run(workspaceId, callType === 'local_service_call' ? 'LOCAL_CALL_RESOLVES_TO_OPERATION' : 'REMOTE_CALL_RESOLVES_TO_OPERATION', 'resolved', 'call', String(call.id), 'operation', String(resolution.target.operationId), resolution.target.score, JSON.stringify(evidence), isDynamic ? 1 : 0, generation);\n return { status: 'resolved', callType };\n }\n const edgeType = callType === 'local_db_query' ? 'HANDLER_RUNS_DB_QUERY' : callType === 'external_http' ? 'HANDLER_CALLS_EXTERNAL_HTTP' : callType === 'async_emit' ? 'HANDLER_EMITS_EVENT' : callType === 'async_subscribe' ? 'EVENT_CONSUMED_BY_HANDLER' : resolution.status === 'dynamic' ? 'DYNAMIC_EDGE_CANDIDATE' : 'UNRESOLVED_EDGE';\n const status = edgeType === 'DYNAMIC_EDGE_CANDIDATE' ? 'dynamic' : resolution.status === 'ambiguous' ? 'ambiguous' : edgeType === 'UNRESOLVED_EDGE' ? 'unresolved' : 'terminal';\n const unresolvedReason = status === 'terminal' ? null : String(call.unresolved_reason ?? (resolution.status === 'ambiguous' ? 'Ambiguous operation candidates require a strong service signal' : resolution.status === 'dynamic' ? `Dynamic target requires runtime variable overrides: ${(resolution.reasons.length ? resolution.reasons : ['missing runtime variables']).join(', ')}` : 'No indexed target operation matched'));\n const targetKind = callType === 'local_db_query' ? 'db_entity' : callType.startsWith('async_') ? 'event' : 'external';\n const targetId = callType === 'local_db_query' ? String(call.query_entity ?? 'unknown') : String(call.event_name_expr ?? op ?? call.id);\n db.prepare('INSERT INTO graph_edges(workspace_id,edge_type,status,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,unresolved_reason,generation) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)').run(workspaceId, edgeType, status, 'call', String(call.id), targetKind, targetId, Number(call.confidence ?? 0.2), JSON.stringify(evidence), isDynamic || resolution.status === 'dynamic' ? 1 : 0, unresolvedReason, generation);\n return { status, callType };\n}\nfunction callEvidence(call: Record<string, unknown>, resolution: { target?: { repoName?: string; operationName?: string }; candidates: unknown[]; status: string; reasons: string[] }, servicePath: string | undefined, op: string | undefined, destination: string | undefined): Record<string, unknown> {\n return { sourceFile: call.source_file, sourceLine: call.source_line, file: call.source_file, line: call.source_line, callId: call.id, repo: call.repoName, serviceAlias: call.alias, serviceAliasExpr: call.aliasExpr, destination, servicePath, operationPath: op, localServiceName: call.local_service_name, localServiceLookup: call.local_service_lookup, aliasChain: call.alias_chain_json ? (JSON.parse(String(call.alias_chain_json)) as unknown) : undefined, transport: call.call_type === 'local_service_call' ? 'local' : undefined, targetRepo: resolution.target?.repoName, targetOperation: resolution.target?.operationName, helperChain: call.helperChainJson ? (JSON.parse(String(call.helperChainJson)) as unknown) : undefined, candidates: resolution.candidates, candidateCount: resolution.candidates.length, resolutionStatus: resolution.status, resolutionReasons: resolution.reasons, analysisCompleteness: call.unresolved_reason ? 'partial' : 'complete', parserWarning: call.unresolved_reason ? { code: 'parser_warning', message: call.unresolved_reason } : undefined };\n}\n\nfunction linkImplementations(db: Db, workspaceId: number, generation: number): { edgeCount: number; resolvedCount: number; ambiguousCount: number; unresolvedCount: number } {\n const operations = db.prepare(`SELECT o.id operationId,o.operation_path operationPath,o.operation_name operationName,s.service_path servicePath,s.repo_id modelRepoId,r.name modelRepo,r.package_name modelPackage,r.kind modelKind FROM cds_operations o JOIN cds_services s ON s.id=o.service_id JOIN repositories r ON r.id=s.repo_id WHERE r.workspace_id=?`).all(workspaceId) as Array<Record<string, unknown>>;\n let edgeCount = 0;\n let resolvedCount = 0;\n let ambiguousCount = 0;\n let unresolvedCount = 0;\n for (const operation of operations) {\n const candidates = rankedImplementationCandidates(db, workspaceId, operation);\n if (candidates.length === 0) continue;\n const accepted = candidates.filter((candidate) => candidate.accepted);\n const topScore = accepted[0]?.score ?? 0;\n const winners = accepted.filter((candidate) => candidate.score === topScore);\n const unique = winners.length === 1 ? winners[0] : undefined;\n const evidence = {\n servicePath: operation.servicePath,\n operationPath: operation.operationPath,\n operationName: operation.operationName,\n modelPackage: { id: operation.modelRepoId, name: operation.modelRepo, packageName: operation.modelPackage },\n candidates: candidates.map((candidate, index) => candidateEvidence(candidate, index + 1)),\n };\n if (accepted.length === 0) {\n db.prepare('INSERT INTO graph_edges(workspace_id,edge_type,status,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,unresolved_reason,generation) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)').run(workspaceId, 'OPERATION_IMPLEMENTED_BY_HANDLER', 'unresolved', 'operation', graphId(operation.operationId), 'handler_method_candidates', candidates.map((row) => graphId(row.methodId)).join(','), 0, JSON.stringify(evidence), 0, 'No implementation candidate passed policy', generation);\n edgeCount += 1;\n unresolvedCount += 1;\n continue;\n }\n db.prepare('INSERT INTO graph_edges(workspace_id,edge_type,status,from_kind,from_id,to_kind,to_id,confidence,evidence_json,is_dynamic,unresolved_reason,generation) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)').run(workspaceId, 'OPERATION_IMPLEMENTED_BY_HANDLER', unique ? 'resolved' : 'ambiguous', 'operation', graphId(operation.operationId), unique ? 'handler_method' : 'handler_method_candidates', unique ? graphId(unique.methodId) : winners.map((row) => graphId(row.methodId)).join(','), unique ? 0.95 : 0.5, JSON.stringify(evidence), 0, unique ? null : 'Ambiguous registered handler implementation candidates', generation);\n edgeCount += 1;\n if (unique) resolvedCount += 1;\n else ambiguousCount += 1;\n }\n return { edgeCount, resolvedCount, ambiguousCount, unresolvedCount };\n}\ninterface ImplementationCandidate extends Record<string, unknown> {\n methodId: number;\n registrations?: Array<Record<string, unknown>>;\n score: number;\n accepted: boolean;\n acceptedReasons: string[];\n rejectedReasons: string[];\n}\nfunction rankedImplementationCandidates(db: Db, workspaceId: number, operation: Record<string, unknown>): ImplementationCandidate[] {\n const rows = implementationCandidates(db, workspaceId, operation);\n return deduplicateCandidates(rows.map((row) => scoreImplementationCandidate(row, operation))).sort((a, b) => b.score - a.score || String(a.className).localeCompare(String(b.className)) || a.methodId - b.methodId);\n}\n\nfunction deduplicateCandidates(rows: ImplementationCandidate[]): ImplementationCandidate[] {\n const merged = new Map<string, ImplementationCandidate>();\n for (const row of rows) {\n const key = [row.methodId, row.classId, row.handlerRepoId].join(':');\n const registration = { file: row.registrationFile, line: row.registrationLine, kind: row.registrationKind, importSource: row.importSource };\n const existing = merged.get(key);\n if (!existing) {\n merged.set(key, { ...row, registrations: [registration] });\n continue;\n }\n existing.registrations = uniqueRegistrations([...(existing.registrations ?? []), registration]);\n existing.score = Math.max(existing.score, row.score);\n existing.accepted = existing.accepted || row.accepted;\n existing.acceptedReasons = [...new Set([...existing.acceptedReasons, ...row.acceptedReasons])];\n existing.rejectedReasons = [...new Set([...existing.rejectedReasons, ...row.rejectedReasons])];\n }\n return [...merged.values()];\n}\nfunction uniqueRegistrations(rows: Array<Record<string, unknown>>): Array<Record<string, unknown>> {\n const seen = new Set<string>();\n return rows.filter((row) => {\n const key = JSON.stringify(row);\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\nfunction implementationCandidates(db: Db, workspaceId: number, operation: Record<string, unknown>): Array<Record<string, unknown>> {\n const modelRepoGraphId = graphId(operation.modelRepoId);\n return db.prepare(`SELECT DISTINCT\n hm.id methodId,\n hm.method_name methodName,\n hm.decorator_value decoratorValue,\n hm.decorator_raw_expression decoratorRawExpression,\n hc.id classId,\n hc.class_name className,\n hc.source_file sourceFile,\n hc.source_line sourceLine,\n hr.repo_id applicationRepoId,\n hr.registration_file registrationFile,\n hr.registration_line registrationLine,\n hr.registration_kind registrationKind,\n hr.import_source importSource,\n handlerRepo.id handlerRepoId,\n handlerRepo.name handlerRepo,\n handlerRepo.package_name handlerPackage,\n appRepo.name applicationRepo,\n appRepo.package_name applicationPackage,\n ? modelRepoId,\n ? modelRepo,\n ? modelPackage,\n ? modelKind,\n ? servicePath,\n ? operationPath,\n ? operationName,\n CASE WHEN appRepo.id=? THEN 1 ELSE 0 END modelIsApplicationRepo,\n CASE WHEN handlerRepo.id=? THEN 1 ELSE 0 END modelIsHandlerRepo,\n CASE WHEN appRepo.id=handlerRepo.id THEN 1 ELSE 0 END sameRepoRegistration,\n CASE WHEN EXISTS (SELECT 1 FROM cds_services localService WHERE localService.repo_id=appRepo.id AND localService.service_path=?) THEN 1 ELSE 0 END localServicePathMatch,\n CASE WHEN EXISTS (SELECT 1 FROM cds_services localService WHERE localService.repo_id=appRepo.id) THEN 1 ELSE 0 END applicationHasLocalServices,\n CASE WHEN EXISTS (SELECT 1 FROM handler_registrations localReg JOIN handler_classes localClass ON (localClass.id=localReg.handler_class_id OR localClass.class_name=localReg.class_name) JOIN handler_methods localMethod ON localMethod.handler_class_id=localClass.id WHERE localReg.repo_id=appRepo.id AND (localMethod.decorator_value=? OR localMethod.decorator_value=? OR localMethod.method_name=? OR localMethod.decorator_raw_expression LIKE ?)) THEN 1 ELSE 0 END applicationHasLocalRegistrationForOperation,\n CASE WHEN EXISTS (SELECT 1 FROM graph_edges dep WHERE dep.edge_type='REPO_IMPORTS_HELPER_PACKAGE' AND dep.status='resolved' AND dep.from_kind='repo' AND dep.from_id=CAST(appRepo.id AS TEXT) AND dep.to_id=?) THEN 1 ELSE 0 END appDependsOnModel,\n CASE WHEN EXISTS (SELECT 1 FROM graph_edges dep WHERE dep.edge_type='REPO_IMPORTS_HELPER_PACKAGE' AND dep.status='resolved' AND dep.from_kind='repo' AND dep.from_id=CAST(appRepo.id AS TEXT) AND dep.to_id=CAST(handlerRepo.id AS TEXT)) THEN 1 ELSE 0 END appDependsOnHandler,\n CASE WHEN EXISTS (SELECT 1 FROM graph_edges dep WHERE dep.edge_type='REPO_IMPORTS_HELPER_PACKAGE' AND dep.status='resolved' AND dep.from_kind='repo' AND dep.from_id=CAST(handlerRepo.id AS TEXT) AND dep.to_id=?) THEN 1 ELSE 0 END handlerDependsOnModel\n FROM handler_methods hm\n JOIN handler_classes hc ON hc.id=hm.handler_class_id\n JOIN repositories handlerRepo ON handlerRepo.id=hc.repo_id\n JOIN handler_registrations hr ON (hr.handler_class_id=hc.id OR (hr.class_name=hc.class_name AND (hr.repo_id=hc.repo_id OR hr.import_source IS NOT NULL)))\n JOIN repositories appRepo ON appRepo.id=hr.repo_id\n WHERE appRepo.workspace_id=?\n AND (hm.decorator_value=? OR hm.decorator_value=? OR hm.method_name=? OR hm.decorator_raw_expression LIKE ?)`).all(\n operation.modelRepoId,\n operation.modelRepo,\n operation.modelPackage,\n operation.modelKind,\n operation.servicePath,\n operation.operationPath,\n operation.operationName,\n operation.modelRepoId,\n operation.modelRepoId,\n operation.servicePath,\n normalizedOperation(String(operation.operationPath ?? '')),\n operation.operationName,\n operation.operationName,\n `%${upperFirst(normalizedOperation(String(operation.operationPath ?? operation.operationName ?? '')))}%`,\n modelRepoGraphId,\n modelRepoGraphId,\n workspaceId,\n normalizedOperation(String(operation.operationPath ?? '')),\n operation.operationName,\n operation.operationName,\n `%${upperFirst(normalizedOperation(String(operation.operationPath ?? operation.operationName ?? '')))}%`,\n ) as Array<Record<string, unknown>>;\n}\nfunction scoreImplementationCandidate(row: Record<string, unknown>, operation: Record<string, unknown>): ImplementationCandidate {\n const acceptedReasons: string[] = [];\n const rejectedReasons: string[] = [];\n let score = 0;\n const modelIsApplicationRepo = flag(row.modelIsApplicationRepo);\n const modelIsHandlerRepo = flag(row.modelIsHandlerRepo);\n const localServicePathMatch = flag(row.localServicePathMatch);\n const applicationHasLocalServices = flag(row.applicationHasLocalServices);\n const appDependsOnModel = flag(row.appDependsOnModel);\n const applicationHasLocalRegistrationForOperation = flag(row.applicationHasLocalRegistrationForOperation);\n const appDependsOnHandler = flag(row.appDependsOnHandler);\n const handlerDependsOnModel = flag(row.handlerDependsOnModel);\n const importSource = typeof row.importSource === 'string' && row.importSource.length > 0;\n const sameRepoRegistration = flag(row.sameRepoRegistration);\n const modelOriented = row.modelKind === 'cap-db-model' || !applicationHasLocalRegistrationForOperation;\n const methodSignal = implementationMethodSignal(row, operation);\n const methodMatches = methodSignal.matches;\n acceptedReasons.push(...methodSignal.acceptedReasons);\n rejectedReasons.push(...methodSignal.rejectedReasons);\n const registeredAndLinked = sameRepoRegistration && importSource;\n const helperOwned = modelOriented && methodMatches && registeredAndLinked && sameRepoRegistration && !applicationHasLocalServices && !modelIsApplicationRepo && !modelIsHandlerRepo && !localServicePathMatch && !appDependsOnModel && !appDependsOnHandler && !handlerDependsOnModel;\n if (modelIsApplicationRepo) {\n score += 100;\n acceptedReasons.push('model package equals registration package');\n }\n if (modelIsHandlerRepo) {\n score += 100;\n acceptedReasons.push('model package equals handler package');\n }\n if (localServicePathMatch) {\n score += 80;\n acceptedReasons.push('registration package contains exact local service path');\n } else if (applicationHasLocalServices && !appDependsOnModel && !modelIsApplicationRepo) {\n rejectedReasons.push(`registration package has local services but none match ${String(operation.servicePath ?? '')}`);\n }\n if (appDependsOnModel) {\n score += 70;\n acceptedReasons.push('registration package depends on model package');\n }\n if (appDependsOnHandler) {\n score += 30;\n acceptedReasons.push('registration package depends on handler package');\n }\n if (handlerDependsOnModel) {\n score += 20;\n acceptedReasons.push('handler package depends on model package');\n }\n if (helperOwned) {\n score += 60;\n acceptedReasons.push('unique registered helper implementation for model-only operation');\n }\n if (importSource) {\n score += 10;\n acceptedReasons.push('registration imports handler class');\n }\n const hasOwnership = modelIsApplicationRepo || modelIsHandlerRepo;\n const hasCrossPackage = appDependsOnModel && (modelIsHandlerRepo || appDependsOnHandler || !importSource);\n const contradicted = applicationHasLocalServices && !localServicePathMatch && !appDependsOnModel && !hasOwnership;\n if (!hasOwnership && !localServicePathMatch && !hasCrossPackage && !helperOwned) rejectedReasons.push('missing direct ownership, exact local service path, or validated cross-package dependency evidence');\n const accepted = methodMatches && !methodSignal.contradicted && !contradicted && (hasOwnership || localServicePathMatch || hasCrossPackage || handlerDependsOnModel || helperOwned);\n if (!accepted && rejectedReasons.length === 0) rejectedReasons.push('candidate did not meet implementation ownership policy');\n return { ...row, methodId: Number(row.methodId), score, accepted, acceptedReasons, rejectedReasons };\n}\nfunction candidateEvidence(candidate: ImplementationCandidate, rank: number): Record<string, unknown> {\n return {\n rank,\n score: candidate.score,\n accepted: candidate.accepted,\n acceptedReasons: candidate.acceptedReasons,\n rejectedReasons: candidate.rejectedReasons,\n methodId: candidate.methodId,\n classId: candidate.classId,\n className: candidate.className,\n sourceFile: candidate.sourceFile,\n sourceLine: candidate.sourceLine,\n registration: { file: candidate.registrationFile, line: candidate.registrationLine, kind: candidate.registrationKind, importSource: candidate.importSource },\n registrations: candidate.registrations ?? [],\n applicationPackage: { id: candidate.applicationRepoId, name: candidate.applicationRepo, packageName: candidate.applicationPackage },\n handlerPackage: { id: candidate.handlerRepoId, name: candidate.handlerRepo, packageName: candidate.handlerPackage },\n modelPackage: { id: candidate.modelRepoId, name: candidate.modelRepo, packageName: candidate.modelPackage },\n servicePath: candidate.servicePath,\n operationPath: candidate.operationPath,\n operationName: candidate.operationName,\n signals: {\n directOwnership: { modelIsApplicationRepo: flag(candidate.modelIsApplicationRepo), modelIsHandlerRepo: flag(candidate.modelIsHandlerRepo) },\n localServicePathMatch: flag(candidate.localServicePathMatch),\n applicationHasLocalServices: flag(candidate.applicationHasLocalServices),\n applicationHasLocalRegistrationForOperation: flag(candidate.applicationHasLocalRegistrationForOperation),\n appDependsOnModel: flag(candidate.appDependsOnModel),\n appDependsOnHandler: flag(candidate.appDependsOnHandler),\n handlerDependsOnModel: flag(candidate.handlerDependsOnModel),\n sameRepoRegistration: flag(candidate.sameRepoRegistration),\n },\n };\n}\nfunction implementationMethodSignal(row: Record<string, unknown>, operation: Record<string, unknown>): { matches: boolean; contradicted: boolean; acceptedReasons: string[]; rejectedReasons: string[] } {\n const op = normalizedOperation(String(operation.operationPath ?? operation.operationName ?? ''));\n const decorator = normalizeDecoratorOperation(typeof row.decoratorValue === 'string' ? row.decoratorValue : undefined, typeof row.decoratorRawExpression === 'string' ? row.decoratorRawExpression : undefined);\n if (decorator && decorator === op) return { matches: true, contradicted: false, acceptedReasons: ['decorator targets operation'], rejectedReasons: [] };\n if (decorator && decorator !== op) return { matches: false, contradicted: true, acceptedReasons: [], rejectedReasons: ['method_name_matches_but_decorator_targets_different_operation'] };\n if (String(row.methodName ?? '') === op) return { matches: true, contradicted: false, acceptedReasons: ['method name fallback matched operation'], rejectedReasons: [] };\n return { matches: false, contradicted: false, acceptedReasons: [], rejectedReasons: ['method name does not match operation'] };\n}\nfunction normalizeDecoratorOperation(value: string | undefined, raw: string | undefined): string | undefined {\n const candidate = value ?? raw?.split('.').filter(Boolean).at(-2);\n if (!candidate) return undefined;\n const cleaned = candidate.replace(/^['\"`]|['\"`]$/g, '');\n for (const prefix of ['Func', 'Action']) {\n if (cleaned.startsWith(prefix) && cleaned.length > prefix.length) return lowerFirst(cleaned.slice(prefix.length));\n }\n return normalizedOperation(cleaned);\n}\nfunction upperFirst(value: string): string {\n return value ? `${value[0]?.toUpperCase() ?? ''}${value.slice(1)}` : value;\n}\nfunction lowerFirst(value: string): string {\n return value ? `${value[0]?.toLowerCase() ?? ''}${value.slice(1)}` : value;\n}\nfunction flag(value: unknown): boolean {\n return Boolean(Number(value ?? 0));\n}\nfunction graphId(value: unknown): string {\n return String(value);\n}\nfunction normalizedOperation(value: string): string {\n return value.startsWith('/') ? value.slice(1) : value;\n}\n","import type { Db } from '../db/connection.js';\nimport { extractPlaceholders, substituteVariables, type RuntimeSubstitution } from '../linker/dynamic-edge-resolver.js';\nimport { resolveOperation, type OperationTarget } from '../linker/service-resolver.js';\nimport type { TraceEdge, TraceResult, TraceStart } from '../types.js';\n\ninterface RepoRef {\n id: number;\n name: string;\n}\ninterface StartScope {\n repo?: RepoRef;\n sourceFiles?: Set<string>;\n symbolIds?: Set<number>;\n selectorMatched: boolean;\n}\ninterface CallRow extends Record<string, unknown> {\n id: number;\n repo_id: number;\n repoName: string;\n source_file: string;\n source_line: number;\n call_type: string;\n confidence: number;\n source_symbol_id?: number;\n}\ninterface GraphRow extends Record<string, unknown> {\n id: number;\n edge_type: string;\n from_id: string;\n to_kind: string;\n to_id: string;\n confidence: number;\n evidence_json: string;\n unresolved_reason?: string;\n status?: string;\n}\ninterface Candidate {\n servicePath?: string;\n operationPath?: string;\n repoName?: string;\n operationName?: string;\n score?: number;\n}\n\nfunction normalizeOperation(value: string | undefined): string | undefined {\n if (!value) return undefined;\n return value.startsWith('/') ? value.slice(1) : value;\n}\nfunction positiveDepth(value: number): number {\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : 25;\n}\nfunction sourceFilesForStart(\n db: Db,\n repoId: number | undefined,\n start: TraceStart,\n): { files?: Set<string>; symbols?: Set<number> } | undefined {\n const handler = start.handler;\n const operation = normalizeOperation(start.operation ?? start.operationPath);\n if (!handler && !operation) return undefined;\n const rows = db\n .prepare(\n `SELECT DISTINCT hc.source_file sourceFile,s.id symbolId\n FROM handler_classes hc LEFT JOIN handler_methods hm ON hm.handler_class_id=hc.id LEFT JOIN symbols s ON s.repo_id=hc.repo_id AND s.source_file=hc.source_file AND s.name=hm.method_name\n WHERE (? IS NULL OR hc.repo_id=?) AND (? IS NULL OR hc.class_name=? OR hm.method_name=?)\n AND (? IS NULL OR hm.decorator_value=? OR hm.method_name=?)\n AND (? IS NULL OR EXISTS (SELECT 1 FROM cds_services s JOIN cds_operations o ON o.service_id=s.id WHERE s.repo_id=hc.repo_id AND s.service_path=? AND (? IS NULL OR o.operation_path=? OR o.operation_name=? OR hm.decorator_value=? OR hm.method_name=?)))`,\n )\n .all(\n repoId,\n repoId,\n handler,\n handler,\n handler,\n operation,\n operation,\n operation,\n start.servicePath,\n start.servicePath,\n operation,\n operation,\n operation,\n operation,\n operation,\n ) as Array<{ sourceFile?: string; symbolId?: number }>;\n if (rows.length > 0) return { files: new Set(rows.map((row) => row.sourceFile).filter(Boolean) as string[]), symbols: new Set(rows.map((row) => Number(row.symbolId)).filter(Boolean)) };\n if (start.servicePath && operation) {\n const implRows = db.prepare(`SELECT DISTINCT hc.source_file sourceFile,sym.id symbolId\n FROM cds_services s JOIN cds_operations o ON o.service_id=s.id\n JOIN graph_edges e ON e.edge_type='OPERATION_IMPLEMENTED_BY_HANDLER' AND e.status='resolved' AND e.from_kind='operation' AND e.from_id=CAST(o.id AS TEXT)\n JOIN handler_methods hm ON hm.id=CAST(e.to_id AS INTEGER)\n JOIN handler_classes hc ON hc.id=hm.handler_class_id\n LEFT JOIN symbols sym ON sym.repo_id=hc.repo_id AND sym.source_file=hc.source_file AND sym.name=hm.method_name\n WHERE (? IS NULL OR s.repo_id=?) AND s.service_path=? AND (o.operation_path=? OR o.operation_name=?)`).all(repoId, repoId, start.servicePath, operation, operation) as Array<{ sourceFile?: string; symbolId?: number }>;\n if (implRows.length > 0) return { files: new Set(implRows.map((row) => row.sourceFile).filter(Boolean) as string[]), symbols: new Set(implRows.map((row) => Number(row.symbolId)).filter(Boolean)) };\n }\n return undefined;\n}\nfunction startScope(db: Db, start: TraceStart): StartScope {\n const repo = start.repo\n ? (db\n .prepare(\n 'SELECT id,name FROM repositories WHERE name=? OR package_name=?',\n )\n .get(start.repo, start.repo) as RepoRef | undefined)\n : undefined;\n if (start.repo && !repo) return { repo, selectorMatched: false };\n const sourceScope = sourceFilesForStart(db, repo?.id, start);\n const sourceFiles = sourceScope?.files;\n const hasSelector = Boolean(\n start.handler ?? start.operation ?? start.operationPath ?? start.servicePath,\n );\n if (start.servicePath && !start.operation && !start.operationPath && !start.handler)\n return { repo, selectorMatched: false };\n return {\n repo,\n sourceFiles,\n symbolIds: sourceScope?.symbols,\n selectorMatched: !hasSelector || sourceFiles !== undefined,\n };\n}\nfunction handlerFilesForOperation(db: Db, operationId: string): Set<string> {\n const op = db\n .prepare(\n `SELECT o.operation_name operationName,o.operation_path operationPath,s.repo_id repoId\n FROM cds_operations o JOIN cds_services s ON s.id=o.service_id WHERE o.id=?`,\n )\n .get(operationId) as\n | { operationName?: string; operationPath?: string; repoId?: number }\n | undefined;\n if (!op) return new Set();\n const operation = normalizeOperation(op.operationPath ?? op.operationName);\n const rows = db\n .prepare(\n `SELECT DISTINCT hc.source_file sourceFile,sym.id symbolId FROM handler_classes hc\n JOIN handler_methods hm ON hm.handler_class_id=hc.id\n LEFT JOIN symbols sym ON sym.repo_id=hc.repo_id AND sym.source_file=hc.source_file AND sym.name=hm.method_name\n WHERE hc.repo_id=? AND (hm.decorator_value=? OR hm.method_name=? OR hm.decorator_value=?)`,\n )\n .all(op.repoId, operation, operation, op.operationName) as Array<{\n sourceFile?: string;\n }>;\n return new Set(rows.map((row) => row.sourceFile).filter(Boolean) as string[]);\n}\n\nfunction implementationEdge(db: Db, operationId: string): GraphRow | undefined {\n return db.prepare(\"SELECT * FROM graph_edges WHERE edge_type='OPERATION_IMPLEMENTED_BY_HANDLER' AND from_kind='operation' AND from_id=? ORDER BY CASE status WHEN 'resolved' THEN 0 WHEN 'ambiguous' THEN 1 ELSE 2 END,id LIMIT 1\").get(operationId) as GraphRow | undefined;\n}\nfunction handlerMethodNode(db: Db, methodId: string): Record<string, unknown> | undefined {\n const row = db.prepare(`SELECT hm.id methodId,hm.method_name methodName,hm.decorator_value decoratorValue,hm.source_line sourceLine,hc.class_name className,hc.source_file sourceFile,r.name repoName,r.id repoId FROM handler_methods hm JOIN handler_classes hc ON hc.id=hm.handler_class_id JOIN repositories r ON r.id=hc.repo_id WHERE hm.id=?`).get(methodId) as Record<string, unknown> | undefined;\n if (!row) return undefined;\n return { id: `handler_method:${methodId}`, kind: 'handler_method', label: `${String(row.repoName)}:${String(row.className)}.${String(row.methodName)}`, ...row };\n}\nfunction implementationScope(db: Db, operationId: string): { repoId?: number; files: Set<string>; symbolId?: number; edge?: GraphRow } {\n const edge = implementationEdge(db, operationId);\n if (!edge || edge.status !== 'resolved') return { files: new Set(), edge };\n const row = db.prepare('SELECT hc.repo_id repoId,hc.source_file sourceFile,s.id symbolId FROM handler_methods hm JOIN handler_classes hc ON hc.id=hm.handler_class_id LEFT JOIN symbols s ON s.repo_id=hc.repo_id AND s.source_file=hc.source_file AND s.name=hm.method_name WHERE hm.id=?').get(edge.to_id) as { repoId?: number; sourceFile?: string; symbolId?: number } | undefined;\n return { repoId: row?.repoId, files: new Set(row?.sourceFile ? [row.sourceFile] : []), symbolId: row?.symbolId, edge };\n}\nfunction contextImplementationMethodId(edge: GraphRow | undefined, callerRepoId: number | undefined): string | undefined {\n if (!edge || edge.status !== 'ambiguous' || callerRepoId === undefined) return undefined;\n const evidence = JSON.parse(String(edge.evidence_json || '{}')) as { candidates?: Array<{ accepted?: boolean; methodId?: number; handlerPackage?: { id?: number }; applicationPackage?: { id?: number } }> };\n const candidate = evidence.candidates?.find((item) => item.accepted && (Number(item.handlerPackage?.id) === callerRepoId || Number(item.applicationPackage?.id) === callerRepoId));\n return candidate?.methodId === undefined ? undefined : String(candidate.methodId);\n}\nfunction handlerScope(db: Db, methodId: string): { repoId?: number; files: Set<string>; symbolId?: number } | undefined {\n const row = db.prepare('SELECT hc.repo_id repoId,hc.source_file sourceFile,s.id symbolId FROM handler_methods hm JOIN handler_classes hc ON hc.id=hm.handler_class_id LEFT JOIN symbols s ON s.repo_id=hc.repo_id AND s.source_file=hc.source_file AND s.name=hm.method_name WHERE hm.id=?').get(methodId) as { repoId?: number; sourceFile?: string; symbolId?: number } | undefined;\n if (!row) return undefined;\n return { repoId: row.repoId, files: new Set(row.sourceFile ? [row.sourceFile] : []), symbolId: row.symbolId };\n}\n\nfunction includeCall(\n type: string,\n options: {\n includeExternal?: boolean;\n includeDb?: boolean;\n includeAsync?: boolean;\n },\n): boolean {\n if (!options.includeDb && type === 'local_db_query') return false;\n if (!options.includeExternal && type === 'external_http') return false;\n if (!options.includeAsync && type.startsWith('async_')) return false;\n return true;\n}\nfunction graphForCalls(db: Db, callIds: number[]): Map<number, GraphRow[]> {\n const map = new Map<number, GraphRow[]>();\n if (callIds.length === 0) return map;\n const rows = db\n .prepare(\n `SELECT * FROM graph_edges WHERE from_kind='call' AND from_id IN (${callIds.map(() => '?').join(',')}) ORDER BY id`,\n )\n .all(...callIds.map((id) => String(id))) as GraphRow[];\n for (const row of rows) {\n const id = Number(row.from_id);\n map.set(id, [...(map.get(id) ?? []), row]);\n }\n return map;\n}\nfunction hasRuntimeVariable(value: unknown, vars: Record<string, string>): boolean {\n return typeof value === 'string' && extractPlaceholders(value).some((key) => Object.hasOwn(vars, key));\n}\n\nfunction isRemoteRuntimeCandidate(row: GraphRow, evidence: Record<string, unknown>, vars: Record<string, string> | undefined): boolean {\n if (!vars || Object.keys(vars).length === 0) return false;\n if (!['dynamic', 'ambiguous', 'unresolved'].includes(String(row.status ?? ''))) return false;\n if (!['DYNAMIC_EDGE_CANDIDATE', 'UNRESOLVED_EDGE', 'REMOTE_CALL_RESOLVES_TO_OPERATION'].includes(row.edge_type)) return false;\n if (row.status === 'resolved') return false;\n return ['servicePath', 'operationPath', 'serviceAliasExpr', 'serviceAlias', 'destination'].some((key) => hasRuntimeVariable(evidence[key], vars));\n}\n\nfunction evidenceWithRuntimeVariables(\n evidence: Record<string, unknown>,\n vars: Record<string, string> | undefined,\n): Record<string, unknown> {\n if (!vars || Object.keys(vars).length === 0) return evidence;\n const substitutions: Record<string, RuntimeSubstitution> = {};\n for (const key of ['servicePath', 'operationPath', 'serviceAliasExpr', 'serviceAlias', 'destination']) {\n const substitution = substituteVariables(typeof evidence[key] === 'string' ? String(evidence[key]) : undefined, vars);\n if (substitution.placeholders.length > 0) substitutions[key] = substitution;\n }\n const next: Record<string, unknown> = { ...evidence, runtimeVariablesApplied: true, runtimeSubstitutions: substitutions };\n for (const [key, value] of Object.entries(substitutions)) {\n if (value.effective) next[key] = value.effective;\n }\n const missing = Object.values(substitutions).flatMap((value) => value.missing);\n if (missing.length > 0) next.missingRuntimeVariables = [...new Set(missing)];\n return next;\n}\n\n\nfunction symbolNode(db: Db, symbolId: number): Record<string, unknown> | undefined {\n const row = db.prepare(`SELECT s.id symbolId,s.name symbolName,s.qualified_name qualifiedName,s.source_file sourceFile,s.start_line startLine,s.end_line endLine,r.name repoName,r.id repoId FROM symbols s JOIN repositories r ON r.id=s.repo_id WHERE s.id=?`).get(symbolId) as Record<string, unknown> | undefined;\n if (!row) return undefined;\n const fileName = String(row.sourceFile ?? '').split('/').at(-1) ?? String(row.sourceFile ?? '');\n return { id: `symbol:${symbolId}`, kind: 'symbol', label: `${fileName}:${String(row.qualifiedName ?? row.symbolName)}`, ...row };\n}\n\nfunction operationNode(db: Db, operationId: string): Record<string, unknown> | undefined {\n const row = db.prepare(`SELECT o.id operationId,o.operation_name operationName,o.operation_type operationType,o.operation_path operationPath,o.source_file sourceFile,o.source_line sourceLine,s.id serviceId,s.service_name serviceName,s.qualified_name qualifiedName,s.service_path servicePath,r.id repoId,r.name repoName FROM cds_operations o JOIN cds_services s ON s.id=o.service_id JOIN repositories r ON r.id=s.repo_id WHERE o.id=?`).get(operationId) as Record<string, unknown> | undefined;\n if (!row) return undefined;\n return { id: `operation:${operationId}`, kind: 'operation', label: `${String(row.repoName)}:${String(row.servicePath)}${String(row.operationPath)}`, ...row };\n}\nfunction workspaceIdForCall(db: Db, callId: string): number | undefined {\n return (db.prepare('SELECT r.workspace_id workspaceId FROM outbound_calls c JOIN repositories r ON r.id=c.repo_id WHERE c.id=?').get(callId) as { workspaceId?: number } | undefined)?.workspaceId;\n}\nfunction runtimeResolution(db: Db, row: GraphRow, evidence: Record<string, unknown>, vars: Record<string, string> | undefined): { row: GraphRow; evidence: Record<string, unknown>; target?: OperationTarget; unresolvedReason?: string } {\n if (!isRemoteRuntimeCandidate(row, evidence, vars))\n return { row, evidence, unresolvedReason: row.unresolved_reason };\n const nextEvidence = evidenceWithRuntimeVariables(evidence, vars);\n const servicePath = typeof nextEvidence.servicePath === 'string' ? nextEvidence.servicePath : undefined;\n const operationPath = typeof nextEvidence.operationPath === 'string' ? nextEvidence.operationPath : undefined;\n const alias = typeof nextEvidence.serviceAliasExpr === 'string' ? nextEvidence.serviceAliasExpr : typeof nextEvidence.serviceAlias === 'string' ? nextEvidence.serviceAlias : undefined;\n const destination = typeof nextEvidence.destination === 'string' ? nextEvidence.destination : undefined;\n const resolution = resolveOperation(db, { servicePath, operationPath, alias, destination, hasExplicitOverride: true, isDynamic: true }, workspaceIdForCall(db, row.from_id));\n nextEvidence.runtimeResolutionStatus = resolution.status;\n nextEvidence.runtimeResolutionReasons = resolution.reasons;\n if (resolution.target) {\n nextEvidence.runtimeResolvedCandidate = resolution.target;\n return { row: { ...row, to_kind: 'operation', to_id: String(resolution.target.operationId), unresolved_reason: undefined, confidence: Math.max(0, Math.min(1, resolution.target.score)) }, evidence: nextEvidence, target: resolution.target };\n }\n const unresolvedReason = resolution.status === 'dynamic' ? `Dynamic target is missing runtime variables: ${resolution.reasons.join(', ')}` : resolution.status === 'ambiguous' ? 'Ambiguous runtime operation candidates' : 'No runtime operation candidate matched substituted service and operation path';\n return { row, evidence: nextEvidence, unresolvedReason };\n}\nfunction edgeTarget(row: GraphRow, evidence: Record<string, unknown>): string {\n const runtimeCandidate = evidence.runtimeResolvedCandidate as\n | Candidate\n | undefined;\n if (runtimeCandidate?.servicePath && runtimeCandidate.operationPath)\n return `${runtimeCandidate.servicePath}${runtimeCandidate.operationPath}`;\n const servicePath =\n typeof evidence.servicePath === 'string' ? evidence.servicePath : undefined;\n const operationPath =\n typeof evidence.operationPath === 'string'\n ? evidence.operationPath\n : undefined;\n const targetOperation =\n typeof evidence.targetOperation === 'string'\n ? evidence.targetOperation\n : undefined;\n const targetRepo =\n typeof evidence.targetRepo === 'string' ? evidence.targetRepo : '';\n if (row.edge_type === 'HANDLER_RUNS_DB_QUERY') return `Entity: ${row.to_id || 'unknown'}`;\n return servicePath && operationPath\n ? `${servicePath}${operationPath}`\n : targetOperation\n ? `${targetRepo}:${targetOperation}`\n : row.to_id;\n}\nexport function trace(\n db: Db,\n start: TraceStart,\n options: {\n depth: number;\n vars?: Record<string, string>;\n includeExternal?: boolean;\n includeDb?: boolean;\n includeAsync?: boolean;\n },\n): TraceResult {\n const scope = startScope(db, start);\n const diagnostics = db\n .prepare(\n 'SELECT severity,code,message,source_file sourceFile,source_line sourceLine FROM diagnostics WHERE (? IS NULL OR repo_id=?)',\n )\n .all(scope.repo?.id, scope.repo?.id) as Array<Record<string, unknown>>;\n const stale = db.prepare('SELECT name,graph_stale_reason reason FROM repositories WHERE graph_stale_reason IS NOT NULL AND (? IS NULL OR id=?)').all(scope.repo?.id, scope.repo?.id) as Array<{ name?: string; reason?: string }>;\n for (const row of stale)\n diagnostics.unshift({ severity: 'warning', code: 'graph_stale', message: `Graph is stale for ${row.name ?? 'repository'}: ${row.reason ?? 'facts_changed'}. Run service-flow link.` });\n if (!scope.selectorMatched)\n diagnostics.unshift({\n severity: 'warning',\n code: 'trace_start_not_found',\n message: start.servicePath && !start.operation && !start.operationPath && !start.handler ? 'Service-only trace requires --operation or --path and will not broaden to the whole workspace' : 'No handler source matched the requested trace start selector',\n });\n const maxDepth = positiveDepth(options.depth);\n const edges: TraceEdge[] = [];\n const nodes = new Map<string, Record<string, unknown>>();\n const queue: Array<{ repoId?: number; files?: Set<string>; symbolIds?: Set<number>; depth: number }> =\n scope.selectorMatched\n ? [{ repoId: scope.repo?.id, files: scope.sourceFiles, symbolIds: scope.symbolIds, depth: 1 }]\n : [];\n if (start.servicePath && (start.operation ?? start.operationPath)) {\n const startOperation = normalizeOperation(start.operation ?? start.operationPath);\n const startRows = db.prepare(`SELECT o.id operationId,r.name repoName,s.service_path servicePath,o.operation_path operationPath,o.operation_name operationName,o.source_file sourceFile,o.source_line sourceLine FROM cds_operations o JOIN cds_services s ON s.id=o.service_id JOIN repositories r ON r.id=s.repo_id WHERE (? IS NULL OR s.repo_id=?) AND s.service_path=? AND (o.operation_path=? OR o.operation_name=?) ORDER BY r.name,o.id LIMIT 2`).all(scope.repo?.id, scope.repo?.id, start.servicePath, startOperation, startOperation) as Array<Record<string, unknown>>;\n if (!scope.repo && startRows.length > 1) diagnostics.unshift({ severity: 'warning', code: 'trace_start_ambiguous', message: 'Service/path trace start matched multiple repositories; add --repo to disambiguate', candidates: startRows });\n const row = startRows.length === 1 ? startRows[0] : undefined;\n if (row?.operationId !== undefined) {\n const opId = String(row.operationId);\n const op = operationNode(db, opId);\n const impl = implementationScope(db, opId);\n if (op) nodes.set(String(op.id), op);\n if (impl.edge) {\n const implEvidence = JSON.parse(String(impl.edge.evidence_json || '{}')) as Record<string, unknown>;\n const handlerNode = impl.edge.status === 'resolved' ? handlerMethodNode(db, impl.edge.to_id) : undefined;\n if (handlerNode) nodes.set(String(handlerNode.id), handlerNode);\n edges.push({ step: 1, type: 'operation_implemented_by_handler', from: op?.label ? String(op.label) : `${start.servicePath}/${startOperation ?? ''}`, to: handlerNode?.label ? String(handlerNode.label) : `${impl.edge.to_kind}:${impl.edge.to_id}`, evidence: implEvidence, confidence: Number(impl.edge.confidence ?? 0), unresolvedReason: impl.edge.status === 'resolved' ? undefined : String(impl.edge.unresolved_reason ?? impl.edge.status) });\n }\n }\n }\n const seenScopes = new Set<string>();\n const seenEdges = new Set<number>();\n while (queue.length > 0) {\n const current = queue.shift();\n if (!current || current.depth > maxDepth) continue;\n const key = `${current.repoId ?? '*'}:${[...(current.symbolIds ?? new Set(['*']))].sort().join(',')}:${[...(current.files ?? new Set(['*']))].sort().join(',')}`;\n if (seenScopes.has(key)) continue;\n seenScopes.add(key);\n const calls = db\n .prepare(\n `SELECT c.*,r.name repoName FROM outbound_calls c JOIN repositories r ON r.id=c.repo_id WHERE (? IS NULL OR c.repo_id=?) ORDER BY c.source_file,c.source_line`,\n )\n .all(current.repoId, current.repoId) as CallRow[];\n const filtered = calls.filter(\n (c) =>\n (!current.symbolIds || current.symbolIds.has(Number(c.source_symbol_id))) && (!current.files || current.files.has(String(c.source_file))) &&\n includeCall(String(c.call_type), options),\n );\n\n if (current.symbolIds && current.symbolIds.size > 0 && current.depth < maxDepth) {\n const symbolRows = db.prepare(`SELECT sc.*,s.repo_id calleeRepoId,s.source_file calleeFile FROM symbol_calls sc LEFT JOIN symbols s ON s.id=sc.callee_symbol_id WHERE sc.caller_symbol_id IN (${[...current.symbolIds].map(() => '?').join(',')}) ORDER BY sc.source_file,sc.source_line`).all(...current.symbolIds) as Array<Record<string, unknown>>;\n for (const symbolCall of symbolRows) {\n if (!symbolCall.callee_symbol_id) continue;\n const nextSymbols = new Set([Number(symbolCall.callee_symbol_id)]);\n const nextFiles = new Set([String(symbolCall.calleeFile)]);\n const nextRepoId = Number(symbolCall.calleeRepoId);\n const nextKey = `${nextRepoId}:${[...nextSymbols].join(',')}:${[...nextFiles].join(',')}`;\n const calleeNode = symbolNode(db, Number(symbolCall.callee_symbol_id));\n if (calleeNode) nodes.set(String(calleeNode.id), calleeNode);\n const evidence = { ...(JSON.parse(String(symbolCall.evidence_json || '{}')) as Record<string, unknown>), sourceFile: symbolCall.source_file, sourceLine: symbolCall.source_line, calleeSymbolId: symbolCall.callee_symbol_id, calleeSymbolName: calleeNode?.symbolName, calleeSymbolFile: calleeNode?.sourceFile, resolutionStatus: symbolCall.status };\n edges.push({ step: current.depth, type: 'local_symbol_call', from: String(symbolCall.callee_expression), to: calleeNode?.label ? String(calleeNode.label) : `symbol:${String(symbolCall.callee_symbol_id)}`, evidence, confidence: Number(symbolCall.confidence ?? 0.8), unresolvedReason: String(symbolCall.status) === 'resolved' ? undefined : symbolCall.unresolved_reason ? String(symbolCall.unresolved_reason) : undefined });\n if (seenScopes.has(nextKey)) edges.push({ step: current.depth, type: 'cycle', from: String(symbolCall.callee_expression), to: nextKey, evidence: { cycle: true, symbolCallId: symbolCall.id }, confidence: 1, unresolvedReason: 'Cycle detected; downstream symbol already visited' });\n else queue.push({ repoId: nextRepoId, files: nextFiles, symbolIds: nextSymbols, depth: current.depth + 1 });\n }\n }\n const graph = graphForCalls(\n db,\n filtered.map((c) => Number(c.id)),\n );\n for (const call of filtered) {\n const callNode = `call:${call.id}`;\n nodes.set(callNode, {\n id: callNode,\n kind: 'outbound_call',\n repo: call.repoName,\n file: call.source_file,\n line: call.source_line,\n callType: call.call_type,\n });\n const graphRows = graph.get(Number(call.id)) ?? [];\n for (const row of graphRows) {\n if (seenEdges.has(Number(row.id))) continue;\n seenEdges.add(Number(row.id));\n const rawEvidence = JSON.parse(\n String(row.evidence_json || '{}'),\n ) as Record<string, unknown>;\n const effective = runtimeResolution(db, row, rawEvidence, options.vars);\n const evidence = effective.evidence;\n const effectiveRow = effective.row;\n const targetNode = `${effectiveRow.to_kind}:${effectiveRow.to_id}`;\n const opNode = effectiveRow.to_kind === 'operation' ? operationNode(db, effectiveRow.to_id) : undefined;\n nodes.set(targetNode, opNode ?? {\n id: targetNode,\n kind: effectiveRow.to_kind,\n label: effectiveRow.to_kind === 'db_entity' ? `Entity: ${effectiveRow.to_id || 'unknown'}` : effectiveRow.to_id,\n });\n const to = edgeTarget(effectiveRow, evidence);\n edges.push({\n step: current.depth,\n type: String(call.call_type),\n from: `${call.repoName}:${call.source_file}:${call.source_line}`,\n to,\n evidence,\n confidence: Number(effectiveRow.confidence ?? call.confidence),\n unresolvedReason: effective.unresolvedReason,\n });\n if (effectiveRow.to_kind === 'operation') {\n const implementation = implementationScope(db, effectiveRow.to_id);\n const contextMethodId = contextImplementationMethodId(implementation.edge, current.repoId);\n const contextNode = contextMethodId ? handlerMethodNode(db, contextMethodId) : undefined;\n if (implementation.edge) {\n const implEvidence = JSON.parse(String(implementation.edge.evidence_json || '{}')) as Record<string, unknown>;\n const handlerNode = implementation.edge.status === 'resolved' ? handlerMethodNode(db, implementation.edge.to_id) : contextNode;\n const implTo = handlerNode?.label ? String(handlerNode.label) : `${implementation.edge.to_kind}:${implementation.edge.to_id}`;\n if (handlerNode) nodes.set(String(handlerNode.id), handlerNode);\n edges.push({\n step: current.depth,\n type: 'operation_implemented_by_handler',\n from: to,\n to: implTo,\n evidence: implEvidence,\n confidence: Number(implementation.edge.confidence ?? 0),\n unresolvedReason: implementation.edge.status === 'resolved' ? undefined : String(implementation.edge.unresolved_reason ?? implementation.edge.status),\n });\n }\n if (current.depth >= maxDepth) continue;\n const contextScope = contextMethodId ? handlerScope(db, contextMethodId) : undefined;\n const files = contextScope?.files ?? (implementation.files.size > 0 ? implementation.files : handlerFilesForOperation(db, effectiveRow.to_id));\n const symbolIds = contextScope?.symbolId ? new Set([contextScope.symbolId]) : implementation.symbolId ? new Set([implementation.symbolId]) : undefined;\n if ((implementation.edge?.status === 'resolved' || contextScope) && files.size > 0) {\n const targetRepoId = contextScope?.repoId ?? implementation.repoId ?? (db\n .prepare(\n 'SELECT s.repo_id repoId FROM cds_operations o JOIN cds_services s ON s.id=o.service_id WHERE o.id=?',\n )\n .get(effectiveRow.to_id)?.repoId as number | undefined);\n const nextKey = `${targetRepoId ?? '*'}:${[...(symbolIds ?? new Set(['*']))].sort().join(',')}:${[...files].sort().join(',')}`;\n if (seenScopes.has(nextKey))\n edges.push({\n step: current.depth,\n type: 'cycle',\n from: to,\n to: nextKey,\n evidence: { ...evidence, cycle: true },\n confidence: 1,\n unresolvedReason:\n 'Cycle detected; downstream scope already visited',\n });\n else\n queue.push({\n repoId: targetRepoId,\n files,\n symbolIds,\n depth: current.depth + 1,\n });\n }\n }\n }\n }\n }\n return { start, nodes: [...nodes.values()], edges, diagnostics };\n}\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAOA,WAAU;;;ACDjB,OAAO,UAAU;AACV,SAAS,cAAc,OAAuB;AACnD,SAAO,MAAM,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AACvC;AACO,SAAS,aAAa,MAAc,OAAuB;AAChE,SAAO,cAAc,KAAK,SAAS,MAAM,KAAK,KAAK,GAAG;AACxD;AACO,SAAS,mBAAmB,OAAuB;AACxD,SAAO,MAAM,WAAW,GAAG,IAAI,QAAQ,IAAI,KAAK;AAClD;AACO,SAAS,YAAY,OAAuB;AACjD,SAAO,MAAM,QAAQ,kBAAkB,EAAE;AAC3C;;;ADRA,eAAsB,qBACpB,UACA,QACiC;AACjC,QAAM,OAAOC,MAAK,QAAQ,QAAQ;AAClC,QAAM,UAAU,IAAI,IAAI,MAAM;AAC9B,QAAM,QAAgC,CAAC;AACvC,iBAAe,gBAAgB,KAA+B;AAC5D,UAAM,UAAUA,MAAK,KAAK,KAAK,MAAM;AACrC,QAAI;AACF,YAAM,KAAK,MAAM,GAAG,KAAK,OAAO;AAChC,UAAI,GAAG,YAAY,GAAG;AACpB,cAAM,WAAW,MAAM,GAAG,QAAQ,OAAO;AACzC,eAAO,SAAS,SAAS,MAAM,KAAK,SAAS,SAAS,QAAQ;AAAA,MAChE;AACA,UAAI,GAAG,OAAO,GAAG;AACf,cAAM,OAAO,MAAM,GAAG,SAAS,SAAS,MAAM;AAC9C,eAAO,KAAK,UA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f","ts","path","fs","fs","path","ts","lineOf","firstArg","ts","fs","path","fs","path","ts","lineOf","ts","fs","path","visit","placeholders","rows","rows"]}