@dimassetoid/septum-mcp 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -28
- package/package.json +4 -4
- package/src/cli/commands/check.ts +27 -16
- package/src/cli/commands/hook.ts +38 -101
- package/src/cli/commands/init.ts +26 -9
- package/src/cli/commands/sync.ts +4 -6
- package/src/cli/hook-payload.ts +43 -0
- package/src/cli/index.ts +9 -52
- package/src/cli/scaffold/harness-config.ts +48 -8
- package/src/cli/templates/hooks.ts +49 -14
- package/src/cli/templates/rules.ts +34 -49
- package/src/cli/templates/skill.ts +39 -35
- package/src/core/boundary/evaluator.ts +67 -83
- package/src/core/boundary/staged-auditor.ts +102 -40
- package/src/core/config/domain-ownership.ts +45 -0
- package/src/core/config/loader.ts +81 -29
- package/src/core/config/schema.ts +0 -10
- package/src/core/database/repositories/dependency.repository.ts +169 -148
- package/src/core/database/repositories/domain.repository.ts +46 -3
- package/src/core/database/repositories/symbol.repository.ts +226 -87
- package/src/core/database/repository.ts +73 -18
- package/src/core/database/schema.ts +2 -33
- package/src/core/discovery/navigation.ts +105 -0
- package/src/core/discovery/topology-detector.ts +60 -2
- package/src/core/ingestion/pipeline.ts +96 -129
- package/src/core/parser/behavioral-analyzer.ts +26 -22
- package/src/core/parser/boundary-tracker.ts +15 -0
- package/src/core/parser/extractors/base.ts +7 -3
- package/src/core/parser/extractors/csharp.ts +7 -3
- package/src/core/parser/extractors/django-semantic.ts +4 -36
- package/src/core/parser/extractors/elysia-semantic.ts +3 -24
- package/src/core/parser/extractors/express-semantic.ts +3 -18
- package/src/core/parser/extractors/fastapi-semantic.ts +19 -53
- package/src/core/parser/extractors/fastify-semantic.ts +3 -18
- package/src/core/parser/extractors/flask-semantic.ts +22 -55
- package/src/core/parser/extractors/go-semantic.ts +92 -33
- package/src/core/parser/extractors/hono-semantic.ts +3 -24
- package/src/core/parser/extractors/java.ts +5 -3
- package/src/core/parser/extractors/laravel-semantic.ts +44 -16
- package/src/core/parser/extractors/mcp-cli-semantic.ts +6 -7
- package/src/core/parser/extractors/nestjs-semantic.ts +3 -19
- package/src/core/parser/extractors/php.ts +16 -0
- package/src/core/parser/extractors/python.ts +9 -4
- package/src/core/parser/extractors/registry.ts +26 -5
- package/src/core/parser/extractors/ruby.ts +8 -5
- package/src/core/parser/extractors/rust.ts +31 -13
- package/src/core/parser/extractors/semantic-extractor.interface.ts +3 -1
- package/src/core/parser/extractors/symfony-semantic.ts +4 -37
- package/src/core/parser/extractors/typescript.ts +14 -1
- package/src/core/parser/implementation-fingerprint.ts +97 -0
- package/src/core/parser/language-capabilities.ts +23 -7
- package/src/core/parser/schema/providers/laravel-migration-provider.ts +73 -50
- package/src/core/parser/schema/schema-provider-registry.ts +1 -3
- package/src/core/parser/schema/schema-provider.interface.ts +2 -1
- package/src/core/parser/semantic-revision.ts +3 -0
- package/src/core/parser/static-string.ts +51 -0
- package/src/core/resolver/call-graph-tracer.ts +337 -28
- package/src/core/resolver/import-resolver.ts +107 -179
- package/src/core/resolver/interpretation-inputs.ts +7 -0
- package/src/core/resolver/languages/go.ts +103 -0
- package/src/core/resolver/languages/managed.ts +200 -0
- package/src/core/resolver/languages/python.ts +115 -0
- package/src/core/resolver/languages/ruby.ts +40 -0
- package/src/core/resolver/languages/rust.ts +127 -0
- package/src/core/resolver/languages/shared.ts +71 -0
- package/src/core/resolver/module-resolver.ts +8 -4
- package/src/core/resolver/slice-catalog.ts +79 -0
- package/src/core/resolver/slice-format.ts +9 -0
- package/src/core/resolver/symbol-impact.ts +381 -0
- package/src/core/resolver/vertical-slice-tracer.ts +93 -115
- package/src/core/resources/ignore.ts +22 -1
- package/src/core/resources/source-files.ts +143 -20
- package/src/core/resources/source-inventory.ts +55 -0
- package/src/core/retrieval/context-page.ts +109 -0
- package/src/core/retrieval/context.ts +320 -0
- package/src/core/retrieval/resolution-warnings.ts +21 -0
- package/src/core/retrieval/symbol-evidence.ts +97 -0
- package/src/core/retrieval/typescript-references.ts +262 -0
- package/src/core/telemetry/telemetry.ts +54 -9
- package/src/index.ts +0 -3
- package/src/mcp/schemas.ts +61 -420
- package/src/mcp/server.ts +116 -290
- package/src/mcp/tools/boundary.ts +2 -2
- package/src/mcp/tools/check-boundary.ts +55 -60
- package/src/mcp/tools/get-domain-catalog.ts +32 -219
- package/src/mcp/tools/get-symbol-impact.ts +45 -5
- package/src/mcp/tools/get-symbol.ts +227 -3
- package/src/mcp/tools/locate-symbol.ts +54 -14
- package/src/mcp/tools/{domain.ts → map.ts} +4 -18
- package/src/mcp/tools/register-domain.ts +41 -3
- package/src/mcp/tools/symbol.ts +23 -21
- package/src/mcp/tools/trace-vertical-slice.ts +36 -10
- package/src/mcp/workspace-manager.ts +15 -4
- package/src/mcp/workspace-watcher.ts +8 -8
- package/src/types/index.ts +35 -53
- package/src/cli/commands/topology.ts +0 -161
- package/src/core/database/repositories/environment.repository.ts +0 -207
- package/src/core/parser/schema/providers/prisma-schema-provider.ts +0 -90
- package/src/core/session/session-manager.ts +0 -107
- package/src/core/topology/environment-detector.ts +0 -973
- package/src/core/topology/types.ts +0 -83
- package/src/mcp/tools/feature.ts +0 -67
- package/src/mcp/tools/get-environment-topology.ts +0 -138
- package/src/mcp/tools/get-feature-context.ts +0 -224
- package/src/mcp/tools/get-symbol-hotspots.ts +0 -54
- package/src/mcp/tools/register-feature.ts +0 -110
|
@@ -3,6 +3,7 @@ import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
|
3
3
|
import { VerticalSliceTracer } from "../../core/resolver/vertical-slice-tracer.ts";
|
|
4
4
|
import type { VerticalSliceTraceResponse } from "../../types/index.ts";
|
|
5
5
|
import type { TraceVerticalSliceArgs } from "../schemas.ts";
|
|
6
|
+
import { formatSliceNode, SLICE_RELATIONSHIP_LIMITS } from "../../core/resolver/slice-format.ts";
|
|
6
7
|
|
|
7
8
|
export type { TraceVerticalSliceArgs } from "../schemas.ts";
|
|
8
9
|
|
|
@@ -33,35 +34,54 @@ export function handleTraceVerticalSlice(
|
|
|
33
34
|
process.cwd();
|
|
34
35
|
const maxDepth = Math.min(Math.max(Math.trunc(Number(args.max_depth ?? 5)), 1), 8);
|
|
35
36
|
const tracer = new VerticalSliceTracer(repo, root, config.settings.ignore_patterns, false);
|
|
36
|
-
return tracer.traceAsync(query, maxDepth, signal).then((result: VerticalSliceTraceResponse) => {
|
|
37
|
+
return tracer.traceAsync(query, maxDepth, signal, args.controller_file).then((result: VerticalSliceTraceResponse) => {
|
|
37
38
|
const chain = result.chain || result.slice || [];
|
|
38
39
|
|
|
39
40
|
let summary = "";
|
|
40
41
|
if (result.found && chain.length > 0) {
|
|
41
|
-
summary = chain
|
|
42
|
-
.map((node) => `[${(node.stage || "STAGE").toUpperCase()}] ${node.symbol}`)
|
|
43
|
-
.join(" ➔ ");
|
|
42
|
+
summary = chain.map(formatSliceNode).join("\n");
|
|
44
43
|
} else if (result.found && result.entrypoint) {
|
|
45
|
-
summary = `[ENTRYPOINT] ${result.entrypoint.method} ${result.entrypoint.uri}
|
|
46
|
-
} else if (result.diagnostics?.length
|
|
44
|
+
summary = `[ENTRYPOINT] ${result.entrypoint.method} ${result.entrypoint.uri}; catalog handler ${result.entrypoint.controller}@${result.entrypoint.action} [unknown; unknown]`;
|
|
45
|
+
} else if (result.diagnostics?.length) {
|
|
47
46
|
summary = ` [UNKNOWN] ${result.message || `No matching slice in the available static catalog for '${query}'.`}`.trim();
|
|
48
47
|
} else {
|
|
49
48
|
summary = `[NOT FOUND] No matching slice in the available static catalog for '${query}'; this does not prove the route is absent at runtime.`;
|
|
50
49
|
}
|
|
50
|
+
if (result.diagnostics?.includes("ambiguous_target")) {
|
|
51
|
+
summary = `[AMBIGUOUS] ${result.message}`;
|
|
52
|
+
} else if (result.diagnostics?.length && result.found) {
|
|
53
|
+
summary = `[UNKNOWN: ${result.diagnostics.join(", ")}]\n${summary}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const nextHints = result.next ?? [
|
|
57
|
+
result.found && result.entrypoint?.action && result.entrypoint?.file
|
|
58
|
+
? `Use septum_symbol(action='context', query='${result.entrypoint.action}', file_path='${result.entrypoint.file}') to inspect handler source/contracts; read the selected mode, freshness and omissions.`
|
|
59
|
+
: result.found
|
|
60
|
+
? "Inspect the selected implementation and unresolved relationships before planning edits."
|
|
61
|
+
: "Refine the query or synchronize the workspace; no match does not prove runtime absence.",
|
|
62
|
+
];
|
|
51
63
|
|
|
52
64
|
const payload = {
|
|
53
|
-
status: result.diagnostics?.length ? "unknown" : result.found ? "success" : "not_found",
|
|
65
|
+
status: result.diagnostics?.includes("ambiguous_target") ? "ambiguous" : result.diagnostics?.length ? "unknown" : result.found ? "success" : "not_found",
|
|
54
66
|
coverage: result.coverage,
|
|
55
67
|
diagnostics: result.diagnostics,
|
|
68
|
+
next: nextHints,
|
|
69
|
+
controller_file_filter: args.controller_file ?? null,
|
|
56
70
|
query,
|
|
57
71
|
found: result.found,
|
|
58
|
-
confidence: result.confidence
|
|
72
|
+
confidence: result.confidence,
|
|
73
|
+
confidence_scope: "query_to_catalog_target_only",
|
|
74
|
+
relationship_limits: SLICE_RELATIONSHIP_LIMITS,
|
|
75
|
+
execution_order: "not_established",
|
|
76
|
+
branch_scope: "Static relationships can span mutually exclusive handler actions; this is not one executed branch.",
|
|
59
77
|
is_exact_match: result.is_exact_match,
|
|
60
78
|
architecture_style: result.architecture_style,
|
|
61
79
|
max_depth_applied: result.max_depth_applied ?? maxDepth,
|
|
62
80
|
entrypoint: result.entrypoint || null,
|
|
63
81
|
chain,
|
|
64
82
|
alternatives: result.alternatives || [],
|
|
83
|
+
candidate_count: result.candidate_count,
|
|
84
|
+
alternatives_omitted: result.alternatives_omitted,
|
|
65
85
|
summary,
|
|
66
86
|
message: result.message || summary,
|
|
67
87
|
};
|
|
@@ -70,10 +90,16 @@ export function handleTraceVerticalSlice(
|
|
|
70
90
|
content: [
|
|
71
91
|
{
|
|
72
92
|
type: "text" as const,
|
|
73
|
-
text: JSON.stringify(payload
|
|
93
|
+
text: JSON.stringify(payload),
|
|
74
94
|
},
|
|
75
95
|
],
|
|
76
|
-
metadata:
|
|
96
|
+
metadata: {
|
|
97
|
+
status: payload.status,
|
|
98
|
+
found: payload.found,
|
|
99
|
+
confidence: payload.confidence,
|
|
100
|
+
query: payload.query,
|
|
101
|
+
chain_length: payload.chain.length,
|
|
102
|
+
},
|
|
77
103
|
};
|
|
78
104
|
});
|
|
79
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, realpathSync, statSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
4
|
-
import { ConfigLoader } from '../core/config/loader.ts';
|
|
4
|
+
import { ConfigLoader, resolveDatabasePath } from '../core/config/loader.ts';
|
|
5
5
|
import type { ValidatedSeptumConfig } from '../core/config/schema.ts';
|
|
6
6
|
import { SeptumDatabase } from '../core/database/client.ts';
|
|
7
7
|
import { SeptumRepository } from '../core/database/repository.ts';
|
|
@@ -12,6 +12,7 @@ import { IngestionPipeline } from '../core/ingestion/pipeline.ts';
|
|
|
12
12
|
import { RESOURCE_LIMITS } from '../core/resources/limits.ts';
|
|
13
13
|
import { SerialWorkQueue } from '../core/resources/work-queue.ts';
|
|
14
14
|
import { WatchBudget, WorkspaceWatcher } from './workspace-watcher.ts';
|
|
15
|
+
import { DomainRootConflictError } from '../core/config/domain-ownership.ts';
|
|
15
16
|
|
|
16
17
|
export function resolveServerWorkspace(options: {workspacePath?: string; filePath?: string; fallbackRoot?: string; knownRoots?: string[]; initial?: boolean; cwd?: string} = {}): string {
|
|
17
18
|
const cwd = options.cwd || process.cwd();
|
|
@@ -91,7 +92,7 @@ export class WorkspaceManager {
|
|
|
91
92
|
get syncDurationMs(): number { return Math.max(0, ...[...this.contexts.values()].map(entry => Number(entry.context.repo.getMeta("sync_duration_ms") || 0))); }
|
|
92
93
|
get pendingPaths(): number { return [...this.contexts.values()].reduce((n, entry) => n + entry.context.watcher.pendingCount, 0); }
|
|
93
94
|
|
|
94
|
-
acquire(rawRoot: string): WorkspaceLease {
|
|
95
|
+
acquire(rawRoot: string, options: { deferDiscovery?: boolean } = {}): WorkspaceLease {
|
|
95
96
|
if (this.closed) throw new Error('Septum server is shutting down');
|
|
96
97
|
const root = realpathSync(rawRoot);
|
|
97
98
|
let entry = this.contexts.get(root);
|
|
@@ -102,13 +103,23 @@ export class WorkspaceManager {
|
|
|
102
103
|
this.dispose(idle);
|
|
103
104
|
}
|
|
104
105
|
const config = ConfigLoader.load(undefined, root);
|
|
105
|
-
const db = new SeptumDatabase(
|
|
106
|
+
const db = new SeptumDatabase(resolveDatabasePath(root, config.settings.db_path));
|
|
106
107
|
try {
|
|
107
108
|
const repo = new SeptumRepository(db.raw);
|
|
108
109
|
const pipeline = new IngestionPipeline(repo, root);
|
|
109
110
|
const evaluator = new BoundaryEvaluator(repo, new ModuleResolver(root, repo));
|
|
110
111
|
const abort = new AbortController();
|
|
111
|
-
const ready = this.queue.run(async () => {
|
|
112
|
+
const ready = this.queue.run(async () => {
|
|
113
|
+
abort.signal.throwIfAborted();
|
|
114
|
+
// An explicit first registration chooses ownership before discovery.
|
|
115
|
+
if (options.deferDiscovery && Object.keys(config.domains).length === 0 && repo.getAllDomains().length === 0) return;
|
|
116
|
+
try { await pipeline.run(config, {verifyContent:true,signal:abort.signal}); }
|
|
117
|
+
catch (error) {
|
|
118
|
+
// Keep a conflicting legacy workspace open for explicit domain repair.
|
|
119
|
+
// Its index remains in error and cannot serve normal tool requests.
|
|
120
|
+
if (!(error instanceof DomainRootConflictError)) throw error;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
112
123
|
const watcher = new WorkspaceWatcher(root, repo, pipeline, ready, this.queue, this.budget, () => ConfigLoader.load(undefined, root));
|
|
113
124
|
entry = {context:{root,config,db,repo,evaluator,pipeline,ready,watcher},leases:0,lastUsed:this.now(),initializing:true,abort};
|
|
114
125
|
this.contexts.set(root, entry);
|
|
@@ -4,6 +4,7 @@ import type { ValidatedSeptumConfig } from '../core/config/schema.ts';
|
|
|
4
4
|
import type { SeptumRepository } from '../core/database/repository.ts';
|
|
5
5
|
import type { IngestionPipeline } from '../core/ingestion/pipeline.ts';
|
|
6
6
|
import { ASTParserEngine } from '../core/parser/tree-sitter.ts';
|
|
7
|
+
import { isResolutionInput } from '../core/resolver/interpretation-inputs.ts';
|
|
7
8
|
import { shouldIgnoreSourcePath } from '../core/resources/ignore.ts';
|
|
8
9
|
import { RESOURCE_LIMITS } from '../core/resources/limits.ts';
|
|
9
10
|
import { SerialWorkQueue } from '../core/resources/work-queue.ts';
|
|
@@ -71,9 +72,6 @@ export class WorkspaceWatcher {
|
|
|
71
72
|
this.config = config;
|
|
72
73
|
const seen = new Set<string>();
|
|
73
74
|
const stack = [this.root];
|
|
74
|
-
const domainRoots = Object.values(config.domains || {})
|
|
75
|
-
.map(d => relative(this.root, resolve(this.root, d.root)).replace(/\\/g, '/').replace(/^\/|\/$/g, ''))
|
|
76
|
-
.filter(dr => dr !== '.' && dr !== '');
|
|
77
75
|
try {
|
|
78
76
|
while (stack.length) {
|
|
79
77
|
const dir = stack.pop()!;
|
|
@@ -99,10 +97,8 @@ export class WorkspaceWatcher {
|
|
|
99
97
|
const childDir = join(dir, entry.name);
|
|
100
98
|
const childRel = relative(this.root, childDir).replace(/\\/g, '/');
|
|
101
99
|
if (shouldIgnoreSourcePath(childRel, config.settings.ignore_patterns)) continue;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (!isRelevant) continue;
|
|
105
|
-
}
|
|
100
|
+
// Semantic inputs may live outside registered domain roots.
|
|
101
|
+
// The shared watch budget still bounds this workspace inventory.
|
|
106
102
|
stack.push(childDir);
|
|
107
103
|
}
|
|
108
104
|
}
|
|
@@ -122,7 +118,7 @@ export class WorkspaceWatcher {
|
|
|
122
118
|
if (isAbsolute(rel) || rel === '..' || rel.startsWith('../') || shouldIgnoreSourcePath(norm, this.config.settings.ignore_patterns)) return;
|
|
123
119
|
let directory = this.watches.has(target);
|
|
124
120
|
try { directory ||= lstatSync(target).isDirectory(); } catch { /* deletion */ }
|
|
125
|
-
if (directory ||
|
|
121
|
+
if (directory || isResolutionInput(norm)) {
|
|
126
122
|
this.reconcile = true;
|
|
127
123
|
this.pending.clear();
|
|
128
124
|
} else if (ASTParserEngine.isSourceFile(norm)) {
|
|
@@ -138,6 +134,10 @@ export class WorkspaceWatcher {
|
|
|
138
134
|
}
|
|
139
135
|
|
|
140
136
|
async flush(forceVerify = true, signal?: AbortSignal): Promise<void> {
|
|
137
|
+
if (this.closed) return;
|
|
138
|
+
// Let already-ready FS notifications arrive before inspecting pending work.
|
|
139
|
+
// MCP requests and native watcher events can be queued in the same turn.
|
|
140
|
+
await new Promise<void>(done => setImmediate(done));
|
|
141
141
|
if (this.closed) return;
|
|
142
142
|
signal?.throwIfAborted();
|
|
143
143
|
if (this.timer) { clearTimeout(this.timer); this.timer = null; }
|
package/src/types/index.ts
CHANGED
|
@@ -42,7 +42,6 @@ export interface SeptumConfig {
|
|
|
42
42
|
ignore_patterns?: string[];
|
|
43
43
|
};
|
|
44
44
|
domains: Record<string, DomainConfig>;
|
|
45
|
-
features?: Record<string, FeatureConfig>;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
export interface DomainConfig {
|
|
@@ -53,53 +52,10 @@ export interface DomainConfig {
|
|
|
53
52
|
description?: string;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
export interface FeatureConfig {
|
|
57
|
-
domain: string;
|
|
58
|
-
description?: string;
|
|
59
|
-
allowed_touchpoints: string[];
|
|
60
|
-
reuse_symbols?: string[];
|
|
61
|
-
input_contract?: Record<string, unknown>;
|
|
62
|
-
output_contract?: Record<string, unknown>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface FeatureContextResponse {
|
|
66
|
-
feature_key: string;
|
|
67
|
-
feature?: string;
|
|
68
|
-
domain: string;
|
|
69
|
-
description?: string;
|
|
70
|
-
allowed_touchpoints: string[];
|
|
71
|
-
reuse_symbols: Array<{
|
|
72
|
-
name: string;
|
|
73
|
-
kind: string;
|
|
74
|
-
signature?: string;
|
|
75
|
-
methods?: string[];
|
|
76
|
-
properties?: string[];
|
|
77
|
-
file_path?: string;
|
|
78
|
-
domain?: string;
|
|
79
|
-
}>;
|
|
80
|
-
input_contract: Record<string, unknown>;
|
|
81
|
-
output_contract: Record<string, unknown>;
|
|
82
|
-
governance_directives?: string[];
|
|
83
|
-
is_inferred?: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface RegisterFeatureArgs {
|
|
87
|
-
feature_key: string;
|
|
88
|
-
feature?: string;
|
|
89
|
-
domain: string;
|
|
90
|
-
description?: string;
|
|
91
|
-
allowed_touchpoints?: string[];
|
|
92
|
-
reuse_symbols?: string[];
|
|
93
|
-
input_contract?: Record<string, unknown>;
|
|
94
|
-
output_contract?: Record<string, unknown>;
|
|
95
|
-
workspace_path?: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
55
|
export interface CheckBoundaryArgs {
|
|
99
56
|
file_path?: string;
|
|
100
57
|
file_paths?: string[];
|
|
101
58
|
proposed_imports?: string[];
|
|
102
|
-
feature_key?: string;
|
|
103
59
|
scope?: "file" | "all" | "staged" | "domain";
|
|
104
60
|
domain?: string;
|
|
105
61
|
workspace_path?: string;
|
|
@@ -128,13 +84,6 @@ export interface FileRecord {
|
|
|
128
84
|
last_scanned_at: string;
|
|
129
85
|
}
|
|
130
86
|
|
|
131
|
-
export interface ActiveFeatureSession {
|
|
132
|
-
owner_id?: string;
|
|
133
|
-
feature_key: string;
|
|
134
|
-
domain: string;
|
|
135
|
-
touchpoints: string[];
|
|
136
|
-
locked_at: string;
|
|
137
|
-
}
|
|
138
87
|
|
|
139
88
|
export interface SymbolReference {
|
|
140
89
|
file_path: string;
|
|
@@ -240,8 +189,6 @@ export interface ParsedFileAST {
|
|
|
240
189
|
export type BoundaryViolationRule =
|
|
241
190
|
| "forbidden_dependency"
|
|
242
191
|
| "disallowed_dependency"
|
|
243
|
-
| "touchpoint_violation"
|
|
244
|
-
| "unknown_feature"
|
|
245
192
|
| "unmapped_domain"
|
|
246
193
|
| "circular_dependency";
|
|
247
194
|
|
|
@@ -289,6 +236,33 @@ export interface DomainCatalogResponse {
|
|
|
289
236
|
agent_hint?: string;
|
|
290
237
|
}
|
|
291
238
|
|
|
239
|
+
/** Navigation facts omit source, signatures and declaration identities. */
|
|
240
|
+
export interface NavigationFile {
|
|
241
|
+
path: string;
|
|
242
|
+
domain: string;
|
|
243
|
+
archetype: ArchetypeKind;
|
|
244
|
+
symbol_count: number;
|
|
245
|
+
anchor: string | null;
|
|
246
|
+
}
|
|
247
|
+
export interface NavigationQuery {
|
|
248
|
+
domain?: string;
|
|
249
|
+
name?: string;
|
|
250
|
+
file_filter?: string;
|
|
251
|
+
archetype_filter?: string;
|
|
252
|
+
archetype?: string;
|
|
253
|
+
detail_level?: "compact" | "full";
|
|
254
|
+
file_offset?: number;
|
|
255
|
+
file_limit?: number;
|
|
256
|
+
include_evidence?: boolean;
|
|
257
|
+
include_capabilities?: boolean;
|
|
258
|
+
}
|
|
259
|
+
export interface NavigationEntrypoint {
|
|
260
|
+
method: string;
|
|
261
|
+
target: string;
|
|
262
|
+
file: string | null;
|
|
263
|
+
handler: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
292
266
|
export interface ExecutionChainNode {
|
|
293
267
|
relationship?: { kind: "imports" | "declares" | "member_of" | "calls" | "route_binding" | "schema_binding"; derivation: "source" | "inferred"; source?: { file: string; line: number; statement?: string }; reason: string };
|
|
294
268
|
|
|
@@ -321,6 +295,7 @@ export interface ExecutionChainNode {
|
|
|
321
295
|
mutations?: string[];
|
|
322
296
|
emits?: string[];
|
|
323
297
|
dispatches?: string[];
|
|
298
|
+
semantic_analysis?: "lexical_heuristic";
|
|
324
299
|
transactions?: boolean;
|
|
325
300
|
payload_props?: string[];
|
|
326
301
|
}
|
|
@@ -345,6 +320,9 @@ export interface VerticalSliceRecord {
|
|
|
345
320
|
export interface VerticalSliceTraceResponse {
|
|
346
321
|
coverage?: "partial";
|
|
347
322
|
diagnostics?: string[];
|
|
323
|
+
next?: string[];
|
|
324
|
+
candidate_count?: number;
|
|
325
|
+
alternatives_omitted?: number;
|
|
348
326
|
query: string;
|
|
349
327
|
found: boolean;
|
|
350
328
|
confidence?: "exact" | "inferred";
|
|
@@ -367,6 +345,8 @@ export interface VerticalSliceTraceResponse {
|
|
|
367
345
|
uri: string;
|
|
368
346
|
controller: string;
|
|
369
347
|
action: string;
|
|
348
|
+
file?: string | null;
|
|
349
|
+
line?: number;
|
|
370
350
|
}>;
|
|
371
351
|
message: string;
|
|
372
352
|
}
|
|
@@ -381,6 +361,7 @@ export interface GetSymbolArgs {
|
|
|
381
361
|
include_source?: boolean;
|
|
382
362
|
source_start_line?: number;
|
|
383
363
|
source_line_limit?: number;
|
|
364
|
+
semantic_depth?: number;
|
|
384
365
|
workspace_path?: string;
|
|
385
366
|
}
|
|
386
367
|
|
|
@@ -439,6 +420,7 @@ export interface InboundCaller {
|
|
|
439
420
|
caller: string;
|
|
440
421
|
line: number;
|
|
441
422
|
kind?: string;
|
|
423
|
+
caller_kind?: string;
|
|
442
424
|
domain?: string;
|
|
443
425
|
}
|
|
444
426
|
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { SeptumDatabase } from "../../core/database/client.ts";
|
|
3
|
-
import { SeptumRepository } from "../../core/database/repository.ts";
|
|
4
|
-
import { EnvironmentDetector } from "../../core/topology/environment-detector.ts";
|
|
5
|
-
import type { EnvironmentLayer, TopologyNode } from "../../core/topology/types.ts";
|
|
6
|
-
|
|
7
|
-
const VALID_LAYERS = new Set<EnvironmentLayer>([
|
|
8
|
-
"edge",
|
|
9
|
-
"gateway",
|
|
10
|
-
"host",
|
|
11
|
-
"runtime",
|
|
12
|
-
"storage",
|
|
13
|
-
"telemetry",
|
|
14
|
-
]);
|
|
15
|
-
|
|
16
|
-
export async function handleTopologyCommand(
|
|
17
|
-
subcommand?: string,
|
|
18
|
-
arg1?: string,
|
|
19
|
-
arg2?: string,
|
|
20
|
-
arg3?: string,
|
|
21
|
-
arg4?: string,
|
|
22
|
-
workspaceRoot?: string
|
|
23
|
-
): Promise<void> {
|
|
24
|
-
const normalizedSub = subcommand?.trim().toLowerCase();
|
|
25
|
-
|
|
26
|
-
if (normalizedSub && normalizedSub !== "resolve" && normalizedSub !== "add-node" && normalizedSub !== "remove-node" && normalizedSub !== "clear") {
|
|
27
|
-
throw new Error(`Unknown topology subcommand: '${subcommand}'. Valid subcommands: resolve, add-node, remove-node, clear.`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (normalizedSub === "resolve") {
|
|
31
|
-
if (!arg1 || !arg2) {
|
|
32
|
-
throw new Error("Missing required arguments for 'topology resolve'. Usage: septum topology resolve <layer> <platform>");
|
|
33
|
-
}
|
|
34
|
-
const layerCandidate = arg1.trim().toLowerCase() as EnvironmentLayer;
|
|
35
|
-
if (!VALID_LAYERS.has(layerCandidate)) {
|
|
36
|
-
throw new Error(`Invalid environment layer '${arg1}'. Valid layers: ${Array.from(VALID_LAYERS).join(", ")}`);
|
|
37
|
-
}
|
|
38
|
-
} else if (normalizedSub === "add-node") {
|
|
39
|
-
if (!arg1 || !arg2 || !arg3) {
|
|
40
|
-
throw new Error("Missing required arguments for 'topology add-node'. Usage: septum topology add-node <id> <layer> <platform> [domain_or_ip]");
|
|
41
|
-
}
|
|
42
|
-
const layerCandidate = arg2.trim().toLowerCase() as EnvironmentLayer;
|
|
43
|
-
if (!VALID_LAYERS.has(layerCandidate)) {
|
|
44
|
-
throw new Error(`Invalid environment layer '${arg2}'. Valid layers: ${Array.from(VALID_LAYERS).join(", ")}`);
|
|
45
|
-
}
|
|
46
|
-
} else if (normalizedSub === "remove-node") {
|
|
47
|
-
if (!arg1) {
|
|
48
|
-
throw new Error("Missing required argument for 'topology remove-node'. Usage: septum topology remove-node <id>");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const cwd = workspaceRoot || process.cwd();
|
|
53
|
-
const dbPath = workspaceRoot ? join(workspaceRoot, ".septum/septum.db") : undefined;
|
|
54
|
-
const db = new SeptumDatabase(dbPath);
|
|
55
|
-
const repo = new SeptumRepository(db.raw);
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
if (normalizedSub === "resolve" && arg1 && arg2) {
|
|
59
|
-
const layer = arg1.trim().toLowerCase() as EnvironmentLayer;
|
|
60
|
-
const platform = arg2;
|
|
61
|
-
// Fix: Preserve existing constraints instead of overwriting with empty array
|
|
62
|
-
const existing = repo.environment.getLayer(layer);
|
|
63
|
-
repo.environment.saveLayer({
|
|
64
|
-
layer,
|
|
65
|
-
platform,
|
|
66
|
-
canonical_tag: EnvironmentDetector.matchCanonicalTag(platform),
|
|
67
|
-
status: "VERIFIED",
|
|
68
|
-
detected_from: ["CLI Manual Resolution"],
|
|
69
|
-
constraints: existing?.constraints && existing.constraints.length > 0 ? existing.constraints : [
|
|
70
|
-
`Configured manually as '${platform}'.`
|
|
71
|
-
],
|
|
72
|
-
});
|
|
73
|
-
console.log(`[Septum Topology] Layer '${layer}' successfully verified as '${platform}' in SQLite SSOT.\n`);
|
|
74
|
-
} else if (normalizedSub === "add-node" && arg1 && arg2 && arg3) {
|
|
75
|
-
const nodeId = arg1;
|
|
76
|
-
const layer = arg2.trim().toLowerCase() as EnvironmentLayer;
|
|
77
|
-
const platform = arg3;
|
|
78
|
-
const domainOrIp = arg4;
|
|
79
|
-
|
|
80
|
-
const node: TopologyNode = {
|
|
81
|
-
id: nodeId,
|
|
82
|
-
layer,
|
|
83
|
-
name: nodeId,
|
|
84
|
-
platform,
|
|
85
|
-
canonical_tag: EnvironmentDetector.matchCanonicalTag(platform),
|
|
86
|
-
domain_or_ip: domainOrIp,
|
|
87
|
-
status: "VERIFIED",
|
|
88
|
-
detected_from: ["CLI Manual Node Resolution"],
|
|
89
|
-
constraints: [`Node added manually with platform '${platform}'.`],
|
|
90
|
-
};
|
|
91
|
-
repo.environment.saveNode(node);
|
|
92
|
-
console.log(`[Septum Topology] Node '${nodeId}' (${layer.toUpperCase()}) added to distributed topology graph.\n`);
|
|
93
|
-
} else if (normalizedSub === "remove-node" && arg1) {
|
|
94
|
-
repo.environment.deleteNode(arg1);
|
|
95
|
-
console.log(`[Septum Topology] Node '${arg1}' removed from distributed topology graph.\n`);
|
|
96
|
-
} else if (normalizedSub === "clear") {
|
|
97
|
-
repo.environment.clearAll();
|
|
98
|
-
console.log("[Septum Topology] Cleared environment topology and nodes in SQLite SSOT.\n");
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const topology = EnvironmentDetector.detect(cwd, repo);
|
|
102
|
-
|
|
103
|
-
console.log("================================================================================");
|
|
104
|
-
console.log("🌐 SEPTUM SELF-AWARE ENVIRONMENT TOPOLOGY PLANE");
|
|
105
|
-
console.log("================================================================================");
|
|
106
|
-
console.log(`Overall Status: ${topology.overall_status}`);
|
|
107
|
-
console.log(`Topology Mode: ${topology.is_distributed ? "DISTRIBUTED MULTI-NODE GRAPH" : "MONOLITHIC SINGLE-NODE"}`);
|
|
108
|
-
console.log(`Summary: ${topology.architectural_summary}\n`);
|
|
109
|
-
|
|
110
|
-
if (topology.nodes.length > 0) {
|
|
111
|
-
console.log("--- DISTRIBUTED TOPOLOGY NODES ---");
|
|
112
|
-
for (const node of topology.nodes) {
|
|
113
|
-
const statusIcon = node.status === "VERIFIED" ? "✓ [VERIFIED]" : node.status === "DETECTED" ? "• [DETECTED]" : "? [AMBIGUOUS]";
|
|
114
|
-
const domainStr = node.domain_or_ip ? ` @ ${node.domain_or_ip}` : "";
|
|
115
|
-
const roleStr = node.role ? ` [Role: ${node.role}]` : "";
|
|
116
|
-
console.log(` ${statusIcon} ${node.id.padEnd(20)} (${node.layer.toUpperCase()}): ${node.platform}${domainStr}${roleStr}`);
|
|
117
|
-
if (node.connected_to && node.connected_to.length > 0) {
|
|
118
|
-
console.log(` ➔ Connected to: ${node.connected_to.join(", ")}`);
|
|
119
|
-
}
|
|
120
|
-
if (node.constraints && node.constraints.length > 0) {
|
|
121
|
-
for (const c of node.constraints) {
|
|
122
|
-
console.log(` - ${c}`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
console.log("");
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
console.log("--- 6-LAYER PRODUCTION SUMMARY PLANE ---");
|
|
130
|
-
for (const [layerKey, info] of Object.entries(topology.layers)) {
|
|
131
|
-
const statusIcon = info.status === "VERIFIED" ? "✓ [VERIFIED]" : info.status === "DETECTED" ? "• [DETECTED]" : "? [AMBIGUOUS]";
|
|
132
|
-
console.log(` ${statusIcon} ${layerKey.toUpperCase().padEnd(10)}: ${info.platform || "Unresolved"}`);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (topology.interplays.length > 0) {
|
|
136
|
-
console.log("\n--- CROSS-LAYER & DISTRIBUTED INVARIANTS ---");
|
|
137
|
-
for (const interplay of topology.interplays) {
|
|
138
|
-
console.log(` ⚡ ${interplay.title} (${interplay.involved_layers.join(" ➔ ")})`);
|
|
139
|
-
console.log(` Rule: ${interplay.risk_or_rule}`);
|
|
140
|
-
console.log(` Action: ${interplay.required_action}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (topology.pending_inquiries.length > 0) {
|
|
145
|
-
console.log("\n--- PENDING ARCHITECTURAL INQUIRIES ---");
|
|
146
|
-
console.log("Action Required: Please clarify these ambiguous layers/nodes for your AI Agent:\n");
|
|
147
|
-
for (const inquiry of topology.pending_inquiries) {
|
|
148
|
-
console.log(` ❓ ${inquiry}`);
|
|
149
|
-
}
|
|
150
|
-
console.log("\nTip: To resolve an inquiry or add distributed nodes, run:");
|
|
151
|
-
console.log(" septum topology resolve <layer> \"<Platform Name>\"");
|
|
152
|
-
console.log(" septum topology add-node <id> <layer> \"<Platform Name>\" [domain_or_ip]");
|
|
153
|
-
console.log("Example:");
|
|
154
|
-
console.log(" septum topology add-node host:vps-worker host \"Ubuntu 24.04 (Dedicated Worker)\" 10.0.0.6");
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
console.log("================================================================================\n");
|
|
158
|
-
} finally {
|
|
159
|
-
db.close();
|
|
160
|
-
}
|
|
161
|
-
}
|