scene-capability-engine 3.6.64 → 3.6.67
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 +26 -0
- package/README.md +17 -6
- package/README.zh.md +18 -6
- package/bin/scene-capability-engine.js +4 -0
- package/docs/README.md +2 -2
- package/docs/command-reference.md +385 -8
- package/docs/document-governance.md +3 -2
- package/docs/integration-modes.md +62 -478
- package/docs/integration-philosophy.md +56 -263
- package/docs/magicball-cli-invocation-examples.md +1 -0
- package/docs/magicball-project-portfolio-contract.md +125 -4
- package/docs/project-management/README.md +14 -0
- package/docs/project-management/assurance/backup.md +3 -0
- package/docs/project-management/assurance/config.md +3 -0
- package/docs/project-management/assurance/evidence/README.md +3 -0
- package/docs/project-management/assurance/incidents/README.md +3 -0
- package/docs/project-management/assurance/logs.md +3 -0
- package/docs/project-management/assurance/overview.md +3 -0
- package/docs/project-management/assurance/recovery/README.md +3 -0
- package/docs/project-management/assurance/resource.md +3 -0
- package/docs/project-management/assurance/runbooks/README.md +3 -0
- package/docs/project-management/delivery/acceptance/README.md +3 -0
- package/docs/project-management/delivery/acceptance/evidence/README.md +3 -0
- package/docs/project-management/delivery/acceptance/exceptions/README.md +3 -0
- package/docs/project-management/delivery/acceptance/reports/README.md +3 -0
- package/docs/project-management/delivery/documents/changes.md +3 -0
- package/docs/project-management/delivery/documents/issues.md +3 -0
- package/docs/project-management/delivery/documents/overview.md +3 -0
- package/docs/project-management/delivery/documents/planning.md +3 -0
- package/docs/project-management/delivery/documents/requirements.md +3 -0
- package/docs/project-management/delivery/documents/tracking.md +3 -0
- package/docs/project-management/delivery/handoffs/README.md +3 -0
- package/docs/project-management/delivery/handoffs/evidence/README.md +3 -0
- package/docs/project-management/delivery/handoffs/records/README.md +3 -0
- package/docs/project-management/delivery/overview.md +10 -0
- package/docs/project-management/delivery/releases/README.md +3 -0
- package/docs/project-management/delivery/releases/baselines/README.md +3 -0
- package/docs/project-management/delivery/releases/evidence/README.md +3 -0
- package/docs/project-management/delivery/tables/changes.md +3 -0
- package/docs/project-management/delivery/tables/issues.md +3 -0
- package/docs/project-management/delivery/tables/planning.md +3 -0
- package/docs/project-management/delivery/tables/requirements.md +3 -0
- package/docs/project-management/delivery/tables/tracking.md +3 -0
- package/docs/project-management/environment/agent-discovery.md +3 -0
- package/docs/project-management/environment/development.md +3 -0
- package/docs/project-management/environment/overview.md +10 -0
- package/docs/project-management/environment/testing.md +3 -0
- package/docs/project-management/environment/version-alignment.md +3 -0
- package/docs/quick-start-with-ai-tools.md +68 -308
- package/docs/releases/README.md +3 -0
- package/docs/releases/v3.6.65.md +25 -0
- package/docs/releases/v3.6.66.md +23 -0
- package/docs/releases/v3.6.67.md +23 -0
- package/docs/steering-governance.md +64 -2
- package/docs/zh/README.md +2 -2
- package/docs/zh/releases/README.md +3 -0
- package/docs/zh/releases/v3.6.65.md +25 -0
- package/docs/zh/releases/v3.6.66.md +23 -0
- package/docs/zh/releases/v3.6.67.md +23 -0
- package/lib/commands/adopt.js +24 -0
- package/lib/commands/native.js +158 -0
- package/lib/commands/project.js +96 -0
- package/lib/commands/semantic.js +1459 -0
- package/lib/commands/session.js +74 -3
- package/lib/commands/spec-bootstrap.js +10 -1
- package/lib/commands/spec-gate.js +10 -1
- package/lib/commands/spec-pipeline.js +10 -1
- package/lib/commands/studio.js +405 -30
- package/lib/commands/task.js +141 -7
- package/lib/governance/supreme-principles.js +530 -0
- package/lib/problem/problem-evaluator.js +4 -0
- package/lib/project/candidate-inspection-service.js +24 -1
- package/lib/project/portfolio-projection-service.js +315 -5
- package/lib/project/project-channel-output.js +94 -0
- package/lib/project/project-channel-projection.js +181 -0
- package/lib/project/root-onboarding-service.js +107 -7
- package/lib/project/semantic-shared-source-projection.js +150 -0
- package/lib/project/supervision-action-model.js +277 -0
- package/lib/project/supervision-projection-service.js +305 -5
- package/lib/project/target-resolution-service.js +70 -5
- package/lib/project/visibility-policy.js +93 -0
- package/lib/runtime/multi-spec-scene-session.js +8 -1
- package/lib/runtime/project-channel-context-store.js +387 -0
- package/lib/runtime/project-channel-context.js +406 -0
- package/lib/runtime/scene-session-binding.js +46 -0
- package/lib/runtime/session-store.js +186 -0
- package/lib/runtime/steering-contract.js +7 -1
- package/lib/semantic/archive-report.js +283 -0
- package/lib/semantic/archive-routing.js +67 -0
- package/lib/semantic/backflow-report.js +245 -0
- package/lib/semantic/capability-contract.js +30 -0
- package/lib/semantic/delta-export.js +145 -0
- package/lib/semantic/interaction-observer.js +254 -0
- package/lib/semantic/kernel-loader.js +881 -0
- package/lib/semantic/native-runtime.js +359 -0
- package/lib/semantic/progress-ledger.js +433 -0
- package/lib/semantic/replay-evaluator.js +382 -0
- package/lib/semantic/shared-publication.js +592 -0
- package/lib/semantic/shared-source-config.js +183 -0
- package/lib/semantic/shared-source-connect.js +139 -0
- package/lib/semantic/shared-source-discovery.js +98 -0
- package/lib/semantic/shared-sync-export.js +413 -0
- package/lib/semantic/shared-sync-intake.js +592 -0
- package/lib/semantic/shared-sync-merge.js +547 -0
- package/lib/semantic/shared-sync-release.js +463 -0
- package/lib/semantic/supreme-intent-report.js +300 -0
- package/lib/state/sce-state-store.js +1360 -0
- package/lib/steering/context-sync-manager.js +276 -25
- package/lib/studio/spec-intake-governor.js +39 -3
- package/lib/studio/task-envelope.js +35 -2
- package/lib/workspace/takeover-baseline.js +342 -83
- package/package.json +7 -2
- package/scripts/agent-governance-baseline-audit.js +395 -0
- package/scripts/clarification-first-audit.js +9 -9
- package/scripts/deprecated-entry-audit.js +240 -0
- package/scripts/release-doc-version-audit.js +24 -0
- package/scripts/release-posture-report.js +262 -0
- package/template/.sce/README.md +62 -228
- package/template/.sce/config/semantic-shared-sources.json +5 -0
- package/template/.sce/config/supreme-principles-policy.json +105 -0
- package/template/.sce/config/takeover-baseline.json +7 -0
- package/template/.sce/steering/CORE_PRINCIPLES.md +23 -63
- package/template/.sce/steering/CURRENT_CONTEXT.md +4 -0
- package/template/.sce/steering/RULES_GUIDE.md +17 -9
- package/template/README.md +32 -96
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
const { getSceStateStore } = require('../state/sce-state-store');
|
|
2
|
+
const { buildSemanticArchiveSummary } = require('./archive-report');
|
|
3
|
+
const { buildSupremeIntentGovernanceReport } = require('./supreme-intent-report');
|
|
4
|
+
const { buildSemanticBackflowReport } = require('./backflow-report');
|
|
5
|
+
const { buildSemanticArchiveReport } = require('./archive-report');
|
|
6
|
+
const { buildSemanticSharedSourceProjection } = require('../project/semantic-shared-source-projection');
|
|
7
|
+
const { buildSupervisionActionQueue } = require('../project/supervision-action-model');
|
|
8
|
+
|
|
9
|
+
function normalizeString(value) {
|
|
10
|
+
if (typeof value !== 'string') {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
return value.trim();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function normalizeInteger(value, fallback = 0) {
|
|
17
|
+
const parsed = Number.parseInt(`${value}`, 10);
|
|
18
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
19
|
+
return fallback;
|
|
20
|
+
}
|
|
21
|
+
return parsed;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function percent(part, total) {
|
|
25
|
+
if (!Number.isFinite(part) || !Number.isFinite(total) || total <= 0) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
return Number(((part / total) * 100).toFixed(2));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function readObservationMetadata(observation = {}) {
|
|
32
|
+
if (observation.normalized_payload && typeof observation.normalized_payload === 'object'
|
|
33
|
+
&& observation.normalized_payload.metadata
|
|
34
|
+
&& typeof observation.normalized_payload.metadata === 'object') {
|
|
35
|
+
return observation.normalized_payload.metadata;
|
|
36
|
+
}
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function readLessonPublishState(lesson = {}) {
|
|
41
|
+
if (lesson.metadata && typeof lesson.metadata === 'object'
|
|
42
|
+
&& lesson.metadata.publish
|
|
43
|
+
&& typeof lesson.metadata.publish === 'object') {
|
|
44
|
+
return normalizeString(lesson.metadata.publish.publish_state) || 'none';
|
|
45
|
+
}
|
|
46
|
+
return 'none';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function buildGovernanceOperatorItems(report = {}) {
|
|
50
|
+
const hotspots = Array.isArray(report.top_scope_hotspots) ? report.top_scope_hotspots : [];
|
|
51
|
+
return hotspots
|
|
52
|
+
.filter((item) => Number(item && item.governed_count || 0) > 0)
|
|
53
|
+
.slice(0, 3)
|
|
54
|
+
.map((item) => ({
|
|
55
|
+
id: `semantic-progress:governance:${normalizeString(item.project_id) || 'project'}:${normalizeString(item.channel_id) || 'channel'}:${normalizeString(item.spec_id) || 'spec'}`,
|
|
56
|
+
kind: 'governance',
|
|
57
|
+
state: Number(item.refuse || 0) > 0 ? 'refuse-hotspot' : 'rewrite-hotspot',
|
|
58
|
+
channelId: normalizeString(item.channel_id) || null,
|
|
59
|
+
sceneId: normalizeString(item.scene_id) || null,
|
|
60
|
+
specId: normalizeString(item.spec_id) || null,
|
|
61
|
+
governedCount: Number(item.governed_count || 0),
|
|
62
|
+
updatedAt: normalizeString(item.latest_at) || null,
|
|
63
|
+
summary: `Governance hotspot on ${normalizeString(item.channel_id) || 'project'} / ${normalizeString(item.spec_id) || normalizeString(item.scene_id) || 'unbound'} with ${Number(item.governed_count || 0)} governed assessments.`
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function buildBackflowOperatorItems(report = {}) {
|
|
68
|
+
const items = [];
|
|
69
|
+
const localBlockedItems = Array.isArray(report?.local?.recent_blocked_items)
|
|
70
|
+
? report.local.recent_blocked_items.slice(0, 3)
|
|
71
|
+
: [];
|
|
72
|
+
for (const item of localBlockedItems) {
|
|
73
|
+
items.push({
|
|
74
|
+
id: `semantic-progress:backflow:local:${normalizeString(item.lesson_id) || normalizeString(item.capability_id) || normalizeString(item.spec_id) || 'unknown'}`,
|
|
75
|
+
kind: 'backflow',
|
|
76
|
+
state: 'local-publish-blocked',
|
|
77
|
+
channelId: normalizeString(item.channel_id) || null,
|
|
78
|
+
sceneId: normalizeString(item.scene_id) || null,
|
|
79
|
+
specId: normalizeString(item.spec_id) || null,
|
|
80
|
+
blockedReason: normalizeString(item.blocked_reason) || 'unknown',
|
|
81
|
+
blockedCount: 1,
|
|
82
|
+
updatedAt: normalizeString(item.blocked_at) || null,
|
|
83
|
+
summary: `Local semantic publication is blocked for ${normalizeString(item.spec_id) || normalizeString(item.scene_id) || 'project scope'} (${normalizeString(item.blocked_reason) || 'unknown'}).`
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const mergeReceipts = Array.isArray(report?.central_merge?.receipts) ? report.central_merge.receipts : [];
|
|
88
|
+
for (const receipt of mergeReceipts.filter((entry) => Number(entry?.totals?.blocked || 0) > 0).slice(0, 3)) {
|
|
89
|
+
items.push({
|
|
90
|
+
id: `semantic-progress:backflow:merge:${normalizeString(receipt.spec_id) || 'unknown'}:${normalizeString(receipt.generated_at) || 'latest'}`,
|
|
91
|
+
kind: 'backflow',
|
|
92
|
+
state: 'central-merge-blocked',
|
|
93
|
+
specId: normalizeString(receipt.spec_id) || null,
|
|
94
|
+
blockedCount: Number(receipt?.totals?.blocked || 0),
|
|
95
|
+
blockedReasons: (Array.isArray(receipt.blocked) ? receipt.blocked : [])
|
|
96
|
+
.map((entry) => normalizeString(entry && entry.reason))
|
|
97
|
+
.filter(Boolean),
|
|
98
|
+
updatedAt: normalizeString(receipt.generated_at) || null,
|
|
99
|
+
summary: `Central merge is blocked for ${normalizeString(receipt.spec_id) || 'unknown spec'} with ${Number(receipt?.totals?.blocked || 0)} blocked entr${Number(receipt?.totals?.blocked || 0) === 1 ? 'y' : 'ies'}.`
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const releaseReceipts = Array.isArray(report?.central_release?.receipts) ? report.central_release.receipts : [];
|
|
104
|
+
for (const receipt of releaseReceipts.filter((entry) => Number(entry?.totals?.blocked || 0) > 0).slice(0, 3)) {
|
|
105
|
+
items.push({
|
|
106
|
+
id: `semantic-progress:backflow:release:${normalizeString(receipt.spec_id) || 'unknown'}:${normalizeString(receipt.generated_at) || 'latest'}`,
|
|
107
|
+
kind: 'backflow',
|
|
108
|
+
state: 'central-release-blocked',
|
|
109
|
+
specId: normalizeString(receipt.spec_id) || null,
|
|
110
|
+
blockedCount: Number(receipt?.totals?.blocked || 0),
|
|
111
|
+
blockedReasons: (Array.isArray(receipt.blocked) ? receipt.blocked : [])
|
|
112
|
+
.map((entry) => normalizeString(entry && entry.reason))
|
|
113
|
+
.filter(Boolean),
|
|
114
|
+
updatedAt: normalizeString(receipt.generated_at) || null,
|
|
115
|
+
summary: `Approved-central release is blocked for ${normalizeString(receipt.spec_id) || 'unknown spec'} with ${Number(receipt?.totals?.blocked || 0)} blocked entr${Number(receipt?.totals?.blocked || 0) === 1 ? 'y' : 'ies'}.`
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return items;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function buildArchiveOperatorItems(report = {}) {
|
|
123
|
+
const items = [];
|
|
124
|
+
const libraries = Array.isArray(report.by_library) ? report.by_library : [];
|
|
125
|
+
for (const item of libraries.filter((entry) => (
|
|
126
|
+
Number(entry.lesson_count || 0) > 0
|
|
127
|
+
|| Number(entry.ledger_count || 0) > 0
|
|
128
|
+
)).slice(0, 3)) {
|
|
129
|
+
items.push({
|
|
130
|
+
id: `semantic-progress:archive:${normalizeString(item.target_library) || 'unknown'}`,
|
|
131
|
+
kind: 'archive',
|
|
132
|
+
state: Number(item.published_shared_count || 0) > 0 ? 'shared-accumulating' : 'local-accumulating',
|
|
133
|
+
targetLibrary: normalizeString(item.target_library) || null,
|
|
134
|
+
publishPendingCount: Number(item.publish_pending_count || 0),
|
|
135
|
+
publishBlockedCount: Number(item.publish_blocked_count || 0),
|
|
136
|
+
sessionId: null,
|
|
137
|
+
specId: null,
|
|
138
|
+
updatedAt: null,
|
|
139
|
+
summary: `${normalizeString(item.target_library) || 'unknown'} is accumulating ${Number(item.lesson_count || 0)} lesson(s) and ${Number(item.ledger_count || 0)} ledger row(s).`
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (Number(report?.totals?.missing_archive_count || 0) > 0) {
|
|
144
|
+
items.push({
|
|
145
|
+
id: 'semantic-progress:archive:missing-routing',
|
|
146
|
+
kind: 'archive',
|
|
147
|
+
state: 'archive-routing-missing',
|
|
148
|
+
missingArchiveCount: Number(report.totals.missing_archive_count || 0),
|
|
149
|
+
updatedAt: normalizeString(report.generated_at) || null,
|
|
150
|
+
summary: `${Number(report.totals.missing_archive_count || 0)} archive item(s) are missing normalized routing metadata.`
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return items;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function buildSharedSourceOperatorItems(projection = {}, specId = '') {
|
|
158
|
+
const normalizedSpecId = normalizeString(specId);
|
|
159
|
+
const items = Array.isArray(projection.items) ? projection.items : [];
|
|
160
|
+
return items
|
|
161
|
+
.filter((item) => item.approved && !item.connected)
|
|
162
|
+
.filter((item) => !normalizedSpecId || normalizeString(item.spec_id) === normalizedSpecId)
|
|
163
|
+
.map((item) => ({
|
|
164
|
+
id: `semantic-progress:shared-source:${normalizeString(item.source_name) || 'source'}:${normalizeString(item.descriptor_file) || 'descriptor'}`,
|
|
165
|
+
kind: 'info',
|
|
166
|
+
state: 'pending-connect',
|
|
167
|
+
specId: normalizeString(item.spec_id) || null,
|
|
168
|
+
descriptorFile: normalizeString(item.descriptor_file) || null,
|
|
169
|
+
sourceName: normalizeString(item.source_name) || null,
|
|
170
|
+
suggestedConnectCommand: normalizeString(item.suggested_connect_command) || null,
|
|
171
|
+
updatedAt: normalizeString(item.updated_at) || null,
|
|
172
|
+
summary: `Approved semantic shared source ${normalizeString(item.source_name) || 'source'} is available but not connected.`
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function buildSemanticProgressReport(options = {}, dependencies = {}) {
|
|
177
|
+
const projectPath = dependencies.projectPath || process.cwd();
|
|
178
|
+
const store = dependencies.stateStore || getSceStateStore(projectPath, {
|
|
179
|
+
fileSystem: dependencies.fileSystem,
|
|
180
|
+
env: dependencies.env,
|
|
181
|
+
sqliteModule: dependencies.sqliteModule,
|
|
182
|
+
noCache: dependencies.noCache === true
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const projectId = normalizeString(options.project_id || options.projectId);
|
|
186
|
+
const specId = normalizeString(options.spec_id || options.specId);
|
|
187
|
+
const sessionId = normalizeString(options.session_id || options.sessionId);
|
|
188
|
+
const scanLimit = normalizeInteger(options.limit, 500);
|
|
189
|
+
|
|
190
|
+
let observations = await store.listSemanticObservations({
|
|
191
|
+
project_id: projectId,
|
|
192
|
+
session_id: sessionId,
|
|
193
|
+
limit: scanLimit
|
|
194
|
+
});
|
|
195
|
+
observations = Array.isArray(observations) ? observations : [];
|
|
196
|
+
if (specId) {
|
|
197
|
+
observations = observations.filter((item) => normalizeString(item.spec_id) === specId);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
let lessons = await store.listSemanticLessonCandidates({
|
|
201
|
+
project_id: projectId,
|
|
202
|
+
limit: scanLimit
|
|
203
|
+
});
|
|
204
|
+
lessons = Array.isArray(lessons) ? lessons : [];
|
|
205
|
+
if (specId) {
|
|
206
|
+
lessons = lessons.filter((item) => normalizeString(item.spec_id) === specId);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
let evaluationRuns = await store.listSemanticEvaluationRuns({
|
|
210
|
+
project_id: projectId,
|
|
211
|
+
session_id: sessionId,
|
|
212
|
+
spec_id: specId,
|
|
213
|
+
limit: scanLimit
|
|
214
|
+
});
|
|
215
|
+
evaluationRuns = Array.isArray(evaluationRuns) ? evaluationRuns : [];
|
|
216
|
+
|
|
217
|
+
let capabilityLedgers = await store.listSemanticCapabilityLedgers({
|
|
218
|
+
project_id: projectId,
|
|
219
|
+
spec_id: specId,
|
|
220
|
+
limit: scanLimit
|
|
221
|
+
});
|
|
222
|
+
capabilityLedgers = Array.isArray(capabilityLedgers) ? capabilityLedgers : [];
|
|
223
|
+
if (sessionId) {
|
|
224
|
+
capabilityLedgers = capabilityLedgers.filter((item) => normalizeString(item.session_id) === sessionId);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
let supremeIntentAssessments = await store.listSupremeIntentAssessments({
|
|
228
|
+
project_id: projectId,
|
|
229
|
+
session_id: sessionId,
|
|
230
|
+
spec_id: specId,
|
|
231
|
+
limit: scanLimit
|
|
232
|
+
});
|
|
233
|
+
supremeIntentAssessments = Array.isArray(supremeIntentAssessments) ? supremeIntentAssessments : [];
|
|
234
|
+
|
|
235
|
+
const nativeObservations = observations.filter((item) => normalizeString(item.source_runtime) === 'sce-native');
|
|
236
|
+
const nativePromptCount = nativeObservations.filter((item) => normalizeString(item.event_kind) === 'prompt').length;
|
|
237
|
+
const nativeReplyItems = nativeObservations.filter((item) => normalizeString(item.event_kind) === 'reply');
|
|
238
|
+
const activatedReplyItems = nativeReplyItems.filter((item) => {
|
|
239
|
+
const metadata = readObservationMetadata(item);
|
|
240
|
+
return Array.isArray(metadata.activated_lesson_ids) && metadata.activated_lesson_ids.length > 0;
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const activatedCapabilityIds = new Set();
|
|
244
|
+
for (const item of activatedReplyItems) {
|
|
245
|
+
const metadata = readObservationMetadata(item);
|
|
246
|
+
const ids = Array.isArray(metadata.activated_capability_ids)
|
|
247
|
+
? metadata.activated_capability_ids
|
|
248
|
+
: (Array.isArray(metadata.activated_lesson_ids) ? metadata.activated_lesson_ids : []);
|
|
249
|
+
for (const id of ids) {
|
|
250
|
+
const normalizedId = normalizeString(id);
|
|
251
|
+
if (normalizedId) {
|
|
252
|
+
activatedCapabilityIds.add(normalizedId);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const promotedLessons = lessons.filter((item) => ['promoted', 'promoted-local', 'published-shared', 'publish_pending'].includes(normalizeString(item.status)));
|
|
258
|
+
const deprecatedLessons = lessons.filter((item) => normalizeString(item.status) === 'deprecated');
|
|
259
|
+
const candidateLessons = lessons.filter((item) => normalizeString(item.status) === 'candidate');
|
|
260
|
+
const publishPendingLessons = lessons.filter((item) => readLessonPublishState(item) === 'pending' || normalizeString(item.status) === 'publish_pending');
|
|
261
|
+
const publishedSharedLessons = lessons.filter((item) => readLessonPublishState(item) === 'published-shared' || normalizeString(item.status) === 'published-shared');
|
|
262
|
+
const publishBlockedLessons = lessons.filter((item) => readLessonPublishState(item) === 'blocked' || normalizeString(item.status) === 'publish_blocked');
|
|
263
|
+
const passedEvaluations = evaluationRuns.filter((item) => normalizeString(item.verdict) === 'passed');
|
|
264
|
+
const failedEvaluations = evaluationRuns.filter((item) => normalizeString(item.verdict) === 'failed');
|
|
265
|
+
const regressionEvaluations = evaluationRuns.filter((item) => item.regression_detected === true);
|
|
266
|
+
const activeCapabilities = capabilityLedgers.filter((item) => normalizeString(item.capability_status) === 'active');
|
|
267
|
+
const quarantinedCapabilities = capabilityLedgers.filter((item) => normalizeString(item.capability_status) === 'quarantined');
|
|
268
|
+
const deprecatedCapabilities = capabilityLedgers.filter((item) => normalizeString(item.capability_status) === 'deprecated');
|
|
269
|
+
const blockedCapabilities = capabilityLedgers.filter((item) => normalizeString(item.publish_state) === 'blocked');
|
|
270
|
+
const governancePenalizedCapabilities = capabilityLedgers.filter((item) => Number(item.metrics && item.metrics.governance_penalty_score) > 0);
|
|
271
|
+
const governanceHighRiskCapabilities = capabilityLedgers.filter((item) => Number(item.metrics && item.metrics.governance_penalty_score) >= 20);
|
|
272
|
+
const supremeAllow = supremeIntentAssessments.filter((item) => normalizeString(item.action) === 'allow');
|
|
273
|
+
const supremeClarify = supremeIntentAssessments.filter((item) => normalizeString(item.action) === 'clarify');
|
|
274
|
+
const supremeRewrite = supremeIntentAssessments.filter((item) => normalizeString(item.action) === 'rewrite');
|
|
275
|
+
const supremeNarrow = supremeIntentAssessments.filter((item) => normalizeString(item.action) === 'narrow');
|
|
276
|
+
const supremeRefuse = supremeIntentAssessments.filter((item) => normalizeString(item.action) === 'refuse');
|
|
277
|
+
const planningBlocked = supremeIntentAssessments.filter((item) => item.planning_allowed !== true);
|
|
278
|
+
const executionBlocked = supremeIntentAssessments.filter((item) => item.execution_allowed !== true);
|
|
279
|
+
|
|
280
|
+
const supremeBySource = {};
|
|
281
|
+
for (const item of supremeIntentAssessments) {
|
|
282
|
+
const sourceKind = normalizeString(item.source_kind) || 'unknown';
|
|
283
|
+
supremeBySource[sourceKind] = (supremeBySource[sourceKind] || 0) + 1;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const runtimeBreakdown = {};
|
|
287
|
+
for (const item of observations) {
|
|
288
|
+
const runtime = normalizeString(item.source_runtime) || 'unknown';
|
|
289
|
+
runtimeBreakdown[runtime] = (runtimeBreakdown[runtime] || 0) + 1;
|
|
290
|
+
}
|
|
291
|
+
const archiveSummary = buildSemanticArchiveSummary({
|
|
292
|
+
lessons,
|
|
293
|
+
capabilityLedgers,
|
|
294
|
+
recent_limit: 10
|
|
295
|
+
});
|
|
296
|
+
const governanceReport = await buildSupremeIntentGovernanceReport({
|
|
297
|
+
project_id: projectId,
|
|
298
|
+
spec_id: specId,
|
|
299
|
+
session_id: sessionId,
|
|
300
|
+
limit: scanLimit,
|
|
301
|
+
hotspot_limit: 3,
|
|
302
|
+
recent_limit: 5
|
|
303
|
+
}, dependencies);
|
|
304
|
+
const backflowReport = await buildSemanticBackflowReport({
|
|
305
|
+
project_id: projectId,
|
|
306
|
+
spec_id: specId,
|
|
307
|
+
limit: scanLimit,
|
|
308
|
+
recent_limit: 5
|
|
309
|
+
}, dependencies);
|
|
310
|
+
const archiveReport = await buildSemanticArchiveReport({
|
|
311
|
+
project_id: projectId,
|
|
312
|
+
spec_id: specId,
|
|
313
|
+
session_id: sessionId,
|
|
314
|
+
limit: scanLimit,
|
|
315
|
+
recent_limit: 5
|
|
316
|
+
}, dependencies);
|
|
317
|
+
const semanticSharedSources = await buildSemanticSharedSourceProjection(projectPath, {
|
|
318
|
+
fileSystem: dependencies.fileSystem
|
|
319
|
+
});
|
|
320
|
+
const operatorItems = [
|
|
321
|
+
...buildGovernanceOperatorItems(governanceReport),
|
|
322
|
+
...buildBackflowOperatorItems(backflowReport),
|
|
323
|
+
...buildArchiveOperatorItems(archiveReport),
|
|
324
|
+
...buildSharedSourceOperatorItems(semanticSharedSources, specId)
|
|
325
|
+
];
|
|
326
|
+
const operatorProjection = buildSupervisionActionQueue(operatorItems, {
|
|
327
|
+
projectId
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const funnel = {
|
|
331
|
+
observations: observations.length,
|
|
332
|
+
lesson_candidates: lessons.length,
|
|
333
|
+
evaluation_runs: evaluationRuns.length,
|
|
334
|
+
promoted_capabilities: promotedLessons.length,
|
|
335
|
+
native_activated_replies: activatedReplyItems.length,
|
|
336
|
+
supreme_intent_assessments: supremeIntentAssessments.length
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
return {
|
|
340
|
+
mode: 'semantic-progress',
|
|
341
|
+
success: true,
|
|
342
|
+
generated_at: new Date().toISOString(),
|
|
343
|
+
filters: {
|
|
344
|
+
project_id: projectId || null,
|
|
345
|
+
spec_id: specId || null,
|
|
346
|
+
session_id: sessionId || null,
|
|
347
|
+
limit: scanLimit
|
|
348
|
+
},
|
|
349
|
+
funnel,
|
|
350
|
+
observations: {
|
|
351
|
+
total: observations.length,
|
|
352
|
+
native_total: nativeObservations.length,
|
|
353
|
+
native_prompt_count: nativePromptCount,
|
|
354
|
+
native_reply_count: nativeReplyItems.length,
|
|
355
|
+
runtime_breakdown: runtimeBreakdown
|
|
356
|
+
},
|
|
357
|
+
lesson_candidates: {
|
|
358
|
+
total: lessons.length,
|
|
359
|
+
candidate: candidateLessons.length,
|
|
360
|
+
promoted: promotedLessons.length,
|
|
361
|
+
deprecated: deprecatedLessons.length,
|
|
362
|
+
publish_pending: publishPendingLessons.length,
|
|
363
|
+
published_shared: publishedSharedLessons.length,
|
|
364
|
+
publish_blocked: publishBlockedLessons.length
|
|
365
|
+
},
|
|
366
|
+
evaluation: {
|
|
367
|
+
total: evaluationRuns.length,
|
|
368
|
+
passed: passedEvaluations.length,
|
|
369
|
+
failed: failedEvaluations.length,
|
|
370
|
+
regressions: regressionEvaluations.length,
|
|
371
|
+
pass_rate_percent: percent(passedEvaluations.length, evaluationRuns.length),
|
|
372
|
+
regression_rate_percent: percent(regressionEvaluations.length, evaluationRuns.length)
|
|
373
|
+
},
|
|
374
|
+
capability_ledger: {
|
|
375
|
+
total: capabilityLedgers.length,
|
|
376
|
+
active: activeCapabilities.length,
|
|
377
|
+
quarantined: quarantinedCapabilities.length,
|
|
378
|
+
deprecated: deprecatedCapabilities.length,
|
|
379
|
+
publish_blocked: blockedCapabilities.length,
|
|
380
|
+
governance_penalized: governancePenalizedCapabilities.length,
|
|
381
|
+
governance_high_risk: governanceHighRiskCapabilities.length
|
|
382
|
+
},
|
|
383
|
+
supreme_intent: {
|
|
384
|
+
total: supremeIntentAssessments.length,
|
|
385
|
+
allow: supremeAllow.length,
|
|
386
|
+
clarify: supremeClarify.length,
|
|
387
|
+
rewrite: supremeRewrite.length,
|
|
388
|
+
narrow: supremeNarrow.length,
|
|
389
|
+
refuse: supremeRefuse.length,
|
|
390
|
+
planning_blocked: planningBlocked.length,
|
|
391
|
+
execution_blocked: executionBlocked.length,
|
|
392
|
+
by_source: supremeBySource,
|
|
393
|
+
governed_action_rate_percent: percent(
|
|
394
|
+
supremeClarify.length + supremeRewrite.length + supremeNarrow.length + supremeRefuse.length,
|
|
395
|
+
supremeIntentAssessments.length
|
|
396
|
+
)
|
|
397
|
+
},
|
|
398
|
+
native_backflow: {
|
|
399
|
+
activated_reply_count: activatedReplyItems.length,
|
|
400
|
+
activation_hit_rate_percent: percent(activatedReplyItems.length, nativeReplyItems.length),
|
|
401
|
+
activated_capability_count: activatedCapabilityIds.size,
|
|
402
|
+
activated_capability_ids: [...activatedCapabilityIds].sort()
|
|
403
|
+
},
|
|
404
|
+
archive: archiveSummary,
|
|
405
|
+
shared_sources: semanticSharedSources.summary,
|
|
406
|
+
operator_items: operatorProjection.items,
|
|
407
|
+
action_queue: operatorProjection.actionQueue,
|
|
408
|
+
operator_control_plane: {
|
|
409
|
+
...operatorProjection.summary,
|
|
410
|
+
governanceHotspotCount: buildGovernanceOperatorItems(governanceReport).length,
|
|
411
|
+
backflowItemCount: buildBackflowOperatorItems(backflowReport).length,
|
|
412
|
+
archiveItemCount: buildArchiveOperatorItems(archiveReport).length,
|
|
413
|
+
pendingConnectCount: Number(semanticSharedSources.summary.pendingApprovedDescriptors || 0)
|
|
414
|
+
},
|
|
415
|
+
progress_signals: {
|
|
416
|
+
distillation_ready: lessons.length > 0,
|
|
417
|
+
evaluation_ready: evaluationRuns.length > 0,
|
|
418
|
+
promotion_ready: passedEvaluations.some((item) => item.governance && item.governance.promotion_gate_passed === true),
|
|
419
|
+
native_runtime_learning_active: nativeObservations.length > 0,
|
|
420
|
+
supreme_governance_active: supremeIntentAssessments.length > 0,
|
|
421
|
+
standalone_substitution_progress_percent: Number((
|
|
422
|
+
(percent(promotedLessons.length > 0 ? 1 : 0, 1) * 0.35)
|
|
423
|
+
+ (percent(evaluationRuns.length > 0 ? 1 : 0, 1) * 0.25)
|
|
424
|
+
+ (percent(nativeObservations.length > 0 ? 1 : 0, 1) * 0.2)
|
|
425
|
+
+ (percent(activatedReplyItems.length > 0 ? 1 : 0, 1) * 0.2)
|
|
426
|
+
).toFixed(2))
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
module.exports = {
|
|
432
|
+
buildSemanticProgressReport
|
|
433
|
+
};
|