mxk1998 commited on
Commit
2bc3f63
·
verified ·
1 Parent(s): 559b5bb

Pack pinned simulator assets; preserve extraction and hashes

Browse files
ARCHIVES.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Simulator Asset Archive
2
+
3
+ Run from the downloaded repository root, before environment setup or evaluation:
4
+
5
+ ```bash
6
+ python tools/unpack_simulation_assets.py
7
+ python tools/unpack_simulation_assets.py --verify-only
8
+ ```
9
+
10
+ The archive contains exactly 44,901 files (9,569,959,833 expanded bytes).
11
+ Compressed size: 4,528,296,178 bytes.
12
+
13
+ Archive SHA256: `bb84af93bf7fb93afa1068f1532321e473e70bf4dc6e09c8406bff4e8d8f3987`.
14
+
15
+ Paths and content are identical to the pinned customized RoboCasa/RoboSuite
16
+ release. Compression changes storage only, not simulator code or assets.
17
+ The extractor checks the archive hash and every asset hash, rejects links
18
+ and traversal paths, and never overwrites modified files. An interrupted
19
+ extraction can be rerun; matching existing assets are retained.
20
+
21
+ `provenance/simulation_assets.sha256.json` seals expanded asset content.
22
+ `provenance/publication/files.sha256.json` inventories the compressed Hub
23
+ representation and excludes itself. Keep the archive until extraction
24
+ passes. Allow disk space for both compressed and expanded assets, the
25
+ checkpoint, environments, and reconstructed runtime backbone weights.
26
+
27
+ Compression/extraction verification is not a model-effectiveness test.
28
+ All reproduction limitations in `VALIDATION.md` remain applicable.
README.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # WM4A: RoboCasa Reproducibility Snapshot
2
+
3
+ Private reproducibility release for `cosmopredict25_vjepa_ImageLatent/robocasa_06-28-13-10`.
4
+ Target repository: `mxk1998/WM4A`. No token or credential is bundled.
5
+
6
+ ## Selected Result
7
+
8
+ | Checkpoint | Historical successes | Historical mean |
9
+ | --- | --- | --- |
10
+ | `steps_280000_pytorch_model.pt` | 674/1200 | 56.17% |
11
+
12
+ The historical benchmark uses 24 tasks, 50 episodes per task, one environment,
13
+ 720 maximum simulator steps, 12 actions per policy call, and shift 5.0.
14
+ The historical top-level inference argument is 5; the action head uses its
15
+ saved 20 diffusion steps, independently of that argument.
16
+ Original CSVs and logs are under `provenance/evaluation/`; the reference run
17
+ is `wm_eval_20260703_054735`. These are historical measurements, not a claim
18
+ that a new migration smoke test reproduced the full benchmark.
19
+
20
+ See `VALIDATION.md` for the exact current validation level.
21
+ The September 26 (Asia/Shanghai) rerun was stopped after 0/50 on the first
22
+ task. Open-loop source-path A/B predictions match exactly, but the historical
23
+ closed-loop success rate is not yet reproduced. Do not treat this release
24
+ as validated for benchmark reproduction.
25
+
26
+ The controlled follow-up reproduced one original demonstration using both
27
+ recorded joint actions and recorded EE actions through the real client/IK.
28
+ The model still failed from the same initial simulator state. Precision and
29
+ IK ablations did not recover success; detailed traces and scripts are under
30
+ `provenance/validation/wm4a_followup_20260925T170412Z/`.
31
+
32
+ Further conditioning tests found no disconnected image, language, or state
33
+ input path. Six-step replanning still failed, including one episode with zero
34
+ IK residual misses. Model actions conditioned on the complete recorded
35
+ demonstration also failed over its 228 transitions. No fix was promoted.
36
+ See `provenance/validation/wm4a_conditioning_20260925T175334Z/REPORT.md`.
37
+
38
+ Action-component diagnostics then restored this one demonstration by replacing
39
+ only predicted EE XYZ with recorded targets, but not by replacing only rotations
40
+ or hands. Four non-oracle-action changes (sampling mean, 80 integration steps,
41
+ training state casting, and full training inputs) all failed recorded-input
42
+ replay. The current 24-dataset min/max statistics match the pinned statistics.
43
+ This narrows the investigation, but does not establish the historical regression's
44
+ cause or a deployable fix. See
45
+ `provenance/validation/wm4a_action_components_20260925T184142Z/REPORT.md`.
46
+
47
+ ## What Is Portable
48
+
49
+ This repository includes policy and training source, model/tokenizer metadata,
50
+ the customized historical RoboCasa/RoboSuite source and assets, GR1 retarget
51
+ code and URDF, run-saved configuration/statistics, and provenance hashes.
52
+ Original README is preserved at `provenance/original_paths/README.md`.
53
+ Do not replace the vendored simulator with an arbitrary recent installation.
54
+
55
+ The Mac copy is a source/resource archive. Evaluation requires Linux x86_64,
56
+ NVIDIA CUDA, and EGL rendering. Native macOS/MPS execution is not supported or
57
+ claimed. Policy and simulation run in separate Python 3.10 environments.
58
+
59
+ ## Checkpoint
60
+
61
+ Filename: `checkpoints/steps_280000_pytorch_model.pt`
62
+
63
+ Bytes: 24232783701
64
+
65
+ SHA-256:
66
+ `eeba9505f715b582a054baac1ef5b599f1da225cabcc060631c23f2f47affe6c`
67
+
68
+ This private release includes the selected checkpoint at the path above.
69
+ Its original source and pinned hash are recorded in `release_manifest.json`.
70
+ A source-only Git clone without large-file contents cannot run inference.
71
+
72
+ ## Download
73
+
74
+ Authenticate with an account that has access to this private repository.
75
+ Run the following on the Linux CUDA evaluation machine:
76
+
77
+ ```bash
78
+ python -m pip install huggingface_hub
79
+ hf auth login
80
+ hf download mxk1998/WM4A --local-dir WM4A
81
+ cd WM4A
82
+ python tools/unpack_simulation_assets.py
83
+ ```
84
+
85
+ The 44,901 customized simulator asset files are stored in
86
+ `archives/simulation_assets.tar.gz`, not as individual Hub files. The
87
+ command above verifies the archive and restores every original path with
88
+ per-file SHA256 validation. It uses only the Python standard library,
89
+ refuses modified existing assets, and needs about 9.57 GB of additional
90
+ disk space for extraction. See `ARCHIVES.md` for details.
91
+
92
+ The download also includes model metadata. Keep the
93
+ repository structure intact. Source and asset integrity can be checked with
94
+ `python -m release.verify --assets`; `release.prepare` additionally verifies
95
+ the full checkpoint hash. See `provenance/publication/files.sha256.json` for
96
+ the publication file inventory. The inventory excludes itself.
97
+
98
+ ## Evaluation
99
+
100
+ Run from this repository's root on a Linux CUDA machine:
101
+
102
+ ```bash
103
+ bash environment/create_linux_envs.sh /absolute/new/envs
104
+ export POLICY_PYTHON=/absolute/new/envs/policy/bin/python
105
+ export SIM_PYTHON=/absolute/new/envs/simulation/bin/python
106
+
107
+ "$POLICY_PYTHON" -m release.doctor --role policy
108
+ "$SIM_PYTHON" -m release.doctor --role simulation
109
+ "$POLICY_PYTHON" -m release.verify --assets
110
+ "$POLICY_PYTHON" -m release.prepare \
111
+ --checkpoint checkpoints/steps_280000_pytorch_model.pt
112
+
113
+ # Choose a GPU assigned to you, after inspecting current use.
114
+ "$POLICY_PYTHON" -m release.evaluate \
115
+ --gpus 0 --policy-python "$POLICY_PYTHON" --sim-python "$SIM_PYTHON" \
116
+ --episodes 1 \
117
+ --task gr1_unified/PosttrainPnPNovelFromCuttingboardToPanSplitA_GR1ArmsAndWaistFourierHands_Env
118
+
119
+ # Full historical task/episode counts:
120
+ "$POLICY_PYTHON" -m release.evaluate \
121
+ --gpus 0 --policy-python "$POLICY_PYTHON" --sim-python "$SIM_PYTHON" \
122
+ --episodes 50
123
+ ```
124
+
125
+ The first GPU ID is only an example, not a reservation. Up to two explicitly
126
+ allocated GPUs may be passed as `--gpus 0,1` to distribute tasks. Never run the
127
+ old batch launchers unchanged: they contain machine-specific paths and process
128
+ cleanup behavior that is unsuitable for shared servers.
129
+
130
+ `release.prepare` verifies the checkpoint and reconstructs backbone loading
131
+ files from its complete state dictionary. It does not download a newer base
132
+ model. Allow approximately another checkpoint's size for `.runtime/backbones`
133
+ and ample host RAM (128 GiB recommended for the larger model). The launcher
134
+ requires 42 GiB free per selected GPU, including headroom, and
135
+ caps policy allocations at 34 GiB. The tested hardware is H200;
136
+ smaller-GPU compatibility has not been validated.
137
+
138
+ The launcher binds loopback ports, rejects occupied ports, records GPU/PID
139
+ ownership, and stops only its own process groups. It writes per-task episode
140
+ outcomes, finite-action traces, logs, and aggregate `summary.csv` /
141
+ `summary.json` under `.runtime/evaluations/`.
142
+ `--no-video` skips video encoding but leaves future-image model inference
143
+ unchanged. `EGL_LIBRARY_PATH` can select the host's NVIDIA EGL libraries.
144
+
145
+ The old scripts printed seed 7 without applying it to policy or simulation.
146
+ Default evaluation preserves this unseeded behavior. `--seed N` applies a new
147
+ controlled seed protocol; it is not claimed to be the historical protocol or
148
+ to guarantee deterministic CUDA execution.
149
+
150
+ ## Version Discipline
151
+
152
+ `provenance/source_snapshot.json` records original source hashes and times.
153
+ `provenance/release_sources.sha256.json` seals the relocated evaluation
154
+ snapshot; `release.verify` detects edits. Keep future training experiments in
155
+ a separate working copy instead of updating this release in place.
156
+ Relocation changes and their original versions remain traceable.
157
+
158
+ Environment setup and limitations: `environment/README.md`.
159
+ Recovered training recipes and missing dependencies: `TRAINING_PROVENANCE.md`.
160
+ Third-party notices and publication checks: `THIRD_PARTY_NOTICES.md`.
archives/simulation_assets.manifest.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "simulation-assets-tar-gzip-v1",
3
+ "archive": "archives/simulation_assets.tar.gz",
4
+ "archive_bytes": 4528296178,
5
+ "archive_sha256": "bb84af93bf7fb93afa1068f1532321e473e70bf4dc6e09c8406bff4e8d8f3987",
6
+ "asset_manifest": "provenance/simulation_assets.sha256.json",
7
+ "asset_manifest_sha256": "2a0486de9d46ba92ebb60313ecca831257945b9b746833f7c32a8893f811cdc0",
8
+ "file_count": 44901,
9
+ "expanded_bytes": 9569959833,
10
+ "source": "Unchanged pinned RoboCasa and RoboSuite assets from the original release."
11
+ }
archives/simulation_assets.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb84af93bf7fb93afa1068f1532321e473e70bf4dc6e09c8406bff4e8d8f3987
3
+ size 4528296178
provenance/publication/attributes_merge.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "user_authorized": true,
3
+ "scope": "Review and merge .gitattributes only; all other existing files remain strict.",
4
+ "prepared_utc": "2026-09-26T09:23:53.033590+00:00",
5
+ "repo_id": "mxk1998/WM4A",
6
+ "reviewed_commit": "2484e17a138d034949f2ebc8f333d9a388a18a3f",
7
+ "reviewed_remote": {
8
+ "bytes": 1519,
9
+ "sha256": "11ad7efa24975ee4b0c3c3a38ed18737f0658a5f75a0a96787b576a78a023361",
10
+ "blob_id": "a6344aac8c09253b3b630fb776ae94478aa0275b"
11
+ },
12
+ "packed_before_merge": {
13
+ "sha256": "73f1f7367cc7d53c483ff424f64291928103a6a4f4ffa837f3707f46ad07b92d",
14
+ "blob_id": "b8bb010d46699f84eff0f440423cc1c6ad10dcc4",
15
+ "bytes": 347
16
+ },
17
+ "merged": {
18
+ "bytes": 1919,
19
+ "sha256": "23232aed246e54e1fc2d477b24d531af330f42cfd12f2cae9638e02ab853f6b2",
20
+ "blob_id": "b91cf457327c8ccc27f7a182e9efd704787208d3"
21
+ },
22
+ "preserved_remote_lines": 35,
23
+ "added_release_rules": [
24
+ "*.stl filter=lfs diff=lfs merge=lfs -text",
25
+ "*.png filter=lfs diff=lfs merge=lfs -text",
26
+ "*.jpg filter=lfs diff=lfs merge=lfs -text",
27
+ "*.jpeg filter=lfs diff=lfs merge=lfs -text",
28
+ "*.tar.gz filter=lfs diff=lfs merge=lfs -text"
29
+ ],
30
+ "added_exact_lfs_rules": [
31
+ "/model_metadata/cosmos/tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text"
32
+ ],
33
+ "classified_files": 4215,
34
+ "classified_lfs_files": 643,
35
+ "effective_lfs_rules_verified_with_git": true
36
+ }
provenance/publication/files.sha256.json ADDED
The diff for this file is too large to render. See raw diff
 
provenance/publication/preparation.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "prepared_utc": "2026-09-26T03:27:07.557Z",
3
+ "repository": "mxk1998/WM4A",
4
+ "privacy_required": "private",
5
+ "owner_authorized_mac_relay": true,
6
+ "selected_checkpoint": "checkpoints/steps_280000_pytorch_model.pt",
7
+ "original_document_sha256": {
8
+ "README.md": "0d75907b0685172f282ae4ddbaf23e5589c7f7685f0ec4a8d26095628c81c285",
9
+ "VALIDATION.md": "15dc0644dc78b21c344aa12e8cfe8f6ce6593a3b2d3f2a5c8ae598243d8bb28e",
10
+ "release_manifest.json": "93fb88a2814ecc79f99ced7545c2dc9d813a73e92f1a69759aaa4a4b3c8df5e8",
11
+ "checkpoints/README.md": "406ad9b2f4ebc998be97c33e2ac202d5b01d55884ee20499abc03026f8b03068",
12
+ "THIRD_PARTY_NOTICES.md": "24d6bf63e7b01f5ba8e607a4c278c6476f9d9ec6500f03efa548bbb61675e5b8",
13
+ ".gitignore": "cbbdbe39f210d0c5bd87218062e7c0651e1d3ab485956fd381e5c02bb287f48f"
14
+ },
15
+ "code_changes": "None. Sealed runtime, training, and simulator sources are unchanged.",
16
+ "diagnostics": "Preserved. Failed WM4A reproduction and oracle limitations remain explicit.",
17
+ "data_path": "perdon-hou -> task-scoped SSH reverse forwarding -> Mac HTTPS CONNECT -> Hugging Face",
18
+ "asset_packaging": {
19
+ "reason": "Hub rejected the expanded tree at its 20000-file hard limit.",
20
+ "packed_utc": "2026-09-26T09:07:26.386485+00:00",
21
+ "archive_sha256": "bb84af93bf7fb93afa1068f1532321e473e70bf4dc6e09c8406bff4e8d8f3987",
22
+ "expanded_files": 44901,
23
+ "roundtrip_verified": true,
24
+ "sealed_runtime_source_changes": false
25
+ }
26
+ }
provenance/simulation_assets.sha256.json ADDED
The diff for this file is too large to render. See raw diff
 
release_manifest.json ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "project": "WM4A",
3
+ "model": "cosmopredict25_vjepa_ImageLatent/robocasa_06-28-13-10",
4
+ "checkpoint_step": 280000,
5
+ "checkpoint_bytes": 24232783701,
6
+ "checkpoint_keys": 2596,
7
+ "checkpoint_sha256": "eeba9505f715b582a054baac1ef5b599f1da225cabcc060631c23f2f47affe6c",
8
+ "historical_success_rate": 0.5616666666666666,
9
+ "inference_steps": 5,
10
+ "max_policy_vram_gib": 34,
11
+ "metadata_labels": [
12
+ "cosmos"
13
+ ],
14
+ "backbone_aliases": {
15
+ "Cosmos-Predict2.5-2B-Post-Trained": "cosmos"
16
+ },
17
+ "components": [
18
+ {
19
+ "prefix": "backbone.text_encoder.",
20
+ "output": "backbones/cosmos/text_encoder/pytorch_model.bin"
21
+ },
22
+ {
23
+ "prefix": "backbone.transformer.",
24
+ "output": "backbones/cosmos/transformer/diffusion_pytorch_model.bin"
25
+ },
26
+ {
27
+ "prefix": "backbone.vae.",
28
+ "output": "backbones/cosmos/vae/diffusion_pytorch_model.bin"
29
+ },
30
+ {
31
+ "prefixes": {
32
+ "encoder": "vjepa_encoder.",
33
+ "predictor": "vjepa_predictor."
34
+ },
35
+ "output": "backbones/vjepa2-ac.pt"
36
+ }
37
+ ],
38
+ "config_paths": {
39
+ "framework.qwenvl.base_vlm": "backbones/Cosmos-Predict2.5-2B-Post-Trained",
40
+ "framework.world_model.base_wm": "backbones/Cosmos-Predict2.5-2B-Post-Trained",
41
+ "framework.vjepa2_ac.repo_dir": "starVLA/facebookresearch_vjepa2_main",
42
+ "framework.vjepa2_ac.pretrained": "backbones/vjepa2-ac.pt"
43
+ },
44
+ "reference": "wm_eval_20260703_054735",
45
+ "tasks": [
46
+ "gr1_unified/PnPCupToDrawerClose_GR1ArmsAndWaistFourierHands_Env",
47
+ "gr1_unified/PnPPotatoToMicrowaveClose_GR1ArmsAndWaistFourierHands_Env",
48
+ "gr1_unified/PnPMilkToMicrowaveClose_GR1ArmsAndWaistFourierHands_Env",
49
+ "gr1_unified/PnPBottleToCabinetClose_GR1ArmsAndWaistFourierHands_Env",
50
+ "gr1_unified/PnPWineToCabinetClose_GR1ArmsAndWaistFourierHands_Env",
51
+ "gr1_unified/PnPCanToDrawerClose_GR1ArmsAndWaistFourierHands_Env",
52
+ "gr1_unified/PosttrainPnPNovelFromCuttingboardToBasketSplitA_GR1ArmsAndWaistFourierHands_Env",
53
+ "gr1_unified/PosttrainPnPNovelFromCuttingboardToCardboardboxSplitA_GR1ArmsAndWaistFourierHands_Env",
54
+ "gr1_unified/PosttrainPnPNovelFromCuttingboardToPanSplitA_GR1ArmsAndWaistFourierHands_Env",
55
+ "gr1_unified/PosttrainPnPNovelFromCuttingboardToPotSplitA_GR1ArmsAndWaistFourierHands_Env",
56
+ "gr1_unified/PosttrainPnPNovelFromCuttingboardToTieredbasketSplitA_GR1ArmsAndWaistFourierHands_Env",
57
+ "gr1_unified/PosttrainPnPNovelFromPlacematToBasketSplitA_GR1ArmsAndWaistFourierHands_Env",
58
+ "gr1_unified/PosttrainPnPNovelFromPlacematToBowlSplitA_GR1ArmsAndWaistFourierHands_Env",
59
+ "gr1_unified/PosttrainPnPNovelFromPlacematToPlateSplitA_GR1ArmsAndWaistFourierHands_Env",
60
+ "gr1_unified/PosttrainPnPNovelFromPlacematToTieredshelfSplitA_GR1ArmsAndWaistFourierHands_Env",
61
+ "gr1_unified/PosttrainPnPNovelFromPlateToBowlSplitA_GR1ArmsAndWaistFourierHands_Env",
62
+ "gr1_unified/PosttrainPnPNovelFromPlateToCardboardboxSplitA_GR1ArmsAndWaistFourierHands_Env",
63
+ "gr1_unified/PosttrainPnPNovelFromPlateToPanSplitA_GR1ArmsAndWaistFourierHands_Env",
64
+ "gr1_unified/PosttrainPnPNovelFromPlateToPlateSplitA_GR1ArmsAndWaistFourierHands_Env",
65
+ "gr1_unified/PosttrainPnPNovelFromTrayToCardboardboxSplitA_GR1ArmsAndWaistFourierHands_Env",
66
+ "gr1_unified/PosttrainPnPNovelFromTrayToPlateSplitA_GR1ArmsAndWaistFourierHands_Env",
67
+ "gr1_unified/PosttrainPnPNovelFromTrayToPotSplitA_GR1ArmsAndWaistFourierHands_Env",
68
+ "gr1_unified/PosttrainPnPNovelFromTrayToTieredbasketSplitA_GR1ArmsAndWaistFourierHands_Env",
69
+ "gr1_unified/PosttrainPnPNovelFromTrayToTieredshelfSplitA_GR1ArmsAndWaistFourierHands_Env"
70
+ ],
71
+ "source_host": "nb-dn22t489hz-0",
72
+ "checkpoint_source": "/mnt/workspace/users/maxiangkai/projects/WM4A/outputs/cosmopredict25_vjepa_ImageLatent/robocasa_06-28-13-10/checkpoints/steps_280000_pytorch_model.pt",
73
+ "historical_protocol": {
74
+ "tasks": 24,
75
+ "episodes_per_task": 50,
76
+ "n_envs": 1,
77
+ "max_episode_steps": 720,
78
+ "n_action_steps": 12,
79
+ "shift": 5,
80
+ "printed_seed": 7,
81
+ "applied_seed": null
82
+ },
83
+ "validation_status": "historical_effectiveness_not_reproduced; full_benchmark_stopped",
84
+ "publication_status": "prepared_for_private_huggingface_publication",
85
+ "huggingface_repository": "mxk1998/WM4A",
86
+ "checkpoint_path": "checkpoints/steps_280000_pytorch_model.pt",
87
+ "clean_install_validated": false,
88
+ "asset_packaging": {
89
+ "format": "simulation-assets-tar-gzip-v1",
90
+ "manifest": "archives/simulation_assets.manifest.json",
91
+ "extract_command": "python tools/unpack_simulation_assets.py"
92
+ }
93
+ }
tools/unpack_simulation_assets.py ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Restore the pinned simulator assets without importing the model environment."""
2
+
3
+ import argparse
4
+ import hashlib
5
+ import json
6
+ import os
7
+ import re
8
+ import tarfile
9
+ import tempfile
10
+ from pathlib import Path
11
+
12
+
13
+ PREFIXES = (
14
+ "third_party/robocasa/robocasa/models/assets/",
15
+ "third_party/robosuite/robosuite/models/assets/",
16
+ )
17
+
18
+
19
+ def digest(path):
20
+ value = hashlib.sha256()
21
+ with path.open("rb") as stream:
22
+ for block in iter(lambda: stream.read(8 * 1024 * 1024), b""):
23
+ value.update(block)
24
+ return value.hexdigest()
25
+
26
+
27
+ def safe_name(name):
28
+ if not isinstance(name, str) or not name.startswith(PREFIXES):
29
+ raise ValueError(f"Unexpected asset path: {name!r}")
30
+ if any(part in ("", ".", "..") for part in name.split("/")) or "\\" in name:
31
+ raise ValueError(f"Unsafe asset path: {name!r}")
32
+ return name
33
+
34
+
35
+ def destination(root, name, create=False):
36
+ target = root / safe_name(name)
37
+ current = root
38
+ for component in Path(name).parts[:-1]:
39
+ current = current / component
40
+ if current.is_symlink():
41
+ raise ValueError(f"Refusing symlink directory: {current}")
42
+ if create:
43
+ current.mkdir(exist_ok=True)
44
+ if current.exists() and not current.is_dir():
45
+ raise ValueError(f"Asset parent is not a directory: {current}")
46
+ if target.is_symlink():
47
+ raise ValueError(f"Refusing symlink destination: {target}")
48
+ return target
49
+
50
+
51
+ def unpack(root, verify_only=False):
52
+ root = root.resolve(strict=True)
53
+ metadata = json.loads((root / "archives/simulation_assets.manifest.json").read_text())
54
+ if metadata["format"] != "simulation-assets-tar-gzip-v1":
55
+ raise ValueError("Unsupported archive format")
56
+ if metadata["archive"] != "archives/simulation_assets.tar.gz":
57
+ raise ValueError("Unexpected archive filename")
58
+ if metadata["asset_manifest"] != "provenance/simulation_assets.sha256.json":
59
+ raise ValueError("Unexpected asset manifest")
60
+ manifest_path = root / metadata["asset_manifest"]
61
+ if digest(manifest_path) != metadata["asset_manifest_sha256"]:
62
+ raise ValueError("Asset manifest SHA256 mismatch")
63
+ assets = json.loads(manifest_path.read_text())
64
+ if len(assets) != metadata["file_count"]:
65
+ raise ValueError("Asset file count mismatch")
66
+ for name, expected in assets.items():
67
+ safe_name(name)
68
+ if not re.fullmatch(r"[a-f0-9]{64}", expected):
69
+ raise ValueError(f"Invalid asset hash: {name}")
70
+
71
+ existing = 0
72
+ for name, expected in assets.items():
73
+ target = destination(root, name)
74
+ if target.exists():
75
+ if not target.is_file() or digest(target) != expected:
76
+ raise ValueError(f"Existing asset was modified; not overwritten: {name}")
77
+ existing += 1
78
+ elif verify_only:
79
+ raise ValueError(f"Missing asset: {name}")
80
+ if verify_only:
81
+ return {"verified_assets": existing, "mode": "verify-only"}
82
+
83
+ archive = root / metadata["archive"]
84
+ if archive.stat().st_size != metadata["archive_bytes"]:
85
+ raise ValueError("Archive size mismatch")
86
+ if digest(archive) != metadata["archive_sha256"]:
87
+ raise ValueError("Archive SHA256 mismatch; no assets extracted")
88
+ print(json.dumps({"event": "archive_verified", "existing_assets": existing}), flush=True)
89
+ seen = set()
90
+ total_bytes = 0
91
+ written = 0
92
+ # Never use extractall: every member and output path is checked explicitly.
93
+ with tarfile.open(archive, mode="r|gz") as bundle:
94
+ for member in bundle:
95
+ name = safe_name(member.name)
96
+ if name not in assets or name in seen:
97
+ raise ValueError(f"Unexpected or duplicate archive member: {name}")
98
+ if not member.isfile() or member.sparse is not None or member.size < 0:
99
+ raise ValueError(f"Only ordinary files are permitted: {name}")
100
+ seen.add(name)
101
+ total_bytes += member.size
102
+ if total_bytes > metadata["expanded_bytes"]:
103
+ raise ValueError("Archive exceeds declared expanded size")
104
+ target = destination(root, name, create=True)
105
+ if target.exists():
106
+ if not target.is_file() or digest(target) != assets[name]:
107
+ raise ValueError(f"Existing asset changed; not overwritten: {name}")
108
+ continue
109
+ temporary = None
110
+ try:
111
+ with tempfile.NamedTemporaryFile(
112
+ prefix=".asset-unpack-", dir=target.parent, delete=False
113
+ ) as stream:
114
+ temporary = Path(stream.name)
115
+ value = hashlib.sha256()
116
+ extracted = bundle.extractfile(member)
117
+ count = 0
118
+ for block in iter(lambda: extracted.read(8 * 1024 * 1024), b""):
119
+ stream.write(block)
120
+ value.update(block)
121
+ count += len(block)
122
+ if count != member.size or value.hexdigest() != assets[name]:
123
+ raise ValueError(f"Extracted content SHA256 mismatch: {name}")
124
+ os.chmod(temporary, 0o644)
125
+ # link() is atomic and refuses to overwrite an existing target.
126
+ os.link(temporary, target)
127
+ written += 1
128
+ finally:
129
+ if temporary is not None:
130
+ temporary.unlink(missing_ok=True)
131
+ if len(seen) % 5000 == 0:
132
+ print(json.dumps({"event": "extracting", "files": len(seen)}), flush=True)
133
+ if seen != set(assets) or total_bytes != metadata["expanded_bytes"]:
134
+ raise ValueError("Archive does not contain the complete pinned asset set")
135
+ return {
136
+ "verified_assets": len(seen),
137
+ "written_assets": written,
138
+ "previously_present": existing,
139
+ "expanded_bytes": total_bytes,
140
+ "archive_sha256": metadata["archive_sha256"],
141
+ }
142
+
143
+
144
+ def main():
145
+ parser = argparse.ArgumentParser(description=__doc__)
146
+ parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1])
147
+ parser.add_argument("--verify-only", action="store_true")
148
+ args = parser.parse_args()
149
+ print(json.dumps(unpack(args.root, args.verify_only)), flush=True)
150
+
151
+
152
+ if __name__ == "__main__":
153
+ main()