archsutra-ai 0.1.5 → 0.2.1

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 (113) hide show
  1. package/CHANGELOG.md +58 -6
  2. package/README.md +87 -15
  3. package/dist/audit.js +125 -44
  4. package/dist/cli.js +184 -96
  5. package/dist/drift.js +29 -15
  6. package/dist/fsutil.js +117 -20
  7. package/dist/history.js +40 -0
  8. package/dist/html.js +10 -8
  9. package/dist/map.js +26 -5
  10. package/dist/mcp.js +70 -55
  11. package/dist/redact.js +24 -11
  12. package/dist/report.js +69 -19
  13. package/dist/rules-extra.js +59 -0
  14. package/dist/secret-patterns.js +69 -0
  15. package/dist/suppress.js +31 -19
  16. package/dist/verify.js +2 -2
  17. package/dist/write.js +71 -0
  18. package/docs/architecture/overview.html +29 -12
  19. package/docs/architecture/overview.md +2 -2
  20. package/docs/architecture/threat-model.html +28 -11
  21. package/docs/assets/charts/coverage-dark.svg +11 -0
  22. package/docs/assets/charts/coverage.svg +11 -0
  23. package/docs/assets/charts/finding-anatomy-dark.svg +20 -0
  24. package/docs/assets/charts/finding-anatomy.svg +20 -0
  25. package/docs/assets/charts/pipeline-dark.svg +13 -0
  26. package/docs/assets/charts/pipeline.svg +13 -0
  27. package/docs/assets/charts/precision-by-batch-dark.svg +12 -0
  28. package/docs/assets/charts/precision-by-batch.svg +12 -0
  29. package/docs/assets/charts/precision-by-rule-dark.svg +12 -0
  30. package/docs/assets/charts/precision-by-rule.svg +12 -0
  31. package/docs/assets/charts/sample-findings-by-severity-dark.svg +11 -0
  32. package/docs/assets/charts/sample-findings-by-severity.svg +11 -0
  33. package/docs/assets/charts/scan-time-dark.svg +11 -0
  34. package/docs/assets/charts/scan-time.svg +11 -0
  35. package/docs/assets/site.css +259 -138
  36. package/docs/assets/site.js +92 -6
  37. package/docs/community/good-first-issues.html +28 -11
  38. package/docs/compatibility/matrix.html +28 -11
  39. package/docs/compatibility/smoke-tests/index.html +28 -11
  40. package/docs/decisions/ADR-0001-deterministic-cli-plus-ide-skills.html +28 -11
  41. package/docs/guides/cheat-sheet.html +100 -0
  42. package/docs/guides/cheat-sheet.md +146 -0
  43. package/docs/guides/ci-recipes.html +170 -0
  44. package/docs/guides/ci-recipes.md +176 -0
  45. package/docs/guides/evidence-at-a-glance.html +93 -0
  46. package/docs/guides/evidence-at-a-glance.md +65 -0
  47. package/docs/guides/getting-started.html +151 -0
  48. package/docs/guides/getting-started.md +160 -0
  49. package/docs/guides/how-it-works.html +161 -0
  50. package/docs/guides/how-it-works.md +148 -0
  51. package/docs/guides/mcp-server.html +99 -0
  52. package/docs/guides/mcp-server.md +81 -0
  53. package/docs/guides/reading-a-report.html +119 -0
  54. package/docs/guides/reading-a-report.md +111 -0
  55. package/docs/guides/real-world-scenarios.html +287 -0
  56. package/docs/guides/real-world-scenarios.md +377 -0
  57. package/docs/handbook/01-executive-summary.html +30 -13
  58. package/docs/handbook/01-executive-summary.md +2 -2
  59. package/docs/handbook/02-functional-specification.html +30 -13
  60. package/docs/handbook/02-functional-specification.md +3 -3
  61. package/docs/handbook/03-technical-specification.html +31 -14
  62. package/docs/handbook/03-technical-specification.md +3 -3
  63. package/docs/handbook/04-architecture.html +29 -12
  64. package/docs/handbook/04-architecture.md +1 -1
  65. package/docs/handbook/05-user-guide.html +33 -15
  66. package/docs/handbook/05-user-guide.md +5 -4
  67. package/docs/handbook/06-cli-reference.html +52 -16
  68. package/docs/handbook/06-cli-reference.md +47 -4
  69. package/docs/handbook/07-security-privacy-legal.html +31 -12
  70. package/docs/handbook/07-security-privacy-legal.md +4 -0
  71. package/docs/handbook/08-testing-and-proof.html +32 -15
  72. package/docs/handbook/08-testing-and-proof.md +4 -4
  73. package/docs/handbook/09-compatibility-and-roadmap.html +33 -16
  74. package/docs/handbook/09-compatibility-and-roadmap.md +8 -7
  75. package/docs/handbook/10-contributor-guide.html +29 -12
  76. package/docs/handbook/10-contributor-guide.md +1 -1
  77. package/docs/handbook/11-glossary-and-faq.html +34 -13
  78. package/docs/handbook/11-glossary-and-faq.md +7 -1
  79. package/docs/handbook/12-rule-catalog.html +59 -19
  80. package/docs/handbook/12-rule-catalog.md +62 -5
  81. package/docs/handbook/13-trust-and-assurance.html +29 -12
  82. package/docs/handbook/13-trust-and-assurance.md +1 -1
  83. package/docs/handbook/14-real-world-evaluation.html +28 -11
  84. package/docs/handbook/15-supply-chain-and-release.html +28 -11
  85. package/docs/handbook/16-performance-and-quality-metrics.html +28 -11
  86. package/docs/handbook/16-performance-and-quality-metrics.md +1 -1
  87. package/docs/handbook/README.md +4 -2
  88. package/docs/handbook/index.html +31 -13
  89. package/docs/index.html +101 -51
  90. package/docs/legal/legal-review-brief.html +28 -11
  91. package/docs/legal/trademark-and-name-clearance.html +28 -11
  92. package/docs/proof/accessibility.html +28 -11
  93. package/docs/proof/benchmarks.json +9 -9
  94. package/docs/proof/benchmarks.md +4 -4
  95. package/docs/proof/test-results.txt +56 -40
  96. package/docs/rfc/0001-archsutra-v0.1.html +28 -11
  97. package/docs/sample-report/architecture-register.json +46 -0
  98. package/docs/sample-report/audit-report.html +123 -0
  99. package/docs/sample-report/audit-report.md +314 -0
  100. package/docs/sample-report/current-state.html +77 -0
  101. package/docs/sample-report/current-state.md +51 -0
  102. package/docs/sample-report/findings.json +478 -0
  103. package/docs/sample-report/findings.sarif +754 -0
  104. package/docs/sample-report/index.html +57 -0
  105. package/docs/sample-report/overview.md +11 -0
  106. package/docs/search-index.json +1 -0
  107. package/docs/sitemap.xml +39 -28
  108. package/llms.txt +12 -3
  109. package/package.json +3 -2
  110. package/schemas/findings.schema.json +4 -3
  111. package/skills/architecture-audit/SKILL.md +2 -2
  112. package/skills/architecture-audit/references/report-template.md +1 -1
  113. package/skills/architecture-verification/references/fitness-functions.md +1 -1
package/dist/report.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
- export const FINDINGS_SCHEMA_VERSION = '1.0.0';
2
+ import { readFileSync } from 'node:fs';
3
+ export const FINDINGS_SCHEMA_VERSION = '1.1.0';
3
4
  const mid = (s) => s.replace(/[^A-Za-z0-9]/g, '_');
4
5
  const q = (s) => s.replace(/"/g, "'");
5
6
  export function mermaidContainers(map) {
@@ -33,8 +34,10 @@ export function renderFinding(f) {
33
34
  `|---|---|---|---|---|`,
34
35
  `| ${f.severity} | ${f.confidence} | ${f.category} | ${f.effort} | ${f.ownerType} |`,
35
36
  '',
37
+ ...(f.cwe ? [`**Classification:** ${f.cwe}, OWASP ${f.owasp}`, ''] : []),
36
38
  '**Evidence**',
37
- ...f.evidence.map(evLine),
39
+ ...f.evidence.slice(0, 10).map(evLine),
40
+ ...(f.evidence.length > 10 ? [`- ... and ${f.evidence.length - 10} more (all listed in findings.json and findings.sarif)`] : []),
38
41
  '',
39
42
  `**Impact:** ${f.impact}`,
40
43
  '',
@@ -50,6 +53,13 @@ export function renderFinding(f) {
50
53
  ...(f.references.length ? [`**References:** ${f.references.join(', ')}`, ''] : []),
51
54
  ].join('\n');
52
55
  }
56
+ function coverageLines(c) {
57
+ const partial = c.folders.filter((f) => f.scanned < f.total);
58
+ return [
59
+ ...(partial.length ? ['### Folders not fully scanned', '', '| Folder | Scanned | Found |', '|---|---|---|', ...partial.slice(0, 40).map((f) => `| \`${f.name}\` | ${f.scanned} | ${f.total} |`), ''] : []),
60
+ ...(c.skippedPaths.length ? ['### Skipped paths', '', ...c.skippedPaths.slice(0, 30).map((p) => `- \`${p.path}\`: ${p.reason}`), ...(c.skippedPaths.length > 30 ? ['- ... more in findings.json'] : []), ''] : []),
61
+ ];
62
+ }
53
63
  export function renderAuditReport(r) {
54
64
  const bySev = (s) => r.findings.filter((f) => f.severity === s).length;
55
65
  return [
@@ -63,12 +73,14 @@ export function renderAuditReport(r) {
63
73
  `- Stack observed: ${r.map.ecosystems.join(', ') || 'none recognised'}`,
64
74
  `- Findings: ${r.findings.length} (critical ${bySev('critical')}, high ${bySev('high')}, medium ${bySev('medium')}, low ${bySev('low')}, info ${bySev('info')})`,
65
75
  '',
66
- '## Scorecard',
67
- '',
68
- '| Category | Rating | Basis |',
69
- '|---|---|---|',
70
- ...r.scorecard.map((s) => `| ${s.category} | ${s.rating} | ${s.basis} |`),
71
- '',
76
+ ...(r.scorecard.length ? [
77
+ '## Scorecard',
78
+ '',
79
+ '| Category | Rating | Confidence | Basis |',
80
+ '|---|---|---|---|',
81
+ ...r.scorecard.map((s) => `| ${s.category} | ${s.rating} | ${s.confidence} | ${s.basis} |`),
82
+ '',
83
+ ] : []),
72
84
  '## Findings',
73
85
  '',
74
86
  r.findings.length ? r.findings.map(renderFinding).join('\n') : '_No findings from the implemented rules. This does not prove the absence of problems._',
@@ -80,6 +92,8 @@ export function renderAuditReport(r) {
80
92
  '',
81
93
  `Skipped: ${JSON.stringify(r.map.coverage.skipped)}`,
82
94
  '',
95
+ ...coverageLines(r.map.coverage),
96
+ ...(r.suppressed.length ? [`Suppressed by .archsutra/suppress.json: ${r.suppressed.reduce((n, f) => n + f.evidence.length, 0)} location(s).`, ''] : []),
83
97
  ].join('\n');
84
98
  }
85
99
  export function renderCurrentState(map) {
@@ -146,14 +160,32 @@ export function findingsJson(r) {
146
160
  coverage: r.map.coverage,
147
161
  blindSpots: r.map.blindSpots,
148
162
  failedChecks: r.failedChecks,
163
+ suppressed: r.suppressed,
149
164
  };
150
165
  }
151
166
  const SARIF_LEVEL = { critical: 'error', high: 'error', medium: 'warning', low: 'note', info: 'note' };
167
+ const SECURITY_SEVERITY = { critical: '9.5', high: '8.0', medium: '5.5', low: '3.0', info: '0.0' };
168
+ const pascal = (title) => title.split(/[^A-Za-z0-9]+/).filter(Boolean).map((w) => w[0].toUpperCase() + w.slice(1)).join('');
152
169
  export function renderSarif(r) {
170
+ const { version } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
153
171
  const rules = new Map();
154
- for (const f of r.findings)
172
+ for (const f of [...r.findings, ...r.suppressed])
155
173
  if (!rules.has(f.rule))
156
174
  rules.set(f.rule, f);
175
+ const cwes = [...new Set([...rules.values()].flatMap((f) => (f.cwe ? [f.cwe.slice(4)] : [])))].sort();
176
+ const home = 'https://github.com/shahvatsalofficial/archsutra-ai';
177
+ const result = (f, e, reason) => {
178
+ // Repository-level findings have no file; code scanning needs one, so they anchor to README.md.
179
+ const repoLevel = !e.path || e.path === '.';
180
+ return {
181
+ ruleId: f.rule,
182
+ level: SARIF_LEVEL[f.severity],
183
+ message: { text: `${f.title}. ${f.impact}` },
184
+ locations: [{ physicalLocation: { artifactLocation: { uri: repoLevel ? 'README.md' : encodeURI(e.path).replace(/#/g, '%23'), uriBaseId: '%SRCROOT%' }, region: { startLine: e.startLine ?? 1, endLine: e.endLine ?? e.startLine ?? 1 } } }],
185
+ ...(e.fingerprint ? { partialFingerprints: { 'archsutra/v1': e.fingerprint } } : {}),
186
+ ...(reason ? { suppressions: [{ kind: 'external', justification: reason }] } : {}),
187
+ };
188
+ };
157
189
  return {
158
190
  $schema: 'https://json.schemastore.org/sarif-2.1.0.json',
159
191
  version: '2.1.0',
@@ -162,18 +194,36 @@ export function renderSarif(r) {
162
194
  tool: {
163
195
  driver: {
164
196
  name: 'ArchSutra AI',
165
- informationUri: 'https://github.com/shahvatsalofficial/archsutra-ai',
166
- rules: [...rules.values()].map((f) => ({ id: f.rule, name: f.title, shortDescription: { text: f.title }, help: { text: f.fix } })),
197
+ semanticVersion: version,
198
+ informationUri: home,
199
+ rules: [...rules.values()].map((f) => {
200
+ const security = f.category === 'security' || f.category === 'ai-security';
201
+ return {
202
+ id: f.rule,
203
+ name: pascal(f.title),
204
+ shortDescription: { text: f.title },
205
+ fullDescription: { text: f.whyItMatters },
206
+ help: { text: f.fix },
207
+ helpUri: `${home}/blob/main/docs/handbook/12-rule-catalog.md`,
208
+ defaultConfiguration: { level: SARIF_LEVEL[f.severity] },
209
+ ...(f.cwe ? { relationships: [{ target: { id: f.cwe.slice(4), toolComponent: { name: 'CWE' } }, kinds: ['superset'] }] } : {}),
210
+ properties: {
211
+ precision: f.confidence,
212
+ tags: [...new Set([f.category, ...(security ? ['security'] : []), ...(f.cwe ? [`external/cwe/${f.cwe.toLowerCase()}`] : [])])],
213
+ ...(security ? { 'security-severity': SECURITY_SEVERITY[f.severity] } : {}),
214
+ },
215
+ };
216
+ }),
167
217
  },
168
218
  },
169
- results: r.findings.flatMap((f) => f.evidence
170
- .filter((e) => e.path && e.path !== '.')
171
- .map((e) => ({
172
- ruleId: f.rule,
173
- level: SARIF_LEVEL[f.severity],
174
- message: { text: `${f.title}. ${f.impact}` },
175
- locations: [{ physicalLocation: { artifactLocation: { uri: e.path }, region: { startLine: e.startLine ?? 1, endLine: e.endLine ?? e.startLine ?? 1 } } }],
176
- }))),
219
+ ...(cwes.length ? { taxonomies: [{ name: 'CWE', organization: 'MITRE', shortDescription: { text: 'Common Weakness Enumeration' }, taxa: cwes.map((id) => ({ id })) }] } : {}),
220
+ originalUriBaseIds: { '%SRCROOT%': { description: { text: 'Root of the scanned project' } } },
221
+ automationDetails: { id: 'archsutra/' },
222
+ invocations: [{ executionSuccessful: r.failedChecks.length === 0, properties: { filesScanned: r.map.coverage.filesScanned, truncated: r.map.coverage.truncated } }],
223
+ results: [
224
+ ...r.findings.flatMap((f) => f.evidence.map((e) => result(f, e))),
225
+ ...r.suppressed.flatMap((f) => f.evidence.map((e) => result(f, e, f.reason))),
226
+ ],
177
227
  },
178
228
  ],
179
229
  };
@@ -0,0 +1,59 @@
1
+ /** CWE and OWASP Top 10 (2021) class per rule. */
2
+ export const CLASSIFICATION = {
3
+ 'AS-SEC-001': ['CWE-798', 'A07:2021'], 'AS-SEC-002': ['CWE-321', 'A02:2021'], 'AS-SEC-003': ['CWE-538', 'A05:2021'],
4
+ 'AS-SEC-004': ['CWE-95', 'A03:2021'], 'AS-SEC-005': ['CWE-89', 'A03:2021'], 'AS-SEC-006': ['CWE-295', 'A02:2021'],
5
+ 'AS-SEC-007': ['CWE-502', 'A08:2021'], 'AS-SEC-008': ['CWE-327', 'A02:2021'], 'AS-SEC-009': ['CWE-338', 'A02:2021'],
6
+ 'AS-SEC-010': ['CWE-79', 'A03:2021'], 'AS-SEC-011': ['CWE-942', 'A05:2021'], 'AS-SEC-012': ['CWE-347', 'A02:2021'],
7
+ 'AS-SEC-013': ['CWE-22', 'A01:2021'], 'AS-SEC-014': ['CWE-918', 'A10:2021'], 'AS-SEC-015': ['CWE-611', 'A05:2021'],
8
+ 'AS-SEC-016': ['CWE-78', 'A03:2021'], 'AS-SEC-017': ['CWE-327', 'A02:2021'], 'AS-IAC-001': ['CWE-284', 'A05:2021'],
9
+ 'AS-OPS-003': ['CWE-250', 'A05:2021'], 'AS-SUP-001': ['CWE-1357', 'A06:2021'], 'AS-SUP-002': ['CWE-1357', 'A06:2021'],
10
+ 'AS-SUP-003': ['CWE-1357', 'A06:2021'], 'AS-AI-001': ['CWE-94', 'A03:2021'],
11
+ };
12
+ const JS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'];
13
+ function build(s) {
14
+ return {
15
+ rule: s.id, re: s.re, exts: new Set(s.exts), codeOnly: true, skipTests: true, also: s.also, near: s.near,
16
+ make: (hits) => ({
17
+ rule: s.id, title: s.title, category: 'security', severity: s.severity, confidence: s.confidence, evidence: hits,
18
+ impact: s.impact, whyItMatters: `${CLASSIFICATION[s.id][0]}, OWASP ${CLASSIFICATION[s.id][1]}.`, fix: s.fix,
19
+ verification: 'Trace where the value comes from; add a test with hostile input.',
20
+ acceptanceCriteria: 'No remaining match without a documented reason.',
21
+ effort: 'S', ownerType: 'application developer',
22
+ caveats: 'Pattern match only. Confirm by data-flow review.',
23
+ references: [`https://cwe.mitre.org/data/definitions/${CLASSIFICATION[s.id][0].slice(4)}.html`],
24
+ }),
25
+ };
26
+ }
27
+ export const EXTRA_RULES = [
28
+ build({ id: 'AS-SEC-009', title: 'Non-cryptographic randomness for a secret value', severity: 'medium', confidence: 'medium', exts: [...JS, '.py'],
29
+ re: /(?:token|secret|passw|otp|nonce|session|api_?key|salt)\w*[^\n]*?(?:Math\.random\s*\(|\brandom\.(?:random|randint|choice|choices|randrange)\s*\()/i,
30
+ impact: 'Tokens or codes can be predicted.', fix: 'Use crypto.randomBytes / crypto.randomUUID, or the Python secrets module.' }),
31
+ build({ id: 'AS-SEC-010', title: 'HTML built from a variable (cross-site scripting sink)', severity: 'medium', confidence: 'low', exts: [...JS, '.vue', '.svelte'],
32
+ re: /\.(?:inner|outer)HTML\s*\+?=\s*(?!\s*(["'`])(?:(?!\1)[^$])*\1\s*(?:;|$))\S|dangerouslySetInnerHTML\s*=|\bdocument\.write(?:ln)?\s*\(\s*(?!["'][^"']*["']\s*\))[^)]/,
33
+ also: (t) => !/sanitiz|DOMPurify|escape/i.test(t),
34
+ impact: 'Attacker-controlled text can run script in a visitor browser.', fix: 'Use textContent or framework escaping; sanitise HTML that must be rendered.' }),
35
+ build({ id: 'AS-SEC-011', title: 'Cross-origin requests allowed from any origin with credentials', severity: 'high', confidence: 'medium', exts: [...JS, '.py'],
36
+ re: /\borigin\s*:\s*(?:true\b|["']\*["'])|allow_origins\s*=\s*\[\s*["']\*["']/, near: /\bcredentials\s*:\s*true|allow_credentials\s*=\s*True/,
37
+ impact: 'Any website can make authenticated requests on behalf of a signed-in user.', fix: 'List the allowed origins explicitly.' }),
38
+ build({ id: 'AS-SEC-012', title: 'Token signature check disabled', severity: 'high', confidence: 'high', exts: [...JS, '.py'],
39
+ re: /\balgorithms?\s*[:=]\s*\[?\s*["']none["']|jwt\.decode\s*\([^\n]*(?:verify\s*=\s*False|["']verify_signature["']\s*:\s*False)/i,
40
+ impact: 'Anyone can forge a token.', fix: 'Verify signatures with an explicit algorithm allowlist.' }),
41
+ build({ id: 'AS-SEC-013', title: 'File path taken from the request', severity: 'high', confidence: 'medium', exts: [...JS, '.py'],
42
+ re: /\b(?:open|readFile(?:Sync)?|createReadStream|sendFile|send_file)\s*\([^\n]*\b(?:req|request)\.(?:params|query|body|args|form|GET|POST)\b/,
43
+ impact: 'Files outside the intended folder can be read.', fix: 'Resolve the path and require it to stay inside an allowed folder.' }),
44
+ build({ id: 'AS-SEC-014', title: 'Outbound request URL taken from the request', severity: 'high', confidence: 'medium', exts: [...JS, '.py'],
45
+ re: /\b(?:fetch|axios(?:\.\w+)?|requests\.(?:get|post|put|delete|head)|urlopen|https?\.get)\s*\(\s*(?:req|request)\.(?:params|query|body|args|form|GET|POST)\b/,
46
+ impact: 'The server can be made to call internal services.', fix: 'Allowlist hosts and block private address ranges.' }),
47
+ build({ id: 'AS-SEC-015', title: 'XML parser resolves external entities', severity: 'high', confidence: 'medium', exts: [...JS, '.py', '.php', '.java'],
48
+ re: /\bresolve_entities\s*=\s*True|\bnoent\s*:\s*true|\bLIBXML_NOENT\b|external-(?:general|parameter)-entities["']\s*,\s*true/,
49
+ impact: 'Local files and internal URLs can be read through crafted XML.', fix: 'Disable external entity and DTD processing.' }),
50
+ build({ id: 'AS-SEC-016', title: 'Operating system command built from input', severity: 'high', confidence: 'medium', exts: ['.php', '.java', '.kt', '.go', '.rb'],
51
+ re: /\b(?:system|exec|shell_exec|passthru|popen)\s*\([^)\n]*\$_(?:GET|POST|REQUEST|COOKIE)|getRuntime\(\)\.exec\s*\([^)\n]*\+|exec\.Command\s*\(\s*"(?:sh|bash|cmd)"\s*,\s*"(?:-c|\/c)"\s*,\s*(?!")[^)\n]|\b(?:system|exec|spawn)\s*\(?\s*"[^"\n]*#\{(?:params|request)/,
52
+ impact: 'Input can run arbitrary commands.', fix: 'Pass arguments as a list without a shell; allowlist values.' }),
53
+ build({ id: 'AS-SEC-017', title: 'Weak cipher mode or deprecated cipher call', severity: 'medium', confidence: 'medium', exts: [...JS, '.py', '.java', '.kt'],
54
+ re: /\bMODE_ECB\b|["']aes-(?:128|192|256)-ecb["']|Cipher\.getInstance\(\s*"AES(?:\/ECB[^"]*)?"|\bcrypto\.createCipher\s*\(/,
55
+ impact: 'Encrypted data leaks patterns or uses a weak key derivation.', fix: 'Use an authenticated mode such as AES-GCM with a random nonce (createCipheriv in Node).' }),
56
+ ];
57
+ /** A query call whose SQL starts on a later line. */
58
+ export const SQL_OPENER = /\b(?:query|execute|executemany|executescript|raw|prepare)\s*\(\s*(?:[fF]?(?:"""|''')|`)?\s*$/;
59
+ export const SQL_BLOCK = /\(\s*(?:[fF](?:"""|''')[\s\S]*?\{|`[^`]*?\$\{|[fF]["'][^"'\n]*\{|["'][^"'\n]*["']\s*\+)/;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Provider credential formats. Specific prefixes come before generic ones: the first match names the hit.
3
+ * Each row needs a matching and a non-matching case in test/secrets.test.mjs.
4
+ */
5
+ const row = (name, re) => ({ name, re });
6
+ export const PROVIDER_PATTERNS = [
7
+ row('aws-access-key', /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g),
8
+ row('github-token', /\bgh[pousr]_[A-Za-z0-9]{20,}\b/g),
9
+ row('github-pat', /\bgithub_pat_[A-Za-z0-9_]{20,}\b/g),
10
+ row('gitlab-token', /\bgl(?:pat|dt|rt|ptt)-[A-Za-z0-9_-]{20,}/g),
11
+ row('anthropic-key', /\bsk-ant-[A-Za-z0-9_-]{20,}/g),
12
+ row('openai-style-key', /\bsk-[A-Za-z0-9_-]{20,}\b/g),
13
+ row('groq-key', /\bgsk_[A-Za-z0-9]{40,}\b/g),
14
+ row('replicate-token', /\br8_[A-Za-z0-9]{37,}\b/g),
15
+ row('perplexity-key', /\bpplx-[A-Za-z0-9]{40,}\b/g),
16
+ row('huggingface-token', /\bhf_[A-Za-z0-9]{30,}\b/g),
17
+ row('databricks-token', /\bdapi[0-9a-f]{32}\b/g),
18
+ row('slack-token', /\bxox[abeoprs]-[A-Za-z0-9-]{10,}\b/g),
19
+ row('slack-webhook', /https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]+\/B[A-Z0-9]+\/[A-Za-z0-9]{16,}/g),
20
+ row('discord-webhook', /https:\/\/(?:ptb\.|canary\.)?discord(?:app)?\.com\/api\/webhooks\/\d{15,}\/[A-Za-z0-9_-]{40,}/g),
21
+ row('teams-webhook', /https:\/\/[a-z0-9-]+\.webhook\.office\.com\/webhookb2\/[A-Za-z0-9@/-]{40,}/g),
22
+ row('telegram-bot-token', /\b\d{8,10}:AA[A-Za-z0-9_-]{32,}/g),
23
+ row('google-api-key', /\bAIza[0-9A-Za-z_-]{35}\b/g),
24
+ row('google-oauth-secret', /\bGOCSPX-[A-Za-z0-9_-]{28}/g),
25
+ row('azure-storage-key', /\bAccountKey=[A-Za-z0-9+/]{40,}={0,2}/g),
26
+ row('digitalocean-token', /\bdo[opr]_v1_[a-f0-9]{64}\b/g),
27
+ row('stripe-secret-key', /\b[sr]k_live_[A-Za-z0-9]{16,}\b/g),
28
+ row('stripe-webhook-secret', /\bwhsec_[A-Za-z0-9]{32,}\b/g),
29
+ row('square-token', /\bsq0(?:atp|csp)-[A-Za-z0-9_-]{22,}/g),
30
+ row('shopify-token', /\bshp(?:at|ss|ca|pa)_[a-fA-F0-9]{32}\b/g),
31
+ row('razorpay-live-key', /\brzp_live_[A-Za-z0-9]{14,}\b/g),
32
+ row('flutterwave-key', /\bFLWSECK-[a-f0-9]{32}-X\b/g),
33
+ row('sendgrid-key', /\bSG\.[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}/g),
34
+ row('brevo-key', /\bxkeysib-[a-f0-9]{64}-[A-Za-z0-9]{16}\b/g),
35
+ row('mailgun-key', /\bkey-[a-f0-9]{32}\b/g),
36
+ row('mailchimp-key', /\b[a-f0-9]{32}-us\d{1,2}\b/g),
37
+ row('twilio-key', /\bSK[0-9a-f]{32}\b/g),
38
+ row('npm-token', /\bnpm_[A-Za-z0-9]{36}\b/g),
39
+ row('pypi-token', /\bpypi-AgEIcHlwaS5vcmc[A-Za-z0-9_-]{50,}/g),
40
+ row('rubygems-key', /\brubygems_[a-f0-9]{48}\b/g),
41
+ row('dockerhub-token', /\bdckr_pat_[A-Za-z0-9_-]{27,}/g),
42
+ row('clojars-token', /\bCLOJARS_[a-z0-9]{60}\b/g),
43
+ row('atlassian-token', /\bATATT3[A-Za-z0-9_=-]{60,}/g),
44
+ row('linear-key', /\blin_api_[A-Za-z0-9]{40}\b/g),
45
+ row('notion-token', /\b(?:ntn_[A-Za-z0-9]{40,}|secret_[A-Za-z0-9]{43})\b/g),
46
+ row('figma-token', /\bfigd_[A-Za-z0-9_-]{40,}/g),
47
+ row('airtable-token', /\bpat[A-Za-z0-9]{14}\.[a-f0-9]{64}\b/g),
48
+ row('postman-key', /\bPMAK-[a-f0-9]{24}-[a-f0-9]{34}\b/g),
49
+ row('contentful-token', /\bCFPAT-[A-Za-z0-9_-]{43}/g),
50
+ row('newrelic-key', /\bNRAK-[A-Z0-9]{27}\b/g),
51
+ row('grafana-token', /\bgl(?:c_[A-Za-z0-9+/]{32,}={0,2}|sa_[A-Za-z0-9]{32}_[a-f0-9]{8})/g),
52
+ row('sentry-token', /\bsntry[su]_[A-Za-z0-9_+/=-]{40,}/g),
53
+ row('dynatrace-token', /\bdt0c01\.[A-Z0-9]{24}\.[A-Z0-9]{64}\b/g),
54
+ row('doppler-token', /\bdp\.(?:pt|st|ct|sa)\.[A-Za-z0-9._-]{40,}/g),
55
+ row('vault-token', /\bhv[sb]\.[A-Za-z0-9_-]{90,}/g),
56
+ row('terraform-cloud-token', /\b[A-Za-z0-9]{14}\.atlasv1\.[A-Za-z0-9_=-]{60,}/g),
57
+ row('pulumi-token', /\bpul-[a-f0-9]{40}\b/g),
58
+ row('planetscale-token', /\bpscale_(?:tkn|pw|oauth)_[A-Za-z0-9_.-]{32,}/g),
59
+ row('supabase-token', /\bsbp_[a-f0-9]{40}\b/g),
60
+ row('netlify-token', /\bnfp_[A-Za-z0-9]{36,}\b/g),
61
+ row('fly-token', /\bfm2_[A-Za-z0-9+/=_-]{60,}/g),
62
+ row('render-key', /\brnd_[A-Za-z0-9]{28,}\b/g),
63
+ row('sonar-token', /\bsq[pua]_[a-f0-9]{40}\b/g),
64
+ row('prefect-key', /\bpnu_[A-Za-z0-9]{36}\b/g),
65
+ row('easypost-key', /\bEZ[AT]K[a-f0-9]{54}\b/g),
66
+ row('mapbox-secret', /\bsk\.eyJ[A-Za-z0-9._-]{60,}/g),
67
+ row('age-secret-key', /\bAGE-SECRET-KEY-1[A-Z0-9]{58}\b/g),
68
+ row('jwt', /\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g),
69
+ ];
package/dist/suppress.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- /** Load `.archsutra/suppress.json`. Missing file means nothing is suppressed. Invalid JSON throws. Entries without a rule and a reason are ignored. */
4
- export async function loadSuppressions(root, today = new Date().toISOString().slice(0, 10)) {
3
+ import { globToRegExp } from './fsutil.js';
4
+ /** All valid entries, expired ones included. A missing file means none; invalid JSON throws. An entry needs a reason and a rule or fingerprint. */
5
+ export async function readSuppressions(root) {
5
6
  const abs = path.join(root, '.archsutra', 'suppress.json');
6
7
  let text;
7
8
  try {
@@ -22,30 +23,41 @@ export async function loadSuppressions(root, today = new Date().toISOString().sl
22
23
  const list = Array.isArray(raw) ? raw : raw.suppress;
23
24
  if (!Array.isArray(list))
24
25
  throw new Error('.archsutra/suppress.json must be an array, or an object with a suppress array.');
26
+ const text1 = (v) => (typeof v === 'string' && v.trim() ? v.trim() : undefined);
25
27
  const out = [];
26
28
  for (const item of list) {
27
29
  if (!item || typeof item !== 'object')
28
30
  continue;
29
31
  const row = item;
30
- if (typeof row.rule !== 'string' || typeof row.reason !== 'string' || !row.reason.trim())
32
+ const rule = text1(row.rule);
33
+ const fingerprint = text1(row.fingerprint);
34
+ const reason = text1(row.reason);
35
+ if (!reason || (!rule && !fingerprint))
31
36
  continue;
32
- if (typeof row.expires === 'string' && row.expires < today)
33
- continue;
34
- out.push({
35
- rule: row.rule,
36
- path: typeof row.path === 'string' ? row.path.replace(/\\/g, '/').replace(/^\.\//, '') : undefined,
37
- reason: row.reason.trim(),
38
- expires: typeof row.expires === 'string' ? row.expires : undefined,
39
- });
37
+ out.push({ rule, fingerprint, reason, owner: text1(row.owner), expires: text1(row.expires), path: text1(row.path)?.replace(/\\/g, '/').replace(/^\.\//, '') });
40
38
  }
41
39
  return out;
42
40
  }
43
- export function isSuppressed(finding, rules) {
44
- return rules.some((s) => {
45
- if (s.rule !== finding.rule)
46
- return false;
47
- if (!s.path)
48
- return true;
49
- return finding.evidence.some((e) => e.path === s.path || e.path.startsWith(`${s.path}/`));
50
- });
41
+ export const isExpired = (s, today = new Date().toISOString().slice(0, 10)) => Boolean(s.expires && s.expires < today);
42
+ export async function loadSuppressions(root, today) {
43
+ return (await readSuppressions(root)).filter((s) => !isExpired(s, today));
44
+ }
45
+ /**
46
+ * Split findings into what stays visible and what is suppressed, location by location: a suppression
47
+ * never hides other locations of the same rule.
48
+ */
49
+ export function applySuppressions(findings, rules) {
50
+ const visible = [];
51
+ const hidden = [];
52
+ for (const f of findings) {
53
+ const mine = rules.filter((s) => !s.rule || s.rule === f.rule).map((s) => ({ ...s, glob: s.path ? globToRegExp(s.path.includes('/') ? s.path : `./${s.path}`) : undefined }));
54
+ const reasonFor = (e) => mine.find((s) => (s.fingerprint ? s.fingerprint === e.fingerprint : !s.path || e.path === s.path || e.path.startsWith(`${s.path}/`) || (/[*?]/.test(s.path) && s.glob.test(e.path))))?.reason;
55
+ const keep = f.evidence.filter((e) => !reasonFor(e));
56
+ const gone = f.evidence.filter((e) => reasonFor(e));
57
+ if (keep.length)
58
+ visible.push({ ...f, evidence: keep });
59
+ if (gone.length)
60
+ hidden.push({ ...f, evidence: gone, reason: [...new Set(gone.map((e) => reasonFor(e)))].join('; ') });
61
+ }
62
+ return { visible, hidden };
51
63
  }
package/dist/verify.js CHANGED
@@ -66,8 +66,8 @@ export function validateFindings(obj) {
66
66
  const o = obj;
67
67
  if (!o || typeof o !== 'object')
68
68
  return ['not an object'];
69
- if (o.schemaVersion !== '1.0.0')
70
- errs.push('schemaVersion must be "1.0.0"');
69
+ if (o.schemaVersion !== '1.0.0' && o.schemaVersion !== '1.1.0')
70
+ errs.push('schemaVersion must be "1.0.0" or "1.1.0"');
71
71
  if (!Array.isArray(o.findings))
72
72
  return [...errs, 'findings must be an array'];
73
73
  const sev = new Set(['critical', 'high', 'medium', 'low', 'info']);
package/dist/write.js ADDED
@@ -0,0 +1,71 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { promises as fs } from 'node:fs';
3
+ import path from 'node:path';
4
+ export const MD_MARK = '<!-- archsutra:generated -->';
5
+ export class UsageError extends Error {
6
+ }
7
+ /** Markdown reports carry a marker so a later run can tell them apart from the user's own files. */
8
+ export function mark(files) {
9
+ return files.map((f) => (f.path.endsWith('.md') && !f.content.startsWith(MD_MARK) ? { ...f, content: `${MD_MARK}\n${f.content}` } : f));
10
+ }
11
+ const sha = (s) => createHash('sha256').update(s).digest('hex');
12
+ function looksGenerated(name, content) {
13
+ if (name.endsWith('.md'))
14
+ return content.startsWith(MD_MARK);
15
+ if (name.endsWith('.html'))
16
+ return content.includes('<meta name="generator" content="ArchSutra AI">');
17
+ if (name === 'findings.json')
18
+ return /"tool":\s*"archsutra"/.test(content);
19
+ if (name.endsWith('.sarif'))
20
+ return /"name":\s*"ArchSutra AI"/.test(content);
21
+ if (name === 'architecture-register.json')
22
+ return content.includes('"artifacts"') && content.includes('"sha256"');
23
+ return false;
24
+ }
25
+ async function read(file) {
26
+ try {
27
+ return await fs.readFile(file, 'utf8');
28
+ }
29
+ catch (e) {
30
+ if (e.code === 'ENOENT')
31
+ return undefined;
32
+ throw e;
33
+ }
34
+ }
35
+ /** Hashes recorded by an earlier run, so reports written before the marker existed can be replaced. */
36
+ async function previousHashes(outDir) {
37
+ try {
38
+ const raw = JSON.parse((await read(path.join(outDir, 'architecture-register.json'))) ?? '{}');
39
+ return new Set((raw.artifacts ?? []).map((a) => String(a.sha256)));
40
+ }
41
+ catch {
42
+ return new Set();
43
+ }
44
+ }
45
+ /**
46
+ * Write reports without destroying user files. A file that exists, differs and was not generated by
47
+ * ArchSutra stops the whole run before anything is written; with force it is copied to backupDir first.
48
+ */
49
+ export async function writeReports(outDir, files, opts) {
50
+ const known = await previousHashes(outDir);
51
+ const foreign = [];
52
+ for (const f of files) {
53
+ const old = await read(path.join(outDir, f.path));
54
+ if (old === undefined || old === f.content || known.has(sha(old)) || looksGenerated(f.path, old))
55
+ continue;
56
+ foreign.push({ name: f.path, content: old });
57
+ }
58
+ if (foreign.length && !opts.force) {
59
+ throw new UsageError(`Refusing to overwrite file(s) ArchSutra did not create in ${outDir}: ${foreign.map((f) => f.name).join(', ')}. Choose another --output, or use --force (originals are backed up to .archsutra/backup/).`);
60
+ }
61
+ if (opts.dry)
62
+ return;
63
+ if (foreign.length) {
64
+ await fs.mkdir(opts.backupDir, { recursive: true });
65
+ for (const f of foreign)
66
+ await fs.writeFile(path.join(opts.backupDir, f.name), f.content, 'utf8');
67
+ }
68
+ await fs.mkdir(outDir, { recursive: true });
69
+ for (const f of files)
70
+ await fs.writeFile(path.join(outDir, f.path), f.content, 'utf8');
71
+ }
@@ -7,6 +7,7 @@
7
7
  <meta name="description" content="Architecture overview - ArchSutra AI documentation.">
8
8
  <link rel="canonical" href="https://shahvatsalofficial.github.io/archsutra-ai/architecture/overview.html">
9
9
  <meta name="color-scheme" content="light dark">
10
+ <meta name="theme-color" content="#ffffff">
10
11
  <meta property="og:type" content="article">
11
12
  <meta property="og:title" content="Architecture overview | ArchSutra AI">
12
13
  <meta property="og:description" content="Architecture overview - ArchSutra AI documentation.">
@@ -18,23 +19,34 @@
18
19
  <meta name="author" content="Vatsal Shah">
19
20
  <link rel="icon" href="../assets/favicon.svg" type="image/svg+xml">
20
21
  <link rel="stylesheet" href="../assets/site.css">
21
- <script>try{var t=localStorage.getItem('as-theme');if(t)document.documentElement.setAttribute('data-theme',t)}catch(e){}</script>
22
+ <script>try{if(localStorage.getItem('as-theme')==='dark')document.documentElement.setAttribute('data-theme','dark')}catch(e){}</script>
22
23
  <script type="application/ld+json">{"@context":"https://schema.org","@type":"TechArticle","headline":"Architecture overview","description":"Architecture overview - ArchSutra AI documentation.","author":{"@type":"Person","name":"Vatsal Shah","url":"https://shahvatsal.com"},"inLanguage":"en","isPartOf":{"@type":"WebSite","name":"ArchSutra AI","url":"https://shahvatsalofficial.github.io/archsutra-ai"}}</script>
23
24
  </head>
24
- <body class="doc">
25
+ <body class="doc" data-root="../">
25
26
  <a class="skip" href="#main">Skip to content</a>
26
27
  <header class="topbar">
27
28
  <div class="topbar-inner">
28
- <button class="menu-btn" type="button" aria-label="Toggle navigation" aria-expanded="false" aria-controls="sidebar">Menu</button>
29
- <a class="brand" href="../index.html" aria-label="ArchSutra AI home"><svg viewBox="0 0 32 32" width="26" height="26" aria-hidden="true"><rect width="32" height="32" rx="8" fill="currentColor" opacity=".12"/><path d="M6 24 16 7l10 17M10.5 18h11" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg><span>ArchSutra <b>AI</b></span></a>
30
- <nav class="top-links" aria-label="Primary"><a href="../handbook/index.html">Handbook</a><a href="../handbook/05-user-guide.html">Get started</a><a href="../handbook/08-testing-and-proof.html">Proof</a><a href="https://github.com/shahvatsalofficial/archsutra-ai" rel="noopener">GitHub</a></nav>
31
- <button class="theme-btn" type="button" aria-label="Toggle color theme"><span class="sun" aria-hidden="true">Light</span><span class="moon" aria-hidden="true">Dark</span></button>
29
+ <a class="brand" href="../index.html" aria-label="ArchSutra AI home"><svg viewBox="0 0 32 32" aria-hidden="true"><rect width="32" height="32" rx="9" fill="currentColor" opacity=".14"/><path d="M6 24 16 7l10 17M10.5 18h11" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg><span>ArchSutra <b>AI</b></span></a>
30
+ <nav class="top-links" aria-label="Primary"><a href="../guides/getting-started.html">Get started</a><a href="../guides/real-world-scenarios.html">Scenarios</a><a href="../handbook/index.html">Handbook</a><a href="../guides/evidence-at-a-glance.html">Proof</a></nav>
31
+ <span class="spacer"></span>
32
+ <div class="search" role="search"><label class="sr-only" for="q">Search the documentation</label><input id="q" type="search" placeholder="Search docs ( / )" autocomplete="off" aria-controls="results" aria-expanded="false"><ul id="results" class="results" role="listbox" hidden></ul></div>
33
+ <a class="gh-btn" href="https://github.com/shahvatsalofficial/archsutra-ai" rel="noopener"><svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 19c-4.3 1.4-4.3-2.5-6-3m12 5v-3.5c0-1 .1-1.4-.5-2 2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 0 0-1.3-3.2 4.2 4.2 0 0 0-.1-3.2s-1.1-.3-3.5 1.3a12 12 0 0 0-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.2 4.2 0 0 0-.1 3.2A4.6 4.6 0 0 0 4 9.5c0 4.6 2.7 5.7 5.5 6-.6.6-.6 1.2-.5 2V21"/></svg><span>GitHub</span></a>
34
+ <button class="icon-btn theme-btn" type="button" aria-label="Switch between light and dark theme"><span class="sun"><svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg></span><span class="moon"><svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg></span></button>
35
+ <button class="icon-btn menu-btn" type="button" aria-label="Open menu" aria-expanded="false" aria-controls="drawer"><svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg></button>
32
36
  </div>
33
37
  </header>
38
+ <div id="drawer" class="drawer" aria-hidden="true">
39
+ <div class="drawer-scrim" data-close></div>
40
+ <div class="drawer-panel" role="dialog" aria-label="Menu">
41
+ <div class="drawer-head"><a class="brand" href="../index.html"><svg viewBox="0 0 32 32" aria-hidden="true"><rect width="32" height="32" rx="9" fill="currentColor" opacity=".14"/><path d="M6 24 16 7l10 17M10.5 18h11" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg><span>ArchSutra <b>AI</b></span></a><button class="icon-btn" type="button" data-close aria-label="Close menu"><svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg></button></div>
42
+ <div class="primary-links"><a href="../index.html">Home</a><a href="../guides/getting-started.html">Get started</a><a href="../guides/real-world-scenarios.html">Scenarios</a><a href="../handbook/index.html">Handbook</a><a href="../guides/evidence-at-a-glance.html">Proof</a><a href="https://github.com/shahvatsalofficial/archsutra-ai" rel="noopener">GitHub</a></div>
43
+ <div class="nav-group"><p class="nav-title">Start here</p><ul><li><a href="../guides/getting-started.html">Get started in 5 minutes</a></li><li><a href="../guides/real-world-scenarios.html">Real-world scenarios</a></li><li><a href="../guides/how-it-works.html">How it works, in pictures</a></li><li><a href="../guides/reading-a-report.html">Reading and triaging a report</a></li><li><a href="../guides/ci-recipes.html">CI recipes</a></li><li><a href="../guides/mcp-server.html">Use ArchSutra as an MCP server</a></li><li><a href="../guides/cheat-sheet.html">Cheat sheet</a></li><li><a href="../guides/evidence-at-a-glance.html">Evidence at a glance</a></li></ul></div><div class="nav-group"><p class="nav-title">Handbook</p><ul><li><a href="../handbook/index.html">Overview</a></li><li><a href="../handbook/01-executive-summary.html">Executive summary</a></li><li><a href="../handbook/02-functional-specification.html">Functional specification</a></li><li><a href="../handbook/03-technical-specification.html">Technical specification</a></li><li><a href="../handbook/04-architecture.html">Architecture</a></li><li><a href="../handbook/05-user-guide.html">User guide</a></li><li><a href="../handbook/06-cli-reference.html">CLI reference</a></li><li><a href="../handbook/07-security-privacy-legal.html">Security, privacy and legal</a></li><li><a href="../handbook/08-testing-and-proof.html">Testing and proof</a></li><li><a href="../handbook/09-compatibility-and-roadmap.html">Compatibility and roadmap</a></li><li><a href="../handbook/10-contributor-guide.html">Contributor guide</a></li><li><a href="../handbook/11-glossary-and-faq.html">Glossary and FAQ</a></li><li><a href="../handbook/12-rule-catalog.html">Audit rule catalog</a></li><li><a href="../handbook/13-trust-and-assurance.html">Trust and assurance</a></li><li><a href="../handbook/14-real-world-evaluation.html">Real-world evaluation</a></li><li><a href="../handbook/15-supply-chain-and-release.html">Supply chain and release</a></li><li><a href="../handbook/16-performance-and-quality-metrics.html">Performance and quality metrics</a></li></ul></div><div class="nav-group"><p class="nav-title">Reference</p><ul><li><a href="../architecture/overview.html" aria-current="page">Architecture overview</a></li><li><a href="../architecture/threat-model.html">Threat model (ArchSutra CLI and skills)</a></li><li><a href="../compatibility/matrix.html">Compatibility matrix</a></li><li><a href="../rfc/0001-archsutra-v0.1.html">RFC 0001: ArchSutra AI v0.1</a></li><li><a href="../decisions/ADR-0001-deterministic-cli-plus-ide-skills.html">ADR-0001: Deterministic CLI plus IDE-native skills</a></li><li><a href="../compatibility/smoke-tests/index.html">Live smoke tests</a></li><li><a href="../community/good-first-issues.html">Good first issues (ready to file)</a></li><li><a href="../legal/trademark-and-name-clearance.html">Name and trademark clearance</a></li><li><a href="../legal/legal-review-brief.html">Legal review brief</a></li><li><a href="../proof/accessibility.html">Accessibility audit of the documentation site</a></li></ul></div>
44
+ </div>
45
+ </div>
34
46
  <div class="layout">
35
- <aside id="sidebar" class="sidebar" aria-label="Documentation"><div class="nav-group"><p class="nav-title">Handbook</p><ul><li><a href="../handbook/index.html">Overview</a></li><li><a href="../handbook/01-executive-summary.html">Executive summary</a></li><li><a href="../handbook/02-functional-specification.html">Functional specification</a></li><li><a href="../handbook/03-technical-specification.html">Technical specification</a></li><li><a href="../handbook/04-architecture.html">Architecture</a></li><li><a href="../handbook/05-user-guide.html">User guide</a></li><li><a href="../handbook/06-cli-reference.html">CLI reference</a></li><li><a href="../handbook/07-security-privacy-legal.html">Security, privacy and legal</a></li><li><a href="../handbook/08-testing-and-proof.html">Testing and proof</a></li><li><a href="../handbook/09-compatibility-and-roadmap.html">Compatibility and roadmap</a></li><li><a href="../handbook/10-contributor-guide.html">Contributor guide</a></li><li><a href="../handbook/11-glossary-and-faq.html">Glossary and FAQ</a></li><li><a href="../handbook/12-rule-catalog.html">Audit rule catalog</a></li><li><a href="../handbook/13-trust-and-assurance.html">Trust and assurance</a></li><li><a href="../handbook/14-real-world-evaluation.html">Real-world evaluation</a></li><li><a href="../handbook/15-supply-chain-and-release.html">Supply chain and release</a></li><li><a href="../handbook/16-performance-and-quality-metrics.html">Performance and quality metrics</a></li></ul></div><div class="nav-group"><p class="nav-title">Reference</p><ul><li><a href="../architecture/overview.html" aria-current="page">Architecture overview</a></li><li><a href="../architecture/threat-model.html">Threat model (ArchSutra CLI and skills)</a></li><li><a href="../compatibility/matrix.html">Compatibility matrix</a></li><li><a href="../rfc/0001-archsutra-v0.1.html">RFC 0001: ArchSutra AI v0.1</a></li><li><a href="../decisions/ADR-0001-deterministic-cli-plus-ide-skills.html">ADR-0001: Deterministic CLI plus IDE-native skills</a></li><li><a href="../compatibility/smoke-tests/index.html">Live smoke tests</a></li><li><a href="../community/good-first-issues.html">Good first issues (ready to file)</a></li><li><a href="../legal/trademark-and-name-clearance.html">Name and trademark clearance</a></li><li><a href="../legal/legal-review-brief.html">Legal review brief</a></li><li><a href="../proof/accessibility.html">Accessibility audit of the documentation site</a></li></ul></div></aside>
47
+ <aside id="sidebar" class="sidebar" aria-label="Documentation"><div class="nav-group"><p class="nav-title">Start here</p><ul><li><a href="../guides/getting-started.html">Get started in 5 minutes</a></li><li><a href="../guides/real-world-scenarios.html">Real-world scenarios</a></li><li><a href="../guides/how-it-works.html">How it works, in pictures</a></li><li><a href="../guides/reading-a-report.html">Reading and triaging a report</a></li><li><a href="../guides/ci-recipes.html">CI recipes</a></li><li><a href="../guides/mcp-server.html">Use ArchSutra as an MCP server</a></li><li><a href="../guides/cheat-sheet.html">Cheat sheet</a></li><li><a href="../guides/evidence-at-a-glance.html">Evidence at a glance</a></li></ul></div><div class="nav-group"><p class="nav-title">Handbook</p><ul><li><a href="../handbook/index.html">Overview</a></li><li><a href="../handbook/01-executive-summary.html">Executive summary</a></li><li><a href="../handbook/02-functional-specification.html">Functional specification</a></li><li><a href="../handbook/03-technical-specification.html">Technical specification</a></li><li><a href="../handbook/04-architecture.html">Architecture</a></li><li><a href="../handbook/05-user-guide.html">User guide</a></li><li><a href="../handbook/06-cli-reference.html">CLI reference</a></li><li><a href="../handbook/07-security-privacy-legal.html">Security, privacy and legal</a></li><li><a href="../handbook/08-testing-and-proof.html">Testing and proof</a></li><li><a href="../handbook/09-compatibility-and-roadmap.html">Compatibility and roadmap</a></li><li><a href="../handbook/10-contributor-guide.html">Contributor guide</a></li><li><a href="../handbook/11-glossary-and-faq.html">Glossary and FAQ</a></li><li><a href="../handbook/12-rule-catalog.html">Audit rule catalog</a></li><li><a href="../handbook/13-trust-and-assurance.html">Trust and assurance</a></li><li><a href="../handbook/14-real-world-evaluation.html">Real-world evaluation</a></li><li><a href="../handbook/15-supply-chain-and-release.html">Supply chain and release</a></li><li><a href="../handbook/16-performance-and-quality-metrics.html">Performance and quality metrics</a></li></ul></div><div class="nav-group"><p class="nav-title">Reference</p><ul><li><a href="../architecture/overview.html" aria-current="page">Architecture overview</a></li><li><a href="../architecture/threat-model.html">Threat model (ArchSutra CLI and skills)</a></li><li><a href="../compatibility/matrix.html">Compatibility matrix</a></li><li><a href="../rfc/0001-archsutra-v0.1.html">RFC 0001: ArchSutra AI v0.1</a></li><li><a href="../decisions/ADR-0001-deterministic-cli-plus-ide-skills.html">ADR-0001: Deterministic CLI plus IDE-native skills</a></li><li><a href="../compatibility/smoke-tests/index.html">Live smoke tests</a></li><li><a href="../community/good-first-issues.html">Good first issues (ready to file)</a></li><li><a href="../legal/trademark-and-name-clearance.html">Name and trademark clearance</a></li><li><a href="../legal/legal-review-brief.html">Legal review brief</a></li><li><a href="../proof/accessibility.html">Accessibility audit of the documentation site</a></li></ul></div></aside>
36
48
  <main id="main" class="content"><article class="prose"><p class="crumbs"><a href="../index.html">ArchSutra AI</a> / Reference</p><h1 id="architecture-overview">Architecture overview</h1>
37
- <p class="meta">Version 0.1.5 &middot; Source: <a href="https://github.com/shahvatsalofficial/archsutra-ai/blob/main/docs/architecture/overview.md" rel="noopener">docs/architecture/overview.md</a></p>
49
+ <p class="meta">Version 0.2.1 &middot; Source: <a href="https://github.com/shahvatsalofficial/archsutra-ai/blob/main/docs/architecture/overview.md" rel="noopener">docs/architecture/overview.md</a></p>
38
50
  <p>ArchSutra has two cooperating halves:</p>
39
51
  <ol><li><strong>Skills and agents</strong> (<code>skills/</code>, <code>agents/</code>): canonical Markdown that an AI IDE loads. Reasoning runs on the IDE's own model.</li><li><strong>Deterministic CLI</strong> (<code>src/</code>): produces reproducible evidence without any model.</li></ol>
40
52
  <figure class="diagram"><pre class="mermaid">flowchart TB
@@ -56,15 +68,20 @@
56
68
  adapters --&gt; hosts[(&quot;Host folders: .claude, .cursor, .agents, .github, .gemini&quot;)]
57
69
  verify --&gt; skills</pre><figcaption>Diagram (Mermaid). If it does not render, the source is shown above.</figcaption></figure>
58
70
  <h2 id="module-responsibilities">Module responsibilities<a class="anchor" href="#module-responsibilities" aria-label="Link to this section">#</a></h2>
59
- <div class="table-wrap" tabindex="0" role="region" aria-label="Table 1: Module responsibilities"><table><thead><tr><th scope="col">Module</th><th scope="col">Responsibility</th></tr></thead><tbody><tr><td><code>src/fsutil.ts</code></td><td>file walk with limits (5000 files, 512 KB each, 15 s), ignore lists, symlink skipping, path containment</td></tr><tr><td><code>src/redact.ts</code></td><td>secret detection and masking; used for every excerpt</td></tr><tr><td><code>src/map.ts</code></td><td>ecosystems, frameworks, datastores, infra, module graph, Tarjan cycle detection</td></tr><tr><td><code>src/audit.ts</code></td><td>rules to findings with evidence; scorecard with <code>not assessed</code> where evidence is absent</td></tr><tr><td><code>src/report.ts</code></td><td>Markdown, Mermaid, findings JSON (v1.0.0), SARIF 2.1.0, artifact register</td></tr><tr><td><code>src/verify.ts</code></td><td>structural validation of skills, agents, links, Mermaid, findings</td></tr><tr><td><code>src/adapters.ts</code></td><td>host specs, install plan with conflict detection, hash manifest, uninstall, doctor</td></tr><tr><td><code>src/cli.ts</code></td><td>argument parsing, exit codes, command dispatch</td></tr></tbody></table></div>
71
+ <div class="table-wrap" tabindex="0" role="region" aria-label="Table 1: Module responsibilities"><table><thead><tr><th scope="col">Module</th><th scope="col">Responsibility</th></tr></thead><tbody><tr><td><code>src/fsutil.ts</code></td><td>file walk with limits (5000 files, 512 KB each, 15 s), folder-by-folder sampling, ignore lists, symlink skipping, path containment</td></tr><tr><td><code>src/redact.ts</code></td><td>secret detection and masking; used for every excerpt</td></tr><tr><td><code>src/map.ts</code></td><td>ecosystems, frameworks, datastores, infra, module graph, Tarjan cycle detection</td></tr><tr><td><code>src/audit.ts</code></td><td>rules to findings with evidence; scorecard with <code>not assessed</code> where evidence is absent</td></tr><tr><td><code>src/report.ts</code></td><td>Markdown, Mermaid, findings JSON (v1.1.0), SARIF 2.1.0, artifact register</td></tr><tr><td><code>src/verify.ts</code></td><td>structural validation of skills, agents, links, Mermaid, findings</td></tr><tr><td><code>src/adapters.ts</code></td><td>host specs, install plan with conflict detection, hash manifest, uninstall, doctor</td></tr><tr><td><code>src/cli.ts</code></td><td>argument parsing, exit codes, command dispatch</td></tr></tbody></table></div>
60
72
  <h2 id="key-decisions">Key decisions<a class="anchor" href="#key-decisions" aria-label="Link to this section">#</a></h2>
61
- <p>See <a href="https://github.com/shahvatsalofficial/archsutra-ai/tree/main/docs/decisions" rel="noopener">../decisions/</a>.</p></article></main>
73
+ <p>See <a href="https://github.com/shahvatsalofficial/archsutra-ai/tree/main/docs/decisions" rel="noopener">../decisions/</a>.</p></article><nav class="pn" aria-label="Previous and next page"><span></span><a class="next" href="threat-model.html"><small>Next</small><span>Threat model (ArchSutra CLI and skills)</span></a></nav><p class="edit"><a href="https://github.com/shahvatsalofficial/archsutra-ai/edit/main/docs/architecture/overview.md" rel="noopener">Edit this page on GitHub</a></p></main>
62
74
  <aside class="rail"><nav class="toc" aria-label="On this page"><p class="nav-title">On this page</p><ul><li class="l2"><a href="#module-responsibilities">Module responsibilities</a></li><li class="l2"><a href="#key-decisions">Key decisions</a></li></ul></nav></aside>
63
75
  </div>
64
76
  <footer class="footer">
65
77
  <div class="footer-inner">
66
- <p><strong>ArchSutra AI</strong> v0.1.5. Design. Audit. Evolve. Created by <a href="https://shahvatsal.com" rel="noopener">Vatsal Shah</a>. Licensed under <a href="https://github.com/shahvatsalofficial/archsutra-ai/blob/main/LICENSE" rel="noopener">Apache-2.0</a>.</p>
67
- <p class="fine">Review aid only. Not a certification, compliance attestation, security guarantee or legal advice. Not affiliated with Anthropic, OpenAI, Cursor, GitHub or Google; product names belong to their owners. <a href="../handbook/07-security-privacy-legal.html">Legal details</a>.</p>
78
+ <div class="footer-grid">
79
+ <div class="about-col"><a class="brand" href="../index.html"><svg viewBox="0 0 32 32" aria-hidden="true"><rect width="32" height="32" rx="9" fill="currentColor" opacity=".14"/><path d="M6 24 16 7l10 17M10.5 18h11" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg><span>ArchSutra <b>AI</b></span></a><p class="about">Design. Audit. Evolve. An open-source, evidence-first software architecture agent. Created by <a href="https://shahvatsal.com" rel="noopener">Vatsal Shah</a>. Apache-2.0.</p></div>
80
+ <div><h4>Learn</h4><ul><li><a href="../guides/getting-started.html">Get started</a></li><li><a href="../guides/real-world-scenarios.html">Real-world scenarios</a></li><li><a href="../guides/how-it-works.html">How it works</a></li><li><a href="../guides/cheat-sheet.html">Cheat sheet</a></li></ul></div>
81
+ <div><h4>Trust</h4><ul><li><a href="../guides/evidence-at-a-glance.html">Evidence at a glance</a></li><li><a href="../handbook/13-trust-and-assurance.html">Honesty register</a></li><li><a href="../handbook/07-security-privacy-legal.html">Security and legal</a></li><li><a href="../handbook/15-supply-chain-and-release.html">Supply chain</a></li></ul></div>
82
+ <div><h4>Project</h4><ul><li><a href="https://github.com/shahvatsalofficial/archsutra-ai" rel="noopener">GitHub</a></li><li><a href="https://www.npmjs.com/package/archsutra-ai" rel="noopener">npm</a></li><li><a href="../handbook/10-contributor-guide.html">Contribute</a></li><li><a href="https://github.com/shahvatsalofficial/archsutra-ai/blob/main/CHANGELOG.md" rel="noopener">Changelog</a></li></ul></div>
83
+ </div>
84
+ <p class="fine">v0.2.1. Review aid only. Not a certification, compliance attestation, security guarantee or legal advice. Not affiliated with Anthropic, OpenAI, Cursor, GitHub or Google; product names belong to their owners. <a href="../handbook/07-security-privacy-legal.html">Legal details</a>.</p>
68
85
  </div>
69
86
  </footer>
70
87
  <script src="../assets/site.js" type="module"></script>
@@ -30,11 +30,11 @@ flowchart TB
30
30
 
31
31
  | Module | Responsibility |
32
32
  |---|---|
33
- | `src/fsutil.ts` | file walk with limits (5000 files, 512 KB each, 15 s), ignore lists, symlink skipping, path containment |
33
+ | `src/fsutil.ts` | file walk with limits (5000 files, 512 KB each, 15 s), folder-by-folder sampling, ignore lists, symlink skipping, path containment |
34
34
  | `src/redact.ts` | secret detection and masking; used for every excerpt |
35
35
  | `src/map.ts` | ecosystems, frameworks, datastores, infra, module graph, Tarjan cycle detection |
36
36
  | `src/audit.ts` | rules to findings with evidence; scorecard with `not assessed` where evidence is absent |
37
- | `src/report.ts` | Markdown, Mermaid, findings JSON (v1.0.0), SARIF 2.1.0, artifact register |
37
+ | `src/report.ts` | Markdown, Mermaid, findings JSON (v1.1.0), SARIF 2.1.0, artifact register |
38
38
  | `src/verify.ts` | structural validation of skills, agents, links, Mermaid, findings |
39
39
  | `src/adapters.ts` | host specs, install plan with conflict detection, hash manifest, uninstall, doctor |
40
40
  | `src/cli.ts` | argument parsing, exit codes, command dispatch |