# CPLD 分析打包工具 根目录入口: ```bash python3 package_for_agent_analysis.py --profile review-compact --output-dir /tmp/prod2u-handoff # 或薄封装: tools/package-review-compact.sh ``` 默认上传 profile 是 **`review-compact`**:统一 `source/` + `evidence/` + `meta/` 布局,单一 ZIP + `.tar.zst`,不含完整 Git bundle / PDF / BRD / DSN 原件。 要求 Python 3.11 或更高版本。默认配置是 `config/agent_analysis_handoff_sources.json`,结构约束是 `schemas/agent_analysis_handoff_sources.schema.json`。 ## Profiles | Profile | 用途 | 布局 | 完整 Git bundle | |---|---|---|---| | `review-compact` | **默认远程上传** | `source/` + `evidence/` + `meta/` | 否(commit/status/log-20/tree/逐文件 SHA-256 + TD binding hooks) | | `review-debug` | 复杂失败时的调试包 | 同上 | 否 | | `archive-local` | 本地归档(默认不上传) | 同上 | 默认是(可用 `--no-git-bundle` 关闭;`--include-full-history` 强制) | | `full` | 兼容旧 inclusion-first | `workspace-current` + core/reference 分包 | **必须** | | `code-only` | 兼容代码+测试包 | `workspace-current` | 可选 | 固件包仍由 `tools/build_firmware_package.py` 独立产出,本工具不改动固件路径。 ## review-compact 调用 ```bash python3 package_for_agent_analysis.py \ --profile review-compact \ --output-dir "${TMPDIR:-/tmp}/prod2u-handoff" \ --package-name "prod2u-review-compact-$(date -u +%Y%m%dT%H%M%SZ)" # 等价: tools/package-review-compact.sh ``` Git provenance(review-compact **强制**): - 必须从 exact DELIVERY 的 **live Git 工作树**(含 linked worktree)打包;在去除 `.git` 之前生成 `meta/git/HEAD.txt`、`branch.txt`、`status.txt`、`log-20.txt`、`tree-manifest.json`、`source-file-sha256.json`。 - tree/逐文件 SHA-256 来自 `git archive `,不是脏工作区扫描。 - 无 live Git 时 **fail closed**(不再静默只写 `sanitized-snapshot-status=not_applicable` 的“成功包”)。 - 可选 `--include-sanitized-git-snapshot` 不能代替上述 provenance,也不能冒充原始 tip。 可选: - `--include-sanitized-git-snapshot`:可选合成单 commit 快照(`meta/git/sanitized-snapshot.bundle` + mapping;明确 synthetic→original,不冒充原始 tip) - `--evidence-root DIR`:把交付/跑批证据树收口到 canonical `evidence/`(见下) - `--include-process-evidence`:额外收入 lane receipts / matrix rerun 等过程证据(`review-debug` 默认开启) - `--audit-only`:只扫描不写 ZIP - `--explain PATH`:解释某路径是否收入 - 四分态回放:`tools/replay-review-compact.sh `(或 `tools/replay_review_compact.py`);仅解压校验用 `tools/extract-review-compact.sh` ## Evidence canonicalization(review-compact) 默认 compact **每种最终证据只保留一份物理副本**;逻辑别名写入 `HANDOFF-INDEX.json` 的 `evidence_aliases` / `evidence_canon.aliases`。允许清单见 `config/review_compact_evidence_allowlist.json`: - final matrix、Formal receipt、TD receipt、tip binding、source closure、bitstream - firmware selftest、compact package selftest、deep-review **summary** - IO evidence、hardware bring-up notes 过程型证据(lane receipts、多个 matrix rerun、deep-review round 文件、完整过程日志)仅在 `review-debug` 或 `--include-process-evidence` 中保留。 结果敏感日志策略:PASS / `not_run` → 摘要;FAIL / BLOCKED / TIMEOUT / CRASH → 完整证据。 ## 收入与排除(review-*) **保留**:活动源码/测试/协议/项目合同、board-viewer 六件派生资产(`board-data.json` / `build-info.json` / `import-report.json` / 三张 SVG)、`tests/board_viewer/fixtures` 小 fixture、上表最终收据类 evidence。 **排除**:`reference/original/{board,schematics,diagrams,local_archives}`、PDF/BRD/DSN 原件、vendor installer zip、license、旧 run log、`.run_id*`、venv、`node_modules`、完整 Git bundle(非 archive-local)、默认 profile 下的过程型 evidence。 ## 包目录内容 - 一个(或少数)普通 `.zip` + 同源 `.tar.zst` - `PACKAGE-PURPOSE.txt`:上传意图 - `HANDOFF-INDEX.json`:来源、卷、SHA-256、`member_count`(ZIP 业务成员 vs 自引用控制文件)、`size_budget`、`content_dedup` / `evidence_aliases`、`evidence_canon`、`derived_evidence` - `size-budget.json`:≥256KiB 或 >1% 体积成员表 - `EXCLUSIONS.txt` / `START-HERE.zh-CN.md` / `SHA256SUMS.txt` ZIP 内(`CPLD/` 根下): - `source/` 活动源与测试 - `evidence/` 收据与 board-viewer 派生资产(物理 dedup + index aliases) - `meta/` PACKAGE-PURPOSE、git 溯源、TD source-closure binding hooks 成员计数语义:`member_count.indexed_files` = `files[]`;`self_reference_control_files` 是包目录控制文件(列入 SHA256SUMS),不要与 ZIP payload 重复加总。 ## 兼容命令(legacy) ```bash python3 package_for_agent_analysis.py --profile full --output-dir /tmp/out python3 package_for_agent_analysis.py --profile code-only --no-git-bundle ``` `--no-git-bundle` 在 `full` 下会失败(full 强制 bundle)。`review-compact` 始终无 bundle。 ## 安全边界 该工具只读取文件、运行 Git/7-Zip 的离线检查并写入指定输出目录。它不会枚举或打开串口,不会切换 DTR/RTS,不会启动 TD GUI,不会运行 JTAG,不会执行 `PROGRAM_SRAM`、Flash 或任何真实执行器动作,也不会上传、推送或自动提交 Git。