soloforge 1.2.16 → 1.2.17
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/dist/adapters/claude_code/pre_prompt_contract.d.ts +64 -0
- package/dist/adapters/claude_code/pre_prompt_contract.d.ts.map +1 -0
- package/dist/adapters/claude_code/pre_prompt_contract.js +116 -0
- package/dist/adapters/claude_code/pre_prompt_contract.js.map +1 -0
- package/dist/adapters/claude_code/tools.d.ts.map +1 -1
- package/dist/adapters/claude_code/tools.js +22 -0
- package/dist/adapters/claude_code/tools.js.map +1 -1
- package/dist/bin/soloforge.d.ts +1 -1
- package/dist/bin/soloforge.d.ts.map +1 -1
- package/dist/bin/soloforge.js +6 -3
- package/dist/bin/soloforge.js.map +1 -1
- package/dist/engine/batch1_scenario_registry.d.ts.map +1 -1
- package/dist/engine/batch1_scenario_registry.js +22 -1
- package/dist/engine/batch1_scenario_registry.js.map +1 -1
- package/dist/engine/batch1_scenario_runners.d.ts.map +1 -1
- package/dist/engine/batch1_scenario_runners.js +114 -0
- package/dist/engine/batch1_scenario_runners.js.map +1 -1
- package/dist/engine/intent_expander.d.ts.map +1 -1
- package/dist/engine/intent_expander.js +6 -2
- package/dist/engine/intent_expander.js.map +1 -1
- package/dist/engine/route_decision_contract_verifier.d.ts +44 -0
- package/dist/engine/route_decision_contract_verifier.d.ts.map +1 -0
- package/dist/engine/route_decision_contract_verifier.js +154 -0
- package/dist/engine/route_decision_contract_verifier.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RouteDecision 合同验证器 — 验证 route_decision 与 workflow_trace 的一致性。
|
|
3
|
+
*
|
|
4
|
+
* 被 sf_verify、scenario runner、negative tests 共用。
|
|
5
|
+
*/
|
|
6
|
+
export function verifyRouteDecisionContract(input) {
|
|
7
|
+
const findings = [];
|
|
8
|
+
const rd = input.route_decision;
|
|
9
|
+
const wt = input.workflow_trace;
|
|
10
|
+
// 1. route_decision must exist
|
|
11
|
+
if (!rd) {
|
|
12
|
+
findings.push({ severity: "hard_fail", rule: "rd-missing", message: "route_decision 不存在,验证无法继续" });
|
|
13
|
+
return findings;
|
|
14
|
+
}
|
|
15
|
+
// 2. workflow_trace must exist when route_decision exists
|
|
16
|
+
if (!wt) {
|
|
17
|
+
findings.push({ severity: "hard_fail", rule: "wt-missing", message: "workflow_trace 不存在,无法验证路由一致性" });
|
|
18
|
+
}
|
|
19
|
+
// 3. workflow_trace.route must match route_decision.route
|
|
20
|
+
if (wt && wt.route !== rd.route) {
|
|
21
|
+
findings.push({
|
|
22
|
+
severity: "hard_fail",
|
|
23
|
+
rule: "wt-route-mismatch",
|
|
24
|
+
message: `workflow_trace.route="${wt.route}" !== route_decision.route="${rd.route}"`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// 4. workflow_trace.execution_shape must match route_decision.execution_shape
|
|
28
|
+
if (wt && wt.execution_shape !== rd.execution_shape) {
|
|
29
|
+
findings.push({
|
|
30
|
+
severity: "hard_fail",
|
|
31
|
+
rule: "wt-shape-mismatch",
|
|
32
|
+
message: `workflow_trace.execution_shape="${wt.execution_shape}" !== route_decision.execution_shape="${rd.execution_shape}"`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// 5. missing_required_inputs non-empty must block normal verify
|
|
36
|
+
if (rd.missing_required_inputs && rd.missing_required_inputs.length > 0) {
|
|
37
|
+
findings.push({
|
|
38
|
+
severity: "blocked",
|
|
39
|
+
rule: "rd-missing-inputs",
|
|
40
|
+
message: `missing_required_inputs 非空: ${rd.missing_required_inputs.join(", ")}`,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// 6. input_materials preservation check
|
|
44
|
+
if (rd.input_materials && rd.input_materials.length > 0 && input.expansion_input_materials) {
|
|
45
|
+
const rdKinds = new Set(rd.input_materials.map(m => m.kind));
|
|
46
|
+
const expRefs = input.expansion_input_materials.map(m => m.path_or_ref ?? "").filter(r => r.length > 0);
|
|
47
|
+
// At least one expansion input_material should correspond to an rd input_material
|
|
48
|
+
const rdPaths = rd.input_materials.filter(m => m.path).map(m => m.path);
|
|
49
|
+
if (rdPaths.length > 0 && expRefs.length > 0) {
|
|
50
|
+
const anyPreserved = rdPaths.some(p => expRefs.some(e => e.includes(p)));
|
|
51
|
+
if (!anyPreserved) {
|
|
52
|
+
findings.push({
|
|
53
|
+
severity: "degraded",
|
|
54
|
+
rule: "rd-inputs-lost",
|
|
55
|
+
message: `route_decision input_materials paths [${rdPaths.join(",")}] not preserved in expansion input_materials`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// 7. mutation_allowed / scope consistency
|
|
61
|
+
if (rd.scope && rd.scope.read_only !== undefined && rd.scope.read_only !== !rd.mutation_allowed) {
|
|
62
|
+
findings.push({
|
|
63
|
+
severity: "hard_fail",
|
|
64
|
+
rule: "rd-scope-mutation-mismatch",
|
|
65
|
+
message: `scope.read_only=${rd.scope.read_only} inconsistent with mutation_allowed=${rd.mutation_allowed}`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// 8. mutation_allowed upgrade detection (source_extraction must be false)
|
|
69
|
+
if (rd.route === "source_extraction" && rd.mutation_allowed === true) {
|
|
70
|
+
findings.push({
|
|
71
|
+
severity: "hard_fail",
|
|
72
|
+
rule: "rd-mutation-upgraded",
|
|
73
|
+
message: "source_extraction route must have mutation_allowed=false, got true (upgrade detected)",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// 9. output_artifact consistency check
|
|
77
|
+
const rdArtifact = rd.output_artifact;
|
|
78
|
+
const expArtifact = input.expansion_output_artifact;
|
|
79
|
+
if (rdArtifact) {
|
|
80
|
+
if (!expArtifact) {
|
|
81
|
+
findings.push({
|
|
82
|
+
severity: "hard_fail",
|
|
83
|
+
rule: "rd-output-artifact-missing",
|
|
84
|
+
message: `route_decision.output_artifact exists (kind=${rdArtifact.kind ?? "?"}) but expansion output artifact is missing`,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (rdArtifact.kind && expArtifact.kind && rdArtifact.kind !== expArtifact.kind) {
|
|
89
|
+
findings.push({
|
|
90
|
+
severity: "hard_fail",
|
|
91
|
+
rule: "rd-output-artifact-kind-mismatch",
|
|
92
|
+
message: `route_decision.output_artifact.kind="${rdArtifact.kind}" !== expansion output kind="${expArtifact.kind}"`,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (rdArtifact.path && expArtifact.path && rdArtifact.path !== expArtifact.path) {
|
|
96
|
+
findings.push({
|
|
97
|
+
severity: "hard_fail",
|
|
98
|
+
rule: "rd-output-artifact-path-mismatch",
|
|
99
|
+
message: `route_decision.output_artifact.path="${rdArtifact.path}" !== expansion output path="${expArtifact.path}"`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// 10. constraints preservation check
|
|
105
|
+
// 10a. If expansion_constraints explicitly provided, compare against rd.constraints
|
|
106
|
+
if (rd.constraints && rd.constraints.length > 0 && Array.isArray(input.expansion_constraints)) {
|
|
107
|
+
const expConstraints = input.expansion_constraints;
|
|
108
|
+
if (expConstraints.length === 0) {
|
|
109
|
+
findings.push({
|
|
110
|
+
severity: "hard_fail",
|
|
111
|
+
rule: "rd-constraints-lost",
|
|
112
|
+
message: `route_decision.constraints [${rd.constraints.join(",")}] not preserved in expansion (empty)`,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
if (rd.route === "source_extraction" && rd.constraints.includes("no_mutation") && !expConstraints.includes("no_mutation")) {
|
|
117
|
+
findings.push({
|
|
118
|
+
severity: "hard_fail",
|
|
119
|
+
rule: "rd-constraint-no-mutation-lost",
|
|
120
|
+
message: "source_extraction no_mutation constraint lost in expansion",
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// 10b. Self-consistency: source_extraction with mutation_allowed=false must have no_mutation constraint
|
|
126
|
+
if (rd.route === "source_extraction" && !rd.mutation_allowed && rd.constraints && !rd.constraints.includes("no_mutation")) {
|
|
127
|
+
findings.push({
|
|
128
|
+
severity: "hard_fail",
|
|
129
|
+
rule: "rd-constraint-no-mutation-missing",
|
|
130
|
+
message: "source_extraction with mutation_allowed=false must have no_mutation constraint",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
// 10c. If rd had constraints but they were completely removed (constraints field is empty/missing when it shouldn't be)
|
|
134
|
+
if (rd.route === "source_extraction" && !rd.mutation_allowed && (!rd.constraints || rd.constraints.length === 0)) {
|
|
135
|
+
findings.push({
|
|
136
|
+
severity: "hard_fail",
|
|
137
|
+
rule: "rd-constraints-empty",
|
|
138
|
+
message: "source_extraction with mutation_allowed=false has empty constraints",
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// 11. input_materials exist but expansion_input_materials missing/empty → blocked
|
|
142
|
+
if (rd.input_materials && rd.input_materials.length > 0) {
|
|
143
|
+
const expInputs = input.expansion_input_materials;
|
|
144
|
+
if (!expInputs || expInputs.length === 0) {
|
|
145
|
+
findings.push({
|
|
146
|
+
severity: "blocked",
|
|
147
|
+
rule: "rd-inputs-no-expansion",
|
|
148
|
+
message: `route_decision has ${rd.input_materials.length} input_materials but expansion_input_materials is empty or missing`,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return findings;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=route_decision_contract_verifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route_decision_contract_verifier.js","sourceRoot":"","sources":["../../src/engine/route_decision_contract_verifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4BH,MAAM,UAAU,2BAA2B,CAAC,KAAiC;IAC3E,MAAM,QAAQ,GAAmC,EAAE,CAAC;IACpD,MAAM,EAAE,GAAG,KAAK,C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