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
package/.agent/rules/GEMINI.md
CHANGED
|
@@ -221,7 +221,7 @@ The Human Gate is never skipped. No code is written to a file without explicit u
|
|
|
221
221
|
| Mobile/Cross-platform | logic + security + mobile-reviewer + type-safety + complexity-reviewer |
|
|
222
222
|
| CI/CD / DevOps | pipeline-reviewer + security + dependency + resilience + complexity-reviewer |
|
|
223
223
|
| Any domain | + performance (if optimization) |
|
|
224
|
-
| Before merge | /tribunal-full (all
|
|
224
|
+
| Before merge | /tribunal-full (all 31 reviewers) |
|
|
225
225
|
|
|
226
226
|
---
|
|
227
227
|
|
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* adaptive_execution.js — Tribunal Kit Phase 4: Adaptive Execution Engine
|
|
5
|
+
* =======================================================================
|
|
6
|
+
* Manages mutable capability graphs, dynamic skill activation on runtime signals,
|
|
7
|
+
* change impact analysis, institutional memory, and final multi-gate engineering review.
|
|
8
|
+
*
|
|
9
|
+
* Invariants:
|
|
10
|
+
* - EXECUTION SHOULD BE ADAPTIVE, NOT PREDETERMINED.
|
|
11
|
+
* - NEW EVIDENCE MAY CHANGE THE PLAN.
|
|
12
|
+
* - NO UNDERENGINEERING. NO OVERENGINEERING.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// 1. DYNAMIC CAPABILITY GRAPH (SECTION 8)
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Mutable execution graph supporting dynamic adaptation.
|
|
21
|
+
* Every graph mutation requires an explicit engineering reason.
|
|
22
|
+
*/
|
|
23
|
+
class DynamicCapabilityGraph {
|
|
24
|
+
constructor(initialNodes = []) {
|
|
25
|
+
this.nodes = Array.isArray(initialNodes) ? [...initialNodes] : [];
|
|
26
|
+
this.mutationHistory = [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getNodes() {
|
|
30
|
+
return [...this.nodes];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
addNode(node, positionIndex = -1, reason = 'Additional capability required.') {
|
|
34
|
+
if (!node) return this;
|
|
35
|
+
if (this.nodes.includes(node)) return this;
|
|
36
|
+
|
|
37
|
+
if (positionIndex >= 0 && positionIndex < this.nodes.length) {
|
|
38
|
+
this.nodes.splice(positionIndex, 0, node);
|
|
39
|
+
} else {
|
|
40
|
+
this.nodes.push(node);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.mutationHistory.push({
|
|
44
|
+
action: 'ADD',
|
|
45
|
+
node,
|
|
46
|
+
position: positionIndex >= 0 ? positionIndex : this.nodes.length - 1,
|
|
47
|
+
reason,
|
|
48
|
+
timestamp: new Date().toISOString(),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
removeNode(node, reason = 'Capability deemed redundant or invalid.') {
|
|
55
|
+
const idx = this.nodes.indexOf(node);
|
|
56
|
+
if (idx !== -1) {
|
|
57
|
+
this.nodes.splice(idx, 1);
|
|
58
|
+
this.mutationHistory.push({
|
|
59
|
+
action: 'REMOVE',
|
|
60
|
+
node,
|
|
61
|
+
previous_position: idx,
|
|
62
|
+
reason,
|
|
63
|
+
timestamp: new Date().toISOString(),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
reorderNodes(fromIndex, toIndex, reason = 'Dependency priority inversion required.') {
|
|
70
|
+
if (
|
|
71
|
+
fromIndex >= 0 &&
|
|
72
|
+
fromIndex < this.nodes.length &&
|
|
73
|
+
toIndex >= 0 &&
|
|
74
|
+
toIndex < this.nodes.length
|
|
75
|
+
) {
|
|
76
|
+
const [item] = this.nodes.splice(fromIndex, 1);
|
|
77
|
+
this.nodes.splice(toIndex, 0, item);
|
|
78
|
+
this.mutationHistory.push({
|
|
79
|
+
action: 'REORDER',
|
|
80
|
+
node: item,
|
|
81
|
+
from: fromIndex,
|
|
82
|
+
to: toIndex,
|
|
83
|
+
reason,
|
|
84
|
+
timestamp: new Date().toISOString(),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
retryNode(
|
|
91
|
+
node,
|
|
92
|
+
reason = 'Verification failure encountered; re-running node with hardened parameters.',
|
|
93
|
+
) {
|
|
94
|
+
this.mutationHistory.push({
|
|
95
|
+
action: 'RETRY',
|
|
96
|
+
node,
|
|
97
|
+
reason,
|
|
98
|
+
timestamp: new Date().toISOString(),
|
|
99
|
+
});
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
skipNode(node, reason = 'Node preconditions already satisfied or non-material.') {
|
|
104
|
+
const idx = this.nodes.indexOf(node);
|
|
105
|
+
if (idx !== -1) {
|
|
106
|
+
this.nodes.splice(idx, 1);
|
|
107
|
+
this.mutationHistory.push({
|
|
108
|
+
action: 'SKIP',
|
|
109
|
+
node,
|
|
110
|
+
reason,
|
|
111
|
+
timestamp: new Date().toISOString(),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
branch(
|
|
118
|
+
condition,
|
|
119
|
+
trueNodes = [],
|
|
120
|
+
falseNodes = [],
|
|
121
|
+
reason = 'Conditional execution path based on runtime signal.',
|
|
122
|
+
) {
|
|
123
|
+
const chosen = condition ? trueNodes : falseNodes;
|
|
124
|
+
for (const node of chosen) {
|
|
125
|
+
if (!this.nodes.includes(node)) {
|
|
126
|
+
this.nodes.push(node);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
this.mutationHistory.push({
|
|
130
|
+
action: 'BRANCH',
|
|
131
|
+
condition_met: !!condition,
|
|
132
|
+
nodes_added: chosen,
|
|
133
|
+
reason,
|
|
134
|
+
timestamp: new Date().toISOString(),
|
|
135
|
+
});
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
merge(otherGraph, reason = 'Merging complementary capability subgraphs.') {
|
|
140
|
+
if (!otherGraph || !Array.isArray(otherGraph.nodes)) return this;
|
|
141
|
+
for (const node of otherGraph.nodes) {
|
|
142
|
+
if (!this.nodes.includes(node)) {
|
|
143
|
+
this.nodes.push(node);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
this.mutationHistory.push({
|
|
147
|
+
action: 'MERGE',
|
|
148
|
+
merged_nodes: otherGraph.nodes,
|
|
149
|
+
reason,
|
|
150
|
+
timestamp: new Date().toISOString(),
|
|
151
|
+
});
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ============================================================================
|
|
157
|
+
// 2. ADAPTIVE SKILL ROUTING (SECTION 7 & BENCHMARK 7)
|
|
158
|
+
// ============================================================================
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Dynamically re-evaluates and mutates the capability pipeline upon receiving new runtime signals.
|
|
162
|
+
*
|
|
163
|
+
* Example:
|
|
164
|
+
* File processing API -> User-controlled URL discovered -> SSRF risk ->
|
|
165
|
+
* Dynamically insert `agentshield-security` / `api-security-auditor` before final verification.
|
|
166
|
+
*
|
|
167
|
+
* @param {Array<string>} currentPipeline
|
|
168
|
+
* @param {Object} signal
|
|
169
|
+
* @returns {Object} Adaptive routing result with mutated graph and justification
|
|
170
|
+
*/
|
|
171
|
+
function adaptPipelineOnSignal(currentPipeline, signal = {}) {
|
|
172
|
+
const graph = new DynamicCapabilityGraph(currentPipeline);
|
|
173
|
+
const signalText = (signal.description || signal.error || signal.diff || '').toLowerCase();
|
|
174
|
+
const additions = [];
|
|
175
|
+
const removals = [];
|
|
176
|
+
|
|
177
|
+
// Signal 1: SSRF / User-controlled URL discovered in file upload / processing API
|
|
178
|
+
if (
|
|
179
|
+
/(?:user[-_ ]controlled url|fetch\s*\(|axios\s*\(|http request to url|ssrf|remote file download)/i.test(
|
|
180
|
+
signalText,
|
|
181
|
+
)
|
|
182
|
+
) {
|
|
183
|
+
if (!graph.getNodes().includes('agentshield-security')) {
|
|
184
|
+
graph.addNode(
|
|
185
|
+
'agentshield-security',
|
|
186
|
+
0,
|
|
187
|
+
'SIGNAL: User-controlled URL detected in request path. Inserted SSRF defense and IP address blacklist validation.',
|
|
188
|
+
);
|
|
189
|
+
additions.push('agentshield-security');
|
|
190
|
+
}
|
|
191
|
+
if (!graph.getNodes().includes('api-security-auditor')) {
|
|
192
|
+
graph.addNode(
|
|
193
|
+
'api-security-auditor',
|
|
194
|
+
1,
|
|
195
|
+
'SIGNAL: External network boundary introduced. Inserted API security audit capability.',
|
|
196
|
+
);
|
|
197
|
+
additions.push('api-security-auditor');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Signal 2: Concurrency Race Condition discovered during testing
|
|
202
|
+
if (
|
|
203
|
+
/(?:race condition|concurrent duplicate|parallel mutation|lost update|deadlock)/i.test(
|
|
204
|
+
signalText,
|
|
205
|
+
)
|
|
206
|
+
) {
|
|
207
|
+
if (!graph.getNodes().includes('error-resilience')) {
|
|
208
|
+
graph.addNode(
|
|
209
|
+
'error-resilience',
|
|
210
|
+
-1,
|
|
211
|
+
'SIGNAL: Concurrent race condition or deadlock detected under load. Inserted concurrency control capability.',
|
|
212
|
+
);
|
|
213
|
+
additions.push('error-resilience');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Signal 3: Redis / External cache proved unnecessary via benchmark evidence
|
|
218
|
+
if (
|
|
219
|
+
/(?:database handles throughput|latency < \d+ms without cache|cache unnecessary)/i.test(
|
|
220
|
+
signalText,
|
|
221
|
+
)
|
|
222
|
+
) {
|
|
223
|
+
if (graph.getNodes().includes('backend-redis')) {
|
|
224
|
+
graph.removeNode(
|
|
225
|
+
'backend-redis',
|
|
226
|
+
'SIGNAL: Benchmark evidence proved baseline DB handles required throughput without cache complexity.',
|
|
227
|
+
);
|
|
228
|
+
removals.push('backend-redis');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
original_pipeline: currentPipeline,
|
|
234
|
+
adapted_pipeline: graph.getNodes(),
|
|
235
|
+
mutations: graph.mutationHistory,
|
|
236
|
+
additions,
|
|
237
|
+
removals,
|
|
238
|
+
has_changed: additions.length > 0 || removals.length > 0,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ============================================================================
|
|
243
|
+
// 3. CHANGE IMPACT ANALYSIS (SECTION 15)
|
|
244
|
+
// ============================================================================
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Maps a proposed architectural change to its blast radius:
|
|
248
|
+
* Affected Components -> Affected Contracts -> Affected Tests -> Operations -> Regression Risk.
|
|
249
|
+
*
|
|
250
|
+
* @param {string} proposedChange
|
|
251
|
+
* @param {Object} [repoContext]
|
|
252
|
+
* @returns {Object} Comprehensive change impact dossier
|
|
253
|
+
*/
|
|
254
|
+
function analyzeChangeImpact(proposedChange, repoContext = {}) {
|
|
255
|
+
const text = (proposedChange || '').toLowerCase();
|
|
256
|
+
|
|
257
|
+
const affectedComponents = [];
|
|
258
|
+
const affectedContracts = [];
|
|
259
|
+
const affectedTests = [];
|
|
260
|
+
const affectedOperations = [];
|
|
261
|
+
let regressionRisk = 'LOW';
|
|
262
|
+
|
|
263
|
+
if (/(?:async job|queue|worker|background job)/i.test(text)) {
|
|
264
|
+
affectedComponents.push('API Request Handler', 'Background Job Consumer', 'Queue Broker');
|
|
265
|
+
affectedContracts.push(
|
|
266
|
+
'Synchronous HTTP 200 -> HTTP 202 Accepted with Polling/Webhook Contract',
|
|
267
|
+
);
|
|
268
|
+
affectedTests.push(
|
|
269
|
+
'End-to-End Async Job Completion Test',
|
|
270
|
+
'Dead-Letter Queue Poison Pill Test',
|
|
271
|
+
);
|
|
272
|
+
affectedOperations.push('Worker Scaling', 'Queue Lag Monitoring', 'Retry Storm Backpressure');
|
|
273
|
+
regressionRisk = 'HIGH';
|
|
274
|
+
} else if (/(?:schema|migration|column|table|alter)/i.test(text)) {
|
|
275
|
+
affectedComponents.push('Database Models', 'ORM Client', 'Data Access Layer');
|
|
276
|
+
affectedContracts.push('Database Schema Model Contract');
|
|
277
|
+
affectedTests.push('Migration Rollback Test', 'Model Validation Tests');
|
|
278
|
+
affectedOperations.push('Zero-Downtime Deployment Window', 'Read/Write Replica Lag');
|
|
279
|
+
regressionRisk = 'HIGH';
|
|
280
|
+
} else if (/(?:caching|redis|cache-aside)/i.test(text)) {
|
|
281
|
+
affectedComponents.push('Service Layer', 'Cache Store');
|
|
282
|
+
affectedContracts.push('Cache Invalidation Event Interface');
|
|
283
|
+
affectedTests.push('Cache Miss/Hit Test', 'Stale Data Invalidation Test');
|
|
284
|
+
affectedOperations.push('Cache Eviction Policy Monitoring', 'Memory Sizing');
|
|
285
|
+
regressionRisk = 'MEDIUM';
|
|
286
|
+
} else {
|
|
287
|
+
affectedComponents.push('Application Component Logic');
|
|
288
|
+
affectedContracts.push('Internal Function Signatures');
|
|
289
|
+
affectedTests.push('Unit Tests');
|
|
290
|
+
affectedOperations.push('Standard Process Restart');
|
|
291
|
+
regressionRisk = 'LOW';
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
proposed_change: proposedChange,
|
|
296
|
+
regression_risk: regressionRisk,
|
|
297
|
+
affected_components: affectedComponents,
|
|
298
|
+
affected_contracts: affectedContracts,
|
|
299
|
+
affected_tests: affectedTests,
|
|
300
|
+
affected_operations: affectedOperations,
|
|
301
|
+
blast_radius: affectedComponents.length > 2 ? 'WIDE' : 'LOCAL',
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// ============================================================================
|
|
306
|
+
// 4. INSTITUTIONAL LEARNING & SKILL QUALITY FEEDBACK (SECTION 20 & 21)
|
|
307
|
+
// ============================================================================
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* In-memory registry of validated engineering lessons and skill contribution telemetry.
|
|
311
|
+
*/
|
|
312
|
+
const INSTITUTIONAL_MEMORY = [
|
|
313
|
+
{
|
|
314
|
+
pattern: 'Payment Mutation & Financial Charging',
|
|
315
|
+
observation:
|
|
316
|
+
'Network timeouts cause client retries that produce duplicate charges unless bounded by unique idempotency keys.',
|
|
317
|
+
lesson:
|
|
318
|
+
'Financial mutations strictly require idempotency key unique constraints and atomic transaction boundaries.',
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
pattern: 'File Upload & Processing Services',
|
|
322
|
+
observation:
|
|
323
|
+
'Accepting arbitrary user URLs or files without magic-number checks opens SSRF and memory exhaustion vectors.',
|
|
324
|
+
lesson:
|
|
325
|
+
'File processors must strictly validate magic bytes, enforce hard streaming quotas, and isolate remote URL fetching.',
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
pattern: 'Distributed Job Processing',
|
|
329
|
+
observation:
|
|
330
|
+
'Uncaught poison pills cause infinite worker retry loops that starve legitimate queue tasks.',
|
|
331
|
+
lesson:
|
|
332
|
+
'Queue workers require exponential backoff with randomized jitter and automated dead-letter queue routing.',
|
|
333
|
+
},
|
|
334
|
+
];
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Records a validated engineering lesson derived from execution & verification failure.
|
|
338
|
+
*
|
|
339
|
+
* @param {string} pattern
|
|
340
|
+
* @param {string} observation
|
|
341
|
+
* @param {string} lesson
|
|
342
|
+
* @returns {Object} Recorded lesson
|
|
343
|
+
*/
|
|
344
|
+
function recordEngineeringLesson(pattern, observation, lesson) {
|
|
345
|
+
const item = {
|
|
346
|
+
pattern,
|
|
347
|
+
observation,
|
|
348
|
+
lesson,
|
|
349
|
+
recorded_at: new Date().toISOString(),
|
|
350
|
+
};
|
|
351
|
+
INSTITUTIONAL_MEMORY.push(item);
|
|
352
|
+
try {
|
|
353
|
+
const {
|
|
354
|
+
getEngineeringMemoryStore,
|
|
355
|
+
MEMORY_TYPES,
|
|
356
|
+
PROVENANCE_TYPES,
|
|
357
|
+
TRUST_STATES,
|
|
358
|
+
} = require('./engineering_memory');
|
|
359
|
+
getEngineeringMemoryStore().add({
|
|
360
|
+
type: MEMORY_TYPES.PATTERN,
|
|
361
|
+
title: pattern,
|
|
362
|
+
content: lesson,
|
|
363
|
+
concepts: pattern
|
|
364
|
+
.toLowerCase()
|
|
365
|
+
.split(/\W+/)
|
|
366
|
+
.filter(w => w.length > 3),
|
|
367
|
+
evidence: [{ type: PROVENANCE_TYPES.VERIFIED_IMPLEMENTATION, source: observation }],
|
|
368
|
+
status: TRUST_STATES.VERIFIED,
|
|
369
|
+
});
|
|
370
|
+
} catch (e) {}
|
|
371
|
+
return item;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Returns relevant institutional lessons matching task intent.
|
|
376
|
+
*
|
|
377
|
+
* @param {string} task
|
|
378
|
+
* @returns {Array<Object>} Relevant institutional lessons
|
|
379
|
+
*/
|
|
380
|
+
function recallRelevantLessons(task) {
|
|
381
|
+
const t = (task || '').toLowerCase();
|
|
382
|
+
return INSTITUTIONAL_MEMORY.filter(mem => {
|
|
383
|
+
const pat = mem.pattern.toLowerCase();
|
|
384
|
+
const words = pat.split(/\s+/).filter(w => w.length > 3);
|
|
385
|
+
return words.some(w => t.includes(w));
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Evaluates skill effectiveness telemetry to prevent redundant or false activations (Section 21).
|
|
391
|
+
*
|
|
392
|
+
* @param {string} skillName
|
|
393
|
+
* @param {Object} outcomeEvidence
|
|
394
|
+
* @returns {Object} Skill contribution report
|
|
395
|
+
*/
|
|
396
|
+
function evaluateSkillEffectiveness(skillName, outcomeEvidence = {}) {
|
|
397
|
+
const diff = (outcomeEvidence.code_diff || '').toLowerCase();
|
|
398
|
+
const tests = outcomeEvidence.tests_executed || [];
|
|
399
|
+
const tokens = skillName.toLowerCase().split('-');
|
|
400
|
+
|
|
401
|
+
const contributedInCode = tokens.some(tok => tok.length > 3 && diff.includes(tok));
|
|
402
|
+
const contributedInTests = tests.some(t =>
|
|
403
|
+
tokens.some(tok => tok.length > 3 && (t.name || '').toLowerCase().includes(tok)),
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
const contributed = contributedInCode || contributedInTests;
|
|
407
|
+
|
|
408
|
+
try {
|
|
409
|
+
const { getSkillTelemetryRegistry } = require('./capability_evolution');
|
|
410
|
+
getSkillTelemetryRegistry().recordSkillExecution(skillName, {
|
|
411
|
+
is_material: contributed,
|
|
412
|
+
task: outcomeEvidence.task || 'evaluated_task',
|
|
413
|
+
});
|
|
414
|
+
} catch (e) {}
|
|
415
|
+
|
|
416
|
+
return {
|
|
417
|
+
skill: skillName,
|
|
418
|
+
contributed,
|
|
419
|
+
contribution_type: contributedInTests
|
|
420
|
+
? 'VERIFICATION'
|
|
421
|
+
: contributedInCode
|
|
422
|
+
? 'IMPLEMENTATION'
|
|
423
|
+
: 'NONE',
|
|
424
|
+
recommendation: contributed ? 'RETAIN' : 'REVIEW_FOR_REDUNDANCY',
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// ============================================================================
|
|
429
|
+
// 5. FINAL ENGINEERING REVIEW (SECTION 24)
|
|
430
|
+
// ============================================================================
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Multi-gate engineering review executed before completion:
|
|
434
|
+
* Requirements -> Considerations -> Security -> Reliability -> Performance -> Maintainability -> Change Impact -> Verification -> Outcome.
|
|
435
|
+
*
|
|
436
|
+
* @param {Object} outcomeContract
|
|
437
|
+
* @param {Object} outcomeReport
|
|
438
|
+
* @param {Object} [options]
|
|
439
|
+
* @returns {Object} Comprehensive engineering review dossier
|
|
440
|
+
*/
|
|
441
|
+
function runFinalEngineeringReview(outcomeContract, outcomeReport, options = {}) {
|
|
442
|
+
const contract = outcomeContract || {};
|
|
443
|
+
const report = outcomeReport || {};
|
|
444
|
+
|
|
445
|
+
const reviews = {
|
|
446
|
+
requirements_review: {
|
|
447
|
+
status: report.is_task_complete ? 'PASS' : 'FAIL',
|
|
448
|
+
detail: report.is_task_complete
|
|
449
|
+
? 'Requested requirements satisfied.'
|
|
450
|
+
: 'Primary functional task incomplete.',
|
|
451
|
+
},
|
|
452
|
+
consideration_review: {
|
|
453
|
+
status:
|
|
454
|
+
(report.satisfied || []).length >= (contract.material_considerations || []).length
|
|
455
|
+
? 'PASS'
|
|
456
|
+
: 'WARN',
|
|
457
|
+
detail: `${(report.satisfied || []).length} of ${(contract.material_considerations || []).length} material considerations satisfied.`,
|
|
458
|
+
},
|
|
459
|
+
security_review: {
|
|
460
|
+
status: (report.new_risks || []).length === 0 ? 'PASS' : 'FAIL',
|
|
461
|
+
detail:
|
|
462
|
+
(report.new_risks || []).length === 0
|
|
463
|
+
? 'Zero security vulnerabilities detected.'
|
|
464
|
+
: `Security vulnerabilities detected: ${(report.new_risks || []).map(r => r.risk).join(', ')}`,
|
|
465
|
+
},
|
|
466
|
+
reliability_review: {
|
|
467
|
+
status: (report.partially_satisfied || []).length === 0 ? 'PASS' : 'WARN',
|
|
468
|
+
detail:
|
|
469
|
+
(report.partially_satisfied || []).length === 0
|
|
470
|
+
? 'Fault tolerance & resilience invariants verified.'
|
|
471
|
+
: 'Unverified resilience or recovery properties.',
|
|
472
|
+
},
|
|
473
|
+
maintainability_review: {
|
|
474
|
+
status: (report.unnecessary_complexity || []).length === 0 ? 'PASS' : 'WARN',
|
|
475
|
+
detail:
|
|
476
|
+
(report.unnecessary_complexity || []).length === 0
|
|
477
|
+
? 'Clean code; zero unnecessary architectural complexity.'
|
|
478
|
+
: 'Overengineering detected; consider simplifying.',
|
|
479
|
+
},
|
|
480
|
+
verification_review: {
|
|
481
|
+
status: report.is_outcome_complete ? 'PASS' : 'FAIL',
|
|
482
|
+
detail: report.is_outcome_complete
|
|
483
|
+
? 'All automated assertions passed with concrete execution evidence.'
|
|
484
|
+
: 'Verification incomplete or failing.',
|
|
485
|
+
},
|
|
486
|
+
outcome_review: {
|
|
487
|
+
status: report.is_outcome_complete ? 'APPROVED' : 'ACTION_REQUIRED',
|
|
488
|
+
outcome_score: report.outcome_score || 0,
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
const isApproved = Object.values(reviews).every(
|
|
493
|
+
r => r.status === 'PASS' || r.status === 'APPROVED',
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
return {
|
|
497
|
+
is_approved: isApproved,
|
|
498
|
+
reviews,
|
|
499
|
+
verdict: isApproved ? 'PRODUCTION_READY' : 'ENGINEERING_GAPS_EXIST',
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
module.exports = {
|
|
504
|
+
DynamicCapabilityGraph,
|
|
505
|
+
adaptPipelineOnSignal,
|
|
506
|
+
analyzeChangeImpact,
|
|
507
|
+
recordEngineeringLesson,
|
|
508
|
+
recallRelevantLessons,
|
|
509
|
+
evaluateSkillEffectiveness,
|
|
510
|
+
runFinalEngineeringReview,
|
|
511
|
+
};
|