@orbit-build/cli 0.8.3 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/commands/cumcm-draft.md +3 -1
- package/dist/index.js +1158 -310
- package/package.json +1 -1
- package/skills/cumcm-draft/SKILL.md +102 -48
- package/skills/cumcm-draft/agents/openai.yaml +1 -1
- package/skills/cumcm-draft/assets/project-template/{code → .cumcm}/finalize.py +33 -4
- package/skills/cumcm-draft/assets/project-template/{paper/contest-profile.json → .cumcm/profile.json} +9 -6
- package/skills/cumcm-draft/assets/project-template/code/requirements.txt +1 -11
- package/skills/cumcm-draft/assets/project-template/paper/AI/345/267/245/345/205/267/344/275/277/347/224/250/350/257/246/346/203/205.tex +1 -11
- package/skills/cumcm-draft/assets/project-template/paper/main.tex +70 -11
- package/skills/cumcm-draft/references/code-and-output-style.md +9 -14
- package/skills/cumcm-draft/references/cumcm-compliance.md +28 -25
- package/skills/cumcm-draft/references/latex-figures-tables.md +1 -1
- package/skills/cumcm-draft/references/modeling-quality.md +1 -1
- package/skills/cumcm-draft/references/paper-architecture.md +3 -3
- package/skills/cumcm-draft/references/project-architecture.md +70 -89
- package/skills/cumcm-draft/scripts/audit_paper.py +37 -9
- package/skills/cumcm-draft/scripts/bootstrap_project.py +198 -56
- package/skills/cumcm-draft/scripts/build_paper.py +38 -23
- package/skills/cumcm-draft/scripts/capture_environment.py +3 -1
- package/skills/cumcm-draft/scripts/clean_project.py +7 -2
- package/skills/cumcm-draft/scripts/evidence_freeze.py +8 -4
- package/skills/cumcm-draft/scripts/finalize_project.py +16 -0
- package/skills/cumcm-draft/scripts/inspect_inputs.py +6 -4
- package/skills/cumcm-draft/scripts/package_support.py +41 -15
- package/skills/cumcm-draft/scripts/project_utils.py +40 -8
- package/skills/cumcm-draft/scripts/validate_project.py +394 -57
- package/skills/cumcm-draft/assets/project-template/code/always/__init__.py +0 -1
- package/skills/cumcm-draft/assets/project-template/code/always/config.py +0 -18
- package/skills/cumcm-draft/assets/project-template/code/always/data.py +0 -24
- package/skills/cumcm-draft/assets/project-template/code/always/plotting.py +0 -25
- package/skills/cumcm-draft/assets/project-template/code/always/validation.py +0 -21
- package/skills/cumcm-draft/assets/project-template/paper/sections/abstract.tex +0 -6
- package/skills/cumcm-draft/assets/project-template/paper/sections/ai-disclosure.tex +0 -3
- package/skills/cumcm-draft/assets/project-template/paper/sections/appendix.tex +0 -3
- package/skills/cumcm-draft/assets/project-template/paper/sections/assumptions.tex +0 -5
- package/skills/cumcm-draft/assets/project-template/paper/sections/data.tex +0 -19
- package/skills/cumcm-draft/assets/project-template/paper/sections/evaluation.tex +0 -9
- package/skills/cumcm-draft/assets/project-template/paper/sections/problem-analysis.tex +0 -3
- package/skills/cumcm-draft/assets/project-template/paper/sections/problem-restatement.tex +0 -3
- package/skills/cumcm-draft/assets/project-template/paper/sections/references.tex +0 -12
- package/skills/cumcm-draft/assets/project-template/paper/sections/source-code.tex +0 -1
- package/skills/cumcm-draft/assets/project-template/paper/sections/support-files.tex +0 -3
- /package/skills/cumcm-draft/assets/project-template/{paper → .cumcm}/ai-use-log.md +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
|
+
import ast
|
|
4
5
|
import csv
|
|
5
6
|
import hashlib
|
|
6
7
|
import io
|
|
@@ -15,7 +16,15 @@ from pathlib import Path, PurePosixPath
|
|
|
15
16
|
from typing import Any
|
|
16
17
|
from xml.etree import ElementTree
|
|
17
18
|
|
|
18
|
-
from project_utils import
|
|
19
|
+
from project_utils import (
|
|
20
|
+
build_directory,
|
|
21
|
+
control_path,
|
|
22
|
+
ensure_safe_file,
|
|
23
|
+
generated_directory,
|
|
24
|
+
load_profile,
|
|
25
|
+
numeric_limit,
|
|
26
|
+
question_numbers,
|
|
27
|
+
)
|
|
19
28
|
from evidence_freeze import evidence_differences
|
|
20
29
|
|
|
21
30
|
|
|
@@ -30,6 +39,18 @@ SUPPORT_EXCLUDED_PARTS = {
|
|
|
30
39
|
}
|
|
31
40
|
NESTED_ARCHIVE_SUFFIXES = {".zip", ".rar", ".7z"}
|
|
32
41
|
TABULAR_RESULT_SUFFIXES = {".csv", ".tsv", ".xls", ".xlsx"}
|
|
42
|
+
FIGURE_SUFFIXES = {".pdf", ".png", ".jpg", ".jpeg", ".eps", ".svg"}
|
|
43
|
+
GENERIC_FIGURE_STEMS = {
|
|
44
|
+
"chart",
|
|
45
|
+
"figure",
|
|
46
|
+
"final",
|
|
47
|
+
"image",
|
|
48
|
+
"output",
|
|
49
|
+
"overview",
|
|
50
|
+
"plot",
|
|
51
|
+
"result",
|
|
52
|
+
"summary",
|
|
53
|
+
}
|
|
33
54
|
RESULT_EXCEPTION_SCOPES = {"filename", "headers", "sheet_names", "encoding"}
|
|
34
55
|
HAN_RE = re.compile(r"[\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]")
|
|
35
56
|
SPREADSHEET_NS = "{http://schemas.openxmlformats.org/spreadsheetml/2006/main}"
|
|
@@ -514,6 +535,35 @@ def result_artifact_contract_errors(
|
|
|
514
535
|
return errors
|
|
515
536
|
|
|
516
537
|
|
|
538
|
+
def figure_artifact_contract_errors(
|
|
539
|
+
root: Path, profile: dict[str, object]
|
|
540
|
+
) -> list[str]:
|
|
541
|
+
"""Require final figures to explain themselves in Chinese filenames."""
|
|
542
|
+
errors: list[str] = []
|
|
543
|
+
if profile.get("require_chinese_figure_filenames", True) is not True:
|
|
544
|
+
errors.append(
|
|
545
|
+
"result_artifacts.require_chinese_figure_filenames must be true"
|
|
546
|
+
)
|
|
547
|
+
figures = root / "figures"
|
|
548
|
+
if not figures.is_dir() or figures.is_symlink():
|
|
549
|
+
return errors
|
|
550
|
+
for path in figures.rglob("*"):
|
|
551
|
+
if not path.is_file() or path.is_symlink():
|
|
552
|
+
continue
|
|
553
|
+
relative = path.relative_to(root).as_posix()
|
|
554
|
+
if path.suffix.lower() not in FIGURE_SUFFIXES:
|
|
555
|
+
errors.append(
|
|
556
|
+
f"figures/ contains a non-figure artifact; move it to results/: {relative}"
|
|
557
|
+
)
|
|
558
|
+
continue
|
|
559
|
+
stem = path.stem.strip()
|
|
560
|
+
if stem.lower() in GENERIC_FIGURE_STEMS or not has_chinese(stem):
|
|
561
|
+
errors.append(
|
|
562
|
+
f"figure filename must be descriptive Chinese, not a generic name: {relative}"
|
|
563
|
+
)
|
|
564
|
+
return errors
|
|
565
|
+
|
|
566
|
+
|
|
517
567
|
def fixed_schema_congruence_errors(
|
|
518
568
|
target: Path, source: Path, allowances: set[str], relative: str
|
|
519
569
|
) -> list[str]:
|
|
@@ -586,6 +636,110 @@ def rules_freshness_errors(profile: dict[str, object]) -> list[str]:
|
|
|
586
636
|
)
|
|
587
637
|
if expires_date < checked_date:
|
|
588
638
|
errors.append("contest rules_expires_at must not precede rules_checked_at")
|
|
639
|
+
if profile.get("profile") == "cumcm-2026":
|
|
640
|
+
official_ai_source = (
|
|
641
|
+
"https://www.mcm.edu.cn/html_cn/node/"
|
|
642
|
+
"fef94648f2836ab6cc81586f4c38512b.html"
|
|
643
|
+
)
|
|
644
|
+
sources = profile.get("sources")
|
|
645
|
+
if not isinstance(sources, list) or official_ai_source not in sources:
|
|
646
|
+
errors.append(
|
|
647
|
+
"cumcm-2026 profile must cite the official 2026 AI-use rule"
|
|
648
|
+
)
|
|
649
|
+
ai_profile = profile.get("ai")
|
|
650
|
+
if not isinstance(ai_profile, dict):
|
|
651
|
+
errors.append("cumcm-2026 profile requires an ai policy object")
|
|
652
|
+
else:
|
|
653
|
+
if ai_profile.get("policy") != "cumcm-2026-trial":
|
|
654
|
+
errors.append(
|
|
655
|
+
"cumcm-2026 profile must use the official cumcm-2026-trial AI policy"
|
|
656
|
+
)
|
|
657
|
+
submission_intent = ai_profile.get("submission_intent")
|
|
658
|
+
if submission_intent not in {"training", "formal"}:
|
|
659
|
+
errors.append(
|
|
660
|
+
"cumcm-2026 ai.submission_intent must be training or formal"
|
|
661
|
+
)
|
|
662
|
+
if submission_intent == "formal":
|
|
663
|
+
if ai_profile.get("core_modeling_led_by_team") is not True:
|
|
664
|
+
errors.append(
|
|
665
|
+
"formal CUMCM submission requires team-led core modeling"
|
|
666
|
+
)
|
|
667
|
+
if ai_profile.get("manual_review_completed") is not True:
|
|
668
|
+
errors.append(
|
|
669
|
+
"formal CUMCM submission requires completed manual AI review"
|
|
670
|
+
)
|
|
671
|
+
for field in (
|
|
672
|
+
"declaration_required",
|
|
673
|
+
"declaration_before_references",
|
|
674
|
+
"details_pdf_required",
|
|
675
|
+
):
|
|
676
|
+
if ai_profile.get(field) is not True:
|
|
677
|
+
errors.append(f"cumcm-2026 ai.{field} must be true")
|
|
678
|
+
return errors
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
def ai_declaration_errors(
|
|
682
|
+
root: Path,
|
|
683
|
+
main_tex: Path,
|
|
684
|
+
ai_profile: dict[str, object],
|
|
685
|
+
) -> list[str]:
|
|
686
|
+
"""Validate the official 2026 declaration text and placement."""
|
|
687
|
+
errors: list[str] = []
|
|
688
|
+
if not bool(ai_profile.get("declaration_required")):
|
|
689
|
+
return errors
|
|
690
|
+
declaration_source = root / "paper" / "sections" / "ai-disclosure.tex"
|
|
691
|
+
declaration_text = (
|
|
692
|
+
declaration_source.read_text(encoding="utf-8", errors="replace")
|
|
693
|
+
if declaration_source.is_file()
|
|
694
|
+
else main_tex.read_text(encoding="utf-8", errors="replace")
|
|
695
|
+
if main_tex.is_file()
|
|
696
|
+
else ""
|
|
697
|
+
)
|
|
698
|
+
compact = re.sub(r"\s+", "", declaration_text)
|
|
699
|
+
if bool(ai_profile.get("used")):
|
|
700
|
+
required_prefix = "本参赛队在竞赛过程中使用了AI工具,主要用于"
|
|
701
|
+
required_suffix = ",详细使用情况见支撑材料。"
|
|
702
|
+
if required_prefix not in compact or required_suffix not in compact:
|
|
703
|
+
errors.append(
|
|
704
|
+
"used-AI paper must include the official 2026 AI declaration text"
|
|
705
|
+
)
|
|
706
|
+
elif "本参赛队在竞赛过程中未使用任何AI工具。" not in compact:
|
|
707
|
+
errors.append(
|
|
708
|
+
"unused-AI paper must include the exact official 2026 AI declaration"
|
|
709
|
+
)
|
|
710
|
+
|
|
711
|
+
if bool(ai_profile.get("declaration_before_references")):
|
|
712
|
+
if not main_tex.is_file():
|
|
713
|
+
errors.append("cannot verify AI declaration placement without paper/main.tex")
|
|
714
|
+
return errors
|
|
715
|
+
main = re.sub(
|
|
716
|
+
r"\s+",
|
|
717
|
+
"",
|
|
718
|
+
main_tex.read_text(encoding="utf-8", errors="replace"),
|
|
719
|
+
)
|
|
720
|
+
declaration_positions = [
|
|
721
|
+
position
|
|
722
|
+
for marker in (
|
|
723
|
+
r"\input{sections/ai-disclosure}",
|
|
724
|
+
"AI工具使用声明",
|
|
725
|
+
)
|
|
726
|
+
if (position := main.find(marker)) >= 0
|
|
727
|
+
]
|
|
728
|
+
reference_positions = [
|
|
729
|
+
position
|
|
730
|
+
for marker in (
|
|
731
|
+
r"\input{sections/references}",
|
|
732
|
+
r"\begin{thebibliography}",
|
|
733
|
+
"参考文献",
|
|
734
|
+
)
|
|
735
|
+
if (position := main.find(marker)) >= 0
|
|
736
|
+
]
|
|
737
|
+
if (
|
|
738
|
+
not declaration_positions
|
|
739
|
+
or not reference_positions
|
|
740
|
+
or min(declaration_positions) >= min(reference_positions)
|
|
741
|
+
):
|
|
742
|
+
errors.append("AI工具使用声明 must appear immediately before references")
|
|
589
743
|
return errors
|
|
590
744
|
|
|
591
745
|
|
|
@@ -599,10 +753,17 @@ def expected_support_names(root: Path, ai_profile: dict[str, object], support_pr
|
|
|
599
753
|
if path.is_file() and not path.is_symlink() and not any(part in SUPPORT_EXCLUDED_PARTS for part in path.relative_to(root).parts):
|
|
600
754
|
names.add(path.relative_to(root).as_posix())
|
|
601
755
|
if bool(ai_profile.get("used")) and bool(ai_profile.get("details_pdf_required")):
|
|
602
|
-
names.add("
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
756
|
+
names.add("AI工具使用详情.pdf")
|
|
757
|
+
environment = control_path(root, "environment.json")
|
|
758
|
+
if environment.is_file():
|
|
759
|
+
names.add("复现环境.json")
|
|
760
|
+
ai_log = control_path(
|
|
761
|
+
root,
|
|
762
|
+
"ai-use-log.md",
|
|
763
|
+
root / "paper" / "ai-use-log.md",
|
|
764
|
+
)
|
|
765
|
+
if bool(support_profile.get("include_ai_log")) and ai_log.is_file():
|
|
766
|
+
names.add("AI工具使用记录.md")
|
|
606
767
|
return names
|
|
607
768
|
|
|
608
769
|
|
|
@@ -657,9 +818,13 @@ def load_simple_evidence_yaml(path: Path) -> dict[str, Any]:
|
|
|
657
818
|
|
|
658
819
|
|
|
659
820
|
def validate_evidence(root: Path, count: int, errors: list[str], warnings: list[str]) -> None:
|
|
660
|
-
path =
|
|
821
|
+
path = control_path(
|
|
822
|
+
root,
|
|
823
|
+
"evidence-map.yaml",
|
|
824
|
+
root / "paper" / "evidence-map.yaml",
|
|
825
|
+
)
|
|
661
826
|
if not path.is_file():
|
|
662
|
-
errors.append("missing
|
|
827
|
+
errors.append("missing .cumcm/evidence-map.yaml")
|
|
663
828
|
return
|
|
664
829
|
try:
|
|
665
830
|
payload = load_evidence_yaml(path)
|
|
@@ -698,8 +863,14 @@ def validate_evidence(root: Path, count: int, errors: list[str], warnings: list[
|
|
|
698
863
|
errors.append(f"unsafe {location}.{field}: {error}")
|
|
699
864
|
continue
|
|
700
865
|
relative = resolved.relative_to(root).as_posix()
|
|
701
|
-
if field == "paper_section" and not
|
|
702
|
-
|
|
866
|
+
if field == "paper_section" and not (
|
|
867
|
+
relative == "paper/main.tex"
|
|
868
|
+
or relative.startswith("paper/sections/")
|
|
869
|
+
):
|
|
870
|
+
errors.append(
|
|
871
|
+
f"{location}.paper_section must be paper/main.tex "
|
|
872
|
+
"or a legacy paper/sections file"
|
|
873
|
+
)
|
|
703
874
|
if not resolved.is_file():
|
|
704
875
|
errors.append(f"evidence path does not exist: {value}")
|
|
705
876
|
status = claim.get("status")
|
|
@@ -709,6 +880,34 @@ def validate_evidence(root: Path, count: int, errors: list[str], warnings: list[
|
|
|
709
880
|
warnings.append(f"unresolved evidence claim: {claim_id or location}")
|
|
710
881
|
|
|
711
882
|
|
|
883
|
+
def code_architecture_errors(root: Path, count: int) -> list[str]:
|
|
884
|
+
"""Reject incomplete qN implementations that cannot support a final paper."""
|
|
885
|
+
errors: list[str] = []
|
|
886
|
+
for number in range(1, count + 1):
|
|
887
|
+
question_dir = root / "code" / f"q{number}"
|
|
888
|
+
if not question_dir.is_dir():
|
|
889
|
+
continue
|
|
890
|
+
modules = sorted(
|
|
891
|
+
path
|
|
892
|
+
for path in question_dir.glob("*.py")
|
|
893
|
+
if path.name != "__init__.py" and path.is_file()
|
|
894
|
+
)
|
|
895
|
+
names = {path.name for path in modules}
|
|
896
|
+
if names == {"main.py"}:
|
|
897
|
+
errors.append(
|
|
898
|
+
f"q{number} contains only main.py; keep it orchestral and add "
|
|
899
|
+
"responsibility-named modules for the actual model and validation"
|
|
900
|
+
)
|
|
901
|
+
main_path = question_dir / "main.py"
|
|
902
|
+
if main_path.is_file():
|
|
903
|
+
main_text = main_path.read_text(encoding="utf-8", errors="replace")
|
|
904
|
+
if "NotImplementedError" in main_text or "TODO" in main_text:
|
|
905
|
+
errors.append(
|
|
906
|
+
f"code/q{number}/main.py is still an unimplemented scaffold"
|
|
907
|
+
)
|
|
908
|
+
return errors
|
|
909
|
+
|
|
910
|
+
|
|
712
911
|
def code_architecture_warnings(root: Path, count: int) -> list[str]:
|
|
713
912
|
"""Find review-hostile Python layouts without prescribing one fixed architecture."""
|
|
714
913
|
warnings: list[str] = []
|
|
@@ -738,9 +937,10 @@ def code_architecture_warnings(root: Path, count: int) -> list[str]:
|
|
|
738
937
|
)
|
|
739
938
|
main_path = question_dir / "main.py"
|
|
740
939
|
if main_path.is_file():
|
|
940
|
+
main_text = main_path.read_text(encoding="utf-8", errors="replace")
|
|
741
941
|
main_lines = [
|
|
742
942
|
line
|
|
743
|
-
for line in
|
|
943
|
+
for line in main_text.splitlines()
|
|
744
944
|
if line.strip()
|
|
745
945
|
]
|
|
746
946
|
if len(main_lines) >= 150:
|
|
@@ -779,6 +979,81 @@ def delivery_hygiene_warnings(root: Path) -> list[str]:
|
|
|
779
979
|
temporary = root / "tmp"
|
|
780
980
|
if temporary.is_dir() and any(temporary.iterdir()):
|
|
781
981
|
warnings.append("non-empty tmp/ directory should be cleaned before handoff")
|
|
982
|
+
manifest = control_path(
|
|
983
|
+
root,
|
|
984
|
+
"project.json",
|
|
985
|
+
root / "paper" / "question-count.json",
|
|
986
|
+
)
|
|
987
|
+
layout = ""
|
|
988
|
+
if manifest.is_file():
|
|
989
|
+
try:
|
|
990
|
+
layout = str(read_json(manifest).get("layout", ""))
|
|
991
|
+
except (OSError, ValueError, json.JSONDecodeError):
|
|
992
|
+
pass
|
|
993
|
+
if layout == "compact-v2":
|
|
994
|
+
for directory in (root / "paper" / "sections", root / "paper" / "build"):
|
|
995
|
+
if directory.is_dir():
|
|
996
|
+
warnings.append(
|
|
997
|
+
f"compact layout must not expose authoring directory: "
|
|
998
|
+
f"{directory.relative_to(root).as_posix()}/"
|
|
999
|
+
)
|
|
1000
|
+
legacy_controls = (
|
|
1001
|
+
"contest-profile.json",
|
|
1002
|
+
"question-count.json",
|
|
1003
|
+
"evidence-map.yaml",
|
|
1004
|
+
"input-inventory.json",
|
|
1005
|
+
"question-fingerprint.json",
|
|
1006
|
+
"evidence-freeze.json",
|
|
1007
|
+
"ai-use-log.md",
|
|
1008
|
+
)
|
|
1009
|
+
for name in legacy_controls:
|
|
1010
|
+
if (root / "paper" / name).exists():
|
|
1011
|
+
warnings.append(
|
|
1012
|
+
f"move internal workflow state out of paper/: paper/{name}"
|
|
1013
|
+
)
|
|
1014
|
+
if (root / "code" / "finalize.py").exists():
|
|
1015
|
+
warnings.append(
|
|
1016
|
+
"code/finalize.py is workflow infrastructure, not modeling code; "
|
|
1017
|
+
"use .cumcm/finalize.py"
|
|
1018
|
+
)
|
|
1019
|
+
allowed_paper_files = {
|
|
1020
|
+
"AI工具使用详情.pdf",
|
|
1021
|
+
"AI工具使用详情.tex",
|
|
1022
|
+
"main.pdf",
|
|
1023
|
+
"main.tex",
|
|
1024
|
+
"支撑材料.zip",
|
|
1025
|
+
}
|
|
1026
|
+
compile_suffixes = {
|
|
1027
|
+
".aux",
|
|
1028
|
+
".bbl",
|
|
1029
|
+
".bcf",
|
|
1030
|
+
".blg",
|
|
1031
|
+
".fdb_latexmk",
|
|
1032
|
+
".fls",
|
|
1033
|
+
".log",
|
|
1034
|
+
".out",
|
|
1035
|
+
".run.xml",
|
|
1036
|
+
".synctex.gz",
|
|
1037
|
+
".toc",
|
|
1038
|
+
".xdv",
|
|
1039
|
+
}
|
|
1040
|
+
paper = root / "paper"
|
|
1041
|
+
if paper.is_dir():
|
|
1042
|
+
for path in paper.iterdir():
|
|
1043
|
+
if not path.is_file() or path.name in allowed_paper_files:
|
|
1044
|
+
continue
|
|
1045
|
+
if any(path.name.endswith(suffix) for suffix in compile_suffixes):
|
|
1046
|
+
continue
|
|
1047
|
+
warnings.append(
|
|
1048
|
+
f"paper/ contains a non-paper internal artifact: "
|
|
1049
|
+
f"{path.relative_to(root).as_posix()}"
|
|
1050
|
+
)
|
|
1051
|
+
for summary in root.glob("results/q*/summary.json"):
|
|
1052
|
+
if summary.is_file():
|
|
1053
|
+
warnings.append(
|
|
1054
|
+
f"generic control summary does not belong in final results: "
|
|
1055
|
+
f"{summary.relative_to(root).as_posix()}"
|
|
1056
|
+
)
|
|
782
1057
|
return warnings
|
|
783
1058
|
|
|
784
1059
|
|
|
@@ -820,20 +1095,24 @@ def main() -> None:
|
|
|
820
1095
|
elif path.is_symlink():
|
|
821
1096
|
errors.append(f"symbolic top-level directory is unsafe: {name}/")
|
|
822
1097
|
|
|
823
|
-
count_path =
|
|
1098
|
+
count_path = control_path(
|
|
1099
|
+
root,
|
|
1100
|
+
"project.json",
|
|
1101
|
+
root / "paper" / "question-count.json",
|
|
1102
|
+
)
|
|
824
1103
|
count = 0
|
|
825
1104
|
if not count_path.is_file():
|
|
826
|
-
errors.append("missing
|
|
1105
|
+
errors.append("missing .cumcm/project.json")
|
|
827
1106
|
else:
|
|
828
1107
|
try:
|
|
829
1108
|
count = int(read_json(count_path).get("questions", 0))
|
|
830
1109
|
except (OSError, ValueError, json.JSONDecodeError) as error:
|
|
831
|
-
errors.append(f"invalid
|
|
1110
|
+
errors.append(f"invalid project manifest: {error}")
|
|
832
1111
|
if not 1 <= count <= 20:
|
|
833
|
-
errors.append("
|
|
1112
|
+
errors.append("project manifest must declare 1 to 20 questions")
|
|
834
1113
|
discovered = question_numbers(root)
|
|
835
1114
|
if discovered and max(discovered) > count:
|
|
836
|
-
errors.append(f"
|
|
1115
|
+
errors.append(f"project manifest omits discovered subproblem q{max(discovered)}")
|
|
837
1116
|
|
|
838
1117
|
if args.run_code:
|
|
839
1118
|
entry = root / "code" / "run_all.py"
|
|
@@ -848,21 +1127,27 @@ def main() -> None:
|
|
|
848
1127
|
|
|
849
1128
|
for number in range(1, count + 1):
|
|
850
1129
|
name = f"q{number}"
|
|
851
|
-
required = (
|
|
1130
|
+
required = (
|
|
1131
|
+
f"code/{name}",
|
|
1132
|
+
f"code/{name}/main.py",
|
|
1133
|
+
f"results/{name}",
|
|
1134
|
+
f"figures/{name}",
|
|
1135
|
+
)
|
|
852
1136
|
for relative in required:
|
|
853
1137
|
if not (root / relative).exists():
|
|
854
1138
|
errors.append(f"missing subproblem artifact: {relative}")
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
1139
|
+
main_source = root / "paper" / "main.tex"
|
|
1140
|
+
legacy_section = root / "paper" / "sections" / f"{name}.tex"
|
|
1141
|
+
if not legacy_section.is_file() and main_source.is_file():
|
|
1142
|
+
main_content = main_source.read_text(encoding="utf-8", errors="replace")
|
|
1143
|
+
if not re.search(rf"\\section\{{问题{number}(?:[::]|\}})", main_content):
|
|
1144
|
+
errors.append(f"paper/main.tex is missing the problem {number} section")
|
|
1145
|
+
|
|
1146
|
+
inventory_path = control_path(
|
|
1147
|
+
root,
|
|
1148
|
+
"input-inventory.json",
|
|
1149
|
+
root / "paper" / "input-inventory.json",
|
|
1150
|
+
)
|
|
866
1151
|
if not inventory_path.is_file():
|
|
867
1152
|
warnings.append("input inventory is missing; run inspect_inputs.py")
|
|
868
1153
|
else:
|
|
@@ -874,7 +1159,11 @@ def main() -> None:
|
|
|
874
1159
|
except (OSError, ValueError, json.JSONDecodeError) as error:
|
|
875
1160
|
errors.append(f"invalid input inventory: {error}")
|
|
876
1161
|
|
|
877
|
-
baseline =
|
|
1162
|
+
baseline = control_path(
|
|
1163
|
+
root,
|
|
1164
|
+
"question-fingerprint.json",
|
|
1165
|
+
root / "paper" / "question-fingerprint.json",
|
|
1166
|
+
)
|
|
878
1167
|
if not baseline.is_file():
|
|
879
1168
|
warnings.append("question fingerprint baseline is missing; run inspect_inputs.py")
|
|
880
1169
|
else:
|
|
@@ -893,13 +1182,24 @@ def main() -> None:
|
|
|
893
1182
|
except (KeyError, OSError, ValueError, json.JSONDecodeError) as error:
|
|
894
1183
|
errors.append(f"invalid question fingerprint: {error}")
|
|
895
1184
|
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
1185
|
+
for source in sorted((root / "code").rglob("*.py")):
|
|
1186
|
+
if not source.is_file() or source.is_symlink():
|
|
1187
|
+
continue
|
|
1188
|
+
try:
|
|
1189
|
+
ast.parse(
|
|
1190
|
+
source.read_text(encoding="utf-8"),
|
|
1191
|
+
filename=source.relative_to(root).as_posix(),
|
|
1192
|
+
)
|
|
1193
|
+
except (OSError, SyntaxError, UnicodeDecodeError) as error:
|
|
1194
|
+
errors.append(
|
|
1195
|
+
f"Python syntax failed for {source.relative_to(root).as_posix()}: {error}"
|
|
1196
|
+
)
|
|
1197
|
+
errors.extend(code_architecture_errors(root, count))
|
|
899
1198
|
warnings.extend(code_architecture_warnings(root, count))
|
|
900
1199
|
warnings.extend(delivery_hygiene_warnings(root))
|
|
901
1200
|
if result_artifact_profile is not None:
|
|
902
1201
|
errors.extend(result_artifact_contract_errors(root, result_artifact_profile))
|
|
1202
|
+
errors.extend(figure_artifact_contract_errors(root, result_artifact_profile))
|
|
903
1203
|
if profile:
|
|
904
1204
|
errors.extend(rules_freshness_errors(profile))
|
|
905
1205
|
validate_evidence(root, count, errors, warnings)
|
|
@@ -910,7 +1210,13 @@ def main() -> None:
|
|
|
910
1210
|
except (KeyError, OSError, TypeError, ValueError, json.JSONDecodeError) as error:
|
|
911
1211
|
errors.append(f"invalid evidence freeze: {error}")
|
|
912
1212
|
|
|
913
|
-
tex_files = [
|
|
1213
|
+
tex_files = [
|
|
1214
|
+
path
|
|
1215
|
+
for base in (root / "paper", generated_directory(root))
|
|
1216
|
+
if base.is_dir()
|
|
1217
|
+
for path in base.rglob("*.tex")
|
|
1218
|
+
if path.is_file() and not path.is_symlink()
|
|
1219
|
+
]
|
|
914
1220
|
tex = "\n".join(path.read_text(encoding="utf-8", errors="replace") for path in tex_files)
|
|
915
1221
|
todo_count = tex.count(r"\TODO{") + len(re.findall(r"TODO\[", tex))
|
|
916
1222
|
if todo_count:
|
|
@@ -928,20 +1234,19 @@ def main() -> None:
|
|
|
928
1234
|
errors.append(margin_error)
|
|
929
1235
|
if r"\tableofcontents" in content:
|
|
930
1236
|
errors.append("CUMCM paper must not contain a table of contents")
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
errors.append("AI-assisted body content must carry corresponding inline markers")
|
|
934
|
-
if bool(ai_profile.get("reference_entry_required")):
|
|
935
|
-
reference_key = str(ai_profile.get("reference_key") or "ai-tool")
|
|
936
|
-
if f"\\bibitem{{{reference_key}}}" not in tex:
|
|
937
|
-
errors.append(f"AI tool reference entry is missing: {reference_key}")
|
|
1237
|
+
if isinstance(ai_profile, dict):
|
|
1238
|
+
errors.extend(ai_declaration_errors(root, main_tex, ai_profile))
|
|
938
1239
|
|
|
939
1240
|
if bool(paper_profile.get("include_support_file_list")):
|
|
940
|
-
support_tex = root / "
|
|
1241
|
+
support_tex = generated_directory(root) / "support-files.tex"
|
|
1242
|
+
if not support_tex.is_file():
|
|
1243
|
+
support_tex = root / "paper" / "sections" / "support-files.tex"
|
|
941
1244
|
if not support_tex.is_file() or "支撑材料文件列表" not in support_tex.read_text(encoding="utf-8", errors="replace"):
|
|
942
1245
|
errors.append("CUMCM appendix is missing the required support-material file list")
|
|
943
1246
|
if bool(paper_profile.get("include_source_appendix")):
|
|
944
|
-
source_tex = root / "
|
|
1247
|
+
source_tex = generated_directory(root) / "source-code.tex"
|
|
1248
|
+
if not source_tex.is_file():
|
|
1249
|
+
source_tex = root / "paper" / "sections" / "source-code.tex"
|
|
945
1250
|
if not source_tex.is_file() or r"\lstinputlisting" not in source_tex.read_text(encoding="utf-8", errors="replace"):
|
|
946
1251
|
errors.append("CUMCM appendix is missing complete runnable source listings")
|
|
947
1252
|
|
|
@@ -970,12 +1275,20 @@ def main() -> None:
|
|
|
970
1275
|
except (IndexError, OSError, PdfReadError, ValueError) as error:
|
|
971
1276
|
warnings.append(f"could not verify CUMCM first-page content: {error}")
|
|
972
1277
|
|
|
973
|
-
archive = root / "paper" / "
|
|
1278
|
+
archive = root / "paper" / "支撑材料.zip"
|
|
1279
|
+
legacy_archive_used = False
|
|
974
1280
|
if not archive.is_file():
|
|
975
|
-
|
|
1281
|
+
legacy_archive = root / "paper" / "support-materials.zip"
|
|
1282
|
+
if legacy_archive.is_file():
|
|
1283
|
+
archive = legacy_archive
|
|
1284
|
+
legacy_archive_used = True
|
|
1285
|
+
if not archive.is_file():
|
|
1286
|
+
warnings.append("支撑材料.zip is missing; run package_support.py")
|
|
976
1287
|
else:
|
|
977
1288
|
if archive_limit is not None and archive.stat().st_size > archive_limit * 1024 * 1024:
|
|
978
|
-
errors.append(
|
|
1289
|
+
errors.append(
|
|
1290
|
+
f"{archive.name} exceeds active {archive_limit:g} MB limit"
|
|
1291
|
+
)
|
|
979
1292
|
try:
|
|
980
1293
|
with zipfile.ZipFile(archive) as bundle:
|
|
981
1294
|
names = [name for name in bundle.namelist() if not name.endswith("/")]
|
|
@@ -984,13 +1297,23 @@ def main() -> None:
|
|
|
984
1297
|
errors.append("support archive contains unsafe absolute/traversal paths")
|
|
985
1298
|
if any(name.replace("\\", "/").lower().startswith("question/") for name in names):
|
|
986
1299
|
errors.append("support archive contains immutable question input files")
|
|
987
|
-
if "
|
|
988
|
-
errors.append("support archive leaks internal
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1300
|
+
if any(name.endswith("ai-use-log.md") or name == "AI工具使用记录.md" for name in names) and not bool(support_profile.get("include_ai_log")):
|
|
1301
|
+
errors.append("support archive leaks the internal AI use log contrary to profile")
|
|
1302
|
+
expected_ai_name = (
|
|
1303
|
+
"paper/AI工具使用详情.pdf"
|
|
1304
|
+
if legacy_archive_used
|
|
1305
|
+
else "AI工具使用详情.pdf"
|
|
1306
|
+
)
|
|
1307
|
+
if bool(ai_profile.get("used")) and bool(ai_profile.get("details_pdf_required")) and expected_ai_name not in names:
|
|
992
1308
|
errors.append("support archive is missing required AI工具使用详情.pdf")
|
|
993
1309
|
expected_names = expected_support_names(root, ai_profile, support_profile)
|
|
1310
|
+
if legacy_archive_used:
|
|
1311
|
+
if "AI工具使用详情.pdf" in expected_names:
|
|
1312
|
+
expected_names.remove("AI工具使用详情.pdf")
|
|
1313
|
+
expected_names.add("paper/AI工具使用详情.pdf")
|
|
1314
|
+
legacy_freeze = root / "paper" / "evidence-freeze.json"
|
|
1315
|
+
if legacy_freeze.is_file():
|
|
1316
|
+
expected_names.add("paper/evidence-freeze.json")
|
|
994
1317
|
actual_names = set(names)
|
|
995
1318
|
missing_names = sorted(expected_names - actual_names)
|
|
996
1319
|
extra_names = sorted(actual_names - expected_names)
|
|
@@ -999,9 +1322,11 @@ def main() -> None:
|
|
|
999
1322
|
if extra_names:
|
|
1000
1323
|
errors.append("support archive contains unlisted project files: " + ", ".join(extra_names[:12]))
|
|
1001
1324
|
except zipfile.BadZipFile:
|
|
1002
|
-
errors.append("
|
|
1325
|
+
errors.append(f"{archive.relative_to(root)} is not a valid ZIP archive")
|
|
1003
1326
|
|
|
1004
|
-
aux = root / "
|
|
1327
|
+
aux = build_directory(root) / "main.aux"
|
|
1328
|
+
if not aux.is_file():
|
|
1329
|
+
aux = root / "paper" / "build" / "main.aux"
|
|
1005
1330
|
if page_limit is not None and aux.is_file():
|
|
1006
1331
|
match = re.search(r"\\newlabel\{body-end\}\{\{.*?\}\{(\d+)\}", aux.read_text(encoding="utf-8", errors="replace"))
|
|
1007
1332
|
if match:
|
|
@@ -1014,17 +1339,29 @@ def main() -> None:
|
|
|
1014
1339
|
warnings.append("could not resolve body-end page label")
|
|
1015
1340
|
|
|
1016
1341
|
if bool(ai_profile.get("used")):
|
|
1017
|
-
disclosure =
|
|
1342
|
+
disclosure = control_path(
|
|
1343
|
+
root,
|
|
1344
|
+
"ai-use-log.md",
|
|
1345
|
+
root / "paper" / "ai-use-log.md",
|
|
1346
|
+
)
|
|
1018
1347
|
if not disclosure.is_file():
|
|
1019
1348
|
warnings.append("internal AI use log is missing")
|
|
1020
1349
|
if bool(ai_profile.get("details_pdf_required")) and not (root / "paper" / "AI工具使用详情.pdf").is_file():
|
|
1021
1350
|
errors.append("AI tool disclosure PDF is required but missing")
|
|
1022
1351
|
details_source = root / "paper" / "AI工具使用详情.tex"
|
|
1023
|
-
if bool(ai_profile.get("details_pdf_required"))
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1352
|
+
if bool(ai_profile.get("details_pdf_required")):
|
|
1353
|
+
details_text = (
|
|
1354
|
+
details_source.read_text(encoding="utf-8", errors="replace")
|
|
1355
|
+
if details_source.is_file()
|
|
1356
|
+
else ""
|
|
1357
|
+
)
|
|
1358
|
+
required_sections = ("主要提示方式与过程", "采纳、人工修改与核验")
|
|
1359
|
+
if not details_source.is_file() or any(
|
|
1360
|
+
section not in details_text for section in required_sections
|
|
1361
|
+
):
|
|
1362
|
+
errors.append(
|
|
1363
|
+
"AI details source must cover prompting/usage process and adoption/manual verification"
|
|
1364
|
+
)
|
|
1028
1365
|
|
|
1029
1366
|
print(f"[RUN] Validation summary: {len(errors)} error(s), {len(warnings)} warning(s)")
|
|
1030
1367
|
for message in errors:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
CODE_ROOT = Path(__file__).resolve().parents[1]
|
|
7
|
-
PROJECT_ROOT = CODE_ROOT.parent
|
|
8
|
-
QUESTION_DIR = PROJECT_ROOT / "question"
|
|
9
|
-
RESULTS_DIR = PROJECT_ROOT / "results"
|
|
10
|
-
FIGURES_DIR = PROJECT_ROOT / "figures"
|
|
11
|
-
RANDOM_STATE = 2026
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def question_output_dirs(question: str) -> tuple[Path, Path]:
|
|
15
|
-
# 只允许 qN,避免输出目录越过项目边界。
|
|
16
|
-
if not question.startswith("q") or not question[1:].isdigit():
|
|
17
|
-
raise ValueError(f"Invalid question name: {question}")
|
|
18
|
-
return RESULTS_DIR / question, FIGURES_DIR / question
|