File size: 21,302 Bytes
18d177a
8387095
18d177a
8387095
 
 
bfada93
18d177a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7fd79c
 
 
 
 
18d177a
 
62d3aad
 
18d177a
 
 
 
 
 
62d3aad
18d177a
9b52e4d
62d3aad
18d177a
 
 
 
7eaf431
 
ae797fc
7eaf431
fcab0d2
 
 
 
 
7eaf431
ec1d592
 
bfada93
ec1d592
ae797fc
 
 
 
 
4148050
c51a5c8
8faf8f4
6cd6d32
5dabf7e
9b52e4d
e00f033
 
 
21651a6
525ff13
ae797fc
 
 
 
 
 
e00f033
 
 
6cd6d32
e00f033
9b52e4d
e00f033
 
 
21651a6
b37ba59
ae797fc
 
 
 
 
 
e00f033
 
 
6cd6d32
 
9b52e4d
e00f033
 
70f3c9c
 
e00f033
ae797fc
 
 
 
 
 
4148050
c51a5c8
8faf8f4
6cd6d32
5dabf7e
9b52e4d
e00f033
 
 
21651a6
525ff13
ae797fc
 
 
 
 
 
e00f033
 
 
6cd6d32
e00f033
9b52e4d
e00f033
 
 
21651a6
b37ba59
ae797fc
 
 
18d177a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7fd79c
 
 
 
 
 
 
 
ec1d592
18d177a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7fd79c
18d177a
e00f033
 
 
 
 
 
18d177a
 
 
 
 
 
 
 
 
 
ec1d592
 
 
 
 
 
 
7eaf431
3655dcd
 
7eaf431
 
 
 
 
 
18d177a
 
ec1d592
18d177a
 
 
 
 
 
 
 
 
 
 
62d3aad
 
 
9f99450
ffc3786
8faf8f4
6cd6d32
44183f3
5dabf7e
916f6e2
96002ad
00b6e59
1d01c68
c51a5c8
21651a6
65b018d
b09fa54
93c739c
b4d66a1
efbbd05
4148050
da16b03
18d177a
 
62d3aad
9b52e4d
62d3aad
9b52e4d
18d177a
e301300
62d3aad
9b52e4d
62d3aad
9b52e4d
18d177a
c51a5c8
b4d66a1
ffc3786
efbbd05
7be1bf2
db1d246
96002ad
62d3aad
8faf8f4
6cd6d32
8faf8f4
44183f3
e301300
5dabf7e
4148050
da16b03
4fce39c
a42afee
00b6e59
1d01c68
318c07e
9a61006
b09fa54
 
c3a9a07
18d177a
21651a6
d286817
40a0560
 
 
45deef7
65b018d
916f6e2
93c739c
4fce39c
 
 
 
 
 
 
9b52e4d
 
 
 
 
 
 
18d177a
fdefd7f
d286817
40a0560
 
cfccffe
 
 
8058007
 
e1f25e3
566adf7
 
 
18d177a
 
 
 
 
102e9bb
385a2c7
18d177a
 
7be1bf2
9b52e4d
c51a5c8
21651a6
d286817
45deef7
65b018d
b4d66a1
96002ad
00b6e59
1d01c68
e301300
7998349
a340c71
a42afee
318c07e
efbbd05
9a61006
c3a9a07
d3ee220
93c739c
916f6e2
c4cc86f
1b2531c
 
 
5618ed1
1b2531c
 
5618ed1
1b2531c
5618ed1
1b2531c
18d177a
916f6e2
 
18d177a
 
 
 
ae797fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18d177a
 
 
 
 
 
 
ec1d592
 
 
 
 
 
18d177a
 
 
ec1d592
18d177a
ae797fc
18d177a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ec1d592
 
 
 
 
7eaf431
 
 
 
 
ae797fc
 
 
 
 
18d177a
 
 
 
 
 
 
ae797fc
18d177a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
#!/usr/bin/env python3
"""Validate public package contents for the repo and HF bundles.

This check scans the GitHub repo plus the prepared Hugging Face
Space/artifact/model folders for generated Python caches, raw Xperience-10M
data, heavyweight checkpoint formats that do not belong in this public package,
and accidental credential text.
"""

from __future__ import annotations

import argparse
import json
import re
import subprocess
import sys
from datetime import datetime, timezone
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
DEFAULT_HF_ROOT = ROOT.parent / "hf_publish"

BANNED_DIR_NAMES = {"__pycache__"}
BANNED_FILE_NAMES = {".DS_Store"}
BANNED_SUFFIXES = {".pyc", ".pyo"}
RAW_DATA_SUFFIXES = {".mp4", ".hdf5", ".h5", ".rrd"}
ALLOWED_PREVIEW_VIDEO_PREFIXES = (
    "docs/assets/raw-sample-preview/",
    "assets/raw-sample-preview/",
)
MAX_PREVIEW_VIDEO_BYTES = 5 * 1024 * 1024
HEAVY_MODEL_SUFFIXES = {".safetensors", ".bin", ".tar"}
TEXT_SUFFIXES = {
    "",
    ".cff",
    ".csv",
    ".html",
    ".json",
    ".md",
    ".py",
    ".sh",
    ".svg",
    ".txt",
    ".webmanifest",
    ".xml",
    ".yaml",
    ".yml",
}
TOKEN_PATTERN = re.compile(r"hf_[A-Za-z0-9]{20,}")
STALE_PRESENTATION_STRINGS = {
    "xperience10m-" + "modalities-v9-large-atlas": "old task-suite infographic cache key",
    "xperience10m-" + "taskfirst-v10": "older task-suite infographic cache key",
    "Start with the large native " + "modality atlas": "old suite-section hierarchy copy",
    "ChatGPT" + "-image": "internal image-generation tool wording in public copy",
    "H" + "20": "private compute infrastructure wording in public copy",
    "A" + "100": "private compute infrastructure wording in public copy",
    "Cur" + "sor": "editor/work-session wording in public copy",
    "public " + "dashboard and generated figures " + "deliberately " + "follow": "meta design-process wording in public copy",
}
LOCAL_PATH_PATTERNS = {
    "/" + "Users/": "local macOS user path in public text",
    "/" + "private/": "temporary local path in public text",
}
CARD_FRESHNESS_EXPECTATIONS = [
    {
        "surface": "github_repo",
        "relative_path": "README.md",
        "required": [
            "XPERIENCE10M_DATASET_CARD_ALIGNMENT.md",
            "EVALUATION_PROTOCOL.md",
            "PROJECT_STATUS.md",
            "PUBLIC_READER_MAP.md",
            "RESEARCH_TAKEAWAYS.md",
            "xperience10m-logo-social-card.png",
            "Dataset Context",
            "Qwen3-Omni",
            "Cosmos 3",
            "20 human-readable tasks",
            "interactive scrub/play walkthrough storyboard",
        ],
    },
    {
        "surface": "hf_space_bundle",
        "relative_path": "README.md",
        "required": [
            "XPERIENCE10M_DATASET_CARD_ALIGNMENT.md",
            "EVALUATION_PROTOCOL.md",
            "PROJECT_STATUS.md",
            "PUBLIC_READER_MAP.md",
            "RESEARCH_TAKEAWAYS.md",
            "xperience10m-logo-social-card.png",
            "Dataset Context",
            "Qwen3-Omni",
            "Cosmos 3",
            "20 human-readable tasks",
            "interactive scrub/play walkthrough storyboard",
        ],
    },
    {
        "surface": "hf_artifact_bundle",
        "relative_path": "README.md",
        "required": [
            "What To Open First",
            "Dataset Boundary",
            "Related Hub Repositories",
            "PUBLIC_READER_MAP.md",
            "docs/data/public_reader_map.json",
            "xperience10m-logo-social-card.png",
            "derived artifacts",
            "Raw Xperience-10M videos",
            "selected_128_windows",
            "viewer/selected128_windows.parquet",
            "Qwen3-Omni",
        ],
    },
    {
        "surface": "hf_artifact_bundle",
        "relative_path": "PROJECT_README.md",
        "required": [
            "XPERIENCE10M_DATASET_CARD_ALIGNMENT.md",
            "EVALUATION_PROTOCOL.md",
            "PROJECT_STATUS.md",
            "PUBLIC_READER_MAP.md",
            "RESEARCH_TAKEAWAYS.md",
            "xperience10m-logo-social-card.png",
            "Dataset Context",
            "Qwen3-Omni",
            "Cosmos 3",
            "20 human-readable tasks",
            "interactive scrub/play walkthrough storyboard",
        ],
    },
    {
        "surface": "hf_model_bundle",
        "relative_path": "README.md",
        "required": [
            "XPERIENCE10M_DATASET_CARD_ALIGNMENT.md",
            "EVALUATION_PROTOCOL.md",
            "PROJECT_STATUS.md",
            "PUBLIC_READER_MAP.md",
            "RESEARCH_TAKEAWAYS.md",
            "xperience10m-logo-social-card.png",
            "Dataset Context",
            "Qwen3-Omni",
            "Cosmos 3",
            "20 human-readable tasks",
            "interactive scrub/play walkthrough storyboard",
        ],
    },
]


def rel(path: Path, base: Path) -> str:
    try:
        return path.relative_to(base).as_posix()
    except ValueError:
        return path.as_posix()


def git_public_paths(root: Path) -> list[Path] | None:
    try:
        result = subprocess.run(
            ["git", "-C", str(root), "ls-files", "--cached", "--others", "--exclude-standard"],
            check=True,
            stdout=subprocess.PIPE,
            stderr=subprocess.DEVNULL,
            text=True,
        )
    except (OSError, subprocess.CalledProcessError):
        return None
    return [root / line for line in result.stdout.splitlines() if line.strip()]


def iter_public_files(root: Path, paths: list[Path] | None = None):
    if paths is not None:
        for path in paths:
            if path.exists():
                yield path
        return
    if not root.exists():
        return
    for path in root.rglob("*"):
        parts = set(path.parts)
        if ".git" in parts or ".venv" in parts or "venv" in parts:
            continue
        yield path


def is_allowed_preview_video(path_rel: str, size: int) -> bool:
    return (
        path_rel.endswith("_preview.mp4")
        and any(path_rel.startswith(prefix) for prefix in ALLOWED_PREVIEW_VIDEO_PREFIXES)
        and size <= MAX_PREVIEW_VIDEO_BYTES
    )


def scan(root: Path, *, paths: list[Path] | None = None, display_root: str | None = None) -> dict:
    violations: list[dict] = []
    text_files = 0
    total_files = 0
    largest_file = {"path": None, "bytes": 0}

    for path in iter_public_files(root, paths):
        path_rel = rel(path, root)
        if path.is_dir():
            if path.name in BANNED_DIR_NAMES:
                violations.append({"kind": "generated_cache_dir", "path": path_rel})
            continue

        total_files += 1
        size = path.stat().st_size
        if size > largest_file["bytes"]:
            largest_file = {"path": path_rel, "bytes": size}

        suffix = path.suffix.lower()
        if path.name in BANNED_FILE_NAMES or suffix in BANNED_SUFFIXES:
            violations.append({"kind": "generated_cache_file", "path": path_rel})
        if suffix in RAW_DATA_SUFFIXES and not is_allowed_preview_video(path_rel, size):
            violations.append({"kind": "raw_xperience10m_data", "path": path_rel})
        allowed_model_weight = (
            display_root == "hf_publish/model"
            and path_rel == "pytorch_model.bin"
            and size < 150 * 1024 * 1024
        )
        if suffix in HEAVY_MODEL_SUFFIXES and not allowed_model_weight:
            violations.append({"kind": "heavy_model_or_archive", "path": path_rel})

        if suffix in TEXT_SUFFIXES:
            text_files += 1
            try:
                text = path.read_text(encoding="utf-8", errors="ignore")
            except OSError:
                continue
            if TOKEN_PATTERN.search(text):
                violations.append({"kind": "possible_hf_token", "path": path_rel})
            for needle, reason in LOCAL_PATH_PATTERNS.items():
                if needle in text:
                    violations.append({
                        "kind": "local_filesystem_path",
                        "path": path_rel,
                        "detail": reason,
                    })
            for needle, reason in STALE_PRESENTATION_STRINGS.items():
                if path_rel == ".mailmap":
                    continue
                if needle in text:
                    violations.append({
                        "kind": "stale_presentation_copy",
                        "path": path_rel,
                        "detail": reason,
                    })

    return {
        "root": display_root or rel(root, ROOT.parent),
        "exists": root.exists(),
        "file_count": total_files,
        "text_file_count": text_files,
        "largest_file": largest_file,
        "violations": violations,
    }


def required_assets(root: Path) -> dict[str, bool]:
    required = [
        "README.md",
        "CITATION.cff",
        "LICENSE",
        "codemeta.json",
        "ARTIFACT_GUIDE.md",
        "GLOSSARY.md",
        "PROJECT_STATUS.md",
        "PUBLIC_READER_MAP.md",
        "RESEARCH_ROADMAP.md",
        "RESEARCH_TAKEAWAYS.md",
        "TASK_SUITE_ENHANCEMENT_128.md",
        "QUALITY_GATES.md",
        "PUBLIC_SURFACE_QA.md",
        "RENDERED_SITE_CHECK.md",
        "EVALUATION_PROTOCOL.md",
        "TASK_SUITE_20.md",
        "TASK_METHOD_20_SOURCE_AUDIT.md",
        "TWO_EVIDENCE_LINE_RESULT_SUMMARY.md",
        "XPERIENCE10M_128_EPISODE_FEATURE_INDEX.md",
        "FIGURE_INDEX.md",
        "SOURCE_ALIGNMENT_AUDIT.md",
        "XPERIENCE10M_DATASET_CARD_ALIGNMENT.md",
        "REPRODUCIBILITY.md",
        "EVIDENCE_CONTRACT.md",
        "DATA_NOTICE.md",
        "docs/404.html",
        "docs/apple-touch-icon.png",
        "docs/favicon.svg",
        "docs/favicon.png",
        "docs/index.html",
        "docs/research_roadmap.html",
        "docs/robots.txt",
        "docs/site.webmanifest",
        "docs/sitemap.xml",
        "docs/data/brand_assets.json",
        "docs/data/evidence_contract.json",
        "docs/data/evaluation_protocol.json",
        "docs/data/figure_index.json",
        "docs/data/glossary.json",
        "docs/data/source_alignment_audit.json",
        "docs/data/artifact_index.json",
        "docs/data/live_publication_status.json",
        "docs/data/quality_gates.json",
        "docs/data/project_manifest.json",
        "docs/data/project_packet.json",
        "docs/data/public_reader_map.json",
        "docs/data/project_status.json",
        "docs/data/research_roadmap.json",
        "docs/data/research_roadmap_interactive.json",
        "docs/data/research_takeaways.json",
        "docs/data/xperience10m_dataset_card_alignment.json",
        "docs/data/reproducibility_matrix.json",
        "docs/data/modality_atlas.json",
        "docs/data/mirror_parity.json",
        "docs/data/public_surface_qa.json",
        "docs/data/rendered_site_check.json",
        "docs/data/scope_claims_audit.json",
        "docs/data/task_surface_integrity.json",
        "docs/data/two_evidence_lines.json",
        "docs/data/two_evidence_line_result_summary.json",
        "docs/data/website_integrity.json",
        "docs/data/summary_metrics.json",
        "docs/data/task_suite_20.json",
        "docs/data/unified_task_model_radar.json",
        "docs/data/single_episode_task_model_radar.json",
        "docs/data/episode128_task_model_radar.json",
        "docs/data/task_method_20_result_matrix.json",
        "docs/data/task_method_20_gap_audit.json",
        "docs/data/task_method_20_source_audit.json",
        "docs/data/task_suite_enhancement_128.json",
        "docs/data/xperience10m_128_episode_feature_index.json",
        "docs/assets/modalities/video.jpg",
        "docs/assets/modalities/audio.png",
        "docs/assets/modalities/depth.jpg",
        "docs/assets/modalities/pose_slam.png",
        "docs/assets/modalities/motion_capture.png",
        "docs/assets/modalities/inertial.png",
        "docs/assets/modalities/language.png",
        "docs/assets/brand/xperience10m-logo-apple-touch.png",
        "docs/assets/brand/xperience10m-logo-favicon-32.png",
        "docs/assets/brand/xperience10m-logo-favicon-64.png",
        "docs/assets/brand/xperience10m-logo-mark.png",
        "docs/assets/brand/xperience10m-logo-mark-192.png",
        "docs/assets/brand/xperience10m-logo-mark-512.png",
        "docs/assets/brand/xperience10m-logo-social-card.png",
        "docs/assets/task_suite_infographic.png",
        "docs/assets/charts/two_evidence_line_map.svg",
        "docs/assets/charts/unified_task_model_radar.svg",
        "docs/assets/charts/single_episode_task_model_radar.svg",
        "docs/assets/charts/episode128_task_model_radar.svg",
        "docs/assets/foundation-pipelines/spatial-intelligence-pipeline.png",
        "docs/assets/foundation-pipelines/human-video-world-model-pipeline.png",
        "docs/assets/foundation-pipelines/vision-language-action-pipeline.png",
        "docs/assets/foundation-pipelines/source-slides/spatial-intelligence-slide.png",
        "docs/assets/foundation-pipelines/source-slides/human-video-world-model-slide.png",
        "docs/assets/foundation-pipelines/source-slides/vision-language-action-slide.png",
        "docs/assets/foundation-pipelines/source-photos/spatial-intelligence-source.jpg",
        "docs/assets/foundation-pipelines/source-photos/human-video-world-model-source.jpg",
        "docs/assets/foundation-pipelines/source-photos/vision-language-action-source.jpg",
        "docs/assets/pipeline_diagram.png",
        "docs/assets/task_architectures.png",
        "results/episode_task_suite/summary_report.json",
        "results/episode_task_suite/feature_manifest.json",
        "results/episode_task_suite/neural_mlp/timeline_action/metrics.json",
        "results/omni_finetune/DATA_ACCESS_STATUS.md",
        "results/omni_finetune/MULTI_EPISODE_ACCESS_STATUS.md",
        "scripts/episode_task_suite.py",
        "scripts/neural_task_models.py",
        "scripts/build_artifact_index.py",
        "scripts/build_brand_assets.py",
        "scripts/build_evaluation_protocol.py",
        "scripts/build_unified_task_suite.py",
        "scripts/build_unified_task_model_radar.py",
        "scripts/build_task_method_20_gap_audit.py",
        "scripts/validate_task_method_matrix_sources.py",
        "scripts/build_figure_index.py",
        "scripts/build_quality_gates.py",
        "scripts/build_public_surface_qa.py",
        "scripts/build_rendered_site_check.py",
        "scripts/build_interactive_research_roadmap.py",
        "scripts/render_foundation_pipeline_diagrams.py",
        "scripts/verify_live_publication.py",
        "scripts/validate_mirror_parity.py",
        "scripts/validate_scope_claims.py",
        "scripts/validate_source_alignment.py",
        "scripts/validate_task_surface.py",
        "scripts/validate_website_integrity.py",
        "scripts/publish_hf_bundles.py",
        "scripts/omni/build_128_episode_feature_index.py",
        "scripts/omni/build_task_suite_enhancement_128.py",
        "scripts/omni/collect_qwen3_retrieval_task_probe_results.sh",
        "scripts/omni/collect_cosmos3_super_retrieval_task_probe_results.sh",
        "scripts/omni/collect_cosmos3_super_future_task_probe_results.sh",
        "scripts/omni/eval_cosmos3_super_future_task_probes.py",
        "scripts/omni/eval_cosmos3_super_interaction_text_task.py",
        "scripts/omni/eval_cosmos3_super_retrieval_task_probes.py",
        "scripts/omni/merge_cosmos3_super_future_task_probe_shards.py",
        "scripts/omni/merge_cosmos3_super_interaction_text_task_shards.py",
        "scripts/omni/run_cosmos3_super_future_task_probes_sharded.sh",
        "scripts/omni/run_cosmos3_super_interaction_text_task_sharded.sh",
        "scripts/omni/run_cosmos3_super_retrieval_task_probes_sharded.sh",
        "scripts/omni/train_qwen3_omni_lora.py",
        "results/omni_finetune/task_suite_enhancement_128_v1_20260608/enhancement_plan.json",
        "results/omni_finetune/task_suite_enhancement_128_v1_20260608/ENHANCEMENT_REPORT.md",
    ]
    return {item: (root / item).exists() for item in required}


def public_card_freshness(roots: dict[str, Path]) -> list[dict]:
    records = []
    for item in CARD_FRESHNESS_EXPECTATIONS:
        surface = item["surface"]
        path = roots[surface] / item["relative_path"]
        text = path.read_text(encoding="utf-8", errors="ignore") if path.exists() else ""
        missing = [marker for marker in item["required"] if marker not in text]
        records.append({
            "surface": surface,
            "path": item["relative_path"],
            "exists": path.exists(),
            "required_marker_count": len(item["required"]),
            "missing_markers": missing,
            "status": "pass" if path.exists() and not missing else "fail",
        })
    return records


def build_report(hf_root: Path) -> dict:
    roots = {
        "github_repo": ROOT,
        "hf_space_bundle": hf_root / "space",
        "hf_artifact_bundle": hf_root / "artifacts",
        "hf_model_bundle": hf_root / "model",
    }
    root_labels = {
        "github_repo": "repo",
        "hf_space_bundle": "hf_publish/space",
        "hf_artifact_bundle": "hf_publish/artifacts",
        "hf_model_bundle": "hf_publish/model",
    }
    scans = {}
    for name, path in roots.items():
        public_paths = git_public_paths(path) if name == "github_repo" else None
        scans[name] = scan(path, paths=public_paths, display_root=root_labels[name])
    assets = required_assets(ROOT)
    card_freshness = public_card_freshness(roots)
    missing_assets = [path for path, present in assets.items() if not present]
    violations = [
        {"root": name, **violation}
        for name, result in scans.items()
        for violation in result["violations"]
    ]
    checks = [
        {
            "name": "required_publication_assets_present",
            "status": "pass" if not missing_assets else "fail",
            "missing": missing_assets,
        },
        {
            "name": "no_generated_python_caches",
            "status": "pass"
            if not any(v["kind"].startswith("generated_cache") for v in violations)
            else "fail",
            "count": sum(1 for v in violations if v["kind"].startswith("generated_cache")),
        },
        {
            "name": "no_raw_xperience10m_data",
            "status": "pass" if not any(v["kind"] == "raw_xperience10m_data" for v in violations) else "fail",
            "count": sum(1 for v in violations if v["kind"] == "raw_xperience10m_data"),
        },
        {
            "name": "no_heavy_model_archives",
            "status": "pass" if not any(v["kind"] == "heavy_model_or_archive" for v in violations) else "fail",
            "count": sum(1 for v in violations if v["kind"] == "heavy_model_or_archive"),
        },
        {
            "name": "no_hf_tokens_in_public_text",
            "status": "pass" if not any(v["kind"] == "possible_hf_token" for v in violations) else "fail",
            "count": sum(1 for v in violations if v["kind"] == "possible_hf_token"),
        },
        {
            "name": "no_local_filesystem_paths_in_public_text",
            "status": "pass" if not any(v["kind"] == "local_filesystem_path" for v in violations) else "fail",
            "count": sum(1 for v in violations if v["kind"] == "local_filesystem_path"),
        },
        {
            "name": "no_stale_task_suite_presentation_copy",
            "status": "pass" if not any(v["kind"] == "stale_presentation_copy" for v in violations) else "fail",
            "count": sum(1 for v in violations if v["kind"] == "stale_presentation_copy"),
        },
        {
            "name": "public_cards_reference_taskfirst_figure",
            "status": "pass" if all(item["status"] == "pass" for item in card_freshness) else "fail",
            "failures": [item for item in card_freshness if item["status"] != "pass"],
        },
    ]
    status = "pass" if all(check["status"] == "pass" for check in checks) else "fail"
    return {
        "status": status,
        "generated_at_utc": datetime.now(timezone.utc).isoformat(timespec="seconds"),
        "checks": checks,
        "required_assets": assets,
        "public_card_freshness": card_freshness,
        "scans": scans,
        "violations": violations,
    }


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("--hf-root", type=Path, default=DEFAULT_HF_ROOT)
    parser.add_argument("--output", type=Path, default=ROOT / "docs/data/publication_audit.json")
    args = parser.parse_args()

    report = build_report(args.hf_root.resolve())
    args.output.parent.mkdir(parents=True, exist_ok=True)
    args.output.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
    print(f"{report['status'].upper()}: wrote {args.output}")
    if report["status"] != "pass":
        for violation in report["violations"][:40]:
            print(f"- {violation['root']}: {violation['kind']} {violation['path']}")
        if len(report["violations"]) > 40:
            print(f"- ... {len(report['violations']) - 40} more violations")
        return 1
    return 0


if __name__ == "__main__":
    raise SystemExit(main())