@hunter-harness/workflow-harness 0.2.53 → 0.2.55
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/harness/bundles/general/claude-code/.harness-build.json +1 -1
- package/harness/bundles/general/claude-code/harness-archive/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-plan/SKILL.md +4 -3
- package/harness/bundles/general/claude-code/harness-plan/checklist.md +2 -1
- package/harness/bundles/general/claude-code/harness-review/SKILL.md +6 -4
- package/harness/bundles/general/claude-code/harness-run/SKILL.md +4 -4
- package/harness/bundles/general/claude-code/harness-run/reference.md +2 -2
- package/harness/bundles/general/claude-code/harness-submit/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-test/SKILL.md +5 -3
- package/harness/bundles/general/claude-code/harness-test/reference.md +1 -1
- package/harness/bundles/general/claude-code/scripts/harness_archive.py +46 -7
- package/harness/bundles/general/claude-code/scripts/harness_context.py +123 -22
- package/harness/bundles/general/claude-code/scripts/harness_events.py +40 -1
- package/harness/bundles/general/claude-code/scripts/harness_events_sync.py +236 -10
- package/harness/bundles/general/claude-code/scripts/harness_gate.py +165 -1
- package/harness/bundles/general/claude-code/scripts/harness_ledger.py +2 -0
- package/harness/bundles/general/claude-code/scripts/harness_plan_finalize.py +2 -0
- package/harness/bundles/general/claude-code/scripts/harness_test_guard.py +37 -44
- package/harness/bundles/general/codebuddy/.harness-build.json +1 -1
- package/harness/bundles/general/codebuddy/harness-archive/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-plan/SKILL.md +4 -3
- package/harness/bundles/general/codebuddy/harness-plan/checklist.md +2 -1
- package/harness/bundles/general/codebuddy/harness-review/SKILL.md +6 -4
- package/harness/bundles/general/codebuddy/harness-run/SKILL.md +4 -4
- package/harness/bundles/general/codebuddy/harness-run/reference.md +2 -2
- package/harness/bundles/general/codebuddy/harness-submit/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-test/SKILL.md +5 -3
- package/harness/bundles/general/codebuddy/harness-test/reference.md +1 -1
- package/harness/bundles/general/codebuddy/scripts/harness_archive.py +46 -7
- package/harness/bundles/general/codebuddy/scripts/harness_context.py +123 -22
- package/harness/bundles/general/codebuddy/scripts/harness_events.py +40 -1
- package/harness/bundles/general/codebuddy/scripts/harness_events_sync.py +236 -10
- package/harness/bundles/general/codebuddy/scripts/harness_gate.py +165 -1
- package/harness/bundles/general/codebuddy/scripts/harness_ledger.py +2 -0
- package/harness/bundles/general/codebuddy/scripts/harness_plan_finalize.py +2 -0
- package/harness/bundles/general/codebuddy/scripts/harness_test_guard.py +37 -44
- package/harness/bundles/general/codex/.harness-build.json +1 -1
- package/harness/bundles/general/codex/harness-archive/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-plan/SKILL.md +4 -3
- package/harness/bundles/general/codex/harness-plan/checklist.md +2 -1
- package/harness/bundles/general/codex/harness-review/SKILL.md +3 -3
- package/harness/bundles/general/codex/harness-run/SKILL.md +4 -4
- package/harness/bundles/general/codex/harness-run/reference.md +2 -2
- package/harness/bundles/general/codex/harness-submit/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-test/SKILL.md +5 -3
- package/harness/bundles/general/codex/harness-test/reference.md +1 -1
- package/harness/bundles/general/codex/scripts/harness_archive.py +46 -7
- package/harness/bundles/general/codex/scripts/harness_context.py +123 -22
- package/harness/bundles/general/codex/scripts/harness_events.py +40 -1
- package/harness/bundles/general/codex/scripts/harness_events_sync.py +236 -10
- package/harness/bundles/general/codex/scripts/harness_gate.py +165 -1
- package/harness/bundles/general/codex/scripts/harness_ledger.py +2 -0
- package/harness/bundles/general/codex/scripts/harness_plan_finalize.py +2 -0
- package/harness/bundles/general/codex/scripts/harness_test_guard.py +37 -44
- package/harness/bundles/general/cursor/.harness-build.json +1 -1
- package/harness/bundles/general/cursor/harness-archive/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-plan/SKILL.md +4 -3
- package/harness/bundles/general/cursor/harness-plan/checklist.md +2 -1
- package/harness/bundles/general/cursor/harness-review/SKILL.md +3 -3
- package/harness/bundles/general/cursor/harness-run/SKILL.md +4 -4
- package/harness/bundles/general/cursor/harness-run/reference.md +2 -2
- package/harness/bundles/general/cursor/harness-submit/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-test/SKILL.md +5 -3
- package/harness/bundles/general/cursor/harness-test/reference.md +1 -1
- package/harness/bundles/general/cursor/scripts/harness_archive.py +46 -7
- package/harness/bundles/general/cursor/scripts/harness_context.py +123 -22
- package/harness/bundles/general/cursor/scripts/harness_events.py +40 -1
- package/harness/bundles/general/cursor/scripts/harness_events_sync.py +236 -10
- package/harness/bundles/general/cursor/scripts/harness_gate.py +165 -1
- package/harness/bundles/general/cursor/scripts/harness_ledger.py +2 -0
- package/harness/bundles/general/cursor/scripts/harness_plan_finalize.py +2 -0
- package/harness/bundles/general/cursor/scripts/harness_test_guard.py +37 -44
- package/harness/bundles/java/claude-code/.harness-build.json +1 -1
- package/harness/bundles/java/claude-code/harness-apidoc/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-archive/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-package/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-plan/SKILL.md +4 -3
- package/harness/bundles/java/claude-code/harness-plan/checklist.md +2 -1
- package/harness/bundles/java/claude-code/harness-review/SKILL.md +6 -4
- package/harness/bundles/java/claude-code/harness-run/SKILL.md +4 -4
- package/harness/bundles/java/claude-code/harness-submit/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-test/SKILL.md +5 -3
- package/harness/bundles/java/claude-code/scripts/harness_archive.py +46 -7
- package/harness/bundles/java/claude-code/scripts/harness_context.py +123 -22
- package/harness/bundles/java/claude-code/scripts/harness_events.py +40 -1
- package/harness/bundles/java/claude-code/scripts/harness_events_sync.py +236 -10
- package/harness/bundles/java/claude-code/scripts/harness_gate.py +165 -1
- package/harness/bundles/java/claude-code/scripts/harness_ledger.py +2 -0
- package/harness/bundles/java/claude-code/scripts/harness_plan_finalize.py +2 -0
- package/harness/bundles/java/claude-code/scripts/harness_test_guard.py +37 -44
- package/harness/bundles/java/codebuddy/.harness-build.json +1 -1
- package/harness/bundles/java/codebuddy/harness-apidoc/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-archive/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-package/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-plan/SKILL.md +4 -3
- package/harness/bundles/java/codebuddy/harness-plan/checklist.md +2 -1
- package/harness/bundles/java/codebuddy/harness-review/SKILL.md +6 -4
- package/harness/bundles/java/codebuddy/harness-run/SKILL.md +4 -4
- package/harness/bundles/java/codebuddy/harness-submit/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-test/SKILL.md +5 -3
- package/harness/bundles/java/codebuddy/scripts/harness_archive.py +46 -7
- package/harness/bundles/java/codebuddy/scripts/harness_context.py +123 -22
- package/harness/bundles/java/codebuddy/scripts/harness_events.py +40 -1
- package/harness/bundles/java/codebuddy/scripts/harness_events_sync.py +236 -10
- package/harness/bundles/java/codebuddy/scripts/harness_gate.py +165 -1
- package/harness/bundles/java/codebuddy/scripts/harness_ledger.py +2 -0
- package/harness/bundles/java/codebuddy/scripts/harness_plan_finalize.py +2 -0
- package/harness/bundles/java/codebuddy/scripts/harness_test_guard.py +37 -44
- package/harness/bundles/java/codex/.harness-build.json +1 -1
- package/harness/bundles/java/codex/harness-apidoc/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-archive/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-package/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-plan/SKILL.md +4 -3
- package/harness/bundles/java/codex/harness-plan/checklist.md +2 -1
- package/harness/bundles/java/codex/harness-review/SKILL.md +3 -3
- package/harness/bundles/java/codex/harness-run/SKILL.md +4 -4
- package/harness/bundles/java/codex/harness-submit/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-test/SKILL.md +5 -3
- package/harness/bundles/java/codex/scripts/harness_archive.py +46 -7
- package/harness/bundles/java/codex/scripts/harness_context.py +123 -22
- package/harness/bundles/java/codex/scripts/harness_events.py +40 -1
- package/harness/bundles/java/codex/scripts/harness_events_sync.py +236 -10
- package/harness/bundles/java/codex/scripts/harness_gate.py +165 -1
- package/harness/bundles/java/codex/scripts/harness_ledger.py +2 -0
- package/harness/bundles/java/codex/scripts/harness_plan_finalize.py +2 -0
- package/harness/bundles/java/codex/scripts/harness_test_guard.py +37 -44
- package/harness/bundles/java/cursor/.harness-build.json +1 -1
- package/harness/bundles/java/cursor/harness-apidoc/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-archive/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-package/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-plan/SKILL.md +4 -3
- package/harness/bundles/java/cursor/harness-plan/checklist.md +2 -1
- package/harness/bundles/java/cursor/harness-review/SKILL.md +3 -3
- package/harness/bundles/java/cursor/harness-run/SKILL.md +4 -4
- package/harness/bundles/java/cursor/harness-submit/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-test/SKILL.md +5 -3
- package/harness/bundles/java/cursor/scripts/harness_archive.py +46 -7
- package/harness/bundles/java/cursor/scripts/harness_context.py +123 -22
- package/harness/bundles/java/cursor/scripts/harness_events.py +40 -1
- package/harness/bundles/java/cursor/scripts/harness_events_sync.py +236 -10
- package/harness/bundles/java/cursor/scripts/harness_gate.py +165 -1
- package/harness/bundles/java/cursor/scripts/harness_ledger.py +2 -0
- package/harness/bundles/java/cursor/scripts/harness_plan_finalize.py +2 -0
- package/harness/bundles/java/cursor/scripts/harness_test_guard.py +37 -44
- package/harness/manifests/general/claude-code.json +24 -24
- package/harness/manifests/general/codebuddy.json +24 -24
- package/harness/manifests/general/codex.json +24 -24
- package/harness/manifests/general/cursor.json +24 -24
- package/harness/manifests/java/claude-code.json +24 -24
- package/harness/manifests/java/codebuddy.json +24 -24
- package/harness/manifests/java/codex.json +24 -24
- package/harness/manifests/java/cursor.json +24 -24
- package/hunter-workflow-family.json +5 -4
- package/package.json +1 -1
|
@@ -40,6 +40,7 @@ WHITELIST = {
|
|
|
40
40
|
"phase",
|
|
41
41
|
"status",
|
|
42
42
|
"note",
|
|
43
|
+
"message",
|
|
43
44
|
"attempt",
|
|
44
45
|
"name",
|
|
45
46
|
"code",
|
|
@@ -49,11 +50,34 @@ WHITELIST = {
|
|
|
49
50
|
"exit_code",
|
|
50
51
|
"duration_ms",
|
|
51
52
|
"schemaVersion",
|
|
53
|
+
"summary",
|
|
54
|
+
"executor_tool",
|
|
55
|
+
"executor_agent",
|
|
56
|
+
"executor_model",
|
|
57
|
+
"execution_mode",
|
|
58
|
+
"decision_reason_code",
|
|
59
|
+
"fallback_reason_code",
|
|
60
|
+
"trigger",
|
|
61
|
+
"from_phase",
|
|
62
|
+
"result_status",
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
MAX_BATCH_SIZE = 100
|
|
55
66
|
ACCEPTED_STATUSES = {"accepted", "duplicate_accepted"}
|
|
56
67
|
QUARANTINE_STATUSES = {"id_conflict", "rejected", "rejected_schema"}
|
|
68
|
+
DISPLAY_TITLE_MAX_LENGTH = 200
|
|
69
|
+
EVENT_SUMMARY_MAX_LENGTH = 500
|
|
70
|
+
|
|
71
|
+
PHASE_LABELS = {
|
|
72
|
+
"plan": "计划",
|
|
73
|
+
"run": "编码",
|
|
74
|
+
"test": "测试",
|
|
75
|
+
"review": "评审",
|
|
76
|
+
"package": "打包",
|
|
77
|
+
"apidoc": "接口文档",
|
|
78
|
+
"submit": "提交",
|
|
79
|
+
"archive": "归档",
|
|
80
|
+
}
|
|
57
81
|
|
|
58
82
|
|
|
59
83
|
def _yaml_scalar(text: str, key: str) -> str | None:
|
|
@@ -87,8 +111,162 @@ def load_endpoint(project: Path) -> dict[str, str] | None:
|
|
|
87
111
|
}
|
|
88
112
|
|
|
89
113
|
|
|
114
|
+
def _summary_text(value: Any) -> str:
|
|
115
|
+
if not isinstance(value, str):
|
|
116
|
+
return ""
|
|
117
|
+
text = re.sub(r"\s+", " ", value).strip()
|
|
118
|
+
text = "".join(character for character in text if ord(character) >= 32 and ord(character) != 127)
|
|
119
|
+
return text[:EVENT_SUMMARY_MAX_LENGTH].rstrip()
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
_MACHINE_DETAIL_RE = re.compile(
|
|
123
|
+
r"(?:\s*[;;,,]?\s*)"
|
|
124
|
+
r"(?:artifactsHash|artifactHash|receiptHash|content_sha256|contentSha256)"
|
|
125
|
+
r"\s*[:=]\s*(?:sha256:)?[0-9a-f]{32,64}",
|
|
126
|
+
re.IGNORECASE,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _readable_summary_text(value: Any) -> str:
|
|
131
|
+
text = _summary_text(value)
|
|
132
|
+
if not text:
|
|
133
|
+
return ""
|
|
134
|
+
text = _MACHINE_DETAIL_RE.sub("", text)
|
|
135
|
+
text = re.sub(
|
|
136
|
+
r"\bfinalize\s+ok\b",
|
|
137
|
+
"规划产物已校验并发布",
|
|
138
|
+
text,
|
|
139
|
+
flags=re.IGNORECASE,
|
|
140
|
+
)
|
|
141
|
+
text = re.sub(r"\s*([;;,,])\s*([;;,,])", r"\1", text)
|
|
142
|
+
return _summary_text(text.strip(" ;;,,"))
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def build_event_summary(event: dict[str, Any]) -> str:
|
|
146
|
+
explicit = _readable_summary_text(event.get("summary"))
|
|
147
|
+
if explicit:
|
|
148
|
+
return explicit
|
|
149
|
+
|
|
150
|
+
event_type = _summary_text(event.get("type"))
|
|
151
|
+
phase = _summary_text(event.get("phase"))
|
|
152
|
+
phase_label = PHASE_LABELS.get(phase, phase or "当前")
|
|
153
|
+
note = _readable_summary_text(event.get("note"))
|
|
154
|
+
message = _readable_summary_text(event.get("message"))
|
|
155
|
+
decision = _readable_summary_text(event.get("decision"))
|
|
156
|
+
reason = _readable_summary_text(event.get("reason"))
|
|
157
|
+
name = _readable_summary_text(event.get("name"))
|
|
158
|
+
code = _readable_summary_text(event.get("code"))
|
|
159
|
+
status = _summary_text(event.get("status"))
|
|
160
|
+
|
|
161
|
+
if event_type == "decision" and decision:
|
|
162
|
+
return _summary_text(f"{decision};原因:{reason}" if reason else decision)
|
|
163
|
+
if event_type == "issue":
|
|
164
|
+
detail = message or note or code
|
|
165
|
+
if detail and reason and reason != detail:
|
|
166
|
+
return _summary_text(f"{detail};原因:{reason}")
|
|
167
|
+
return detail or "发现一项需要处理的问题。"
|
|
168
|
+
if event_type == "issue.resolve":
|
|
169
|
+
detail = message or note or code
|
|
170
|
+
return _summary_text(f"问题已解决:{detail}" if detail else "已解决此前记录的问题。")
|
|
171
|
+
if event_type == "phase.start":
|
|
172
|
+
return _summary_text(
|
|
173
|
+
f"开始执行{phase_label}阶段:{note}" if note else f"开始执行{phase_label}阶段。"
|
|
174
|
+
)
|
|
175
|
+
if event_type in {"phase.end", "phase.auto_sealed"}:
|
|
176
|
+
detail = note or status
|
|
177
|
+
return _summary_text(
|
|
178
|
+
f"{phase_label}阶段已结束:{detail}" if detail else f"{phase_label}阶段已结束。"
|
|
179
|
+
)
|
|
180
|
+
if event_type == "command":
|
|
181
|
+
detail = name or note
|
|
182
|
+
return _summary_text(f"执行步骤:{detail}" if detail else "执行了一项工作步骤。")
|
|
183
|
+
if event_type == "verification":
|
|
184
|
+
detail = name or note or status
|
|
185
|
+
return _summary_text(f"完成验证:{detail}" if detail else "完成了一项结果验证。")
|
|
186
|
+
if event_type == "artifact":
|
|
187
|
+
detail = name or note
|
|
188
|
+
return _summary_text(f"生成或更新产物:{detail}" if detail else "生成或更新了一项交付内容。")
|
|
189
|
+
if event_type == "correction":
|
|
190
|
+
detail = note or reason or message
|
|
191
|
+
return _summary_text(f"调整执行方式:{detail}" if detail else "根据当前结果调整了执行方式。")
|
|
192
|
+
if event_type == "change.rename":
|
|
193
|
+
return note or message or "更新了变更名称。"
|
|
194
|
+
if event_type in {"recovery", "phase.recovery", "attempt.recovery"}:
|
|
195
|
+
return note or reason or message or "恢复了中断的运行状态。"
|
|
196
|
+
if event_type == "heartbeat":
|
|
197
|
+
return "客户端保持在线,并同步了最新运行状态。"
|
|
198
|
+
|
|
199
|
+
return note or message or name or reason or code or "记录了一项运行事件。"
|
|
200
|
+
|
|
201
|
+
|
|
90
202
|
def sanitize(event: dict[str, Any]) -> dict[str, Any]:
|
|
91
|
-
|
|
203
|
+
payload = {key: event[key] for key in WHITELIST if key in event}
|
|
204
|
+
payload["summary"] = build_event_summary(event)
|
|
205
|
+
return payload
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _valid_display_title(value: Any) -> str | None:
|
|
209
|
+
if not isinstance(value, str):
|
|
210
|
+
return None
|
|
211
|
+
title = value.strip()
|
|
212
|
+
if (
|
|
213
|
+
not title
|
|
214
|
+
or len(title) > DISPLAY_TITLE_MAX_LENGTH
|
|
215
|
+
or any(ord(character) < 32 or ord(character) == 127 for character in title)
|
|
216
|
+
):
|
|
217
|
+
return None
|
|
218
|
+
return title
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def _safe_file_within(change_dir: Path, path: Path) -> Path | None:
|
|
222
|
+
try:
|
|
223
|
+
root = change_dir.resolve()
|
|
224
|
+
resolved = path.resolve()
|
|
225
|
+
except OSError:
|
|
226
|
+
return None
|
|
227
|
+
if path.is_symlink() or not resolved.is_relative_to(root) or not resolved.is_file():
|
|
228
|
+
return None
|
|
229
|
+
return resolved
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def load_display_title(change_dir: Path, change_key: str) -> str:
|
|
233
|
+
metadata_path = _safe_file_within(
|
|
234
|
+
change_dir, change_dir / "meta" / "change-title.json"
|
|
235
|
+
)
|
|
236
|
+
if metadata_path is not None:
|
|
237
|
+
try:
|
|
238
|
+
payload = json.loads(metadata_path.read_text(encoding="utf-8-sig"))
|
|
239
|
+
except (OSError, json.JSONDecodeError):
|
|
240
|
+
payload = None
|
|
241
|
+
if isinstance(payload, dict):
|
|
242
|
+
title = _valid_display_title(payload.get("displayTitle"))
|
|
243
|
+
if title is not None:
|
|
244
|
+
return title
|
|
245
|
+
|
|
246
|
+
# Legacy migration: older Plan runs already wrote a human title into the
|
|
247
|
+
# approved design H1 but had no structured title metadata.
|
|
248
|
+
design_path = _safe_file_within(
|
|
249
|
+
change_dir, change_dir / "spec" / f"{change_key}-design.md"
|
|
250
|
+
)
|
|
251
|
+
if design_path is not None:
|
|
252
|
+
try:
|
|
253
|
+
with design_path.open("r", encoding="utf-8-sig") as stream:
|
|
254
|
+
for _ in range(40):
|
|
255
|
+
line = stream.readline()
|
|
256
|
+
if not line:
|
|
257
|
+
break
|
|
258
|
+
if not line.startswith("# "):
|
|
259
|
+
continue
|
|
260
|
+
candidate = re.sub(
|
|
261
|
+
r"\s+(?:设计文档|设计方案|设计)$", "", line[2:].strip()
|
|
262
|
+
)
|
|
263
|
+
title = _valid_display_title(candidate)
|
|
264
|
+
if title is not None and title != change_key:
|
|
265
|
+
return title
|
|
266
|
+
break
|
|
267
|
+
except OSError:
|
|
268
|
+
pass
|
|
269
|
+
return change_key
|
|
92
270
|
|
|
93
271
|
|
|
94
272
|
def cursor_path(change_dir: Path) -> Path:
|
|
@@ -252,6 +430,7 @@ def sync_change(
|
|
|
252
430
|
resolved_key = change_key or change_dir.name
|
|
253
431
|
rid = run_id or run_id_for(change_dir)
|
|
254
432
|
project_id = endpoint["project_id"]
|
|
433
|
+
display_title = load_display_title(change_dir, resolved_key)
|
|
255
434
|
|
|
256
435
|
# Always heartbeat so the console can separate connection vs run status.
|
|
257
436
|
try:
|
|
@@ -264,7 +443,7 @@ def sync_change(
|
|
|
264
443
|
"run_id": rid,
|
|
265
444
|
"change_key": resolved_key,
|
|
266
445
|
"client_time": client_time,
|
|
267
|
-
"title":
|
|
446
|
+
"title": display_title,
|
|
268
447
|
},
|
|
269
448
|
)
|
|
270
449
|
except (urllib.error.URLError, TimeoutError, OSError, json.JSONDecodeError) as exc:
|
|
@@ -337,7 +516,7 @@ def sync_change(
|
|
|
337
516
|
"protocol_version": "hunter-progress-sync/v1",
|
|
338
517
|
"run_id": rid,
|
|
339
518
|
"change_key": resolved_key,
|
|
340
|
-
"title":
|
|
519
|
+
"title": display_title,
|
|
341
520
|
"events": batch,
|
|
342
521
|
},
|
|
343
522
|
)
|
|
@@ -607,6 +786,39 @@ def _discover_changes(project_root: Path) -> list[Path]:
|
|
|
607
786
|
return sorted(path for path in root.glob("*") if path.is_dir()) if root.is_dir() else []
|
|
608
787
|
|
|
609
788
|
|
|
789
|
+
def _change_has_open_phase(change_dir: Path) -> bool:
|
|
790
|
+
"""Project the append-only stream into open/closed phase state."""
|
|
791
|
+
try:
|
|
792
|
+
path = Path(harness_paths.resolve_state_dir_for_contract(change_dir)) / "events.ndjson"
|
|
793
|
+
except (OSError, ValueError):
|
|
794
|
+
return False
|
|
795
|
+
if not path.is_file():
|
|
796
|
+
return False
|
|
797
|
+
open_phases: dict[str, bool] = {}
|
|
798
|
+
try:
|
|
799
|
+
for line in path.read_text(encoding="utf-8-sig").splitlines():
|
|
800
|
+
if not line.strip():
|
|
801
|
+
continue
|
|
802
|
+
event = json.loads(line)
|
|
803
|
+
if not isinstance(event, dict):
|
|
804
|
+
continue
|
|
805
|
+
phase = event.get("phase")
|
|
806
|
+
event_type = event.get("type")
|
|
807
|
+
if not isinstance(phase, str) or not phase:
|
|
808
|
+
continue
|
|
809
|
+
if event_type == "phase.start":
|
|
810
|
+
open_phases[phase] = True
|
|
811
|
+
elif event_type in {"phase.end", "phase.auto_sealed", "workflow.end", "run.end"}:
|
|
812
|
+
open_phases[phase] = False
|
|
813
|
+
except (OSError, json.JSONDecodeError):
|
|
814
|
+
return False
|
|
815
|
+
return any(open_phases.values())
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
def _project_has_open_phase(project_root: Path) -> bool:
|
|
819
|
+
return any(_change_has_open_phase(path) for path in _discover_changes(project_root))
|
|
820
|
+
|
|
821
|
+
|
|
610
822
|
def _run_agent_session(project_root: Path) -> dict[str, Any]:
|
|
611
823
|
attempts = 0
|
|
612
824
|
uploaded = 0
|
|
@@ -619,14 +831,28 @@ def _run_agent_session(project_root: Path) -> dict[str, Any]:
|
|
|
619
831
|
if all(item.get("ok") for item in results):
|
|
620
832
|
time.sleep(0.6)
|
|
621
833
|
if generation == _read_nudge_generation(project_root):
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
834
|
+
if not _project_has_open_phase(project_root):
|
|
835
|
+
return {
|
|
836
|
+
"ok": True,
|
|
837
|
+
"uploaded": uploaded,
|
|
838
|
+
"quarantined": quarantined,
|
|
839
|
+
"attempts": attempts + 1,
|
|
840
|
+
}
|
|
841
|
+
# Keep a finite workflow lease alive while a phase is open.
|
|
842
|
+
# A phase.end nudge is observed on the next pass and releases
|
|
843
|
+
# the worker naturally; no terminal window is created.
|
|
844
|
+
time.sleep(10.0)
|
|
845
|
+
heartbeat_results = [
|
|
846
|
+
sync_change(project_root, path, heartbeat_only=True)
|
|
847
|
+
for path in _discover_changes(project_root)
|
|
848
|
+
]
|
|
849
|
+
if all(item.get("ok") for item in heartbeat_results):
|
|
850
|
+
attempts = 0
|
|
851
|
+
continue
|
|
852
|
+
results = heartbeat_results
|
|
628
853
|
attempts = 0
|
|
629
|
-
|
|
854
|
+
if generation != _read_nudge_generation(project_root):
|
|
855
|
+
continue
|
|
630
856
|
time.sleep(min(16.0, float(2 ** attempts)))
|
|
631
857
|
attempts += 1
|
|
632
858
|
return {
|
|
@@ -30,6 +30,7 @@ if str(SCRIPTS_DIR) not in sys.path:
|
|
|
30
30
|
sys.path.insert(0, str(SCRIPTS_DIR))
|
|
31
31
|
|
|
32
32
|
import harness_change as hc # noqa: E402
|
|
33
|
+
import harness_context as hctx # noqa: E402
|
|
33
34
|
import harness_events as he # noqa: E402
|
|
34
35
|
import harness_events_sync as hes # noqa: E402
|
|
35
36
|
import harness_ledger as hl # noqa: E402
|
|
@@ -1602,6 +1603,18 @@ def append_phase_event(
|
|
|
1602
1603
|
auto_sealed: list[dict[str, Any]] = []
|
|
1603
1604
|
with he.event_file_lock(lock_path):
|
|
1604
1605
|
existing = he.load_events(events_file)
|
|
1606
|
+
phase_attempts = he.split_phase_attempts(
|
|
1607
|
+
[event for event in existing if event.get("phase") == phase]
|
|
1608
|
+
)
|
|
1609
|
+
latest_attempt = max(
|
|
1610
|
+
(
|
|
1611
|
+
int(item.get("attempt"))
|
|
1612
|
+
for item in phase_attempts
|
|
1613
|
+
if isinstance(item.get("attempt"), int)
|
|
1614
|
+
),
|
|
1615
|
+
default=0,
|
|
1616
|
+
)
|
|
1617
|
+
event_attempt = latest_attempt + 1 if type_ == "phase.start" else latest_attempt or 1
|
|
1605
1618
|
args = argparse.Namespace(
|
|
1606
1619
|
phase=phase,
|
|
1607
1620
|
type=type_,
|
|
@@ -1619,12 +1632,18 @@ def append_phase_event(
|
|
|
1619
1632
|
decision=None,
|
|
1620
1633
|
reason=None,
|
|
1621
1634
|
run_id=run_id,
|
|
1622
|
-
attempt=
|
|
1635
|
+
attempt=event_attempt,
|
|
1623
1636
|
executor_tool=executor_tool,
|
|
1624
1637
|
executor_agent=executor_agent,
|
|
1625
1638
|
executor_model=executor_model,
|
|
1626
1639
|
handoff_from_tool=None,
|
|
1627
1640
|
handoff_reason=None,
|
|
1641
|
+
execution_mode=None,
|
|
1642
|
+
decision_reason_code=None,
|
|
1643
|
+
fallback_reason_code=None,
|
|
1644
|
+
trigger=("fixback" if "fixback" in note.lower() else None),
|
|
1645
|
+
from_phase=("review" if phase == "run" and "fixback" in note.lower() else None),
|
|
1646
|
+
result_status=None,
|
|
1628
1647
|
)
|
|
1629
1648
|
event = he.build_event(args, existing)
|
|
1630
1649
|
if identity:
|
|
@@ -1655,6 +1674,7 @@ def append_phase_event(
|
|
|
1655
1674
|
content = he.render_execution_log(events)
|
|
1656
1675
|
log_path = he.write_execution_log(change_dir, content)
|
|
1657
1676
|
rendered = True
|
|
1677
|
+
he.nudge_remote_sync(change_dir)
|
|
1658
1678
|
return {
|
|
1659
1679
|
"ok": True,
|
|
1660
1680
|
"eventId": event.get("id"),
|
|
@@ -1702,6 +1722,80 @@ def _phase_event_exists(change_dir: Path, phase: str, type_: str, run_id: str) -
|
|
|
1702
1722
|
)
|
|
1703
1723
|
|
|
1704
1724
|
|
|
1725
|
+
def _latest_phase_end(
|
|
1726
|
+
change_dir: Path,
|
|
1727
|
+
phase: str,
|
|
1728
|
+
run_id: str | None = None,
|
|
1729
|
+
) -> dict[str, Any] | None:
|
|
1730
|
+
for event in reversed(he.load_events(he.events_path(change_dir))):
|
|
1731
|
+
if event.get("phase") != phase or event.get("type") != "phase.end":
|
|
1732
|
+
continue
|
|
1733
|
+
if run_id and event.get("run_id") != run_id:
|
|
1734
|
+
continue
|
|
1735
|
+
return event
|
|
1736
|
+
return None
|
|
1737
|
+
|
|
1738
|
+
|
|
1739
|
+
def _terminal_matches_context_session(
|
|
1740
|
+
project: Path,
|
|
1741
|
+
change_id: str,
|
|
1742
|
+
phase: str,
|
|
1743
|
+
terminal: dict[str, Any],
|
|
1744
|
+
) -> bool:
|
|
1745
|
+
view = hctx.context_view(project, change_id)
|
|
1746
|
+
current = view.get("current") if isinstance(view, dict) else None
|
|
1747
|
+
if not isinstance(current, dict) or current.get("phase") != phase:
|
|
1748
|
+
return False
|
|
1749
|
+
prepared_at = he.parse_timestamp(current.get("preparedAt"))
|
|
1750
|
+
terminal_at = he.parse_timestamp(
|
|
1751
|
+
terminal.get("timestamp") or terminal.get("occurred_at")
|
|
1752
|
+
)
|
|
1753
|
+
return (
|
|
1754
|
+
prepared_at is not None
|
|
1755
|
+
and terminal_at is not None
|
|
1756
|
+
and terminal_at >= prepared_at
|
|
1757
|
+
)
|
|
1758
|
+
|
|
1759
|
+
|
|
1760
|
+
def _close_context_handoff(
|
|
1761
|
+
project: Path,
|
|
1762
|
+
change_id: str,
|
|
1763
|
+
args: argparse.Namespace,
|
|
1764
|
+
*,
|
|
1765
|
+
status: str,
|
|
1766
|
+
) -> dict[str, Any] | None:
|
|
1767
|
+
to_phase = getattr(args, "to_phase", None)
|
|
1768
|
+
if not to_phase:
|
|
1769
|
+
return None
|
|
1770
|
+
try:
|
|
1771
|
+
return hctx.close_transition(
|
|
1772
|
+
project,
|
|
1773
|
+
change_id,
|
|
1774
|
+
from_phase=args.phase,
|
|
1775
|
+
to_phase=str(to_phase),
|
|
1776
|
+
executor=getattr(args, "executor", None),
|
|
1777
|
+
artifacts=list(getattr(args, "artifact", None) or []),
|
|
1778
|
+
status=status,
|
|
1779
|
+
)
|
|
1780
|
+
except Exception as exc: # noqa: BLE001 — phase close remains locally durable
|
|
1781
|
+
return {
|
|
1782
|
+
"ok": False,
|
|
1783
|
+
"code": "CONTEXT_HANDOFF_FAILED",
|
|
1784
|
+
"message": str(exc),
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
def _sync_after_phase_close(project: Path, change_dir: Path) -> dict[str, Any]:
|
|
1789
|
+
try:
|
|
1790
|
+
return hes.auto_events_sync(project, change_dir)
|
|
1791
|
+
except Exception as exc: # noqa: BLE001 — remote sync is recoverable
|
|
1792
|
+
return {
|
|
1793
|
+
"ok": False,
|
|
1794
|
+
"code": "PLATFORM_EVENTS_SYNC_WARN",
|
|
1795
|
+
"warning": f"events-sync hook failed: {exc}",
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
|
|
1705
1799
|
def _validate_scenario_coverage(change_dir: Path) -> dict[str, Any]:
|
|
1706
1800
|
"""C9: validate all ledger-required scenarios are covered by ledger entries.
|
|
1707
1801
|
|
|
@@ -2266,6 +2360,48 @@ def cmd_close(args: argparse.Namespace) -> int:
|
|
|
2266
2360
|
explicit_run_id = args.run_id or os.environ.get("HUNTER_HARNESS_RUN_ID")
|
|
2267
2361
|
current_lease = hc.inspect_lease(project, resolved["changeId"])
|
|
2268
2362
|
if current_lease is None:
|
|
2363
|
+
terminal = _latest_phase_end(change_dir, args.phase, explicit_run_id)
|
|
2364
|
+
if (
|
|
2365
|
+
getattr(args, "to_phase", None)
|
|
2366
|
+
and terminal is not None
|
|
2367
|
+
and _terminal_matches_context_session(
|
|
2368
|
+
project, str(resolved["changeId"]), args.phase, terminal
|
|
2369
|
+
)
|
|
2370
|
+
):
|
|
2371
|
+
terminal_status = str(terminal.get("status") or args.status)
|
|
2372
|
+
handoff = _close_context_handoff(
|
|
2373
|
+
project,
|
|
2374
|
+
str(resolved["changeId"]),
|
|
2375
|
+
args,
|
|
2376
|
+
status=terminal_status,
|
|
2377
|
+
)
|
|
2378
|
+
monitor = _sync_after_phase_close(project, change_dir)
|
|
2379
|
+
if not isinstance(handoff, dict) or not handoff.get("ok"):
|
|
2380
|
+
return emit_error(
|
|
2381
|
+
"PHASE_HANDOFF_PENDING",
|
|
2382
|
+
"phase gate is closed, but context handoff still needs attention",
|
|
2383
|
+
as_json=as_json,
|
|
2384
|
+
extra={
|
|
2385
|
+
"localCloseComplete": True,
|
|
2386
|
+
"retryable": True,
|
|
2387
|
+
"contextHandoff": handoff,
|
|
2388
|
+
"platformMonitor": monitor,
|
|
2389
|
+
},
|
|
2390
|
+
)
|
|
2391
|
+
emit(
|
|
2392
|
+
{
|
|
2393
|
+
"ok": True,
|
|
2394
|
+
"code": "PHASE_CLOSE_RESUMED",
|
|
2395
|
+
"phase": args.phase,
|
|
2396
|
+
"status": terminal_status,
|
|
2397
|
+
"changeId": resolved["changeId"],
|
|
2398
|
+
"localCloseComplete": True,
|
|
2399
|
+
"contextHandoff": handoff,
|
|
2400
|
+
"platformMonitor": monitor,
|
|
2401
|
+
},
|
|
2402
|
+
as_json=as_json,
|
|
2403
|
+
)
|
|
2404
|
+
return 0
|
|
2269
2405
|
return emit_error("LEASE_ABSENT", "no active lease for phase close", as_json=as_json)
|
|
2270
2406
|
run_id = explicit_run_id or str(current_lease.get("runId") or "")
|
|
2271
2407
|
if str(current_lease.get("runId")) != run_id or str(current_lease.get("phase")) != args.phase:
|
|
@@ -2597,6 +2733,29 @@ def cmd_close(args: argparse.Namespace) -> int:
|
|
|
2597
2733
|
capsule["closeStatus"] = close_status
|
|
2598
2734
|
write_phase_capsule(change_dir, args.phase, run_id, capsule)
|
|
2599
2735
|
|
|
2736
|
+
context_handoff = _close_context_handoff(
|
|
2737
|
+
project,
|
|
2738
|
+
str(resolved["changeId"]),
|
|
2739
|
+
args,
|
|
2740
|
+
status=close_status,
|
|
2741
|
+
)
|
|
2742
|
+
platform_monitor = _sync_after_phase_close(project, change_dir)
|
|
2743
|
+
if isinstance(context_handoff, dict) and not context_handoff.get("ok"):
|
|
2744
|
+
return emit_error(
|
|
2745
|
+
"PHASE_HANDOFF_PENDING",
|
|
2746
|
+
"phase gate closed locally, but context handoff failed; retry the same close command",
|
|
2747
|
+
as_json=as_json,
|
|
2748
|
+
extra={
|
|
2749
|
+
"localCloseComplete": True,
|
|
2750
|
+
"retryable": True,
|
|
2751
|
+
"phase": args.phase,
|
|
2752
|
+
"status": close_status,
|
|
2753
|
+
"changeId": resolved["changeId"],
|
|
2754
|
+
"contextHandoff": context_handoff,
|
|
2755
|
+
"platformMonitor": platform_monitor,
|
|
2756
|
+
},
|
|
2757
|
+
)
|
|
2758
|
+
|
|
2600
2759
|
payload = {
|
|
2601
2760
|
"ok": True,
|
|
2602
2761
|
"code": close_code,
|
|
@@ -2612,6 +2771,8 @@ def cmd_close(args: argparse.Namespace) -> int:
|
|
|
2612
2771
|
"lease": release,
|
|
2613
2772
|
"gateSeverityMode": severity_mode,
|
|
2614
2773
|
"gateWarnings": gate_warnings,
|
|
2774
|
+
"contextHandoff": context_handoff,
|
|
2775
|
+
"platformMonitor": platform_monitor,
|
|
2615
2776
|
}
|
|
2616
2777
|
emit(payload, as_json=as_json)
|
|
2617
2778
|
return 0
|
|
@@ -2806,6 +2967,9 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
2806
2967
|
p_close.add_argument("--run-id", default=None)
|
|
2807
2968
|
p_close.add_argument("--task", type=int, default=None)
|
|
2808
2969
|
p_close.add_argument("--note", default="")
|
|
2970
|
+
p_close.add_argument("--to-phase", default=None)
|
|
2971
|
+
p_close.add_argument("--executor", default=None)
|
|
2972
|
+
p_close.add_argument("--artifact", action="append", default=[])
|
|
2809
2973
|
p_close.set_defaults(func=cmd_close)
|
|
2810
2974
|
|
|
2811
2975
|
p_classify = sub.add_parser("classify", parents=[shared])
|
|
@@ -1160,6 +1160,8 @@ _DYNAMIC_OWN_DIRS = ("events.ndjson", "logs", "evidence", "reports", "runtime",
|
|
|
1160
1160
|
|
|
1161
1161
|
def _matches_ownership_path(rel: str, declared: Any) -> bool:
|
|
1162
1162
|
scope = str(declared).replace("\\", "/").strip("/")
|
|
1163
|
+
if scope.endswith("/**"):
|
|
1164
|
+
scope = scope[:-3].rstrip("/")
|
|
1163
1165
|
if not scope:
|
|
1164
1166
|
return False
|
|
1165
1167
|
normalized = rel.replace("\\", "/").strip("/")
|
|
@@ -1155,6 +1155,7 @@ def finalize_plan(
|
|
|
1155
1155
|
"artifactsHash": validation["artifactsHash"],
|
|
1156
1156
|
"files": validation["files"],
|
|
1157
1157
|
"receiptPath": str(receipt_path),
|
|
1158
|
+
"artifactRef": "meta/plan-finalization.json",
|
|
1158
1159
|
}
|
|
1159
1160
|
|
|
1160
1161
|
lock_path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -1253,6 +1254,7 @@ def finalize_plan(
|
|
|
1253
1254
|
"artifactsHash": validation["artifactsHash"],
|
|
1254
1255
|
"files": validation["files"],
|
|
1255
1256
|
"receiptPath": str(receipt_path),
|
|
1257
|
+
"artifactRef": "meta/plan-finalization.json",
|
|
1256
1258
|
"executionLogPath": str(harness_events.execution_log_path(change_dir)),
|
|
1257
1259
|
}
|
|
1258
1260
|
except OSError as exc:
|
|
@@ -1593,18 +1593,15 @@ def close(project: Path | str, change_dir: Path | str) -> dict[str, Any]:
|
|
|
1593
1593
|
[],
|
|
1594
1594
|
error=str(exc),
|
|
1595
1595
|
)
|
|
1596
|
-
|
|
1596
|
+
profile_changed = bool(
|
|
1597
1597
|
isinstance(snapshot.get("profileFingerprint"), str)
|
|
1598
1598
|
and snapshot["profileFingerprint"] != current_profile_fingerprint
|
|
1599
|
-
)
|
|
1600
|
-
return _result(False, action, "PROFILE_CHANGED", [])
|
|
1599
|
+
)
|
|
1601
1600
|
baseline_commit = _snapshot_baseline_commit(
|
|
1602
1601
|
project_root,
|
|
1603
1602
|
change_root,
|
|
1604
1603
|
snapshot,
|
|
1605
1604
|
)
|
|
1606
|
-
profile_changed = False
|
|
1607
|
-
|
|
1608
1605
|
before_entries = snapshot.get("files")
|
|
1609
1606
|
if not isinstance(before_entries, list):
|
|
1610
1607
|
return _result(False, action, "SNAPSHOT_INVALID", [])
|
|
@@ -1682,11 +1679,21 @@ def close(project: Path | str, change_dir: Path | str) -> dict[str, Any]:
|
|
|
1682
1679
|
return result
|
|
1683
1680
|
|
|
1684
1681
|
recorded = [rel for rel, _ in touched]
|
|
1685
|
-
reconciliation =
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1682
|
+
reconciliation = (
|
|
1683
|
+
{
|
|
1684
|
+
"ok": True,
|
|
1685
|
+
"code": "PROFILE_REBASED_MANIFEST_PRESERVED",
|
|
1686
|
+
"removedCurrentTouches": 0,
|
|
1687
|
+
"deletedEntries": 0,
|
|
1688
|
+
"preservedForeignEntries": 0,
|
|
1689
|
+
}
|
|
1690
|
+
if profile_changed
|
|
1691
|
+
else _reconcile_close_manifest(
|
|
1692
|
+
project_root,
|
|
1693
|
+
change_root,
|
|
1694
|
+
set(recorded),
|
|
1695
|
+
baseline_commit,
|
|
1696
|
+
)
|
|
1690
1697
|
)
|
|
1691
1698
|
if not reconciliation.get("ok"):
|
|
1692
1699
|
return _result(
|
|
@@ -1696,40 +1703,26 @@ def close(project: Path | str, change_dir: Path | str) -> dict[str, Any]:
|
|
|
1696
1703
|
list(reconciliation.get("files") or []),
|
|
1697
1704
|
)
|
|
1698
1705
|
|
|
1699
|
-
#
|
|
1700
|
-
#
|
|
1701
|
-
#
|
|
1702
|
-
|
|
1703
|
-
if
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
or f.get("introducedBy") == change_id
|
|
1720
|
-
or change_id in (f.get("touchedBy") or [])
|
|
1721
|
-
)
|
|
1722
|
-
]
|
|
1723
|
-
if active_entries and not recorded:
|
|
1724
|
-
return _result(
|
|
1725
|
-
False,
|
|
1726
|
-
action,
|
|
1727
|
-
"MANIFEST_DIFF_HASH_MISMATCH",
|
|
1728
|
-
[],
|
|
1729
|
-
manifestEntries=len(active_entries),
|
|
1730
|
-
recordedCount=0,
|
|
1731
|
-
detail="manifest has active entries but close computed 0 recorded tests",
|
|
1732
|
-
)
|
|
1706
|
+
# A manifest is change-wide and intentionally survives phase boundaries.
|
|
1707
|
+
# Therefore pre-existing entries with no new diff are consistent and must
|
|
1708
|
+
# not force a test-guard reset. When the build profile changes mid-phase,
|
|
1709
|
+
# retain the diff result and rebaseline the reusable snapshot atomically.
|
|
1710
|
+
if profile_changed:
|
|
1711
|
+
snapshot.update(
|
|
1712
|
+
{
|
|
1713
|
+
"profileFingerprint": current_profile_fingerprint,
|
|
1714
|
+
"capturedAt": time.strftime("%Y-%m-%dT%H:%M:%S"),
|
|
1715
|
+
"files": [
|
|
1716
|
+
{
|
|
1717
|
+
"path": rel,
|
|
1718
|
+
"sha256": digest,
|
|
1719
|
+
"ignored": _is_ignored(project_root, rel),
|
|
1720
|
+
}
|
|
1721
|
+
for rel, digest in sorted(current.items())
|
|
1722
|
+
],
|
|
1723
|
+
}
|
|
1724
|
+
)
|
|
1725
|
+
_write_json(snapshot_path, snapshot)
|
|
1733
1726
|
|
|
1734
1727
|
return _result(
|
|
1735
1728
|
True,
|