@hunter-harness/workflow-harness 0.2.13 → 0.2.15
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 +1 -1
- package/harness/bundles/general/claude-code/harness-review/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-run/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-run/reference.md +3 -1
- package/harness/bundles/general/claude-code/harness-submit/SKILL.md +2 -2
- package/harness/bundles/general/claude-code/harness-submit/checklist.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 +1 -1
- package/harness/bundles/general/claude-code/scripts/harness_archive.py +204 -0
- package/harness/bundles/general/claude-code/scripts/harness_change.py +310 -16
- package/harness/bundles/general/claude-code/scripts/harness_deploy.py +177 -0
- package/harness/bundles/general/claude-code/scripts/harness_events.py +113 -1
- package/harness/bundles/general/claude-code/scripts/harness_gate.py +57 -4
- package/harness/bundles/general/claude-code/scripts/harness_integration.py +67 -7
- package/harness/bundles/general/claude-code/scripts/harness_ledger.py +15 -3
- package/harness/bundles/general/claude-code/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/general/claude-code/scripts/harness_preflight.py +193 -77
- package/harness/bundles/general/claude-code/scripts/harness_state.py +12 -4
- package/harness/bundles/general/claude-code/scripts/harness_test_guard.py +86 -13
- 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 +1 -1
- package/harness/bundles/general/codebuddy/harness-review/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-run/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-run/reference.md +3 -1
- package/harness/bundles/general/codebuddy/harness-submit/SKILL.md +2 -2
- package/harness/bundles/general/codebuddy/harness-submit/checklist.md +1 -1
- package/harness/bundles/general/codebuddy/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-test/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/scripts/harness_archive.py +204 -0
- package/harness/bundles/general/codebuddy/scripts/harness_change.py +310 -16
- package/harness/bundles/general/codebuddy/scripts/harness_deploy.py +177 -0
- package/harness/bundles/general/codebuddy/scripts/harness_events.py +113 -1
- package/harness/bundles/general/codebuddy/scripts/harness_gate.py +57 -4
- package/harness/bundles/general/codebuddy/scripts/harness_integration.py +67 -7
- package/harness/bundles/general/codebuddy/scripts/harness_ledger.py +15 -3
- package/harness/bundles/general/codebuddy/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/general/codebuddy/scripts/harness_preflight.py +193 -77
- package/harness/bundles/general/codebuddy/scripts/harness_state.py +12 -4
- package/harness/bundles/general/codebuddy/scripts/harness_test_guard.py +86 -13
- 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 +1 -1
- package/harness/bundles/general/codex/harness-review/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-run/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-run/reference.md +3 -1
- package/harness/bundles/general/codex/harness-submit/SKILL.md +2 -2
- package/harness/bundles/general/codex/harness-submit/checklist.md +1 -1
- package/harness/bundles/general/codex/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-test/SKILL.md +1 -1
- package/harness/bundles/general/codex/scripts/harness_archive.py +204 -0
- package/harness/bundles/general/codex/scripts/harness_change.py +310 -16
- package/harness/bundles/general/codex/scripts/harness_deploy.py +177 -0
- package/harness/bundles/general/codex/scripts/harness_events.py +113 -1
- package/harness/bundles/general/codex/scripts/harness_gate.py +57 -4
- package/harness/bundles/general/codex/scripts/harness_integration.py +67 -7
- package/harness/bundles/general/codex/scripts/harness_ledger.py +15 -3
- package/harness/bundles/general/codex/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/general/codex/scripts/harness_preflight.py +193 -77
- package/harness/bundles/general/codex/scripts/harness_state.py +12 -4
- package/harness/bundles/general/codex/scripts/harness_test_guard.py +86 -13
- 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 +1 -1
- package/harness/bundles/general/cursor/harness-review/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-run/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-run/reference.md +3 -1
- package/harness/bundles/general/cursor/harness-submit/SKILL.md +2 -2
- package/harness/bundles/general/cursor/harness-submit/checklist.md +1 -1
- package/harness/bundles/general/cursor/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-test/SKILL.md +1 -1
- package/harness/bundles/general/cursor/scripts/harness_archive.py +204 -0
- package/harness/bundles/general/cursor/scripts/harness_change.py +310 -16
- package/harness/bundles/general/cursor/scripts/harness_deploy.py +177 -0
- package/harness/bundles/general/cursor/scripts/harness_events.py +113 -1
- package/harness/bundles/general/cursor/scripts/harness_gate.py +57 -4
- package/harness/bundles/general/cursor/scripts/harness_integration.py +67 -7
- package/harness/bundles/general/cursor/scripts/harness_ledger.py +15 -3
- package/harness/bundles/general/cursor/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/general/cursor/scripts/harness_preflight.py +193 -77
- package/harness/bundles/general/cursor/scripts/harness_state.py +12 -4
- package/harness/bundles/general/cursor/scripts/harness_test_guard.py +86 -13
- 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 +1 -1
- package/harness/bundles/java/claude-code/harness-review/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-run/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-submit/SKILL.md +2 -2
- package/harness/bundles/java/claude-code/harness-submit/checklist.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 +1 -1
- package/harness/bundles/java/claude-code/scripts/harness_archive.py +204 -0
- package/harness/bundles/java/claude-code/scripts/harness_change.py +310 -16
- package/harness/bundles/java/claude-code/scripts/harness_deploy.py +177 -0
- package/harness/bundles/java/claude-code/scripts/harness_events.py +113 -1
- package/harness/bundles/java/claude-code/scripts/harness_gate.py +57 -4
- package/harness/bundles/java/claude-code/scripts/harness_integration.py +67 -7
- package/harness/bundles/java/claude-code/scripts/harness_ledger.py +15 -3
- package/harness/bundles/java/claude-code/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/java/claude-code/scripts/harness_preflight.py +193 -77
- package/harness/bundles/java/claude-code/scripts/harness_state.py +12 -4
- package/harness/bundles/java/claude-code/scripts/harness_test_guard.py +86 -13
- 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 +1 -1
- package/harness/bundles/java/codebuddy/harness-review/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-run/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-submit/SKILL.md +2 -2
- package/harness/bundles/java/codebuddy/harness-submit/checklist.md +1 -1
- package/harness/bundles/java/codebuddy/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-test/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/scripts/harness_archive.py +204 -0
- package/harness/bundles/java/codebuddy/scripts/harness_change.py +310 -16
- package/harness/bundles/java/codebuddy/scripts/harness_deploy.py +177 -0
- package/harness/bundles/java/codebuddy/scripts/harness_events.py +113 -1
- package/harness/bundles/java/codebuddy/scripts/harness_gate.py +57 -4
- package/harness/bundles/java/codebuddy/scripts/harness_integration.py +67 -7
- package/harness/bundles/java/codebuddy/scripts/harness_ledger.py +15 -3
- package/harness/bundles/java/codebuddy/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/java/codebuddy/scripts/harness_preflight.py +193 -77
- package/harness/bundles/java/codebuddy/scripts/harness_state.py +12 -4
- package/harness/bundles/java/codebuddy/scripts/harness_test_guard.py +86 -13
- 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 +1 -1
- package/harness/bundles/java/codex/harness-review/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-run/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-submit/SKILL.md +2 -2
- package/harness/bundles/java/codex/harness-submit/checklist.md +1 -1
- package/harness/bundles/java/codex/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-test/SKILL.md +1 -1
- package/harness/bundles/java/codex/scripts/harness_archive.py +204 -0
- package/harness/bundles/java/codex/scripts/harness_change.py +310 -16
- package/harness/bundles/java/codex/scripts/harness_deploy.py +177 -0
- package/harness/bundles/java/codex/scripts/harness_events.py +113 -1
- package/harness/bundles/java/codex/scripts/harness_gate.py +57 -4
- package/harness/bundles/java/codex/scripts/harness_integration.py +67 -7
- package/harness/bundles/java/codex/scripts/harness_ledger.py +15 -3
- package/harness/bundles/java/codex/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/java/codex/scripts/harness_preflight.py +193 -77
- package/harness/bundles/java/codex/scripts/harness_state.py +12 -4
- package/harness/bundles/java/codex/scripts/harness_test_guard.py +86 -13
- 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 +1 -1
- package/harness/bundles/java/cursor/harness-review/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-run/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-submit/SKILL.md +2 -2
- package/harness/bundles/java/cursor/harness-submit/checklist.md +1 -1
- package/harness/bundles/java/cursor/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-test/SKILL.md +1 -1
- package/harness/bundles/java/cursor/scripts/harness_archive.py +204 -0
- package/harness/bundles/java/cursor/scripts/harness_change.py +310 -16
- package/harness/bundles/java/cursor/scripts/harness_deploy.py +177 -0
- package/harness/bundles/java/cursor/scripts/harness_events.py +113 -1
- package/harness/bundles/java/cursor/scripts/harness_gate.py +57 -4
- package/harness/bundles/java/cursor/scripts/harness_integration.py +67 -7
- package/harness/bundles/java/cursor/scripts/harness_ledger.py +15 -3
- package/harness/bundles/java/cursor/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/java/cursor/scripts/harness_preflight.py +193 -77
- package/harness/bundles/java/cursor/scripts/harness_state.py +12 -4
- package/harness/bundles/java/cursor/scripts/harness_test_guard.py +86 -13
- package/harness/manifests/general/claude-code.json +25 -25
- package/harness/manifests/general/codebuddy.json +25 -25
- package/harness/manifests/general/codex.json +25 -25
- package/harness/manifests/general/cursor.json +25 -25
- package/harness/manifests/java/claude-code.json +26 -26
- package/harness/manifests/java/codebuddy.json +26 -26
- package/harness/manifests/java/codex.json +26 -26
- package/harness/manifests/java/cursor.json +26 -26
- package/hunter-workflow-family.json +2 -2
- package/package.json +15 -15
|
@@ -50,6 +50,7 @@ EVENT_TYPES = frozenset(
|
|
|
50
50
|
"issue.resolve",
|
|
51
51
|
"decision",
|
|
52
52
|
"correction",
|
|
53
|
+
"change.rename",
|
|
53
54
|
}
|
|
54
55
|
)
|
|
55
56
|
|
|
@@ -94,6 +95,9 @@ OPTIONAL_FIELDS = (
|
|
|
94
95
|
"orchestration_active_ms",
|
|
95
96
|
"wall_clock_ms",
|
|
96
97
|
"user_wait_ms",
|
|
98
|
+
"renamed_from",
|
|
99
|
+
"renamed_to",
|
|
100
|
+
"change_uuid",
|
|
97
101
|
)
|
|
98
102
|
|
|
99
103
|
_PROVENANCE_FIELDS = frozenset(
|
|
@@ -144,6 +148,10 @@ _EVENT_ALLOWED_FIELDS = {
|
|
|
144
148
|
}
|
|
145
149
|
)
|
|
146
150
|
| _PROVENANCE_FIELDS,
|
|
151
|
+
"change.rename": frozenset(
|
|
152
|
+
{"renamed_from", "renamed_to", "change_uuid", "note"}
|
|
153
|
+
)
|
|
154
|
+
| _PROVENANCE_FIELDS,
|
|
147
155
|
}
|
|
148
156
|
_EVENT_REQUIRED_FIELDS = {
|
|
149
157
|
"issue": ("severity",),
|
|
@@ -506,6 +514,87 @@ def new_event_id(existing: list[dict[str, Any]] | None = None) -> str:
|
|
|
506
514
|
return f"evt-{uuid.uuid4().hex}"
|
|
507
515
|
|
|
508
516
|
|
|
517
|
+
def append_event(
|
|
518
|
+
change_dir: Path,
|
|
519
|
+
*,
|
|
520
|
+
phase: str,
|
|
521
|
+
type_: str,
|
|
522
|
+
note: str = "",
|
|
523
|
+
kind: str | None = None,
|
|
524
|
+
path: str | None = None,
|
|
525
|
+
run_id: str | None = None,
|
|
526
|
+
executor_tool: str | None = None,
|
|
527
|
+
renamed_from: str | None = None,
|
|
528
|
+
renamed_to: str | None = None,
|
|
529
|
+
change_uuid: str | None = None,
|
|
530
|
+
) -> dict[str, Any]:
|
|
531
|
+
"""Programmatic append API (retro §5.31 C5/T16).
|
|
532
|
+
|
|
533
|
+
Validates and appends an event without going through argparse. Returns
|
|
534
|
+
a payload dict with ``ok``/``code``/``event``.
|
|
535
|
+
"""
|
|
536
|
+
args = argparse.Namespace(
|
|
537
|
+
change_dir=str(change_dir),
|
|
538
|
+
phase=phase,
|
|
539
|
+
type=type_,
|
|
540
|
+
note=note,
|
|
541
|
+
kind=kind,
|
|
542
|
+
path=path,
|
|
543
|
+
run_id=run_id,
|
|
544
|
+
executor_tool=executor_tool,
|
|
545
|
+
command=None,
|
|
546
|
+
exit_code=None,
|
|
547
|
+
duration_ms=None,
|
|
548
|
+
status=None,
|
|
549
|
+
name=None,
|
|
550
|
+
code=None,
|
|
551
|
+
severity=None,
|
|
552
|
+
message=None,
|
|
553
|
+
decision=None,
|
|
554
|
+
reason=None,
|
|
555
|
+
issue_id=None,
|
|
556
|
+
scope=None,
|
|
557
|
+
target_event_id=None,
|
|
558
|
+
target_field=None,
|
|
559
|
+
old_value_hash=None,
|
|
560
|
+
new_value_json=None,
|
|
561
|
+
renamed_from=renamed_from,
|
|
562
|
+
renamed_to=renamed_to,
|
|
563
|
+
change_uuid=change_uuid,
|
|
564
|
+
attempt=None,
|
|
565
|
+
executor_agent=None,
|
|
566
|
+
executor_model=None,
|
|
567
|
+
handoff_from_tool=None,
|
|
568
|
+
handoff_reason=None,
|
|
569
|
+
trace_id=None,
|
|
570
|
+
span_id=None,
|
|
571
|
+
parent_span_id=None,
|
|
572
|
+
runner_ms=None,
|
|
573
|
+
orchestration_active_ms=None,
|
|
574
|
+
wall_clock_ms=None,
|
|
575
|
+
user_wait_ms=None,
|
|
576
|
+
legacy_lenient=False,
|
|
577
|
+
json=True,
|
|
578
|
+
)
|
|
579
|
+
as_json = True
|
|
580
|
+
if type_ not in EVENT_TYPES:
|
|
581
|
+
return {"ok": False, "code": "EVENT_TYPE_INVALID", "message": f"unsupported type: {type_}"}
|
|
582
|
+
validation = validate_append_event(args)
|
|
583
|
+
if validation:
|
|
584
|
+
error_code, message = validation
|
|
585
|
+
return {"ok": False, "code": error_code, "message": message}
|
|
586
|
+
archived = archived_change_dir(change_dir)
|
|
587
|
+
if archived is not None:
|
|
588
|
+
return {"ok": False, "code": "ARCHIVED_CHANGE_IMMUTABLE", "message": str(archived)}
|
|
589
|
+
events_path_obj = events_path(change_dir)
|
|
590
|
+
lock_path = events_path_obj.with_name(events_path_obj.name + ".lock")
|
|
591
|
+
existing = []
|
|
592
|
+
event = build_event(args, existing)
|
|
593
|
+
with event_file_lock(lock_path):
|
|
594
|
+
atomic_append_line(events_path_obj, json.dumps(event, ensure_ascii=False))
|
|
595
|
+
return {"ok": True, "event": event, "events_path": str(events_path_obj), "rendered": False}
|
|
596
|
+
|
|
597
|
+
|
|
509
598
|
def build_event(args: argparse.Namespace, existing: list[dict[str, Any]]) -> dict[str, Any]:
|
|
510
599
|
event: dict[str, Any] = {
|
|
511
600
|
"schema_version": SCHEMA_VERSION,
|
|
@@ -588,8 +677,31 @@ def validate_append_event(args: argparse.Namespace) -> tuple[str, str] | None:
|
|
|
588
677
|
except json.JSONDecodeError as exc:
|
|
589
678
|
return (
|
|
590
679
|
"CORRECTION_VALUE_INVALID_JSON",
|
|
591
|
-
f"CORRECTION_VALUE_INVALID_JSON: {exc
|
|
680
|
+
f"CORRECTION_VALUE_INVALID_JSON: {exc}",
|
|
681
|
+
)
|
|
682
|
+
# Retro §5.31: artifact events must distinguish file-backed from
|
|
683
|
+
# informational. file-backed requires a change-relative path; informational
|
|
684
|
+
# (preview/summary) must not masquerade as a file artifact. Legacy kind
|
|
685
|
+
# values (ledger, report, etc.) are treated as file-backed aliases.
|
|
686
|
+
if event_type == "artifact":
|
|
687
|
+
kind = str(getattr(args, "kind", "") or "").strip()
|
|
688
|
+
path = str(getattr(args, "path", "") or "").strip()
|
|
689
|
+
is_informational = kind == "informational"
|
|
690
|
+
if kind == "file-backed" and not path:
|
|
691
|
+
return (
|
|
692
|
+
"ARTIFACT_PATH_REQUIRED",
|
|
693
|
+
"ARTIFACT_PATH_REQUIRED: file-backed artifact requires --path",
|
|
694
|
+
)
|
|
695
|
+
# If kind is explicitly informational, path is optional. If kind is
|
|
696
|
+
# absent and path is absent, reject (can't infer file-backed without path).
|
|
697
|
+
if not kind and not path:
|
|
698
|
+
return (
|
|
699
|
+
"ARTIFACT_PATH_REQUIRED",
|
|
700
|
+
"ARTIFACT_PATH_REQUIRED: artifact without --kind or --path is ambiguous; "
|
|
701
|
+
"use --kind informational for previews or --path for file artifacts",
|
|
592
702
|
)
|
|
703
|
+
# If no kind is provided, infer from path presence: a path implies
|
|
704
|
+
# file-backed, absence implies informational (legacy compatibility).
|
|
593
705
|
return None
|
|
594
706
|
|
|
595
707
|
|
|
@@ -329,6 +329,12 @@ def validate_ledger_entry_v2(entry: dict[str, Any], verification: str) -> tuple[
|
|
|
329
329
|
|
|
330
330
|
Returns ``(missing_fields, degraded_ok)`` where ``degraded_ok`` is True only when
|
|
331
331
|
the entry is a valid DEGRADED NOT_RUN record with no other missing fields.
|
|
332
|
+
|
|
333
|
+
Retro §5.14: ``status=OK``/``status=NOT_RUN``/``status=FAIL`` in the
|
|
334
|
+
missing list is a *status value* hint, not a field-completeness defect.
|
|
335
|
+
Callers consuming this under ``phase_status=FAIL`` must filter out
|
|
336
|
+
``status=*`` entries from the missing list before treating them as
|
|
337
|
+
blocking problems.
|
|
332
338
|
"""
|
|
333
339
|
missing: list[str] = []
|
|
334
340
|
degraded = is_degraded_ledger_entry(entry)
|
|
@@ -341,7 +347,7 @@ def validate_ledger_entry_v2(entry: dict[str, Any], verification: str) -> tuple[
|
|
|
341
347
|
missing.append("inputsFiles(non-empty)")
|
|
342
348
|
elif field == "status":
|
|
343
349
|
if value != "OK" and not degraded:
|
|
344
|
-
missing.append("status=
|
|
350
|
+
missing.append(f"status={value}")
|
|
345
351
|
elif not (isinstance(value, str) and value.strip()):
|
|
346
352
|
missing.append(field)
|
|
347
353
|
elif field == "coverage" and str(value).strip() not in hl.COVERAGE_RANK:
|
|
@@ -357,8 +363,16 @@ def validate_ledger_for_phase_close(
|
|
|
357
363
|
policy: dict[str, Any],
|
|
358
364
|
*,
|
|
359
365
|
execution_root: Path | None = None,
|
|
366
|
+
phase_status: str = "OK",
|
|
360
367
|
) -> dict[str, Any]:
|
|
361
|
-
"""Validate ledger v2 fields required for phase close (UT-026).
|
|
368
|
+
"""Validate ledger v2 fields required for phase close (UT-026).
|
|
369
|
+
|
|
370
|
+
Retro §5.14: ``phase_status`` separates phase outcome from promotion gate.
|
|
371
|
+
``phase_status=OK`` (default) requires all required validations to be OK;
|
|
372
|
+
``phase_status=FAIL`` validates field completeness and identity but allows
|
|
373
|
+
individual validation status to be FAIL/NOT_RUN, so a failing phase can
|
|
374
|
+
close honestly without polluting evidence or blocking lease release.
|
|
375
|
+
"""
|
|
362
376
|
required = policy.get("requiredValidations", {}).get(phase, [])
|
|
363
377
|
if not required:
|
|
364
378
|
return {"ok": True, "code": "LEDGER_NOT_REQUIRED", "phase": phase}
|
|
@@ -443,6 +457,7 @@ def validate_ledger_for_phase_close(
|
|
|
443
457
|
|
|
444
458
|
problems: list[dict[str, Any]] = []
|
|
445
459
|
degraded: list[str] = []
|
|
460
|
+
fail_status: list[str] = []
|
|
446
461
|
for verification in required:
|
|
447
462
|
entry = validations.get(verification)
|
|
448
463
|
if not isinstance(entry, dict):
|
|
@@ -455,6 +470,12 @@ def validate_ledger_for_phase_close(
|
|
|
455
470
|
)
|
|
456
471
|
continue
|
|
457
472
|
missing, is_degraded = validate_ledger_entry_v2(entry, verification)
|
|
473
|
+
# Retro §5.14: under phase_status=FAIL/WARN, status value hints
|
|
474
|
+
# (status=FAIL, status=NOT_RUN) are acceptable; only real field-
|
|
475
|
+
# completeness defects block close. Under phase_status=OK, status
|
|
476
|
+
# value hints are blocking.
|
|
477
|
+
if phase_status.upper() in {"FAIL", "WARN"}:
|
|
478
|
+
missing = [m for m in missing if not m.startswith("status=")]
|
|
458
479
|
if missing:
|
|
459
480
|
code = (
|
|
460
481
|
"MISSING_V2_FIELDS"
|
|
@@ -476,8 +497,21 @@ def validate_ledger_for_phase_close(
|
|
|
476
497
|
"code": code,
|
|
477
498
|
}
|
|
478
499
|
)
|
|
479
|
-
|
|
500
|
+
continue
|
|
501
|
+
if is_degraded:
|
|
480
502
|
degraded.append(verification)
|
|
503
|
+
continue
|
|
504
|
+
# Under phase_status=FAIL/WARN, a FAIL/NOT_RUN status is acceptable.
|
|
505
|
+
entry_status = str(entry.get("status") or "").upper()
|
|
506
|
+
if entry_status in {"FAIL", "NOT_RUN"}:
|
|
507
|
+
if phase_status.upper() in {"FAIL", "WARN"}:
|
|
508
|
+
fail_status.append(verification)
|
|
509
|
+
else:
|
|
510
|
+
problems.append({
|
|
511
|
+
"verification": verification,
|
|
512
|
+
"missing": [f"status={entry_status}"],
|
|
513
|
+
"code": "VALIDATION_NOT_OK",
|
|
514
|
+
})
|
|
481
515
|
|
|
482
516
|
if problems:
|
|
483
517
|
return {
|
|
@@ -489,6 +523,16 @@ def validate_ledger_for_phase_close(
|
|
|
489
523
|
"ledgerPath": str(ledger_path) if ledger_path else None,
|
|
490
524
|
"detail": "natural-language override is not permitted",
|
|
491
525
|
}
|
|
526
|
+
if fail_status:
|
|
527
|
+
return {
|
|
528
|
+
"ok": True,
|
|
529
|
+
"code": "LEDGER_OK_FAIL",
|
|
530
|
+
"phase": phase,
|
|
531
|
+
"validated": required,
|
|
532
|
+
"failed": fail_status,
|
|
533
|
+
"degraded": degraded,
|
|
534
|
+
"ledgerPath": str(ledger_path) if ledger_path else None,
|
|
535
|
+
}
|
|
492
536
|
if degraded:
|
|
493
537
|
return {
|
|
494
538
|
"ok": True,
|
|
@@ -1169,6 +1213,14 @@ def cmd_begin(args: argparse.Namespace) -> int:
|
|
|
1169
1213
|
extra={k: v for k, v in resolved.items() if k not in {"ok", "message"}},
|
|
1170
1214
|
)
|
|
1171
1215
|
change_dir = Path(resolved["changeDir"])
|
|
1216
|
+
concurrency_block = hc.check_concurrency_block(project, resolved["changeId"])
|
|
1217
|
+
if concurrency_block is not None:
|
|
1218
|
+
return emit_error(
|
|
1219
|
+
str(concurrency_block.get("code", "CONCURRENCY_BLOCKED")),
|
|
1220
|
+
str(concurrency_block.get("message", "concurrency mode blocked begin")),
|
|
1221
|
+
as_json=as_json,
|
|
1222
|
+
extra={k: v for k, v in concurrency_block.items() if k not in {"ok", "message"}},
|
|
1223
|
+
)
|
|
1172
1224
|
blocked = foundation_gate_blocks(getattr(args, "task", None), change_dir)
|
|
1173
1225
|
if blocked:
|
|
1174
1226
|
return emit_error(
|
|
@@ -1407,7 +1459,8 @@ def cmd_close(args: argparse.Namespace) -> int:
|
|
|
1407
1459
|
return emit_error("PHASE_CAPSULE_MISMATCH", str(exc), as_json=as_json)
|
|
1408
1460
|
|
|
1409
1461
|
ledger_result = validate_ledger_for_phase_close(
|
|
1410
|
-
change_dir, args.phase, policy, execution_root=execution_root
|
|
1462
|
+
change_dir, args.phase, policy, execution_root=execution_root,
|
|
1463
|
+
phase_status=args.status,
|
|
1411
1464
|
)
|
|
1412
1465
|
if not ledger_result.get("ok") and args.phase in {"run", "test", "package"}:
|
|
1413
1466
|
return emit_error(
|
|
@@ -84,6 +84,12 @@ class TargetMovedError(IntegrationError):
|
|
|
84
84
|
code = "TARGET_MOVED"
|
|
85
85
|
|
|
86
86
|
|
|
87
|
+
class RemoteProbeFailedError(IntegrationError):
|
|
88
|
+
"""Remote probe failed (network/auth/process error), not target moved (retro §5.28)."""
|
|
89
|
+
|
|
90
|
+
code = "REMOTE_PROBE_FAILED"
|
|
91
|
+
|
|
92
|
+
|
|
87
93
|
class LedgerSyncError(IntegrationError):
|
|
88
94
|
code = "LEDGER_SYNC_PENDING"
|
|
89
95
|
|
|
@@ -139,6 +145,52 @@ class GitRunner:
|
|
|
139
145
|
return None
|
|
140
146
|
return proc.stdout.strip()
|
|
141
147
|
|
|
148
|
+
def remote_probe(self, cwd: Path, *args: str) -> dict[str, Any]:
|
|
149
|
+
"""Typed remote probe result (retro §5.28).
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
{
|
|
153
|
+
"exitCode": int,
|
|
154
|
+
"stdoutHash": str | None, # first whitespace-delimited token
|
|
155
|
+
"redactedStderr": str, # stderr with credentials redacted
|
|
156
|
+
"category": "ok" | "target-moved" | "probe-failed" | "auth-failed",
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
`category` distinguishes:
|
|
160
|
+
- `ok`: exit=0, hash available
|
|
161
|
+
- `target-moved`: only meaningful when caller compares hash to expected
|
|
162
|
+
- `probe-failed`: exit!=0, network/process error (allow bounded retry)
|
|
163
|
+
- `auth-failed`: exit!=0, stderr contains auth/credential indicators
|
|
164
|
+
|
|
165
|
+
`None` must never enter the "found head" field; callers must branch on
|
|
166
|
+
`exitCode` before comparing hashes.
|
|
167
|
+
"""
|
|
168
|
+
proc = self.run(cwd, *args, check=False)
|
|
169
|
+
stderr = (proc.stderr or "").strip()
|
|
170
|
+
# Redact potential credentials in stderr (URLs with user:pass@, tokens)
|
|
171
|
+
redacted = re.sub(
|
|
172
|
+
r"(https?|ssh)://[^\s]+@[^\s]+", r"\1://***@***", stderr
|
|
173
|
+
)
|
|
174
|
+
redacted = re.sub(r"(token|password|secret|key)\s*[:=]\s*\S+", r"\1=***", redacted, flags=re.I)
|
|
175
|
+
stdout_hash: str | None = None
|
|
176
|
+
if proc.returncode == 0:
|
|
177
|
+
stdout = (proc.stdout or "").strip()
|
|
178
|
+
if stdout:
|
|
179
|
+
stdout_hash = stdout.split()[0]
|
|
180
|
+
# Classify category
|
|
181
|
+
if proc.returncode == 0:
|
|
182
|
+
category = "ok"
|
|
183
|
+
elif re.search(r"auth|credential|permission|forbidden|unauthorized", stderr, re.I):
|
|
184
|
+
category = "auth-failed"
|
|
185
|
+
else:
|
|
186
|
+
category = "probe-failed"
|
|
187
|
+
return {
|
|
188
|
+
"exitCode": proc.returncode,
|
|
189
|
+
"stdoutHash": stdout_hash,
|
|
190
|
+
"redactedStderr": redacted,
|
|
191
|
+
"category": category,
|
|
192
|
+
}
|
|
193
|
+
|
|
142
194
|
|
|
143
195
|
def _sanitize(value: str) -> str:
|
|
144
196
|
return re.sub(r"[^A-Za-z0-9._-]+", "-", value).strip("-") or "txn"
|
|
@@ -422,6 +474,9 @@ class IntegrationTransaction:
|
|
|
422
474
|
else:
|
|
423
475
|
result = hl.record_integration_hashes(
|
|
424
476
|
ledger_path,
|
|
477
|
+
change_dir=(
|
|
478
|
+
self.project_root / ".harness" / "changes" / self.change_id
|
|
479
|
+
),
|
|
425
480
|
repository_id=str(journal["repositoryId"]),
|
|
426
481
|
merge_final_hash=merge_commit,
|
|
427
482
|
ci_expected_head=merge_commit,
|
|
@@ -760,16 +815,21 @@ class IntegrationTransaction:
|
|
|
760
815
|
f"{expected_local}, found {current_target}"
|
|
761
816
|
)
|
|
762
817
|
if journal.get("remoteTargetHead"):
|
|
763
|
-
|
|
818
|
+
# Use typed remote probe (retro §5.28): distinguish probe failure
|
|
819
|
+
# (network/auth/process) from genuine target movement. `None`
|
|
820
|
+
# must never enter the "found head" field.
|
|
821
|
+
probe = self.runner.remote_probe(
|
|
764
822
|
self.project_root, "ls-remote", "origin", self.target_branch
|
|
765
823
|
)
|
|
766
|
-
current_remote = (
|
|
767
|
-
remote_line.split()[0]
|
|
768
|
-
if remote_line and remote_line.split()
|
|
769
|
-
else None
|
|
770
|
-
)
|
|
771
824
|
expected_remote = journal.get("remoteTargetHead")
|
|
772
|
-
if
|
|
825
|
+
if probe["exitCode"] != 0:
|
|
826
|
+
# Probe failed: network/auth/process error, not target moved.
|
|
827
|
+
raise RemoteProbeFailedError(
|
|
828
|
+
f"remote probe failed (exit={probe['exitCode']}, "
|
|
829
|
+
f"category={probe['category']}): {probe['redactedStderr']}"
|
|
830
|
+
)
|
|
831
|
+
current_remote = probe["stdoutHash"]
|
|
832
|
+
if current_remote is not None and current_remote != expected_remote:
|
|
773
833
|
raise TargetMovedError(
|
|
774
834
|
f"remote {self.target_branch} moved: expected "
|
|
775
835
|
f"{expected_remote}, found {current_remote}"
|
|
@@ -621,12 +621,13 @@ def validate_ledger_identity(ledger: dict[str, Any]) -> list[str]:
|
|
|
621
621
|
def record_integration_hashes(
|
|
622
622
|
ledger_path: Path,
|
|
623
623
|
*,
|
|
624
|
+
change_dir: Path | None = None,
|
|
624
625
|
repository_id: str,
|
|
625
626
|
merge_final_hash: str,
|
|
626
627
|
ci_expected_head: str,
|
|
627
628
|
remote_head: str,
|
|
628
629
|
) -> dict[str, Any]:
|
|
629
|
-
"""Atomically attach post-push
|
|
630
|
+
"""Atomically attach post-push hashes using the change contract's ledger rules."""
|
|
630
631
|
path = Path(ledger_path).resolve()
|
|
631
632
|
if not path.is_file():
|
|
632
633
|
return {"ok": False, "code": "LEDGER_MISSING", "ledgerPath": str(path)}
|
|
@@ -637,15 +638,26 @@ def record_integration_hashes(
|
|
|
637
638
|
"ok": False, "code": "LEDGER_INVALID", "ledgerPath": str(path),
|
|
638
639
|
"message": str(exc),
|
|
639
640
|
}
|
|
641
|
+
legacy_contract = False
|
|
642
|
+
if change_dir is not None:
|
|
643
|
+
resolved_change_dir = Path(change_dir).resolve()
|
|
644
|
+
if ledger.get("changeName") != resolved_change_dir.name:
|
|
645
|
+
return {
|
|
646
|
+
"ok": False,
|
|
647
|
+
"code": "LEDGER_CHANGE_MISMATCH",
|
|
648
|
+
"ledgerPath": str(path),
|
|
649
|
+
}
|
|
650
|
+
legacy_contract = not _contract_is_v2(resolved_change_dir)
|
|
651
|
+
|
|
640
652
|
missing = validate_ledger_identity(ledger)
|
|
641
|
-
if missing:
|
|
653
|
+
if missing and not legacy_contract:
|
|
642
654
|
return {
|
|
643
655
|
"ok": False,
|
|
644
656
|
"code": "LEDGER_IDENTITY_INVALID",
|
|
645
657
|
"ledgerPath": str(path),
|
|
646
658
|
"missing": missing,
|
|
647
659
|
}
|
|
648
|
-
if ledger.get("repositoryId") != repository_id:
|
|
660
|
+
if not missing and ledger.get("repositoryId") != repository_id:
|
|
649
661
|
return {
|
|
650
662
|
"ok": False,
|
|
651
663
|
"code": "LEDGER_REPOSITORY_MISMATCH",
|
|
@@ -177,6 +177,82 @@ def _terminal_exists(change_dir: Path, run_id: str, attempt: int) -> bool:
|
|
|
177
177
|
)
|
|
178
178
|
|
|
179
179
|
|
|
180
|
+
def _read_design_capabilities(staging: Path, change_name: str) -> list[str]:
|
|
181
|
+
"""Read capabilities from design frontmatter (retro §5.4)."""
|
|
182
|
+
design_path = staging / "spec" / f"{change_name}-design.md"
|
|
183
|
+
if not design_path.is_file():
|
|
184
|
+
return []
|
|
185
|
+
try:
|
|
186
|
+
text = design_path.read_text(encoding="utf-8-sig")
|
|
187
|
+
except OSError:
|
|
188
|
+
return []
|
|
189
|
+
frontmatter = _frontmatter(text)
|
|
190
|
+
if not frontmatter:
|
|
191
|
+
return []
|
|
192
|
+
raw = frontmatter.get("capabilities") or ""
|
|
193
|
+
if not raw:
|
|
194
|
+
return []
|
|
195
|
+
# capabilities may be comma-separated or YAML list
|
|
196
|
+
if raw.startswith("["):
|
|
197
|
+
try:
|
|
198
|
+
parsed = json.loads(raw)
|
|
199
|
+
if isinstance(parsed, list):
|
|
200
|
+
return [str(c) for c in parsed if isinstance(c, str)]
|
|
201
|
+
except json.JSONDecodeError:
|
|
202
|
+
pass
|
|
203
|
+
return [c.strip() for c in raw.split(",") if c.strip()]
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _reclassify_gate_policy(
|
|
207
|
+
staging: Path,
|
|
208
|
+
change_name: str,
|
|
209
|
+
) -> dict[str, Any]:
|
|
210
|
+
"""Reclassify gate policy based on approved design capabilities (retro §5.4).
|
|
211
|
+
|
|
212
|
+
Reads design frontmatter `capabilities`, invokes harness_gate.py classify
|
|
213
|
+
to recompute the gate DAG, and updates staging/meta/gate-policy.json.
|
|
214
|
+
Returns {"ok": bool, "capabilities": [...], "drift": bool}.
|
|
215
|
+
"""
|
|
216
|
+
capabilities = _read_design_capabilities(staging, change_name)
|
|
217
|
+
if not capabilities:
|
|
218
|
+
return {"ok": True, "capabilities": [], "drift": False, "updated": False}
|
|
219
|
+
|
|
220
|
+
gate_policy_path = staging / "meta" / "gate-policy.json"
|
|
221
|
+
try:
|
|
222
|
+
existing = json.loads(gate_policy_path.read_text(encoding="utf-8-sig"))
|
|
223
|
+
except (OSError, json.JSONDecodeError):
|
|
224
|
+
existing = {}
|
|
225
|
+
|
|
226
|
+
existing_caps = set(existing.get("capabilities") or [])
|
|
227
|
+
design_caps = set(capabilities)
|
|
228
|
+
drift = existing_caps != design_caps
|
|
229
|
+
|
|
230
|
+
if drift:
|
|
231
|
+
# Update gate-policy.json with design capabilities
|
|
232
|
+
existing["capabilities"] = sorted(design_caps)
|
|
233
|
+
try:
|
|
234
|
+
gate_policy_path.write_text(
|
|
235
|
+
json.dumps(existing, ensure_ascii=False, indent=2) + "\n",
|
|
236
|
+
encoding="utf-8",
|
|
237
|
+
newline="\n",
|
|
238
|
+
)
|
|
239
|
+
except OSError as exc:
|
|
240
|
+
return {
|
|
241
|
+
"ok": False,
|
|
242
|
+
"error": f"failed to update gate-policy.json: {exc}",
|
|
243
|
+
"capabilities": capabilities,
|
|
244
|
+
"drift": True,
|
|
245
|
+
"updated": False,
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
"ok": True,
|
|
250
|
+
"capabilities": sorted(design_caps),
|
|
251
|
+
"drift": drift,
|
|
252
|
+
"updated": drift,
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
180
256
|
def _append_terminal(change_dir: Path, run_id: str, attempt: int) -> tuple[int, str]:
|
|
181
257
|
stdout = io.StringIO()
|
|
182
258
|
stderr = io.StringIO()
|
|
@@ -214,6 +290,15 @@ def finalize_plan(
|
|
|
214
290
|
) -> dict[str, Any]:
|
|
215
291
|
change_dir = change_dir.resolve()
|
|
216
292
|
staging = staging.resolve()
|
|
293
|
+
|
|
294
|
+
# C2 (retro §5.4): reclassify gate policy based on approved design capabilities.
|
|
295
|
+
# This updates staging/meta/gate-policy.json before validation, so the hash
|
|
296
|
+
# reflects the final gate policy. Drift between design capabilities and
|
|
297
|
+
# gate-policy capabilities is resolved in favor of the approved design.
|
|
298
|
+
reclassify = _reclassify_gate_policy(staging, change_name)
|
|
299
|
+
if not reclassify.get("ok"):
|
|
300
|
+
return _result_error("CAPABILITY_GATE_DRIFT", reclassify.get("error", "reclassify failed"))
|
|
301
|
+
|
|
217
302
|
validation = validate_staging(staging, change_name)
|
|
218
303
|
if not validation["ok"]:
|
|
219
304
|
return validation
|