thumbgate 1.16.3 → 1.16.4
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/claude/.mcp.json +2 -2
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/config/github-about.json +2 -2
- package/package.json +3 -2
- package/public/dashboard.html +298 -3
- package/public/index.html +20 -17
- package/scripts/background-agent-governance.js +229 -0
- package/scripts/dashboard.js +209 -1
- package/scripts/workflow-sentinel.js +121 -3
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Background Agent Governance — the missing layer for Ramp/Ona-style agent stacks.
|
|
6
|
+
*
|
|
7
|
+
* Background agents run unattended (writing 57% of PRs at Ramp). They need:
|
|
8
|
+
* 1. Run tracking — what did each agent run do?
|
|
9
|
+
* 2. Governance gate — should this PR/action be allowed based on past failures?
|
|
10
|
+
* 3. Post-run audit — auto-capture feedback from CI results
|
|
11
|
+
* 4. Governance report — "X runs, Y blocked, Z lessons learned"
|
|
12
|
+
*
|
|
13
|
+
* Integrates with: MCP server, gates engine, org dashboard, lesson inference.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const { resolveFeedbackDir } = require('./feedback-paths');
|
|
19
|
+
const { ensureParentDir, readJsonl } = require('./fs-utils');
|
|
20
|
+
|
|
21
|
+
const RUNS_FILE = 'agent-runs.jsonl';
|
|
22
|
+
|
|
23
|
+
function getFeedbackDir(feedbackDir) { return resolveFeedbackDir({ feedbackDir }); }
|
|
24
|
+
function getRunsPath(feedbackDir) { return path.join(getFeedbackDir(feedbackDir), RUNS_FILE); }
|
|
25
|
+
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// 1. Run Tracking
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Record a background agent run.
|
|
32
|
+
* Called when a background agent starts or completes a task.
|
|
33
|
+
*/
|
|
34
|
+
function recordAgentRun({ agentId, runType, source, branch, prNumber, status, gatesChecked, gatesBlocked, filesChanged, ciPassed, duration, metadata } = {}, feedbackDir) {
|
|
35
|
+
const runsPath = getRunsPath(feedbackDir);
|
|
36
|
+
ensureParentDir(runsPath);
|
|
37
|
+
const run = {
|
|
38
|
+
id: `run_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
39
|
+
timestamp: new Date().toISOString(),
|
|
40
|
+
agentId: agentId || 'unknown',
|
|
41
|
+
runType: runType || 'unknown', // 'pr', 'fix', 'refactor', 'ci-repair', 'migration'
|
|
42
|
+
source: source || 'background', // 'background', 'triggered', 'scheduled', 'manual'
|
|
43
|
+
branch: branch || null,
|
|
44
|
+
prNumber: prNumber || null,
|
|
45
|
+
status: status || 'started', // 'started', 'completed', 'blocked', 'failed'
|
|
46
|
+
gatesChecked: gatesChecked || 0,
|
|
47
|
+
gatesBlocked: gatesBlocked || 0,
|
|
48
|
+
filesChanged: filesChanged || 0,
|
|
49
|
+
ciPassed: ciPassed === undefined ? null : ciPassed,
|
|
50
|
+
durationMs: duration || null,
|
|
51
|
+
metadata: metadata || {},
|
|
52
|
+
};
|
|
53
|
+
fs.appendFileSync(runsPath, JSON.stringify(run) + '\n');
|
|
54
|
+
return run;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// 2. Governance Gate — pre-run check
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Check if a background agent run should proceed based on governance rules.
|
|
63
|
+
* Returns { allowed, blockers, warnings, governanceScore }.
|
|
64
|
+
*/
|
|
65
|
+
function checkRunGovernance({ agentId, runType, branch, filesChanged } = {}, feedbackDir) {
|
|
66
|
+
const runs = readJsonl(getRunsPath(feedbackDir));
|
|
67
|
+
const blockers = [];
|
|
68
|
+
const warnings = [];
|
|
69
|
+
|
|
70
|
+
// Rule 1: Block if this agent has > 50% failure rate in last 10 runs
|
|
71
|
+
const agentRuns = runs.filter((r) => r.agentId === agentId).slice(-10);
|
|
72
|
+
const failedRuns = agentRuns.filter((r) => r.status === 'failed' || r.status === 'blocked');
|
|
73
|
+
if (agentRuns.length >= 5 && failedRuns.length / agentRuns.length > 0.5) {
|
|
74
|
+
blockers.push({ rule: 'high_failure_rate', message: `Agent ${agentId} has ${failedRuns.length}/${agentRuns.length} failed runs (>50%)`, severity: 'critical' });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Rule 2: Warn if agent has been blocked by gates in recent runs
|
|
78
|
+
const recentBlocked = agentRuns.filter((r) => r.gatesBlocked > 0);
|
|
79
|
+
if (recentBlocked.length >= 3) {
|
|
80
|
+
warnings.push({ rule: 'repeated_gate_blocks', message: `Agent ${agentId} has been gate-blocked in ${recentBlocked.length} recent runs`, severity: 'warning' });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Rule 3: Block if targeting protected branch without CI passing
|
|
84
|
+
if (branch && /^(main|master|develop)$/.test(branch)) {
|
|
85
|
+
warnings.push({ rule: 'protected_branch', message: `Run targets protected branch "${branch}" — CI must pass before merge`, severity: 'warning' });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Rule 4: Warn if too many files changed (large blast radius)
|
|
89
|
+
if (filesChanged > 20) {
|
|
90
|
+
warnings.push({ rule: 'large_blast_radius', message: `${filesChanged} files changed — consider splitting into smaller PRs`, severity: 'warning' });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const governanceScore = Math.max(0, 100 - blockers.length * 40 - warnings.length * 10);
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
allowed: blockers.length === 0,
|
|
97
|
+
blockers,
|
|
98
|
+
warnings,
|
|
99
|
+
governanceScore,
|
|
100
|
+
checkedAt: new Date().toISOString(),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// 3. Post-Run Audit — auto-capture feedback from CI
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Auto-capture feedback from a completed background agent run.
|
|
110
|
+
* Converts CI pass/fail into structured feedback for the learning loop.
|
|
111
|
+
*/
|
|
112
|
+
function auditCompletedRun({ runId, agentId, ciPassed, ciOutput, prNumber, branch, filesChanged } = {}, feedbackDir) {
|
|
113
|
+
const signal = ciPassed ? 'positive' : 'negative';
|
|
114
|
+
const context = ciPassed
|
|
115
|
+
? `Background agent run ${runId || 'unknown'} completed successfully. PR #${prNumber || '?'} on ${branch || '?'}. ${filesChanged || 0} files changed. CI passed.`
|
|
116
|
+
: `Background agent run ${runId || 'unknown'} failed. PR #${prNumber || '?'} on ${branch || '?'}. ${filesChanged || 0} files changed. CI failed.`;
|
|
117
|
+
|
|
118
|
+
const whatWentWrong = !ciPassed && ciOutput ? ciOutput.slice(0, 500) : null;
|
|
119
|
+
|
|
120
|
+
// Record the completed run
|
|
121
|
+
const run = recordAgentRun({
|
|
122
|
+
agentId,
|
|
123
|
+
runType: 'pr',
|
|
124
|
+
source: 'background',
|
|
125
|
+
branch,
|
|
126
|
+
prNumber,
|
|
127
|
+
status: ciPassed ? 'completed' : 'failed',
|
|
128
|
+
filesChanged,
|
|
129
|
+
ciPassed,
|
|
130
|
+
}, feedbackDir);
|
|
131
|
+
|
|
132
|
+
// Auto-capture feedback
|
|
133
|
+
let feedbackResult = null;
|
|
134
|
+
try {
|
|
135
|
+
const { captureFeedback } = require('./feedback-loop');
|
|
136
|
+
feedbackResult = captureFeedback({
|
|
137
|
+
signal: ciPassed ? 'up' : 'down',
|
|
138
|
+
context,
|
|
139
|
+
whatWentWrong,
|
|
140
|
+
whatWorked: ciPassed ? `Agent successfully completed PR #${prNumber || '?'}` : undefined,
|
|
141
|
+
tags: ['background-agent', ciPassed ? 'ci-pass' : 'ci-fail', `agent:${agentId || 'unknown'}`],
|
|
142
|
+
});
|
|
143
|
+
} catch { /* feedback capture is non-critical */ }
|
|
144
|
+
|
|
145
|
+
return { run, feedbackResult, signal, context };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
// 4. Governance Report
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Generate a governance report for background agent runs.
|
|
154
|
+
* Shows: total runs, blocked, pass rate, top failing agents, lessons learned.
|
|
155
|
+
*/
|
|
156
|
+
function generateGovernanceReport({ periodHours = 24, feedbackDir } = {}) {
|
|
157
|
+
const runs = readJsonl(getRunsPath(feedbackDir));
|
|
158
|
+
const cutoff = Date.now() - periodHours * 60 * 60 * 1000;
|
|
159
|
+
const recent = runs.filter((r) => new Date(r.timestamp).getTime() > cutoff);
|
|
160
|
+
|
|
161
|
+
const total = recent.length;
|
|
162
|
+
const completed = recent.filter((r) => r.status === 'completed').length;
|
|
163
|
+
const failed = recent.filter((r) => r.status === 'failed').length;
|
|
164
|
+
const blocked = recent.filter((r) => r.status === 'blocked').length;
|
|
165
|
+
const started = recent.filter((r) => r.status === 'started').length;
|
|
166
|
+
|
|
167
|
+
const passRate = (completed + failed) > 0 ? Math.round((completed / (completed + failed)) * 1000) / 10 : 0;
|
|
168
|
+
const totalGatesChecked = recent.reduce((s, r) => s + (r.gatesChecked || 0), 0);
|
|
169
|
+
const totalGatesBlocked = recent.reduce((s, r) => s + (r.gatesBlocked || 0), 0);
|
|
170
|
+
|
|
171
|
+
// Per-agent breakdown
|
|
172
|
+
const byAgent = {};
|
|
173
|
+
for (const r of recent) {
|
|
174
|
+
if (!byAgent[r.agentId]) byAgent[r.agentId] = { completed: 0, failed: 0, blocked: 0, total: 0 };
|
|
175
|
+
byAgent[r.agentId].total++;
|
|
176
|
+
if (r.status === 'completed') byAgent[r.agentId].completed++;
|
|
177
|
+
if (r.status === 'failed') byAgent[r.agentId].failed++;
|
|
178
|
+
if (r.status === 'blocked') byAgent[r.agentId].blocked++;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const agentSummaries = Object.entries(byAgent).map(([id, counts]) => ({
|
|
182
|
+
agentId: id,
|
|
183
|
+
...counts,
|
|
184
|
+
passRate: (counts.completed + counts.failed) > 0 ? Math.round((counts.completed / (counts.completed + counts.failed)) * 1000) / 10 : 0,
|
|
185
|
+
})).sort((a, b) => a.passRate - b.passRate);
|
|
186
|
+
|
|
187
|
+
// By run type
|
|
188
|
+
const byType = {};
|
|
189
|
+
for (const r of recent) {
|
|
190
|
+
if (!byType[r.runType]) byType[r.runType] = 0;
|
|
191
|
+
byType[r.runType]++;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
periodHours,
|
|
196
|
+
total, completed, failed, blocked, started,
|
|
197
|
+
passRate,
|
|
198
|
+
gatesChecked: totalGatesChecked,
|
|
199
|
+
gatesBlocked: totalGatesBlocked,
|
|
200
|
+
agents: agentSummaries,
|
|
201
|
+
topFailingAgent: agentSummaries.length > 0 && agentSummaries[0].passRate < 80 ? agentSummaries[0] : null,
|
|
202
|
+
byType,
|
|
203
|
+
generatedAt: new Date().toISOString(),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Format governance report as a human-readable string.
|
|
209
|
+
*/
|
|
210
|
+
function formatGovernanceReport(report) {
|
|
211
|
+
const lines = [
|
|
212
|
+
`Background Agent Governance Report (${report.periodHours}h)`,
|
|
213
|
+
`Total runs: ${report.total} | Completed: ${report.completed} | Failed: ${report.failed} | Blocked: ${report.blocked}`,
|
|
214
|
+
`Pass rate: ${report.passRate}%`,
|
|
215
|
+
`Gates checked: ${report.gatesChecked} | Gates blocked: ${report.gatesBlocked}`,
|
|
216
|
+
];
|
|
217
|
+
if (report.topFailingAgent) {
|
|
218
|
+
lines.push(`Top failing agent: ${report.topFailingAgent.agentId} (${report.topFailingAgent.passRate}% pass rate)`);
|
|
219
|
+
}
|
|
220
|
+
if (Object.keys(report.byType).length > 0) {
|
|
221
|
+
lines.push(`Run types: ${Object.entries(report.byType).map(([t, c]) => `${t}:${c}`).join(', ')}`);
|
|
222
|
+
}
|
|
223
|
+
return lines.join('\n');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
module.exports = {
|
|
227
|
+
recordAgentRun, checkRunGovernance, auditCompletedRun,
|
|
228
|
+
generateGovernanceReport, formatGovernanceReport, getRunsPath,
|
|
229
|
+
};
|
package/scripts/dashboard.js
CHANGED
|
@@ -39,9 +39,15 @@ const { buildPredictiveInsights } = loadOptionalModule('./predictive-insights',
|
|
|
39
39
|
const { routeProfile } = require('./profile-router');
|
|
40
40
|
const { getSettingsStatus } = require('./settings-hierarchy');
|
|
41
41
|
const { summarizeWorkflowRuns } = require('./workflow-runs');
|
|
42
|
+
const { generateGovernanceReport } = require('./background-agent-governance');
|
|
42
43
|
const { searchLessons } = require('./lesson-search');
|
|
43
44
|
const { getInterventionPolicySummary } = require('./intervention-policy');
|
|
44
|
-
const {
|
|
45
|
+
const {
|
|
46
|
+
DECISION_LOG_FILENAME,
|
|
47
|
+
computeDecisionMetrics,
|
|
48
|
+
readDecisionLog,
|
|
49
|
+
} = require('./decision-journal');
|
|
50
|
+
const { analyzeFeedback } = require('./feedback-loop');
|
|
45
51
|
|
|
46
52
|
const PROJECT_ROOT = path.join(__dirname, '..');
|
|
47
53
|
const DEFAULT_GATES_PATH = path.join(PROJECT_ROOT, 'config', 'gates', 'default.json');
|
|
@@ -1308,6 +1314,183 @@ function computeHarnessOverview(feedbackDir, entries) {
|
|
|
1308
1314
|
};
|
|
1309
1315
|
}
|
|
1310
1316
|
|
|
1317
|
+
function remediationPriority(type) {
|
|
1318
|
+
const priorities = {
|
|
1319
|
+
'trend-declining': 90,
|
|
1320
|
+
'trend-degrading': 85,
|
|
1321
|
+
'high-risk-domain': 80,
|
|
1322
|
+
'high-risk-tag': 78,
|
|
1323
|
+
'skill-improve': 72,
|
|
1324
|
+
'delegation-reduce': 68,
|
|
1325
|
+
'delegation-policy-review': 66,
|
|
1326
|
+
'diagnose-failure-category': 62,
|
|
1327
|
+
'pattern-reuse': 58,
|
|
1328
|
+
};
|
|
1329
|
+
return priorities[type] || 40;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
function summarizeActionableRemediations(items, limit = 6) {
|
|
1333
|
+
if (!Array.isArray(items)) return [];
|
|
1334
|
+
return items
|
|
1335
|
+
.slice()
|
|
1336
|
+
.sort((left, right) => {
|
|
1337
|
+
const delta = remediationPriority(right && right.type) - remediationPriority(left && left.type);
|
|
1338
|
+
if (delta !== 0) return delta;
|
|
1339
|
+
const rightCount = Number(right && right.evidence && (right.evidence.count || right.evidence.total || right.evidence.highRisk || 0));
|
|
1340
|
+
const leftCount = Number(left && left.evidence && (left.evidence.count || left.evidence.total || left.evidence.highRisk || 0));
|
|
1341
|
+
if (rightCount !== leftCount) return rightCount - leftCount;
|
|
1342
|
+
return String((left && left.target) || '').localeCompare(String((right && right.target) || ''));
|
|
1343
|
+
})
|
|
1344
|
+
.slice(0, limit)
|
|
1345
|
+
.map((item) => ({
|
|
1346
|
+
...item,
|
|
1347
|
+
priority: remediationPriority(item.type),
|
|
1348
|
+
title: `${String(item.action || 'review').replace(/-/g, ' ')} · ${item.target || 'system'}`,
|
|
1349
|
+
badge: String(item.type || 'remediation').replace(/-/g, ' '),
|
|
1350
|
+
}));
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
function summarizeMcpServerInventory(projectRoot = PROJECT_ROOT) {
|
|
1354
|
+
const configPath = path.join(projectRoot, '.mcp.json');
|
|
1355
|
+
const parsed = readJsonFile(configPath);
|
|
1356
|
+
const mcpServers = parsed && parsed.mcpServers && typeof parsed.mcpServers === 'object'
|
|
1357
|
+
? Object.keys(parsed.mcpServers).sort((left, right) => left.localeCompare(right))
|
|
1358
|
+
: [];
|
|
1359
|
+
return {
|
|
1360
|
+
configPath: fs.existsSync(configPath) ? configPath : null,
|
|
1361
|
+
configuredServers: mcpServers,
|
|
1362
|
+
configuredServerCount: mcpServers.length,
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function computeAgentSurfaceInventory(feedbackDir, options = {}) {
|
|
1367
|
+
const readiness = options.readiness || generateAgentReadinessReport({ projectRoot: PROJECT_ROOT });
|
|
1368
|
+
const auditEntries = Array.isArray(options.auditEntries)
|
|
1369
|
+
? options.auditEntries
|
|
1370
|
+
: readJSONL(path.join(feedbackDir, AUDIT_LOG_FILENAME));
|
|
1371
|
+
const decisionRecords = Array.isArray(options.decisionRecords)
|
|
1372
|
+
? options.decisionRecords
|
|
1373
|
+
: readDecisionLog(path.join(feedbackDir, DECISION_LOG_FILENAME));
|
|
1374
|
+
const toolBuckets = new Map();
|
|
1375
|
+
const sourceBuckets = new Map();
|
|
1376
|
+
const toolNames = new Set();
|
|
1377
|
+
|
|
1378
|
+
function getToolBucket(toolName) {
|
|
1379
|
+
const key = normalizeText(toolName) || 'unknown';
|
|
1380
|
+
toolNames.add(key);
|
|
1381
|
+
if (!toolBuckets.has(key)) {
|
|
1382
|
+
toolBuckets.set(key, {
|
|
1383
|
+
toolName: key,
|
|
1384
|
+
evaluations: 0,
|
|
1385
|
+
allow: 0,
|
|
1386
|
+
warn: 0,
|
|
1387
|
+
deny: 0,
|
|
1388
|
+
intercepted: 0,
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
return toolBuckets.get(key);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
for (const record of decisionRecords) {
|
|
1395
|
+
if (!record || record.recordType !== 'evaluation') continue;
|
|
1396
|
+
getToolBucket(record.toolName).evaluations += 1;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
for (const entry of auditEntries) {
|
|
1400
|
+
if (!entry) continue;
|
|
1401
|
+
const bucket = getToolBucket(entry.toolName);
|
|
1402
|
+
if (entry.decision === 'allow') bucket.allow += 1;
|
|
1403
|
+
if (entry.decision === 'warn') {
|
|
1404
|
+
bucket.warn += 1;
|
|
1405
|
+
bucket.intercepted += 1;
|
|
1406
|
+
}
|
|
1407
|
+
if (entry.decision === 'deny') {
|
|
1408
|
+
bucket.deny += 1;
|
|
1409
|
+
bucket.intercepted += 1;
|
|
1410
|
+
}
|
|
1411
|
+
const sourceKey = normalizeText(entry.source) || 'unknown';
|
|
1412
|
+
sourceBuckets.set(sourceKey, (sourceBuckets.get(sourceKey) || 0) + 1);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
const observedTools = [...toolBuckets.values()]
|
|
1416
|
+
.sort((left, right) => {
|
|
1417
|
+
if (right.intercepted !== left.intercepted) return right.intercepted - left.intercepted;
|
|
1418
|
+
if (right.evaluations !== left.evaluations) return right.evaluations - left.evaluations;
|
|
1419
|
+
return left.toolName.localeCompare(right.toolName);
|
|
1420
|
+
})
|
|
1421
|
+
.slice(0, 8);
|
|
1422
|
+
const policySources = [...sourceBuckets.entries()]
|
|
1423
|
+
.sort((left, right) => right[1] - left[1] || left[0].localeCompare(right[0]))
|
|
1424
|
+
.map(([source, count]) => ({ source, count }))
|
|
1425
|
+
.slice(0, 6);
|
|
1426
|
+
const mcpInventory = summarizeMcpServerInventory(PROJECT_ROOT);
|
|
1427
|
+
|
|
1428
|
+
return {
|
|
1429
|
+
profile: readiness.permissions.profile,
|
|
1430
|
+
tier: readiness.permissions.tier,
|
|
1431
|
+
configuredServerCount: mcpInventory.configuredServerCount,
|
|
1432
|
+
configuredServers: mcpInventory.configuredServers,
|
|
1433
|
+
observedToolCount: toolNames.size,
|
|
1434
|
+
observedTools,
|
|
1435
|
+
policySources,
|
|
1436
|
+
writeCapableTools: readiness.permissions.writeCapableTools.slice(0, 8),
|
|
1437
|
+
activeBootstrapFiles: readiness.bootstrap.requiredPresent,
|
|
1438
|
+
requiredBootstrapFiles: readiness.bootstrap.requiredCount,
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
function computeBackgroundAgentMode(feedbackDir, options = {}) {
|
|
1443
|
+
const governance = generateGovernanceReport({
|
|
1444
|
+
periodHours: options.periodHours || 24,
|
|
1445
|
+
feedbackDir,
|
|
1446
|
+
});
|
|
1447
|
+
const workflowSummary = options.workflowSummary || summarizeWorkflowRuns(feedbackDir);
|
|
1448
|
+
const topRunType = Object.entries(governance.byType || {})
|
|
1449
|
+
.sort((left, right) => right[1] - left[1] || left[0].localeCompare(right[0]))[0] || null;
|
|
1450
|
+
const latestRun = workflowSummary.latestRun || null;
|
|
1451
|
+
const checkpointCoverage = safeRate(workflowSummary.reviewedRuns || 0, workflowSummary.proofBackedRuns || 0);
|
|
1452
|
+
|
|
1453
|
+
return {
|
|
1454
|
+
...governance,
|
|
1455
|
+
checkpointCoverage,
|
|
1456
|
+
reviewedRuns: workflowSummary.reviewedRuns || 0,
|
|
1457
|
+
proofBackedRuns: workflowSummary.proofBackedRuns || 0,
|
|
1458
|
+
latestRun,
|
|
1459
|
+
topRunType: topRunType ? { runType: topRunType[0], count: topRunType[1] } : null,
|
|
1460
|
+
recommendedMode: governance.blocked > 0 || governance.failed > 0
|
|
1461
|
+
? 'checkpoint-heavy'
|
|
1462
|
+
: governance.total > 0
|
|
1463
|
+
? 'operator-light'
|
|
1464
|
+
: 'bootstrapping',
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
function computeRegulatedBuyerProof(settingsStatus, workflowSummary, decisions, readiness) {
|
|
1469
|
+
const origins = Array.isArray(settingsStatus && settingsStatus.origins) ? settingsStatus.origins : [];
|
|
1470
|
+
const activeLayers = Array.isArray(settingsStatus && settingsStatus.activeLayers)
|
|
1471
|
+
? settingsStatus.activeLayers.filter((layer) => layer && layer.exists)
|
|
1472
|
+
: [];
|
|
1473
|
+
const latestRun = workflowSummary && workflowSummary.latestRun ? workflowSummary.latestRun : null;
|
|
1474
|
+
const proofArtifacts = latestRun && Array.isArray(latestRun.proofArtifacts) ? latestRun.proofArtifacts : [];
|
|
1475
|
+
|
|
1476
|
+
return {
|
|
1477
|
+
policyOriginCount: origins.length,
|
|
1478
|
+
activeLayerCount: activeLayers.length,
|
|
1479
|
+
reviewedRuns: workflowSummary && workflowSummary.reviewedRuns || 0,
|
|
1480
|
+
proofBackedRuns: workflowSummary && workflowSummary.proofBackedRuns || 0,
|
|
1481
|
+
checkpointCoverage: safeRate(
|
|
1482
|
+
workflowSummary && workflowSummary.reviewedRuns || 0,
|
|
1483
|
+
workflowSummary && workflowSummary.proofBackedRuns || 0
|
|
1484
|
+
),
|
|
1485
|
+
decisionEvaluations: decisions && decisions.evaluationCount || 0,
|
|
1486
|
+
appendOnlyAuditReady: Boolean(decisions && decisions.evaluationCount > 0),
|
|
1487
|
+
runtimeIsolation: Boolean(readiness && readiness.articleAlignment && readiness.articleAlignment.runtimeIsolation),
|
|
1488
|
+
latestWorkflowName: latestRun ? (latestRun.workflowName || latestRun.workflowId) : null,
|
|
1489
|
+
latestProofArtifacts: proofArtifacts.slice(0, 3),
|
|
1490
|
+
latestPolicyOrigin: origins[0] || null,
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1311
1494
|
function resolveTeamWindowHours(analyticsWindow) {
|
|
1312
1495
|
const window = analyticsWindow && analyticsWindow.window;
|
|
1313
1496
|
if (window === 'today') return 24;
|
|
@@ -1416,9 +1599,19 @@ function generateDashboard(feedbackDir, options = {}) {
|
|
|
1416
1599
|
availability: 'private_core',
|
|
1417
1600
|
};
|
|
1418
1601
|
const readiness = generateAgentReadinessReport({ projectRoot: PROJECT_ROOT });
|
|
1602
|
+
const feedbackAnalysis = analyzeFeedback(path.join(feedbackDir, 'feedback-log.jsonl'));
|
|
1419
1603
|
const harness = computeHarnessOverview(feedbackDir, entries);
|
|
1420
1604
|
const interventionPolicy = getInterventionPolicySummary(feedbackDir);
|
|
1605
|
+
const decisionRecords = readDecisionLog(path.join(feedbackDir, DECISION_LOG_FILENAME));
|
|
1421
1606
|
const decisions = computeDecisionMetrics(feedbackDir);
|
|
1607
|
+
const actionableRemediations = summarizeActionableRemediations(
|
|
1608
|
+
feedbackAnalysis && feedbackAnalysis.actionableRemediations
|
|
1609
|
+
);
|
|
1610
|
+
const agentSurfaceInventory = computeAgentSurfaceInventory(feedbackDir, {
|
|
1611
|
+
readiness,
|
|
1612
|
+
auditEntries,
|
|
1613
|
+
decisionRecords,
|
|
1614
|
+
});
|
|
1422
1615
|
const settingsStatus = getSettingsStatus({ projectRoot: PROJECT_ROOT });
|
|
1423
1616
|
settingsStatus.routingPreview = {
|
|
1424
1617
|
dashboardTool: routeProfile({
|
|
@@ -1433,6 +1626,16 @@ function generateDashboard(feedbackDir, options = {}) {
|
|
|
1433
1626
|
settingsOptions: { projectRoot: PROJECT_ROOT },
|
|
1434
1627
|
}),
|
|
1435
1628
|
};
|
|
1629
|
+
const workflowSummary = summarizeWorkflowRuns(feedbackDir);
|
|
1630
|
+
const backgroundAgents = computeBackgroundAgentMode(feedbackDir, {
|
|
1631
|
+
workflowSummary,
|
|
1632
|
+
});
|
|
1633
|
+
const regulatedProof = computeRegulatedBuyerProof(
|
|
1634
|
+
settingsStatus,
|
|
1635
|
+
workflowSummary,
|
|
1636
|
+
decisions,
|
|
1637
|
+
readiness,
|
|
1638
|
+
);
|
|
1436
1639
|
|
|
1437
1640
|
// Live metrics — gate hit rate, lesson effectiveness, error trend
|
|
1438
1641
|
const now = Date.now();
|
|
@@ -1520,6 +1723,11 @@ function generateDashboard(feedbackDir, options = {}) {
|
|
|
1520
1723
|
observability,
|
|
1521
1724
|
instrumentation,
|
|
1522
1725
|
readiness,
|
|
1726
|
+
feedbackAnalysis,
|
|
1727
|
+
actionableRemediations,
|
|
1728
|
+
agentSurfaceInventory,
|
|
1729
|
+
backgroundAgents,
|
|
1730
|
+
regulatedProof,
|
|
1523
1731
|
interventionPolicy,
|
|
1524
1732
|
decisions,
|
|
1525
1733
|
settingsStatus,
|