Просмотр исходного кода

fix(packager): keep source_closure mirror for detached replay

Dual-place config/source_closure.json under source/ and evidence/, and
call validate_detached_derived with --generated so compact software
replay can pass without raw git.

Co-authored-by: Cursor <cursoragent@cursor.com>
root 3 месяцев назад
Родитель
Сommit
920cbfc42f
2 измененных файлов с 37 добавлено и 1 удалено
  1. 36 0
      package_for_agent_analysis.py
  2. 1 1
      tools/replay_review_compact.py

+ 36 - 0
package_for_agent_analysis.py

@@ -839,6 +839,15 @@ def _package_relative_for_unified(
     return f"{placed}/{original_relative}", category
 
 
+# Workspace paths remapped into evidence/ that must also remain under source/ for
+# detached software replay (imports / generators that resolve repo-relative paths).
+_SOFTWARE_MIRROR_UNDER_SOURCE = frozenset(
+    {
+        "config/source_closure.json",
+    }
+)
+
+
 def _materialize_bytes_items(
     payloads: dict[str, bytes],
     *,
@@ -988,6 +997,26 @@ def collect_analysis_inputs(
                     scan_archive=item.scan_archive,
                 )
             )
+            if original in _SOFTWARE_MIRROR_UNDER_SOURCE and not package_relative.startswith(
+                "source/"
+            ):
+                remapped.append(
+                    PackageItem(
+                        candidate=handoff.Candidate(
+                            absolute=item.candidate.absolute,
+                            relative=f"source/{original}",
+                            size=item.candidate.size,
+                            mtime_ns=item.candidate.mtime_ns,
+                            device=item.candidate.device,
+                            inode=item.candidate.inode,
+                            mode=item.candidate.mode,
+                        ),
+                        category="source",
+                        source_id=primary_source_id,
+                        original_path=original,
+                        scan_archive=item.scan_archive,
+                    )
+                )
         items.extend(remapped)
         for entry in root_excluded:
             original_excluded = entry["path"]
@@ -1776,6 +1805,13 @@ def _dedup_canonical_path(paths: list[str]) -> str:
 
 
 def _should_content_dedup(size: int, relative: str) -> bool:
+    # Keep software mirrors under source/ even when an evidence/ twin exists.
+    stripped = relative
+    lower = relative.casefold()
+    if lower.startswith("source/"):
+        stripped = relative[len("source/") :]
+    if stripped in _SOFTWARE_MIRROR_UNDER_SOURCE:
+        return False
     name = _path_basename(relative)
     if name in DERIVED_BOARD_VIEWER_ASSETS or name.endswith((".brd", ".pdf")):
         return True

+ 1 - 1
tools/replay_review_compact.py

@@ -198,7 +198,7 @@ def _board_detached_check(cpld_root: Path) -> dict[str, Any]:
             sys.executable,
             "-B",
             str(validator),
-            "--generated-dir",
+            "--generated",
             str(generated),
         ],
         cwd=str(validator.parent),