tribunal-kit 9.2.6 → 9.2.7
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/.agent/ARCHITECTURE.md +2 -2
- package/.agent/history/architecture-intelligence.html +1487 -401
- package/.agent/history/architecture-model.json +9365 -5697
- package/.agent/history/architecture-verification.json +37 -9
- package/.agent/routing_index.json +2069 -3340
- package/.agent/rules/GEMINI.md +1 -1
- package/.agent/scripts/adaptive_execution.js +511 -0
- package/.agent/scripts/architecture_diff.js +303 -260
- package/.agent/scripts/architecture_extractor.js +792 -753
- package/.agent/scripts/architecture_health.js +293 -256
- package/.agent/scripts/architecture_intelligence.js +3100 -0
- package/.agent/scripts/architecture_verifier.js +303 -270
- package/.agent/scripts/architecture_visualizer.js +880 -873
- package/.agent/scripts/blast_radius_engine.js +274 -234
- package/.agent/scripts/capability_evolution.js +453 -0
- package/.agent/scripts/concept_extractor.js +240 -0
- package/.agent/scripts/consideration_engine.js +284 -0
- package/.agent/scripts/coverage_engine.js +102 -0
- package/.agent/scripts/cross_domain_engine.js +1883 -0
- package/.agent/scripts/engineering_memory.js +1313 -0
- package/.agent/scripts/integrity_manifest.js +1 -5
- package/.agent/scripts/judgment_engine.js +790 -0
- package/.agent/scripts/materiality_engine.js +251 -0
- package/.agent/scripts/outcome_engine.js +624 -0
- package/.agent/scripts/outcome_optimization_engine.js +1632 -0
- package/.agent/scripts/simulation_engine.js +1478 -0
- package/.agent/scripts/skill_intelligence.js +1371 -0
- package/.agent/scripts/validation_engine.js +236 -236
- package/.agent/scripts/verification_auditor.js +266 -0
- package/.agent/skill-intelligence/taxonomy/engineering-concepts.json +555 -0
- package/.agent/skill_topic_map.json +301 -341
- package/.agent/skills_inventory.json +4272 -6922
- package/.agent/workflows/arch.md +96 -80
- package/.agent/workflows/skill-intelligence.md +216 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +24 -24
- package/bin/adapter-install.js +1 -1
- package/package.json +8 -9
- package/plugins/core-plugin.json +1 -1
- package/plugins/gemini/extension.json +1 -1
- package/src/browser/index.js +2 -1
- package/src/browser/launcher.js +41 -1
- package/src/cli.js +3 -1
- package/src/commands/arch.js +261 -172
- package/src/commands/context.js +27 -8
- package/src/commands/learn.js +21 -6
- package/src/commands/memory.js +10 -1
- package/src/commands/native.js +12 -3
- package/src/commands/skill-intelligence.js +1165 -0
- package/src/commands/system1.js +105 -4
- package/src/context/ranker.js +337 -339
- package/src/evolution/engine.js +296 -295
- package/src/synthesis/claim_check_separator.js +294 -271
- package/src/system1/browser_intelligence.js +300 -0
- package/src/system1/constants.js +49 -0
- package/src/system1/decision_engine.js +498 -0
- package/src/system1/evidence_engine.js +602 -0
- package/src/system1/evolution_pipeline.js +581 -0
- package/src/system1/index.d.ts +114 -0
- package/src/system1/index.js +102 -0
- package/src/system1/reviewer_orchestrator.js +477 -0
- package/src/tui/banner.js +1 -1
- package/src/utils/fs.js +27 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* browser_intelligence.js — System-1 Capability 5: Browser / Interaction Intelligence
|
|
5
|
+
* ====================================================================================
|
|
6
|
+
* Reasons about browser/UI verification signals to determine whether
|
|
7
|
+
* browser validation is required, which level of verification is needed,
|
|
8
|
+
* and whether the browser infrastructure is safely available.
|
|
9
|
+
*
|
|
10
|
+
* Routing Levels:
|
|
11
|
+
* - NONE: No UI impact -> skip browser stage
|
|
12
|
+
* - SMOKE: CSS-only / styling change -> lightweight smoke test
|
|
13
|
+
* - FUNCTIONAL: Form / interactive component / navigation -> functional verification
|
|
14
|
+
* - HIGH_RISK: Payment / session / access-control / auth UI -> high-risk verification
|
|
15
|
+
*
|
|
16
|
+
* Safety Invariant:
|
|
17
|
+
* If browser infrastructure is not available when validation is required,
|
|
18
|
+
* return deterministic UNAVAILABLE state and signal escalation rather than
|
|
19
|
+
* pretending validation occurred.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const { findBrowser } = require('../browser/discovery');
|
|
24
|
+
|
|
25
|
+
const UI_EXTENSIONS = new Set([
|
|
26
|
+
'.css',
|
|
27
|
+
'.scss',
|
|
28
|
+
'.less',
|
|
29
|
+
'.html',
|
|
30
|
+
'.htm',
|
|
31
|
+
'.jsx',
|
|
32
|
+
'.tsx',
|
|
33
|
+
'.vue',
|
|
34
|
+
'.svelte',
|
|
35
|
+
'.astro',
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
const CSS_EXTENSIONS = new Set(['.css', '.scss', '.less']);
|
|
39
|
+
|
|
40
|
+
const FORM_PATTERNS = [
|
|
41
|
+
/<form\b/i,
|
|
42
|
+
/<input\b/i,
|
|
43
|
+
/<textarea\b/i,
|
|
44
|
+
/<select\b/i,
|
|
45
|
+
/\bonSubmit\b/i,
|
|
46
|
+
/\bhandleSubmit\b/i,
|
|
47
|
+
/\bFormData\b/i,
|
|
48
|
+
/\buseForm\b/i,
|
|
49
|
+
/\bvalidationSchema\b/i,
|
|
50
|
+
/\bzodResolver\b/i,
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
const AUTH_UI_PATTERNS = [
|
|
54
|
+
/\b(login|sign-?in|signup|sign-?up|register|password|passphrase|mfa|totp|oauth|sso|credentials?)\b/i,
|
|
55
|
+
/\b(auth-form|auth-dialog|login-button|session-expire)\b/i,
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const PAYMENT_UI_PATTERNS = [
|
|
59
|
+
/\b(stripe|paypal|checkout|payment|credit-card|card-number|cvv|billing-form|invoice)\b/i,
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
const DOM_INTERACTION_PATTERNS = [
|
|
63
|
+
/\b(addEventListener|removeEventListener|querySelector|getElementById|innerHTML|innerText)\b/i,
|
|
64
|
+
/\b(onClick|onKeyDown|onKeyUp|onChange|onBlur|onFocus)\b/i,
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const OS_SYSTEM_ROOTS = new Set([
|
|
68
|
+
'usr',
|
|
69
|
+
'etc',
|
|
70
|
+
'tmp',
|
|
71
|
+
'var',
|
|
72
|
+
'home',
|
|
73
|
+
'bin',
|
|
74
|
+
'lib',
|
|
75
|
+
'lib64',
|
|
76
|
+
'opt',
|
|
77
|
+
'dev',
|
|
78
|
+
'proc',
|
|
79
|
+
'sys',
|
|
80
|
+
'node_modules',
|
|
81
|
+
'Users',
|
|
82
|
+
'Program Files',
|
|
83
|
+
'Windows',
|
|
84
|
+
'sbin',
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
function isTestFilePath(filePath) {
|
|
88
|
+
const norm = filePath.replace(/\\/g, '/');
|
|
89
|
+
return (
|
|
90
|
+
/\.(test|spec)\.[a-zA-Z0-9]+$/i.test(norm) ||
|
|
91
|
+
norm.includes('/__tests__/') ||
|
|
92
|
+
norm.includes('/test/') ||
|
|
93
|
+
norm.includes('/tests/')
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Extract affected route or page names from file paths and task/diff
|
|
99
|
+
*/
|
|
100
|
+
function extractAffectedRoutes(files = [], task = '', diff = '') {
|
|
101
|
+
const routes = new Set();
|
|
102
|
+
|
|
103
|
+
for (const f of files) {
|
|
104
|
+
const norm = f.replace(/\\/g, '/');
|
|
105
|
+
// Next.js App Router / Pages Router / Vue pages
|
|
106
|
+
const pageMatch = norm.match(/(?:app|pages|routes|views)\/([^.]+)/i);
|
|
107
|
+
if (pageMatch) {
|
|
108
|
+
let r = pageMatch[1].replace(/\/page$/, '').replace(/\/route$/, '');
|
|
109
|
+
if (!r.startsWith('/')) r = '/' + r;
|
|
110
|
+
routes.add(r);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Regex for route mentions in task or diff (e.g. /login, /checkout)
|
|
115
|
+
const routeMentionRegex = /(?:^|\s)(\/(?:[a-zA-Z0-9_-]+\/?){1,4})/g;
|
|
116
|
+
let match;
|
|
117
|
+
while ((match = routeMentionRegex.exec(task + ' ' + diff)) !== null) {
|
|
118
|
+
const r = match[1].trim();
|
|
119
|
+
if (r.length > 1 && !r.startsWith('/.') && !r.includes('//')) {
|
|
120
|
+
const topSegment = r.replace(/^\/+/, '').split('/')[0];
|
|
121
|
+
if (!OS_SYSTEM_ROOTS.has(topSegment)) {
|
|
122
|
+
routes.add(r);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return Array.from(routes);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Reason about browser verification requirement and level
|
|
132
|
+
* @param {Object} options
|
|
133
|
+
* @param {string[]|string} [options.files]
|
|
134
|
+
* @param {string} [options.diff]
|
|
135
|
+
* @param {string} [options.task]
|
|
136
|
+
* @param {Object} [options.environment] - Optional override for testing browser availability
|
|
137
|
+
* @returns {Object} Browser Intelligence Decision
|
|
138
|
+
*/
|
|
139
|
+
function evaluateBrowserRequirement(options = {}) {
|
|
140
|
+
const rawFiles = options.files;
|
|
141
|
+
const files = (
|
|
142
|
+
Array.isArray(rawFiles) ? rawFiles : typeof rawFiles === 'string' ? rawFiles.split(',') : []
|
|
143
|
+
)
|
|
144
|
+
.map(f =>
|
|
145
|
+
typeof f === 'string'
|
|
146
|
+
? f
|
|
147
|
+
.replace(/[\u200B-\u200D\uFEFF]/g, '')
|
|
148
|
+
.trim()
|
|
149
|
+
.replace(/\\/g, '/')
|
|
150
|
+
: '',
|
|
151
|
+
)
|
|
152
|
+
.filter(Boolean);
|
|
153
|
+
|
|
154
|
+
const diff = typeof options.diff === 'string' ? options.diff : '';
|
|
155
|
+
const task = typeof options.task === 'string' ? options.task : '';
|
|
156
|
+
const combinedContext = `${task}\n${diff}\n${files.join('\n')}`;
|
|
157
|
+
|
|
158
|
+
// 1. Analyze UI files (exclude test files)
|
|
159
|
+
const uiFiles = files.filter(
|
|
160
|
+
f =>
|
|
161
|
+
!isTestFilePath(f) &&
|
|
162
|
+
(UI_EXTENSIONS.has(path.extname(f).toLowerCase()) || f.includes('/components/')),
|
|
163
|
+
);
|
|
164
|
+
const hasUiFiles = uiFiles.length > 0;
|
|
165
|
+
const isAllCss =
|
|
166
|
+
hasUiFiles && uiFiles.every(f => CSS_EXTENSIONS.has(path.extname(f).toLowerCase()));
|
|
167
|
+
|
|
168
|
+
// 2. Identify UI signals
|
|
169
|
+
const hasForms = FORM_PATTERNS.some(pat => pat.test(combinedContext));
|
|
170
|
+
const hasAuthUi = AUTH_UI_PATTERNS.some(pat => pat.test(combinedContext));
|
|
171
|
+
const hasPaymentUi = PAYMENT_UI_PATTERNS.some(pat => pat.test(combinedContext));
|
|
172
|
+
const hasDomInteraction = DOM_INTERACTION_PATTERNS.some(pat => pat.test(diff));
|
|
173
|
+
const affectedRoutes = extractAffectedRoutes(files, task, diff);
|
|
174
|
+
|
|
175
|
+
// 3. Determine Validation Level
|
|
176
|
+
let validationLevel = 'NONE';
|
|
177
|
+
const reasons = [];
|
|
178
|
+
|
|
179
|
+
if (!hasUiFiles && !hasForms && !hasAuthUi && !hasPaymentUi && affectedRoutes.length === 0) {
|
|
180
|
+
validationLevel = 'NONE';
|
|
181
|
+
reasons.push('No UI or browser interaction impact detected');
|
|
182
|
+
} else if (hasPaymentUi || (hasAuthUi && (hasForms || hasUiFiles))) {
|
|
183
|
+
validationLevel = 'HIGH_RISK';
|
|
184
|
+
reasons.push(
|
|
185
|
+
'High-risk browser verification: touches payment, checkout, or authentication UI flow',
|
|
186
|
+
);
|
|
187
|
+
} else if (hasForms || hasDomInteraction || (hasUiFiles && !isAllCss)) {
|
|
188
|
+
validationLevel = 'FUNCTIONAL';
|
|
189
|
+
reasons.push(
|
|
190
|
+
'Functional browser verification: interactive components, form elements, or client-side routing',
|
|
191
|
+
);
|
|
192
|
+
} else if (isAllCss) {
|
|
193
|
+
validationLevel = 'SMOKE';
|
|
194
|
+
reasons.push(
|
|
195
|
+
'Lightweight smoke verification: CSS-only styling changes without logic mutations',
|
|
196
|
+
);
|
|
197
|
+
} else {
|
|
198
|
+
validationLevel = 'NONE';
|
|
199
|
+
reasons.push('No substantive UI impact');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 4. Check Browser Infrastructure Availability
|
|
203
|
+
let browserFound = null;
|
|
204
|
+
if (options.environment && typeof options.environment.browserFound !== 'undefined') {
|
|
205
|
+
browserFound = options.environment.browserFound;
|
|
206
|
+
} else {
|
|
207
|
+
try {
|
|
208
|
+
browserFound = findBrowser();
|
|
209
|
+
} catch (_) {
|
|
210
|
+
browserFound = null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const isBrowserAvailable = !!browserFound;
|
|
215
|
+
const requiresVerification = validationLevel !== 'NONE';
|
|
216
|
+
|
|
217
|
+
// 5. Determine Execution Status & Safety Routing
|
|
218
|
+
let status = 'SKIPPED';
|
|
219
|
+
let escalate = false;
|
|
220
|
+
let safetyNotice = null;
|
|
221
|
+
|
|
222
|
+
if (!requiresVerification) {
|
|
223
|
+
status = 'SKIPPED';
|
|
224
|
+
escalate = false;
|
|
225
|
+
} else if (!isBrowserAvailable) {
|
|
226
|
+
status = 'UNAVAILABLE';
|
|
227
|
+
// Monotonic safety: high risk or functional verification cannot be skipped silently if browser is missing
|
|
228
|
+
escalate = true;
|
|
229
|
+
safetyNotice = `Browser verification (${validationLevel}) is required but no compatible browser binary was discovered. Automatic escalation enforced.`;
|
|
230
|
+
reasons.push(safetyNotice);
|
|
231
|
+
} else {
|
|
232
|
+
status = 'READY';
|
|
233
|
+
escalate = false;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// 6. Recommended checks and evidence
|
|
237
|
+
const expectedChecks = [];
|
|
238
|
+
const suggestedActions = [];
|
|
239
|
+
|
|
240
|
+
if (validationLevel === 'SMOKE') {
|
|
241
|
+
expectedChecks.push('layout_shift_check', 'visual_smoke_audit');
|
|
242
|
+
suggestedActions.push('cdp_snapshot', 'check_error_overlay');
|
|
243
|
+
} else if (validationLevel === 'FUNCTIONAL') {
|
|
244
|
+
expectedChecks.push(
|
|
245
|
+
'console_exceptions',
|
|
246
|
+
'network_failures',
|
|
247
|
+
'react_error_overlay',
|
|
248
|
+
'form_submission',
|
|
249
|
+
);
|
|
250
|
+
suggestedActions.push('captureRuntimeErrors', 'verifyRuntimeFix', 'auditURL');
|
|
251
|
+
} else if (validationLevel === 'HIGH_RISK') {
|
|
252
|
+
expectedChecks.push(
|
|
253
|
+
'console_exceptions',
|
|
254
|
+
'network_failures',
|
|
255
|
+
'react_error_overlay',
|
|
256
|
+
'auth_cookie_state',
|
|
257
|
+
'form_submission',
|
|
258
|
+
'security_headers',
|
|
259
|
+
'wcag22_accessibility',
|
|
260
|
+
);
|
|
261
|
+
suggestedActions.push('captureRuntimeErrors', 'auditURL', 'verifyRuntimeFix');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
requires_browser_verification: requiresVerification,
|
|
266
|
+
validation_level: validationLevel,
|
|
267
|
+
browser_available: isBrowserAvailable ? true : 'UNAVAILABLE',
|
|
268
|
+
status,
|
|
269
|
+
escalate,
|
|
270
|
+
safety_notice: safetyNotice,
|
|
271
|
+
signals: {
|
|
272
|
+
has_ui_files: hasUiFiles,
|
|
273
|
+
has_css_only: isAllCss,
|
|
274
|
+
has_forms: hasForms,
|
|
275
|
+
has_auth_ui: hasAuthUi,
|
|
276
|
+
has_payment_ui: hasPaymentUi,
|
|
277
|
+
has_dom_interaction: hasDomInteraction,
|
|
278
|
+
affected_routes: affectedRoutes,
|
|
279
|
+
},
|
|
280
|
+
evidence: {
|
|
281
|
+
expected_checks: expectedChecks,
|
|
282
|
+
suggested_actions: suggestedActions,
|
|
283
|
+
affected_routes: affectedRoutes,
|
|
284
|
+
},
|
|
285
|
+
affected_routes: affectedRoutes,
|
|
286
|
+
ui_files: uiFiles,
|
|
287
|
+
reasons,
|
|
288
|
+
browser_details: browserFound ? { type: browserFound.type, path: browserFound.path } : null,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
module.exports = {
|
|
293
|
+
evaluateBrowserRequirement,
|
|
294
|
+
extractAffectedRoutes,
|
|
295
|
+
UI_EXTENSIONS,
|
|
296
|
+
CSS_EXTENSIONS,
|
|
297
|
+
FORM_PATTERNS,
|
|
298
|
+
AUTH_UI_PATTERNS,
|
|
299
|
+
PAYMENT_UI_PATTERNS,
|
|
300
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* constants.js — System-1 Capability Suite Core Constants & Risk Patterns
|
|
5
|
+
* =======================================================================
|
|
6
|
+
* Single source of truth for risk patterns, impact tiers, routing names,
|
|
7
|
+
* and security boundaries across all System-1 intelligence modules.
|
|
8
|
+
*
|
|
9
|
+
* This module has ZERO dependencies, guaranteeing zero circular requires.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const HIGH_RISK_PATTERNS =
|
|
13
|
+
/\b(auth(?:entication|orization)?|login|sign-in|sso|oauth|identity|roles?|access-control|permissions?|ownership|admin|secrets?|credentials?|api keys?|signing-keys?|postgres|sql|schema|migration|transaction|pools?|database|db|containers?|privileges?|deployment|network polic(?:y|ies)|tls|certificates?|ci|redis|docker|passwords?|tokens?|jwt|rbac|infrastructure|provisioning|sessions?)\b/i;
|
|
14
|
+
|
|
15
|
+
const HIGH_RISK_EXTENSIONS = /\.(sql|prisma|tf|tofu)$/i;
|
|
16
|
+
|
|
17
|
+
const TIER_NAMES = ['Fast-Pass', 'Express Pass', 'Targeted Audit', 'Full Gauntlet'];
|
|
18
|
+
const ROUTING_NAMES = ['FAST_PASS', 'EXPRESS_PASS', 'TARGETED_REVIEW', 'FULL_TRIBUNAL'];
|
|
19
|
+
|
|
20
|
+
// Security boundary path patterns
|
|
21
|
+
const SECURITY_BOUNDARIES = [
|
|
22
|
+
/[\\/](?:auth|security|jwt|crypto|secrets?|tokens?|passwords?|sessions?)[\\/.]/i,
|
|
23
|
+
/[\\/](?:roles?|access-control|rbac|oauth|sso|permissions?)[\\/.]/i,
|
|
24
|
+
/[\\/]SECURITY\.md$/i,
|
|
25
|
+
/[\\/]\.env/i,
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// Type hierarchy priority for deterministic evidence ordering
|
|
29
|
+
const TYPE_PRIORITY = {
|
|
30
|
+
changed_file: 1,
|
|
31
|
+
changed_symbol: 2,
|
|
32
|
+
direct_dependency: 3,
|
|
33
|
+
direct_importer: 3,
|
|
34
|
+
relevant_test: 4,
|
|
35
|
+
configuration: 5,
|
|
36
|
+
security_boundary: 6,
|
|
37
|
+
historical_memory: 7,
|
|
38
|
+
previous_finding: 8,
|
|
39
|
+
repository_context: 9,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
HIGH_RISK_PATTERNS,
|
|
44
|
+
HIGH_RISK_EXTENSIONS,
|
|
45
|
+
TIER_NAMES,
|
|
46
|
+
ROUTING_NAMES,
|
|
47
|
+
SECURITY_BOUNDARIES,
|
|
48
|
+
TYPE_PRIORITY,
|
|
49
|
+
};
|