torusguard 0.9.5 → 1.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.
Files changed (80) hide show
  1. package/.torusguard/.manifest.json +98 -79
  2. package/.torusguard/config/torusguard.json +1 -1
  3. package/.torusguard/references/csharp-security.md +41 -0
  4. package/.torusguard/references/go-security.md +41 -0
  5. package/.torusguard/references/java-security.md +40 -0
  6. package/.torusguard/references/polyglot-security-matrix.md +25 -0
  7. package/.torusguard/references/rust-security.md +40 -0
  8. package/.torusguard/rules/custom/.gitkeep +1 -0
  9. package/.torusguard/rules/custom/README.md +30 -0
  10. package/.torusguard/runs/report-latest.html +328 -0
  11. package/.torusguard/schemas/golden-recipe.schema.json +75 -0
  12. package/.torusguard/schemas/memory-context.schema.json +95 -0
  13. package/.torusguard/schemas/memory-event.schema.json +70 -0
  14. package/.torusguard/schemas/memory-pattern.schema.json +65 -0
  15. package/.torusguard/scripts/diff_guard.py +202 -15
  16. package/.torusguard/scripts/finding_scorer.py +199 -86
  17. package/.torusguard/scripts/html_reporter.py +628 -0
  18. package/.torusguard/scripts/manifest_builder.py +7 -5
  19. package/.torusguard/scripts/memory_engine.py +1334 -0
  20. package/.torusguard/scripts/monorepo_detector.py +123 -10
  21. package/.torusguard/scripts/rules_sync.py +321 -0
  22. package/.torusguard/scripts/run_manager.py +171 -89
  23. package/.torusguard/scripts/stack_detect.py +458 -26
  24. package/.torusguard/skills/torusguard/SKILL.md +4 -3
  25. package/.torusguard/skills/torusguard/bootstrap.py +344 -56
  26. package/.torusguard/skills/torusguard/references/csharp-security.md +41 -0
  27. package/.torusguard/skills/torusguard/references/go-security.md +41 -0
  28. package/.torusguard/skills/torusguard/references/java-security.md +40 -0
  29. package/.torusguard/skills/torusguard/references/polyglot-security-matrix.md +25 -0
  30. package/.torusguard/skills/torusguard/references/rust-security.md +40 -0
  31. package/.torusguard/skills/torusguard-audit/SKILL.md +25 -25
  32. package/.torusguard/skills/torusguard-harden/SKILL.md +3 -3
  33. package/.torusguard/skills/torusguard-recheck/SKILL.md +3 -3
  34. package/.torusguard/workflows/memory.md +53 -0
  35. package/README.md +307 -401
  36. package/bin/torusguard.js +204 -6
  37. package/package.json +1 -1
  38. package/skills/torusguard/SKILL.md +4 -3
  39. package/skills/torusguard/bootstrap.py +68 -4
  40. package/skills/torusguard/payload/.manifest.json +98 -79
  41. package/skills/torusguard/payload/config/torusguard.json +1 -1
  42. package/skills/torusguard/payload/references/csharp-security.md +41 -0
  43. package/skills/torusguard/payload/references/go-security.md +41 -0
  44. package/skills/torusguard/payload/references/java-security.md +40 -0
  45. package/skills/torusguard/payload/references/polyglot-security-matrix.md +25 -0
  46. package/skills/torusguard/payload/references/rust-security.md +40 -0
  47. package/skills/torusguard/payload/rules/custom/.gitkeep +1 -0
  48. package/skills/torusguard/payload/rules/custom/README.md +30 -0
  49. package/skills/torusguard/payload/schemas/golden-recipe.schema.json +75 -0
  50. package/skills/torusguard/payload/schemas/memory-context.schema.json +95 -0
  51. package/skills/torusguard/payload/schemas/memory-event.schema.json +70 -0
  52. package/skills/torusguard/payload/schemas/memory-pattern.schema.json +65 -0
  53. package/skills/torusguard/payload/scripts/diff_guard.py +202 -15
  54. package/skills/torusguard/payload/scripts/finding_scorer.py +199 -86
  55. package/skills/torusguard/payload/scripts/html_reporter.py +628 -0
  56. package/skills/torusguard/payload/scripts/manifest_builder.py +7 -5
  57. package/skills/torusguard/payload/scripts/memory_engine.py +1334 -0
  58. package/skills/torusguard/payload/scripts/monorepo_detector.py +123 -10
  59. package/skills/torusguard/payload/scripts/rules_sync.py +321 -0
  60. package/skills/torusguard/payload/scripts/run_manager.py +171 -89
  61. package/skills/torusguard/payload/scripts/stack_detect.py +458 -26
  62. package/skills/torusguard/payload/skills/torusguard/SKILL.md +4 -3
  63. package/skills/torusguard/payload/skills/torusguard/bootstrap.py +344 -56
  64. package/skills/torusguard/payload/skills/torusguard/references/csharp-security.md +41 -0
  65. package/skills/torusguard/payload/skills/torusguard/references/go-security.md +41 -0
  66. package/skills/torusguard/payload/skills/torusguard/references/java-security.md +40 -0
  67. package/skills/torusguard/payload/skills/torusguard/references/polyglot-security-matrix.md +25 -0
  68. package/skills/torusguard/payload/skills/torusguard/references/rust-security.md +40 -0
  69. package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +25 -25
  70. package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +3 -3
  71. package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +3 -3
  72. package/skills/torusguard/payload/workflows/memory.md +53 -0
  73. package/skills/torusguard-audit/SKILL.md +25 -25
  74. package/skills/torusguard-harden/SKILL.md +3 -3
  75. package/skills/torusguard-recheck/SKILL.md +3 -3
  76. package/.torusguard/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
  77. package/.torusguard/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
  78. package/skills/torusguard/__pycache__/bootstrap.cpython-311.pyc +0 -0
  79. package/skills/torusguard/payload/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
  80. package/skills/torusguard/payload/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
@@ -0,0 +1,328 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>TorusGuard Security Posture &middot; TorusGuard</title>
7
+ <style>
8
+ :root {
9
+ --bg-dark: #0d1117;
10
+ --bg-surface: #161b22;
11
+ --bg-card: #21262d;
12
+ --border-subtle: #30363d;
13
+ --text-main: #f0f6fc;
14
+ --text-muted: #8b949e;
15
+ --accent-blue: #58a6ff;
16
+ --accent-green: #3fb950;
17
+ --accent-yellow: #d29922;
18
+ --accent-red: #f85149;
19
+ --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji";
20
+ }
21
+ * { box-sizing: border-box; margin: 0; padding: 0; }
22
+ body {
23
+ background: var(--bg-dark);
24
+ color: var(--text-main);
25
+ font-family: var(--font-stack);
26
+ line-height: 1.5;
27
+ padding: 24px;
28
+ }
29
+ .container { max-width: 1200px; margin: 0 auto; }
30
+ header {
31
+ display: flex;
32
+ justify-content: space-between;
33
+ align-items: center;
34
+ padding-bottom: 20px;
35
+ border-bottom: 1px solid var(--border-subtle);
36
+ margin-bottom: 24px;
37
+ }
38
+ .logo-group h1 {
39
+ font-size: 24px;
40
+ font-weight: 700;
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 8px;
44
+ }
45
+ .shield-icon { font-size: 26px; }
46
+ .project-meta { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
47
+ .status-badge {
48
+ background: rgba(63, 185, 80, 0.15);
49
+ border: 1px solid var(--accent-green);
50
+ color: var(--accent-green);
51
+ padding: 6px 14px;
52
+ border-radius: 20px;
53
+ font-size: 13px;
54
+ font-weight: 600;
55
+ }
56
+ .grid-top {
57
+ display: grid;
58
+ grid-template-columns: 280px 1fr 1fr 1fr;
59
+ gap: 16px;
60
+ margin-bottom: 24px;
61
+ }
62
+ @media (max-width: 900px) {
63
+ .grid-top { grid-template-columns: 1fr 1fr; }
64
+ }
65
+ @media (max-width: 600px) {
66
+ .grid-top { grid-template-columns: 1fr; }
67
+ }
68
+ .card {
69
+ background: var(--bg-surface);
70
+ border: 1px solid var(--border-subtle);
71
+ border-radius: 8px;
72
+ padding: 20px;
73
+ }
74
+ .gauge-card {
75
+ display: flex;
76
+ flex-direction: column;
77
+ align-items: center;
78
+ justify-content: center;
79
+ text-align: center;
80
+ }
81
+ .gauge-svg { width: 120px; height: 120px; transform: rotate(-90deg); }
82
+ .gauge-bg { fill: none; stroke: var(--bg-card); stroke-width: 8; }
83
+ .gauge-fill {
84
+ fill: none;
85
+ stroke: #3fb950;
86
+ stroke-width: 8;
87
+ stroke-linecap: round;
88
+ stroke-dasharray: 251.2;
89
+ stroke-dashoffset: 37.68000000000001;
90
+ transition: stroke-dashoffset 0.8s ease;
91
+ }
92
+ .gauge-value {
93
+ position: absolute;
94
+ font-size: 32px;
95
+ font-weight: 700;
96
+ color: var(--text-main);
97
+ }
98
+ .stat-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
99
+ .stat-value { font-size: 28px; font-weight: 700; color: var(--text-main); }
100
+ .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
101
+ .pipeline-section { margin-bottom: 24px; }
102
+ .pipeline-tracker {
103
+ display: flex;
104
+ justify-content: space-between;
105
+ position: relative;
106
+ margin-top: 16px;
107
+ }
108
+ .pipeline-step {
109
+ display: flex;
110
+ flex-direction: column;
111
+ align-items: center;
112
+ flex: 1;
113
+ text-align: center;
114
+ position: relative;
115
+ z-index: 2;
116
+ }
117
+ .step-circle {
118
+ width: 32px;
119
+ height: 32px;
120
+ border-radius: 50%;
121
+ background: var(--bg-card);
122
+ border: 2px solid var(--accent-blue);
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: center;
126
+ font-size: 13px;
127
+ font-weight: 700;
128
+ color: var(--accent-blue);
129
+ margin-bottom: 8px;
130
+ }
131
+ .step-circle.active { background: var(--accent-blue); color: var(--bg-dark); }
132
+ .step-name { font-size: 12px; font-weight: 600; color: var(--text-main); }
133
+ .step-cmd { font-size: 11px; color: var(--text-muted); font-family: monospace; margin-top: 2px; }
134
+ .pipeline-line {
135
+ position: absolute;
136
+ top: 16px;
137
+ left: 6%;
138
+ right: 6%;
139
+ height: 2px;
140
+ background: var(--border-subtle);
141
+ z-index: 1;
142
+ }
143
+ .grid-bottom {
144
+ display: grid;
145
+ grid-template-columns: 1fr 1fr;
146
+ gap: 24px;
147
+ margin-top: 24px;
148
+ }
149
+ @media (max-width: 800px) {
150
+ .grid-bottom { grid-template-columns: 1fr; }
151
+ }
152
+ .section-title {
153
+ font-size: 18px;
154
+ font-weight: 600;
155
+ margin-bottom: 16px;
156
+ display: flex;
157
+ align-items: center;
158
+ gap: 8px;
159
+ }
160
+ .badge {
161
+ display: inline-block;
162
+ padding: 3px 8px;
163
+ border-radius: 12px;
164
+ font-size: 11px;
165
+ font-weight: 600;
166
+ font-family: monospace;
167
+ }
168
+ .badge-success { background: rgba(63, 185, 80, 0.15); color: var(--accent-green); border: 1px solid rgba(63, 185, 80, 0.3); }
169
+ .badge-danger { background: rgba(248, 81, 73, 0.15); color: var(--accent-red); border: 1px solid rgba(248, 81, 73, 0.3); }
170
+ .recipe-card {
171
+ background: var(--bg-card);
172
+ border: 1px solid var(--border-subtle);
173
+ border-radius: 6px;
174
+ padding: 12px;
175
+ margin-bottom: 12px;
176
+ }
177
+ .card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
178
+ .meta-label { font-size: 11px; color: var(--text-muted); }
179
+ .recipe-desc { font-size: 13px; color: var(--text-main); margin-bottom: 8px; }
180
+ .diff-block {
181
+ background: var(--bg-dark);
182
+ border: 1px solid var(--border-subtle);
183
+ border-radius: 4px;
184
+ padding: 8px 12px;
185
+ font-family: monospace;
186
+ font-size: 12px;
187
+ overflow-x: auto;
188
+ color: #e6edf3;
189
+ }
190
+ table { width: 100%; border-collapse: collapse; }
191
+ th, td { padding: 10px 12px; text-align: left; font-size: 13px; }
192
+ th { color: var(--text-muted); border-bottom: 1px solid var(--border-subtle); font-weight: 600; font-size: 12px; text-transform: uppercase; }
193
+ td { border-bottom: 1px solid rgba(48, 54, 61, 0.5); }
194
+ .empty-state { text-align: center; padding: 24px; color: var(--text-muted); font-size: 13px; }
195
+ .empty-cell { text-align: center; color: var(--text-muted); padding: 16px; font-style: italic; }
196
+ footer {
197
+ margin-top: 40px;
198
+ text-align: center;
199
+ color: var(--text-muted);
200
+ font-size: 12px;
201
+ border-top: 1px solid var(--border-subtle);
202
+ padding-top: 20px;
203
+ }
204
+ </style>
205
+ </head>
206
+ <body>
207
+ <div class="container">
208
+ <header>
209
+ <div class="logo-group">
210
+ <h1><span class="shield-icon">&#128737;</span> TorusGuard Security Posture</h1>
211
+ <div class="project-meta">Workspace: <strong>TorusGuard</strong> &middot; Stack: <strong>TypeScript</strong> &middot; 2026-09-07 11:55:40 UTC</div>
212
+ </div>
213
+ <div class="status-badge">&check; Local Governance Active</div>
214
+ </header>
215
+
216
+ <!-- Top KPI Grid -->
217
+ <div class="grid-top">
218
+ <div class="card gauge-card">
219
+ <div style="position: relative; display: flex; align-items: center; justify-content: center;">
220
+ <svg class="gauge-svg" viewBox="0 0 100 100">
221
+ <circle class="gauge-bg" cx="50" cy="50" r="40" />
222
+ <circle class="gauge-fill" cx="50" cy="50" r="40" />
223
+ </svg>
224
+ <div class="gauge-value">85</div>
225
+ </div>
226
+ <div class="stat-label" style="margin-top: 12px;">Security Posture Score</div>
227
+ </div>
228
+
229
+ <div class="card">
230
+ <div class="stat-label">Verified Golden Recipes</div>
231
+ <div class="stat-value" style="color: var(--accent-green);">0</div>
232
+ <div class="stat-sub">Distilled Ponytail fixes (<=35 add, <=25 del)</div>
233
+ </div>
234
+
235
+ <div class="card">
236
+ <div class="stat-label">Active Memory Patterns</div>
237
+ <div class="stat-value">0</div>
238
+ <div class="stat-sub">0 suppressed &middot; 0 recurring</div>
239
+ </div>
240
+
241
+ <div class="card">
242
+ <div class="stat-label">Security Rules Catalog</div>
243
+ <div class="stat-value" style="color: var(--accent-blue);">71</div>
244
+ <div class="stat-sub">11 rule families &middot; Multi-agent verified</div>
245
+ </div>
246
+ </div>
247
+
248
+ <!-- 7-Stage Canonical Pipeline Tracker -->
249
+ <div class="card pipeline-section">
250
+ <div class="section-title">&#9658; Canonical 7-Stage Closed-Loop Governance Flow</div>
251
+ <div class="pipeline-tracker">
252
+ <div class="pipeline-line"></div>
253
+ <div class="pipeline-step">
254
+ <div class="step-circle active">1</div>
255
+ <div class="step-name">Scan</div>
256
+ <div class="step-cmd">/audit</div>
257
+ </div>
258
+ <div class="pipeline-step">
259
+ <div class="step-circle active">2</div>
260
+ <div class="step-name">Score</div>
261
+ <div class="step-cmd">0-100</div>
262
+ </div>
263
+ <div class="pipeline-step">
264
+ <div class="step-circle active">3</div>
265
+ <div class="step-name">Harden</div>
266
+ <div class="step-cmd">/harden</div>
267
+ </div>
268
+ <div class="pipeline-step">
269
+ <div class="step-circle active">4</div>
270
+ <div class="step-name">Authorize</div>
271
+ <div class="step-cmd">Human Gate</div>
272
+ </div>
273
+ <div class="pipeline-step">
274
+ <div class="step-circle active">5</div>
275
+ <div class="step-name">Apply</div>
276
+ <div class="step-cmd">.bak Snapshot</div>
277
+ </div>
278
+ <div class="pipeline-step">
279
+ <div class="step-circle active">6</div>
280
+ <div class="step-name">Recheck</div>
281
+ <div class="step-cmd">Differential</div>
282
+ </div>
283
+ <div class="pipeline-step">
284
+ <div class="step-circle active">7</div>
285
+ <div class="step-name">Report</div>
286
+ <div class="step-cmd">SARIF v2.1.0</div>
287
+ </div>
288
+ </div>
289
+ </div>
290
+
291
+ <!-- Bottom Details Grid -->
292
+ <div class="grid-bottom">
293
+ <!-- Golden Recipes Catalog -->
294
+ <div class="card">
295
+ <div class="section-title">&#10024; Active Golden Fix Recipes (0)</div>
296
+ <div class="recipes-list">
297
+
298
+ <div class="empty-state">
299
+ <p>No golden fix recipes captured yet. Run <code>/torusguard-apply</code> on verified remediations to distill reusable recipes.</p>
300
+ </div>
301
+
302
+ </div>
303
+ </div>
304
+
305
+ <!-- Regression Watches & False Positives -->
306
+ <div class="card">
307
+ <div class="section-title">&#128065; Regression Watches & Suppressions</div>
308
+ <table>
309
+ <thead>
310
+ <tr>
311
+ <th>Rule ID</th>
312
+ <th>Description / Reason</th>
313
+ <th>Target Path</th>
314
+ </tr>
315
+ </thead>
316
+ <tbody>
317
+ <tr><td colspan='3' class='empty-cell'>Zero active security regressions detected. Posture clean.</td></tr>
318
+ </tbody>
319
+ </table>
320
+ </div>
321
+ </div>
322
+
323
+ <footer>
324
+ TorusGuard v1.2.0 &middot; Autonomous Security Engine for AI-Built Applications &middot; 100% Local-First &middot; Zero Cloud Telemetry Leakage
325
+ </footer>
326
+ </div>
327
+ </body>
328
+ </html>
@@ -0,0 +1,75 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://torusguard.dev/schemas/golden-recipe.schema.json",
4
+ "title": "TorusGuard Golden Fix Recipe Schema",
5
+ "description": "Schema for reusable, verified AST remediation code snippets distilled from passing security patches.",
6
+ "type": "object",
7
+ "required": [
8
+ "recipe_id",
9
+ "rule_id",
10
+ "file_type",
11
+ "before_snippet",
12
+ "after_snippet",
13
+ "diff_snippet",
14
+ "ponytail_metrics",
15
+ "verified_count",
16
+ "last_verified"
17
+ ],
18
+ "properties": {
19
+ "recipe_id": {
20
+ "type": "string",
21
+ "pattern": "^recipe-[A-Za-z0-9_-]+$"
22
+ },
23
+ "rule_id": {
24
+ "type": "string",
25
+ "pattern": "^TG-[A-Z]+-[0-9]{3}$"
26
+ },
27
+ "file_type": {
28
+ "type": "string",
29
+ "description": "File extension or language identifier (e.g., .py, .ts, .js)"
30
+ },
31
+ "framework": {
32
+ "type": ["string", "null"],
33
+ "description": "Target web framework (e.g., Django, FastAPI, Next.js)"
34
+ },
35
+ "description": {
36
+ "type": "string",
37
+ "description": "Human-readable summary of the fix strategy"
38
+ },
39
+ "before_snippet": {
40
+ "type": "string",
41
+ "description": "Vulnerable code pattern before remediation"
42
+ },
43
+ "after_snippet": {
44
+ "type": "string",
45
+ "description": "Remediated code pattern adhering to Ponytail bounds"
46
+ },
47
+ "diff_snippet": {
48
+ "type": "string",
49
+ "description": "Unified diff snippet representing the surgical fix"
50
+ },
51
+ "ponytail_metrics": {
52
+ "type": "object",
53
+ "required": ["additions", "deletions"],
54
+ "properties": {
55
+ "additions": {
56
+ "type": "integer",
57
+ "maximum": 35
58
+ },
59
+ "deletions": {
60
+ "type": "integer",
61
+ "maximum": 25
62
+ }
63
+ }
64
+ },
65
+ "verified_count": {
66
+ "type": "integer",
67
+ "minimum": 1
68
+ },
69
+ "last_verified": {
70
+ "type": "string",
71
+ "format": "date-time"
72
+ }
73
+ },
74
+ "additionalProperties": false
75
+ }
@@ -0,0 +1,95 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "torusguard-memory-context.schema.json",
4
+ "title": "TorusGuard Memory Context Window",
5
+ "description": "Pre-computed, token-budgeted context window for AI agent consumption formatted as structured JSON cards.",
6
+ "type": "object",
7
+ "required": ["version", "generated_at", "token_estimate", "max_token_budget", "project_profile", "cards"],
8
+ "properties": {
9
+ "version": {
10
+ "type": "string",
11
+ "description": "TorusGuard engine version (e.g., 1.0.0)."
12
+ },
13
+ "generated_at": {
14
+ "type": "string",
15
+ "format": "date-time",
16
+ "description": "ISO 8601 UTC timestamp when this context window was computed."
17
+ },
18
+ "token_estimate": {
19
+ "type": "integer",
20
+ "minimum": 0,
21
+ "description": "Estimated token count of this context document."
22
+ },
23
+ "max_token_budget": {
24
+ "type": "integer",
25
+ "default": 2000,
26
+ "description": "Maximum allowed tokens for agent context injection (default: 2000)."
27
+ },
28
+ "project_profile": {
29
+ "type": "object",
30
+ "required": ["stack", "total_events", "active_patterns_count"],
31
+ "properties": {
32
+ "stack": {
33
+ "type": "array",
34
+ "items": { "type": "string" },
35
+ "description": "Detected technology stack frameworks/languages."
36
+ },
37
+ "total_events": {
38
+ "type": "integer",
39
+ "minimum": 0
40
+ },
41
+ "active_patterns_count": {
42
+ "type": "integer",
43
+ "minimum": 0
44
+ },
45
+ "fix_rate_percentage": {
46
+ "type": ["number", "null"],
47
+ "minimum": 0,
48
+ "maximum": 100
49
+ },
50
+ "top_vulnerabilities": {
51
+ "type": "array",
52
+ "items": { "type": "string" }
53
+ }
54
+ }
55
+ },
56
+ "cards": {
57
+ "type": "array",
58
+ "description": "Ordered list of high-priority intelligence cards for LLM grounding.",
59
+ "items": {
60
+ "type": "object",
61
+ "required": ["card_id", "card_type", "priority", "title", "summary", "card_data"],
62
+ "properties": {
63
+ "card_id": {
64
+ "type": "string",
65
+ "description": "Unique card identifier (e.g., CARD-001)."
66
+ },
67
+ "card_type": {
68
+ "type": "string",
69
+ "enum": ["pattern", "profile", "regression_watch", "false_positive", "fix_idiom"],
70
+ "description": "Semantic category of this context card."
71
+ },
72
+ "priority": {
73
+ "type": "integer",
74
+ "minimum": 1,
75
+ "maximum": 100,
76
+ "description": "Rank order priority (higher = more relevant/critical)."
77
+ },
78
+ "title": {
79
+ "type": "string",
80
+ "description": "Short, human-readable and agent-scannable card title."
81
+ },
82
+ "summary": {
83
+ "type": "string",
84
+ "description": "One-line operational summary for rapid agent reasoning."
85
+ },
86
+ "card_data": {
87
+ "type": "object",
88
+ "description": "Structured card payload containing rule_id, fix_strategy, confidence, affected_files, etc.",
89
+ "additionalProperties": true
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
@@ -0,0 +1,70 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "torusguard-memory-event.schema.json",
4
+ "title": "TorusGuard Memory Event",
5
+ "description": "Schema for individual memory events recorded during audit/fix/recheck cycles.",
6
+ "type": "object",
7
+ "required": ["event_id", "event_type", "timestamp", "version"],
8
+ "properties": {
9
+ "event_id": {
10
+ "type": "string",
11
+ "description": "Unique event identifier (UUID v4 or timestamp-based)."
12
+ },
13
+ "event_type": {
14
+ "type": "string",
15
+ "enum": ["audit_finding", "fix_applied", "fix_verified", "false_positive", "pattern_learned", "stack_changed"],
16
+ "description": "Category of security event."
17
+ },
18
+ "timestamp": {
19
+ "type": "string",
20
+ "format": "date-time",
21
+ "description": "ISO 8601 UTC timestamp."
22
+ },
23
+ "version": {
24
+ "type": "string",
25
+ "description": "TorusGuard version that recorded this event."
26
+ },
27
+ "rule_id": {
28
+ "type": ["string", "null"],
29
+ "description": "TorusGuard rule ID (e.g., TG-DB-004)."
30
+ },
31
+ "file_path": {
32
+ "type": ["string", "null"],
33
+ "description": "Relative file path within the project."
34
+ },
35
+ "line_number": {
36
+ "type": ["integer", "null"],
37
+ "description": "Line number of the finding."
38
+ },
39
+ "severity": {
40
+ "type": ["string", "null"],
41
+ "enum": ["critical", "high", "medium", "low", "info", null]
42
+ },
43
+ "confidence_score": {
44
+ "type": ["integer", "null"],
45
+ "minimum": 0,
46
+ "maximum": 100
47
+ },
48
+ "code_hash": {
49
+ "type": ["string", "null"],
50
+ "description": "SHA-256 hash of the relevant code snippet for pattern matching."
51
+ },
52
+ "fix_strategy": {
53
+ "type": ["string", "null"],
54
+ "description": "Human-readable description of the fix approach used."
55
+ },
56
+ "verification_result": {
57
+ "type": ["string", "null"],
58
+ "enum": ["fixed", "regressed", "partial", "not_tested", null]
59
+ },
60
+ "suppression_reason": {
61
+ "type": ["string", "null"],
62
+ "description": "Reason for false positive suppression."
63
+ },
64
+ "metadata": {
65
+ "type": "object",
66
+ "description": "Additional event-specific metadata.",
67
+ "additionalProperties": true
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "torusguard-memory-pattern.schema.json",
4
+ "title": "TorusGuard Memory Pattern",
5
+ "description": "Schema for distilled security patterns extracted from raw events. Patterns represent recurring fix strategies, vulnerability classes, and project-specific security idioms.",
6
+ "type": "object",
7
+ "required": ["pattern_id", "rule_id", "pattern_type", "confidence", "occurrences", "first_seen", "last_seen"],
8
+ "properties": {
9
+ "pattern_id": {
10
+ "type": "string",
11
+ "description": "Unique pattern identifier (PAT-NNN)."
12
+ },
13
+ "rule_id": {
14
+ "type": "string",
15
+ "description": "TorusGuard rule ID this pattern relates to."
16
+ },
17
+ "pattern_type": {
18
+ "type": "string",
19
+ "enum": ["recurring_fix", "common_vulnerability", "false_positive_class", "regression_watch", "security_idiom"],
20
+ "description": "Category of the distilled pattern."
21
+ },
22
+ "description": {
23
+ "type": "string",
24
+ "description": "Human-readable summary of the pattern."
25
+ },
26
+ "fix_strategy": {
27
+ "type": ["string", "null"],
28
+ "description": "The preferred fix approach observed across multiple occurrences."
29
+ },
30
+ "confidence": {
31
+ "type": "integer",
32
+ "minimum": 0,
33
+ "maximum": 100,
34
+ "description": "Pattern confidence (amplified by repeated confirmations, decayed by TTL)."
35
+ },
36
+ "occurrences": {
37
+ "type": "integer",
38
+ "minimum": 1,
39
+ "description": "Number of times this pattern has been observed."
40
+ },
41
+ "affected_files": {
42
+ "type": "array",
43
+ "items": { "type": "string" },
44
+ "description": "List of relative file paths where this pattern has been observed."
45
+ },
46
+ "first_seen": {
47
+ "type": "string",
48
+ "format": "date-time"
49
+ },
50
+ "last_seen": {
51
+ "type": "string",
52
+ "format": "date-time"
53
+ },
54
+ "decay_checkpoint": {
55
+ "type": ["string", "null"],
56
+ "format": "date-time",
57
+ "description": "Last timestamp when this pattern's confidence was reconfirmed or decayed."
58
+ },
59
+ "source_events": {
60
+ "type": "array",
61
+ "items": { "type": "string" },
62
+ "description": "List of event_ids that contributed to this pattern."
63
+ }
64
+ }
65
+ }