Skip to content

Lucasuiii/modeling-workbench / .agents/skills/cumcm-workflow

cumcm-workflow

Verified

Build or resume mathematical-modeling competition work, including CUMCM, MCM/ICM, graduate and regional contests, data challenges, and open-topic statistical modeling. Guide problem framing, modeling, computation, validation, Chinese or English LaTeX writing, and reviewed PDF/source delivery using current official requirements. Not for ordinary paper polishing.

FileKindSize
SKILL.mdskill md9.0 KB
agents/openai.yamlconfig427 B
assets/latex-template/generic-ctex/macros.texother859 B
assets/latex-template/generic-ctex/main.tex.tmplother2.5 KB
assets/latex-template/generic-ctex/metadata.tex.tmplother272 B
assets/latex-template/generic-ctex/planned-section.tex.tmplother1.0 KB
assets/latex-template/generic-ctex/references.bibother155 B
assets/latex-template/generic-ctex/sections/00_abstract.texother935 B
assets/latex-template/generic-ctex/sections/98_references.texother221 B
assets/latex-template/generic-ctex/sections/99_appendix.texother264 B
assets/latex-template/generic-ctex/template.jsonconfig304 B
assets/latex-template/generic-en/macros.texother868 B
assets/latex-template/generic-en/main.tex.tmplother2.2 KB
assets/latex-template/generic-en/metadata.tex.tmplother278 B
assets/latex-template/generic-en/planned-section.tex.tmplother1013 B
assets/latex-template/generic-en/references.bibother155 B
assets/latex-template/generic-en/sections/00_abstract.texother454 B
assets/latex-template/generic-en/sections/98_references.texother201 B
assets/latex-template/generic-en/sections/99_appendix.texother240 B
assets/latex-template/generic-en/template.jsonconfig249 B
assets/latex-template/huawei-ctex/main.tex.tmplother3.3 KB
assets/latex-template/huawei-ctex/template.jsonconfig276 B
assets/plot-style/cumcm.mplstyleother953 B
references/01-intake.mdmarkdown3.9 KB
references/02-problem-analysis.mdmarkdown2.8 KB
references/03-model-design.mdmarkdown7.6 KB
references/04-computation.mdmarkdown13.4 KB
references/05-validation.mdmarkdown5.9 KB
references/06-paper-writing.mdmarkdown14.3 KB
references/07-compile-delivery.mdmarkdown6.1 KB
references/artifact-contracts.mdmarkdown3.1 KB
references/competition-adaptation.mdmarkdown6.8 KB
references/competition-writing.mdmarkdown5.6 KB
references/diagnostics.mdmarkdown4.5 KB
references/evidence-rules.mdmarkdown1.6 KB
references/handoffs.mdmarkdown3.5 KB
references/huawei-delivery.mdmarkdown10.1 KB
references/latex-template.mdmarkdown6.2 KB
references/mechanism-validation.mdmarkdown11.6 KB
references/open-topic-research.mdmarkdown4.9 KB
references/task-driven-modeling.mdmarkdown7.2 KB
schemas/claim-ledger.schema.jsonconfig5.5 KB
schemas/common.schema.jsonconfig2.5 KB
schemas/compile-receipt.schema.jsonconfig3.7 KB
schemas/cross-question-ledger.schema.jsonconfig1.3 KB
schemas/delivery-manifest.schema.jsonconfig7.9 KB
schemas/figure-manifest.schema.jsonconfig1.9 KB
schemas/handoff.schema.jsonconfig2.1 KB
schemas/independent-review-package.schema.jsonconfig3.4 KB
schemas/independent-review-result.schema.jsonconfig4.0 KB
schemas/latex-template-manifest.schema.jsonconfig2.4 KB
schemas/model-contract.schema.jsonconfig5.0 KB
schemas/paper-plan.schema.jsonconfig3.3 KB
schemas/paper-quality-report.schema.jsonconfig5.7 KB
schemas/paper-revision-log.schema.jsonconfig2.2 KB
schemas/paper-visible-text-report.schema.jsonconfig1.6 KB
schemas/problem-facts.schema.jsonconfig1.7 KB
schemas/results-index.schema.jsonconfig1.4 KB
schemas/run-manifest.schema.jsonconfig7.1 KB
schemas/source-manifest.schema.jsonconfig1.9 KB
schemas/task-capabilities.schema.jsonconfig3.9 KB
schemas/workflow-state.schema.jsonconfig2.4 KB
scripts/backend_selection.pyscript6.3 KB
scripts/build_handoff.pyscript20.4 KB
scripts/build_independent_review_package.pyscript14.9 KB
scripts/canonical_evidence.pyscript8.4 KB
scripts/compile_sources.pyscript2.4 KB
scripts/cumcm_check.pyscript2.9 KB
scripts/delivery_archives.pyscript7.0 KB
scripts/doctor.pyscript7.5 KB
scripts/index_result.pyscript10.9 KB
scripts/init_latex_paper.pyscript17.2 KB
scripts/init_project.pyscript11.1 KB
scripts/inventory_artifacts.pyscript4.1 KB
scripts/json_pointer.pyscript1.0 KB
scripts/official_materials.pyscript3.0 KB
scripts/paper_visible_text_check.pyscript5.4 KB
scripts/plan_redo.pyscript18.8 KB
scripts/project_status.pyscript5.8 KB
scripts/provenance.pyscript2.2 KB
scripts/record_compile.pyscript13.2 KB
scripts/record_decision.pyscript12.0 KB
scripts/record_run.pyscript28.1 KB
scripts/refresh_evidence.pyscript4.7 KB
scripts/set_mode.pyscript2.0 KB
scripts/submission_check.pyscript10.6 KB
scripts/workflow_checks.pyscript146.0 KB

scripts/submission_check.py

View on GitHub
#!/usr/bin/env python3
"""Measure contest submission files using project-declared current official rules.

The receipt is part of DELIVERY_MANIFEST, never an assertion of visual compliance
or a receipt from the organizer. Recording does not submit anything.
"""
from __future__ import annotations

import argparse
import hashlib
import json
import re
import subprocess
import zipfile
import unicodedata
from pathlib import Path

from official_materials import classified_official_materials
from refresh_evidence import write_atomic

MANIFEST = "delivery/DELIVERY_MANIFEST.json"


def local_file(root: Path, value: str) -> Path:
    if not isinstance(value, str) or not value or Path(value).is_absolute():
        raise ValueError("submission paths must be project-relative")
    path = (root / value).resolve()
    if not path.is_relative_to(root.resolve()) or not path.is_file():
        raise ValueError(f"missing or unsafe submission file: {value}")
    return path


def measure(root: Path, value: str) -> dict:
    path = local_file(root, value)
    sha = hashlib.sha256()
    md5 = hashlib.md5(usedforsecurity=False)
    size = 0
    with path.open("rb") as stream:
        for chunk in iter(lambda: stream.read(1024 * 1024), b""):
            sha.update(chunk)
            md5.update(chunk)
            size += len(chunk)
    if not size:
        raise ValueError(f"empty submission file: {value}")
    return {"path": value, "sha256": sha.hexdigest(), "md5": md5.hexdigest(), "size": size}


def run_tool(argv: list[str]) -> str:
    try:
        return subprocess.run(argv, check=True, capture_output=True, text=True,
                              encoding="utf-8", errors="strict", timeout=60).stdout
    except (OSError, subprocess.SubprocessError, UnicodeError) as exc:
        raise ValueError(f"PDF inspection failed: {exc}") from exc


def compact(value: str) -> str:
    return re.sub(r"\s+", "", value)


def identity_text(value: str) -> str:
    return compact(unicodedata.normalize("NFKC", value)).casefold()


def positive(value, label: str) -> int:
    if type(value) is not int or value < 1:
        raise ValueError(f"{label} must be a positive integer")
    return value


def inspect_submission(root: Path, delivery: dict) -> tuple[dict, list[str]]:
    """Return measured facts and failures, without changing any file."""
    rules = delivery["submission"]["rules"]
    if not isinstance(rules, dict):
        raise ValueError("submission.rules must be an object")
    source_manifest = json.loads((root / "problem/SOURCE_MANIFEST.json").read_text(encoding="utf-8"))
    official = {item["path"] for item in classified_official_materials(source_manifest.get("sources", []))
                if item["role"] in {"paper_template", "format_or_submission_rule"}}
    sources = rules["sources"]
    if not isinstance(sources, list) or not sources or any(p not in official for p in sources):
        raise ValueError("rules.sources must cite declared official format/submission materials")
    source_records = [measure(root, p) for p in sources]
    pdf_rel = delivery["deliverables"]["final_pdf"]["path"]
    pdf = local_file(root, pdf_rel)
    if pdf.suffix.lower() != ".pdf":
        raise ValueError("final submission must be a PDF")
    before = measure(root, pdf_rel)
    errors = []
    receipt_rel = delivery["compile_receipt_path"]
    receipt = json.loads(local_file(root, receipt_rel).read_text(encoding="utf-8"))
    selected = next((a for a in receipt["attempts"] if a.get("attempt_id") == receipt["selected_attempt_id"]), None)
    if not selected or selected.get("exit_code") != 0:
        raise ValueError("submission requires a selected successful compilation")
    compiled = measure(root, selected["pdf_path"])
    if before["sha256"] != selected.get("pdf_sha256") or compiled["sha256"] != before["sha256"]:
        errors.append("submission PDF bytes differ from the selected compiled PDF")
    if pdf.name != rules["pdf_name"]:
        errors.append("final PDF filename differs from the declared official submission name")
    info = run_tool(["pdfinfo", "-enc", "UTF-8", str(pdf)])
    match = re.search(r"^Pages:\s+(\d+)\s*$", info, re.MULTILINE)
    if not match:
        raise ValueError("pdfinfo did not report page count")
    count = int(match.group(1))
    pages = run_tool(["pdftotext", "-enc", "UTF-8", "-layout", str(pdf), "-"]).split("\f")
    if pages and not pages[-1].strip():
        pages.pop()
    if len(pages) != count or any(not text.strip() for text in pages):
        raise ValueError("PDF has empty or unextractable pages; inspect images/OCR manually before recording")
    cover = positive(rules["cover_pages"], "cover_pages")
    if count <= cover:
        raise ValueError("PDF contains no abstract/body after its cover")
    tokens = rules["identity_tokens"]
    if not isinstance(tokens, list) or not tokens or any(not isinstance(t, str) or not compact(t) for t in tokens):
        raise ValueError("identity_tokens must list the actual non-empty team/person/institution identifiers")
    # XMP and the document information dictionary are both outside the cover.
    metadata = info + run_tool(["pdfinfo", "-enc", "UTF-8", "-meta", str(pdf)])
    for token in tokens:
        if identity_text(token) in identity_text(metadata):
            errors.append("identity information found in PDF metadata")
        for number, page in enumerate(pages[cover:], cover + 1):
            if identity_text(token) in identity_text(page):
                errors.append(f"identity information found outside the cover on page {number}")
    abstract = rules["abstract"]
    maximum = positive(abstract["max_pages"], "abstract.max_pages")
    boundaries = []
    for field in ("start_marker", "body_marker"):
        marker = abstract[field]
        if not isinstance(marker, str) or not compact(marker):
            raise ValueError(f"abstract.{field} must be non-empty")
        hits = [(index, compact(page).find(compact(marker))) for index, page in enumerate(pages)
                if index >= cover and compact(marker) in compact(page)]
        if len(hits) != 1 or compact(pages[hits[0][0]]).count(compact(marker)) != 1:
            raise ValueError(f"abstract.{field} must occur exactly once after the cover")
        boundaries.append(hits[0])
    start, end = boundaries
    if start[0] != cover or end <= start:
        errors.append("abstract/body order differs from cover -> abstract -> body")
    # A body heading may share the last abstract page. Count that page when
    # non-whitespace text precedes the heading; otherwise the abstract ends before it.
    abstract_pages = end[0] - start[0] + (1 if end[1] > 0 else 0)
    if abstract_pages > maximum:
        errors.append(f"abstract occupies {abstract_pages} pages; maximum is {maximum}")
    attachments = rules["attachments"]
    if not isinstance(attachments, list):
        raise ValueError("attachments must be a list (empty when none are to be submitted)")
    measured_attachments = []
    for item in attachments:
        path = local_file(root, item["path"])
        record = measure(root, item["path"])
        measured_attachments.append(record)
        if path.name != item["name"]:
            errors.append(f"attachment filename mismatch: {item['path']}")
        if record["size"] > positive(item["max_bytes"], "attachment.max_bytes"):
            errors.append(f"attachment exceeds byte limit: {item['path']}")
        formats = item["formats"]
        if not isinstance(formats, list) or not formats or any(f not in ("zip", "rar", "7z") for f in formats):
            raise ValueError("attachment formats must name allowed zip/rar/7z containers")
        with path.open("rb") as stream:
            magic = stream.read(8)
        kind = ("zip" if zipfile.is_zipfile(path) else "rar" if magic.startswith((b"Rar!\x1a\x07\x00", b"Rar!\x1a\x07\x01\x00"))
                else "7z" if magic.startswith(b"7z\xbc\xaf\x27\x1c") else None)
        if kind not in formats or path.suffix.lower() != f".{kind}":
            errors.append(f"attachment container/extension not allowed: {item['path']}")
    if before != measure(root, pdf_rel):
        raise ValueError("PDF changed during inspection")
    return {"pdf": before, "rule_files": source_records, "compile_receipt": measure(root, receipt_rel),
            "rules_sha256": hashlib.sha256(json.dumps(rules, sort_keys=True, ensure_ascii=False).encode()).hexdigest(),
            "page_count": count, "abstract_pages": abstract_pages, "attachments": measured_attachments}, errors


def is_huawei(root: Path) -> bool:
    path = root / "paper/LATEX_TEMPLATE_MANIFEST.json"
    if not path.is_file():
        return False
    name = str(json.loads(path.read_text(encoding="utf-8")).get("competition", "")).casefold()
    return any(token in name for token in ("华为", "huawei", "研究生数学建模", "gmcm", "cpgmcm", "cpmcm"))


def check_submission(root: Path, delivery: dict) -> list[str]:
    try:
        if "submission" not in delivery:
            return ["Huawei delivery requires current submission rules and a recorded file check"] if is_huawei(root) else []
        observed, errors = inspect_submission(root, delivery)
        if delivery["submission"].get("recorded") != observed:
            errors.append("submission record is missing or stale; do not reuse a previously submitted MD5")
        return errors
    except (OSError, ValueError, KeyError, TypeError, AttributeError) as exc:
        return [f"cannot verify submission: {exc}"]


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--project", type=Path, required=True)
    parser.add_argument("--record", action="store_true", help="record successful measured checks in the existing delivery manifest")
    args = parser.parse_args()
    root = args.project.resolve()
    try:
        path = root / MANIFEST
        data = json.loads(path.read_text(encoding="utf-8"))
        observed, errors = inspect_submission(root, data)
        old = data["submission"].get("recorded")
        if old is not None and old != observed:
            errors.append("existing submission record differs; stop and resolve the previously frozen/submitted version before replacing it")
        if args.record and not errors:
            if old is None:
                data["submission"]["recorded"] = observed
                write_atomic(path, data)
        print(json.dumps({"observed": observed, "errors": errors,
                          "scope": "file checks only; official layout, completeness of identity tokens and image text require visual review"}, ensure_ascii=False, indent=2))
        return 1 if errors else 0
    except (OSError, ValueError, KeyError, TypeError, AttributeError) as exc:
        parser.error(str(exc))
    return 2


if __name__ == "__main__":
    raise SystemExit(main())
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall