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.
Files changed (63) hide show
  1. package/.agent/ARCHITECTURE.md +2 -2
  2. package/.agent/history/architecture-intelligence.html +1487 -401
  3. package/.agent/history/architecture-model.json +9365 -5697
  4. package/.agent/history/architecture-verification.json +37 -9
  5. package/.agent/routing_index.json +2069 -3340
  6. package/.agent/rules/GEMINI.md +1 -1
  7. package/.agent/scripts/adaptive_execution.js +511 -0
  8. package/.agent/scripts/architecture_diff.js +303 -260
  9. package/.agent/scripts/architecture_extractor.js +792 -753
  10. package/.agent/scripts/architecture_health.js +293 -256
  11. package/.agent/scripts/architecture_intelligence.js +3100 -0
  12. package/.agent/scripts/architecture_verifier.js +303 -270
  13. package/.agent/scripts/architecture_visualizer.js +880 -873
  14. package/.agent/scripts/blast_radius_engine.js +274 -234
  15. package/.agent/scripts/capability_evolution.js +453 -0
  16. package/.agent/scripts/concept_extractor.js +240 -0
  17. package/.agent/scripts/consideration_engine.js +284 -0
  18. package/.agent/scripts/coverage_engine.js +102 -0
  19. package/.agent/scripts/cross_domain_engine.js +1883 -0
  20. package/.agent/scripts/engineering_memory.js +1313 -0
  21. package/.agent/scripts/integrity_manifest.js +1 -5
  22. package/.agent/scripts/judgment_engine.js +790 -0
  23. package/.agent/scripts/materiality_engine.js +251 -0
  24. package/.agent/scripts/outcome_engine.js +624 -0
  25. package/.agent/scripts/outcome_optimization_engine.js +1632 -0
  26. package/.agent/scripts/simulation_engine.js +1478 -0
  27. package/.agent/scripts/skill_intelligence.js +1371 -0
  28. package/.agent/scripts/validation_engine.js +236 -236
  29. package/.agent/scripts/verification_auditor.js +266 -0
  30. package/.agent/skill-intelligence/taxonomy/engineering-concepts.json +555 -0
  31. package/.agent/skill_topic_map.json +301 -341
  32. package/.agent/skills_inventory.json +4272 -6922
  33. package/.agent/workflows/arch.md +96 -80
  34. package/.agent/workflows/skill-intelligence.md +216 -0
  35. package/CONTRIBUTING.md +2 -2
  36. package/README.md +24 -24
  37. package/bin/adapter-install.js +1 -1
  38. package/package.json +8 -9
  39. package/plugins/core-plugin.json +1 -1
  40. package/plugins/gemini/extension.json +1 -1
  41. package/src/browser/index.js +2 -1
  42. package/src/browser/launcher.js +41 -1
  43. package/src/cli.js +3 -1
  44. package/src/commands/arch.js +261 -172
  45. package/src/commands/context.js +27 -8
  46. package/src/commands/learn.js +21 -6
  47. package/src/commands/memory.js +10 -1
  48. package/src/commands/native.js +12 -3
  49. package/src/commands/skill-intelligence.js +1165 -0
  50. package/src/commands/system1.js +105 -4
  51. package/src/context/ranker.js +337 -339
  52. package/src/evolution/engine.js +296 -295
  53. package/src/synthesis/claim_check_separator.js +294 -271
  54. package/src/system1/browser_intelligence.js +300 -0
  55. package/src/system1/constants.js +49 -0
  56. package/src/system1/decision_engine.js +498 -0
  57. package/src/system1/evidence_engine.js +602 -0
  58. package/src/system1/evolution_pipeline.js +581 -0
  59. package/src/system1/index.d.ts +114 -0
  60. package/src/system1/index.js +102 -0
  61. package/src/system1/reviewer_orchestrator.js +477 -0
  62. package/src/tui/banner.js +1 -1
  63. package/src/utils/fs.js +27 -0
@@ -1,236 +1,236 @@
1
- #!/usr/bin/env node
2
- /**
3
- * validation_engine.js — Tribunal Validation Engine (Trust Boundary Authority)
4
- *
5
- * THIS IS THE SOLE AUTHORITY for VERIFIED status.
6
- *
7
- * Trust Model:
8
- * UNTRUSTED: Repository content, LLM observations, LLM claims
9
- * STRUCTURALLY VALID: Findings that pass Zod schema
10
- * SOURCE CONFIRMED: Evidence locations verified against repository
11
- * VERIFIED: Independent proof exists (test execution or static tool)
12
- *
13
- * CRITICAL RULES:
14
- * 1. LLM output is NEVER trusted for verification status.
15
- * 2. Any finding arriving with status=VERIFIED is DEMOTED to DETECTED.
16
- * 3. VERIFIED requires independent execution proof with provenance.
17
- * 4. Evidence locations are verified against the actual repository.
18
- * 5. Stale evidence (code changed) prevents VERIFIED.
19
- */
20
-
21
- 'use strict';
22
-
23
- const fs = require('fs');
24
- const { BOLD, RESET, BLUE, GREEN, RED, YELLOW, sectionHeader } = require('./_colors');
25
- const { verifyFindingEvidence } = require('./evidence_verifier');
26
- const { redactFinding } = require('./secret_redactor');
27
-
28
- // Trusted statuses that only this engine can assign
29
- const TRUSTED_STATUSES = new Set(['VERIFIED', 'FIXED', 'REGRESSION-PROTECTED']);
30
-
31
- /**
32
- * Output Isolation (§9):
33
- * Strip any trusted status that the LLM may have self-assigned.
34
- * LLM may only produce DETECTED or UNVERIFIED.
35
- */
36
- function enforceOutputIsolation(finding) {
37
- if (TRUSTED_STATUSES.has(finding.status)) {
38
- finding._original_status = finding.status;
39
- finding.status = 'DETECTED';
40
- finding._isolation_note = `Status "${finding._original_status}" was demoted to DETECTED. Only the validation engine can assign trusted statuses.`;
41
- }
42
- return finding;
43
- }
44
-
45
- /**
46
- * Validation provenance record (§13).
47
- * Every VERIFIED finding gets a provenance trail.
48
- */
49
- function createProvenance(method, details) {
50
- return {
51
- method,
52
- timestamp: new Date().toISOString(),
53
- engine: 'validation_engine.js',
54
- ...details,
55
- };
56
- }
57
-
58
- /**
59
- * Determines the validation status for a finding.
60
- *
61
- * Decision tree:
62
- * 1. Output isolation: demote any self-assigned VERIFIED
63
- * 2. Evidence verification: check source locations exist
64
- * 3. Architecture/design → UNVERIFIED (cannot be tested)
65
- * 4. Has trusted test execution record → VERIFIED (with provenance)
66
- * 5. Has trusted static proof record → VERIFIED (with provenance)
67
- * 6. All others → DETECTED (evidence exists, no reproduction)
68
- */
69
- function runSafeValidation(finding, repoRoot) {
70
- // Step 1: Output isolation — demote self-assigned trusted statuses
71
- enforceOutputIsolation(finding);
72
-
73
- // Step 2: Evidence verification against repository (if repoRoot provided)
74
- if (repoRoot) {
75
- finding = verifyFindingEvidence(finding, repoRoot);
76
-
77
- // If ALL evidence locations are fabricated, finding is UNVERIFIED
78
- if (
79
- finding.evidence_verification &&
80
- finding.evidence_verification.status === 'ALL_FABRICATED'
81
- ) {
82
- return {
83
- status: 'UNVERIFIED',
84
- message: 'All evidence locations are fabricated or do not exist in the repository.',
85
- provenance: createProvenance('evidence_verification', {
86
- result: 'ALL_FABRICATED',
87
- details: finding.evidence_verification.details,
88
- }),
89
- };
90
- }
91
- }
92
-
93
- // Step 3: Architecture and design findings cannot be reproduced
94
- if (finding.category === 'architecture' || finding.category === 'design') {
95
- return {
96
- status: 'UNVERIFIED',
97
- message: 'Architectural issues cannot be automatically verified safely.',
98
- provenance: createProvenance('category_exclusion', { category: finding.category }),
99
- };
100
- }
101
-
102
- // Step 4: Trusted test execution proof
103
- // The verification object must contain a trusted execution record
104
- // with command, exit_code, and output — not just "test_executed: true"
105
- if (finding.verification) {
106
- const v = finding.verification;
107
-
108
- if (v.test_executed === true && v.command && typeof v.exit_code === 'number' && v.test_output) {
109
- return {
110
- status: 'VERIFIED',
111
- message: `Verified by test execution: ${v.command} (exit ${v.exit_code})`,
112
- provenance: createProvenance('test_execution', {
113
- command: v.command,
114
- exit_code: v.exit_code,
115
- output_preview: (v.test_output || '').substring(0, 200),
116
- }),
117
- };
118
- }
119
-
120
- // Step 5: Trusted static analysis proof
121
- // Must have tool name AND tool output — not just "static_proof: true"
122
- if (v.static_proof === true && v.tool && v.tool_output) {
123
- return {
124
- status: 'VERIFIED',
125
- message: `Verified by static analysis: ${v.tool}`,
126
- provenance: createProvenance('static_analysis', {
127
- tool: v.tool,
128
- output_preview: (v.tool_output || '').substring(0, 200),
129
- }),
130
- };
131
- }
132
-
133
- // Incomplete verification claims — demote to DETECTED with explanation
134
- if (v.test_executed === true && (!v.command || typeof v.exit_code !== 'number')) {
135
- finding._verification_rejection =
136
- 'test_executed=true but missing required provenance (command, exit_code)';
137
- }
138
- if (v.static_proof === true && (!v.tool || !v.tool_output)) {
139
- finding._verification_rejection =
140
- 'static_proof=true but missing required provenance (tool, tool_output)';
141
- }
142
- }
143
-
144
- // Step 6: Default — evidence exists but no reproduction
145
- return {
146
- status: 'DETECTED',
147
- message:
148
- 'Evidence exists but no automated reproduction was performed. Manual review recommended.',
149
- provenance: createProvenance('default', { reason: 'no_independent_proof' }),
150
- };
151
- }
152
-
153
- function runValidation(findings, repoRoot) {
154
- const validated = [];
155
- console.log(sectionHeader('Validation Engine Execution'));
156
-
157
- for (const finding of findings) {
158
- const titlePreview = (finding.title || '').substring(0, 50);
159
- console.log(`${BOLD}Validating finding: ${finding.id} - ${titlePreview}...${RESET}`);
160
-
161
- // Log output isolation events
162
- if (finding._isolation_note) {
163
- console.log(` ${RED}⚠ OUTPUT ISOLATION:${RESET} ${finding._isolation_note}`);
164
- }
165
-
166
- if (finding.validation && finding.validation.required !== false) {
167
- const result = runSafeValidation(finding, repoRoot);
168
-
169
- if (result.status === 'VERIFIED') console.log(` ${GREEN}Result:${RESET} ${result.message}`);
170
- else if (result.status === 'DETECTED')
171
- console.log(` ${YELLOW}Result:${RESET} ${result.message}`);
172
- else console.log(` ${BLUE}Result:${RESET} ${result.message}`);
173
-
174
- if (finding._verification_rejection) {
175
- console.log(` ${RED}⚠ REJECTED:${RESET} ${finding._verification_rejection}`);
176
- }
177
-
178
- finding.status = result.status;
179
- finding.validation = {
180
- ...finding.validation,
181
- result: result.message,
182
- provenance: result.provenance,
183
- };
184
-
185
- // Redact secrets before output
186
- validated.push(redactFinding(finding));
187
- } else {
188
- console.log(` ${BLUE}Result:${RESET} Validation not required by finding.`);
189
- finding.validation = {
190
- ...finding.validation,
191
- result: 'Skipped — validation not required.',
192
- };
193
- validated.push(redactFinding(finding));
194
- }
195
- }
196
- return validated;
197
- }
198
-
199
- function main() {
200
- const args = process.argv.slice(2);
201
- const inputPath =
202
- args.find(a => a.startsWith('--in='))?.split('=')[1] || 'correlated_findings.json';
203
- const outPath =
204
- args.find(a => a.startsWith('--out='))?.split('=')[1] || 'validated_findings.json';
205
- const repoRoot = args.find(a => a.startsWith('--repo='))?.split('=')[1] || null;
206
-
207
- console.log(`${BOLD}Tribunal — Validation Engine${RESET}`);
208
- if (!fs.existsSync(inputPath)) {
209
- console.log(RED + `Input file not found: ${inputPath}` + RESET);
210
- process.exit(1);
211
- }
212
-
213
- let data;
214
- try {
215
- data = JSON.parse(fs.readFileSync(inputPath, 'utf8'));
216
- } catch (e) {
217
- console.error(RED + 'Failed to parse JSON:' + RESET, e.message);
218
- process.exit(1);
219
- }
220
-
221
- const findings = data.findings || [];
222
- if (findings.length === 0) {
223
- console.log(YELLOW + 'No findings to validate.' + RESET);
224
- fs.writeFileSync(outPath, JSON.stringify({ findings: [] }, null, 2));
225
- return;
226
- }
227
-
228
- const validated = runValidation(findings, repoRoot);
229
- fs.writeFileSync(outPath, JSON.stringify({ findings: validated }, null, 2));
230
-
231
- console.log(`\nWritten validated findings to: ${outPath}`);
232
- }
233
-
234
- if (require.main === module) {
235
- main();
236
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * validation_engine.js — Tribunal Validation Engine (Trust Boundary Authority)
4
+ *
5
+ * THIS IS THE SOLE AUTHORITY for VERIFIED status.
6
+ *
7
+ * Trust Model:
8
+ * UNTRUSTED: Repository content, LLM observations, LLM claims
9
+ * STRUCTURALLY VALID: Findings that pass Zod schema
10
+ * SOURCE CONFIRMED: Evidence locations verified against repository
11
+ * VERIFIED: Independent proof exists (test execution or static tool)
12
+ *
13
+ * CRITICAL RULES:
14
+ * 1. LLM output is NEVER trusted for verification status.
15
+ * 2. Any finding arriving with status=VERIFIED is DEMOTED to DETECTED.
16
+ * 3. VERIFIED requires independent execution proof with provenance.
17
+ * 4. Evidence locations are verified against the actual repository.
18
+ * 5. Stale evidence (code changed) prevents VERIFIED.
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ const fs = require('fs');
24
+ const { BOLD, RESET, BLUE, GREEN, RED, YELLOW, sectionHeader } = require('./_colors');
25
+ const { verifyFindingEvidence } = require('./evidence_verifier');
26
+ const { redactFinding } = require('./secret_redactor');
27
+
28
+ // Trusted statuses that only this engine can assign
29
+ const TRUSTED_STATUSES = new Set(['VERIFIED', 'FIXED', 'REGRESSION-PROTECTED']);
30
+
31
+ /**
32
+ * Output Isolation (§9):
33
+ * Strip any trusted status that the LLM may have self-assigned.
34
+ * LLM may only produce DETECTED or UNVERIFIED.
35
+ */
36
+ function enforceOutputIsolation(finding) {
37
+ if (TRUSTED_STATUSES.has(finding.status)) {
38
+ finding._original_status = finding.status;
39
+ finding.status = 'DETECTED';
40
+ finding._isolation_note = `Status "${finding._original_status}" was demoted to DETECTED. Only the validation engine can assign trusted statuses.`;
41
+ }
42
+ return finding;
43
+ }
44
+
45
+ /**
46
+ * Validation provenance record (§13).
47
+ * Every VERIFIED finding gets a provenance trail.
48
+ */
49
+ function createProvenance(method, details) {
50
+ return {
51
+ method,
52
+ timestamp: new Date().toISOString(),
53
+ engine: 'validation_engine.js',
54
+ ...details,
55
+ };
56
+ }
57
+
58
+ /**
59
+ * Determines the validation status for a finding.
60
+ *
61
+ * Decision tree:
62
+ * 1. Output isolation: demote any self-assigned VERIFIED
63
+ * 2. Evidence verification: check source locations exist
64
+ * 3. Architecture/design → UNVERIFIED (cannot be tested)
65
+ * 4. Has trusted test execution record → VERIFIED (with provenance)
66
+ * 5. Has trusted static proof record → VERIFIED (with provenance)
67
+ * 6. All others → DETECTED (evidence exists, no reproduction)
68
+ */
69
+ function runSafeValidation(finding, repoRoot) {
70
+ // Step 1: Output isolation — demote self-assigned trusted statuses
71
+ enforceOutputIsolation(finding);
72
+
73
+ // Step 2: Evidence verification against repository (if repoRoot provided)
74
+ if (repoRoot) {
75
+ finding = verifyFindingEvidence(finding, repoRoot);
76
+
77
+ // If ALL evidence locations are fabricated, finding is UNVERIFIED
78
+ if (
79
+ finding.evidence_verification &&
80
+ finding.evidence_verification.status === 'ALL_FABRICATED'
81
+ ) {
82
+ return {
83
+ status: 'UNVERIFIED',
84
+ message: 'All evidence locations are fabricated or do not exist in the repository.',
85
+ provenance: createProvenance('evidence_verification', {
86
+ result: 'ALL_FABRICATED',
87
+ details: finding.evidence_verification.details,
88
+ }),
89
+ };
90
+ }
91
+ }
92
+
93
+ // Step 3: Architecture and design findings cannot be reproduced
94
+ if (finding.category === 'architecture' || finding.category === 'design') {
95
+ return {
96
+ status: 'UNVERIFIED',
97
+ message: 'Architectural issues cannot be automatically verified safely.',
98
+ provenance: createProvenance('category_exclusion', { category: finding.category }),
99
+ };
100
+ }
101
+
102
+ // Step 4: Trusted test execution proof
103
+ // The verification object must contain a trusted execution record
104
+ // with command, exit_code, and output — not just "test_executed: true"
105
+ if (finding.verification) {
106
+ const v = finding.verification;
107
+
108
+ if (v.test_executed === true && v.command && typeof v.exit_code === 'number' && v.test_output) {
109
+ return {
110
+ status: 'VERIFIED',
111
+ message: `Verified by test execution: ${v.command} (exit ${v.exit_code})`,
112
+ provenance: createProvenance('test_execution', {
113
+ command: v.command,
114
+ exit_code: v.exit_code,
115
+ output_preview: (v.test_output || '').substring(0, 200),
116
+ }),
117
+ };
118
+ }
119
+
120
+ // Step 5: Trusted static analysis proof
121
+ // Must have tool name AND tool output — not just "static_proof: true"
122
+ if (v.static_proof === true && v.tool && v.tool_output) {
123
+ return {
124
+ status: 'VERIFIED',
125
+ message: `Verified by static analysis: ${v.tool}`,
126
+ provenance: createProvenance('static_analysis', {
127
+ tool: v.tool,
128
+ output_preview: (v.tool_output || '').substring(0, 200),
129
+ }),
130
+ };
131
+ }
132
+
133
+ // Incomplete verification claims — demote to DETECTED with explanation
134
+ if (v.test_executed === true && (!v.command || typeof v.exit_code !== 'number')) {
135
+ finding._verification_rejection =
136
+ 'test_executed=true but missing required provenance (command, exit_code)';
137
+ }
138
+ if (v.static_proof === true && (!v.tool || !v.tool_output)) {
139
+ finding._verification_rejection =
140
+ 'static_proof=true but missing required provenance (tool, tool_output)';
141
+ }
142
+ }
143
+
144
+ // Step 6: Default — evidence exists but no reproduction
145
+ return {
146
+ status: 'DETECTED',
147
+ message:
148
+ 'Evidence exists but no automated reproduction was performed. Manual review recommended.',
149
+ provenance: createProvenance('default', { reason: 'no_independent_proof' }),
150
+ };
151
+ }
152
+
153
+ function runValidation(findings, repoRoot) {
154
+ const validated = [];
155
+ console.log(sectionHeader('Validation Engine Execution'));
156
+
157
+ for (const finding of findings) {
158
+ const titlePreview = (finding.title || '').substring(0, 50);
159
+ console.log(`${BOLD}Validating finding: ${finding.id} - ${titlePreview}...${RESET}`);
160
+
161
+ // Log output isolation events
162
+ if (finding._isolation_note) {
163
+ console.log(` ${RED}⚠ OUTPUT ISOLATION:${RESET} ${finding._isolation_note}`);
164
+ }
165
+
166
+ if (finding.validation && finding.validation.required !== false) {
167
+ const result = runSafeValidation(finding, repoRoot);
168
+
169
+ if (result.status === 'VERIFIED') console.log(` ${GREEN}Result:${RESET} ${result.message}`);
170
+ else if (result.status === 'DETECTED')
171
+ console.log(` ${YELLOW}Result:${RESET} ${result.message}`);
172
+ else console.log(` ${BLUE}Result:${RESET} ${result.message}`);
173
+
174
+ if (finding._verification_rejection) {
175
+ console.log(` ${RED}⚠ REJECTED:${RESET} ${finding._verification_rejection}`);
176
+ }
177
+
178
+ finding.status = result.status;
179
+ finding.validation = {
180
+ ...finding.validation,
181
+ result: result.message,
182
+ provenance: result.provenance,
183
+ };
184
+
185
+ // Redact secrets before output
186
+ validated.push(redactFinding(finding));
187
+ } else {
188
+ console.log(` ${BLUE}Result:${RESET} Validation not required by finding.`);
189
+ finding.validation = {
190
+ ...finding.validation,
191
+ result: 'Skipped — validation not required.',
192
+ };
193
+ validated.push(redactFinding(finding));
194
+ }
195
+ }
196
+ return validated;
197
+ }
198
+
199
+ function main() {
200
+ const args = process.argv.slice(2);
201
+ const inputPath =
202
+ args.find(a => a.startsWith('--in='))?.split('=')[1] || 'correlated_findings.json';
203
+ const outPath =
204
+ args.find(a => a.startsWith('--out='))?.split('=')[1] || 'validated_findings.json';
205
+ const repoRoot = args.find(a => a.startsWith('--repo='))?.split('=')[1] || null;
206
+
207
+ console.log(`${BOLD}Tribunal — Validation Engine${RESET}`);
208
+ if (!fs.existsSync(inputPath)) {
209
+ console.log(RED + `Input file not found: ${inputPath}` + RESET);
210
+ process.exit(1);
211
+ }
212
+
213
+ let data;
214
+ try {
215
+ data = JSON.parse(fs.readFileSync(inputPath, 'utf8'));
216
+ } catch (e) {
217
+ console.error(RED + 'Failed to parse JSON:' + RESET, e.message);
218
+ process.exit(1);
219
+ }
220
+
221
+ const findings = data.findings || [];
222
+ if (findings.length === 0) {
223
+ console.log(YELLOW + 'No findings to validate.' + RESET);
224
+ fs.writeFileSync(outPath, JSON.stringify({ findings: [] }, null, 2));
225
+ return;
226
+ }
227
+
228
+ const validated = runValidation(findings, repoRoot);
229
+ fs.writeFileSync(outPath, JSON.stringify({ findings: validated }, null, 2));
230
+
231
+ console.log(`\nWritten validated findings to: ${outPath}`);
232
+ }
233
+
234
+ if (require.main === module) {
235
+ main();
236
+ }