@vibecheckai/cli 3.5.0 → 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/registry.js +214 -237
- package/bin/runners/cli-utils.js +33 -2
- package/bin/runners/context/analyzer.js +52 -1
- package/bin/runners/context/generators/cursor.js +2 -49
- package/bin/runners/context/git-context.js +3 -1
- package/bin/runners/context/team-conventions.js +33 -7
- package/bin/runners/lib/analysis-core.js +25 -5
- package/bin/runners/lib/analyzers.js +431 -481
- package/bin/runners/lib/default-config.js +127 -0
- package/bin/runners/lib/doctor/modules/security.js +3 -1
- package/bin/runners/lib/engine/ast-cache.js +210 -0
- package/bin/runners/lib/engine/auth-extractor.js +211 -0
- package/bin/runners/lib/engine/billing-extractor.js +112 -0
- package/bin/runners/lib/engine/enforcement-extractor.js +100 -0
- package/bin/runners/lib/engine/env-extractor.js +207 -0
- package/bin/runners/lib/engine/express-extractor.js +208 -0
- package/bin/runners/lib/engine/extractors.js +849 -0
- package/bin/runners/lib/engine/index.js +207 -0
- package/bin/runners/lib/engine/repo-index.js +514 -0
- package/bin/runners/lib/engine/types.js +124 -0
- package/bin/runners/lib/engines/accessibility-engine.js +18 -218
- package/bin/runners/lib/engines/api-consistency-engine.js +30 -335
- package/bin/runners/lib/engines/cross-file-analysis-engine.js +27 -292
- package/bin/runners/lib/engines/empty-catch-engine.js +17 -127
- package/bin/runners/lib/engines/mock-data-engine.js +10 -53
- package/bin/runners/lib/engines/performance-issues-engine.js +36 -176
- package/bin/runners/lib/engines/security-vulnerabilities-engine.js +54 -382
- package/bin/runners/lib/engines/type-aware-engine.js +39 -263
- package/bin/runners/lib/engines/vibecheck-engines/index.js +13 -122
- package/bin/runners/lib/engines/vibecheck-engines/lib/ast-cache.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/code-quality-engine.js +291 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/console-logs-engine.js +83 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/dead-code-engine.js +198 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/deprecated-api-engine.js +275 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/empty-catch-engine.js +167 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/file-filter.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +73 -373
- package/bin/runners/lib/engines/vibecheck-engines/lib/mock-data-engine.js +140 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/parallel-processor.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/performance-issues-engine.js +234 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/type-aware-engine.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/unsafe-regex-engine.js +78 -0
- package/bin/runners/lib/entitlements-v2.js +73 -97
- package/bin/runners/lib/error-handler.js +44 -3
- package/bin/runners/lib/error-messages.js +289 -0
- package/bin/runners/lib/evidence-pack.js +7 -1
- package/bin/runners/lib/finding-id.js +69 -0
- package/bin/runners/lib/finding-sorter.js +89 -0
- package/bin/runners/lib/html-proof-report.js +700 -350
- package/bin/runners/lib/missions/plan.js +6 -46
- package/bin/runners/lib/missions/templates.js +0 -232
- package/bin/runners/lib/next-action.js +560 -0
- package/bin/runners/lib/prerequisites.js +149 -0
- package/bin/runners/lib/route-detection.js +137 -68
- package/bin/runners/lib/scan-output.js +91 -76
- package/bin/runners/lib/scan-runner.js +135 -0
- package/bin/runners/lib/schemas/ajv-validator.js +464 -0
- package/bin/runners/lib/schemas/error-envelope.schema.json +105 -0
- package/bin/runners/lib/schemas/finding-v3.schema.json +151 -0
- package/bin/runners/lib/schemas/report-artifact.schema.json +120 -0
- package/bin/runners/lib/schemas/run-request.schema.json +108 -0
- package/bin/runners/lib/schemas/validator.js +27 -0
- package/bin/runners/lib/schemas/verdict.schema.json +140 -0
- package/bin/runners/lib/ship-output-enterprise.js +23 -23
- package/bin/runners/lib/ship-output.js +75 -31
- package/bin/runners/lib/terminal-ui.js +6 -113
- package/bin/runners/lib/truth.js +351 -10
- package/bin/runners/lib/unified-cli-output.js +430 -603
- package/bin/runners/lib/unified-output.js +13 -9
- package/bin/runners/runAIAgent.js +10 -5
- package/bin/runners/runAgent.js +0 -3
- package/bin/runners/runAllowlist.js +389 -0
- package/bin/runners/runApprove.js +0 -33
- package/bin/runners/runAuth.js +73 -45
- package/bin/runners/runCheckpoint.js +51 -11
- package/bin/runners/runClassify.js +85 -21
- package/bin/runners/runContext.js +0 -3
- package/bin/runners/runDoctor.js +41 -28
- package/bin/runners/runEvidencePack.js +362 -0
- package/bin/runners/runFirewall.js +0 -3
- package/bin/runners/runFirewallHook.js +0 -3
- package/bin/runners/runFix.js +66 -76
- package/bin/runners/runGuard.js +18 -411
- package/bin/runners/runInit.js +113 -30
- package/bin/runners/runLabs.js +424 -0
- package/bin/runners/runMcp.js +19 -25
- package/bin/runners/runPolish.js +64 -240
- package/bin/runners/runPromptFirewall.js +12 -5
- package/bin/runners/runProve.js +57 -22
- package/bin/runners/runQuickstart.js +531 -0
- package/bin/runners/runReality.js +59 -68
- package/bin/runners/runReport.js +38 -33
- package/bin/runners/runRuntime.js +8 -5
- package/bin/runners/runScan.js +1413 -190
- package/bin/runners/runShip.js +113 -719
- package/bin/runners/runTruth.js +0 -3
- package/bin/runners/runValidate.js +13 -9
- package/bin/runners/runWatch.js +23 -14
- package/bin/scan.js +6 -1
- package/bin/vibecheck.js +204 -185
- package/mcp-server/deprecation-middleware.js +282 -0
- package/mcp-server/handlers/index.ts +15 -0
- package/mcp-server/handlers/tool-handler.ts +554 -0
- package/mcp-server/index-v1.js +698 -0
- package/mcp-server/index.js +210 -238
- package/mcp-server/lib/cache-wrapper.cjs +383 -0
- package/mcp-server/lib/error-envelope.js +138 -0
- package/mcp-server/lib/executor.ts +499 -0
- package/mcp-server/lib/index.ts +19 -0
- package/mcp-server/lib/rate-limiter.js +166 -0
- package/mcp-server/lib/sandbox.test.ts +519 -0
- package/mcp-server/lib/sandbox.ts +395 -0
- package/mcp-server/lib/types.ts +267 -0
- package/mcp-server/package.json +12 -3
- package/mcp-server/registry/tool-registry.js +794 -0
- package/mcp-server/registry/tools.json +605 -0
- package/mcp-server/registry.test.ts +334 -0
- package/mcp-server/tests/tier-gating.test.js +297 -0
- package/mcp-server/tier-auth.js +378 -45
- package/mcp-server/tools-v3.js +353 -442
- package/mcp-server/tsconfig.json +37 -0
- package/mcp-server/vibecheck-2.0-tools.js +14 -1
- package/package.json +1 -1
- package/bin/runners/lib/agent-firewall/learning/learning-engine.js +0 -849
- package/bin/runners/lib/audit-logger.js +0 -532
- package/bin/runners/lib/authority/authorities/architecture.js +0 -364
- package/bin/runners/lib/authority/authorities/compliance.js +0 -341
- package/bin/runners/lib/authority/authorities/human.js +0 -343
- package/bin/runners/lib/authority/authorities/quality.js +0 -420
- package/bin/runners/lib/authority/authorities/security.js +0 -228
- package/bin/runners/lib/authority/index.js +0 -293
- package/bin/runners/lib/bundle/bundle-intelligence.js +0 -846
- package/bin/runners/lib/cli-charts.js +0 -368
- package/bin/runners/lib/cli-config-display.js +0 -405
- package/bin/runners/lib/cli-demo.js +0 -275
- package/bin/runners/lib/cli-errors.js +0 -438
- package/bin/runners/lib/cli-help-formatter.js +0 -439
- package/bin/runners/lib/cli-interactive-menu.js +0 -509
- package/bin/runners/lib/cli-prompts.js +0 -441
- package/bin/runners/lib/cli-scan-cards.js +0 -362
- package/bin/runners/lib/compliance-reporter.js +0 -710
- package/bin/runners/lib/conductor/index.js +0 -671
- package/bin/runners/lib/easy/README.md +0 -123
- package/bin/runners/lib/easy/index.js +0 -140
- package/bin/runners/lib/easy/interactive-wizard.js +0 -788
- package/bin/runners/lib/easy/one-click-firewall.js +0 -564
- package/bin/runners/lib/easy/zero-config-reality.js +0 -714
- package/bin/runners/lib/engines/async-patterns-engine.js +0 -444
- package/bin/runners/lib/engines/bundle-size-engine.js +0 -433
- package/bin/runners/lib/engines/confidence-scoring.js +0 -276
- package/bin/runners/lib/engines/context-detection.js +0 -264
- package/bin/runners/lib/engines/database-patterns-engine.js +0 -429
- package/bin/runners/lib/engines/duplicate-code-engine.js +0 -354
- package/bin/runners/lib/engines/env-variables-engine.js +0 -458
- package/bin/runners/lib/engines/error-handling-engine.js +0 -437
- package/bin/runners/lib/engines/false-positive-prevention.js +0 -630
- package/bin/runners/lib/engines/framework-adapters/index.js +0 -607
- package/bin/runners/lib/engines/framework-detection.js +0 -508
- package/bin/runners/lib/engines/import-order-engine.js +0 -429
- package/bin/runners/lib/engines/naming-conventions-engine.js +0 -544
- package/bin/runners/lib/engines/noise-reduction-engine.js +0 -452
- package/bin/runners/lib/engines/orchestrator.js +0 -334
- package/bin/runners/lib/engines/react-patterns-engine.js +0 -457
- package/bin/runners/lib/engines/vibecheck-engines/lib/ai-hallucination-engine.js +0 -806
- package/bin/runners/lib/engines/vibecheck-engines/lib/smart-fix-engine.js +0 -577
- package/bin/runners/lib/engines/vibecheck-engines/lib/vibe-score-engine.js +0 -543
- package/bin/runners/lib/engines/vibecheck-engines.js +0 -514
- package/bin/runners/lib/enhanced-features/index.js +0 -305
- package/bin/runners/lib/enhanced-output.js +0 -631
- package/bin/runners/lib/enterprise.js +0 -300
- package/bin/runners/lib/firewall/command-validator.js +0 -351
- package/bin/runners/lib/firewall/config.js +0 -341
- package/bin/runners/lib/firewall/content-validator.js +0 -519
- package/bin/runners/lib/firewall/index.js +0 -101
- package/bin/runners/lib/firewall/path-validator.js +0 -256
- package/bin/runners/lib/intelligence/cross-repo-intelligence.js +0 -817
- package/bin/runners/lib/mcp-utils.js +0 -425
- package/bin/runners/lib/output/index.js +0 -1022
- package/bin/runners/lib/policy-engine.js +0 -652
- package/bin/runners/lib/polish/autofix/accessibility-fixes.js +0 -333
- package/bin/runners/lib/polish/autofix/async-handlers.js +0 -273
- package/bin/runners/lib/polish/autofix/dead-code.js +0 -280
- package/bin/runners/lib/polish/autofix/imports-optimizer.js +0 -344
- package/bin/runners/lib/polish/autofix/index.js +0 -200
- package/bin/runners/lib/polish/autofix/remove-consoles.js +0 -209
- package/bin/runners/lib/polish/autofix/strengthen-types.js +0 -245
- package/bin/runners/lib/polish/backend-checks.js +0 -148
- package/bin/runners/lib/polish/documentation-checks.js +0 -111
- package/bin/runners/lib/polish/frontend-checks.js +0 -168
- package/bin/runners/lib/polish/index.js +0 -71
- package/bin/runners/lib/polish/infrastructure-checks.js +0 -131
- package/bin/runners/lib/polish/library-detection.js +0 -175
- package/bin/runners/lib/polish/performance-checks.js +0 -100
- package/bin/runners/lib/polish/security-checks.js +0 -148
- package/bin/runners/lib/polish/utils.js +0 -203
- package/bin/runners/lib/prompt-builder.js +0 -540
- package/bin/runners/lib/proof-certificate.js +0 -634
- package/bin/runners/lib/reality/accessibility-audit.js +0 -946
- package/bin/runners/lib/reality/api-contract-validator.js +0 -1012
- package/bin/runners/lib/reality/chaos-engineering.js +0 -1084
- package/bin/runners/lib/reality/performance-tracker.js +0 -1077
- package/bin/runners/lib/reality/scenario-generator.js +0 -1404
- package/bin/runners/lib/reality/visual-regression.js +0 -852
- package/bin/runners/lib/reality-profiler.js +0 -717
- package/bin/runners/lib/replay/flight-recorder-viewer.js +0 -1160
- package/bin/runners/lib/review/ai-code-review.js +0 -832
- package/bin/runners/lib/rules/custom-rule-engine.js +0 -985
- package/bin/runners/lib/sbom-generator.js +0 -641
- package/bin/runners/lib/scan-output-enhanced.js +0 -512
- package/bin/runners/lib/security/owasp-scanner.js +0 -939
- package/bin/runners/lib/validators/contract-validator.js +0 -283
- package/bin/runners/lib/validators/dead-export-detector.js +0 -279
- package/bin/runners/lib/validators/dep-audit.js +0 -245
- package/bin/runners/lib/validators/env-validator.js +0 -319
- package/bin/runners/lib/validators/index.js +0 -120
- package/bin/runners/lib/validators/license-checker.js +0 -252
- package/bin/runners/lib/validators/route-validator.js +0 -290
- package/bin/runners/runAuthority.js +0 -528
- package/bin/runners/runConductor.js +0 -772
- package/bin/runners/runContainer.js +0 -366
- package/bin/runners/runEasy.js +0 -410
- package/bin/runners/runIaC.js +0 -372
- package/bin/runners/runVibe.js +0 -791
- package/mcp-server/tools.js +0 -495
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authority System - The AI That Says No
|
|
3
|
-
*
|
|
4
|
-
* Allows designated approvers (human or automated) to sign off on changes.
|
|
5
|
-
*
|
|
6
|
-
* Built-in Authorities:
|
|
7
|
-
* - security: Security review (checks for vulnerabilities)
|
|
8
|
-
* - architecture: Architecture review (patterns, structure)
|
|
9
|
-
* - compliance: Compliance check (SOC2, GDPR, HIPAA, etc.)
|
|
10
|
-
* - quality: Code quality review
|
|
11
|
-
* - human: Requires human approval (creates GitHub issue/Slack message)
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* const { listAuthorities, requestApproval } = require('./authority');
|
|
15
|
-
*
|
|
16
|
-
* // List available authorities
|
|
17
|
-
* const authorities = await listAuthorities();
|
|
18
|
-
*
|
|
19
|
-
* // Request approval from security authority
|
|
20
|
-
* const result = await requestApproval('security', {
|
|
21
|
-
* files: [{ path: 'src/auth.ts', content: '...' }],
|
|
22
|
-
* diff: '+ const password = "secret123";',
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* console.log(result.verdict); // 'APPROVED' or 'REJECTED'
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
"use strict";
|
|
29
|
-
|
|
30
|
-
const { SecurityAuthority } = require("./authorities/security");
|
|
31
|
-
const { ArchitectureAuthority } = require("./authorities/architecture");
|
|
32
|
-
const { ComplianceAuthority } = require("./authorities/compliance");
|
|
33
|
-
const { QualityAuthority } = require("./authorities/quality");
|
|
34
|
-
const { HumanAuthority } = require("./authorities/human");
|
|
35
|
-
|
|
36
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
37
|
-
// AUTHORITY REGISTRY
|
|
38
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
39
|
-
|
|
40
|
-
const AUTHORITIES = {
|
|
41
|
-
security: SecurityAuthority,
|
|
42
|
-
architecture: ArchitectureAuthority,
|
|
43
|
-
compliance: ComplianceAuthority,
|
|
44
|
-
quality: QualityAuthority,
|
|
45
|
-
human: HumanAuthority,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
49
|
-
// PUBLIC API
|
|
50
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* List all available approval authorities
|
|
54
|
-
*
|
|
55
|
-
* @returns {Promise<Array<{name: string, description: string, automated: boolean, tier: string}>>}
|
|
56
|
-
*/
|
|
57
|
-
async function listAuthorities() {
|
|
58
|
-
return Object.entries(AUTHORITIES).map(([name, Authority]) => ({
|
|
59
|
-
name,
|
|
60
|
-
description: Authority.description,
|
|
61
|
-
automated: Authority.automated,
|
|
62
|
-
tier: Authority.tier,
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Get a specific authority by name
|
|
68
|
-
*
|
|
69
|
-
* @param {string} authorityName - Name of the authority
|
|
70
|
-
* @returns {Object|null} Authority class or null if not found
|
|
71
|
-
*/
|
|
72
|
-
function getAuthority(authorityName) {
|
|
73
|
-
return AUTHORITIES[authorityName] || null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Check if an authority exists
|
|
78
|
-
*
|
|
79
|
-
* @param {string} authorityName - Name of the authority
|
|
80
|
-
* @returns {boolean}
|
|
81
|
-
*/
|
|
82
|
-
function hasAuthority(authorityName) {
|
|
83
|
-
return authorityName in AUTHORITIES;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Request approval from a specific authority
|
|
88
|
-
*
|
|
89
|
-
* @param {string} authorityName - Name of the authority to request approval from
|
|
90
|
-
* @param {Object} payload - The payload to review
|
|
91
|
-
* @param {Array<{path: string, content: string}>} payload.files - Files to review
|
|
92
|
-
* @param {string} payload.diff - Git diff of changes
|
|
93
|
-
* @param {Object} payload.context - Additional context (branch, commit, etc.)
|
|
94
|
-
* @param {Object} options - Additional options for the authority
|
|
95
|
-
* @returns {Promise<{
|
|
96
|
-
* authority: string,
|
|
97
|
-
* verdict: 'APPROVED' | 'REJECTED' | 'PENDING',
|
|
98
|
-
* reason: string,
|
|
99
|
-
* findings: Array<Object>,
|
|
100
|
-
* timestamp: string,
|
|
101
|
-
* signature: string,
|
|
102
|
-
* metadata?: Object
|
|
103
|
-
* }>}
|
|
104
|
-
*/
|
|
105
|
-
async function requestApproval(authorityName, payload, options = {}) {
|
|
106
|
-
const Authority = AUTHORITIES[authorityName];
|
|
107
|
-
|
|
108
|
-
if (!Authority) {
|
|
109
|
-
throw new Error(`Unknown authority: ${authorityName}`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const authority = new Authority(options);
|
|
113
|
-
const result = await authority.review(payload);
|
|
114
|
-
|
|
115
|
-
// Determine verdict from result
|
|
116
|
-
let verdict;
|
|
117
|
-
if (result.status === "pending") {
|
|
118
|
-
verdict = "PENDING";
|
|
119
|
-
} else {
|
|
120
|
-
verdict = result.approved ? "APPROVED" : "REJECTED";
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
authority: authorityName,
|
|
125
|
-
verdict,
|
|
126
|
-
reason: result.reason,
|
|
127
|
-
findings: result.findings || [],
|
|
128
|
-
timestamp: new Date().toISOString(),
|
|
129
|
-
signature: result.signature,
|
|
130
|
-
metadata: result.metadata,
|
|
131
|
-
// Include additional fields from specific authorities
|
|
132
|
-
...(result.qualityScore !== undefined && { qualityScore: result.qualityScore }),
|
|
133
|
-
...(result.metrics && { metrics: result.metrics }),
|
|
134
|
-
...(result.approvalRequest && { approvalRequest: result.approvalRequest }),
|
|
135
|
-
...(result.notifications && { notifications: result.notifications }),
|
|
136
|
-
...(result.existingApproval && { existingApproval: result.existingApproval }),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Run multiple authorities in parallel
|
|
142
|
-
*
|
|
143
|
-
* @param {string[]} authorityNames - Names of authorities to run
|
|
144
|
-
* @param {Object} payload - The payload to review
|
|
145
|
-
* @param {Object} options - Options passed to each authority
|
|
146
|
-
* @returns {Promise<Array<Object>>} Results from all authorities
|
|
147
|
-
*/
|
|
148
|
-
async function requestMultipleApprovals(authorityNames, payload, options = {}) {
|
|
149
|
-
const results = await Promise.all(
|
|
150
|
-
authorityNames.map(name =>
|
|
151
|
-
requestApproval(name, payload, options[name] || {})
|
|
152
|
-
.catch(error => ({
|
|
153
|
-
authority: name,
|
|
154
|
-
verdict: "ERROR",
|
|
155
|
-
reason: error.message,
|
|
156
|
-
findings: [],
|
|
157
|
-
timestamp: new Date().toISOString(),
|
|
158
|
-
signature: null,
|
|
159
|
-
error: true,
|
|
160
|
-
}))
|
|
161
|
-
)
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
return results;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Get aggregated verdict from multiple authority results
|
|
169
|
-
*
|
|
170
|
-
* @param {Array<Object>} results - Results from requestMultipleApprovals
|
|
171
|
-
* @returns {{
|
|
172
|
-
* verdict: 'APPROVED' | 'REJECTED' | 'PENDING',
|
|
173
|
-
* summary: Object,
|
|
174
|
-
* blockers: Array<string>
|
|
175
|
-
* }}
|
|
176
|
-
*/
|
|
177
|
-
function getAggregatedVerdict(results) {
|
|
178
|
-
const summary = {
|
|
179
|
-
total: results.length,
|
|
180
|
-
approved: 0,
|
|
181
|
-
rejected: 0,
|
|
182
|
-
pending: 0,
|
|
183
|
-
error: 0,
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const blockers = [];
|
|
187
|
-
|
|
188
|
-
for (const result of results) {
|
|
189
|
-
switch (result.verdict) {
|
|
190
|
-
case "APPROVED":
|
|
191
|
-
summary.approved++;
|
|
192
|
-
break;
|
|
193
|
-
case "REJECTED":
|
|
194
|
-
summary.rejected++;
|
|
195
|
-
blockers.push(`${result.authority}: ${result.reason}`);
|
|
196
|
-
break;
|
|
197
|
-
case "PENDING":
|
|
198
|
-
summary.pending++;
|
|
199
|
-
blockers.push(`${result.authority}: Awaiting approval`);
|
|
200
|
-
break;
|
|
201
|
-
case "ERROR":
|
|
202
|
-
summary.error++;
|
|
203
|
-
blockers.push(`${result.authority}: Error - ${result.reason}`);
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
let verdict;
|
|
209
|
-
if (summary.rejected > 0 || summary.error > 0) {
|
|
210
|
-
verdict = "REJECTED";
|
|
211
|
-
} else if (summary.pending > 0) {
|
|
212
|
-
verdict = "PENDING";
|
|
213
|
-
} else {
|
|
214
|
-
verdict = "APPROVED";
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
verdict,
|
|
219
|
-
summary,
|
|
220
|
-
blockers,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Register a custom authority
|
|
226
|
-
*
|
|
227
|
-
* @param {string} name - Name for the authority
|
|
228
|
-
* @param {Function} AuthorityClass - Authority class with static description, automated, tier properties
|
|
229
|
-
*/
|
|
230
|
-
function registerAuthority(name, AuthorityClass) {
|
|
231
|
-
if (AUTHORITIES[name]) {
|
|
232
|
-
throw new Error(`Authority "${name}" is already registered`);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (!AuthorityClass.description) {
|
|
236
|
-
throw new Error("Authority class must have a static 'description' property");
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (typeof AuthorityClass.prototype.review !== "function") {
|
|
240
|
-
throw new Error("Authority class must have a 'review' method");
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
AUTHORITIES[name] = AuthorityClass;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Unregister a custom authority (built-in authorities cannot be removed)
|
|
248
|
-
*
|
|
249
|
-
* @param {string} name - Name of the authority to remove
|
|
250
|
-
*/
|
|
251
|
-
function unregisterAuthority(name) {
|
|
252
|
-
const builtInAuthorities = ["security", "architecture", "compliance", "quality", "human"];
|
|
253
|
-
|
|
254
|
-
if (builtInAuthorities.includes(name)) {
|
|
255
|
-
throw new Error(`Cannot unregister built-in authority: ${name}`);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (!AUTHORITIES[name]) {
|
|
259
|
-
throw new Error(`Authority "${name}" is not registered`);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
delete AUTHORITIES[name];
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
266
|
-
// EXPORTS
|
|
267
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
268
|
-
|
|
269
|
-
module.exports = {
|
|
270
|
-
// Core API
|
|
271
|
-
listAuthorities,
|
|
272
|
-
requestApproval,
|
|
273
|
-
requestMultipleApprovals,
|
|
274
|
-
getAggregatedVerdict,
|
|
275
|
-
|
|
276
|
-
// Authority management
|
|
277
|
-
getAuthority,
|
|
278
|
-
hasAuthority,
|
|
279
|
-
registerAuthority,
|
|
280
|
-
unregisterAuthority,
|
|
281
|
-
|
|
282
|
-
// Authority classes (for extension/testing)
|
|
283
|
-
SecurityAuthority,
|
|
284
|
-
ArchitectureAuthority,
|
|
285
|
-
ComplianceAuthority,
|
|
286
|
-
QualityAuthority,
|
|
287
|
-
HumanAuthority,
|
|
288
|
-
|
|
289
|
-
// Registry (read-only access)
|
|
290
|
-
get AUTHORITIES() {
|
|
291
|
-
return { ...AUTHORITIES };
|
|
292
|
-
},
|
|
293
|
-
};
|