|
@@ -1785,22 +1785,147 @@ def create_sanitized_git_snapshot(
|
|
|
return status, artifacts
|
|
return status, artifacts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def live_git_cli_usable(root: Path) -> bool:
|
|
|
|
|
+ """True when ``git -C root`` reports an inside-work-tree checkout.
|
|
|
|
|
+
|
|
|
|
|
+ Unlike ``resolve_git_dir``, this accepts linked worktrees whose ``gitdir:``
|
|
|
|
|
+ points outside the worktree root (required for clean DELIVERY worktrees).
|
|
|
|
|
+ """
|
|
|
|
|
+ git = shutil.which("git")
|
|
|
|
|
+ if not git:
|
|
|
|
|
+ return False
|
|
|
|
|
+ code, payload = run_capture(
|
|
|
|
|
+ [git, "rev-parse", "--is-inside-work-tree"],
|
|
|
|
|
+ cwd=root,
|
|
|
|
|
+ )
|
|
|
|
|
+ return code == 0 and payload.decode("ascii", errors="replace").strip() == "true"
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _hash_exact_commit_tree(
|
|
|
|
|
+ git: str,
|
|
|
|
|
+ root: Path,
|
|
|
|
|
+ commit: str,
|
|
|
|
|
+ *,
|
|
|
|
|
+ temp_root: Path,
|
|
|
|
|
+) -> tuple[list[dict[str, object]], dict[str, str], list[str]]:
|
|
|
|
|
+ """SHA-256 tracked files from exact commit via ``git archive`` (not dirty WT)."""
|
|
|
|
|
+ work = temp_root / f"commit-tree-{commit[:12]}"
|
|
|
|
|
+ if work.exists():
|
|
|
|
|
+ shutil.rmtree(work)
|
|
|
|
|
+ work.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
+ tar_path = temp_root / f"commit-tree-{commit[:12]}.tar"
|
|
|
|
|
+ code, err = run_capture(
|
|
|
|
|
+ [git, "archive", "--format=tar", "-o", str(tar_path), commit],
|
|
|
|
|
+ cwd=root,
|
|
|
|
|
+ timeout=600,
|
|
|
|
|
+ )
|
|
|
|
|
+ if code != 0 or not tar_path.is_file():
|
|
|
|
|
+ detail = err.decode("utf-8", errors="replace")[:500]
|
|
|
|
|
+ raise PackagingError(
|
|
|
|
|
+ f"git archive {commit} failed for review provenance: {detail}"
|
|
|
|
|
+ )
|
|
|
|
|
+ with tarfile.open(tar_path, "r:") as archive:
|
|
|
|
|
+ # filter='data' avoids 3.14 deprecation and blocks unsafe paths.
|
|
|
|
|
+ try:
|
|
|
|
|
+ archive.extractall(work, filter="data")
|
|
|
|
|
+ except TypeError:
|
|
|
|
|
+ archive.extractall(work)
|
|
|
|
|
+ tree_rows: list[dict[str, object]] = []
|
|
|
|
|
+ file_hashes: dict[str, str] = {}
|
|
|
|
|
+ file_rels: list[str] = []
|
|
|
|
|
+ for path in sorted(work.rglob("*")):
|
|
|
|
|
+ if not path.is_file():
|
|
|
|
|
+ continue
|
|
|
|
|
+ rel = path.relative_to(work).as_posix()
|
|
|
|
|
+ digest = sha256_file(path)
|
|
|
|
|
+ file_rels.append(rel)
|
|
|
|
|
+ file_hashes[rel] = digest
|
|
|
|
|
+ tree_rows.append({"path": rel, "sha256": digest, "size": path.stat().st_size})
|
|
|
|
|
+ return tree_rows, file_hashes, file_rels
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def validate_review_git_provenance_artifacts(
|
|
|
|
|
+ artifacts: dict[str, bytes],
|
|
|
|
|
+ *,
|
|
|
|
|
+ meta_prefix: str = "meta/git",
|
|
|
|
|
+ expected_head: str | None = None,
|
|
|
|
|
+) -> list[str]:
|
|
|
|
|
+ """Fail-closed checks for review-compact Git provenance members."""
|
|
|
|
|
+ failures: list[str] = []
|
|
|
|
|
+ required = (
|
|
|
|
|
+ f"{meta_prefix}/HEAD.txt",
|
|
|
|
|
+ f"{meta_prefix}/branch.txt",
|
|
|
|
|
+ f"{meta_prefix}/status.txt",
|
|
|
|
|
+ f"{meta_prefix}/log-20.txt",
|
|
|
|
|
+ f"{meta_prefix}/tree-manifest.json",
|
|
|
|
|
+ f"{meta_prefix}/source-file-sha256.json",
|
|
|
|
|
+ )
|
|
|
|
|
+ for key in required:
|
|
|
|
|
+ if key not in artifacts:
|
|
|
|
|
+ failures.append(f"missing_{key.replace('/', '_')}")
|
|
|
|
|
+ head_raw = artifacts.get(f"{meta_prefix}/HEAD.txt", b"").decode("utf-8", errors="replace").strip()
|
|
|
|
|
+ if not COMMIT_FULL_RE.fullmatch(head_raw.casefold()):
|
|
|
|
|
+ failures.append("invalid_HEAD")
|
|
|
|
|
+ if expected_head and head_raw.casefold() != expected_head.casefold():
|
|
|
|
|
+ failures.append("HEAD_mismatch_expected")
|
|
|
|
|
+ try:
|
|
|
|
|
+ tree = json.loads(artifacts.get(f"{meta_prefix}/tree-manifest.json", b"{}"))
|
|
|
|
|
+ files = json.loads(
|
|
|
|
|
+ artifacts.get(
|
|
|
|
|
+ f"{meta_prefix}/source-file-sha256.json",
|
|
|
|
|
+ artifacts.get(f"{meta_prefix}/file-sha256.json", b"{}"),
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ except (TypeError, json.JSONDecodeError):
|
|
|
|
|
+ failures.append("invalid_tree_or_file_sha_json")
|
|
|
|
|
+ return failures
|
|
|
|
|
+ tree_head = str(tree.get("head") or "")
|
|
|
|
|
+ files_head = str(files.get("head") or "")
|
|
|
|
|
+ if tree_head.casefold() != head_raw.casefold() or files_head.casefold() != head_raw.casefold():
|
|
|
|
|
+ failures.append("HEAD_tree_file_sha_inconsistent")
|
|
|
|
|
+ tree_files = tree.get("files") if isinstance(tree.get("files"), list) else []
|
|
|
|
|
+ hash_map = files.get("files") if isinstance(files.get("files"), dict) else {}
|
|
|
|
|
+ if int(tree.get("file_count") or 0) != len(tree_files):
|
|
|
|
|
+ failures.append("tree_manifest_count_mismatch")
|
|
|
|
|
+ if len(tree_files) == 0:
|
|
|
|
|
+ failures.append("tree_manifest_empty")
|
|
|
|
|
+ tree_paths = {str(row.get("path")) for row in tree_files if isinstance(row, dict)}
|
|
|
|
|
+ if tree_paths != set(hash_map):
|
|
|
|
|
+ failures.append("tree_manifest_hash_map_path_mismatch")
|
|
|
|
|
+ for row in tree_files:
|
|
|
|
|
+ if not isinstance(row, dict):
|
|
|
|
|
+ continue
|
|
|
|
|
+ path = str(row.get("path") or "")
|
|
|
|
|
+ digest = str(row.get("sha256") or "")
|
|
|
|
|
+ if path and hash_map.get(path) != digest:
|
|
|
|
|
+ failures.append(f"file_hash_mismatch:{path}")
|
|
|
|
|
+ break
|
|
|
|
|
+ return failures
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def collect_review_git_provenance(
|
|
def collect_review_git_provenance(
|
|
|
root: Path,
|
|
root: Path,
|
|
|
*,
|
|
*,
|
|
|
include_sanitized_git_snapshot: bool = False,
|
|
include_sanitized_git_snapshot: bool = False,
|
|
|
meta_prefix: str = "meta/git",
|
|
meta_prefix: str = "meta/git",
|
|
|
temp_root: Path | None = None,
|
|
temp_root: Path | None = None,
|
|
|
|
|
+ require_clean: bool = False,
|
|
|
|
|
+ commit: str | None = None,
|
|
|
) -> tuple[dict[str, object], dict[str, bytes]]:
|
|
) -> tuple[dict[str, object], dict[str, bytes]]:
|
|
|
- """Git provenance for review-* packages: no full bundle; commit/status/log/tree/hashes."""
|
|
|
|
|
- git_dir = resolve_git_dir(root)
|
|
|
|
|
|
|
+ """Git provenance for review-* packages: no full bundle; commit/status/log/tree/hashes.
|
|
|
|
|
+
|
|
|
|
|
+ Uses the live ``git`` CLI so linked DELIVERY worktrees work even when
|
|
|
|
|
+ ``resolve_git_dir`` rejects an external ``gitdir:``. Tree/file SHA-256 are
|
|
|
|
|
+ taken from the exact commit via ``git archive``, never from a dirty WT scan.
|
|
|
|
|
+ """
|
|
|
artifacts: dict[str, bytes] = {}
|
|
artifacts: dict[str, bytes] = {}
|
|
|
- if git_dir is None:
|
|
|
|
|
|
|
+ git = shutil.which("git")
|
|
|
|
|
+ if not git or not live_git_cli_usable(root):
|
|
|
metadata: dict[str, object] = {
|
|
metadata: dict[str, object] = {
|
|
|
"status": "not_a_git_worktree",
|
|
"status": "not_a_git_worktree",
|
|
|
"branch": None,
|
|
"branch": None,
|
|
|
"head": None,
|
|
"head": None,
|
|
|
- "tool": None,
|
|
|
|
|
|
|
+ "tool": None if not git else "git",
|
|
|
"full_bundle": False,
|
|
"full_bundle": False,
|
|
|
"sanitized_git_snapshot": {
|
|
"sanitized_git_snapshot": {
|
|
|
"requested": include_sanitized_git_snapshot,
|
|
"requested": include_sanitized_git_snapshot,
|
|
@@ -1812,13 +1937,11 @@ def collect_review_git_provenance(
|
|
|
)
|
|
)
|
|
|
return metadata, artifacts
|
|
return metadata, artifacts
|
|
|
|
|
|
|
|
- branch, head = read_head_metadata(git_dir)
|
|
|
|
|
- git = shutil.which("git")
|
|
|
|
|
if not git:
|
|
if not git:
|
|
|
return {
|
|
return {
|
|
|
"status": "blocked_missing_git_tool",
|
|
"status": "blocked_missing_git_tool",
|
|
|
- "branch": branch,
|
|
|
|
|
- "head": head,
|
|
|
|
|
|
|
+ "branch": None,
|
|
|
|
|
+ "head": None,
|
|
|
"tool": None,
|
|
"tool": None,
|
|
|
"full_bundle": False,
|
|
"full_bundle": False,
|
|
|
"sanitized_git_snapshot": {
|
|
"sanitized_git_snapshot": {
|
|
@@ -1834,6 +1957,80 @@ def collect_review_git_provenance(
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ rev_parse = _git_bytes(git, ["rev-parse", "HEAD"], cwd=root)
|
|
|
|
|
+ head = (
|
|
|
|
|
+ rev_parse.decode("utf-8", errors="replace").strip()
|
|
|
|
|
+ if rev_parse is not None
|
|
|
|
|
+ else None
|
|
|
|
|
+ )
|
|
|
|
|
+ if commit:
|
|
|
|
|
+ # Format-check alone is insufficient — commit must exist in this repo.
|
|
|
|
|
+ verified = _git_bytes(
|
|
|
|
|
+ git,
|
|
|
|
|
+ ["rev-parse", "--verify", f"{commit}^{{commit}}"],
|
|
|
|
|
+ cwd=root,
|
|
|
|
|
+ )
|
|
|
|
|
+ if verified is None:
|
|
|
|
|
+ return {
|
|
|
|
|
+ "status": "fail_invalid_commit",
|
|
|
|
|
+ "branch": None,
|
|
|
|
|
+ "head": head,
|
|
|
|
|
+ "tool": "git",
|
|
|
|
|
+ "full_bundle": False,
|
|
|
|
|
+ "sanitized_git_snapshot": {
|
|
|
|
|
+ "requested": include_sanitized_git_snapshot,
|
|
|
|
|
+ "status": "not_applicable",
|
|
|
|
|
+ },
|
|
|
|
|
+ }, {
|
|
|
|
|
+ f"{meta_prefix}/sanitized-snapshot-status.json": json_bytes(
|
|
|
|
|
+ {
|
|
|
|
|
+ "requested": include_sanitized_git_snapshot,
|
|
|
|
|
+ "status": "not_applicable",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ head = verified.decode("utf-8", errors="replace").strip().casefold()
|
|
|
|
|
+ if not head or not COMMIT_FULL_RE.fullmatch(head.casefold()):
|
|
|
|
|
+ return {
|
|
|
|
|
+ "status": "fail_missing_HEAD",
|
|
|
|
|
+ "branch": None,
|
|
|
|
|
+ "head": head,
|
|
|
|
|
+ "tool": "git",
|
|
|
|
|
+ "full_bundle": False,
|
|
|
|
|
+ "sanitized_git_snapshot": {
|
|
|
|
|
+ "requested": include_sanitized_git_snapshot,
|
|
|
|
|
+ "status": "not_applicable",
|
|
|
|
|
+ },
|
|
|
|
|
+ }, {
|
|
|
|
|
+ f"{meta_prefix}/sanitized-snapshot-status.json": json_bytes(
|
|
|
|
|
+ {
|
|
|
|
|
+ "requested": include_sanitized_git_snapshot,
|
|
|
|
|
+ "status": "not_applicable",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ head = head.casefold()
|
|
|
|
|
+
|
|
|
|
|
+ branch_raw = _git_bytes(git, ["rev-parse", "--abbrev-ref", "HEAD"], cwd=root)
|
|
|
|
|
+ branch = (
|
|
|
|
|
+ branch_raw.decode("utf-8", errors="replace").strip()
|
|
|
|
|
+ if branch_raw is not None
|
|
|
|
|
+ else None
|
|
|
|
|
+ )
|
|
|
|
|
+ if branch == "HEAD":
|
|
|
|
|
+ # Detached HEAD at exact DELIVERY — record detached + commit, not fake branch.
|
|
|
|
|
+ branch = f"detached:{head}"
|
|
|
|
|
+
|
|
|
|
|
+ # Prefer embedded .git metadata when packager-safe; CLI remains authority.
|
|
|
|
|
+ git_dir = resolve_git_dir(root)
|
|
|
|
|
+ if git_dir is not None:
|
|
|
|
|
+ meta_branch, meta_head = read_head_metadata(git_dir)
|
|
|
|
|
+ if meta_branch and not str(branch).startswith("detached:"):
|
|
|
|
|
+ branch = meta_branch
|
|
|
|
|
+ if meta_head and COMMIT_FULL_RE.fullmatch(meta_head.casefold()) and not commit:
|
|
|
|
|
+ # Keep CLI HEAD (exact tip) as authority when packing current tip.
|
|
|
|
|
+ pass
|
|
|
|
|
+
|
|
|
status_payload = _git_bytes(
|
|
status_payload = _git_bytes(
|
|
|
git,
|
|
git,
|
|
|
[
|
|
[
|
|
@@ -1849,34 +2046,77 @@ def collect_review_git_provenance(
|
|
|
],
|
|
],
|
|
|
cwd=root,
|
|
cwd=root,
|
|
|
)
|
|
)
|
|
|
|
|
+ # Dirty = modified/staged tracked files vs HEAD. Untracked-only noise does not
|
|
|
|
|
+ # affect git-archive commit snapshots; still recorded for status.txt honesty.
|
|
|
|
|
+ porcelain = _git_bytes(
|
|
|
|
|
+ git,
|
|
|
|
|
+ [
|
|
|
|
|
+ "--no-optional-locks",
|
|
|
|
|
+ "-c",
|
|
|
|
|
+ "core.fsmonitor=false",
|
|
|
|
|
+ "status",
|
|
|
|
|
+ "--porcelain=v1",
|
|
|
|
|
+ "--untracked-files=no",
|
|
|
|
|
+ ],
|
|
|
|
|
+ cwd=root,
|
|
|
|
|
+ )
|
|
|
|
|
+ dirty = bool(porcelain and porcelain.strip())
|
|
|
|
|
+ if require_clean and dirty:
|
|
|
|
|
+ return {
|
|
|
|
|
+ "status": "fail_dirty_worktree",
|
|
|
|
|
+ "branch": branch,
|
|
|
|
|
+ "head": head,
|
|
|
|
|
+ "tool": "git",
|
|
|
|
|
+ "full_bundle": False,
|
|
|
|
|
+ "dirty": True,
|
|
|
|
|
+ "sanitized_git_snapshot": {
|
|
|
|
|
+ "requested": include_sanitized_git_snapshot,
|
|
|
|
|
+ "status": "not_applicable",
|
|
|
|
|
+ },
|
|
|
|
|
+ }, {
|
|
|
|
|
+ f"{meta_prefix}/sanitized-snapshot-status.json": json_bytes(
|
|
|
|
|
+ {
|
|
|
|
|
+ "requested": include_sanitized_git_snapshot,
|
|
|
|
|
+ "status": "not_applicable",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
log_payload = _git_bytes(
|
|
log_payload = _git_bytes(
|
|
|
git,
|
|
git,
|
|
|
- ["log", "-20", "--format=%H %ad %s", "--date=iso-strict"],
|
|
|
|
|
|
|
+ ["log", "-20", "--format=%H %ad %s", "--date=iso-strict", head],
|
|
|
cwd=root,
|
|
cwd=root,
|
|
|
)
|
|
)
|
|
|
- rev_parse = _git_bytes(git, ["rev-parse", "HEAD"], cwd=root)
|
|
|
|
|
- if rev_parse is not None:
|
|
|
|
|
- head = rev_parse.decode("utf-8", errors="replace").strip() or head
|
|
|
|
|
- ls_files = _git_bytes(git, ["ls-files", "-z"], cwd=root)
|
|
|
|
|
|
|
|
|
|
- tree_rows: list[dict[str, object]] = []
|
|
|
|
|
- file_hashes: dict[str, str] = {}
|
|
|
|
|
- file_rels: list[str] = []
|
|
|
|
|
- if ls_files is not None:
|
|
|
|
|
- for raw in ls_files.split(b"\0"):
|
|
|
|
|
- if not raw:
|
|
|
|
|
- continue
|
|
|
|
|
- rel = raw.decode("utf-8", errors="surrogateescape")
|
|
|
|
|
- file_rels.append(rel)
|
|
|
|
|
- path = root / Path(*rel.split("/"))
|
|
|
|
|
- if not path.is_file():
|
|
|
|
|
- continue
|
|
|
|
|
- digest = sha256_file(path)
|
|
|
|
|
- file_hashes[rel] = digest
|
|
|
|
|
- tree_rows.append({"path": rel, "sha256": digest, "size": path.stat().st_size})
|
|
|
|
|
- tree_rows.sort(key=lambda row: str(row["path"]))
|
|
|
|
|
|
|
+ snap_temp = temp_root if temp_root is not None else Path(
|
|
|
|
|
+ tempfile.mkdtemp(prefix="prod2u-review-git-", dir=os.environ.get("TMPDIR", "/tmp"))
|
|
|
|
|
+ )
|
|
|
|
|
+ snap_temp.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
+ try:
|
|
|
|
|
+ tree_rows, file_hashes, file_rels = _hash_exact_commit_tree(
|
|
|
|
|
+ git, root, head, temp_root=snap_temp
|
|
|
|
|
+ )
|
|
|
|
|
+ except PackagingError:
|
|
|
|
|
+ return {
|
|
|
|
|
+ "status": "fail_commit_tree_archive",
|
|
|
|
|
+ "branch": branch,
|
|
|
|
|
+ "head": head,
|
|
|
|
|
+ "tool": "git",
|
|
|
|
|
+ "full_bundle": False,
|
|
|
|
|
+ "sanitized_git_snapshot": {
|
|
|
|
|
+ "requested": include_sanitized_git_snapshot,
|
|
|
|
|
+ "status": "not_applicable",
|
|
|
|
|
+ },
|
|
|
|
|
+ }, {
|
|
|
|
|
+ f"{meta_prefix}/sanitized-snapshot-status.json": json_bytes(
|
|
|
|
|
+ {
|
|
|
|
|
+ "requested": include_sanitized_git_snapshot,
|
|
|
|
|
+ "status": "not_applicable",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- artifacts[f"{meta_prefix}/HEAD.txt"] = f"{head or ''}\n".encode("utf-8")
|
|
|
|
|
|
|
+ artifacts[f"{meta_prefix}/HEAD.txt"] = f"{head}\n".encode("utf-8")
|
|
|
if branch:
|
|
if branch:
|
|
|
artifacts[f"{meta_prefix}/branch.txt"] = f"{branch}\n".encode("utf-8")
|
|
artifacts[f"{meta_prefix}/branch.txt"] = f"{branch}\n".encode("utf-8")
|
|
|
if status_payload is not None:
|
|
if status_payload is not None:
|
|
@@ -1888,6 +2128,7 @@ def collect_review_git_provenance(
|
|
|
"schema": "cpld-review-git-tree-manifest-v1",
|
|
"schema": "cpld-review-git-tree-manifest-v1",
|
|
|
"head": head,
|
|
"head": head,
|
|
|
"file_count": len(tree_rows),
|
|
"file_count": len(tree_rows),
|
|
|
|
|
+ "source": "git_archive_exact_commit",
|
|
|
"files": tree_rows,
|
|
"files": tree_rows,
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
@@ -1895,6 +2136,7 @@ def collect_review_git_provenance(
|
|
|
{
|
|
{
|
|
|
"schema": "cpld-review-git-file-sha256-v1",
|
|
"schema": "cpld-review-git-file-sha256-v1",
|
|
|
"head": head,
|
|
"head": head,
|
|
|
|
|
+ "source": "git_archive_exact_commit",
|
|
|
"files": file_hashes,
|
|
"files": file_hashes,
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
@@ -1903,10 +2145,6 @@ def collect_review_git_provenance(
|
|
|
artifacts[f"{meta_prefix}/file-sha256.json"] = file_sha_payload
|
|
artifacts[f"{meta_prefix}/file-sha256.json"] = file_sha_payload
|
|
|
|
|
|
|
|
if include_sanitized_git_snapshot:
|
|
if include_sanitized_git_snapshot:
|
|
|
- snap_temp = temp_root if temp_root is not None else Path(
|
|
|
|
|
- tempfile.mkdtemp(prefix="prod2u-sanitized-git-", dir=os.environ.get("TMPDIR", "/tmp"))
|
|
|
|
|
- )
|
|
|
|
|
- snap_temp.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
snapshot_status, snap_artifacts = create_sanitized_git_snapshot(
|
|
snapshot_status, snap_artifacts = create_sanitized_git_snapshot(
|
|
|
root,
|
|
root,
|
|
|
git=git,
|
|
git=git,
|
|
@@ -1924,25 +2162,35 @@ def collect_review_git_provenance(
|
|
|
"note": (
|
|
"note": (
|
|
|
"Optional sanitized synthetic single-commit snapshot via "
|
|
"Optional sanitized synthetic single-commit snapshot via "
|
|
|
"--include-sanitized-git-snapshot. When present it records "
|
|
"--include-sanitized-git-snapshot. When present it records "
|
|
|
- "synthetic→original mapping and must not impersonate the original tip."
|
|
|
|
|
|
|
+ "synthetic→original mapping and must not impersonate the original tip. "
|
|
|
|
|
+ "It cannot replace HEAD/tree/per-file SHA-256 live provenance."
|
|
|
),
|
|
),
|
|
|
}
|
|
}
|
|
|
artifacts[f"{meta_prefix}/sanitized-snapshot-status.json"] = json_bytes(
|
|
artifacts[f"{meta_prefix}/sanitized-snapshot-status.json"] = json_bytes(
|
|
|
snapshot_status
|
|
snapshot_status
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ validation_failures = validate_review_git_provenance_artifacts(
|
|
|
|
|
+ artifacts, meta_prefix=meta_prefix, expected_head=head
|
|
|
|
|
+ )
|
|
|
capture_status = "pass"
|
|
capture_status = "pass"
|
|
|
- if status_payload is None or log_payload is None or ls_files is None:
|
|
|
|
|
- capture_status = "partial"
|
|
|
|
|
|
|
+ if status_payload is None or log_payload is None or validation_failures:
|
|
|
|
|
+ capture_status = "partial" if not validation_failures else "fail_provenance_incomplete"
|
|
|
|
|
+ if validation_failures:
|
|
|
|
|
+ capture_status = "fail_provenance_incomplete"
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
"status": capture_status,
|
|
"status": capture_status,
|
|
|
"branch": branch,
|
|
"branch": branch,
|
|
|
"head": head,
|
|
"head": head,
|
|
|
"tool": "git",
|
|
"tool": "git",
|
|
|
"full_bundle": False,
|
|
"full_bundle": False,
|
|
|
|
|
+ "dirty": dirty,
|
|
|
"status_captured": status_payload is not None,
|
|
"status_captured": status_payload is not None,
|
|
|
"log20_captured": log_payload is not None,
|
|
"log20_captured": log_payload is not None,
|
|
|
"tree_manifest_files": len(tree_rows),
|
|
"tree_manifest_files": len(tree_rows),
|
|
|
|
|
+ "tree_source": "git_archive_exact_commit",
|
|
|
|
|
+ "validation_failures": validation_failures,
|
|
|
"sanitized_git_snapshot": snapshot_status,
|
|
"sanitized_git_snapshot": snapshot_status,
|
|
|
}, artifacts
|
|
}, artifacts
|
|
|
|
|
|