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/canonical_evidence.py

View on GitHub
#!/usr/bin/env python3
"""Resolve the one canonical RESULTS_INDEX -> official run -> source chain.

Every formal consumer -- the computation handoff, the independent review package
and paper->delivery -- goes through here, so "the run behind this result" means
the same thing in all of them, superseded runs included.
"""

from __future__ import annotations

import json
from pathlib import Path
from typing import Any

from provenance import snapshot_matches, sha256_file


def read_object(path: Path) -> dict[str, Any]:
    try:
        value = json.loads(path.read_text(encoding="utf-8"))
    except (OSError, json.JSONDecodeError) as exc:
        raise ValueError(f"cannot read JSON object {path}: {exc}") from exc
    if not isinstance(value, dict):
        raise ValueError(f"expected JSON object: {path}")
    return value


def live_evidence_drift(project: Path, run: dict[str, Any]) -> list[str]:
    """Compare current source/team inputs with their preserved execution bytes.

    Strip only this run's freeze layer: an explicitly historical upstream input
    remains bound to the declared upstream snapshot, not its latest live output.
    """
    project = project.resolve()
    snapshot = (run.get("implementation") or {}).get("source_snapshot") or {}
    frozen_paths = list(snapshot.get("files", []))
    frozen_paths += [e.get("path") for e in run.get("inputs", [])
                     if isinstance(e, dict) and e.get("evidence_role") == "formal_input"]
    drifted = []
    for frozen in frozen_paths:
        if not isinstance(frozen, str):
            continue
        parts = frozen.split("/")
        if len(parts) <= 3 or parts[0] != "runs" or parts[2] not in {"source", "inputs"}:
            continue
        live = "/".join(parts[3:])
        frozen_file, live_file = (project / frozen).resolve(), (project / live).resolve()
        if (not frozen_file.is_relative_to(project) or not live_file.is_relative_to(project)
                or not frozen_file.is_file() or not live_file.is_file()
                or sha256_file(live_file) != sha256_file(frozen_file)):
            drifted.append(live)
    return sorted(set(drifted))


def resolve_official_computation(project: Path, results: dict[str, Any] | None = None) -> list[dict[str, Any]]:
    """Return referenced successful official runs or fail on any broken formal link."""
    project = project.resolve()
    results = results or read_object(project / "results" / "RESULTS_INDEX.json")
    result_items = results.get("results")
    if not isinstance(result_items, list) or not result_items:
        raise ValueError("RESULTS_INDEX.json must contain at least one formal result")

    referenced: set[str] = set()
    for item in result_items:
        if not isinstance(item, dict) or not str(item.get("run_id", "")).strip():
            raise ValueError("every formal result must reference a run_id")
        referenced.add(str(item["run_id"]))

    manifests: dict[str, tuple[str, dict[str, Any]]] = {}
    superseded: set[str] = set()
    for manifest_path in sorted((project / "runs").glob("*/RUN_MANIFEST.json")):
        rel = manifest_path.relative_to(project).as_posix()
        run = read_object(manifest_path)
        run_id = str(run.get("run_id", "")).strip()
        if not run_id:
            continue
        if run_id in manifests:
            raise ValueError(f"duplicate run_id in RUN_MANIFEST files: {run_id}")
        manifests[run_id] = (rel, run)
        # Same rule the checker uses: only a successful official run retires its parent.
        parent = str(run.get("parent_run_id", "")).strip()
        if parent and parent != run_id and run.get("official_run") is True and run.get("status") == "completed" and run.get("exit_code") == 0:
            superseded.add(parent)

    resolved: list[dict[str, Any]] = []
    for run_id in sorted(referenced):
        candidate = manifests.get(run_id)
        if candidate is None:
            raise ValueError(f"formal result references a missing run: {run_id}")
        manifest_path, run = candidate
        if run.get("official_run") is not True or run.get("status") != "completed" or run.get("exit_code") != 0:
            raise ValueError(f"formal result references a run that is not a successful official run: {run_id}")
        if run_id in superseded:
            raise ValueError(
                f"formal result references {run_id}, which a later official run superseded; "
                "re-point it with index_result.py --follow-lineage"
            )
        implementation = run.get("implementation") if isinstance(run.get("implementation"), dict) else {}
        snapshot = implementation.get("source_snapshot")
        if not snapshot_matches(project, snapshot):
            raise ValueError(f"formal result references an official run with a missing or stale source snapshot: {run_id}")

        # All formal files matter, including inputs not directly used by a locator.
        for collection, role in (("inputs", "formal_input"), ("outputs", "claim_bearing_output")):
            entries = run.get(collection, [])
            if not isinstance(entries, list):
                raise ValueError(f"invalid {collection} in official run {run_id}")
            for entry in entries:
                if not isinstance(entry, dict):
                    raise ValueError(f"invalid file record in official run {run_id}")
                if entry.get("evidence_role") != role:
                    continue
                rel = entry.get("path")
                if not isinstance(rel, str) or not rel or Path(rel).is_absolute():
                    raise ValueError(f"formal file integrity: invalid path in {run_id}")
                target = (project / rel).resolve()
                try:
                    target.relative_to(project)
                    valid = target.is_file() and sha256_file(target) == entry.get("sha256")
                except (ValueError, OSError):
                    valid = False
                if not valid:
                    raise ValueError(f"formal file SHA256 integrity failure in {run_id}: {rel}")

        drifted = live_evidence_drift(project, run)
        if drifted:
            raise ValueError(f"current official evidence is stale in {run_id}; rerun required: {', '.join(drifted)}")

        output_roles = {
            str(entry.get("path")): entry.get("evidence_role")
            for entry in run.get("outputs", [])
            if isinstance(entry, dict) and entry.get("path")
        }
        for result in result_items:
            if not isinstance(result, dict) or str(result.get("run_id")) != run_id:
                continue
            locator = str(result.get("output_locator", ""))
            output_path = locator.split("#", 1)[0] if "#" in locator else ""
            if not output_path or output_roles.get(output_path) != "claim_bearing_output":
                raise ValueError(
                    f"formal result does not locate a claim-bearing output of official run {run_id}: "
                    f"{result.get('result_id')}"
                )

            from json_pointer import resolve_json_pointer
            pointer = locator.split("#", 1)[1]
            try:
                output = json.loads((project / output_path).read_text(encoding="utf-8"))
            except (OSError, ValueError) as exc:
                raise ValueError(f"cannot read formal result output: {output_path}") from exc
            actual_value, found = resolve_json_pointer(output, pointer)
            if not found:
                raise ValueError(f"formal result JSON pointer does not resolve: {locator}")
            if "value" in result and result["value"] != actual_value:
                raise ValueError(f"formal result value differs from frozen output: {locator}")

        resolved.append(
            {
                "run_id": run_id,
                "manifest_path": manifest_path,
                "manifest": run,
                "source_snapshot": snapshot,
                "source_files": [str(path) for path in snapshot.get("files", [])],
                "formal_inputs": [
                    str(entry.get("path"))
                    for entry in run.get("inputs", [])
                    if isinstance(entry, dict) and entry.get("evidence_role") == "formal_input"
                ],
                "claim_bearing_outputs": [
                    str(entry.get("path"))
                    for entry in run.get("outputs", [])
                    if isinstance(entry, dict) and entry.get("evidence_role") == "claim_bearing_output"
                ],
            }
        )
    return resolved
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