@orbit-build/cli 0.8.2 → 0.8.5

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.
Files changed (44) hide show
  1. package/README.md +4 -1
  2. package/dist/index.js +1407 -582
  3. package/package.json +1 -1
  4. package/skills/cumcm-draft/SKILL.md +92 -48
  5. package/skills/cumcm-draft/agents/openai.yaml +1 -1
  6. package/skills/cumcm-draft/assets/project-template/{code → .cumcm}/finalize.py +33 -4
  7. package/skills/cumcm-draft/assets/project-template/{paper/contest-profile.json → .cumcm/profile.json} +9 -6
  8. package/skills/cumcm-draft/assets/project-template/code/requirements.txt +1 -11
  9. 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
  10. package/skills/cumcm-draft/assets/project-template/paper/main.tex +70 -11
  11. package/skills/cumcm-draft/references/code-and-output-style.md +9 -14
  12. package/skills/cumcm-draft/references/cumcm-compliance.md +28 -25
  13. package/skills/cumcm-draft/references/latex-figures-tables.md +1 -1
  14. package/skills/cumcm-draft/references/modeling-quality.md +1 -1
  15. package/skills/cumcm-draft/references/paper-architecture.md +3 -3
  16. package/skills/cumcm-draft/references/project-architecture.md +70 -89
  17. package/skills/cumcm-draft/scripts/audit_paper.py +37 -9
  18. package/skills/cumcm-draft/scripts/bootstrap_project.py +182 -56
  19. package/skills/cumcm-draft/scripts/build_paper.py +38 -23
  20. package/skills/cumcm-draft/scripts/capture_environment.py +3 -1
  21. package/skills/cumcm-draft/scripts/clean_project.py +7 -2
  22. package/skills/cumcm-draft/scripts/evidence_freeze.py +8 -4
  23. package/skills/cumcm-draft/scripts/finalize_project.py +4 -0
  24. package/skills/cumcm-draft/scripts/inspect_inputs.py +6 -4
  25. package/skills/cumcm-draft/scripts/package_support.py +41 -15
  26. package/skills/cumcm-draft/scripts/project_utils.py +40 -8
  27. package/skills/cumcm-draft/scripts/validate_project.py +374 -57
  28. package/skills/cumcm-draft/assets/project-template/code/always/__init__.py +0 -1
  29. package/skills/cumcm-draft/assets/project-template/code/always/config.py +0 -18
  30. package/skills/cumcm-draft/assets/project-template/code/always/data.py +0 -24
  31. package/skills/cumcm-draft/assets/project-template/code/always/plotting.py +0 -25
  32. package/skills/cumcm-draft/assets/project-template/code/always/validation.py +0 -21
  33. package/skills/cumcm-draft/assets/project-template/paper/sections/abstract.tex +0 -6
  34. package/skills/cumcm-draft/assets/project-template/paper/sections/ai-disclosure.tex +0 -3
  35. package/skills/cumcm-draft/assets/project-template/paper/sections/appendix.tex +0 -3
  36. package/skills/cumcm-draft/assets/project-template/paper/sections/assumptions.tex +0 -5
  37. package/skills/cumcm-draft/assets/project-template/paper/sections/data.tex +0 -19
  38. package/skills/cumcm-draft/assets/project-template/paper/sections/evaluation.tex +0 -9
  39. package/skills/cumcm-draft/assets/project-template/paper/sections/problem-analysis.tex +0 -3
  40. package/skills/cumcm-draft/assets/project-template/paper/sections/problem-restatement.tex +0 -3
  41. package/skills/cumcm-draft/assets/project-template/paper/sections/references.tex +0 -12
  42. package/skills/cumcm-draft/assets/project-template/paper/sections/source-code.tex +0 -1
  43. package/skills/cumcm-draft/assets/project-template/paper/sections/support-files.tex +0 -3
  44. /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 ensure_safe_file, load_profile, numeric_limit, question_numbers
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("paper/AI工具使用详情.pdf")
603
- if bool(support_profile.get("include_ai_log")) and (root / "paper" / "ai-use-log.md").is_file():
604
- names.add("paper/ai-use-log.md")
605
- names.add("paper/evidence-freeze.json")
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 = root / "paper" / "evidence-map.yaml"
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 paper/evidence-map.yaml")
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 relative.startswith("paper/sections/"):
702
- errors.append(f"{location}.paper_section must be under paper/sections/")
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")
@@ -722,6 +893,11 @@ def code_architecture_warnings(root: Path, count: int) -> list[str]:
722
893
  if path.name != "__init__.py" and path.is_file()
723
894
  )
724
895
  names = {path.name for path in modules}
896
+ if names == {"main.py"}:
897
+ warnings.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
+ )
725
901
  if names == {"main.py", "model.py", "output.py"}:
726
902
  warnings.append(
727
903
  f"q{number} uses the generic main.py + model.py + output.py trio; "
@@ -738,9 +914,14 @@ def code_architecture_warnings(root: Path, count: int) -> list[str]:
738
914
  )
739
915
  main_path = question_dir / "main.py"
740
916
  if main_path.is_file():
917
+ main_text = main_path.read_text(encoding="utf-8", errors="replace")
918
+ if "NotImplementedError" in main_text or "TODO" in main_text:
919
+ warnings.append(
920
+ f"code/q{number}/main.py is still an unimplemented scaffold"
921
+ )
741
922
  main_lines = [
742
923
  line
743
- for line in main_path.read_text(encoding="utf-8", errors="replace").splitlines()
924
+ for line in main_text.splitlines()
744
925
  if line.strip()
745
926
  ]
746
927
  if len(main_lines) >= 150:
@@ -779,6 +960,81 @@ def delivery_hygiene_warnings(root: Path) -> list[str]:
779
960
  temporary = root / "tmp"
780
961
  if temporary.is_dir() and any(temporary.iterdir()):
781
962
  warnings.append("non-empty tmp/ directory should be cleaned before handoff")
963
+ manifest = control_path(
964
+ root,
965
+ "project.json",
966
+ root / "paper" / "question-count.json",
967
+ )
968
+ layout = ""
969
+ if manifest.is_file():
970
+ try:
971
+ layout = str(read_json(manifest).get("layout", ""))
972
+ except (OSError, ValueError, json.JSONDecodeError):
973
+ pass
974
+ if layout == "compact-v2":
975
+ for directory in (root / "paper" / "sections", root / "paper" / "build"):
976
+ if directory.is_dir():
977
+ warnings.append(
978
+ f"compact layout must not expose authoring directory: "
979
+ f"{directory.relative_to(root).as_posix()}/"
980
+ )
981
+ legacy_controls = (
982
+ "contest-profile.json",
983
+ "question-count.json",
984
+ "evidence-map.yaml",
985
+ "input-inventory.json",
986
+ "question-fingerprint.json",
987
+ "evidence-freeze.json",
988
+ "ai-use-log.md",
989
+ )
990
+ for name in legacy_controls:
991
+ if (root / "paper" / name).exists():
992
+ warnings.append(
993
+ f"move internal workflow state out of paper/: paper/{name}"
994
+ )
995
+ if (root / "code" / "finalize.py").exists():
996
+ warnings.append(
997
+ "code/finalize.py is workflow infrastructure, not modeling code; "
998
+ "use .cumcm/finalize.py"
999
+ )
1000
+ allowed_paper_files = {
1001
+ "AI工具使用详情.pdf",
1002
+ "AI工具使用详情.tex",
1003
+ "main.pdf",
1004
+ "main.tex",
1005
+ "支撑材料.zip",
1006
+ }
1007
+ compile_suffixes = {
1008
+ ".aux",
1009
+ ".bbl",
1010
+ ".bcf",
1011
+ ".blg",
1012
+ ".fdb_latexmk",
1013
+ ".fls",
1014
+ ".log",
1015
+ ".out",
1016
+ ".run.xml",
1017
+ ".synctex.gz",
1018
+ ".toc",
1019
+ ".xdv",
1020
+ }
1021
+ paper = root / "paper"
1022
+ if paper.is_dir():
1023
+ for path in paper.iterdir():
1024
+ if not path.is_file() or path.name in allowed_paper_files:
1025
+ continue
1026
+ if any(path.name.endswith(suffix) for suffix in compile_suffixes):
1027
+ continue
1028
+ warnings.append(
1029
+ f"paper/ contains a non-paper internal artifact: "
1030
+ f"{path.relative_to(root).as_posix()}"
1031
+ )
1032
+ for summary in root.glob("results/q*/summary.json"):
1033
+ if summary.is_file():
1034
+ warnings.append(
1035
+ f"generic control summary does not belong in final results: "
1036
+ f"{summary.relative_to(root).as_posix()}"
1037
+ )
782
1038
  return warnings
783
1039
 
784
1040
 
@@ -820,20 +1076,24 @@ def main() -> None:
820
1076
  elif path.is_symlink():
821
1077
  errors.append(f"symbolic top-level directory is unsafe: {name}/")
822
1078
 
823
- count_path = root / "paper" / "question-count.json"
1079
+ count_path = control_path(
1080
+ root,
1081
+ "project.json",
1082
+ root / "paper" / "question-count.json",
1083
+ )
824
1084
  count = 0
825
1085
  if not count_path.is_file():
826
- errors.append("missing paper/question-count.json")
1086
+ errors.append("missing .cumcm/project.json")
827
1087
  else:
828
1088
  try:
829
1089
  count = int(read_json(count_path).get("questions", 0))
830
1090
  except (OSError, ValueError, json.JSONDecodeError) as error:
831
- errors.append(f"invalid paper/question-count.json: {error}")
1091
+ errors.append(f"invalid project manifest: {error}")
832
1092
  if not 1 <= count <= 20:
833
- errors.append("paper/question-count.json must declare 1 to 20 questions")
1093
+ errors.append("project manifest must declare 1 to 20 questions")
834
1094
  discovered = question_numbers(root)
835
1095
  if discovered and max(discovered) > count:
836
- errors.append(f"question-count.json omits discovered subproblem q{max(discovered)}")
1096
+ errors.append(f"project manifest omits discovered subproblem q{max(discovered)}")
837
1097
 
838
1098
  if args.run_code:
839
1099
  entry = root / "code" / "run_all.py"
@@ -848,21 +1108,27 @@ def main() -> None:
848
1108
 
849
1109
  for number in range(1, count + 1):
850
1110
  name = f"q{number}"
851
- required = (f"code/{name}", f"results/{name}", f"figures/{name}", f"paper/sections/{name}.tex")
1111
+ required = (
1112
+ f"code/{name}",
1113
+ f"code/{name}/main.py",
1114
+ f"results/{name}",
1115
+ f"figures/{name}",
1116
+ )
852
1117
  for relative in required:
853
1118
  if not (root / relative).exists():
854
1119
  errors.append(f"missing subproblem artifact: {relative}")
855
- summary = root / "results" / name / "summary.json"
856
- if not summary.is_file():
857
- errors.append(f"missing result evidence: results/{name}/summary.json")
858
- else:
859
- try:
860
- if read_json(summary).get("status") == "TODO":
861
- warnings.append(f"{name} still emits placeholder results")
862
- except (OSError, ValueError, json.JSONDecodeError) as error:
863
- errors.append(f"invalid {summary.relative_to(root)}: {error}")
864
-
865
- inventory_path = root / "paper" / "input-inventory.json"
1120
+ main_source = root / "paper" / "main.tex"
1121
+ legacy_section = root / "paper" / "sections" / f"{name}.tex"
1122
+ if not legacy_section.is_file() and main_source.is_file():
1123
+ main_content = main_source.read_text(encoding="utf-8", errors="replace")
1124
+ if not re.search(rf"\\section\{{问题{number}(?:[::]|\}})", main_content):
1125
+ errors.append(f"paper/main.tex is missing the problem {number} section")
1126
+
1127
+ inventory_path = control_path(
1128
+ root,
1129
+ "input-inventory.json",
1130
+ root / "paper" / "input-inventory.json",
1131
+ )
866
1132
  if not inventory_path.is_file():
867
1133
  warnings.append("input inventory is missing; run inspect_inputs.py")
868
1134
  else:
@@ -874,7 +1140,11 @@ def main() -> None:
874
1140
  except (OSError, ValueError, json.JSONDecodeError) as error:
875
1141
  errors.append(f"invalid input inventory: {error}")
876
1142
 
877
- baseline = root / "paper" / "question-fingerprint.json"
1143
+ baseline = control_path(
1144
+ root,
1145
+ "question-fingerprint.json",
1146
+ root / "paper" / "question-fingerprint.json",
1147
+ )
878
1148
  if not baseline.is_file():
879
1149
  warnings.append("question fingerprint baseline is missing; run inspect_inputs.py")
880
1150
  else:
@@ -893,13 +1163,23 @@ def main() -> None:
893
1163
  except (KeyError, OSError, ValueError, json.JSONDecodeError) as error:
894
1164
  errors.append(f"invalid question fingerprint: {error}")
895
1165
 
896
- compile_result = subprocess.run([sys.executable, "-m", "compileall", "-q", str(root / "code")], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=False)
897
- if compile_result.returncode:
898
- errors.append("Python compile failed: " + compile_result.stdout.strip())
1166
+ for source in sorted((root / "code").rglob("*.py")):
1167
+ if not source.is_file() or source.is_symlink():
1168
+ continue
1169
+ try:
1170
+ ast.parse(
1171
+ source.read_text(encoding="utf-8"),
1172
+ filename=source.relative_to(root).as_posix(),
1173
+ )
1174
+ except (OSError, SyntaxError, UnicodeDecodeError) as error:
1175
+ errors.append(
1176
+ f"Python syntax failed for {source.relative_to(root).as_posix()}: {error}"
1177
+ )
899
1178
  warnings.extend(code_architecture_warnings(root, count))
900
1179
  warnings.extend(delivery_hygiene_warnings(root))
901
1180
  if result_artifact_profile is not None:
902
1181
  errors.extend(result_artifact_contract_errors(root, result_artifact_profile))
1182
+ errors.extend(figure_artifact_contract_errors(root, result_artifact_profile))
903
1183
  if profile:
904
1184
  errors.extend(rules_freshness_errors(profile))
905
1185
  validate_evidence(root, count, errors, warnings)
@@ -910,7 +1190,13 @@ def main() -> None:
910
1190
  except (KeyError, OSError, TypeError, ValueError, json.JSONDecodeError) as error:
911
1191
  errors.append(f"invalid evidence freeze: {error}")
912
1192
 
913
- tex_files = [path for path in (root / "paper").rglob("*.tex") if path.is_file() and not path.is_symlink()]
1193
+ tex_files = [
1194
+ path
1195
+ for base in (root / "paper", generated_directory(root))
1196
+ if base.is_dir()
1197
+ for path in base.rglob("*.tex")
1198
+ if path.is_file() and not path.is_symlink()
1199
+ ]
914
1200
  tex = "\n".join(path.read_text(encoding="utf-8", errors="replace") for path in tex_files)
915
1201
  todo_count = tex.count(r"\TODO{") + len(re.findall(r"TODO\[", tex))
916
1202
  if todo_count:
@@ -928,20 +1214,19 @@ def main() -> None:
928
1214
  errors.append(margin_error)
929
1215
  if r"\tableofcontents" in content:
930
1216
  errors.append("CUMCM paper must not contain a table of contents")
931
- if bool(ai_profile.get("used")):
932
- if bool(ai_profile.get("inline_markers_required")) and tex.count(r"\AIUseMark") < 2:
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}")
1217
+ if isinstance(ai_profile, dict):
1218
+ errors.extend(ai_declaration_errors(root, main_tex, ai_profile))
938
1219
 
939
1220
  if bool(paper_profile.get("include_support_file_list")):
940
- support_tex = root / "paper" / "sections" / "support-files.tex"
1221
+ support_tex = generated_directory(root) / "support-files.tex"
1222
+ if not support_tex.is_file():
1223
+ support_tex = root / "paper" / "sections" / "support-files.tex"
941
1224
  if not support_tex.is_file() or "支撑材料文件列表" not in support_tex.read_text(encoding="utf-8", errors="replace"):
942
1225
  errors.append("CUMCM appendix is missing the required support-material file list")
943
1226
  if bool(paper_profile.get("include_source_appendix")):
944
- source_tex = root / "paper" / "sections" / "source-code.tex"
1227
+ source_tex = generated_directory(root) / "source-code.tex"
1228
+ if not source_tex.is_file():
1229
+ source_tex = root / "paper" / "sections" / "source-code.tex"
945
1230
  if not source_tex.is_file() or r"\lstinputlisting" not in source_tex.read_text(encoding="utf-8", errors="replace"):
946
1231
  errors.append("CUMCM appendix is missing complete runnable source listings")
947
1232
 
@@ -970,12 +1255,20 @@ def main() -> None:
970
1255
  except (IndexError, OSError, PdfReadError, ValueError) as error:
971
1256
  warnings.append(f"could not verify CUMCM first-page content: {error}")
972
1257
 
973
- archive = root / "paper" / "support-materials.zip"
1258
+ archive = root / "paper" / "支撑材料.zip"
1259
+ legacy_archive_used = False
1260
+ if not archive.is_file():
1261
+ legacy_archive = root / "paper" / "support-materials.zip"
1262
+ if legacy_archive.is_file():
1263
+ archive = legacy_archive
1264
+ legacy_archive_used = True
974
1265
  if not archive.is_file():
975
- warnings.append("support-materials.zip is missing; run package_support.py")
1266
+ warnings.append("支撑材料.zip is missing; run package_support.py")
976
1267
  else:
977
1268
  if archive_limit is not None and archive.stat().st_size > archive_limit * 1024 * 1024:
978
- errors.append(f"support-materials.zip exceeds active {archive_limit:g} MB limit")
1269
+ errors.append(
1270
+ f"{archive.name} exceeds active {archive_limit:g} MB limit"
1271
+ )
979
1272
  try:
980
1273
  with zipfile.ZipFile(archive) as bundle:
981
1274
  names = [name for name in bundle.namelist() if not name.endswith("/")]
@@ -984,13 +1277,23 @@ def main() -> None:
984
1277
  errors.append("support archive contains unsafe absolute/traversal paths")
985
1278
  if any(name.replace("\\", "/").lower().startswith("question/") for name in names):
986
1279
  errors.append("support archive contains immutable question input files")
987
- if "paper/ai-use-log.md" in names and not bool(support_profile.get("include_ai_log")):
988
- errors.append("support archive leaks internal ai-use-log.md contrary to profile")
989
- if "paper/evidence-freeze.json" not in names:
990
- errors.append("support archive is missing paper/evidence-freeze.json")
991
- if bool(ai_profile.get("used")) and bool(ai_profile.get("details_pdf_required")) and "paper/AI工具使用详情.pdf" not in names:
1280
+ 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")):
1281
+ errors.append("support archive leaks the internal AI use log contrary to profile")
1282
+ expected_ai_name = (
1283
+ "paper/AI工具使用详情.pdf"
1284
+ if legacy_archive_used
1285
+ else "AI工具使用详情.pdf"
1286
+ )
1287
+ if bool(ai_profile.get("used")) and bool(ai_profile.get("details_pdf_required")) and expected_ai_name not in names:
992
1288
  errors.append("support archive is missing required AI工具使用详情.pdf")
993
1289
  expected_names = expected_support_names(root, ai_profile, support_profile)
1290
+ if legacy_archive_used:
1291
+ if "AI工具使用详情.pdf" in expected_names:
1292
+ expected_names.remove("AI工具使用详情.pdf")
1293
+ expected_names.add("paper/AI工具使用详情.pdf")
1294
+ legacy_freeze = root / "paper" / "evidence-freeze.json"
1295
+ if legacy_freeze.is_file():
1296
+ expected_names.add("paper/evidence-freeze.json")
994
1297
  actual_names = set(names)
995
1298
  missing_names = sorted(expected_names - actual_names)
996
1299
  extra_names = sorted(actual_names - expected_names)
@@ -999,9 +1302,11 @@ def main() -> None:
999
1302
  if extra_names:
1000
1303
  errors.append("support archive contains unlisted project files: " + ", ".join(extra_names[:12]))
1001
1304
  except zipfile.BadZipFile:
1002
- errors.append("paper/support-materials.zip is not a valid ZIP archive")
1305
+ errors.append(f"{archive.relative_to(root)} is not a valid ZIP archive")
1003
1306
 
1004
- aux = root / "paper" / "build" / "main.aux"
1307
+ aux = build_directory(root) / "main.aux"
1308
+ if not aux.is_file():
1309
+ aux = root / "paper" / "build" / "main.aux"
1005
1310
  if page_limit is not None and aux.is_file():
1006
1311
  match = re.search(r"\\newlabel\{body-end\}\{\{.*?\}\{(\d+)\}", aux.read_text(encoding="utf-8", errors="replace"))
1007
1312
  if match:
@@ -1014,17 +1319,29 @@ def main() -> None:
1014
1319
  warnings.append("could not resolve body-end page label")
1015
1320
 
1016
1321
  if bool(ai_profile.get("used")):
1017
- disclosure = root / "paper" / "ai-use-log.md"
1322
+ disclosure = control_path(
1323
+ root,
1324
+ "ai-use-log.md",
1325
+ root / "paper" / "ai-use-log.md",
1326
+ )
1018
1327
  if not disclosure.is_file():
1019
1328
  warnings.append("internal AI use log is missing")
1020
1329
  if bool(ai_profile.get("details_pdf_required")) and not (root / "paper" / "AI工具使用详情.pdf").is_file():
1021
1330
  errors.append("AI tool disclosure PDF is required but missing")
1022
1331
  details_source = root / "paper" / "AI工具使用详情.tex"
1023
- if bool(ai_profile.get("details_pdf_required")) and (
1024
- not details_source.is_file()
1025
- or "关键交互记录" not in details_source.read_text(encoding="utf-8", errors="replace")
1026
- ):
1027
- errors.append("AI details source must include key prompt-and-response interactions")
1332
+ if bool(ai_profile.get("details_pdf_required")):
1333
+ details_text = (
1334
+ details_source.read_text(encoding="utf-8", errors="replace")
1335
+ if details_source.is_file()
1336
+ else ""
1337
+ )
1338
+ required_sections = ("主要提示方式与过程", "采纳、人工修改与核验")
1339
+ if not details_source.is_file() or any(
1340
+ section not in details_text for section in required_sections
1341
+ ):
1342
+ errors.append(
1343
+ "AI details source must cover prompting/usage process and adoption/manual verification"
1344
+ )
1028
1345
 
1029
1346
  print(f"[RUN] Validation summary: {len(errors)} error(s), {len(warnings)} warning(s)")
1030
1347
  for message in errors:
@@ -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
@@ -1,24 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pathlib import Path
4
- from typing import Iterable
5
-
6
- import pandas as pd
7
-
8
- from always.config import QUESTION_DIR
9
-
10
-
11
- def input_files(suffixes: Iterable[str]) -> list[Path]:
12
- # 统一转为小写,兼容 Windows 数据文件的大小写后缀。
13
- normalized = {suffix.lower() for suffix in suffixes}
14
- return sorted(
15
- path
16
- for path in QUESTION_DIR.rglob("*")
17
- if path.is_file() and path.suffix.lower() in normalized
18
- )
19
-
20
-
21
- def require_columns(frame: pd.DataFrame, columns: Iterable[str]) -> None:
22
- missing = sorted(set(columns) - set(frame.columns))
23
- if missing:
24
- raise ValueError(f"Missing required columns: {missing}")