enterprise-agent-designer 0.34.1

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.
Files changed (34) hide show
  1. package/.codebuddy-plugin/plugin.json +66 -0
  2. package/CHANGELOG.md +729 -0
  3. package/DESIGN_NOTE.md +101 -0
  4. package/LICENSE +21 -0
  5. package/PACKAGE.yaml +209 -0
  6. package/README.md +109 -0
  7. package/RETROSPECTIVE_v0.1-v0.10.md +67 -0
  8. package/RUNTIME_ASSEMBLY.md +134 -0
  9. package/SYSTEM_PROMPT.md +139 -0
  10. package/agents/agent-designer.md +151 -0
  11. package/avatars/.gitkeep +0 -0
  12. package/avatars/expert.png +0 -0
  13. package/evaluation/README.md +60 -0
  14. package/evaluation/cases.json +2045 -0
  15. package/evaluation/document-reviewer-holdout.md +24 -0
  16. package/package.json +33 -0
  17. package/references/optional-host-workflow.md +105 -0
  18. package/scripts/check_agent_delivery.py +202 -0
  19. package/scripts/optional/workflow_controller.py +478 -0
  20. package/scripts/validate.py +437 -0
  21. package/scripts/verify_v0321_guards.py +410 -0
  22. package/skills/design-enterprise-agent/SKILL.md +131 -0
  23. package/skills/design-enterprise-agent/references/41-performance-worked-example.md +199 -0
  24. package/skills/design-enterprise-agent/references/cold-start-and-writing.md +163 -0
  25. package/skills/design-enterprise-agent/references/requirements-grilling.md +40 -0
  26. package/skills/design-enterprise-agent/references/runtime-and-integration.md +102 -0
  27. package/skills/design-enterprise-agent/references/task-adaptive-runtime.md +70 -0
  28. package/skills/design-enterprise-agent/scripts/finalize_agent_delivery.py +748 -0
  29. package/skills/grill-with-docs/SKILL.md +58 -0
  30. package/skills/grill-with-docs/references/design-context-format.md +101 -0
  31. package/skills/grilling/SKILL.md +62 -0
  32. package/skills/review-enterprise-agent/SKILL.md +86 -0
  33. package/skills/review-enterprise-agent/references/isolated-review-contract.md +154 -0
  34. package/skills/review-enterprise-agent/scripts/validate_review_receipt.py +338 -0
@@ -0,0 +1,338 @@
1
+ #!/usr/bin/env python3
2
+ """Validate review-receipt structure and explicit cross-field contradictions.
3
+
4
+ This script does not judge whether cited business evidence is true or sufficient.
5
+ It only prevents a receipt from declaring pass while its own structured fields say
6
+ that decisive evidence, replay, authority, or dependency closure is missing.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ import json
13
+ import sys
14
+ from pathlib import Path
15
+
16
+
17
+ COMMON_FIELDS = {
18
+ "review_mode",
19
+ "review_scope",
20
+ "review_round",
21
+ "verdict",
22
+ "lowest_failed_layer",
23
+ "decisive_reason",
24
+ "evidence",
25
+ "preserve",
26
+ "return_to",
27
+ "next_action",
28
+ "change_condition",
29
+ "reviewed_snapshot_id",
30
+ "grounding_audit",
31
+ "source_audit",
32
+ "materiality_audit",
33
+ "authority_audit",
34
+ }
35
+
36
+ LOWEST_FAILED_LAYERS = {
37
+ "requirements",
38
+ "professional-task",
39
+ "role",
40
+ "principles",
41
+ "skill-topology",
42
+ "tool-knowledge",
43
+ "output-handoff",
44
+ "trace-runtime",
45
+ "none",
46
+ }
47
+
48
+ RETURN_TARGETS = {
49
+ "grilling",
50
+ "grill-with-docs",
51
+ "design-enterprise-agent",
52
+ "delivery-finalizer",
53
+ "user",
54
+ }
55
+
56
+ COUNTEREXAMPLE_BASIS_FIELDS = {
57
+ "standard_source_status",
58
+ "standard_source",
59
+ "anchor_set_completeness",
60
+ "all_explicit_anchors_satisfied",
61
+ "coverage_gap_status",
62
+ "coverage_gap_source",
63
+ "scenario_evidence_status",
64
+ }
65
+
66
+ SOURCE_AUDIT_FIELDS = {
67
+ "normal_case_replay",
68
+ "highest_risk_case_replay",
69
+ "finding_classification_consistent",
70
+ "unsupported_scope_expansion_found",
71
+ "skill_dependency_closure",
72
+ }
73
+
74
+ MATERIALITY_AUDIT_FIELDS = {
75
+ "overall_goal",
76
+ "consumer_decision",
77
+ "first_release_boundary",
78
+ "material_blocker_found",
79
+ "material_effect",
80
+ "same_failure_family_scope",
81
+ "deferred_non_blocking",
82
+ "late_round_blocking_justification",
83
+ }
84
+
85
+ LATE_ROUND_BLOCKING_JUSTIFICATIONS = {
86
+ "not_applicable",
87
+ "new-independent-failure-class",
88
+ "material-same-family-missed-instance",
89
+ "patch-introduced-failure",
90
+ "previously-unobservable-failure",
91
+ }
92
+
93
+
94
+ def parse_args() -> argparse.Namespace:
95
+ parser = argparse.ArgumentParser(
96
+ description="Validate an isolated grounding-gate or source-gate receipt."
97
+ )
98
+ parser.add_argument("receipt", type=Path)
99
+ parser.add_argument(
100
+ "--expected-mode", choices=("grounding-gate", "source-gate"), required=True
101
+ )
102
+ parser.add_argument("--expected-round", type=int)
103
+ parser.add_argument("--expected-snapshot")
104
+ return parser.parse_args()
105
+
106
+
107
+ def load_receipt(path: Path, errors: list[str]) -> dict[str, object] | None:
108
+ try:
109
+ payload = json.loads(path.read_text(encoding="utf-8"))
110
+ except FileNotFoundError:
111
+ errors.append(f"收据不存在:{path}")
112
+ return None
113
+ except (OSError, UnicodeError, json.JSONDecodeError) as exc:
114
+ errors.append(f"收据无法按 UTF-8 JSON 读取:{exc}")
115
+ return None
116
+ if not isinstance(payload, dict):
117
+ errors.append("收据必须是 JSON 对象")
118
+ return None
119
+ return payload
120
+
121
+
122
+ def validate_common(
123
+ receipt: dict[str, object], args: argparse.Namespace, errors: list[str]
124
+ ) -> None:
125
+ missing = COMMON_FIELDS - set(receipt)
126
+ if missing:
127
+ errors.append(f"收据缺少字段:{sorted(missing)}")
128
+ return
129
+ if receipt.get("review_mode") != args.expected_mode:
130
+ errors.append("review_mode 与 --expected-mode 不一致")
131
+ if receipt.get("review_scope") != "isolated-subagent":
132
+ errors.append("review_scope 不是 isolated-subagent")
133
+ review_round = receipt.get("review_round")
134
+ if not isinstance(review_round, int) or isinstance(review_round, bool) or review_round < 1:
135
+ errors.append("review_round 必须是从 1 开始的正整数")
136
+ if args.expected_round is not None and review_round != args.expected_round:
137
+ errors.append("review_round 与 --expected-round 不一致")
138
+ if receipt.get("verdict") not in {"pass", "revision_required", "insufficient_basis"}:
139
+ errors.append("verdict 不在允许枚举中")
140
+ verdict = receipt.get("verdict")
141
+ lowest_failed_layer = receipt.get("lowest_failed_layer")
142
+ if lowest_failed_layer not in LOWEST_FAILED_LAYERS:
143
+ errors.append("lowest_failed_layer 不在允许枚举中")
144
+ elif verdict == "pass" and lowest_failed_layer != "none":
145
+ errors.append("pass 收据的 lowest_failed_layer 必须为 none")
146
+ elif verdict in {"revision_required", "insufficient_basis"} and lowest_failed_layer == "none":
147
+ errors.append("非 pass 收据的 lowest_failed_layer 不能为 none")
148
+ if receipt.get("return_to") not in RETURN_TARGETS:
149
+ errors.append("return_to 不在允许枚举中")
150
+ for name in ("decisive_reason", "next_action", "change_condition"):
151
+ if not isinstance(receipt.get(name), str) or not str(receipt.get(name)).strip():
152
+ errors.append(f"{name} 必须是非空字符串")
153
+ for name in ("evidence", "preserve"):
154
+ if not isinstance(receipt.get(name), list):
155
+ errors.append(f"{name} 必须是数组")
156
+
157
+ authority = receipt.get("authority_audit")
158
+ if not isinstance(authority, dict):
159
+ errors.append("authority_audit 必须是对象")
160
+ else:
161
+ for name in ("stable_rules_reviewed", "unresolved_or_unauthorized"):
162
+ if not isinstance(authority.get(name), list):
163
+ errors.append(f"authority_audit.{name} 必须是数组")
164
+ if receipt.get("verdict") == "pass" and authority.get("unresolved_or_unauthorized"):
165
+ errors.append("pass 收据仍含无权或未解决规则")
166
+
167
+
168
+ def validate_grounding(receipt: dict[str, object], errors: list[str]) -> None:
169
+ if receipt.get("reviewed_snapshot_id") != "not_applicable":
170
+ errors.append("grounding-gate 的 reviewed_snapshot_id 必须为 not_applicable")
171
+ if receipt.get("source_audit") != "not_applicable":
172
+ errors.append("grounding-gate 的 source_audit 必须为 not_applicable")
173
+ if receipt.get("materiality_audit") != "not_applicable":
174
+ errors.append("grounding-gate 的 materiality_audit 必须为 not_applicable")
175
+ audit = receipt.get("grounding_audit")
176
+ if not isinstance(audit, dict):
177
+ errors.append("grounding-gate 必须提供 grounding_audit 对象")
178
+ return
179
+ if receipt.get("verdict") != "pass":
180
+ return
181
+
182
+ standard_mode = audit.get("standard_mode")
183
+ counterexample_status = audit.get("strict_counterexample_status")
184
+ if standard_mode == "none":
185
+ if counterexample_status != "not_applicable":
186
+ errors.append("standard_mode=none 时严格反例必须为 not_applicable")
187
+ return
188
+ if standard_mode == "runtime-input-only":
189
+ if counterexample_status != "not_required_contract_only":
190
+ errors.append(
191
+ "standard_mode=runtime-input-only 时必须标记 not_required_contract_only"
192
+ )
193
+ return
194
+ if standard_mode != "coverage-or-applicability":
195
+ errors.append("grounding pass 的 standard_mode 不在允许枚举中")
196
+ return
197
+ if counterexample_status != "pass":
198
+ errors.append("声称判断标准覆盖性或适用性时必须有严格反例 pass")
199
+
200
+ basis = audit.get("counterexample_basis")
201
+ if not isinstance(basis, dict):
202
+ errors.append("grounding pass 缺少 counterexample_basis")
203
+ return
204
+ missing = COUNTEREXAMPLE_BASIS_FIELDS - set(basis)
205
+ if missing:
206
+ errors.append(f"counterexample_basis 缺少字段:{sorted(missing)}")
207
+ return
208
+ if basis.get("standard_source_status") not in {
209
+ "verified-text",
210
+ "authorized-scope-confirmation",
211
+ }:
212
+ errors.append("严格反例没有可接受的标准来源")
213
+ if not isinstance(basis.get("standard_source"), str) or not str(
214
+ basis.get("standard_source")
215
+ ).strip():
216
+ errors.append("严格反例缺少具体标准来源")
217
+ if basis.get("anchor_set_completeness") != "confirmed":
218
+ errors.append("全部显式锚点集合尚未确认完整")
219
+ if basis.get("all_explicit_anchors_satisfied") is not True:
220
+ errors.append("没有确认全部显式锚点已经满足")
221
+ if basis.get("coverage_gap_status") != "confirmed":
222
+ errors.append("标准覆盖缺口尚未确认")
223
+ if not isinstance(basis.get("coverage_gap_source"), str) or not str(
224
+ basis.get("coverage_gap_source")
225
+ ).strip():
226
+ errors.append("标准覆盖缺口缺少具体来源")
227
+ if basis.get("scenario_evidence_status") not in {
228
+ "verified-case",
229
+ "self-contained-fixture",
230
+ }:
231
+ errors.append("严格反例仍是未经核证的假设场景")
232
+
233
+
234
+ def validate_source(
235
+ receipt: dict[str, object], args: argparse.Namespace, errors: list[str]
236
+ ) -> None:
237
+ if receipt.get("grounding_audit") != "not_applicable":
238
+ errors.append("source-gate 的 grounding_audit 必须为 not_applicable")
239
+ snapshot = receipt.get("reviewed_snapshot_id")
240
+ if not isinstance(snapshot, str) or not snapshot.startswith("sha256:"):
241
+ errors.append("source-gate 收据未绑定 sha256 源码快照")
242
+ if args.expected_snapshot is None:
243
+ errors.append("source-gate 校验必须提供 --expected-snapshot")
244
+ elif snapshot != args.expected_snapshot:
245
+ errors.append("reviewed_snapshot_id 与 --expected-snapshot 不一致")
246
+
247
+ audit = receipt.get("source_audit")
248
+ if not isinstance(audit, dict):
249
+ errors.append("source-gate 必须提供 source_audit 对象")
250
+ else:
251
+ missing = SOURCE_AUDIT_FIELDS - set(audit)
252
+ if missing:
253
+ errors.append(f"source_audit 缺少字段:{sorted(missing)}")
254
+ elif receipt.get("verdict") == "pass":
255
+ if audit.get("normal_case_replay") != "pass":
256
+ errors.append("正常案例尚未通过源码回放")
257
+ if audit.get("highest_risk_case_replay") != "pass":
258
+ errors.append("最高风险案例尚未通过源码回放")
259
+ if audit.get("finding_classification_consistent") is not True:
260
+ errors.append("评测发现分类尚未确认一致")
261
+ if audit.get("unsupported_scope_expansion_found") is not False:
262
+ errors.append("源码或评测仍含未经依据的范围扩张")
263
+ if audit.get("skill_dependency_closure") != "pass":
264
+ errors.append("Skill 数据依赖尚未闭合")
265
+
266
+ materiality = receipt.get("materiality_audit")
267
+ if not isinstance(materiality, dict):
268
+ errors.append("source-gate 必须提供 materiality_audit 对象")
269
+ return
270
+ missing_materiality = MATERIALITY_AUDIT_FIELDS - set(materiality)
271
+ if missing_materiality:
272
+ errors.append(f"materiality_audit 缺少字段:{sorted(missing_materiality)}")
273
+ return
274
+ for name in ("overall_goal", "consumer_decision", "first_release_boundary", "material_effect"):
275
+ if not isinstance(materiality.get(name), str) or not str(materiality.get(name)).strip():
276
+ errors.append(f"materiality_audit.{name} 必须是非空字符串")
277
+ for name in ("same_failure_family_scope", "deferred_non_blocking"):
278
+ if not isinstance(materiality.get(name), list):
279
+ errors.append(f"materiality_audit.{name} 必须是数组")
280
+ late_round_justification = materiality.get("late_round_blocking_justification")
281
+ if late_round_justification not in LATE_ROUND_BLOCKING_JUSTIFICATIONS:
282
+ errors.append(
283
+ "materiality_audit.late_round_blocking_justification 不在允许枚举中"
284
+ )
285
+
286
+ verdict = receipt.get("verdict")
287
+ if verdict == "pass" and materiality.get("material_blocker_found") is not False:
288
+ errors.append("source-gate pass 仍声明存在 material blocker")
289
+ if verdict in {"revision_required", "insufficient_basis"}:
290
+ if materiality.get("material_blocker_found") is not True:
291
+ errors.append("source-gate 非 pass 必须确认存在 material blocker")
292
+ if not materiality.get("same_failure_family_scope"):
293
+ errors.append("source-gate 非 pass 必须记录同类失败横向扫描范围")
294
+ review_round = receipt.get("review_round")
295
+ if (
296
+ verdict in {"revision_required", "insufficient_basis"}
297
+ and isinstance(review_round, int)
298
+ and review_round >= 4
299
+ and late_round_justification
300
+ not in {
301
+ "new-independent-failure-class",
302
+ "material-same-family-missed-instance",
303
+ "patch-introduced-failure",
304
+ "previously-unobservable-failure",
305
+ }
306
+ ):
307
+ errors.append(
308
+ "source-gate 第 4 轮及以后继续阻断必须是新发现的独立高影响失败类、"
309
+ "仍具实质影响的同类遗漏、本轮修改引入的高影响失败,"
310
+ "或此前证据客观上无法发现的高影响失败"
311
+ )
312
+ if verdict == "pass" and late_round_justification != "not_applicable":
313
+ errors.append("source-gate pass 的 late_round_blocking_justification 必须为 not_applicable")
314
+
315
+
316
+ def main() -> int:
317
+ args = parse_args()
318
+ errors: list[str] = []
319
+ receipt = load_receipt(args.receipt, errors)
320
+ if receipt is not None:
321
+ validate_common(receipt, args, errors)
322
+ if args.expected_mode == "grounding-gate":
323
+ validate_grounding(receipt, errors)
324
+ else:
325
+ validate_source(receipt, args, errors)
326
+
327
+ if errors:
328
+ print(f"RECEIPT_FAIL:{len(errors)} 个结构或显式矛盾")
329
+ for error in errors:
330
+ print(f"- {error}")
331
+ return 1
332
+ print("RECEIPT_PASS:收据结构与显式证据状态一致")
333
+ print("说明:该结果不判断引用事实是否真实,不替代隔离评审。")
334
+ return 0
335
+
336
+
337
+ if __name__ == "__main__":
338
+ sys.exit(main())