scene-capability-engine 3.3.3 → 3.3.5
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 +21 -0
- package/docs/README.md +2 -0
- package/docs/agent-runtime/agent-result-summary-contract.schema.json +50 -0
- package/docs/agent-runtime/agent-result-summary.sample.json +11 -0
- package/docs/agent-runtime/capability-mapping-report.sample.json +42 -0
- package/docs/agent-runtime/capability-mapping-report.schema.json +136 -0
- package/docs/agent-runtime/failure-taxonomy-baseline.json +99 -0
- package/docs/agent-runtime/multi-agent-coordination-policy-baseline.json +38 -0
- package/docs/agent-runtime/strategy-routing-policy-baseline.json +24 -0
- package/docs/agent-runtime/symbol-evidence.sample.json +34 -0
- package/docs/agent-runtime/symbol-evidence.schema.json +128 -0
- package/docs/command-reference.md +64 -0
- package/docs/release-checklist.md +6 -0
- package/docs/sce-capability-matrix-e2e-example.md +94 -0
- package/docs/sce-capability-matrix-roadmap.md +48 -0
- package/docs/zh/README.md +9 -0
- package/docs/zh/release-checklist.md +6 -0
- package/lib/orchestrator/agent-spawner.js +153 -0
- package/lib/orchestrator/bootstrap-prompt-builder.js +3 -0
- package/lib/orchestrator/orchestration-engine.js +345 -1
- package/package.json +4 -1
|
@@ -143,6 +143,12 @@ Ensure:
|
|
|
143
143
|
- `KSE_RELEASE_ASSET_INTEGRITY_ENFORCE`: `true|false` (default `true`)
|
|
144
144
|
- `KSE_RELEASE_ASSET_INTEGRITY_REQUIRE_NON_EMPTY`: `true|false` (default `true`)
|
|
145
145
|
- `KSE_RELEASE_ASSET_INTEGRITY_REQUIRED_FILES`: override required asset list (comma-separated, supports `{tag}`)
|
|
146
|
+
- Optional release-asset 0-byte guard (enabled in workflow by default):
|
|
147
|
+
- `scripts/release-asset-nonempty-normalize.js` auto-fills placeholder content for optional assets such as `.lines` and `.jsonl` before GitHub Release upload.
|
|
148
|
+
- Local dry-run example:
|
|
149
|
+
- `node scripts/release-asset-nonempty-normalize.js --file .kiro/reports/release-evidence/matrix-remediation-vX.Y.Z.lines --kind lines --note "no matrix remediation items for this release" --dry-run --json`
|
|
150
|
+
- Local normalize example:
|
|
151
|
+
- `node scripts/release-asset-nonempty-normalize.js --file .kiro/reports/release-evidence/interactive-matrix-signals-vX.Y.Z.jsonl --kind jsonl --event interactive-matrix-signals --note "No interactive matrix signals collected for this release." --json`
|
|
146
152
|
- Optional local dry-run for gate history index artifact:
|
|
147
153
|
- `sce auto handoff gate-index --dir .kiro/reports/release-evidence --out .kiro/reports/release-evidence/release-gate-history.json --json`
|
|
148
154
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# SCE Capability Matrix E2E Example
|
|
2
|
+
|
|
3
|
+
This example shows one complete execution chain:
|
|
4
|
+
|
|
5
|
+
`input -> strategy decision -> symbol evidence -> failure attribution -> capability mapping -> multi-agent summary merge`
|
|
6
|
+
|
|
7
|
+
## 1) Input and Strategy Decision
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
node scripts/auto-strategy-router.js \
|
|
11
|
+
--input '{"goal_type":"bugfix","requires_write":true,"test_failures":1,"changed_files":1}' \
|
|
12
|
+
--policy-file docs/agent-runtime/strategy-routing-policy-baseline.json \
|
|
13
|
+
--json
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Expected decision: `code_fix` with reasons and next actions.
|
|
17
|
+
|
|
18
|
+
## 2) Symbol Evidence Gate
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
node scripts/symbol-evidence-locate.js \
|
|
22
|
+
--workspace . \
|
|
23
|
+
--query "approve order" \
|
|
24
|
+
--strict \
|
|
25
|
+
--json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Expected:
|
|
29
|
+
- reliable evidence => `fallback_action=allow_write`
|
|
30
|
+
- no reliable evidence => `fallback_action=block_high_risk_write` and exit code `2`
|
|
31
|
+
|
|
32
|
+
## 3) Failure Attribution and Bounded Repair
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
node scripts/failure-attribution-repair.js \
|
|
36
|
+
--error "Cannot find module @acme/order-core" \
|
|
37
|
+
--attempted-passes 0 \
|
|
38
|
+
--max-repair-passes 1 \
|
|
39
|
+
--tests "npm run test -- order-service" \
|
|
40
|
+
--json
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Expected:
|
|
44
|
+
- classification into `Failure_Taxonomy`
|
|
45
|
+
- at most one `run_repair_pass`
|
|
46
|
+
- terminal stop summary when budget is exhausted or category is non-repairable
|
|
47
|
+
|
|
48
|
+
## 4) Capability Mapping (Template + Ontology)
|
|
49
|
+
|
|
50
|
+
Prepare `mapping-input.json`:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"changes": [
|
|
55
|
+
{ "type": "entity", "name": "Order" },
|
|
56
|
+
{ "type": "business_rule", "name": "credit-check" }
|
|
57
|
+
],
|
|
58
|
+
"templates": [
|
|
59
|
+
{ "id": "scene-moqui-order-core", "capabilities": ["entity:order"] }
|
|
60
|
+
],
|
|
61
|
+
"ontology": {
|
|
62
|
+
"entities": [{ "name": "Order" }],
|
|
63
|
+
"business_rules": []
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Run report:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
node scripts/capability-mapping-report.js \
|
|
72
|
+
--input-file mapping-input.json \
|
|
73
|
+
--json
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Expected:
|
|
77
|
+
- `mapping_report[]`
|
|
78
|
+
- `missing_capabilities[]`
|
|
79
|
+
- `recommended_templates[]`
|
|
80
|
+
- `ontology_gaps[]`
|
|
81
|
+
|
|
82
|
+
## 5) Multi-Agent Merge Summary Contract
|
|
83
|
+
|
|
84
|
+
During `sce orchestrate run`, sub-agent completion is validated against:
|
|
85
|
+
|
|
86
|
+
- `docs/agent-runtime/agent-result-summary-contract.schema.json`
|
|
87
|
+
- `docs/agent-runtime/multi-agent-coordination-policy-baseline.json`
|
|
88
|
+
|
|
89
|
+
If `require_result_summary=true`, merge is blocked when:
|
|
90
|
+
- summary is missing/invalid
|
|
91
|
+
- `tests_passed < tests_run` (when enabled)
|
|
92
|
+
- unresolved conflict issues are reported (when enabled)
|
|
93
|
+
|
|
94
|
+
This enforces summary-driven, auditable merge decisions.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# SCE Capability Matrix Roadmap
|
|
2
|
+
|
|
3
|
+
This roadmap consolidates the next capability uplift priorities for SCE and maps each item to concrete deliverables.
|
|
4
|
+
|
|
5
|
+
## Priority Matrix
|
|
6
|
+
|
|
7
|
+
| Capability | Current State | Gap | Next Deliverables |
|
|
8
|
+
| --- | --- | --- | --- |
|
|
9
|
+
| Task decomposition and strategy selection | `auto close-loop`, `orchestrate`, release gates already exist | Missing explicit machine-readable strategy router for `answer_only/code_change/rollback` | `scripts/auto-strategy-router.js` + baseline policy + command-reference integration |
|
|
10
|
+
| Code retrieval and symbol-level localization | `rg`-style file search is common; orchestration has status tracking | Missing unified symbol locator contract and ranked evidence payload | add `symbol-locate` utility + evidence schema + tests |
|
|
11
|
+
| Failure attribution and self-repair | retry/backoff and recovery loops already exist in multiple flows | Missing normalized root-cause taxonomy and bounded second-pass repair contract | add failure taxonomy schema + first/second-pass repair pipeline adapter |
|
|
12
|
+
| Scene template and ontology mapping | strong scene + ontology stack exists (`scene lint/score/ontology`) | Missing cross-project mapping report from runtime changes to ontology/template assets | add mapping report generator and remediation queue sync |
|
|
13
|
+
| Multi-agent coordination strategy | orchestrator + rate-limit adaptive controls already online | Missing explicit primary/sub-agent role policy and merge-summary contract | baseline policy + required result-summary validation in orchestration path |
|
|
14
|
+
|
|
15
|
+
## Current Baseline Artifacts (This Iteration)
|
|
16
|
+
|
|
17
|
+
- `scripts/auto-strategy-router.js`
|
|
18
|
+
- `scripts/symbol-evidence-locate.js`
|
|
19
|
+
- `scripts/failure-attribution-repair.js`
|
|
20
|
+
- `scripts/capability-mapping-report.js`
|
|
21
|
+
- `docs/agent-runtime/strategy-routing-policy-baseline.json`
|
|
22
|
+
- `docs/agent-runtime/symbol-evidence.schema.json`
|
|
23
|
+
- `docs/agent-runtime/failure-taxonomy-baseline.json`
|
|
24
|
+
- `docs/agent-runtime/capability-mapping-report.schema.json`
|
|
25
|
+
- `docs/agent-runtime/agent-result-summary-contract.schema.json`
|
|
26
|
+
- `docs/agent-runtime/multi-agent-coordination-policy-baseline.json`
|
|
27
|
+
- `docs/sce-capability-matrix-e2e-example.md`
|
|
28
|
+
|
|
29
|
+
## Execution Plan
|
|
30
|
+
|
|
31
|
+
1. Phase 1: Strategy and safety routing
|
|
32
|
+
- ship strategy router and policy file integration in autonomous entrypoints.
|
|
33
|
+
2. Phase 2: Symbol evidence pipeline
|
|
34
|
+
- provide deterministic `query -> symbols -> evidence` payload for repair and explanation flows.
|
|
35
|
+
3. Phase 3: Failure attribution and bounded self-repair
|
|
36
|
+
- classify failures, apply one focused patch pass, rerun scoped tests, stop on bounded retries.
|
|
37
|
+
4. Phase 4: Scene/Ontology cross-project mapping
|
|
38
|
+
- generate actionable mapping deltas from project changes to reusable scene assets.
|
|
39
|
+
5. Phase 5: Multi-agent merge governance
|
|
40
|
+
- enforce result summary contract and role-based decision merge.
|
|
41
|
+
|
|
42
|
+
## Success Criteria
|
|
43
|
+
|
|
44
|
+
- Strategy router decision accuracy >= 90% on curated regression fixture set.
|
|
45
|
+
- Symbol localization response includes at least one valid evidence hit for >= 95% supported queries.
|
|
46
|
+
- Self-repair flow reduces unresolved test failures by >= 30% in bounded second-pass runs.
|
|
47
|
+
- Scene/Ontology mapping report generated for every release candidate.
|
|
48
|
+
- Multi-agent runs produce complete role-tagged result summary payloads for 100% completed sub-agents.
|
package/docs/zh/README.md
CHANGED
|
@@ -190,6 +190,15 @@
|
|
|
190
190
|
- 主从编排与门禁增强
|
|
191
191
|
- 跨轮次回归与发布治理集成
|
|
192
192
|
|
|
193
|
+
### [SCE 能力矩阵路线图](../sce-capability-matrix-roadmap.md)
|
|
194
|
+
**核心能力补齐路线(英文)** - 策略路由、符号证据、自修复、ontology 映射与多 agent 汇总
|
|
195
|
+
- 任务策略决策闭环
|
|
196
|
+
- 失败归因与有界修复
|
|
197
|
+
- 跨项目能力沉淀与协同治理
|
|
198
|
+
|
|
199
|
+
### [SCE 能力矩阵端到端示例](../sce-capability-matrix-e2e-example.md)
|
|
200
|
+
**端到端流程示例(英文)** - 从策略决策到符号证据、失败修复、能力映射和主从摘要合并阻断
|
|
201
|
+
|
|
193
202
|
### [Handoff Profile Integration Guide](../handoff-profile-integration-guide.md)
|
|
194
203
|
**外部项目接入规范(英文)** - `default|moqui|enterprise` 三档 handoff profile 契约
|
|
195
204
|
- profile 默认策略与显式参数覆盖规则
|
|
@@ -115,6 +115,12 @@ git log --oneline -n 15
|
|
|
115
115
|
- `KSE_RELEASE_DRIFT_PREFLIGHT_BLOCK_RATE_MIN_PERCENT`:近 5 版(有 preflight 信号)blocked 占比告警阈值(默认 `40`)
|
|
116
116
|
- `KSE_RELEASE_DRIFT_HARD_GATE_BLOCK_STREAK_MIN`:hard-gate preflight 连续 blocked 告警阈值(最近窗口,默认 `2`)
|
|
117
117
|
- `KSE_RELEASE_DRIFT_PREFLIGHT_UNAVAILABLE_STREAK_MIN`:release preflight 连续 unavailable 告警阈值(最近窗口,默认 `2`)
|
|
118
|
+
- 可选:发布资产 0 字节防护(workflow 默认开启)
|
|
119
|
+
- `scripts/release-asset-nonempty-normalize.js` 会在上传 GitHub Release 资产前,为可选 `.lines` / `.jsonl` 资产自动补齐占位内容,避免 422。
|
|
120
|
+
- 本地 dry-run 示例:
|
|
121
|
+
- `node scripts/release-asset-nonempty-normalize.js --file .kiro/reports/release-evidence/matrix-remediation-vX.Y.Z.lines --kind lines --note "no matrix remediation items for this release" --dry-run --json`
|
|
122
|
+
- 本地规范化示例:
|
|
123
|
+
- `node scripts/release-asset-nonempty-normalize.js --file .kiro/reports/release-evidence/interactive-matrix-signals-vX.Y.Z.jsonl --kind jsonl --event interactive-matrix-signals --note "No interactive matrix signals collected for this release." --json`
|
|
118
124
|
- 可选本地预演 release gate 历史索引产物:
|
|
119
125
|
- `sce auto handoff gate-index --dir .kiro/reports/release-evidence --out .kiro/reports/release-evidence/release-gate-history.json --json`
|
|
120
126
|
|
|
@@ -248,10 +248,163 @@ class AgentSpawner extends EventEmitter {
|
|
|
248
248
|
return new Map(this._agents);
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Resolve a structured result summary emitted by a sub-agent.
|
|
253
|
+
* The summary is extracted from captured JSON events and used by
|
|
254
|
+
* orchestration merge-governance checks.
|
|
255
|
+
*
|
|
256
|
+
* @param {string} agentId
|
|
257
|
+
* @returns {object|null}
|
|
258
|
+
*/
|
|
259
|
+
getResultSummary(agentId) {
|
|
260
|
+
const agent = this._agents.get(agentId);
|
|
261
|
+
if (!agent || !Array.isArray(agent.events)) {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
return this._extractResultSummaryFromEvents(agent.events);
|
|
265
|
+
}
|
|
266
|
+
|
|
251
267
|
// ---------------------------------------------------------------------------
|
|
252
268
|
// Private helpers
|
|
253
269
|
// ---------------------------------------------------------------------------
|
|
254
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Parse known summary carriers from agent JSON events.
|
|
273
|
+
* Prefers the candidate with the most contract fields.
|
|
274
|
+
*
|
|
275
|
+
* @param {object[]} events
|
|
276
|
+
* @returns {object|null}
|
|
277
|
+
* @private
|
|
278
|
+
*/
|
|
279
|
+
_extractResultSummaryFromEvents(events) {
|
|
280
|
+
const candidates = [];
|
|
281
|
+
const collect = (value) => {
|
|
282
|
+
if (!value || typeof value !== 'object') {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (this._summaryCandidateFieldCount(value) > 0) {
|
|
286
|
+
candidates.push(value);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
for (const event of events) {
|
|
291
|
+
if (!event || typeof event !== 'object') {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
collect(event.result_summary);
|
|
295
|
+
collect(event.summary);
|
|
296
|
+
collect(event.payload && event.payload.result_summary);
|
|
297
|
+
collect(event.payload && event.payload.summary);
|
|
298
|
+
collect(event.result && event.result.summary);
|
|
299
|
+
collect(event.data && event.data.result_summary);
|
|
300
|
+
collect(event.item && event.item.result_summary);
|
|
301
|
+
|
|
302
|
+
collect(this._tryParseSummaryFromText(event.message));
|
|
303
|
+
collect(this._tryParseSummaryFromText(event.output_text));
|
|
304
|
+
collect(this._tryParseSummaryFromText(event.text));
|
|
305
|
+
collect(this._tryParseSummaryFromText(event.item && event.item.text));
|
|
306
|
+
|
|
307
|
+
const itemContent = event.item && event.item.content;
|
|
308
|
+
if (Array.isArray(itemContent)) {
|
|
309
|
+
for (const entry of itemContent) {
|
|
310
|
+
if (typeof entry === 'string') {
|
|
311
|
+
collect(this._tryParseSummaryFromText(entry));
|
|
312
|
+
} else if (entry && typeof entry === 'object') {
|
|
313
|
+
collect(entry.result_summary);
|
|
314
|
+
collect(entry.summary);
|
|
315
|
+
collect(this._tryParseSummaryFromText(entry.text));
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (candidates.length === 0) {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
candidates.sort((left, right) =>
|
|
326
|
+
this._summaryCandidateFieldCount(right) - this._summaryCandidateFieldCount(left));
|
|
327
|
+
return { ...candidates[0] };
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @param {object} candidate
|
|
332
|
+
* @returns {number}
|
|
333
|
+
* @private
|
|
334
|
+
*/
|
|
335
|
+
_summaryCandidateFieldCount(candidate) {
|
|
336
|
+
if (!candidate || typeof candidate !== 'object') {
|
|
337
|
+
return 0;
|
|
338
|
+
}
|
|
339
|
+
const fields = [
|
|
340
|
+
'spec_id',
|
|
341
|
+
'changed_files',
|
|
342
|
+
'tests_run',
|
|
343
|
+
'tests_passed',
|
|
344
|
+
'risk_level',
|
|
345
|
+
'open_issues'
|
|
346
|
+
];
|
|
347
|
+
let count = 0;
|
|
348
|
+
for (const field of fields) {
|
|
349
|
+
if (Object.prototype.hasOwnProperty.call(candidate, field)) {
|
|
350
|
+
count += 1;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return count;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Attempt to parse a JSON summary object from free-form text.
|
|
358
|
+
*
|
|
359
|
+
* @param {string} text
|
|
360
|
+
* @returns {object|null}
|
|
361
|
+
* @private
|
|
362
|
+
*/
|
|
363
|
+
_tryParseSummaryFromText(text) {
|
|
364
|
+
if (typeof text !== 'string') {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
const trimmed = text.trim();
|
|
368
|
+
if (!trimmed || !trimmed.includes('spec_id')) {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const candidates = [trimmed];
|
|
373
|
+
const fenced = /```json\s*([\s\S]*?)```/gi;
|
|
374
|
+
let match;
|
|
375
|
+
while ((match = fenced.exec(trimmed)) !== null) {
|
|
376
|
+
if (match[1]) {
|
|
377
|
+
candidates.push(match[1].trim());
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const firstBrace = trimmed.indexOf('{');
|
|
382
|
+
const lastBrace = trimmed.lastIndexOf('}');
|
|
383
|
+
if (firstBrace >= 0 && lastBrace > firstBrace) {
|
|
384
|
+
candidates.push(trimmed.slice(firstBrace, lastBrace + 1));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
for (const candidate of candidates) {
|
|
388
|
+
if (!candidate || typeof candidate !== 'string') {
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
const parsed = JSON.parse(candidate);
|
|
393
|
+
if (parsed && typeof parsed === 'object') {
|
|
394
|
+
if (parsed.result_summary && typeof parsed.result_summary === 'object') {
|
|
395
|
+
return parsed.result_summary;
|
|
396
|
+
}
|
|
397
|
+
if (this._summaryCandidateFieldCount(parsed) > 0) {
|
|
398
|
+
return parsed;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
} catch (_err) {
|
|
402
|
+
// Ignore parse failures and continue.
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
|
|
255
408
|
/**
|
|
256
409
|
* Ensure bootstrap prompt is a non-empty string before using it in spawn args.
|
|
257
410
|
* @param {unknown} prompt
|
|
@@ -172,6 +172,9 @@ class BootstrapPromptBuilder {
|
|
|
172
172
|
'5. Mark each task as completed (change `[ ]` or `[-]` to `[x]`) after finishing.',
|
|
173
173
|
'6. Run relevant tests to verify your implementation before moving on.',
|
|
174
174
|
'7. If a task fails after multiple attempts, document the issue and continue.',
|
|
175
|
+
'8. At completion, output a final JSON object named result_summary with fields:',
|
|
176
|
+
' spec_id, changed_files, tests_run, tests_passed, risk_level, open_issues.',
|
|
177
|
+
' Keep risk_level in: low | medium | high | unknown.',
|
|
175
178
|
'',
|
|
176
179
|
'Quality requirements:',
|
|
177
180
|
'- All code must compile and pass linting.',
|