secufusion-mcp 2.1.5 → 2.2.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/.claude-plugin/plugin.json +2 -2
- package/README.md +49 -89
- package/agents/AGENTS.md +224 -31
- package/agents/reviewer.md +231 -304
- package/commands/sfn-code.md +72 -6
- package/commands/sfn-init.md +506 -36
- package/commands/sfn-review.md +695 -30
- package/mcp/dist/parsers/events.js +11 -4
- package/mcp/dist/server.js +253 -1396
- package/package.json +2 -2
- package/scripts/.secufusion-migrations.json +395 -0
- package/scripts/.secufusion-project-spec.json +857 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "secufusion-mcp",
|
|
3
|
-
"description": "SecuFusion MSSP platform dev agent — project-level spec driven, tenant-isolation enforced, zero-trust guardrails. Slash
|
|
4
|
-
"version": "2.
|
|
3
|
+
"description": "SecuFusion MSSP platform dev agent — project-level spec driven, tenant-isolation enforced, zero-trust guardrails. 5 Core Slash Commands: /sfn-init (dynamic DNA + architecture diagram + watcher), /sfn-plan (philosophy check + intent WHY + classify + plan), /sfn-code (spec-driven implementation), /sfn-review (zero-tolerance 3-tier PR gate), /sfn-explore (on-demand service graph or blast-radius analysis).",
|
|
4
|
+
"version": "2.1.6",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Motivity Labs"
|
|
7
7
|
},
|
package/README.md
CHANGED
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
| `get_pattern_from_task` | **Phase 1** — Cross-Task Intelligence | Extracts reusable decisions, file patterns, and test scenarios from a completed task |
|
|
25
25
|
| `manage_branch_state` | Legacy — Branch State | Backward-compatible branch-scoped JSON state tracker (for tasks before `manage_task`) |
|
|
26
26
|
| `log_rejected_pattern` | **Phase 3** — Course Correction | Records bad patterns to `.rejected-patterns.json` so they are never repeated |
|
|
27
|
-
| `run_pre_pr_checks_with_reviewer_agent` | **Phase 4** — PR Handoff | **NEW** — Unified 3-tier PR gate. Runs mechanical checks, AI file reviews, and context-aware task evaluation in a single pass. |
|
|
28
27
|
| `get_secufusion_rules` | **Setup** | Returns the `AGENTS.md` rules for AI clients that don't natively support MCP Resources |
|
|
29
28
|
| `classify_task` | **Phase 0.5** — Task Classification | **NEW** — Deep multi-pass analysis engine. Classifies any task as `BACKEND_ONLY`, `FRONTEND_ONLY`, etc. based on root cause. |
|
|
30
29
|
| `prime_session` | **Phase 0** — Session Start | **NEW** — Hyper-efficient session startup. Combines Phase 00 (spec) and Phase 0 (task) into one call using Thin Indexes to optimize context tokens. |
|
|
@@ -36,23 +35,25 @@
|
|
|
36
35
|
|
|
37
36
|
The SecuFusion MCP has been refactored to align with the advanced MLMCPS framework principles, bringing massive efficiency and UX improvements:
|
|
38
37
|
|
|
39
|
-
1. **
|
|
38
|
+
1. **5 High-Impact Slash Commands**: The monolithic agent prompt and fragmented utility scripts are consolidated into 5 clean, focused commands: `/sfn-init`, `/sfn-plan`, `/sfn-code`, `/sfn-review`, and `/sfn-explore`.
|
|
40
39
|
2. **Subprocess PR Checks**: Tier 1 mechanical checks (`TENANT_ISOLATION`, `N_PLUS_ONE`, etc.) are now extracted into a standalone CLI script (`scripts/sfn-pr-check.js`), allowing them to be run by the AI *or* natively within your CI/CD pipelines.
|
|
41
40
|
3. **Thin Index Token Discipline**: Context bloat is gone. Tools like `manage_task(read)` and `prime_session` now return lightweight "Thin Indexes"—compact Markdown summaries with absolute file paths—so the AI only reads the full JSON via `view_file` when truly necessary.
|
|
42
41
|
4. **Dynamic Skill Registry**: A new `skill_recommend` tool allows the AI to dynamically discover domain-specific architectural skills without bloating the base prompt.
|
|
43
42
|
5. **Phase -1 Philosophy Engine**: An invisible gate that checks the WHY, WHO, WHAT, and RISK of every task (including bugs and hotfixes) before any planning starts. If the business intent or blast radius is unsafe, it stops the AI from writing a single line of code.
|
|
44
|
-
6. **Poly-Repo DNA Discovery**:
|
|
43
|
+
6. **Built-in Poly-Repo DNA Discovery**: Built directly into `secufusion-mcp`. The AI dynamically analyzes the entire poly-repo workspace at session start, mapping microservices, API contracts, Kafka topologies, frontend repos, and browser extensions into a living knowledge graph (`.secufusion/dna.json`) with an auto-generated Mermaid architecture diagram.
|
|
44
|
+
7. **Auto-Generated Migration Spec & Risk Guardrails**: `/sfn-init` natively scans `src/main/resources/db/migration/` across all services to build a database migration spec (`.secufusion-migrations.json`). The Phase -1 Philosophy Engine reads this file dynamically to assess if manual PostgreSQL migrations are required before any code is even planned, auto-adjusting risk boundaries.
|
|
45
|
+
8. **Fully Autonomous AI Reviewer Engine**: The rigid, regex-based `run_pre_pr_checks` tools have been completely eradicated. `/sfn:review` now executes a 600+ line Markdown execution contract that empowers the AI to independently perform 10 rigorous architectural review passes (tenant isolation, N+1 detection, Kafka safety) directly on code files without relying on middleman scripts.
|
|
46
|
+
9. **Smart Spec Merging & Auto-Sync**: The project specification (`.secufusion-project-spec.json`) now seamlessly syncs with the active MCP plugin version. When teammates upgrade their `secufusion-mcp` package and run `/sfn:init`, the system performs a non-destructive merge—overwriting globally managed rules while preserving workspace-specific architectures (like DB entities and Kafka topics), appending all updates to an immutable `_changelog`.
|
|
45
47
|
|
|
46
48
|
---
|
|
47
49
|
|
|
48
|
-
## 🧬
|
|
50
|
+
## 🧬 Built-In DNA Discovery & Architecture Exploration
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
`secufusion-mcp` includes native ecosystem-wide discovery tools:
|
|
51
53
|
|
|
52
|
-
**Key Features:**
|
|
53
54
|
- **Dynamic Stack Analysis:** Identifies Java/Spring, Node, Docker, and other frameworks on the fly.
|
|
54
|
-
- **Slash Command Agents:** Use `/analyze`, `/map-architecture`, and `/blast-radius` directly in your AI chat to orchestrate complex codebase queries.
|
|
55
55
|
- **Automated Dependency Mapping:** Generates cross-service dependency maps and evaluates the blast radius of potential changes.
|
|
56
|
+
- **Interactive Commands:** Use `/sfn-init` to map your entire workspace and launch the watcher, and `/sfn-explore` on-demand to render Mermaid architecture graphs or analyze component blast radius.
|
|
56
57
|
|
|
57
58
|
---
|
|
58
59
|
|
|
@@ -144,13 +145,13 @@ npx secufusion-mcp
|
|
|
144
145
|
### Option 2 — Global install
|
|
145
146
|
|
|
146
147
|
```bash
|
|
147
|
-
npm install -g secufusion-mcp@2.1.
|
|
148
|
+
npm install -g secufusion-mcp@2.1.9
|
|
148
149
|
```
|
|
149
150
|
|
|
150
151
|
### Option 3 — Local project install
|
|
151
152
|
|
|
152
153
|
```bash
|
|
153
|
-
npm install --save-dev secufusion-mcp@2.1.
|
|
154
|
+
npm install --save-dev secufusion-mcp@2.1.9
|
|
154
155
|
```
|
|
155
156
|
|
|
156
157
|
---
|
|
@@ -946,86 +947,45 @@ If any of these are physically missing from your local workspace folder, a `[WAR
|
|
|
946
947
|
|
|
947
948
|
## ⚡ End-to-End Slash Command Workflow
|
|
948
949
|
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
|
954
|
-
|
|
955
|
-
| `/sfn-
|
|
956
|
-
| `/
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|---|---|---|
|
|
989
|
-
| `/sfn-review` | After coding is done, before opening a PR | Agent enters the adversarial `reviewer.md` persona. Triggers `run_pre_pr_checks` — a 3-tier AST-level gate: (1) Mechanical guardrails (tenant isolation, N+1 queries, hardcoded URLs), (2) AI file-by-file code review, (3) Context-aware task evaluation against your spec. **Blocks the PR if Tier 1 violations are found.** |
|
|
990
|
-
|
|
991
|
-
---
|
|
992
|
-
|
|
993
|
-
### 🔍 Phase 4 — Architecture Discovery
|
|
994
|
-
|
|
995
|
-
These commands can be run at any time to explore your codebase, independent of any active task.
|
|
996
|
-
|
|
997
|
-
| Command | When to run | What it does |
|
|
998
|
-
|---|---|---|
|
|
999
|
-
| `/blast-radius <component>` | Before refactoring a shared entity, API, or Kafka topic | Reads `dna.json` and calculates exactly which services, endpoints, and consumers will break if the given component is changed. Prevents accidental breaking changes. |
|
|
1000
|
-
| `/map-architecture` | When onboarding a new dev or auditing the ecosystem | Generates a comprehensive bird's-eye view of all your services, domains, inter-service call graph, and Kafka topics sourced directly from the DNA graph. |
|
|
1001
|
-
| `/analyze` | When debugging a cross-service issue or doing a deep-dive on a subsystem | Performs a deep-dive AST analysis of a specific area, generating detailed dependency and data-flow maps. |
|
|
1002
|
-
|
|
1003
|
-
---
|
|
1004
|
-
|
|
1005
|
-
### 📊 The Full SDLC Flow at a Glance
|
|
1006
|
-
|
|
1007
|
-
```
|
|
1008
|
-
Morning
|
|
1009
|
-
↓
|
|
1010
|
-
/sfn-init ← Validate all repos, build DNA knowledge graph
|
|
1011
|
-
↓
|
|
1012
|
-
/watch-dna ← Background watcher keeps DNA fresh all day
|
|
1013
|
-
↓
|
|
1014
|
-
New ticket arrives
|
|
1015
|
-
↓
|
|
1016
|
-
/sfn-plan TASK-XXX ← Plan is written + presented → you say "proceed"
|
|
1017
|
-
↓
|
|
1018
|
-
/sfn-code ← Feature is implemented per plan, zero-trust guardrails active
|
|
1019
|
-
↓
|
|
1020
|
-
/sfn-review ← 3-tier AST gate → PASS or BLOCK with specific violations
|
|
1021
|
-
↓
|
|
1022
|
-
PR opened ✅
|
|
1023
|
-
|
|
1024
|
-
Need to investigate?
|
|
1025
|
-
↓
|
|
1026
|
-
/blast-radius ← Impact analysis before any structural change
|
|
1027
|
-
/map-architecture ← Full ecosystem overview
|
|
1028
|
-
/analyze ← Deep subsystem inspection
|
|
950
|
+
All commands are natively registered as Claude Plugins and appear directly in the Claude IDE `/` command picker. The workflow is streamlined into **5 core commands** with zero redundancy:
|
|
951
|
+
|
|
952
|
+
| # | Command | Persona / Role | When to run | What it does |
|
|
953
|
+
|---|---|---|---|---|
|
|
954
|
+
| **1** | `/sfn-init` | Ecosystem Architect | First thing in morning, on new machine, or new clone | Bootstraps workspace, validates mandatory repos against `.secufusion-project-spec.json`, extracts domain models, API endpoints, Kafka topics, generates `.secufusion/dna.json`, builds full Mermaid architecture diagram, and launches continuous background file watcher (`chokidar`). |
|
|
955
|
+
| **2** | `/sfn-plan <ticket-id or desc>` | `planner.md` | When starting any story, chore, feature, bug, or hotfix | Evaluates Phase -1 Philosophy gate (WHY/WHO/WHAT/RISK), creates Markdown business intent (`spec_create_intent`), primes session AST context (`prime_session`), classifies task boundaries (`classify_task`), enforces **Rule 5 STRICT YIELD** for your green light, then generates structured `plan.md`. |
|
|
956
|
+
| **3** | `/sfn-code` | `coder.md` | After you approve the plan | Implements strictly according to the approved plan. Enforces zero-trust standards: mandatory tenant isolation on DB operations, proper `@Transactional` scoping, DTO mapping rules, and logs anti-patterns to `.rejected-patterns.json`. |
|
|
957
|
+
| **4** | `/sfn-review` | `reviewer.md` | After coding is done, before opening a PR | Adversarial PR gate running 3 tiers in a single pass: (1) Mechanical AST guardrails (tenant isolation, N+1 queries, hardcoded endpoints), (2) AI file-by-file code review, (3) Context-aware task evaluation against spec. Blocks PR if Tier 1 violations exist. |
|
|
958
|
+
| **5** | `/sfn-explore [map \| <component>]` | Architecture Explorer | On-demand for cross-service impact & system maps | Dual-mode architecture query: `/sfn-explore map` renders the full cross-service Mermaid architecture diagram; `/sfn-explore <component-or-path>` calculates blast radius and affected downstream consumers before making breaking changes. |
|
|
959
|
+
|
|
960
|
+
---
|
|
961
|
+
|
|
962
|
+
### 📊 The 5-Command SDLC Flow at a Glance
|
|
963
|
+
|
|
964
|
+
```
|
|
965
|
+
Morning / First Setup
|
|
966
|
+
│
|
|
967
|
+
▼
|
|
968
|
+
/sfn-init ← Scans workspace, writes dna.json, draws Mermaid diagram, starts watcher
|
|
969
|
+
│
|
|
970
|
+
├─► /sfn-explore map (Optional on-demand: view ecosystem graph)
|
|
971
|
+
│
|
|
972
|
+
Ticket Arrives (Feature / Bug / Hotfix)
|
|
973
|
+
│
|
|
974
|
+
▼
|
|
975
|
+
/sfn-plan WI-XXXX ← Phase -1 Philosophy check → Intent WHY → Prime → Classify → STRICT YIELD
|
|
976
|
+
│
|
|
977
|
+
├─► User Approves Plan ✅
|
|
978
|
+
│
|
|
979
|
+
▼
|
|
980
|
+
/sfn-code ← Implement approved plan with zero-trust guardrails
|
|
981
|
+
│
|
|
982
|
+
├─► /sfn-explore <comp> (Optional: verify blast radius if touching shared interfaces)
|
|
983
|
+
│
|
|
984
|
+
▼
|
|
985
|
+
/sfn-review ← 3-Tier PR Gate: mechanical AST checks + AI review + spec matching
|
|
986
|
+
│
|
|
987
|
+
▼
|
|
988
|
+
PR Ready to Merge 🚀
|
|
1029
989
|
```
|
|
1030
990
|
|
|
1031
991
|
---
|
package/agents/AGENTS.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# SecuFusion MCP Workflow Router
|
|
1
|
+
# SecuFusion MCP Workflow Router
|
|
2
2
|
|
|
3
3
|
You are an elite Senior Developer and Architect. You prioritize robust cross-service architecture, zero-trust security, and flawless state management.
|
|
4
4
|
|
|
@@ -12,13 +12,13 @@ Do not attempt to load all instructions into memory. Based on the current SDLC p
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
## THE NON-NEGOTIABLE EXECUTION ORDER
|
|
15
|
-
(Every task, every time
|
|
15
|
+
(Every task, every time — no exceptions, no shortcuts)
|
|
16
16
|
|
|
17
|
-
**DYNAMIC ENFORCEMENT**: Whether you are starting fresh, resuming, or answering mid-task
|
|
17
|
+
**DYNAMIC ENFORCEMENT**: Whether you are starting fresh, resuming, or answering mid-task — you must respect this exact sequence. Never skip ahead.
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
### Rule 0
|
|
21
|
+
### Rule 0 — DNA First (Absolute Pre-requisite)
|
|
22
22
|
|
|
23
23
|
Before ANY other action, call `prime_session(work_item_id: <id>)`.
|
|
24
24
|
|
|
@@ -34,30 +34,30 @@ If DNA is not loaded (DNA_LOADED = false in `.agents/claude.md`), ABORT and tell
|
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
|
-
### Rule 1
|
|
37
|
+
### Rule 1 — Philosophy Check (Phase -1, SILENT, runs AFTER DNA)
|
|
38
38
|
|
|
39
39
|
For any `user_story`, `feature`, `chore`, or `refactor`:
|
|
40
40
|
|
|
41
|
-
Call `philosophy_check` AFTER DNA is loaded
|
|
41
|
+
Call `philosophy_check` AFTER DNA is loaded — never before. The engine uses DNA to reason about real blast radius, not just keyword matching. It knows:
|
|
42
42
|
- Which DB entities your story touches and how many services depend on them
|
|
43
43
|
- Whether you are touching a shared multi-tenant auth service
|
|
44
44
|
- Whether the Chrome extension is in scope (requires store deployment)
|
|
45
45
|
- Which Kafka topics fan out to how many consumers
|
|
46
46
|
- Whether your description violates any golden rules
|
|
47
47
|
|
|
48
|
-
**This check is completely invisible to the user.** You do not announce it. You do not show scores, verdicts, or "philosophy" terminology. You surface a concern to the user only if the verdict is FAIL or BLOCKED
|
|
48
|
+
**This check is completely invisible to the user.** You do not announce it. You do not show scores, verdicts, or "philosophy" terminology. You surface a concern to the user only if the verdict is FAIL or BLOCKED — and you translate it into plain developer language.
|
|
49
49
|
|
|
50
50
|
For `bug` and `hotfix`: philosophy check still applies, though the scoring engine evaluates them with slightly relaxed thresholds since defects have an inherent "WHY".
|
|
51
51
|
|
|
52
52
|
**Verdicts:**
|
|
53
|
-
- `PHILOSOPHY_PASS`
|
|
54
|
-
- `PHILOSOPHY_ADVISORY`
|
|
55
|
-
- `PHILOSOPHY_FAIL`
|
|
56
|
-
- `PHILOSOPHY_BLOCKED`
|
|
53
|
+
- `PHILOSOPHY_PASS` → Silent. Proceed immediately.
|
|
54
|
+
- `PHILOSOPHY_ADVISORY` → Note concerns in `decisions.json`. Tell the user briefly what to watch out for. Continue.
|
|
55
|
+
- `PHILOSOPHY_FAIL` → STOP. Ask the user what is missing (no jargon). Wait for answers. Re-run philosophy_check.
|
|
56
|
+
- `PHILOSOPHY_BLOCKED` → STOP completely. Tell the user the risk and who must sign off. Do not plan. Do not code.
|
|
57
57
|
|
|
58
58
|
---
|
|
59
59
|
|
|
60
|
-
### Rule 2
|
|
60
|
+
### Rule 2 — Clarify Business Intent (WHY before HOW)
|
|
61
61
|
|
|
62
62
|
After philosophy check passes, capture the WHY formally. Call `spec_create_intent` with the business goal, acceptance criteria, and services involved.
|
|
63
63
|
|
|
@@ -65,31 +65,31 @@ Do not initialize task tracking (`manage_task`) until the WHY is captured.
|
|
|
65
65
|
|
|
66
66
|
---
|
|
67
67
|
|
|
68
|
-
### Rule 3
|
|
68
|
+
### Rule 3 — ReAct (Reason, Observe, Act)
|
|
69
69
|
|
|
70
70
|
Deeply reason about the problem using the DNA context you loaded. Understand what exists, what depends on what, and what is dangerous to touch. Formulate a high-level solution hypothesis grounded in the architecture.
|
|
71
71
|
|
|
72
72
|
---
|
|
73
73
|
|
|
74
|
-
### Rule 4
|
|
74
|
+
### Rule 4 — Classify
|
|
75
75
|
|
|
76
76
|
Call `classify_task`. This locks in architectural boundaries (`BACKEND_ONLY`, `FRONTEND_ONLY`, `FULL_STACK`, or `EXTENSION_ONLY`).
|
|
77
77
|
|
|
78
78
|
---
|
|
79
79
|
|
|
80
|
-
### Rule 5
|
|
80
|
+
### Rule 5 — STRICT YIELD
|
|
81
81
|
|
|
82
82
|
After classifying, STOP. Output the result. Ask the user for the green signal. Do NOT chain tool calls.
|
|
83
83
|
|
|
84
84
|
---
|
|
85
85
|
|
|
86
|
-
### Rule 6
|
|
86
|
+
### Rule 6 — Plan Only After Approval
|
|
87
87
|
|
|
88
88
|
Produce the implementation plan only after the user approves the classification.
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
|
92
|
-
### Rule 7
|
|
92
|
+
### Rule 7 — Code is the Last Resort
|
|
93
93
|
|
|
94
94
|
Source code changes are the absolute final step. Only after the plan is approved.
|
|
95
95
|
|
|
@@ -97,15 +97,15 @@ Source code changes are the absolute final step. Only after the plan is approved
|
|
|
97
97
|
|
|
98
98
|
## What you are NOT allowed to do before DNA is loaded and philosophy passes:
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
⌠Read any source files
|
|
101
|
+
⌠Call `classify_task`
|
|
102
|
+
⌠Call `manage_task`
|
|
103
|
+
⌠Write any implementation plan
|
|
104
|
+
⌠Suggest technical approaches
|
|
105
|
+
⌠Say "let's start and see"
|
|
106
|
+
⌠Minimize a FAIL verdict
|
|
107
|
+
⌠Offer to proceed despite BLOCKED
|
|
108
|
+
⌠Mention "philosophy", "PHILOSOPHY_FAIL", "PHILOSOPHY_BLOCKED" to the user
|
|
109
109
|
|
|
110
110
|
---
|
|
111
111
|
|
|
@@ -114,20 +114,213 @@ Source code changes are the absolute final step. Only after the plan is approved
|
|
|
114
114
|
Four questions every story must answer before implementation can begin:
|
|
115
115
|
|
|
116
116
|
```
|
|
117
|
-
WHY
|
|
117
|
+
WHY → What specific problem does this solve?
|
|
118
118
|
If we can't state the problem, the solution is guesswork.
|
|
119
119
|
|
|
120
|
-
WHO
|
|
120
|
+
WHO → Who confirmed this is needed?
|
|
121
121
|
"Someone asked" is not confirmation.
|
|
122
122
|
The decision maker must be on record.
|
|
123
123
|
|
|
124
|
-
WHAT
|
|
124
|
+
WHAT → What exactly are we building?
|
|
125
125
|
Vague stories produce vague software.
|
|
126
126
|
If you can't test it, you can't build it.
|
|
127
127
|
|
|
128
|
-
RISK
|
|
128
|
+
RISK → What breaks if we're wrong?
|
|
129
129
|
Irreversible changes need higher certainty.
|
|
130
130
|
High risk + low certainty = guaranteed waste.
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
-
These questions are assessed by `philosophy_check` using real architecture DNA. You never ask the user these questions directly
|
|
133
|
+
These questions are assessed by `philosophy_check` using real architecture DNA. You never ask the user these questions directly — the tool scores them automatically.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Migration Guardrails
|
|
138
|
+
(enforce on every task that touches a service with a database)
|
|
139
|
+
|
|
140
|
+
SecuFusion uses **MANUAL migration scripts**. This is the single most important thing to internalize about the DB layer:
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
⌠NO Flyway on boot
|
|
144
|
+
⌠NO automatic execution
|
|
145
|
+
⌠NO spring.flyway.* config
|
|
146
|
+
✅ Scripts applied MANUALLY by developer/DBA via psql or DB client
|
|
147
|
+
✅ Scripts MUST run against PostgreSQL BEFORE deploying the code that depends on them
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Source of truth: `.secufusion-migrations.json`
|
|
151
|
+
|
|
152
|
+
All migration rules, version numbers, gap lists, and naming conventions come from this file.
|
|
153
|
+
**NEVER guess from memory.** Always read `mcp_guardrails` in that file for the authoritative state.
|
|
154
|
+
|
|
155
|
+
Services with manual migration scripts (as of last scan):
|
|
156
|
+
- `sfn-events-api` → `src/main/resources/db/migration/` — see spec for next version
|
|
157
|
+
- `sfn-iam-api` → `src/main/resources/db/migration/` — has version gaps, see spec
|
|
158
|
+
- `sfn-tenants-api` → `src/main/resources/db/migration/` — has version gaps, see spec
|
|
159
|
+
|
|
160
|
+
Services WITHOUT migrations: `sfn-auth-api`, `sfn-eureka-api`, `sfn-gateway-api`, `sfn-policy-api`, `sfn-web-ui`, `snf-browser-extn`
|
|
161
|
+
|
|
162
|
+
### Before writing any migration script
|
|
163
|
+
|
|
164
|
+
1. Read `.secufusion-migrations.json`
|
|
165
|
+
2. Find your service's `current_state.next_suggested` — that is the filename base
|
|
166
|
+
3. Check `organization.version_gaps` — do NOT reuse any gap number
|
|
167
|
+
4. Name file: exactly `{next_suggested}` with a meaningful snake_case description
|
|
168
|
+
5. Place in: `src/main/resources/db/migration/` (SINGULAR — not `migrations`)
|
|
169
|
+
|
|
170
|
+
### Migration content conventions (from spec)
|
|
171
|
+
|
|
172
|
+
```sql
|
|
173
|
+
-- =====================================================
|
|
174
|
+
-- V{n}: Short description of the change
|
|
175
|
+
-- WHY: Reason this change was needed (business context)
|
|
176
|
+
-- NOTE: Applied MANUALLY — not auto-run on startup
|
|
177
|
+
-- =====================================================
|
|
178
|
+
|
|
179
|
+
-- Use IF NOT EXISTS for CREATE TABLE
|
|
180
|
+
CREATE TABLE IF NOT EXISTS ...;
|
|
181
|
+
|
|
182
|
+
-- Include CREATE INDEX in same file for new filterable columns
|
|
183
|
+
CREATE INDEX IF NOT EXISTS idx_{table}_{column} ON {table}({column});
|
|
184
|
+
|
|
185
|
+
-- Constraint naming: chk_{table}_{field}, idx_{abbrev}_{column}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### DO NOT
|
|
189
|
+
|
|
190
|
+
- Reuse version numbers from `organization.version_gaps`
|
|
191
|
+
- Assume any script runs automatically
|
|
192
|
+
- Skip a migration for ANY `@Entity`/`@Column`/`@Table` change
|
|
193
|
+
- Put migration scripts anywhere other than `src/main/resources/db/migration/`
|
|
194
|
+
- Leave `CREATE INDEX` for "later" — include it in the same migration file
|
|
195
|
+
|
|
196
|
+
### Pre-PR check verifies (automated in `run_pre_pr_checks`):
|
|
197
|
+
- ✅ Migration script exists for `@Entity` change
|
|
198
|
+
- ✅ Naming pattern: `^V\d+__[a-z][a-z0-9_]*\.sql$`
|
|
199
|
+
- ✅ Version is correct next in sequence (from spec)
|
|
200
|
+
- ✅ No gap version reuse (from spec)
|
|
201
|
+
- ✅ Naming and version validated against `.secufusion-migrations.json`
|
|
202
|
+
|
|
203
|
+
### PR review verifies (Pass 0 in `/sfn-review`):
|
|
204
|
+
- ✅ Comment header present with V# and WHY
|
|
205
|
+
- ✅ IF NOT EXISTS guards used
|
|
206
|
+
- ✅ Constraint naming follows convention from spec
|
|
207
|
+
- ✅ All `@Entity` changes have corresponding migration coverage
|
|
208
|
+
- 🔴 Manual application reminder included in PR description
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## PLATFORM DOMAIN CONTEXT
|
|
214
|
+
(Loaded by ALL engines — planner, coder, reviewer, philosophy check. Non-negotiable.)
|
|
215
|
+
|
|
216
|
+
### What SecuFusion is
|
|
217
|
+
|
|
218
|
+
SecuFusion is a **multi-tenant MSSP browser security platform** consisting of:
|
|
219
|
+
- Multiple Spring Boot microservices behind a Spring Cloud Gateway
|
|
220
|
+
- A React 19 / Vite 7 frontend (`sfn-web-ui`)
|
|
221
|
+
- Browser extensions deployed across customer environments (`snf-browser-extn` — Node + Go agent)
|
|
222
|
+
- Keycloak for identity management
|
|
223
|
+
- Kafka for event-driven inter-service communication
|
|
224
|
+
- PostgreSQL databases (manual migrations — no Flyway auto-execution)
|
|
225
|
+
|
|
226
|
+
When investigating any issue: **always consider cross-service impact first**. The symptom almost
|
|
227
|
+
never lives in the same service as the root cause.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### CRITICAL: Device vs Machine terminology
|
|
232
|
+
|
|
233
|
+
This distinction has caused production bugs and engineering confusion. Every engine must know it.
|
|
234
|
+
|
|
235
|
+
| Term | Means | Example |
|
|
236
|
+
|---|---|---|
|
|
237
|
+
| **Device** | A **browser installation** | Chrome on a laptop, Edge on a workstation |
|
|
238
|
+
| **Machine** | A **physical endpoint** | Laptop, desktop, workstation, PC |
|
|
239
|
+
|
|
240
|
+
**Historical problem:** The platform originally used "Device" to mean physical endpoint. This
|
|
241
|
+
caused ambiguity — engineers, POs, and customers all read "device" as a physical machine.
|
|
242
|
+
|
|
243
|
+
A terminology correction was introduced across backend services and data models. However:
|
|
244
|
+
- **Older code may still use legacy "Device" naming** even when the concept is physically a Machine
|
|
245
|
+
- **DB schemas, event payloads, and older APIs** may not yet reflect the corrected terminology
|
|
246
|
+
- **UI labels are intentionally normalized** — they may say "endpoint" or "device" for UX reasons
|
|
247
|
+
even when the underlying backend entity is a Machine
|
|
248
|
+
|
|
249
|
+
**Rules for every engine:**
|
|
250
|
+
|
|
251
|
+
1. Before declaring a bug involving a "device": determine whether the subject is a Browser (Device)
|
|
252
|
+
or Physical Endpoint (Machine). They are different entities with different ownership models.
|
|
253
|
+
|
|
254
|
+
2. When reading backend code, DB schemas, API contracts, event payloads, or migration scripts:
|
|
255
|
+
- "Device" often = browser install (unless proven otherwise by context)
|
|
256
|
+
- "Machine" = physical endpoint
|
|
257
|
+
- Naming inconsistency ≠ bug — it may be legacy terminology, not a defect
|
|
258
|
+
|
|
259
|
+
3. Frontend labels do NOT map 1:1 to backend entity names. Always trace the API contract and
|
|
260
|
+
payload before concluding a data mismatch exists.
|
|
261
|
+
|
|
262
|
+
4. Never propose a rename or terminology fix without first confirming:
|
|
263
|
+
- Which entity is actually being referenced in that specific file/layer
|
|
264
|
+
- Whether the inconsistency is legacy naming or an actual modelling error
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
### Service architecture
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
Clients:
|
|
272
|
+
sfn-web-ui React 19 / Vite 7 — same-origin via axiosConfig.js:93,104
|
|
273
|
+
snf-browser-extn Node + Go agent — inferred routing, not confirmed in sampled routes
|
|
274
|
+
|
|
275
|
+
Gateway:
|
|
276
|
+
sfn-gateway-api Spring Cloud Gateway (all external traffic enters here)
|
|
277
|
+
sfn-eureka-api Service Registry (all services register via lb://)
|
|
278
|
+
|
|
279
|
+
Java Microservices (all behind gateway):
|
|
280
|
+
sfn-auth-api Authentication (gateway routing not confirmed in sampled routes)
|
|
281
|
+
sfn-iam-api Identity & Access Management → /api/iam/**
|
|
282
|
+
sfn-tenants-api Tenant management → /api/tenants/**
|
|
283
|
+
sfn-events-api Event processing → /api/events/**
|
|
284
|
+
sfn-policy-api Policy engine → /api/policies/**
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**Cross-service call patterns:**
|
|
288
|
+
|
|
289
|
+
| Caller | Callee | How | Notes |
|
|
290
|
+
|---|---|---|---|
|
|
291
|
+
| `sfn-web-ui` | `sfn-gateway-api` | HTTP, same-origin | axiosConfig.js:93,104 |
|
|
292
|
+
| `sfn-browser-extn` | `sfn-gateway-api` | Inferred | Not confirmed in sampled routes |
|
|
293
|
+
| `sfn-tenants-api` | `sfn-iam-api` | Direct REST | Bypasses gateway — target hosts not confirmed |
|
|
294
|
+
| `sfn-tenants-api` | `sfn-policy-api` | Direct REST | Bypasses gateway |
|
|
295
|
+
| `sfn-tenants-api` | `sfn-events-api` | Direct REST | Bypasses gateway |
|
|
296
|
+
|
|
297
|
+
**Kafka topics and their consumers:**
|
|
298
|
+
|
|
299
|
+
| Topic | Producer | Consumer | Notes |
|
|
300
|
+
|---|---|---|---|
|
|
301
|
+
| `device-registration` | `sfn-iam-api` | `sfn-events-api` | |
|
|
302
|
+
| `device-deleted` | `sfn-events-api` | `sfn-iam-api` | |
|
|
303
|
+
| `extension-approval-decided` | `sfn-events-api` | `sfn-policy-api`, `sfn-tenants-api` | Fan-out to 2 consumers |
|
|
304
|
+
| `extension-policy-changed` | `sfn-policy-api`, `sfn-tenants-api` | `sfn-events-api` | Two producers |
|
|
305
|
+
| `policy-events` | `sfn-policy-api`, `sfn-tenants-api` | **NO LIVE CONSUMER** | ⚠️ Dead topic risk |
|
|
306
|
+
| `quickstart-events` | `sfn-events-api` | `sfn-events-api` | Self-loop |
|
|
307
|
+
|
|
308
|
+
**⚠️ Architecture flags to know:**
|
|
309
|
+
- `policy-events` topic has NO confirmed live consumer — producing to it is likely wasted work
|
|
310
|
+
- `sfn-tenants-api` makes direct REST calls that bypass the gateway — no gateway auth or circuit breaking on these paths
|
|
311
|
+
- Browser extension gateway routing is inferred, not confirmed in sampled routes
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
### Services with manual migration scripts (as of last scan)
|
|
316
|
+
|
|
317
|
+
| Service | Location | Notes |
|
|
318
|
+
|---|---|---|
|
|
319
|
+
| `sfn-events-api` | `src/main/resources/db/migration/` | See spec for next version |
|
|
320
|
+
| `sfn-iam-api` | `src/main/resources/db/migration/` | Has version gaps — check spec |
|
|
321
|
+
| `sfn-tenants-api` | `src/main/resources/db/migration/` | Has version gaps — check spec |
|
|
322
|
+
|
|
323
|
+
Services WITHOUT migrations: `sfn-auth-api`, `sfn-eureka-api`, `sfn-gateway-api`, `sfn-policy-api`, `sfn-web-ui`, `snf-browser-extn`
|
|
324
|
+
|
|
325
|
+
NEVER guess migration version numbers. Always read `.secufusion-migrations.json` first.
|
|
326
|
+
|