mirror of
https://github.com/Jeuners/ECC.git
synced 2026-09-09 15:02:30 +02:00
feat: add status readiness rollup
This commit is contained in:
parent
d2760d0359
commit
fb9a8f2973
4 changed files with 71 additions and 9 deletions
|
|
@ -202,6 +202,22 @@ function summarizeInstallHealth(installations) {
|
|||
};
|
||||
}
|
||||
|
||||
function summarizeReadiness({ activeSessionCount, skillRuns, installHealth, pendingGovernanceCount }) {
|
||||
const failedSkillRuns = skillRuns.summary.failureCount;
|
||||
const warningInstallations = installHealth.warningCount;
|
||||
const pendingGovernanceEvents = pendingGovernanceCount;
|
||||
const attentionCount = failedSkillRuns + warningInstallations + pendingGovernanceEvents;
|
||||
|
||||
return {
|
||||
status: attentionCount > 0 ? 'attention' : 'ok',
|
||||
attentionCount,
|
||||
activeSessions: activeSessionCount,
|
||||
failedSkillRuns,
|
||||
warningInstallations,
|
||||
pendingGovernanceEvents,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeSessionInput(session) {
|
||||
return {
|
||||
id: session.id,
|
||||
|
|
@ -568,24 +584,34 @@ function createQueryApi(db) {
|
|||
const pendingLimit = normalizeLimit(options.pendingLimit, 5);
|
||||
|
||||
const activeSessions = listActiveSessionsStatement.all(activeLimit).map(mapSessionRow);
|
||||
const activeSessionCount = countActiveSessionsStatement.get().total_count;
|
||||
const recentSkillRuns = listRecentSkillRunsStatement.all(recentSkillRunLimit).map(mapSkillRunRow);
|
||||
const installations = listInstallStateStatement.all().map(mapInstallStateRow);
|
||||
const pendingGovernanceEvents = listPendingGovernanceStatement.all(pendingLimit).map(mapGovernanceEventRow);
|
||||
const skillRuns = {
|
||||
windowSize: recentSkillRunLimit,
|
||||
summary: summarizeSkillRuns(recentSkillRuns),
|
||||
recent: recentSkillRuns,
|
||||
};
|
||||
const installHealth = summarizeInstallHealth(installations);
|
||||
const pendingGovernanceCount = countPendingGovernanceStatement.get().total_count;
|
||||
|
||||
return {
|
||||
generatedAt: new Date().toISOString(),
|
||||
readiness: summarizeReadiness({
|
||||
activeSessionCount,
|
||||
skillRuns,
|
||||
installHealth,
|
||||
pendingGovernanceCount,
|
||||
}),
|
||||
activeSessions: {
|
||||
activeCount: countActiveSessionsStatement.get().total_count,
|
||||
activeCount: activeSessionCount,
|
||||
sessions: activeSessions,
|
||||
},
|
||||
skillRuns: {
|
||||
windowSize: recentSkillRunLimit,
|
||||
summary: summarizeSkillRuns(recentSkillRuns),
|
||||
recent: recentSkillRuns,
|
||||
},
|
||||
installHealth: summarizeInstallHealth(installations),
|
||||
skillRuns,
|
||||
installHealth,
|
||||
governance: {
|
||||
pendingCount: countPendingGovernanceStatement.get().total_count,
|
||||
pendingCount: pendingGovernanceCount,
|
||||
events: pendingGovernanceEvents,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -142,9 +142,20 @@ function printGovernance(section) {
|
|||
}
|
||||
}
|
||||
|
||||
function printReadiness(section) {
|
||||
console.log(`Readiness: ${section.status}`);
|
||||
console.log(` Attention items: ${section.attentionCount}`);
|
||||
console.log(` Active sessions: ${section.activeSessions}`);
|
||||
console.log(` Failed skill runs: ${section.failedSkillRuns}`);
|
||||
console.log(` Warning installs: ${section.warningInstallations}`);
|
||||
console.log(` Pending governance: ${section.pendingGovernanceEvents}`);
|
||||
}
|
||||
|
||||
function printHuman(payload) {
|
||||
console.log('ECC status\n');
|
||||
console.log(`Database: ${payload.dbPath}\n`);
|
||||
printReadiness(payload.readiness);
|
||||
console.log();
|
||||
printActiveSessions(payload.activeSessions);
|
||||
console.log();
|
||||
printSkillRuns(payload.skillRuns);
|
||||
|
|
@ -169,6 +180,15 @@ function renderMarkdown(payload) {
|
|||
`Generated: ${payload.generatedAt}`,
|
||||
`Database: ${formatCode(payload.dbPath)}`,
|
||||
'',
|
||||
'## Readiness',
|
||||
'',
|
||||
`Status: ${payload.readiness.status}`,
|
||||
`Attention items: ${payload.readiness.attentionCount}`,
|
||||
`Active sessions: ${payload.readiness.activeSessions}`,
|
||||
`Failed skill runs: ${payload.readiness.failedSkillRuns}`,
|
||||
`Warning installs: ${payload.readiness.warningInstallations}`,
|
||||
`Pending governance: ${payload.readiness.pendingGovernanceEvents}`,
|
||||
'',
|
||||
'## Active Sessions',
|
||||
'',
|
||||
`Active sessions: ${payload.activeSessions.activeCount}`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue