fix(visor): isolate evidence outputs and linked-file writes
Browse filesEnforce formal evidence roles at every configurable report entry and renderer target. Replace linked text outputs atomically with unique temporary files. Twelve isolated tests and 26 two-sequence integration scenarios pass. Data/raw/schema and pending human review are preserved; historical full-run evidence is distinguished from this maintenance.
- EPIC-KITCHENS-VISOR/shared-v1.1/doc/FULL_MIGRATION_SUMMARY.json +32 -1
- EPIC-KITCHENS-VISOR/shared-v1.1/doc/REVIEW_FIXES.md +74 -0
- EPIC-KITCHENS-VISOR/shared-v1.1/doc/validation/review_fixes.json +48 -0
- EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/README.md +17 -0
- EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/convert.py +2 -0
- EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/read_sequence.py +1 -3
- EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/render.py +11 -2
- EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/test_review_fixes.py +177 -0
- EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/verify.py +1 -2
- EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/visor_common.py +20 -11
EPIC-KITCHENS-VISOR/shared-v1.1/doc/FULL_MIGRATION_SUMMARY.json
CHANGED
|
@@ -930,5 +930,36 @@
|
|
| 930 |
"note": "CONTRACT 6.5 keeps human visual acceptance separate from this record; every check above is mechanical. full_output_human_review in the view metainfo still reads pending and was not rewritten."
|
| 931 |
},
|
| 932 |
"publication_authorized": false,
|
| 933 |
-
"scope": "179 sequences, 179 ego views, 50729 frames; a first release that is v1.1 (no v1.0 exists for this dataset); human post-full review and HF publication pending"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 934 |
}
|
|
|
|
| 930 |
"note": "CONTRACT 6.5 keeps human visual acceptance separate from this record; every check above is mechanical. full_output_human_review in the view metainfo still reads pending and was not rewritten."
|
| 931 |
},
|
| 932 |
"publication_authorized": false,
|
| 933 |
+
"scope": "179 sequences, 179 ego views, 50729 frames; a first release that is v1.1 (no v1.0 exists for this dataset); human post-full review and HF publication pending",
|
| 934 |
+
"maintenance": {
|
| 935 |
+
"date": "2026-10-21",
|
| 936 |
+
"reviewed_parent": "e6d5a90bb89ab4e9b33c20aa990cde8d4a59e9f5",
|
| 937 |
+
"scope": "output isolation, repeatable regression tests and provenance only; data, raw and existing validation pages unchanged",
|
| 938 |
+
"historical_full_run_fields": "All pre-existing full-validation results, tool_digest and target_files/target_bytes identify the reviewed parent; they are not fresh full-dataset checks with these maintenance tools.",
|
| 939 |
+
"current_release_tools_sha256": {
|
| 940 |
+
"script/provenance/operations/build_visor_docs.py": "5a3e45bc7957975444f41b58dc84ca63b877312769f8d7c54ede22e5c631dc9e",
|
| 941 |
+
"script/visor_v1_1/convert.py": "3f7f5289063fdc82c3bef7284b16150ee72dd85b3e16dea845b3dcd4f981da0f",
|
| 942 |
+
"script/visor_v1_1/media.py": "f6372167e59fe2be1d8786fd14aee5c3edfe8297d9d126848a09d2adab485650",
|
| 943 |
+
"script/visor_v1_1/read_sequence.py": "315e58ea96780b4f4c98ca0ac61afa66e7d099b639065b7fc4e0423b9b00f322",
|
| 944 |
+
"script/visor_v1_1/render.py": "8871869335020a25a33e0b038ea3274a45c726e1d0e461cc7e77181b3c05f506",
|
| 945 |
+
"script/visor_v1_1/validate.py": "613678ea8ec9f8e4d48e1e6db9a2e1c0f2ca3f8f4f5df738843925b23819c40b",
|
| 946 |
+
"script/visor_v1_1/verify.py": "bb557c082f5461507059356c4b8b486602de97b85a1ad837f5f7d6b70a07ee9a",
|
| 947 |
+
"script/visor_v1_1/visor_common.py": "9f7a0c40f0c29219aca5c7ceb975d9f761252c36046f7582ce5317fd9fb28a42",
|
| 948 |
+
"script/visor_v1_1/warehouse.py": "fe62f79f9228475e23764d57c923e781422951ad5ed6680337bf67e120a63db2",
|
| 949 |
+
"script/visor_v1_1/test_review_fixes.py": "1f79282b6935d00d7919765ae0a0b5560404b18dfcacc55ea5dce13605d43f99"
|
| 950 |
+
},
|
| 951 |
+
"current_release_files": 35729,
|
| 952 |
+
"regression_report": "doc/validation/review_fixes.json",
|
| 953 |
+
"documentation": "doc/REVIEW_FIXES.md",
|
| 954 |
+
"full_real_data_validation_rerun": false,
|
| 955 |
+
"human_review": "pending",
|
| 956 |
+
"merge_authorized_by_current_user": true,
|
| 957 |
+
"current_external_content_identity_ledger": {
|
| 958 |
+
"rebuilt": true,
|
| 959 |
+
"location": "outside the release: maintenance workdir/TREE_MANIFEST.json",
|
| 960 |
+
"basis": "all pinned Git tree/blob identities; SHA256 of new/changed files; unchanged LFS identities retained",
|
| 961 |
+
"full_lfs_payload_reread": false
|
| 962 |
+
},
|
| 963 |
+
"current_external_sha256_publication_manifest_refreshed": false
|
| 964 |
+
}
|
| 965 |
}
|
EPIC-KITCHENS-VISOR/shared-v1.1/doc/REVIEW_FIXES.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PR #9 maintenance — 2026-10-21
|
| 2 |
+
|
| 3 |
+
Reviewed input: `e6d5a90bb89ab4e9b33c20aa990cde8d4a59e9f5`.
|
| 4 |
+
|
| 5 |
+
## Invariant and repair
|
| 6 |
+
|
| 7 |
+
A partial operation must not rewrite formal acceptance evidence. Checking only an output
|
| 8 |
+
directory is insufficient: a child file can alias protected evidence, and a separate
|
| 9 |
+
command can expose another report-writing entry point.
|
| 10 |
+
|
| 11 |
+
The repair has three small parts:
|
| 12 |
+
|
| 13 |
+
1. The converter validates `--report` before opening the source or creating output.
|
| 14 |
+
2. The renderer preflights every planned page, per-view report, index and aggregate
|
| 15 |
+
report before starting decoder workers. A formal renderer can write its own page
|
| 16 |
+
role, but cannot borrow a different protected role through a link.
|
| 17 |
+
3. JSON, JSONL and HTML use a shared atomic text writer: create a unique sibling temporary
|
| 18 |
+
file, write it, then replace the directory entry. Existing linked inodes are not
|
| 19 |
+
truncated; a fixed `.tmp` alias cannot redirect the write. Temporary files are cleaned
|
| 20 |
+
if replacement fails. Reader and source-verifier reports use that same writer.
|
| 21 |
+
|
| 22 |
+
This preserves JSON/JSONL serialization and makes the safeguard apply to the write itself,
|
| 23 |
+
not merely to a particular CLI option. It does not introduce a dependency or change the
|
| 24 |
+
source semantics, validity policies or any released data bytes.
|
| 25 |
+
|
| 26 |
+
## Repeatable tests
|
| 27 |
+
|
| 28 |
+
```bash
|
| 29 |
+
python -B shared-v1.1/script/visor_v1_1/test_review_fixes.py
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
The 12 isolated unittest cases require the normal tool dependencies but no raw archive or
|
| 33 |
+
released data. They cover converter report roles and aliases, renderer child aliases and
|
| 34 |
+
preflight order, formal role separation, atomic replacement, failure cleanup, fixed-temp
|
| 35 |
+
aliases, NaN rejection and unchanged JSONL serialization. The two principal regression
|
| 36 |
+
tests fail against the reviewed parent and pass with the repair.
|
| 37 |
+
|
| 38 |
+
The maintenance report is `doc/validation/review_fixes.json`. Its additional 26 integration
|
| 39 |
+
scenarios used isolated copies of the real P04_26 (4 frames) and P32_07 (6 frames) views
|
| 40 |
+
and raw members from immutable main `da27f4bfba2e521d75ab180257ebadd689fa0ad4`.
|
| 41 |
+
All ten JPEG packets and 56 polygon rings / 3,541 points matched the source; structure,
|
| 42 |
+
validity round-trip, reading and the four-frame P04_26 render passed. A fresh P04_26
|
| 43 |
+
conversion preserved all four JSONL tables and all three bool validity tensors.
|
| 44 |
+
Injected contact-target corruption, a missing exhaustive flag, empty/invalid selections
|
| 45 |
+
and protected output requests were rejected. Formal evidence survived both symbolic and
|
| 46 |
+
hard-link probes; normal temporary outputs still work.
|
| 47 |
+
|
| 48 |
+
## Provenance and manifest scope
|
| 49 |
+
|
| 50 |
+
All `data/` and `raw/` Git tree identities are preserved. No other dataset, root LFS rule,
|
| 51 |
+
schema or existing review page is changed. Three files are added: the repeatable test,
|
| 52 |
+
this document and the maintenance report.
|
| 53 |
+
|
| 54 |
+
The original full-run fields in `FULL_MIGRATION_SUMMARY.json`, including its original
|
| 55 |
+
tool digests and tree totals, are historical evidence for the reviewed parent, not a claim
|
| 56 |
+
that this maintenance reran all 179 views. Its `maintenance` section identifies the
|
| 57 |
+
currently shipped tool digests and the new test evidence separately. The original full
|
| 58 |
+
reader/structural/source records and human-review state are not relabeled.
|
| 59 |
+
|
| 60 |
+
A current candidate-bound content-identity ledger is rebuilt outside the release tree.
|
| 61 |
+
It records every Git tree/blob identity, SHA256 for new or changed files, and the pinned
|
| 62 |
+
LFS content identities where available. It is not the author's external full SHA256
|
| 63 |
+
publication manifest, which was not available locally and is not claimed to have been
|
| 64 |
+
regenerated. Immutable tree identities establish unchanged tracked content without
|
| 65 |
+
redownloading unrelated data. They do not establish annotation correctness or repeat a
|
| 66 |
+
full-media decode. The ledger is outside the release and does not hash itself.
|
| 67 |
+
|
| 68 |
+
## Remaining acceptance boundaries
|
| 69 |
+
|
| 70 |
+
Human review remains **pending**. No new human approval or source-license interpretation
|
| 71 |
+
is asserted. The full approximately 30.6 GB raw SHA256 pass and all approximately 20 GB
|
| 72 |
+
released media were not reread in this maintenance. Merge authorization comes from the
|
| 73 |
+
current user's explicit request; merging is not human visual acceptance and does not
|
| 74 |
+
silently change the published view flags.
|
EPIC-KITCHENS-VISOR/shared-v1.1/doc/validation/review_fixes.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"date": "2026-10-21",
|
| 3 |
+
"reviewed_parent": "e6d5a90bb89ab4e9b33c20aa990cde8d4a59e9f5",
|
| 4 |
+
"scope": "maintenance regression and two real sequence samples, not a fresh full-dataset acceptance or human visual approval",
|
| 5 |
+
"unit_tests": {
|
| 6 |
+
"tool": "script/visor_v1_1/test_review_fixes.py",
|
| 7 |
+
"tests": 12,
|
| 8 |
+
"passed": true,
|
| 9 |
+
"baseline_selected_regressions_failed": true
|
| 10 |
+
},
|
| 11 |
+
"integration": {
|
| 12 |
+
"scenarios": 26,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"views": [
|
| 15 |
+
"P04_26/ego",
|
| 16 |
+
"P32_07/ego"
|
| 17 |
+
],
|
| 18 |
+
"frames": 10,
|
| 19 |
+
"source_archive": "immutable main da27f4bfba2e521d75ab180257ebadd689fa0ad4, HTTP-range-extracted members cached during independent review",
|
| 20 |
+
"source_subset_sha256": "8d4f1113e544f4cac81775c757d260ab1d9e9d8f17d5f3c6e234fac59bf9d040",
|
| 21 |
+
"all_ten_rgb_packets_equal_source": true,
|
| 22 |
+
"polygons": {
|
| 23 |
+
"rings": 56,
|
| 24 |
+
"points": 3541,
|
| 25 |
+
"bit_identical": true
|
| 26 |
+
},
|
| 27 |
+
"converted_jsonl_and_validity_equal_published": {
|
| 28 |
+
"P04_26/ego/observation/rgb_valid.pt": true,
|
| 29 |
+
"P04_26/ego/camera/frames.jsonl": true,
|
| 30 |
+
"P04_26/ego/annotation/contact/relations_valid.pt": true,
|
| 31 |
+
"P04_26/ego/annotation/contact/relations.jsonl": true,
|
| 32 |
+
"P04_26/ego/annotation/segment/mask_valid.pt": true,
|
| 33 |
+
"P04_26/ego/annotation/segment/instances.jsonl": true,
|
| 34 |
+
"P04_26/ego/annotation/segment/polygons.jsonl": true
|
| 35 |
+
},
|
| 36 |
+
"all_original_review_defects_rejected": true,
|
| 37 |
+
"conversion_manifest_preserved": true,
|
| 38 |
+
"linked_html_index_preserved": {
|
| 39 |
+
"symlink": true,
|
| 40 |
+
"hardlink": true
|
| 41 |
+
},
|
| 42 |
+
"unregistered_page_hardlinks_detached_by_reader_and_verifier": true,
|
| 43 |
+
"formal_review_reports_preserved": true
|
| 44 |
+
},
|
| 45 |
+
"human_review": "pending",
|
| 46 |
+
"full_dataset_rerun": false,
|
| 47 |
+
"raw_archive_full_sha256_rerun": false
|
| 48 |
+
}
|
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/README.md
CHANGED
|
@@ -205,3 +205,20 @@ python shared-v1.1/script/visor_v1_1/validate.py --expect-views 179 --rewrite-ch
|
|
| 205 |
这套页面是**人工验收要看的材料**,不是训练输入。CONTRACT §6.5 区分「重打包在数值上逐字节同一」与「人工目视验收」,页面给的是后者;渲出页面不等于有人看过,所以发布状态里的 `full_output_human_review` 与汇总里的 `human_full_review` 都仍是 `"pending"`。
|
| 206 |
|
| 207 |
验收只证明「发布忠实于源、且在数值上逐位同一」,不等同于人工目视确认(CONTRACT §6.5)。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
这套页面是**人工验收要看的材料**,不是训练输入。CONTRACT §6.5 区分「重打包在数值上逐字节同一」与「人工目视验收」,页面给的是后者;渲出页面不等于有人看过,所以发布状态里的 `full_output_human_review` 与汇总里的 `human_full_review` 都仍是 `"pending"`。
|
| 206 |
|
| 207 |
验收只证明「发布忠实于源、且在数值上逐位同一」,不等同于人工目视确认(CONTRACT §6.5)。
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
## 2026-10-21:正式证据输出隔离修复
|
| 211 |
+
|
| 212 |
+
报告输出先校验权限,渲染在启动子进程前逐一校验所有目标文件;JSON/JSONL/HTML
|
| 213 |
+
共用唯一临时文件和原子替换写入,避免通过硬链接、符号链接或固定 `.tmp` 名称改写原件。
|
| 214 |
+
转换器的 `--report` 也适用正式证据保护。正常转换与 JSONL 序列化内容不变。
|
| 215 |
+
|
| 216 |
+
随发布提供可重复运行的隔离回归测试(只写系统临时目录,不要求 raw 或正式数据):
|
| 217 |
+
|
| 218 |
+
```bash
|
| 219 |
+
python -B shared-v1.1/script/visor_v1_1/test_review_fixes.py
|
| 220 |
+
```
|
| 221 |
+
|
| 222 |
+
12 项单元测试及真实两段序列的维护检查见 `doc/validation/review_fixes.json`。
|
| 223 |
+
历史全量验收不冒充这次重新执行的验收;范围与文件清单说明见 `doc/REVIEW_FIXES.md`。
|
| 224 |
+
人工复核仍为 pending,源语义与许可待确认事项未改判。
|
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/convert.py
CHANGED
|
@@ -592,6 +592,8 @@ def main(argv=None):
|
|
| 592 |
parser.add_argument("--report", type=Path, default=vc.TMP_ROOT / "convert_report.json")
|
| 593 |
args = parser.parse_args(argv)
|
| 594 |
|
|
|
|
|
|
|
| 595 |
# 整包身份:只有确实指向那份源整包时才要求字节数与 sha256 吻合。原型阶段可以指向
|
| 596 |
# tmp 里重建的探针 zip(成员路径与源一致),此时如实记下它是什么、不假装是源整包。
|
| 597 |
declared = args.archive.resolve() == vc.RAW_ARCHIVE.resolve()
|
|
|
|
| 592 |
parser.add_argument("--report", type=Path, default=vc.TMP_ROOT / "convert_report.json")
|
| 593 |
args = parser.parse_args(argv)
|
| 594 |
|
| 595 |
+
vc.guard_output(args.report, False, set(), "convert")
|
| 596 |
+
|
| 597 |
# 整包身份:只有确实指向那份源整包时才要求字节数与 sha256 吻合。原型阶段可以指向
|
| 598 |
# tmp 里重建的探针 zip(成员路径与源一致),此时如实记下它是什么、不假装是源整包。
|
| 599 |
declared = args.archive.resolve() == vc.RAW_ARCHIVE.resolve()
|
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/read_sequence.py
CHANGED
|
@@ -570,9 +570,7 @@ def main(argv=None):
|
|
| 570 |
"check against the raw deposit (the converter owns that evidence)",
|
| 571 |
}
|
| 572 |
if args.report is not None:
|
| 573 |
-
args.report
|
| 574 |
-
args.report.write_text(json.dumps(report, ensure_ascii=False, indent=2),
|
| 575 |
-
encoding="utf-8")
|
| 576 |
print(f"wrote {args.report}")
|
| 577 |
print("ACCEPTANCE_PASS" if accepted else "ACCEPTANCE_FAIL")
|
| 578 |
return 0 if accepted else 1
|
|
|
|
| 570 |
"check against the raw deposit (the converter owns that evidence)",
|
| 571 |
}
|
| 572 |
if args.report is not None:
|
| 573 |
+
vc.save(args.report, report)
|
|
|
|
|
|
|
| 574 |
print(f"wrote {args.report}")
|
| 575 |
print("ACCEPTANCE_PASS" if accepted else "ACCEPTANCE_FAIL")
|
| 576 |
return 0 if accepted else 1
|
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/render.py
CHANGED
|
@@ -71,10 +71,12 @@ from visor_common import (
|
|
| 71 |
TMP_ROOT,
|
| 72 |
check_view,
|
| 73 |
guard_directory,
|
|
|
|
| 74 |
load,
|
| 75 |
read_jsonl,
|
| 76 |
same_path,
|
| 77 |
save,
|
|
|
|
| 78 |
)
|
| 79 |
from warehouse import Registry
|
| 80 |
|
|
@@ -930,7 +932,7 @@ def render_one(view: Path, destination: Path, root: Path) -> dict:
|
|
| 930 |
)
|
| 931 |
|
| 932 |
destination.mkdir(parents=True, exist_ok=True)
|
| 933 |
-
(destination / (title + ".html")
|
| 934 |
save(destination / (title + ".report.json"), report)
|
| 935 |
report["_page"] = title + ".html"
|
| 936 |
print(destination / (title + ".html"), "selected_frames", selected, flush=True)
|
|
@@ -1280,6 +1282,13 @@ def main(argv=None):
|
|
| 1280 |
"annotated_in_release": sum(1 for f in facts.values() if f["annotated"]),
|
| 1281 |
}
|
| 1282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1283 |
start = time.monotonic()
|
| 1284 |
#: no .pyc may land in the release tree, and a spawn child re-imports this module before
|
| 1285 |
#: any guard inside it runs -- so the switch has to be in the environment the children
|
|
@@ -1408,7 +1417,7 @@ def main(argv=None):
|
|
| 1408 |
for name in links
|
| 1409 |
) + "</ul></html>"
|
| 1410 |
)
|
| 1411 |
-
(destination / "index.html"
|
| 1412 |
print(
|
| 1413 |
"POST_FULL_HTML_DONE", len(views), "views", round(report["wall_seconds"], 2),
|
| 1414 |
"seconds", destination / "index.html", flush=True,
|
|
|
|
| 71 |
TMP_ROOT,
|
| 72 |
check_view,
|
| 73 |
guard_directory,
|
| 74 |
+
guard_output,
|
| 75 |
load,
|
| 76 |
read_jsonl,
|
| 77 |
same_path,
|
| 78 |
save,
|
| 79 |
+
write_text_atomic,
|
| 80 |
)
|
| 81 |
from warehouse import Registry
|
| 82 |
|
|
|
|
| 932 |
)
|
| 933 |
|
| 934 |
destination.mkdir(parents=True, exist_ok=True)
|
| 935 |
+
write_text_atomic(destination / (title + ".html"), page)
|
| 936 |
save(destination / (title + ".report.json"), report)
|
| 937 |
report["_page"] = title + ".html"
|
| 938 |
print(destination / (title + ".html"), "selected_frames", selected, flush=True)
|
|
|
|
| 1282 |
"annotated_in_release": sum(1 for f in facts.values() if f["annotated"]),
|
| 1283 |
}
|
| 1284 |
|
| 1285 |
+
outputs = [destination / "index.html", destination / "V1_1_VALIDATION.json"]
|
| 1286 |
+
for view in views:
|
| 1287 |
+
title = f"{view.parent.name}_{view.name}"
|
| 1288 |
+
outputs.extend(destination / (title + suffix) for suffix in (".html", ".report.json"))
|
| 1289 |
+
for output in outputs:
|
| 1290 |
+
guard_output(output, formal, {"review pages", "review report", "review index"}, "render")
|
| 1291 |
+
|
| 1292 |
start = time.monotonic()
|
| 1293 |
#: no .pyc may land in the release tree, and a spawn child re-imports this module before
|
| 1294 |
#: any guard inside it runs -- so the switch has to be in the environment the children
|
|
|
|
| 1417 |
for name in links
|
| 1418 |
) + "</ul></html>"
|
| 1419 |
)
|
| 1420 |
+
write_text_atomic(destination / "index.html", index)
|
| 1421 |
print(
|
| 1422 |
"POST_FULL_HTML_DONE", len(views), "views", round(report["wall_seconds"], 2),
|
| 1423 |
"seconds", destination / "index.html", flush=True,
|
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/test_review_fixes.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Output-isolation regression tests; fixtures never touch the release's real evidence."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import contextlib
|
| 5 |
+
import io
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
import sys
|
| 10 |
+
import tempfile
|
| 11 |
+
import unittest
|
| 12 |
+
from unittest.mock import patch
|
| 13 |
+
|
| 14 |
+
sys.dont_write_bytecode = True
|
| 15 |
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 16 |
+
|
| 17 |
+
import convert
|
| 18 |
+
import render
|
| 19 |
+
import visor_common as vc
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class OutputIsolationTests(unittest.TestCase):
|
| 23 |
+
def setUp(self):
|
| 24 |
+
self.temporary = tempfile.TemporaryDirectory()
|
| 25 |
+
self.addCleanup(self.temporary.cleanup)
|
| 26 |
+
self.root = Path(self.temporary.name)
|
| 27 |
+
self.release = self.root / "shared-v1.1"
|
| 28 |
+
self.tmp = self.root / "tmp" / "visor-tools"
|
| 29 |
+
self.guard = patch.multiple(
|
| 30 |
+
vc, RELEASE_ROOT=self.release, TMP_ROOT=self.tmp,
|
| 31 |
+
MANIFEST_PATH=self.tmp / "PUBLISH_MANIFEST.json",
|
| 32 |
+
)
|
| 33 |
+
self.guard.start()
|
| 34 |
+
self.addCleanup(self.guard.stop)
|
| 35 |
+
for path in vc.protected_outputs().values():
|
| 36 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 37 |
+
path.write_text("formal evidence", encoding="utf-8")
|
| 38 |
+
self.view = self.release / "data" / "P04_26" / "ego"
|
| 39 |
+
self.view.mkdir(parents=True)
|
| 40 |
+
(self.view / "metainfo.json").write_text("{}", encoding="utf-8")
|
| 41 |
+
|
| 42 |
+
def rejected(self, action, label):
|
| 43 |
+
with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
|
| 44 |
+
with self.assertRaisesRegex(SystemExit, label):
|
| 45 |
+
action()
|
| 46 |
+
|
| 47 |
+
def test_converter_rejects_every_formal_report_before_opening_source(self):
|
| 48 |
+
for role, path in vc.protected_outputs().items():
|
| 49 |
+
with self.subTest(role=role):
|
| 50 |
+
output = self.root / "unused-conversion"
|
| 51 |
+
self.rejected(lambda: convert.main([
|
| 52 |
+
"--archive", str(self.root / "does-not-exist.zip"),
|
| 53 |
+
"--out", str(output), "--report", str(path),
|
| 54 |
+
]), "convert")
|
| 55 |
+
self.assertEqual(path.read_text(), "formal evidence")
|
| 56 |
+
self.assertFalse(output.exists())
|
| 57 |
+
|
| 58 |
+
def test_converter_rejects_report_aliases(self):
|
| 59 |
+
for kind in ("symlink", "hardlink"):
|
| 60 |
+
with self.subTest(kind=kind):
|
| 61 |
+
alias = self.root / (kind + ".json")
|
| 62 |
+
if kind == "symlink":
|
| 63 |
+
alias.symlink_to(vc.MANIFEST_PATH)
|
| 64 |
+
else:
|
| 65 |
+
os.link(vc.MANIFEST_PATH, alias)
|
| 66 |
+
self.rejected(lambda: convert.main([
|
| 67 |
+
"--archive", str(self.root / "does-not-exist.zip"),
|
| 68 |
+
"--report", str(alias),
|
| 69 |
+
]), "convert")
|
| 70 |
+
self.assertEqual(vc.MANIFEST_PATH.read_text(), "formal evidence")
|
| 71 |
+
|
| 72 |
+
def check_render_alias(self, name, kind, protected):
|
| 73 |
+
output = self.root / (name.replace(".", "_") + "-" + kind)
|
| 74 |
+
output.mkdir()
|
| 75 |
+
alias = output / name
|
| 76 |
+
if kind == "symlink":
|
| 77 |
+
alias.symlink_to(protected)
|
| 78 |
+
else:
|
| 79 |
+
os.link(protected, alias)
|
| 80 |
+
with patch.object(render, "ProcessPoolExecutor") as executor:
|
| 81 |
+
self.rejected(lambda: render.main([
|
| 82 |
+
"--root", str(self.release), "--views", "P04_26/ego",
|
| 83 |
+
"--out", str(output), "--workers", "1",
|
| 84 |
+
]), "render")
|
| 85 |
+
executor.assert_not_called()
|
| 86 |
+
self.assertEqual(protected.read_text(), "formal evidence")
|
| 87 |
+
self.assertEqual(list(output.iterdir()), [alias])
|
| 88 |
+
|
| 89 |
+
def test_render_rejects_child_index_aliases_before_rendering(self):
|
| 90 |
+
protected = self.release / "doc" / "validation" / "index.html"
|
| 91 |
+
for kind in ("symlink", "hardlink"):
|
| 92 |
+
with self.subTest(kind=kind):
|
| 93 |
+
self.check_render_alias("index.html", kind, protected)
|
| 94 |
+
|
| 95 |
+
def test_render_rejects_child_page_and_report_aliases(self):
|
| 96 |
+
protected = self.release / "doc" / "validation" / "index.html"
|
| 97 |
+
for name in ("P04_26_ego.html", "P04_26_ego.report.json", "V1_1_VALIDATION.json"):
|
| 98 |
+
for kind in ("symlink", "hardlink"):
|
| 99 |
+
with self.subTest(name=name, kind=kind):
|
| 100 |
+
self.check_render_alias(name, kind, protected)
|
| 101 |
+
|
| 102 |
+
def test_render_rejects_symlink_to_an_unregistered_formal_page(self):
|
| 103 |
+
protected = self.release / "doc" / "validation" / "other_view.html"
|
| 104 |
+
protected.write_text("formal evidence")
|
| 105 |
+
self.check_render_alias("P04_26_ego.html", "symlink", protected)
|
| 106 |
+
|
| 107 |
+
def test_partial_output_never_targets_a_formal_directory(self):
|
| 108 |
+
path = self.release / "doc" / "validation" / "new_page.html"
|
| 109 |
+
self.rejected(lambda: vc.guard_output(path, False, set(), "test"), "test")
|
| 110 |
+
self.assertFalse(path.exists())
|
| 111 |
+
|
| 112 |
+
def test_formal_renderer_can_write_its_pages_but_not_other_roles(self):
|
| 113 |
+
review = self.release / "doc" / "validation"
|
| 114 |
+
for name in ("new_page.html", "new_page.report.json", "index.html", "V1_1_VALIDATION.json"):
|
| 115 |
+
vc.guard_output(review / name, True,
|
| 116 |
+
{"review pages", "review index", "review report"}, "render")
|
| 117 |
+
self.rejected(lambda: vc.guard_output(
|
| 118 |
+
review / "validate_report.json", True,
|
| 119 |
+
{"review pages", "review index", "review report"}, "render"), "render")
|
| 120 |
+
|
| 121 |
+
def test_formal_writer_cannot_borrow_one_of_two_linked_roles(self):
|
| 122 |
+
report = self.release / "doc" / "validation" / "validate_report.json"
|
| 123 |
+
report.unlink()
|
| 124 |
+
os.link(vc.MANIFEST_PATH, report)
|
| 125 |
+
self.rejected(lambda: vc.guard_output(
|
| 126 |
+
report, True, {"validate report"}, "validate"), "validate")
|
| 127 |
+
self.assertEqual(vc.MANIFEST_PATH.read_text(), "formal evidence")
|
| 128 |
+
|
| 129 |
+
def test_text_writer_detaches_hardlinks_and_symlinks(self):
|
| 130 |
+
protected = self.release / "doc" / "validation" / "unregistered_page.html"
|
| 131 |
+
protected.write_text("formal evidence")
|
| 132 |
+
for kind in ("symlink", "hardlink"):
|
| 133 |
+
target = self.root / (kind + ".html")
|
| 134 |
+
if kind == "symlink":
|
| 135 |
+
target.symlink_to(protected)
|
| 136 |
+
else:
|
| 137 |
+
os.link(protected, target)
|
| 138 |
+
vc.write_text_atomic(target, "local result")
|
| 139 |
+
self.assertEqual(target.read_text(), "local result")
|
| 140 |
+
self.assertEqual(protected.read_text(), "formal evidence")
|
| 141 |
+
self.assertFalse(os.path.samefile(target, protected))
|
| 142 |
+
|
| 143 |
+
def test_json_writers_ignore_predictable_temp_aliases(self):
|
| 144 |
+
for name, write in (
|
| 145 |
+
("report.json", lambda p: vc.save(p, {"ok": True})),
|
| 146 |
+
("rows.jsonl", lambda p: vc.write_jsonl(p, [{"ok": True}])),
|
| 147 |
+
):
|
| 148 |
+
target = self.root / name
|
| 149 |
+
alias = target.with_suffix(target.suffix + ".tmp")
|
| 150 |
+
alias.symlink_to(vc.MANIFEST_PATH)
|
| 151 |
+
write(target)
|
| 152 |
+
self.assertEqual(json.loads(target.read_text()), {"ok": True})
|
| 153 |
+
self.assertEqual(vc.MANIFEST_PATH.read_text(), "formal evidence")
|
| 154 |
+
|
| 155 |
+
def test_failed_atomic_replace_preserves_old_file_and_cleans_temp(self):
|
| 156 |
+
target = self.root / "failure.html"
|
| 157 |
+
target.write_text("old result")
|
| 158 |
+
before = set(self.root.iterdir())
|
| 159 |
+
with patch("os.replace", side_effect=OSError("simulated failure")):
|
| 160 |
+
with self.assertRaisesRegex(OSError, "simulated failure"):
|
| 161 |
+
vc.write_text_atomic(target, "new result")
|
| 162 |
+
self.assertEqual(target.read_text(), "old result")
|
| 163 |
+
self.assertEqual(set(self.root.iterdir()), before)
|
| 164 |
+
|
| 165 |
+
def test_json_nan_rejection_and_jsonl_bytes_are_preserved(self):
|
| 166 |
+
target = self.root / "ordinary.json"
|
| 167 |
+
with self.assertRaises(ValueError):
|
| 168 |
+
vc.save(target, {"bad": float("nan")})
|
| 169 |
+
self.assertFalse(target.exists())
|
| 170 |
+
rows = [{"name": "手", "value": 1.5}, {"valid": True}]
|
| 171 |
+
vc.write_jsonl(target, rows)
|
| 172 |
+
self.assertEqual(target.read_text(), "".join(
|
| 173 |
+
json.dumps(row, ensure_ascii=False, allow_nan=False) + "\n" for row in rows))
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
if __name__ == "__main__":
|
| 177 |
+
unittest.main(verbosity=2)
|
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/verify.py
CHANGED
|
@@ -682,8 +682,7 @@ def main(argv=None):
|
|
| 682 |
"not a judgement of source annotation correctness and not visual acceptance",
|
| 683 |
}
|
| 684 |
if args.report is not None:
|
| 685 |
-
args.report
|
| 686 |
-
args.report.write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding="utf-8")
|
| 687 |
print(f"wrote {args.report}")
|
| 688 |
if accepted:
|
| 689 |
print("VERIFY_PASS")
|
|
|
|
| 682 |
"not a judgement of source annotation correctness and not visual acceptance",
|
| 683 |
}
|
| 684 |
if args.report is not None:
|
| 685 |
+
vc.save(args.report, report)
|
|
|
|
| 686 |
print(f"wrote {args.report}")
|
| 687 |
if accepted:
|
| 688 |
print("VERIFY_PASS")
|
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/visor_common.py
CHANGED
|
@@ -39,6 +39,7 @@ import json
|
|
| 39 |
import os
|
| 40 |
import re
|
| 41 |
import sys
|
|
|
|
| 42 |
import zipfile
|
| 43 |
from pathlib import Path, PurePosixPath
|
| 44 |
|
|
@@ -142,22 +143,28 @@ def load(path):
|
|
| 142 |
return json.loads(Path(path).read_text(encoding="utf-8"))
|
| 143 |
|
| 144 |
|
| 145 |
-
def
|
| 146 |
-
"""
|
| 147 |
path = Path(path)
|
| 148 |
path.parent.mkdir(parents=True, exist_ok=True)
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
|
| 154 |
def write_jsonl(path, rows):
|
| 155 |
-
path = Path(path)
|
| 156 |
-
path.parent.mkdir(parents=True, exist_ok=True)
|
| 157 |
text = "".join(json.dumps(row, ensure_ascii=False, allow_nan=False) + "\n" for row in rows)
|
| 158 |
-
|
| 159 |
-
tmp.write_text(text, encoding="utf-8")
|
| 160 |
-
tmp.replace(path)
|
| 161 |
|
| 162 |
|
| 163 |
def read_jsonl(path):
|
|
@@ -571,12 +578,14 @@ def guard_output(path, formal, writable, label):
|
|
| 571 |
target = Path(path)
|
| 572 |
roles = _protected_roles(target)
|
| 573 |
if roles:
|
| 574 |
-
if formal and set(
|
| 575 |
return
|
| 576 |
reason = "正式运行不改写该角色" if formal else "局部运行不得写正式证据"
|
| 577 |
raise SystemExit(f"{label}: {reason} {roles[0]} -> {target}(写到 {TMP_ROOT})")
|
| 578 |
for name, directory in protected_directories().items():
|
| 579 |
if _within(target, directory):
|
|
|
|
|
|
|
| 580 |
raise SystemExit(
|
| 581 |
f"{label}: {name} 目录内只允许正式运行按角色写文件 -> {target}"
|
| 582 |
)
|
|
|
|
| 39 |
import os
|
| 40 |
import re
|
| 41 |
import sys
|
| 42 |
+
import tempfile
|
| 43 |
import zipfile
|
| 44 |
from pathlib import Path, PurePosixPath
|
| 45 |
|
|
|
|
| 143 |
return json.loads(Path(path).read_text(encoding="utf-8"))
|
| 144 |
|
| 145 |
|
| 146 |
+
def write_text_atomic(path, text):
|
| 147 |
+
"""Replace the directory entry, never truncate an existing linked inode."""
|
| 148 |
path = Path(path)
|
| 149 |
path.parent.mkdir(parents=True, exist_ok=True)
|
| 150 |
+
fd, name = tempfile.mkstemp(prefix="." + path.name + ".", suffix=".tmp", dir=path.parent)
|
| 151 |
+
temporary = Path(name)
|
| 152 |
+
try:
|
| 153 |
+
with os.fdopen(fd, "w", encoding="utf-8") as stream:
|
| 154 |
+
stream.write(text)
|
| 155 |
+
temporary.replace(path)
|
| 156 |
+
finally:
|
| 157 |
+
temporary.unlink(missing_ok=True)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def save(path, value):
|
| 161 |
+
"""JSON 写盘:原子替换,NaN 直接报错而不是写出非法 JSON。"""
|
| 162 |
+
write_text_atomic(path, json.dumps(value, ensure_ascii=False, indent=2, allow_nan=False))
|
| 163 |
|
| 164 |
|
| 165 |
def write_jsonl(path, rows):
|
|
|
|
|
|
|
| 166 |
text = "".join(json.dumps(row, ensure_ascii=False, allow_nan=False) + "\n" for row in rows)
|
| 167 |
+
write_text_atomic(path, text)
|
|
|
|
|
|
|
| 168 |
|
| 169 |
|
| 170 |
def read_jsonl(path):
|
|
|
|
| 578 |
target = Path(path)
|
| 579 |
roles = _protected_roles(target)
|
| 580 |
if roles:
|
| 581 |
+
if formal and set(roles) <= set(writable):
|
| 582 |
return
|
| 583 |
reason = "正式运行不改写该角色" if formal else "局部运行不得写正式证据"
|
| 584 |
raise SystemExit(f"{label}: {reason} {roles[0]} -> {target}(写到 {TMP_ROOT})")
|
| 585 |
for name, directory in protected_directories().items():
|
| 586 |
if _within(target, directory):
|
| 587 |
+
if formal and name in writable:
|
| 588 |
+
return
|
| 589 |
raise SystemExit(
|
| 590 |
f"{label}: {name} 目录内只允许正式运行按角色写文件 -> {target}"
|
| 591 |
)
|