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
@@ -0,0 +1,284 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { extractConcepts } = require('./concept_extractor');
5
+
6
+ function generateConsiderations(conceptResultOrQuery, agentDir) {
7
+ let conceptData;
8
+ if (typeof conceptResultOrQuery === 'string') {
9
+ conceptData = extractConcepts(conceptResultOrQuery, agentDir);
10
+ } else {
11
+ conceptData = conceptResultOrQuery;
12
+ }
13
+
14
+ const considerations = [];
15
+ const risks = [...(conceptData.risk_signals || [])];
16
+ const failureModes = new Set();
17
+ const qualityAttributes = new Set();
18
+ const constraints = [];
19
+
20
+ const seenConsiderations = new Set();
21
+
22
+ function addConsideration(severity, category, title, rationale) {
23
+ const key = `${category}:${title}`;
24
+ if (!seenConsiderations.has(key)) {
25
+ seenConsiderations.add(key);
26
+ considerations.push({ severity, category, title, rationale });
27
+ }
28
+ }
29
+
30
+ for (const c of conceptData.all_concepts || []) {
31
+ if (c.failure_modes) c.failure_modes.forEach(fm => failureModes.add(fm));
32
+ if (c.quality_attributes) c.quality_attributes.forEach(qa => qualityAttributes.add(qa));
33
+
34
+ switch (c.id) {
35
+ case 'idempotency':
36
+ addConsideration(
37
+ 'CRITICAL',
38
+ 'Data Integrity',
39
+ 'Duplicate Execution Protection',
40
+ 'Client retries or network replays must produce exactly one business effect.',
41
+ );
42
+ addConsideration(
43
+ 'CRITICAL',
44
+ 'API Design',
45
+ 'Idempotency Key Protocol',
46
+ 'Enforce unique client idempotency keys stored in an atomic lock/cache.',
47
+ );
48
+ break;
49
+ case 'transaction-integrity':
50
+ addConsideration(
51
+ 'CRITICAL',
52
+ 'Consistency',
53
+ 'Atomic Database Boundaries',
54
+ 'Multi-step state mutations must rollback atomically upon external or internal failure.',
55
+ );
56
+ addConsideration(
57
+ 'HIGH',
58
+ 'Data Integrity',
59
+ 'Isolation & Deadlock Prevention',
60
+ 'Ensure appropriate transaction isolation levels to prevent phantom/dirty reads.',
61
+ );
62
+ break;
63
+ case 'concurrency-control':
64
+ addConsideration(
65
+ 'HIGH',
66
+ 'Concurrency',
67
+ 'Race Condition Defense',
68
+ 'Concurrent duplicate requests for the same entity must be serialized or rejected with conflict.',
69
+ );
70
+ break;
71
+ case 'retry-and-backoff':
72
+ addConsideration(
73
+ 'HIGH',
74
+ 'Reliability',
75
+ 'Exponential Backoff & Jitter',
76
+ 'Downstream calls must use backoff with jitter to prevent thundering herd / retry storms.',
77
+ );
78
+ addConsideration(
79
+ 'HIGH',
80
+ 'Fault Tolerance',
81
+ 'Timeout & Circuit Breaking',
82
+ 'Bound all external RPCs with explicit deadlines and circuit breakers.',
83
+ );
84
+ break;
85
+ case 'query-optimization':
86
+ addConsideration(
87
+ 'HIGH',
88
+ 'Performance',
89
+ 'Query Planning & Index Coverage',
90
+ 'Ensure queries use covering/composite indexes and avoid table scans or N+1 queries.',
91
+ );
92
+ addConsideration(
93
+ 'MEDIUM',
94
+ 'Scalability',
95
+ 'Connection Pool Sizing',
96
+ 'Prevent connection starvation under load with connection pooling.',
97
+ );
98
+ break;
99
+ case 'authentication-and-authorization':
100
+ addConsideration(
101
+ 'CRITICAL',
102
+ 'Security',
103
+ 'Authentication & Token Verification',
104
+ 'Enforce strict cryptographic signature and expiration validation on credentials.',
105
+ );
106
+ addConsideration(
107
+ 'HIGH',
108
+ 'Security',
109
+ 'Least-Privilege Authorization',
110
+ 'Verify permissions prior to executing any mutation or accessing private entities.',
111
+ );
112
+ break;
113
+ case 'input-validation-and-sanitization':
114
+ addConsideration(
115
+ 'HIGH',
116
+ 'Security',
117
+ 'Strict Schema Boundary Validation',
118
+ 'Validate incoming payloads against schemas before passing to domain logic.',
119
+ );
120
+ break;
121
+ case 'structured-observability':
122
+ addConsideration(
123
+ 'MEDIUM',
124
+ 'Observability',
125
+ 'Correlation IDs & Structured Logs',
126
+ 'Propagate trace IDs across async operations and log structured JSON context.',
127
+ );
128
+ break;
129
+ case 'file-upload-and-storage':
130
+ addConsideration(
131
+ 'HIGH',
132
+ 'Security',
133
+ 'MIME Validation & Storage Quotas',
134
+ 'Verify magic bytes/MIME type and enforce strict byte limits on uploads.',
135
+ );
136
+ break;
137
+ case 'ai-agent-security-and-sandboxing':
138
+ addConsideration(
139
+ 'CRITICAL',
140
+ 'Security',
141
+ 'Tool Execution Sandboxing',
142
+ 'Disallow unrestricted subprocess execution and strip prompt injection vectors.',
143
+ );
144
+ break;
145
+ case 'realtime-collaboration-and-sync':
146
+ addConsideration(
147
+ 'HIGH',
148
+ 'Consistency',
149
+ 'Conflict Resolution & State Synchronization',
150
+ 'Employ deterministic CRDT/OT merging to avoid state divergence.',
151
+ );
152
+ break;
153
+ case 'cicd-and-deployment-safety':
154
+ addConsideration(
155
+ 'HIGH',
156
+ 'Reliability',
157
+ 'Zero-Downtime Deployment & Rollback Safety',
158
+ 'Enforce automated health checks, blue-green/canary rollout, and instant rollback capability.',
159
+ );
160
+ addConsideration(
161
+ 'HIGH',
162
+ 'Operability',
163
+ 'Configuration & Secret Isolation',
164
+ 'Isolate environment secrets and validate container resource limits.',
165
+ );
166
+ break;
167
+ case 'distributed-job-processing':
168
+ addConsideration(
169
+ 'HIGH',
170
+ 'Reliability',
171
+ 'Dead-Letter Queue & Poison Pill Isolation',
172
+ 'Isolate failing jobs to dead-letter queue after bounded retries.',
173
+ );
174
+ addConsideration(
175
+ 'HIGH',
176
+ 'Concurrency',
177
+ 'Worker Concurrency & Backpressure',
178
+ 'Throttle concurrent worker pool execution to prevent resource starvation.',
179
+ );
180
+ break;
181
+ case 'rag-and-vector-retrieval':
182
+ addConsideration(
183
+ 'HIGH',
184
+ 'Accuracy',
185
+ 'Retrieval Grounding & Hallucination Defense',
186
+ 'Ensure prompt context is strictly bounded by retrieved semantic chunks.',
187
+ );
188
+ addConsideration(
189
+ 'MEDIUM',
190
+ 'Performance',
191
+ 'Vector Indexing & Embedding Latency',
192
+ 'Utilize HNSW or IVFFlat vector indexing to accelerate similarity search.',
193
+ );
194
+ break;
195
+ case 'event-driven-data-pipelines':
196
+ addConsideration(
197
+ 'HIGH',
198
+ 'Reliability',
199
+ 'Stream Backpressure & Partition Offset Management',
200
+ 'Control consumer ingest rates and commit offsets only after processing.',
201
+ );
202
+ break;
203
+ case 'notification-delivery-and-dispatch':
204
+ addConsideration(
205
+ 'HIGH',
206
+ 'Reliability',
207
+ 'Provider Rate-Limiting & Failover',
208
+ 'Buffer notifications and respect downstream SMS/email provider throttle limits.',
209
+ );
210
+ break;
211
+ case 'search-indexing-and-ranking':
212
+ addConsideration(
213
+ 'HIGH',
214
+ 'Performance',
215
+ 'Inverted Index & Tokenization Efficiency',
216
+ 'Optimize inverted index updates and relevance scoring pipelines.',
217
+ );
218
+ break;
219
+ case 'multi-region-consistency-and-replication':
220
+ addConsideration(
221
+ 'CRITICAL',
222
+ 'Consistency',
223
+ 'Replication Lag & Conflict Resolution',
224
+ 'Define deterministic conflict resolution for cross-region state divergence.',
225
+ );
226
+ break;
227
+ case 'responsive-ui-and-accessibility':
228
+ addConsideration(
229
+ 'HIGH',
230
+ 'Usability',
231
+ 'Responsive Layout & Mobile Viewport Adaptation',
232
+ 'Ensure fluid layout without horizontal clipping and touch targets >= 44px.',
233
+ );
234
+ addConsideration(
235
+ 'HIGH',
236
+ 'Accessibility',
237
+ 'Keyboard Navigation & ARIA Semantics',
238
+ 'Ensure complete WCAG 2.1 compliance with accessible color contrast and screen reader labels.',
239
+ );
240
+ break;
241
+ }
242
+ }
243
+
244
+ const domainSet = new Set(conceptData.domains || []);
245
+ if (domainSet.has('backend') && domainSet.has('database')) {
246
+ addConsideration(
247
+ 'HIGH',
248
+ 'Architecture',
249
+ 'Database Connection & Transaction Boundary',
250
+ 'Ensure HTTP handler lifecycle correctly scopes database transactions and releases pool connections.',
251
+ );
252
+ }
253
+ if (domainSet.has('backend') && domainSet.has('security')) {
254
+ addConsideration(
255
+ 'HIGH',
256
+ 'Security',
257
+ 'Rate Limiting & Abuse Defense',
258
+ 'Apply IP/token bucket throttling to defend against automated abuse.',
259
+ );
260
+ }
261
+
262
+ const critical = considerations.filter(c => c.severity === 'CRITICAL');
263
+ const high = considerations.filter(c => c.severity === 'HIGH');
264
+ const medium = considerations.filter(c => c.severity === 'MEDIUM');
265
+ const low = considerations.filter(c => c.severity === 'LOW');
266
+
267
+ return {
268
+ query: conceptData.query,
269
+ total_considerations: considerations.length,
270
+ critical,
271
+ high,
272
+ medium,
273
+ low,
274
+ all_considerations: considerations,
275
+ risks,
276
+ failure_modes: Array.from(failureModes),
277
+ quality_attributes: Array.from(qualityAttributes),
278
+ constraints,
279
+ };
280
+ }
281
+
282
+ module.exports = {
283
+ generateConsiderations,
284
+ };
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { extractConcepts } = require('./concept_extractor');
5
+ const { generateConsiderations } = require('./consideration_engine');
6
+
7
+ function evaluateCoverage(conceptData, discoveredSkills, allSkillsList) {
8
+ const activeSkillNames = new Set(
9
+ (discoveredSkills.mandatory || [])
10
+ .concat(discoveredSkills.recommended || [])
11
+ .map(s => s.skill || s),
12
+ );
13
+ const optionalSkillNames = new Set((discoveredSkills.optional || []).map(s => s.skill || s));
14
+
15
+ const coverageMatrix = [];
16
+ const full = [];
17
+ const partial = [];
18
+ const uncovered = [];
19
+ const candidateAdditions = new Set();
20
+ const trueGaps = [];
21
+
22
+ for (const c of conceptData.all_concepts || []) {
23
+ const commonSkills = c.common_skills || [];
24
+ let matchedSkill = null;
25
+ let coverage = 'NONE';
26
+ let confidence = 0.0;
27
+
28
+ for (const cs of commonSkills) {
29
+ if (activeSkillNames.has(cs)) {
30
+ matchedSkill = cs;
31
+ coverage = 'FULL';
32
+ confidence = 0.95;
33
+ break;
34
+ }
35
+ }
36
+
37
+ if (coverage !== 'FULL') {
38
+ for (const cs of commonSkills) {
39
+ if (optionalSkillNames.has(cs)) {
40
+ matchedSkill = cs;
41
+ coverage = 'PARTIAL';
42
+ confidence = 0.7;
43
+ break;
44
+ }
45
+ }
46
+ }
47
+
48
+ if (coverage === 'NONE') {
49
+ for (const skill of (discoveredSkills.mandatory || []).concat(
50
+ discoveredSkills.recommended || [],
51
+ )) {
52
+ const desc = (skill.description || '').toLowerCase();
53
+ if (desc.includes(c.id.replace(/-/g, ' ')) || desc.includes(c.name.toLowerCase())) {
54
+ matchedSkill = skill.skill;
55
+ coverage = 'PARTIAL';
56
+ confidence = 0.6;
57
+ break;
58
+ }
59
+ }
60
+ }
61
+
62
+ const row = {
63
+ concept_id: c.id,
64
+ concept_name: c.name,
65
+ domain: c.domain,
66
+ required_capability: c.aliases ? c.aliases[0] : c.name,
67
+ matched_skill: matchedSkill,
68
+ coverage,
69
+ confidence,
70
+ };
71
+
72
+ coverageMatrix.push(row);
73
+
74
+ if (coverage === 'FULL') {
75
+ full.push(row);
76
+ } else if (coverage === 'PARTIAL') {
77
+ partial.push(row);
78
+ commonSkills.forEach(cs => candidateAdditions.add(cs));
79
+ } else {
80
+ uncovered.push(row);
81
+ if (commonSkills.length > 0) {
82
+ commonSkills.forEach(cs => candidateAdditions.add(cs));
83
+ } else {
84
+ trueGaps.push(c.id);
85
+ }
86
+ }
87
+ }
88
+
89
+ return {
90
+ total_concepts: (conceptData.all_concepts || []).length,
91
+ coverage_matrix: coverageMatrix,
92
+ full,
93
+ partial,
94
+ uncovered,
95
+ candidate_additions: Array.from(candidateAdditions).filter(s => !activeSkillNames.has(s)),
96
+ true_gaps: trueGaps,
97
+ };
98
+ }
99
+
100
+ module.exports = {
101
+ evaluateCoverage,
102
+ };