scene-capability-engine 3.6.32 → 3.6.36
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/CHANGELOG.md +86 -1
- package/README.md +119 -122
- package/README.zh.md +123 -121
- package/bin/scene-capability-engine.js +11 -0
- package/docs/README.md +21 -32
- package/docs/auto-refactor-index.md +384 -0
- package/docs/command-reference.md +94 -2
- package/docs/magicball-adaptation-task-checklist-v1.md +385 -0
- package/docs/magicball-app-bundle-sqlite-and-command-draft.md +539 -0
- package/docs/magicball-capability-iteration-api.md +2 -0
- package/docs/magicball-capability-iteration-ui.md +2 -0
- package/docs/magicball-capability-library.md +2 -0
- package/docs/magicball-cli-invocation-examples.md +336 -0
- package/docs/magicball-frontend-state-and-command-mapping.md +244 -0
- package/docs/magicball-integration-doc-index.md +137 -0
- package/docs/magicball-integration-issue-tracker.md +218 -0
- package/docs/magicball-mode-home-and-ontology-empty-state-playbook.md +249 -0
- package/docs/magicball-sce-adaptation-guide.md +203 -0
- package/docs/magicball-three-mode-alignment-plan.md +551 -0
- package/docs/magicball-ui-surface-checklist.md +126 -0
- package/docs/magicball-write-auth-adaptation-guide.md +328 -0
- package/docs/refactor-completion-roadmap.md +116 -0
- package/docs/zh/README.md +27 -30
- package/docs/zh/refactor-completion-roadmap.md +116 -0
- package/lib/app/registry-config.js +73 -0
- package/lib/app/registry-sync-service.js +228 -0
- package/lib/auto/archive-schema-service.js +276 -0
- package/lib/auto/archive-summary.js +60 -0
- package/lib/auto/batch-goal-input-service.js +543 -0
- package/lib/auto/batch-output.js +201 -0
- package/lib/auto/batch-summary-storage-service.js +110 -0
- package/lib/auto/close-loop-batch-service.js +116 -0
- package/lib/auto/close-loop-controller-service.js +287 -0
- package/lib/auto/close-loop-program-service.js +283 -0
- package/lib/auto/close-loop-recovery-service.js +191 -0
- package/lib/auto/close-loop-session-storage-service.js +50 -0
- package/lib/auto/controller-lock-service.js +55 -0
- package/lib/auto/controller-output.js +32 -0
- package/lib/auto/controller-queue-service.js +127 -0
- package/lib/auto/controller-session-storage-service.js +105 -0
- package/lib/auto/governance-advisory-service.js +208 -0
- package/lib/auto/governance-close-loop-service.js +411 -0
- package/lib/auto/governance-maintenance-presenter.js +162 -0
- package/lib/auto/governance-maintenance-service.js +112 -0
- package/lib/auto/governance-session-presenter.js +70 -0
- package/lib/auto/governance-session-storage-service.js +198 -0
- package/lib/auto/governance-signals.js +139 -0
- package/lib/auto/governance-stats-presenter.js +337 -0
- package/lib/auto/governance-stats-service.js +115 -0
- package/lib/auto/governance-summary.js +703 -0
- package/lib/auto/handoff-capability-matrix-service.js +281 -0
- package/lib/auto/handoff-evidence-review-service.js +251 -0
- package/lib/auto/handoff-release-evidence-service.js +190 -0
- package/lib/auto/handoff-release-gate-history-loaders-service.js +502 -0
- package/lib/auto/handoff-release-gate-history-service.js +257 -0
- package/lib/auto/handoff-reporting-service.js +1407 -0
- package/lib/auto/handoff-run-service.js +486 -0
- package/lib/auto/handoff-snapshots-service.js +645 -0
- package/lib/auto/observability-service.js +132 -0
- package/lib/auto/output-writer.js +34 -0
- package/lib/auto/program-auto-remediation-service.js +130 -0
- package/lib/auto/program-diagnostics.js +138 -0
- package/lib/auto/program-governance-helpers.js +306 -0
- package/lib/auto/program-governance-loop-service.js +413 -0
- package/lib/auto/program-output.js +106 -0
- package/lib/auto/program-summary.js +183 -0
- package/lib/auto/recovery-memory-service.js +684 -0
- package/lib/auto/recovery-selection-service.js +52 -0
- package/lib/auto/retention-policy.js +98 -0
- package/lib/auto/session-persistence-service.js +106 -0
- package/lib/auto/session-presenter.js +105 -0
- package/lib/auto/session-prune-service.js +190 -0
- package/lib/auto/session-query-service.js +249 -0
- package/lib/auto/spec-protection.js +141 -0
- package/lib/commands/app.js +911 -0
- package/lib/commands/assurance.js +212 -0
- package/lib/commands/auto.js +1091 -11063
- package/lib/commands/mode.js +321 -0
- package/lib/commands/ontology.js +415 -0
- package/lib/commands/pm.js +422 -0
- package/lib/ontology/seed-profiles.js +160 -0
- package/lib/state/sce-state-store.js +3369 -1200
- package/package.json +1 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
function resolveResultSourceIndex(item, fallbackIndex = 0) {
|
|
2
|
+
if (Number.isInteger(item && item.source_index) && item.source_index >= 0) {
|
|
3
|
+
return item.source_index;
|
|
4
|
+
}
|
|
5
|
+
const fromIndex = Number(item && item.index);
|
|
6
|
+
if (Number.isInteger(fromIndex) && fromIndex > 0) {
|
|
7
|
+
return fromIndex - 1;
|
|
8
|
+
}
|
|
9
|
+
return Math.max(0, fallbackIndex);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getBatchFailureStatusSet() {
|
|
13
|
+
return new Set(['failed', 'error', 'unknown', 'stopped']);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function buildProgramCoordinationSnapshot(summary) {
|
|
17
|
+
const results = Array.isArray(summary && summary.results) ? summary.results : [];
|
|
18
|
+
const failedStatuses = getBatchFailureStatusSet();
|
|
19
|
+
const unresolvedIndexes = [];
|
|
20
|
+
const masterSpecs = new Set();
|
|
21
|
+
let totalSubSpecs = 0;
|
|
22
|
+
for (const item of results) {
|
|
23
|
+
const status = `${item && item.status ? item.status : ''}`.trim().toLowerCase();
|
|
24
|
+
if (failedStatuses.has(status)) {
|
|
25
|
+
unresolvedIndexes.push(resolveResultSourceIndex(item) + 1);
|
|
26
|
+
}
|
|
27
|
+
const masterSpec = item && typeof item.master_spec === 'string' ? item.master_spec.trim() : '';
|
|
28
|
+
if (masterSpec) {
|
|
29
|
+
masterSpecs.add(masterSpec);
|
|
30
|
+
}
|
|
31
|
+
totalSubSpecs += Number(item && item.sub_spec_count) || 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
topology: 'master-sub',
|
|
36
|
+
master_spec_count: masterSpecs.size,
|
|
37
|
+
sub_spec_count: totalSubSpecs,
|
|
38
|
+
unresolved_goal_count: unresolvedIndexes.length,
|
|
39
|
+
unresolved_goal_indexes: unresolvedIndexes.slice(0, 50),
|
|
40
|
+
scheduler: {
|
|
41
|
+
batch_parallel: Number(summary && summary.batch_parallel) || 0,
|
|
42
|
+
agent_budget: summary && summary.resource_plan && summary.resource_plan.agent_budget !== undefined
|
|
43
|
+
? summary.resource_plan.agent_budget
|
|
44
|
+
: null,
|
|
45
|
+
priority: summary && summary.resource_plan ? summary.resource_plan.scheduling_strategy : null,
|
|
46
|
+
aging_factor: summary && summary.resource_plan ? summary.resource_plan.aging_factor : null
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function mergeProgramRecoveryIntoProgramSummary(initialSummary, recoverySummary, metadata = {}, dependencies = {}) {
|
|
52
|
+
const buildBatchMetrics = dependencies.buildBatchMetrics || (() => ({}));
|
|
53
|
+
const mergeBatchResourcePlans = dependencies.mergeBatchResourcePlans || ((_base, next) => next || null);
|
|
54
|
+
|
|
55
|
+
const baseSummary = initialSummary && typeof initialSummary === 'object' ? initialSummary : {};
|
|
56
|
+
const recovery = recoverySummary && typeof recoverySummary === 'object' ? recoverySummary : {};
|
|
57
|
+
const failedStatuses = getBatchFailureStatusSet();
|
|
58
|
+
const mergedBySource = new Map();
|
|
59
|
+
|
|
60
|
+
const initialResults = Array.isArray(baseSummary.results) ? baseSummary.results : [];
|
|
61
|
+
for (let index = 0; index < initialResults.length; index += 1) {
|
|
62
|
+
const item = initialResults[index];
|
|
63
|
+
const sourceIndex = resolveResultSourceIndex(item, index);
|
|
64
|
+
mergedBySource.set(sourceIndex, {
|
|
65
|
+
...item,
|
|
66
|
+
source_index: sourceIndex,
|
|
67
|
+
index: sourceIndex + 1
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const recoveryResults = Array.isArray(recovery.results) ? recovery.results : [];
|
|
72
|
+
for (let index = 0; index < recoveryResults.length; index += 1) {
|
|
73
|
+
const item = recoveryResults[index];
|
|
74
|
+
const sourceIndex = resolveResultSourceIndex(item, index);
|
|
75
|
+
mergedBySource.set(sourceIndex, {
|
|
76
|
+
...item,
|
|
77
|
+
source_index: sourceIndex,
|
|
78
|
+
index: sourceIndex + 1,
|
|
79
|
+
recovered_by_program: true
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const orderedResults = [...mergedBySource.entries()]
|
|
84
|
+
.sort((a, b) => a[0] - b[0])
|
|
85
|
+
.map(([, item]) => item);
|
|
86
|
+
const totalGoals = Number(baseSummary.total_goals) || orderedResults.length;
|
|
87
|
+
const failedGoals = orderedResults.filter(item => failedStatuses.has(`${item && item.status ? item.status : ''}`.trim().toLowerCase())).length;
|
|
88
|
+
const completedGoals = orderedResults.length - failedGoals;
|
|
89
|
+
const status = failedGoals === 0
|
|
90
|
+
? 'completed'
|
|
91
|
+
: completedGoals === 0
|
|
92
|
+
? 'failed'
|
|
93
|
+
: 'partial-failed';
|
|
94
|
+
const mergedResourcePlan = mergeBatchResourcePlans(baseSummary.resource_plan || null, recovery.resource_plan || null);
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
...baseSummary,
|
|
98
|
+
status,
|
|
99
|
+
total_goals: totalGoals,
|
|
100
|
+
processed_goals: orderedResults.length,
|
|
101
|
+
completed_goals: completedGoals,
|
|
102
|
+
failed_goals: failedGoals,
|
|
103
|
+
batch_parallel: Math.max(Number(baseSummary.batch_parallel) || 0, Number(recovery.batch_parallel) || 0),
|
|
104
|
+
resource_plan: mergedResourcePlan,
|
|
105
|
+
metrics: buildBatchMetrics(orderedResults, totalGoals),
|
|
106
|
+
results: orderedResults,
|
|
107
|
+
auto_recovery: {
|
|
108
|
+
...metadata,
|
|
109
|
+
source_status: baseSummary.status || null,
|
|
110
|
+
recovery_status: recovery.status || null,
|
|
111
|
+
converged: recovery.status === 'completed',
|
|
112
|
+
selected_action_index: recovery.recovered_from_summary
|
|
113
|
+
? recovery.recovered_from_summary.selected_action_index
|
|
114
|
+
: null,
|
|
115
|
+
selection_source: recovery.recovery_plan ? recovery.recovery_plan.selection_source : null,
|
|
116
|
+
recovery_cycle: recovery.recovery_cycle || null,
|
|
117
|
+
recovery_memory: recovery.recovery_memory || null
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function buildProgramKpiSnapshot(summary, dependencies = {}) {
|
|
123
|
+
const now = dependencies.now || (() => new Date().toISOString());
|
|
124
|
+
const results = Array.isArray(summary && summary.results) ? summary.results : [];
|
|
125
|
+
const totalGoals = Number(summary && summary.total_goals) || results.length || 1;
|
|
126
|
+
const completedGoals = Number(summary && summary.completed_goals) || 0;
|
|
127
|
+
const failedGoals = Number(summary && summary.failed_goals) || 0;
|
|
128
|
+
const processedGoals = Number(summary && summary.processed_goals) || results.length;
|
|
129
|
+
const completionRate = Number(((completedGoals / totalGoals) * 100).toFixed(2));
|
|
130
|
+
const failureRate = Number(((failedGoals / totalGoals) * 100).toFixed(2));
|
|
131
|
+
const averageWaitTicks = Number(
|
|
132
|
+
(
|
|
133
|
+
results.reduce((sum, item) => sum + (Number(item && item.wait_ticks) || 0), 0) /
|
|
134
|
+
(results.length || 1)
|
|
135
|
+
).toFixed(2)
|
|
136
|
+
);
|
|
137
|
+
const highComplexityGoals = results.filter(item => (Number(item && item.goal_weight) || 0) >= 3).length;
|
|
138
|
+
const highComplexityRatioPercent = Number(((highComplexityGoals / totalGoals) * 100).toFixed(2));
|
|
139
|
+
const retry = summary && summary.batch_retry ? summary.batch_retry : {};
|
|
140
|
+
const retryHistory = Array.isArray(retry.history) ? retry.history : [];
|
|
141
|
+
const firstRoundUnresolved = retryHistory.length > 0
|
|
142
|
+
? (Number(retryHistory[0].failed_goals) || 0) + (Number(retryHistory[0].unprocessed_goals) || 0)
|
|
143
|
+
: failedGoals;
|
|
144
|
+
const recoveredGoals = Math.max(0, firstRoundUnresolved - failedGoals);
|
|
145
|
+
const retryRecoveryRatePercent = firstRoundUnresolved > 0
|
|
146
|
+
? Number(((recoveredGoals / firstRoundUnresolved) * 100).toFixed(2))
|
|
147
|
+
: 100;
|
|
148
|
+
|
|
149
|
+
let convergenceState = 'converged';
|
|
150
|
+
if (summary && summary.status === 'partial-failed') {
|
|
151
|
+
convergenceState = 'at-risk';
|
|
152
|
+
} else if (summary && summary.status === 'failed') {
|
|
153
|
+
convergenceState = 'blocked';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let riskLevel = 'low';
|
|
157
|
+
if (failureRate > 20 || convergenceState === 'blocked') {
|
|
158
|
+
riskLevel = 'high';
|
|
159
|
+
} else if (failureRate > 0 || (Number(retry.performed_rounds) || 0) > 0) {
|
|
160
|
+
riskLevel = 'medium';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
generated_at: now(),
|
|
165
|
+
completion_rate_percent: completionRate,
|
|
166
|
+
failure_rate_percent: failureRate,
|
|
167
|
+
processed_goals: processedGoals,
|
|
168
|
+
high_complexity_goal_ratio_percent: highComplexityRatioPercent,
|
|
169
|
+
average_wait_ticks: averageWaitTicks,
|
|
170
|
+
retry_rounds_performed: Number(retry.performed_rounds) || 0,
|
|
171
|
+
retry_recovery_rate_percent: retryRecoveryRatePercent,
|
|
172
|
+
convergence_state: convergenceState,
|
|
173
|
+
risk_level: riskLevel
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
module.exports = {
|
|
178
|
+
resolveResultSourceIndex,
|
|
179
|
+
getBatchFailureStatusSet,
|
|
180
|
+
buildProgramCoordinationSnapshot,
|
|
181
|
+
mergeProgramRecoveryIntoProgramSummary,
|
|
182
|
+
buildProgramKpiSnapshot
|
|
183
|
+
};
|