@hunter-harness/workflow-harness 0.2.13 → 0.2.14
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-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 +124 -0
- package/harness/bundles/general/claude-code/scripts/harness_change.py +54 -0
- package/harness/bundles/general/claude-code/scripts/harness_deploy.py +177 -0
- package/harness/bundles/general/claude-code/scripts/harness_events.py +99 -1
- package/harness/bundles/general/claude-code/scripts/harness_gate.py +57 -4
- package/harness/bundles/general/claude-code/scripts/harness_integration.py +3 -0
- package/harness/bundles/general/claude-code/scripts/harness_ledger.py +15 -3
- package/harness/bundles/general/claude-code/scripts/harness_preflight.py +47 -0
- 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-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 +124 -0
- package/harness/bundles/general/codebuddy/scripts/harness_change.py +54 -0
- package/harness/bundles/general/codebuddy/scripts/harness_deploy.py +177 -0
- package/harness/bundles/general/codebuddy/scripts/harness_events.py +99 -1
- package/harness/bundles/general/codebuddy/scripts/harness_gate.py +57 -4
- package/harness/bundles/general/codebuddy/scripts/harness_integration.py +3 -0
- package/harness/bundles/general/codebuddy/scripts/harness_ledger.py +15 -3
- package/harness/bundles/general/codebuddy/scripts/harness_preflight.py +47 -0
- 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-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 +124 -0
- package/harness/bundles/general/codex/scripts/harness_change.py +54 -0
- package/harness/bundles/general/codex/scripts/harness_deploy.py +177 -0
- package/harness/bundles/general/codex/scripts/harness_events.py +99 -1
- package/harness/bundles/general/codex/scripts/harness_gate.py +57 -4
- package/harness/bundles/general/codex/scripts/harness_integration.py +3 -0
- package/harness/bundles/general/codex/scripts/harness_ledger.py +15 -3
- package/harness/bundles/general/codex/scripts/harness_preflight.py +47 -0
- 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-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 +124 -0
- package/harness/bundles/general/cursor/scripts/harness_change.py +54 -0
- package/harness/bundles/general/cursor/scripts/harness_deploy.py +177 -0
- package/harness/bundles/general/cursor/scripts/harness_events.py +99 -1
- package/harness/bundles/general/cursor/scripts/harness_gate.py +57 -4
- package/harness/bundles/general/cursor/scripts/harness_integration.py +3 -0
- package/harness/bundles/general/cursor/scripts/harness_ledger.py +15 -3
- package/harness/bundles/general/cursor/scripts/harness_preflight.py +47 -0
- 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 +124 -0
- package/harness/bundles/java/claude-code/scripts/harness_change.py +54 -0
- package/harness/bundles/java/claude-code/scripts/harness_deploy.py +177 -0
- package/harness/bundles/java/claude-code/scripts/harness_events.py +99 -1
- package/harness/bundles/java/claude-code/scripts/harness_gate.py +57 -4
- package/harness/bundles/java/claude-code/scripts/harness_integration.py +3 -0
- package/harness/bundles/java/claude-code/scripts/harness_ledger.py +15 -3
- package/harness/bundles/java/claude-code/scripts/harness_preflight.py +47 -0
- 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 +124 -0
- package/harness/bundles/java/codebuddy/scripts/harness_change.py +54 -0
- package/harness/bundles/java/codebuddy/scripts/harness_deploy.py +177 -0
- package/harness/bundles/java/codebuddy/scripts/harness_events.py +99 -1
- package/harness/bundles/java/codebuddy/scripts/harness_gate.py +57 -4
- package/harness/bundles/java/codebuddy/scripts/harness_integration.py +3 -0
- package/harness/bundles/java/codebuddy/scripts/harness_ledger.py +15 -3
- package/harness/bundles/java/codebuddy/scripts/harness_preflight.py +47 -0
- 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 +124 -0
- package/harness/bundles/java/codex/scripts/harness_change.py +54 -0
- package/harness/bundles/java/codex/scripts/harness_deploy.py +177 -0
- package/harness/bundles/java/codex/scripts/harness_events.py +99 -1
- package/harness/bundles/java/codex/scripts/harness_gate.py +57 -4
- package/harness/bundles/java/codex/scripts/harness_integration.py +3 -0
- package/harness/bundles/java/codex/scripts/harness_ledger.py +15 -3
- package/harness/bundles/java/codex/scripts/harness_preflight.py +47 -0
- 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 +124 -0
- package/harness/bundles/java/cursor/scripts/harness_change.py +54 -0
- package/harness/bundles/java/cursor/scripts/harness_deploy.py +177 -0
- package/harness/bundles/java/cursor/scripts/harness_events.py +99 -1
- package/harness/bundles/java/cursor/scripts/harness_gate.py +57 -4
- package/harness/bundles/java/cursor/scripts/harness_integration.py +3 -0
- package/harness/bundles/java/cursor/scripts/harness_ledger.py +15 -3
- package/harness/bundles/java/cursor/scripts/harness_preflight.py +47 -0
- package/harness/bundles/java/cursor/scripts/harness_test_guard.py +86 -13
- package/harness/manifests/general/claude-code.json +22 -22
- package/harness/manifests/general/codebuddy.json +22 -22
- package/harness/manifests/general/codex.json +22 -22
- package/harness/manifests/general/cursor.json +22 -22
- 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 +2 -2
- package/package.json +15 -15
|
@@ -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",
|
|
@@ -29,6 +29,7 @@ if hasattr(sys.stderr, "reconfigure"):
|
|
|
29
29
|
sys.stderr.reconfigure(encoding="utf-8")
|
|
30
30
|
|
|
31
31
|
|
|
32
|
+
import harness_change as hc # noqa: E402
|
|
32
33
|
import harness_profile as hprof # noqa: E402
|
|
33
34
|
|
|
34
35
|
|
|
@@ -69,6 +70,52 @@ def cmd_check(project: Path) -> dict[str, Any]:
|
|
|
69
70
|
return result
|
|
70
71
|
|
|
71
72
|
|
|
73
|
+
def check_concurrency(project: Path) -> dict[str, Any]:
|
|
74
|
+
"""Report the configured concurrency mode and active Change landscape.
|
|
75
|
+
|
|
76
|
+
Retro §5.2: preflight must surface concurrencyMode, activeChanges, and
|
|
77
|
+
allowedParallelLevels so agents don't have to guess whether parallel
|
|
78
|
+
Changes are supported.
|
|
79
|
+
"""
|
|
80
|
+
mode = hc.read_concurrency_mode(project)
|
|
81
|
+
active = hc.list_active_changes(project)
|
|
82
|
+
shared_conflicts: list[dict[str, Any]] = []
|
|
83
|
+
# In isolated-multi-active, surface any shared-state conflicts (e.g. same
|
|
84
|
+
# worktree path) so callers know isolation is incomplete.
|
|
85
|
+
if mode == "isolated-multi-active" and len(active) > 1:
|
|
86
|
+
seen_worktrees: dict[str, str] = {}
|
|
87
|
+
for entry in active:
|
|
88
|
+
change_dir = Path(entry["path"])
|
|
89
|
+
worktree_meta = change_dir / "meta" / "worktree.json"
|
|
90
|
+
if not worktree_meta.is_file():
|
|
91
|
+
continue
|
|
92
|
+
try:
|
|
93
|
+
meta = json.loads(worktree_meta.read_text(encoding="utf-8"))
|
|
94
|
+
except (OSError, json.JSONDecodeError):
|
|
95
|
+
continue
|
|
96
|
+
wt = meta.get("path") if isinstance(meta, dict) else None
|
|
97
|
+
if isinstance(wt, str) and wt:
|
|
98
|
+
if wt in seen_worktrees:
|
|
99
|
+
shared_conflicts.append({
|
|
100
|
+
"kind": "worktree",
|
|
101
|
+
"path": wt,
|
|
102
|
+
"changes": [seen_worktrees[wt], entry["changeId"]],
|
|
103
|
+
})
|
|
104
|
+
else:
|
|
105
|
+
seen_worktrees[wt] = entry["changeId"]
|
|
106
|
+
levels = ["change-internal"] if mode == "single-active" else [
|
|
107
|
+
"change-internal",
|
|
108
|
+
"multi-change",
|
|
109
|
+
]
|
|
110
|
+
return {
|
|
111
|
+
"ok": True,
|
|
112
|
+
"concurrencyMode": mode,
|
|
113
|
+
"activeChanges": active,
|
|
114
|
+
"sharedStateConflicts": shared_conflicts,
|
|
115
|
+
"allowedParallelLevels": levels,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
72
119
|
# ---------------------------------------------------------------------------
|
|
73
120
|
# record-quirk — 适配 v2 commands(source=user override)
|
|
74
121
|
# ---------------------------------------------------------------------------
|
|
@@ -448,9 +448,18 @@ def _validate_existing_manifest(
|
|
|
448
448
|
tracked_now = _git(
|
|
449
449
|
project, "ls-files", "--error-unmatch", "--", rel
|
|
450
450
|
).returncode == 0
|
|
451
|
-
|
|
451
|
+
checkpointed = not item["trackedBefore"] and tracked_now
|
|
452
|
+
if (
|
|
453
|
+
item["trackedBefore"] != tracked_now and not checkpointed
|
|
454
|
+
) or (
|
|
455
|
+
item["ignored"] != ignored_now and not checkpointed
|
|
456
|
+
):
|
|
452
457
|
return "MANIFEST_INVALID", {}
|
|
453
|
-
|
|
458
|
+
normalized_item = dict(item)
|
|
459
|
+
if checkpointed:
|
|
460
|
+
normalized_item["trackedBefore"] = True
|
|
461
|
+
normalized_item["ignored"] = ignored_now
|
|
462
|
+
validated[rel] = normalized_item
|
|
454
463
|
return None, validated
|
|
455
464
|
|
|
456
465
|
|
|
@@ -734,11 +743,26 @@ def _stage_locked(
|
|
|
734
743
|
error, entries = validator(project_root, manifest, require_files=True)
|
|
735
744
|
if error:
|
|
736
745
|
return _result(False, action, error, [])
|
|
737
|
-
rels = [
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
746
|
+
rels: list[str] = []
|
|
747
|
+
for rel, entry in entries.items():
|
|
748
|
+
if is_v2:
|
|
749
|
+
if entry.get("commitScope") == "current-change":
|
|
750
|
+
rels.append(rel)
|
|
751
|
+
continue
|
|
752
|
+
if not entry["trackedBefore"]:
|
|
753
|
+
rels.append(rel)
|
|
754
|
+
continue
|
|
755
|
+
changed = _git(project_root, "diff", "--quiet", "HEAD", "--", rel)
|
|
756
|
+
if changed.returncode == 1:
|
|
757
|
+
rels.append(rel)
|
|
758
|
+
elif changed.returncode != 0:
|
|
759
|
+
return _result(
|
|
760
|
+
False,
|
|
761
|
+
action,
|
|
762
|
+
"GIT_DIFF_FAILED",
|
|
763
|
+
[rel],
|
|
764
|
+
error=changed.stderr.strip(),
|
|
765
|
+
)
|
|
742
766
|
if not rels:
|
|
743
767
|
return _result(True, action, "STAGED", [])
|
|
744
768
|
|
|
@@ -925,9 +949,22 @@ def close(project: Path | str, change_dir: Path | str) -> dict[str, Any]:
|
|
|
925
949
|
if (
|
|
926
950
|
not isinstance(snapshot, dict)
|
|
927
951
|
or snapshot.get("schemaVersion") != SCHEMA_VERSION
|
|
928
|
-
or snapshot.get("projectRoot") != str(project_root)
|
|
929
952
|
):
|
|
930
953
|
return _result(False, action, "SNAPSHOT_INVALID", [])
|
|
954
|
+
# Execution-root contract (retro §5.10): a snapshot captured against a
|
|
955
|
+
# different project root must fail with EXECUTION_ROOT_MISMATCH before
|
|
956
|
+
# the generic SNAPSHOT_INVALID, so callers can distinguish "wrong root"
|
|
957
|
+
# from "corrupt snapshot".
|
|
958
|
+
snapshot_root = snapshot.get("projectRoot")
|
|
959
|
+
if snapshot_root is not None and snapshot_root != str(project_root):
|
|
960
|
+
return _result(
|
|
961
|
+
False,
|
|
962
|
+
action,
|
|
963
|
+
"EXECUTION_ROOT_MISMATCH",
|
|
964
|
+
[],
|
|
965
|
+
expectedRoot=snapshot_root,
|
|
966
|
+
actualRoot=str(project_root),
|
|
967
|
+
)
|
|
931
968
|
|
|
932
969
|
before_entries = snapshot.get("files")
|
|
933
970
|
if not isinstance(before_entries, list):
|
|
@@ -963,15 +1000,51 @@ def close(project: Path | str, change_dir: Path | str) -> dict[str, Any]:
|
|
|
963
1000
|
if before[rel]["sha256"] != digest:
|
|
964
1001
|
touched.append((rel, "test-updated"))
|
|
965
1002
|
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1003
|
+
for reason in ("tdd-created", "test-updated"):
|
|
1004
|
+
rels = [rel for rel, item_reason in touched if item_reason == reason]
|
|
1005
|
+
if not rels:
|
|
1006
|
+
continue
|
|
1007
|
+
result = record(
|
|
1008
|
+
project_root,
|
|
1009
|
+
change_root,
|
|
1010
|
+
[str(project_root / rel) for rel in rels],
|
|
1011
|
+
reason,
|
|
1012
|
+
)
|
|
969
1013
|
if not result.get("ok"):
|
|
970
1014
|
code = result.get("code", "RECORD_FAILED")
|
|
971
1015
|
if code == "TEST_PATH_NOT_ALLOWED":
|
|
972
|
-
return _result(False, action, "UNCLASSIFIABLE_TEST",
|
|
1016
|
+
return _result(False, action, "UNCLASSIFIABLE_TEST", rels)
|
|
973
1017
|
return result
|
|
974
|
-
|
|
1018
|
+
|
|
1019
|
+
recorded = [rel for rel, _ in touched]
|
|
1020
|
+
|
|
1021
|
+
# Cross-check (retro §5.10): if the manifest has active entries for this
|
|
1022
|
+
# change but close computed recordedCount=0, the snapshot/manifest/diff
|
|
1023
|
+
# are inconsistent. Fail closed instead of silently returning success.
|
|
1024
|
+
manifest_path = _manifest_path(change_root)
|
|
1025
|
+
if manifest_path is not None and manifest_path.is_file():
|
|
1026
|
+
try:
|
|
1027
|
+
manifest = _read_json(manifest_path)
|
|
1028
|
+
except (OSError, json.JSONDecodeError):
|
|
1029
|
+
manifest = None
|
|
1030
|
+
if isinstance(manifest, dict):
|
|
1031
|
+
manifest_files = manifest.get("files")
|
|
1032
|
+
if isinstance(manifest_files, list):
|
|
1033
|
+
active_entries = [
|
|
1034
|
+
f for f in manifest_files
|
|
1035
|
+
if isinstance(f, dict)
|
|
1036
|
+
and f.get("reason") in ("tdd-created", "test-updated", "stale-test-repair")
|
|
1037
|
+
]
|
|
1038
|
+
if active_entries and not recorded:
|
|
1039
|
+
return _result(
|
|
1040
|
+
False,
|
|
1041
|
+
action,
|
|
1042
|
+
"MANIFEST_DIFF_HASH_MISMATCH",
|
|
1043
|
+
[],
|
|
1044
|
+
manifestEntries=len(active_entries),
|
|
1045
|
+
recordedCount=0,
|
|
1046
|
+
detail="manifest has active entries but close computed 0 recorded tests",
|
|
1047
|
+
)
|
|
975
1048
|
|
|
976
1049
|
return _result(
|
|
977
1050
|
True,
|
|
@@ -20,7 +20,7 @@ disallowed-tools:
|
|
|
20
20
|
- Bash(awk *)
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
---
|
|
23
|
-
<!-- generated by harness_deploy.py; core=
|
|
23
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
24
24
|
# harness-apidoc — 前端接口文档(Java overlay)
|
|
25
25
|
|
|
26
26
|
## Purpose
|
|
@@ -20,7 +20,7 @@ disallowed-tools:
|
|
|
20
20
|
- Bash(awk *)
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
---
|
|
23
|
-
<!-- generated by harness_deploy.py; core=
|
|
23
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
24
24
|
# harness-archive — 变更归档
|
|
25
25
|
|
|
26
26
|
## Purpose
|
|
@@ -20,7 +20,7 @@ disallowed-tools:
|
|
|
20
20
|
- Bash(awk *)
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
---
|
|
23
|
-
<!-- generated by harness_deploy.py; core=
|
|
23
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
24
24
|
# harness-codebase-map — 代码库地图
|
|
25
25
|
|
|
26
26
|
## Purpose
|
|
@@ -20,7 +20,7 @@ disallowed-tools:
|
|
|
20
20
|
- Bash(awk *)
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
---
|
|
23
|
-
<!-- generated by harness_deploy.py; core=
|
|
23
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
24
24
|
# harness-knowledge-ingest
|
|
25
25
|
|
|
26
26
|
从 `.harness/archive/**/reports/final/summary-data.json` 抽取项目知识,生成并维护本地 `.harness/knowledge/` 索引。
|
|
@@ -20,7 +20,7 @@ disallowed-tools:
|
|
|
20
20
|
- Bash(awk *)
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
---
|
|
23
|
-
<!-- generated by harness_deploy.py; core=
|
|
23
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
24
24
|
# harness-knowledge-query
|
|
25
25
|
|
|
26
26
|
并行 change 中查询必须传 `--change <change-id>`;成功后以该 change 的 `meta/knowledge-context.json` 为稳定指针。全局 `context-packs/latest.json` 仅向后兼容,不得用于判断多个 active change 的上下文归属。
|
|
@@ -20,7 +20,7 @@ disallowed-tools:
|
|
|
20
20
|
- Bash(awk *)
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
---
|
|
23
|
-
<!-- generated by harness_deploy.py; core=
|
|
23
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
24
24
|
# harness-package — 增量模块打包(Java overlay)
|
|
25
25
|
|
|
26
26
|
## Purpose
|
|
@@ -20,7 +20,7 @@ disallowed-tools:
|
|
|
20
20
|
- Bash(awk *)
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
---
|
|
23
|
-
<!-- generated by harness_deploy.py; core=
|
|
23
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
24
24
|
# harness-plan — 需求规划
|
|
25
25
|
|
|
26
26
|
## Purpose
|
|
@@ -21,7 +21,7 @@ disallowed-tools:
|
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
- Bash(codegraph *)
|
|
23
23
|
---
|
|
24
|
-
<!-- generated by harness_deploy.py; core=
|
|
24
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
25
25
|
# harness-review — 代码审查
|
|
26
26
|
|
|
27
27
|
## Purpose
|
|
@@ -21,7 +21,7 @@ disallowed-tools:
|
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
- Bash(codegraph *)
|
|
23
23
|
---
|
|
24
|
-
<!-- generated by harness_deploy.py; core=
|
|
24
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
25
25
|
# harness-run — 需求编码
|
|
26
26
|
|
|
27
27
|
## Purpose
|
|
@@ -20,7 +20,7 @@ disallowed-tools:
|
|
|
20
20
|
- Bash(awk *)
|
|
21
21
|
- Bash(curl *)
|
|
22
22
|
---
|
|
23
|
-
<!-- generated by harness_deploy.py; core=
|
|
23
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
24
24
|
# harness-submit — 最终提交(含 worktree 合并)
|
|
25
25
|
|
|
26
26
|
## Purpose
|
|
@@ -130,7 +130,7 @@ commit+push / 仅本地 commit / 取消;**不调用 Superpowers 呈现 PR/丢
|
|
|
130
130
|
|
|
131
131
|
见 `checklist.md` 与 `../protocols/ledger-protocol.md`、`../protocols/submit-protocol.md`。
|
|
132
132
|
|
|
133
|
-
test-tracking manifest 是 ignored test 的唯一强制暂存授权:只允许 `harness_test_guard.py stage` 暂存 manifest
|
|
133
|
+
test-tracking manifest 是 ignored test 的唯一强制暂存授权:只允许 `harness_test_guard.py stage` 暂存 manifest 中已校验且相对 `HEAD` 仍有差异的路径,禁止 `git add -f .`、目录级 `git add -f` 或全局修改 `.gitignore`。worktree commit 前须确认 guard 返回的 `files` 全部进入 cached diff;manifest 中已由 `HEAD` 跟踪且未变化的历史条目允许保留而不进入本次 cached diff。合并回主分支后、删除 worktree 前仍须确认 manifest 路径已由目标 commit 跟踪,否则停止清理。
|
|
134
134
|
|
|
135
135
|
### 四、worktree 合并硬规则
|
|
136
136
|
|
|
@@ -119,7 +119,7 @@ python <skills-root>/scripts/harness_ledger.py can-reuse `
|
|
|
119
119
|
|
|
120
120
|
- [ ] 检查 `.harness/changes/<change-name>/evidence/test-tracking.json` 是否存在
|
|
121
121
|
- [ ] 存在时先执行 `python <skills-root>/scripts/harness_test_guard.py stage --project . --change-dir ".harness/changes/<change-name>" --json`;任一 manifest/path/hash/index 校验失败立即停止
|
|
122
|
-
- [ ] 用 `git diff --cached --name-only` 验证
|
|
122
|
+
- [ ] 用 `git diff --cached --name-only` 验证 guard 响应 `files` 中的每个精确路径均已暂存,且没有 guard 引入的额外路径;manifest 中已由 `HEAD` 跟踪且未变化的历史条目无需进入本次 cached diff
|
|
123
123
|
- [ ] 无 manifest 时禁止使用 `git add -f`;有 manifest 时也只允许 guard 内部的 exact force-add,**禁止全局 force-add**、目录级 force-add 和全局修改 `.gitignore`
|
|
124
124
|
|
|
125
125
|
提交前**强制检查 `.gitignore`** 是否包含 `.harness/`:
|
|
@@ -19,7 +19,7 @@ disallowed-tools:
|
|
|
19
19
|
- Bash(awk *)
|
|
20
20
|
- Bash(curl *)
|
|
21
21
|
---
|
|
22
|
-
<!-- generated by harness_deploy.py; core=
|
|
22
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
23
23
|
# harness-sync — 元数据同步
|
|
24
24
|
|
|
25
25
|
## Purpose
|
|
@@ -22,7 +22,7 @@ disallowed-tools:
|
|
|
22
22
|
- Bash(node *)
|
|
23
23
|
- Bash(codegraph *)
|
|
24
24
|
---
|
|
25
|
-
<!-- generated by harness_deploy.py; core=
|
|
25
|
+
<!-- generated by harness_deploy.py; core=d90d5df79c624dc7; overlay=java; agent=claude-code; do not edit -->
|
|
26
26
|
# harness-test — 测试执行
|
|
27
27
|
|
|
28
28
|
## Purpose
|
|
@@ -2799,6 +2799,130 @@ def _html_escape(text: str) -> str:
|
|
|
2799
2799
|
# ---------------------------------------------------------------------------
|
|
2800
2800
|
|
|
2801
2801
|
|
|
2802
|
+
def validate_report_adequacy(summary: dict[str, Any]) -> dict[str, Any]:
|
|
2803
|
+
"""Validate that final summary is factually complete (retro §5.32).
|
|
2804
|
+
|
|
2805
|
+
The archive validator must not return all-green when the summary is
|
|
2806
|
+
factually incomplete. This gate checks independent sources (git facts,
|
|
2807
|
+
typed metrics, stage status) rather than comparing the summary against
|
|
2808
|
+
a lossy projection of itself.
|
|
2809
|
+
"""
|
|
2810
|
+
issues: list[dict[str, str]] = []
|
|
2811
|
+
|
|
2812
|
+
git_facts = summary.get("gitFacts") or {}
|
|
2813
|
+
if isinstance(git_facts, dict):
|
|
2814
|
+
base = str(git_facts.get("baseCommit") or "").strip()
|
|
2815
|
+
final = str(git_facts.get("finalCommit") or "").strip()
|
|
2816
|
+
files_changed = int(git_facts.get("filesChanged") or 0)
|
|
2817
|
+
# base != final but diff=0 → factually incomplete.
|
|
2818
|
+
if base and final and base != final and files_changed == 0:
|
|
2819
|
+
issues.append({
|
|
2820
|
+
"code": "DIFF_ZERO_WITH_NONEMPTY_COMMIT",
|
|
2821
|
+
"severity": "error",
|
|
2822
|
+
"message": f"final commit {final} differs from base {base} but filesChanged=0",
|
|
2823
|
+
})
|
|
2824
|
+
|
|
2825
|
+
# Typed metrics missing despite test report artifacts present.
|
|
2826
|
+
verification = summary.get("verification") or {}
|
|
2827
|
+
if isinstance(verification, dict):
|
|
2828
|
+
unit = verification.get("unitTests") or {}
|
|
2829
|
+
api = verification.get("apiTests") or {}
|
|
2830
|
+
artifacts = summary.get("artifacts") or []
|
|
2831
|
+
has_test_report = any(
|
|
2832
|
+
isinstance(a, dict) and "test" in str(a.get("path") or "").lower()
|
|
2833
|
+
for a in artifacts
|
|
2834
|
+
) if isinstance(artifacts, list) else False
|
|
2835
|
+
unit_pass = int(unit.get("passed") or 0) if isinstance(unit, dict) else 0
|
|
2836
|
+
api_status = str(api.get("status") or "") if isinstance(api, dict) else ""
|
|
2837
|
+
if has_test_report and unit_pass == 0 and api_status in {"", "not_available"}:
|
|
2838
|
+
issues.append({
|
|
2839
|
+
"code": "TYPED_METRICS_MISSING",
|
|
2840
|
+
"severity": "error",
|
|
2841
|
+
"message": "test report artifacts present but unitTests/apiTests typed metrics are empty",
|
|
2842
|
+
})
|
|
2843
|
+
|
|
2844
|
+
# stageStatus contradicts event reducer.
|
|
2845
|
+
stage = summary.get("stageStatus") or {}
|
|
2846
|
+
stage_from_events = summary.get("stageStatusFromEvents") or {}
|
|
2847
|
+
if isinstance(stage, dict) and isinstance(stage_from_events, dict):
|
|
2848
|
+
for phase, status in stage.items():
|
|
2849
|
+
event_status = stage_from_events.get(phase)
|
|
2850
|
+
if event_status is not None and str(status) != str(event_status):
|
|
2851
|
+
issues.append({
|
|
2852
|
+
"code": "STAGE_STATUS_CONTRADICTION",
|
|
2853
|
+
"severity": "error",
|
|
2854
|
+
"message": f"stageStatus.{phase}={status} but event reducer says {event_status}",
|
|
2855
|
+
})
|
|
2856
|
+
|
|
2857
|
+
return {"ok": not issues, "issues": issues}
|
|
2858
|
+
|
|
2859
|
+
|
|
2860
|
+
def artifact_preflight(change_dir: Path) -> dict[str, Any]:
|
|
2861
|
+
"""Classify artifact events before destructive finalize (retro §5.31).
|
|
2862
|
+
|
|
2863
|
+
Returns per-artifact classification: informational (no path, OK),
|
|
2864
|
+
canonicalizable (same-change repo-relative path, auto-normalize), or
|
|
2865
|
+
blocking (cross-change/absolute/escaping path, fail closed).
|
|
2866
|
+
"""
|
|
2867
|
+
change_dir = change_dir.resolve()
|
|
2868
|
+
events_p = change_dir / "events.ndjson"
|
|
2869
|
+
items: list[dict[str, Any]] = []
|
|
2870
|
+
blocking: list[dict[str, Any]] = []
|
|
2871
|
+
if not events_p.is_file():
|
|
2872
|
+
return {"ok": True, "items": [], "blocking": []}
|
|
2873
|
+
change_id = change_dir.name
|
|
2874
|
+
for line in events_p.read_text(encoding="utf-8").splitlines():
|
|
2875
|
+
try:
|
|
2876
|
+
event = json.loads(line)
|
|
2877
|
+
except json.JSONDecodeError:
|
|
2878
|
+
continue
|
|
2879
|
+
if not isinstance(event, dict) or event.get("type") != "artifact":
|
|
2880
|
+
continue
|
|
2881
|
+
path = str(event.get("path") or "").strip()
|
|
2882
|
+
kind = str(event.get("kind") or "").strip()
|
|
2883
|
+
event_id = str(event.get("id") or "")
|
|
2884
|
+
if not path:
|
|
2885
|
+
items.append({
|
|
2886
|
+
"eventId": event_id,
|
|
2887
|
+
"category": "informational",
|
|
2888
|
+
"kind": kind or "informational",
|
|
2889
|
+
"note": str(event.get("note") or "")[:80],
|
|
2890
|
+
})
|
|
2891
|
+
continue
|
|
2892
|
+
# Check for escaping/cross-change paths.
|
|
2893
|
+
parts = path.replace("\\", "/").split("/")
|
|
2894
|
+
if ".." in parts or path.startswith("/") or re.match(r"^[A-Za-z]:", path):
|
|
2895
|
+
item = {
|
|
2896
|
+
"eventId": event_id,
|
|
2897
|
+
"category": "blocking",
|
|
2898
|
+
"path": path,
|
|
2899
|
+
"reason": "absolute or escaping path",
|
|
2900
|
+
}
|
|
2901
|
+
items.append(item)
|
|
2902
|
+
blocking.append(item)
|
|
2903
|
+
continue
|
|
2904
|
+
# Same-change repo-relative path: canonicalizable.
|
|
2905
|
+
prefix = f".harness/changes/{change_id}/"
|
|
2906
|
+
if path.startswith(prefix):
|
|
2907
|
+
canonical = path[len(prefix):]
|
|
2908
|
+
items.append({
|
|
2909
|
+
"eventId": event_id,
|
|
2910
|
+
"category": "canonicalizable",
|
|
2911
|
+
"path": path,
|
|
2912
|
+
"canonicalPath": canonical,
|
|
2913
|
+
"correction": f"append correction --target-event-id {event_id} --target-field path --new-value-json \"{canonical}\"",
|
|
2914
|
+
})
|
|
2915
|
+
continue
|
|
2916
|
+
# Change-relative path: OK.
|
|
2917
|
+
items.append({
|
|
2918
|
+
"eventId": event_id,
|
|
2919
|
+
"category": "file-backed",
|
|
2920
|
+
"path": path,
|
|
2921
|
+
"exists": (change_dir / path).is_file(),
|
|
2922
|
+
})
|
|
2923
|
+
return {"ok": not blocking, "items": items, "blocking": blocking}
|
|
2924
|
+
|
|
2925
|
+
|
|
2802
2926
|
def run_knowledge_poststeps(project_root: Path) -> dict[str, Any]:
|
|
2803
2927
|
results: dict[str, Any] = {"ran": False, "steps": [], "warnings": []}
|
|
2804
2928
|
if not KNOWLEDGE_SCRIPT.is_file():
|
|
@@ -224,6 +224,60 @@ def _layout_fields(project_root: Path, change_id: str) -> dict[str, Any]:
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
|
|
227
|
+
def read_concurrency_mode(project_root: Path) -> str:
|
|
228
|
+
"""Return the configured concurrency mode (retro §5.2).
|
|
229
|
+
|
|
230
|
+
Defaults to ``single-active`` when no config declares a mode. Supported
|
|
231
|
+
values: ``single-active`` (default, blocks a second active Change),
|
|
232
|
+
``isolated-multi-active`` (allows multiple active Changes but all
|
|
233
|
+
Change-scoped commands require ``--change``).
|
|
234
|
+
"""
|
|
235
|
+
cfg = project_root / ".harness" / "config.json"
|
|
236
|
+
if cfg.is_file():
|
|
237
|
+
try:
|
|
238
|
+
data = json.loads(cfg.read_text(encoding="utf-8"))
|
|
239
|
+
if isinstance(data, dict):
|
|
240
|
+
mode = data.get("concurrencyMode")
|
|
241
|
+
if isinstance(mode, str) and mode in {
|
|
242
|
+
"single-active",
|
|
243
|
+
"isolated-multi-active",
|
|
244
|
+
}:
|
|
245
|
+
return mode
|
|
246
|
+
except (OSError, json.JSONDecodeError):
|
|
247
|
+
pass
|
|
248
|
+
return "single-active"
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def check_concurrency_block(
|
|
252
|
+
project_root: Path, change_id: str
|
|
253
|
+
) -> dict[str, Any] | None:
|
|
254
|
+
"""Return a blocking payload when a second active Change is forbidden.
|
|
255
|
+
|
|
256
|
+
Returns ``None`` when the begin may proceed. In ``single-active`` mode a
|
|
257
|
+
second active Change (any other than ``change_id``) blocks begin; in
|
|
258
|
+
``isolated-multi-active`` mode multiple active Changes are allowed.
|
|
259
|
+
"""
|
|
260
|
+
mode = read_concurrency_mode(project_root)
|
|
261
|
+
if mode == "isolated-multi-active":
|
|
262
|
+
return None
|
|
263
|
+
active = list_active_changes(project_root)
|
|
264
|
+
others = [entry for entry in active if entry.get("changeId") != change_id]
|
|
265
|
+
if not others:
|
|
266
|
+
return None
|
|
267
|
+
return {
|
|
268
|
+
"ok": False,
|
|
269
|
+
"code": "SINGLE_ACTIVE_BLOCKED",
|
|
270
|
+
"message": (
|
|
271
|
+
"single-active concurrency mode: another active Change exists; "
|
|
272
|
+
"use portfolio/decompose to sequence multiple Changes, or switch "
|
|
273
|
+
"to isolated-multi-active after ensuring full Change-scoped isolation"
|
|
274
|
+
),
|
|
275
|
+
"concurrencyMode": mode,
|
|
276
|
+
"activeChanges": active,
|
|
277
|
+
"blockingChanges": others,
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
|
|
227
281
|
def resolve_change(
|
|
228
282
|
project_root: Path,
|
|
229
283
|
change_id: str | None,
|