septum 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +100 -100
  3. package/bin/septum.ts +4 -4
  4. package/package.json +63 -62
  5. package/src/cli/commands/check.ts +161 -161
  6. package/src/cli/commands/hook.ts +188 -188
  7. package/src/cli/commands/ingest.ts +29 -29
  8. package/src/cli/commands/init.ts +211 -211
  9. package/src/cli/commands/locate.ts +61 -61
  10. package/src/cli/commands/query.ts +64 -64
  11. package/src/cli/commands/serve.ts +5 -5
  12. package/src/cli/commands/slice.ts +90 -90
  13. package/src/cli/commands/sync.ts +31 -31
  14. package/src/cli/index.ts +199 -178
  15. package/src/cli/templates/hooks.ts +75 -75
  16. package/src/cli/templates/rules.ts +38 -38
  17. package/src/cli/templates/skill.ts +66 -66
  18. package/src/core/boundary/evaluator.ts +210 -210
  19. package/src/core/config/loader.ts +84 -84
  20. package/src/core/config/schema.ts +39 -39
  21. package/src/core/database/client.ts +44 -132
  22. package/src/core/database/repositories/dependency.repository.ts +279 -279
  23. package/src/core/database/repositories/domain.repository.ts +198 -198
  24. package/src/core/database/repositories/file.repository.ts +99 -99
  25. package/src/core/database/repositories/meta.repository.ts +33 -33
  26. package/src/core/database/repositories/symbol.repository.ts +424 -424
  27. package/src/core/database/repository.ts +242 -242
  28. package/src/core/database/schema.ts +120 -0
  29. package/src/core/discovery/topology-detector.ts +418 -418
  30. package/src/core/ingestion/hasher.ts +5 -5
  31. package/src/core/ingestion/pipeline.ts +438 -438
  32. package/src/core/parser/boundary-tracker.ts +128 -128
  33. package/src/core/parser/extractors/base.ts +60 -60
  34. package/src/core/parser/extractors/frontend.ts +194 -194
  35. package/src/core/parser/extractors/go.ts +176 -176
  36. package/src/core/parser/extractors/laravel-semantic.ts +426 -426
  37. package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
  38. package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
  39. package/src/core/parser/extractors/php.ts +149 -149
  40. package/src/core/parser/extractors/python.ts +226 -226
  41. package/src/core/parser/extractors/registry.ts +49 -49
  42. package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
  43. package/src/core/parser/extractors/typescript.ts +177 -177
  44. package/src/core/parser/tree-sitter.ts +39 -39
  45. package/src/core/resolver/call-graph-tracer.ts +668 -668
  46. package/src/core/resolver/module-resolver.ts +342 -323
  47. package/src/core/resolver/symbol-locator.ts +543 -405
  48. package/src/core/resolver/vertical-slice-tracer.ts +237 -236
  49. package/src/core/session/session-manager.ts +56 -56
  50. package/src/core/telemetry/telemetry.ts +86 -86
  51. package/src/index.ts +18 -18
  52. package/src/mcp/schemas.ts +68 -68
  53. package/src/mcp/server.ts +612 -602
  54. package/src/mcp/tools/check-boundary.ts +102 -102
  55. package/src/mcp/tools/get-domain-catalog.ts +91 -91
  56. package/src/mcp/tools/get-feature-context.ts +116 -116
  57. package/src/mcp/tools/get-symbol-hotspots.ts +49 -49
  58. package/src/mcp/tools/get-symbol-impact.ts +26 -26
  59. package/src/mcp/tools/get-symbol.ts +63 -63
  60. package/src/mcp/tools/locate-symbol.ts +74 -74
  61. package/src/mcp/tools/register-domain.ts +64 -64
  62. package/src/mcp/tools/trace-vertical-slice.ts +102 -102
  63. package/src/types/index.ts +296 -296
  64. package/src/version.ts +3 -0
  65. package/src/core/database/schema.sql +0 -92
@@ -1,102 +1,102 @@
1
- import type { BoundaryEvaluator } from "../../core/boundary/evaluator.ts";
2
- import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
3
-
4
- export interface CheckBoundaryArgs {
5
- file_path?: string;
6
- file_paths?: string[];
7
- proposed_imports?: string[];
8
- feature_key?: string;
9
- }
10
-
11
- export function handleCheckBoundary(
12
- evaluator: BoundaryEvaluator,
13
- config: ValidatedSeptumConfig,
14
- args: CheckBoundaryArgs
15
- ) {
16
- const filesToCheck: string[] = [];
17
- if (args.file_paths && Array.isArray(args.file_paths) && args.file_paths.length > 0) {
18
- filesToCheck.push(...args.file_paths);
19
- } else if (args.file_path) {
20
- filesToCheck.push(args.file_path);
21
- } else {
22
- throw new Error("Missing required argument: specify either 'file_path' or 'file_paths'");
23
- }
24
-
25
- // Multi-file batch evaluation
26
- if (filesToCheck.length > 1) {
27
- const results = filesToCheck.map((filePath) => {
28
- const violations = evaluator.evaluate(filePath, args.proposed_imports ?? [], args.feature_key, config);
29
- return {
30
- file: filePath,
31
- status: violations.length > 0 ? "rejected" : "approved",
32
- violations,
33
- };
34
- });
35
-
36
- const totalViolations = results.reduce((acc, r) => acc + r.violations.length, 0);
37
- const hasViolations = totalViolations > 0;
38
-
39
- return {
40
- content: [
41
- {
42
- type: "text" as const,
43
- text: JSON.stringify(
44
- {
45
- status: hasViolations ? "rejected" : "approved",
46
- total_checked: filesToCheck.length,
47
- total_violations: totalViolations,
48
- results,
49
- message: hasViolations
50
- ? `${totalViolations} boundary violation(s) detected across ${filesToCheck.length} file(s).`
51
- : `All ${filesToCheck.length} file(s) approved. No boundary violations detected.`,
52
- },
53
- null,
54
- 2
55
- ),
56
- },
57
- ],
58
- };
59
- }
60
-
61
- // Single file evaluation (backward-compatible output)
62
- const singleFile = filesToCheck[0];
63
- const violations = evaluator.evaluate(singleFile, args.proposed_imports ?? [], args.feature_key, config);
64
-
65
- if (violations.length > 0) {
66
- return {
67
- content: [
68
- {
69
- type: "text" as const,
70
- text: JSON.stringify(
71
- {
72
- status: "rejected",
73
- file: singleFile,
74
- violations_count: violations.length,
75
- violations,
76
- message: "Boundary violation detected. Proposed imports violate bounded context architecture.",
77
- },
78
- null,
79
- 2
80
- ),
81
- },
82
- ],
83
- };
84
- }
85
-
86
- return {
87
- content: [
88
- {
89
- type: "text" as const,
90
- text: JSON.stringify(
91
- {
92
- status: "approved",
93
- file: singleFile,
94
- message: "No boundary violations detected. Proposed imports are permissible.",
95
- },
96
- null,
97
- 2
98
- ),
99
- },
100
- ],
101
- };
102
- }
1
+ import type { BoundaryEvaluator } from "../../core/boundary/evaluator.ts";
2
+ import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
3
+
4
+ export interface CheckBoundaryArgs {
5
+ file_path?: string;
6
+ file_paths?: string[];
7
+ proposed_imports?: string[];
8
+ feature_key?: string;
9
+ }
10
+
11
+ export function handleCheckBoundary(
12
+ evaluator: BoundaryEvaluator,
13
+ config: ValidatedSeptumConfig,
14
+ args: CheckBoundaryArgs
15
+ ) {
16
+ const filesToCheck: string[] = [];
17
+ if (args.file_paths && Array.isArray(args.file_paths) && args.file_paths.length > 0) {
18
+ filesToCheck.push(...args.file_paths);
19
+ } else if (args.file_path) {
20
+ filesToCheck.push(args.file_path);
21
+ } else {
22
+ throw new Error("Missing required argument: specify either 'file_path' or 'file_paths'");
23
+ }
24
+
25
+ // Multi-file batch evaluation
26
+ if (filesToCheck.length > 1) {
27
+ const results = filesToCheck.map((filePath) => {
28
+ const violations = evaluator.evaluate(filePath, args.proposed_imports ?? [], args.feature_key, config);
29
+ return {
30
+ file: filePath,
31
+ status: violations.length > 0 ? "rejected" : "approved",
32
+ violations,
33
+ };
34
+ });
35
+
36
+ const totalViolations = results.reduce((acc, r) => acc + r.violations.length, 0);
37
+ const hasViolations = totalViolations > 0;
38
+
39
+ return {
40
+ content: [
41
+ {
42
+ type: "text" as const,
43
+ text: JSON.stringify(
44
+ {
45
+ status: hasViolations ? "rejected" : "approved",
46
+ total_checked: filesToCheck.length,
47
+ total_violations: totalViolations,
48
+ results,
49
+ message: hasViolations
50
+ ? `${totalViolations} boundary violation(s) detected across ${filesToCheck.length} file(s).`
51
+ : `All ${filesToCheck.length} file(s) approved. No boundary violations detected.`,
52
+ },
53
+ null,
54
+ 2
55
+ ),
56
+ },
57
+ ],
58
+ };
59
+ }
60
+
61
+ // Single file evaluation (backward-compatible output)
62
+ const singleFile = filesToCheck[0];
63
+ const violations = evaluator.evaluate(singleFile, args.proposed_imports ?? [], args.feature_key, config);
64
+
65
+ if (violations.length > 0) {
66
+ return {
67
+ content: [
68
+ {
69
+ type: "text" as const,
70
+ text: JSON.stringify(
71
+ {
72
+ status: "rejected",
73
+ file: singleFile,
74
+ violations_count: violations.length,
75
+ violations,
76
+ message: "Boundary violation detected. Proposed imports violate bounded context architecture.",
77
+ },
78
+ null,
79
+ 2
80
+ ),
81
+ },
82
+ ],
83
+ };
84
+ }
85
+
86
+ return {
87
+ content: [
88
+ {
89
+ type: "text" as const,
90
+ text: JSON.stringify(
91
+ {
92
+ status: "approved",
93
+ file: singleFile,
94
+ message: "No boundary violations detected. Proposed imports are permissible.",
95
+ },
96
+ null,
97
+ 2
98
+ ),
99
+ },
100
+ ],
101
+ };
102
+ }
@@ -1,91 +1,91 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
4
- import type { SeptumRepository } from "../../core/database/repository.ts";
5
-
6
- export interface GetDomainCatalogArgs {
7
- domain?: string;
8
- archetype_filter?: string;
9
- }
10
-
11
- export function handleGetDomainCatalog(
12
- repo: SeptumRepository,
13
- config: ValidatedSeptumConfig,
14
- args: GetDomainCatalogArgs
15
- ) {
16
- if (!args.domain) {
17
- const allDomains = repo.getAllDomains();
18
- const projectType = repo.getMeta("project_type") || "generic";
19
- const framework = repo.getMeta("framework") || "unknown";
20
- const archStyle = repo.getMeta("architecture_style") || "modular";
21
- const totalSlices = repo.getAllVerticalSlices().length;
22
-
23
- const macroMap = {
24
- telescope_view: {
25
- project_type: projectType,
26
- framework,
27
- architecture_style: archStyle,
28
- total_domains: allDomains.length,
29
- total_vertical_slices: totalSlices,
30
- },
31
- domains: allDomains.map((d) => ({
32
- name: d.name,
33
- root: d.root_path,
34
- archetypes: Object.keys(JSON.parse(d.archetypes_json || "{}")),
35
- allowed_dependencies: JSON.parse(d.allowed_deps_json || "[]"),
36
- forbidden_dependencies: JSON.parse(d.forbidden_deps_json || "[]"),
37
- })),
38
- agent_instruction:
39
- "Macro semantic map loaded from SQLite SSOT. Use 'septum_get_domain_catalog' with domain='<name>' for granular file/symbol catalogs, or 'septum_trace_vertical_slice' with query='<route|command|intent>' for end-to-end execution flow.",
40
- };
41
-
42
- return {
43
- content: [
44
- {
45
- type: "text" as const,
46
- text: JSON.stringify(macroMap, null, 2),
47
- },
48
- ],
49
- };
50
- }
51
-
52
- const catalog = repo.getDomainCatalog(args.domain, args.archetype_filter);
53
- if (!catalog) {
54
- const available = Object.keys(config.domains).join(", ");
55
- throw new Error(
56
- `Domain '${args.domain}' not found. Available domains in Septum catalog: [${available}]. Run 'septum ingest' or 'septum_register_domain' if recently added.`
57
- );
58
- }
59
-
60
- // Record access log for Gate 3 (Mandatory Catalog Consultation)
61
- recordCatalogAccess(args.domain);
62
-
63
- // Token-efficient serialization: keep payload dense and under 500 tokens
64
- return {
65
- content: [
66
- {
67
- type: "text" as const,
68
- text: JSON.stringify(catalog, null, 2),
69
- },
70
- ],
71
- };
72
- }
73
-
74
- function recordCatalogAccess(domain: string): void {
75
- try {
76
- const septumDir = path.resolve(process.cwd(), ".septum");
77
- if (!fs.existsSync(septumDir)) {
78
- fs.mkdirSync(septumDir, { recursive: true });
79
- }
80
- const logPath = path.join(septumDir, "catalog_access.json");
81
- let log: { domains?: Record<string, string>; features?: Record<string, string> } = {};
82
- if (fs.existsSync(logPath)) {
83
- try {
84
- log = JSON.parse(fs.readFileSync(logPath, "utf-8"));
85
- } catch {}
86
- }
87
- log.domains = log.domains || {};
88
- log.domains[domain] = new Date().toISOString();
89
- fs.writeFileSync(logPath, JSON.stringify(log, null, 2), "utf-8");
90
- } catch {}
91
- }
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
4
+ import type { SeptumRepository } from "../../core/database/repository.ts";
5
+
6
+ export interface GetDomainCatalogArgs {
7
+ domain?: string;
8
+ archetype_filter?: string;
9
+ }
10
+
11
+ export function handleGetDomainCatalog(
12
+ repo: SeptumRepository,
13
+ config: ValidatedSeptumConfig,
14
+ args: GetDomainCatalogArgs
15
+ ) {
16
+ if (!args.domain) {
17
+ const allDomains = repo.getAllDomains();
18
+ const projectType = repo.getMeta("project_type") || "generic";
19
+ const framework = repo.getMeta("framework") || "unknown";
20
+ const archStyle = repo.getMeta("architecture_style") || "modular";
21
+ const totalSlices = repo.getAllVerticalSlices().length;
22
+
23
+ const macroMap = {
24
+ telescope_view: {
25
+ project_type: projectType,
26
+ framework,
27
+ architecture_style: archStyle,
28
+ total_domains: allDomains.length,
29
+ total_vertical_slices: totalSlices,
30
+ },
31
+ domains: allDomains.map((d) => ({
32
+ name: d.name,
33
+ root: d.root_path,
34
+ archetypes: Object.keys(JSON.parse(d.archetypes_json || "{}")),
35
+ allowed_dependencies: JSON.parse(d.allowed_deps_json || "[]"),
36
+ forbidden_dependencies: JSON.parse(d.forbidden_deps_json || "[]"),
37
+ })),
38
+ agent_instruction:
39
+ "Macro semantic map loaded from SQLite SSOT. Use 'septum_get_domain_catalog' with domain='<name>' for granular file/symbol catalogs, or 'septum_trace_vertical_slice' with query='<route|command|intent>' for end-to-end execution flow.",
40
+ };
41
+
42
+ return {
43
+ content: [
44
+ {
45
+ type: "text" as const,
46
+ text: JSON.stringify(macroMap, null, 2),
47
+ },
48
+ ],
49
+ };
50
+ }
51
+
52
+ const catalog = repo.getDomainCatalog(args.domain, args.archetype_filter);
53
+ if (!catalog) {
54
+ const available = Object.keys(config.domains).join(", ");
55
+ throw new Error(
56
+ `Domain '${args.domain}' not found. Available domains in Septum catalog: [${available}]. Run 'septum ingest' or 'septum_register_domain' if recently added.`
57
+ );
58
+ }
59
+
60
+ // Record access log for Gate 3 (Mandatory Catalog Consultation)
61
+ recordCatalogAccess(args.domain);
62
+
63
+ // Token-efficient serialization: keep payload dense and under 500 tokens
64
+ return {
65
+ content: [
66
+ {
67
+ type: "text" as const,
68
+ text: JSON.stringify(catalog, null, 2),
69
+ },
70
+ ],
71
+ };
72
+ }
73
+
74
+ function recordCatalogAccess(domain: string): void {
75
+ try {
76
+ const septumDir = path.resolve(process.cwd(), ".septum");
77
+ if (!fs.existsSync(septumDir)) {
78
+ fs.mkdirSync(septumDir, { recursive: true });
79
+ }
80
+ const logPath = path.join(septumDir, "catalog_access.json");
81
+ let log: { domains?: Record<string, string>; features?: Record<string, string> } = {};
82
+ if (fs.existsSync(logPath)) {
83
+ try {
84
+ log = JSON.parse(fs.readFileSync(logPath, "utf-8"));
85
+ } catch {}
86
+ }
87
+ log.domains = log.domains || {};
88
+ log.domains[domain] = new Date().toISOString();
89
+ fs.writeFileSync(logPath, JSON.stringify(log, null, 2), "utf-8");
90
+ } catch {}
91
+ }
@@ -1,116 +1,116 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
4
- import type { SeptumRepository } from "../../core/database/repository.ts";
5
- import { SessionManager } from "../../core/session/session-manager.ts";
6
- import type { FeatureContextResponse } from "../../types/index.ts";
7
-
8
- export interface GetFeatureContextArgs {
9
- feature: string;
10
- }
11
-
12
- export function handleClearFeatureContext(workspaceRoot: string = process.cwd()): boolean {
13
- return SessionManager.clearActiveSession(workspaceRoot);
14
- }
15
-
16
- export function handleGetFeatureContext(
17
- repo: SeptumRepository,
18
- config: ValidatedSeptumConfig,
19
- args: GetFeatureContextArgs
20
- ) {
21
- if (!args.feature) {
22
- throw new Error("Missing required argument: 'feature'");
23
- }
24
-
25
- const features = config.features ?? {};
26
- const featureConfig = features[args.feature];
27
-
28
- if (!featureConfig) {
29
- const available = Object.keys(features).join(", ") || "none";
30
- throw new Error(
31
- `Feature '${args.feature}' not found in configuration. Available features: [${available}]`
32
- );
33
- }
34
-
35
- // Record Active Feature Session Lease (.septum/session.json)
36
- SessionManager.saveActiveSession(process.cwd(), {
37
- feature_key: args.feature,
38
- domain: featureConfig.domain,
39
- touchpoints: featureConfig.allowed_touchpoints ?? [],
40
- locked_at: new Date().toISOString(),
41
- });
42
-
43
- // Deterministically fetch signatures, methods, and properties for reuse_symbols from SQLite
44
- const reuseSymbolsWithMeta: FeatureContextResponse["reuse_symbols"] = [];
45
- const requestedSymbols = featureConfig.reuse_symbols ?? [];
46
-
47
- for (const symName of requestedSymbols) {
48
- const record = repo.findSymbolWithMembers(symName);
49
- if (record) {
50
- reuseSymbolsWithMeta.push({
51
- name: record.symbol_name,
52
- kind: record.kind,
53
- signature: record.signature,
54
- methods: record.methods.length > 0 ? record.methods : undefined,
55
- properties: record.properties.length > 0 ? record.properties : undefined,
56
- file_path: record.file_path,
57
- domain: record.domain_name,
58
- });
59
- } else {
60
- reuseSymbolsWithMeta.push({
61
- name: symName,
62
- kind: "unknown",
63
- domain: featureConfig.domain,
64
- });
65
- }
66
- }
67
-
68
- const response: FeatureContextResponse = {
69
- feature: args.feature,
70
- domain: featureConfig.domain,
71
- description: featureConfig.description,
72
- allowed_touchpoints: featureConfig.allowed_touchpoints,
73
- reuse_symbols: reuseSymbolsWithMeta,
74
- input_contract: (featureConfig.input_contract as Record<string, unknown>) ?? {},
75
- output_contract: (featureConfig.output_contract as Record<string, unknown>) ?? {},
76
- governance_directives: [
77
- "DO NOT modify or edit any files outside allowed_touchpoints.",
78
- "DO NOT create duplicate helpers/services; reuse the existing symbols and methods declared in reuse_symbols.",
79
- "DO NOT emit or expect phantom payload fields outside input_contract and output_contract.",
80
- "DO NOT import cross-domain modules without declared allowed_dependencies in Septum domain boundaries.",
81
- ],
82
- };
83
-
84
- recordFeatureAccess(featureConfig.domain, args.feature);
85
-
86
- return {
87
- content: [
88
- {
89
- type: "text" as const,
90
- text: JSON.stringify(response, null, 2),
91
- },
92
- ],
93
- };
94
- }
95
-
96
- function recordFeatureAccess(domain: string, feature: string): void {
97
- try {
98
- const septumDir = path.resolve(process.cwd(), ".septum");
99
- if (!fs.existsSync(septumDir)) {
100
- fs.mkdirSync(septumDir, { recursive: true });
101
- }
102
- const logPath = path.join(septumDir, "catalog_access.json");
103
- let log: { domains?: Record<string, string>; features?: Record<string, string> } = {};
104
- if (fs.existsSync(logPath)) {
105
- try {
106
- log = JSON.parse(fs.readFileSync(logPath, "utf-8"));
107
- } catch {}
108
- }
109
- log.domains = log.domains || {};
110
- log.features = log.features || {};
111
- const now = new Date().toISOString();
112
- log.domains[domain] = now;
113
- log.features[feature] = now;
114
- fs.writeFileSync(logPath, JSON.stringify(log, null, 2), "utf-8");
115
- } catch {}
116
- }
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
4
+ import type { SeptumRepository } from "../../core/database/repository.ts";
5
+ import { SessionManager } from "../../core/session/session-manager.ts";
6
+ import type { FeatureContextResponse } from "../../types/index.ts";
7
+
8
+ export interface GetFeatureContextArgs {
9
+ feature: string;
10
+ }
11
+
12
+ export function handleClearFeatureContext(workspaceRoot: string = process.cwd()): boolean {
13
+ return SessionManager.clearActiveSession(workspaceRoot);
14
+ }
15
+
16
+ export function handleGetFeatureContext(
17
+ repo: SeptumRepository,
18
+ config: ValidatedSeptumConfig,
19
+ args: GetFeatureContextArgs
20
+ ) {
21
+ if (!args.feature) {
22
+ throw new Error("Missing required argument: 'feature'");
23
+ }
24
+
25
+ const features = config.features ?? {};
26
+ const featureConfig = features[args.feature];
27
+
28
+ if (!featureConfig) {
29
+ const available = Object.keys(features).join(", ") || "none";
30
+ throw new Error(
31
+ `Feature '${args.feature}' not found in configuration. Available features: [${available}]`
32
+ );
33
+ }
34
+
35
+ // Record Active Feature Session Lease (.septum/session.json)
36
+ SessionManager.saveActiveSession(process.cwd(), {
37
+ feature_key: args.feature,
38
+ domain: featureConfig.domain,
39
+ touchpoints: featureConfig.allowed_touchpoints ?? [],
40
+ locked_at: new Date().toISOString(),
41
+ });
42
+
43
+ // Deterministically fetch signatures, methods, and properties for reuse_symbols from SQLite
44
+ const reuseSymbolsWithMeta: FeatureContextResponse["reuse_symbols"] = [];
45
+ const requestedSymbols = featureConfig.reuse_symbols ?? [];
46
+
47
+ for (const symName of requestedSymbols) {
48
+ const record = repo.findSymbolWithMembers(symName);
49
+ if (record) {
50
+ reuseSymbolsWithMeta.push({
51
+ name: record.symbol_name,
52
+ kind: record.kind,
53
+ signature: record.signature,
54
+ methods: record.methods.length > 0 ? record.methods : undefined,
55
+ properties: record.properties.length > 0 ? record.properties : undefined,
56
+ file_path: record.file_path,
57
+ domain: record.domain_name,
58
+ });
59
+ } else {
60
+ reuseSymbolsWithMeta.push({
61
+ name: symName,
62
+ kind: "unknown",
63
+ domain: featureConfig.domain,
64
+ });
65
+ }
66
+ }
67
+
68
+ const response: FeatureContextResponse = {
69
+ feature: args.feature,
70
+ domain: featureConfig.domain,
71
+ description: featureConfig.description,
72
+ allowed_touchpoints: featureConfig.allowed_touchpoints,
73
+ reuse_symbols: reuseSymbolsWithMeta,
74
+ input_contract: (featureConfig.input_contract as Record<string, unknown>) ?? {},
75
+ output_contract: (featureConfig.output_contract as Record<string, unknown>) ?? {},
76
+ governance_directives: [
77
+ "DO NOT modify or edit any files outside allowed_touchpoints.",
78
+ "DO NOT create duplicate helpers/services; reuse the existing symbols and methods declared in reuse_symbols.",
79
+ "DO NOT emit or expect phantom payload fields outside input_contract and output_contract.",
80
+ "DO NOT import cross-domain modules without declared allowed_dependencies in Septum domain boundaries.",
81
+ ],
82
+ };
83
+
84
+ recordFeatureAccess(featureConfig.domain, args.feature);
85
+
86
+ return {
87
+ content: [
88
+ {
89
+ type: "text" as const,
90
+ text: JSON.stringify(response, null, 2),
91
+ },
92
+ ],
93
+ };
94
+ }
95
+
96
+ function recordFeatureAccess(domain: string, feature: string): void {
97
+ try {
98
+ const septumDir = path.resolve(process.cwd(), ".septum");
99
+ if (!fs.existsSync(septumDir)) {
100
+ fs.mkdirSync(septumDir, { recursive: true });
101
+ }
102
+ const logPath = path.join(septumDir, "catalog_access.json");
103
+ let log: { domains?: Record<string, string>; features?: Record<string, string> } = {};
104
+ if (fs.existsSync(logPath)) {
105
+ try {
106
+ log = JSON.parse(fs.readFileSync(logPath, "utf-8"));
107
+ } catch {}
108
+ }
109
+ log.domains = log.domains || {};
110
+ log.features = log.features || {};
111
+ const now = new Date().toISOString();
112
+ log.domains[domain] = now;
113
+ log.features[feature] = now;
114
+ fs.writeFileSync(logPath, JSON.stringify(log, null, 2), "utf-8");
115
+ } catch {}
116
+ }