scene-capability-engine 3.3.26 → 3.4.6
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 +82 -0
- package/README.md +100 -711
- package/README.zh.md +103 -577
- package/bin/scene-capability-engine.js +103 -0
- package/docs/README.md +47 -249
- package/docs/command-reference.md +84 -9
- package/docs/images/wechat-qr.png +0 -0
- package/docs/spec-workflow.md +35 -4
- package/docs/zh/README.md +44 -331
- package/lib/adoption/adoption-strategy.js +5 -0
- package/lib/adoption/detection-engine.js +5 -0
- package/lib/adoption/file-classifier.js +6 -1
- package/lib/adoption/smart-orchestrator.js +5 -0
- package/lib/commands/adopt.js +32 -0
- package/lib/commands/errorbook.js +551 -4
- package/lib/commands/spec-domain.js +78 -2
- package/lib/commands/studio.js +550 -9
- package/lib/commands/upgrade.js +16 -0
- package/lib/problem/problem-evaluator.js +1035 -0
- package/lib/spec/domain-modeling.js +266 -5
- package/lib/workspace/takeover-baseline.js +514 -0
- package/package.json +1 -1
- package/template/.sce/config/problem-closure-policy.json +18 -0
- package/template/.sce/config/problem-eval-policy.json +78 -0
- package/template/.sce/config/session-governance.json +8 -0
- package/template/.sce/config/spec-domain-policy.json +14 -0
- package/template/.sce/config/takeover-baseline.json +33 -0
- package/template/.sce/steering/CORE_PRINCIPLES.md +4 -2
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { mergeConfigs } = require('../auto/config-schema');
|
|
4
|
+
const {
|
|
5
|
+
SteeringContract,
|
|
6
|
+
DEFAULT_LAYER_FILES,
|
|
7
|
+
MANIFEST_FILENAME,
|
|
8
|
+
SCE_STEERING_DIR,
|
|
9
|
+
} = require('../runtime/steering-contract');
|
|
10
|
+
|
|
11
|
+
const TAKEOVER_BASELINE_SCHEMA_VERSION = '1.0';
|
|
12
|
+
|
|
13
|
+
const SESSION_GOVERNANCE_DEFAULTS = Object.freeze({
|
|
14
|
+
schema_version: '1.0',
|
|
15
|
+
scene_primary_session_required: true,
|
|
16
|
+
one_scene_one_primary_session: true,
|
|
17
|
+
spec_runs_bind_child_session: true,
|
|
18
|
+
scene_completion_auto_rollover: true,
|
|
19
|
+
auto_archive_spec_sessions: true
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const SPEC_DOMAIN_POLICY_DEFAULTS = Object.freeze({
|
|
23
|
+
schema_version: '1.0',
|
|
24
|
+
closed_loop_research_required: true,
|
|
25
|
+
coverage_validation_required: true,
|
|
26
|
+
fail_on_gap_default: true,
|
|
27
|
+
problem_contract_required: true,
|
|
28
|
+
ontology_axes_required: ['entity', 'relation', 'business_rule', 'decision_policy', 'execution_flow']
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const PROBLEM_EVAL_POLICY_DEFAULTS = Object.freeze({
|
|
32
|
+
schema_version: '1.0',
|
|
33
|
+
enabled: true,
|
|
34
|
+
mode: 'required',
|
|
35
|
+
enforce_on_stages: ['plan', 'generate', 'apply', 'verify', 'release'],
|
|
36
|
+
block_on_stages: ['apply', 'release'],
|
|
37
|
+
min_confidence_by_stage: {
|
|
38
|
+
plan: 20,
|
|
39
|
+
generate: 25,
|
|
40
|
+
apply: 30,
|
|
41
|
+
verify: 35,
|
|
42
|
+
release: 40
|
|
43
|
+
},
|
|
44
|
+
high_risk_requires_debug_evidence: true,
|
|
45
|
+
high_risk_keywords: [
|
|
46
|
+
'auth',
|
|
47
|
+
'payment',
|
|
48
|
+
'security',
|
|
49
|
+
'delete',
|
|
50
|
+
'rollback',
|
|
51
|
+
'production',
|
|
52
|
+
'migrate',
|
|
53
|
+
'compliance',
|
|
54
|
+
'data-loss'
|
|
55
|
+
],
|
|
56
|
+
recommendation_limit: 6,
|
|
57
|
+
max_failed_rounds_before_debug: 2,
|
|
58
|
+
problem_contract_required_stages: ['plan', 'generate', 'apply', 'verify', 'release'],
|
|
59
|
+
problem_contract_block_stages: ['plan', 'apply', 'release'],
|
|
60
|
+
ontology_alignment_required_stages: ['plan', 'generate', 'apply', 'verify', 'release'],
|
|
61
|
+
ontology_alignment_block_stages: ['apply', 'release'],
|
|
62
|
+
ontology_required_axes: ['entity', 'relation', 'business_rule', 'decision_policy', 'execution_flow'],
|
|
63
|
+
require_ontology_evidence_binding: true,
|
|
64
|
+
ontology_evidence_min_bindings: 1,
|
|
65
|
+
convergence_required_stages: ['verify', 'release'],
|
|
66
|
+
convergence_block_stages: ['release'],
|
|
67
|
+
release_block_on_high_alerts: true,
|
|
68
|
+
release_require_governance_report: false
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const PROBLEM_CLOSURE_POLICY_DEFAULTS = Object.freeze({
|
|
72
|
+
schema_version: '1.0',
|
|
73
|
+
enabled: true,
|
|
74
|
+
governance_report_path: '.sce/reports/interactive-governance-report.json',
|
|
75
|
+
verify: {
|
|
76
|
+
require_problem_contract: true,
|
|
77
|
+
require_domain_validation: true,
|
|
78
|
+
require_domain_coverage: true
|
|
79
|
+
},
|
|
80
|
+
release: {
|
|
81
|
+
require_problem_contract: true,
|
|
82
|
+
require_domain_validation: true,
|
|
83
|
+
require_domain_coverage: true,
|
|
84
|
+
require_verify_report: true,
|
|
85
|
+
require_governance_report: false,
|
|
86
|
+
block_on_high_governance_alerts: true
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const TAKEOVER_DEFAULTS = Object.freeze({
|
|
91
|
+
autonomous: {
|
|
92
|
+
enabled: true,
|
|
93
|
+
mode: 'aggressive',
|
|
94
|
+
require_step_confirmation: false,
|
|
95
|
+
apply_all_work_by_default: true
|
|
96
|
+
},
|
|
97
|
+
session_governance: {
|
|
98
|
+
scene_primary_session_required: true,
|
|
99
|
+
one_scene_one_primary_session: true,
|
|
100
|
+
spec_runs_bind_child_session: true,
|
|
101
|
+
scene_completion_auto_rollover: true
|
|
102
|
+
},
|
|
103
|
+
spec_domain_policy: {
|
|
104
|
+
closed_loop_research_required: true,
|
|
105
|
+
coverage_validation_required: true,
|
|
106
|
+
fail_on_gap_default: true,
|
|
107
|
+
problem_contract_required: true,
|
|
108
|
+
ontology_axes_required: ['entity', 'relation', 'business_rule', 'decision_policy', 'execution_flow']
|
|
109
|
+
},
|
|
110
|
+
problem_evaluation: {
|
|
111
|
+
enabled: true,
|
|
112
|
+
mode: 'required',
|
|
113
|
+
enforce_on_stages: ['plan', 'generate', 'apply', 'verify', 'release'],
|
|
114
|
+
block_on_stages: ['apply', 'release'],
|
|
115
|
+
problem_contract_required_stages: ['plan', 'generate', 'apply', 'verify', 'release'],
|
|
116
|
+
problem_contract_block_stages: ['plan', 'apply', 'release'],
|
|
117
|
+
ontology_alignment_required_stages: ['plan', 'generate', 'apply', 'verify', 'release'],
|
|
118
|
+
ontology_alignment_block_stages: ['apply', 'release'],
|
|
119
|
+
convergence_required_stages: ['verify', 'release'],
|
|
120
|
+
convergence_block_stages: ['release'],
|
|
121
|
+
max_failed_rounds_before_debug: 2
|
|
122
|
+
},
|
|
123
|
+
problem_closure: {
|
|
124
|
+
enabled: true,
|
|
125
|
+
governance_report_path: '.sce/reports/interactive-governance-report.json',
|
|
126
|
+
verify: {
|
|
127
|
+
require_problem_contract: true,
|
|
128
|
+
require_domain_validation: true,
|
|
129
|
+
require_domain_coverage: true
|
|
130
|
+
},
|
|
131
|
+
release: {
|
|
132
|
+
require_problem_contract: true,
|
|
133
|
+
require_domain_validation: true,
|
|
134
|
+
require_domain_coverage: true,
|
|
135
|
+
require_verify_report: true,
|
|
136
|
+
require_governance_report: false,
|
|
137
|
+
block_on_high_governance_alerts: true
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
debug_policy: {
|
|
141
|
+
prioritize_root_cause_fix: true,
|
|
142
|
+
max_direct_fix_rounds_before_debug: 2,
|
|
143
|
+
forbid_bypass_workarounds: true
|
|
144
|
+
},
|
|
145
|
+
migration_policy: {
|
|
146
|
+
legacy_kiro_supported: false,
|
|
147
|
+
require_manual_legacy_migration_confirmation: true
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
function _toRelativePosix(projectPath, absolutePath) {
|
|
152
|
+
return path.relative(projectPath, absolutePath).replace(/\\/g, '/');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function _isObject(value) {
|
|
156
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function _clone(value) {
|
|
160
|
+
return JSON.parse(JSON.stringify(value));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function _deepEqual(left, right) {
|
|
164
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function _deepMerge(base, patch) {
|
|
168
|
+
const output = _isObject(base) ? _clone(base) : {};
|
|
169
|
+
if (!_isObject(patch)) {
|
|
170
|
+
return output;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
174
|
+
if (_isObject(value)) {
|
|
175
|
+
output[key] = _deepMerge(output[key], value);
|
|
176
|
+
} else {
|
|
177
|
+
output[key] = value;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return output;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function _readJsonSafe(filePath, fileSystem) {
|
|
184
|
+
if (!await fileSystem.pathExists(filePath)) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
return await fileSystem.readJson(filePath);
|
|
189
|
+
} catch (_error) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function _buildAutoConfig(existing) {
|
|
195
|
+
const merged = mergeConfigs({}, _isObject(existing) ? existing : {});
|
|
196
|
+
merged.mode = 'aggressive';
|
|
197
|
+
merged.checkpoints = {
|
|
198
|
+
...(merged.checkpoints || {}),
|
|
199
|
+
requirementsReview: false,
|
|
200
|
+
designReview: false,
|
|
201
|
+
tasksReview: false,
|
|
202
|
+
phaseCompletion: false,
|
|
203
|
+
finalReview: false
|
|
204
|
+
};
|
|
205
|
+
merged.errorRecovery = {
|
|
206
|
+
...(merged.errorRecovery || {}),
|
|
207
|
+
enabled: true,
|
|
208
|
+
maxAttempts: Math.max(3, Number(merged?.errorRecovery?.maxAttempts || 0) || 0)
|
|
209
|
+
};
|
|
210
|
+
merged.performance = {
|
|
211
|
+
...(merged.performance || {}),
|
|
212
|
+
maxConcurrentTasks: Math.max(1, Number(merged?.performance?.maxConcurrentTasks || 0) || 1)
|
|
213
|
+
};
|
|
214
|
+
merged.takeover = {
|
|
215
|
+
managed: true,
|
|
216
|
+
require_step_confirmation: false,
|
|
217
|
+
apply_all_work_by_default: true
|
|
218
|
+
};
|
|
219
|
+
return merged;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function _buildAdoptionConfig(existing, nowIso, sceVersion) {
|
|
223
|
+
const base = _isObject(existing) ? _clone(existing) : {};
|
|
224
|
+
const adoptedAt = typeof base.adoptedAt === 'string' && base.adoptedAt.trim()
|
|
225
|
+
? base.adoptedAt
|
|
226
|
+
: nowIso;
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
...base,
|
|
230
|
+
version: typeof base.version === 'string' && base.version.trim() ? base.version : '1.0.0',
|
|
231
|
+
adoptedAt,
|
|
232
|
+
steeringStrategy: typeof base.steeringStrategy === 'string' && base.steeringStrategy.trim()
|
|
233
|
+
? base.steeringStrategy
|
|
234
|
+
: 'use-kse',
|
|
235
|
+
multiUserMode: base.multiUserMode === true,
|
|
236
|
+
runtimePolicy: {
|
|
237
|
+
agent_parity_permissions: true,
|
|
238
|
+
autonomous_default: true
|
|
239
|
+
},
|
|
240
|
+
takeover: {
|
|
241
|
+
managed: true,
|
|
242
|
+
schema_version: TAKEOVER_BASELINE_SCHEMA_VERSION,
|
|
243
|
+
auto_detect_on_startup: true,
|
|
244
|
+
legacy_kiro_supported: false
|
|
245
|
+
},
|
|
246
|
+
defaults: _clone(TAKEOVER_DEFAULTS),
|
|
247
|
+
lastAlignedSceVersion: sceVersion
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function _buildTakeoverBaselineConfig(existing, sceVersion) {
|
|
252
|
+
const base = _isObject(existing) ? _clone(existing) : {};
|
|
253
|
+
return {
|
|
254
|
+
...base,
|
|
255
|
+
schema_version: TAKEOVER_BASELINE_SCHEMA_VERSION,
|
|
256
|
+
engine: 'sce',
|
|
257
|
+
managed: true,
|
|
258
|
+
last_aligned_sce_version: sceVersion,
|
|
259
|
+
defaults: _clone(TAKEOVER_DEFAULTS)
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async function _reconcileJsonFile(filePath, desired, options = {}) {
|
|
264
|
+
const {
|
|
265
|
+
projectPath,
|
|
266
|
+
apply,
|
|
267
|
+
fileSystem,
|
|
268
|
+
managedBy = 'takeover-baseline'
|
|
269
|
+
} = options;
|
|
270
|
+
const existing = await _readJsonSafe(filePath, fileSystem);
|
|
271
|
+
const existed = existing !== null;
|
|
272
|
+
const changed = !existed || !_deepEqual(existing, desired);
|
|
273
|
+
|
|
274
|
+
if (apply && changed) {
|
|
275
|
+
await fileSystem.ensureDir(path.dirname(filePath));
|
|
276
|
+
await fileSystem.writeJson(filePath, desired, { spaces: 2 });
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
path: _toRelativePosix(projectPath, filePath),
|
|
281
|
+
existed,
|
|
282
|
+
changed,
|
|
283
|
+
status: existed ? (changed ? 'updated' : 'unchanged') : (changed ? 'created' : 'unchanged'),
|
|
284
|
+
managed_by: managedBy
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async function _inspectSteeringState(projectPath, fileSystem) {
|
|
289
|
+
const steeringDir = path.join(projectPath, SCE_STEERING_DIR);
|
|
290
|
+
const manifestPath = path.join(steeringDir, MANIFEST_FILENAME);
|
|
291
|
+
const layers = Object.values(DEFAULT_LAYER_FILES).map((filename) => path.join(steeringDir, filename));
|
|
292
|
+
const files = [manifestPath, ...layers];
|
|
293
|
+
let missing = 0;
|
|
294
|
+
for (const filePath of files) {
|
|
295
|
+
if (!await fileSystem.pathExists(filePath)) {
|
|
296
|
+
missing += 1;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
steeringDir,
|
|
301
|
+
manifestPath,
|
|
302
|
+
layerFiles: layers,
|
|
303
|
+
missing
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
async function _reconcileSteeringContract(projectPath, options = {}) {
|
|
308
|
+
const { apply, fileSystem } = options;
|
|
309
|
+
const before = await _inspectSteeringState(projectPath, fileSystem);
|
|
310
|
+
let ensureResult = null;
|
|
311
|
+
if (apply) {
|
|
312
|
+
const contract = new SteeringContract(projectPath);
|
|
313
|
+
ensureResult = await contract.ensureContract();
|
|
314
|
+
}
|
|
315
|
+
const after = await _inspectSteeringState(projectPath, fileSystem);
|
|
316
|
+
const changed = before.missing !== after.missing;
|
|
317
|
+
|
|
318
|
+
return {
|
|
319
|
+
path: _toRelativePosix(projectPath, before.steeringDir),
|
|
320
|
+
changed,
|
|
321
|
+
status: changed ? 'updated' : 'unchanged',
|
|
322
|
+
managed_by: 'steering-contract',
|
|
323
|
+
details: {
|
|
324
|
+
missing_before: before.missing,
|
|
325
|
+
missing_after: after.missing,
|
|
326
|
+
ensure_result: ensureResult
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function _summarize(items) {
|
|
332
|
+
const summary = {
|
|
333
|
+
created: 0,
|
|
334
|
+
updated: 0,
|
|
335
|
+
unchanged: 0,
|
|
336
|
+
pending: 0
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
for (const item of items) {
|
|
340
|
+
if (!item) {
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (item.status === 'created') {
|
|
344
|
+
summary.created += 1;
|
|
345
|
+
} else if (item.status === 'updated') {
|
|
346
|
+
summary.updated += 1;
|
|
347
|
+
} else if (item.status === 'pending') {
|
|
348
|
+
summary.pending += 1;
|
|
349
|
+
} else {
|
|
350
|
+
summary.unchanged += 1;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return summary;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function _toAuditStatus(items, apply) {
|
|
357
|
+
if (apply) {
|
|
358
|
+
return items.map((item) => item);
|
|
359
|
+
}
|
|
360
|
+
return items.map((item) => {
|
|
361
|
+
if (item.status === 'created' || item.status === 'updated') {
|
|
362
|
+
return {
|
|
363
|
+
...item,
|
|
364
|
+
status: 'pending',
|
|
365
|
+
changed: true
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
return item;
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
async function applyTakeoverBaseline(projectPath = process.cwd(), options = {}) {
|
|
373
|
+
const fileSystem = options.fileSystem || fs;
|
|
374
|
+
const apply = options.apply !== false;
|
|
375
|
+
const writeReport = options.writeReport === true;
|
|
376
|
+
const now = options.now || new Date();
|
|
377
|
+
const nowIso = typeof now.toISOString === 'function' ? now.toISOString() : new Date().toISOString();
|
|
378
|
+
const sceVersion = typeof options.sceVersion === 'string' && options.sceVersion.trim()
|
|
379
|
+
? options.sceVersion.trim()
|
|
380
|
+
: 'unknown';
|
|
381
|
+
|
|
382
|
+
const sceRoot = path.join(projectPath, '.sce');
|
|
383
|
+
if (!await fileSystem.pathExists(sceRoot)) {
|
|
384
|
+
return {
|
|
385
|
+
mode: 'workspace-takeover-baseline',
|
|
386
|
+
detected_project: false,
|
|
387
|
+
apply,
|
|
388
|
+
passed: true,
|
|
389
|
+
project_path: projectPath,
|
|
390
|
+
drift_count: 0,
|
|
391
|
+
files: [],
|
|
392
|
+
summary: {
|
|
393
|
+
created: 0,
|
|
394
|
+
updated: 0,
|
|
395
|
+
unchanged: 0,
|
|
396
|
+
pending: 0
|
|
397
|
+
},
|
|
398
|
+
message: 'No .sce directory found; takeover baseline skipped.'
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const adoptionPath = path.join(sceRoot, 'adoption-config.json');
|
|
403
|
+
const autoConfigPath = path.join(sceRoot, 'auto', 'config.json');
|
|
404
|
+
const takeoverConfigPath = path.join(sceRoot, 'config', 'takeover-baseline.json');
|
|
405
|
+
const sessionGovernancePath = path.join(sceRoot, 'config', 'session-governance.json');
|
|
406
|
+
const specDomainPolicyPath = path.join(sceRoot, 'config', 'spec-domain-policy.json');
|
|
407
|
+
const problemEvalPolicyPath = path.join(sceRoot, 'config', 'problem-eval-policy.json');
|
|
408
|
+
const problemClosurePolicyPath = path.join(sceRoot, 'config', 'problem-closure-policy.json');
|
|
409
|
+
const reportPath = path.join(sceRoot, 'reports', 'takeover-baseline-latest.json');
|
|
410
|
+
|
|
411
|
+
const existingAdoption = await _readJsonSafe(adoptionPath, fileSystem);
|
|
412
|
+
const existingAuto = await _readJsonSafe(autoConfigPath, fileSystem);
|
|
413
|
+
const existingTakeover = await _readJsonSafe(takeoverConfigPath, fileSystem);
|
|
414
|
+
const existingSessionGovernance = await _readJsonSafe(sessionGovernancePath, fileSystem);
|
|
415
|
+
const existingSpecDomainPolicy = await _readJsonSafe(specDomainPolicyPath, fileSystem);
|
|
416
|
+
const existingProblemEvalPolicy = await _readJsonSafe(problemEvalPolicyPath, fileSystem);
|
|
417
|
+
const existingProblemClosurePolicy = await _readJsonSafe(problemClosurePolicyPath, fileSystem);
|
|
418
|
+
|
|
419
|
+
const desiredAdoption = _buildAdoptionConfig(existingAdoption, nowIso, sceVersion);
|
|
420
|
+
const desiredAutoConfig = _buildAutoConfig(existingAuto);
|
|
421
|
+
const desiredTakeover = _buildTakeoverBaselineConfig(existingTakeover, sceVersion);
|
|
422
|
+
const desiredSessionGovernance = _deepMerge(existingSessionGovernance || {}, SESSION_GOVERNANCE_DEFAULTS);
|
|
423
|
+
const desiredSpecDomainPolicy = _deepMerge(existingSpecDomainPolicy || {}, SPEC_DOMAIN_POLICY_DEFAULTS);
|
|
424
|
+
const desiredProblemEvalPolicy = _deepMerge(existingProblemEvalPolicy || {}, PROBLEM_EVAL_POLICY_DEFAULTS);
|
|
425
|
+
const desiredProblemClosurePolicy = _deepMerge(existingProblemClosurePolicy || {}, PROBLEM_CLOSURE_POLICY_DEFAULTS);
|
|
426
|
+
|
|
427
|
+
const fileResults = [];
|
|
428
|
+
fileResults.push(await _reconcileJsonFile(adoptionPath, desiredAdoption, {
|
|
429
|
+
projectPath,
|
|
430
|
+
apply,
|
|
431
|
+
fileSystem
|
|
432
|
+
}));
|
|
433
|
+
fileResults.push(await _reconcileJsonFile(autoConfigPath, desiredAutoConfig, {
|
|
434
|
+
projectPath,
|
|
435
|
+
apply,
|
|
436
|
+
fileSystem
|
|
437
|
+
}));
|
|
438
|
+
fileResults.push(await _reconcileJsonFile(takeoverConfigPath, desiredTakeover, {
|
|
439
|
+
projectPath,
|
|
440
|
+
apply,
|
|
441
|
+
fileSystem
|
|
442
|
+
}));
|
|
443
|
+
fileResults.push(await _reconcileJsonFile(sessionGovernancePath, desiredSessionGovernance, {
|
|
444
|
+
projectPath,
|
|
445
|
+
apply,
|
|
446
|
+
fileSystem
|
|
447
|
+
}));
|
|
448
|
+
fileResults.push(await _reconcileJsonFile(specDomainPolicyPath, desiredSpecDomainPolicy, {
|
|
449
|
+
projectPath,
|
|
450
|
+
apply,
|
|
451
|
+
fileSystem
|
|
452
|
+
}));
|
|
453
|
+
fileResults.push(await _reconcileJsonFile(problemEvalPolicyPath, desiredProblemEvalPolicy, {
|
|
454
|
+
projectPath,
|
|
455
|
+
apply,
|
|
456
|
+
fileSystem
|
|
457
|
+
}));
|
|
458
|
+
fileResults.push(await _reconcileJsonFile(problemClosurePolicyPath, desiredProblemClosurePolicy, {
|
|
459
|
+
projectPath,
|
|
460
|
+
apply,
|
|
461
|
+
fileSystem
|
|
462
|
+
}));
|
|
463
|
+
fileResults.push(await _reconcileSteeringContract(projectPath, {
|
|
464
|
+
apply,
|
|
465
|
+
fileSystem
|
|
466
|
+
}));
|
|
467
|
+
|
|
468
|
+
const auditFiles = _toAuditStatus(fileResults, apply);
|
|
469
|
+
const summary = _summarize(auditFiles);
|
|
470
|
+
const driftCount = summary.pending;
|
|
471
|
+
const passed = driftCount === 0;
|
|
472
|
+
|
|
473
|
+
const report = {
|
|
474
|
+
mode: 'workspace-takeover-baseline',
|
|
475
|
+
generated_at: nowIso,
|
|
476
|
+
detected_project: true,
|
|
477
|
+
apply,
|
|
478
|
+
passed,
|
|
479
|
+
project_path: projectPath,
|
|
480
|
+
sce_version: sceVersion,
|
|
481
|
+
drift_count: driftCount,
|
|
482
|
+
enforced_defaults: _clone(TAKEOVER_DEFAULTS),
|
|
483
|
+
files: auditFiles,
|
|
484
|
+
summary
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
if (apply && writeReport) {
|
|
488
|
+
const reportExists = await fileSystem.pathExists(reportPath);
|
|
489
|
+
const shouldWriteReport = options.forceWriteReport === true
|
|
490
|
+
|| !reportExists
|
|
491
|
+
|| summary.created > 0
|
|
492
|
+
|| summary.updated > 0;
|
|
493
|
+
|
|
494
|
+
if (shouldWriteReport) {
|
|
495
|
+
await fileSystem.ensureDir(path.dirname(reportPath));
|
|
496
|
+
await fileSystem.writeJson(reportPath, report, { spaces: 2 });
|
|
497
|
+
}
|
|
498
|
+
if (reportExists || shouldWriteReport) {
|
|
499
|
+
report.report_file = _toRelativePosix(projectPath, reportPath);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return report;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
module.exports = {
|
|
507
|
+
TAKEOVER_BASELINE_SCHEMA_VERSION,
|
|
508
|
+
TAKEOVER_DEFAULTS,
|
|
509
|
+
SESSION_GOVERNANCE_DEFAULTS,
|
|
510
|
+
SPEC_DOMAIN_POLICY_DEFAULTS,
|
|
511
|
+
PROBLEM_CLOSURE_POLICY_DEFAULTS,
|
|
512
|
+
PROBLEM_EVAL_POLICY_DEFAULTS,
|
|
513
|
+
applyTakeoverBaseline
|
|
514
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": "1.0",
|
|
3
|
+
"enabled": true,
|
|
4
|
+
"governance_report_path": ".sce/reports/interactive-governance-report.json",
|
|
5
|
+
"verify": {
|
|
6
|
+
"require_problem_contract": true,
|
|
7
|
+
"require_domain_validation": true,
|
|
8
|
+
"require_domain_coverage": true
|
|
9
|
+
},
|
|
10
|
+
"release": {
|
|
11
|
+
"require_problem_contract": true,
|
|
12
|
+
"require_domain_validation": true,
|
|
13
|
+
"require_domain_coverage": true,
|
|
14
|
+
"require_verify_report": true,
|
|
15
|
+
"require_governance_report": false,
|
|
16
|
+
"block_on_high_governance_alerts": true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": "1.0",
|
|
3
|
+
"enabled": true,
|
|
4
|
+
"mode": "required",
|
|
5
|
+
"enforce_on_stages": [
|
|
6
|
+
"plan",
|
|
7
|
+
"generate",
|
|
8
|
+
"apply",
|
|
9
|
+
"verify",
|
|
10
|
+
"release"
|
|
11
|
+
],
|
|
12
|
+
"block_on_stages": [
|
|
13
|
+
"apply",
|
|
14
|
+
"release"
|
|
15
|
+
],
|
|
16
|
+
"min_confidence_by_stage": {
|
|
17
|
+
"plan": 20,
|
|
18
|
+
"generate": 25,
|
|
19
|
+
"apply": 30,
|
|
20
|
+
"verify": 35,
|
|
21
|
+
"release": 40
|
|
22
|
+
},
|
|
23
|
+
"high_risk_requires_debug_evidence": true,
|
|
24
|
+
"high_risk_keywords": [
|
|
25
|
+
"auth",
|
|
26
|
+
"payment",
|
|
27
|
+
"security",
|
|
28
|
+
"delete",
|
|
29
|
+
"rollback",
|
|
30
|
+
"production",
|
|
31
|
+
"migrate",
|
|
32
|
+
"compliance",
|
|
33
|
+
"data-loss"
|
|
34
|
+
],
|
|
35
|
+
"recommendation_limit": 6,
|
|
36
|
+
"max_failed_rounds_before_debug": 2,
|
|
37
|
+
"problem_contract_required_stages": [
|
|
38
|
+
"plan",
|
|
39
|
+
"generate",
|
|
40
|
+
"apply",
|
|
41
|
+
"verify",
|
|
42
|
+
"release"
|
|
43
|
+
],
|
|
44
|
+
"problem_contract_block_stages": [
|
|
45
|
+
"plan",
|
|
46
|
+
"apply",
|
|
47
|
+
"release"
|
|
48
|
+
],
|
|
49
|
+
"ontology_alignment_required_stages": [
|
|
50
|
+
"plan",
|
|
51
|
+
"generate",
|
|
52
|
+
"apply",
|
|
53
|
+
"verify",
|
|
54
|
+
"release"
|
|
55
|
+
],
|
|
56
|
+
"ontology_alignment_block_stages": [
|
|
57
|
+
"apply",
|
|
58
|
+
"release"
|
|
59
|
+
],
|
|
60
|
+
"ontology_required_axes": [
|
|
61
|
+
"entity",
|
|
62
|
+
"relation",
|
|
63
|
+
"business_rule",
|
|
64
|
+
"decision_policy",
|
|
65
|
+
"execution_flow"
|
|
66
|
+
],
|
|
67
|
+
"require_ontology_evidence_binding": true,
|
|
68
|
+
"ontology_evidence_min_bindings": 1,
|
|
69
|
+
"convergence_required_stages": [
|
|
70
|
+
"verify",
|
|
71
|
+
"release"
|
|
72
|
+
],
|
|
73
|
+
"convergence_block_stages": [
|
|
74
|
+
"release"
|
|
75
|
+
],
|
|
76
|
+
"release_block_on_high_alerts": true,
|
|
77
|
+
"release_require_governance_report": false
|
|
78
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": "1.0",
|
|
3
|
+
"closed_loop_research_required": true,
|
|
4
|
+
"coverage_validation_required": true,
|
|
5
|
+
"fail_on_gap_default": true,
|
|
6
|
+
"problem_contract_required": true,
|
|
7
|
+
"ontology_axes_required": [
|
|
8
|
+
"entity",
|
|
9
|
+
"relation",
|
|
10
|
+
"business_rule",
|
|
11
|
+
"decision_policy",
|
|
12
|
+
"execution_flow"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": "1.0",
|
|
3
|
+
"engine": "sce",
|
|
4
|
+
"managed": true,
|
|
5
|
+
"defaults": {
|
|
6
|
+
"autonomous": {
|
|
7
|
+
"enabled": true,
|
|
8
|
+
"mode": "aggressive",
|
|
9
|
+
"require_step_confirmation": false,
|
|
10
|
+
"apply_all_work_by_default": true
|
|
11
|
+
},
|
|
12
|
+
"session_governance": {
|
|
13
|
+
"scene_primary_session_required": true,
|
|
14
|
+
"one_scene_one_primary_session": true,
|
|
15
|
+
"spec_runs_bind_child_session": true,
|
|
16
|
+
"scene_completion_auto_rollover": true
|
|
17
|
+
},
|
|
18
|
+
"spec_domain_policy": {
|
|
19
|
+
"closed_loop_research_required": true,
|
|
20
|
+
"coverage_validation_required": true,
|
|
21
|
+
"fail_on_gap_default": true
|
|
22
|
+
},
|
|
23
|
+
"debug_policy": {
|
|
24
|
+
"prioritize_root_cause_fix": true,
|
|
25
|
+
"max_direct_fix_rounds_before_debug": 2,
|
|
26
|
+
"forbid_bypass_workarounds": true
|
|
27
|
+
},
|
|
28
|
+
"migration_policy": {
|
|
29
|
+
"legacy_kiro_supported": false,
|
|
30
|
+
"require_manual_legacy_migration_confirmation": true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -211,10 +211,12 @@
|
|
|
211
211
|
- `.sce/specs/<spec>/custom/problem-domain-map.md`
|
|
212
212
|
- `.sce/specs/<spec>/custom/scene-spec.md`
|
|
213
213
|
- `.sce/specs/<spec>/custom/problem-domain-chain.json`
|
|
214
|
+
- `.sce/specs/<spec>/custom/problem-contract.json`
|
|
214
215
|
2) `problem-domain-map` 必须包含:Root Problem、Mind Map、Layered Exploration Chain、Correction Loop
|
|
215
216
|
3) `scene-spec` 必须包含:Scene Definition、Ontology Coverage、Decision & Execution Path、Acceptance & Gate
|
|
216
|
-
4) `problem-domain-chain.json` 必须包含可机读思维链:problem/ontology/hypotheses/risks/decision_execution_path/correction_loop/verification
|
|
217
|
-
5)
|
|
217
|
+
4) `problem-domain-chain.json` 必须包含可机读思维链:problem/ontology/hypotheses/risks/decision_execution_path/correction_loop/verification/problem_contract/ontology_evidence
|
|
218
|
+
5) `problem-contract.json` 必须包含:issue_statement、expected_outcome、reproduction_steps、impact_scope、forbidden_workarounds
|
|
219
|
+
6) 默认门禁强制校验上述结构,缺失即 `no-go`(`problem-closure-gate` 在 verify/release 默认启用)
|
|
218
220
|
|
|
219
221
|
**目标**: 用全局问题域视角 + 场景契约约束,减少方向性错误与盲改,提升纠偏效率
|
|
220
222
|
|