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

View on GitHub
#!/usr/bin/env python3
"""Index a formal result by reading its value out of the executed output.

The value is never transcribed by hand: it is resolved through the same
`path#/json-pointer` locator the checker will later re-resolve, so RESULT-E012
(indexed value differs from executed output) becomes structurally impossible.
"""

from __future__ import annotations

import argparse
import json
import os
import tempfile
from datetime import datetime, timezone
from pathlib import Path
from typing import Any

WORKFLOW_VERSION = "0.6.0"
EVIDENCE_STATES = (
    "not_checked", "missing_evidence", "supported_not_reproduced", "reproduced",
    "partially_supported", "contradicted", "ambiguous", "not_applicable",
)


def utc_now() -> str:
    return datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")


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 SystemExit(f"cannot read {path}: {exc}")
    if not isinstance(value, dict):
        raise SystemExit(f"expected a JSON object: {path}")
    return value


def resolve_pointer(data: Any, pointer: str) -> Any:
    from json_pointer import resolve_json_pointer
    value, found = resolve_json_pointer(data, pointer)
    if not found:
        raise SystemExit(f"JSON pointer does not resolve: {pointer}")
    return value


def all_runs(root: Path) -> dict[str, dict[str, Any]]:
    runs: dict[str, dict[str, Any]] = {}
    for manifest_path in sorted((root / "runs").glob("*/RUN_MANIFEST.json")):
        manifest = read_object(manifest_path)
        run_id = str(manifest.get("run_id", "")).strip()
        if run_id:
            runs[run_id] = manifest
    return runs


def successful_official(manifest: dict[str, Any]) -> bool:
    return manifest.get("official_run") is True and manifest.get("status") == "completed" and manifest.get("exit_code") == 0


def newest_descendant(runs: dict[str, dict[str, Any]], run_id: str) -> str:
    """Walk parent links forward through successful official runs only.

    A failed or exploratory rerun replaces nothing. Multiple successful official
    children are ambiguous; the caller must choose a branch explicitly.
    """
    children: dict[str, list[str]] = {}
    for rid, manifest in runs.items():
        parent = str(manifest.get("parent_run_id", "")).strip()
        if parent and parent != rid and successful_official(manifest):
            children.setdefault(parent, []).append(rid)
    seen = {run_id}
    current = run_id
    while current in children:
        candidates = sorted(children[current], key=lambda rid: (str(runs[rid].get("finished_at", "")), rid))
        if len(candidates) > 1:
            # Two successful official reruns of the same parent is a fork, not a chain.
            # Both superseded it, and which one the result should follow is a judgement
            # about the work; guessing "newest" would quietly re-point evidence at a
            # branch nobody chose.
            raise ValueError(
                f"lineage from {current} is ambiguous: {', '.join(candidates)} all supersede it; "
                "name the run you mean with --run-id instead of --follow-lineage"
            )
        current = candidates[0]
        if current in seen:
            break
        seen.add(current)
    return current


def frozen_locator(manifest: dict[str, Any], run_id: str, locator: str) -> str:
    """Accept the path the program writes to and store the immutable frozen copy."""
    rel, _, pointer = locator.partition("#")
    roles = {str(entry.get("path")): entry.get("evidence_role") for entry in manifest.get("outputs", []) if isinstance(entry, dict)}
    if roles.get(rel) == "claim_bearing_output":
        return locator
    candidate = f"runs/{run_id}/outputs/{rel}"
    if roles.get(candidate) == "claim_bearing_output":
        return f"{candidate}#{pointer}"
    return locator


def find_run(root: Path, run_id: str) -> dict[str, Any]:
    for manifest_path in sorted((root / "runs").glob("*/RUN_MANIFEST.json")):
        manifest = read_object(manifest_path)
        if str(manifest.get("run_id")) == run_id:
            return manifest
    raise SystemExit(f"no run manifest declares run_id {run_id}")


def write_atomic(path: Path, payload: dict[str, Any]) -> None:
    path.parent.mkdir(parents=True, exist_ok=True)
    with tempfile.NamedTemporaryFile("w", encoding="utf-8", dir=path.parent, delete=False) as stream:
        json.dump(payload, stream, ensure_ascii=False, indent=2)
        stream.write("\n")
        temp_name = stream.name
    os.replace(temp_name, path)


def current_value(root: Path, item: dict[str, Any]) -> Any:
    from canonical_evidence import resolve_official_computation
    try:
        # Recompute the value while retaining every evidence/path check.
        probe = {key: value for key, value in item.items() if key != "value"}
        resolve_official_computation(root, {"results": [probe]})
        rel, pointer = item["output_locator"].split("#", 1)
        return resolve_pointer(json.loads((root / rel).read_text(encoding="utf-8")), pointer)
    except (OSError, ValueError, KeyError) as exc:
        raise SystemExit(str(exc)) from exc


def main() -> int:
    parser = argparse.ArgumentParser(description="Add or refresh one entry in results/RESULTS_INDEX.json")
    parser.add_argument("--project", required=True, type=Path)
    parser.add_argument("--result-id")
    parser.add_argument("--run")
    parser.add_argument("--locator", help="project-relative path#/json-pointer into a claim-bearing output")
    parser.add_argument("--name")
    parser.add_argument("--unit", default="")
    parser.add_argument("--scope")
    parser.add_argument("--precision")
    parser.add_argument("--display-rounding", type=int)
    parser.add_argument("--check", action="append", default=[], help="validation check name; repeat as needed")
    parser.add_argument("--evidence-state", choices=EVIDENCE_STATES, default="supported_not_reproduced")
    parser.add_argument("--supersedes")
    parser.add_argument("--remove", help="drop this result_id from the index")
    parser.add_argument("--refresh", action="store_true", help="re-resolve every indexed value from its locator")
    parser.add_argument("--follow-lineage", action="store_true", help="re-point every result at the run that superseded the one it cites")
    args = parser.parse_args()

    root = args.project.resolve()
    if not root.is_dir():
        parser.error(f"project is not a directory: {root}")
    index_path = root / "results" / "RESULTS_INDEX.json"
    if index_path.is_file():
        index = read_object(index_path)
    else:
        index = {
            "schema_version": WORKFLOW_VERSION,
            "artifact_type": "results_index",
            "project_id": read_object(root / ".cumcm" / "state.json")["project_id"],
            "updated_at": utc_now(),
            "producer": {"kind": "script", "name": "index_result.py", "version": WORKFLOW_VERSION},
            "results": [],
        }
    results = [item for item in index.get("results", []) if isinstance(item, dict)]

    if args.remove:
        remaining = [item for item in results if str(item.get("result_id")) != args.remove]
        if len(remaining) == len(results):
            parser.error(f"no such result: {args.remove}")
        if not remaining:
            parser.error("cannot remove the last formal result; index must remain nonempty")
        results = remaining
    elif args.follow_lineage:
        runs = all_runs(root)
        moved = 0
        for item in results:
            current = str(item.get("run_id", ""))
            newest = newest_descendant(runs, current)
            if newest == current:
                current_value(root, item)
                continue
            manifest = runs[newest]
            locator = str(item.get("output_locator", ""))
            live = locator.partition("#")[0]
            for prefix in (f"runs/{current}/outputs/",):
                if live.startswith(prefix):
                    live = live[len(prefix):]
            item["run_id"] = newest
            item["output_locator"] = frozen_locator(manifest, newest, f"{live}#{locator.partition('#')[2]}")
            rel, _, pointer = item["output_locator"].partition("#")
            item["value"] = current_value(root, item)
            moved += 1
            print(f"{item['result_id']}: {current} -> {newest}")
        if not moved:
            print("no indexed result cites a superseded run")
    elif args.refresh:
        for item in results:
            locator = str(item.get("output_locator", ""))
            rel, _, pointer = locator.partition("#")
            item["value"] = current_value(root, item)
    else:
        for required in ("result_id", "run", "locator", "name", "scope"):
            if not getattr(args, required.replace("-", "_")):
                parser.error(f"--{required.replace('_', '-')} is required when indexing a result")
        if "#" not in args.locator:
            parser.error("--locator must be path#/json-pointer")
        manifest = find_run(root, args.run)
        if manifest.get("official_run") is not True or manifest.get("exit_code") != 0 or manifest.get("status") != "completed":
            parser.error(f"{args.run} is not a successful official run; re-record it with record_run.py --official")
        roles = {str(entry.get("path")): entry.get("evidence_role") for entry in manifest.get("outputs", []) if isinstance(entry, dict)}
        probe = frozen_locator(manifest, args.run, args.locator).partition("#")[0]
        if roles.get(probe) != "claim_bearing_output":
            parser.error(f"{args.locator.partition('#')[0]} is not a claim-bearing output of {args.run}")
        locator = frozen_locator(manifest, args.run, args.locator)
        rel, _, pointer = locator.partition("#")
        if locator != args.locator:
            print(f"locator points at the frozen copy: {locator}")
        value = current_value(root, {"run_id": args.run, "output_locator": locator})
        entry = {
            "result_id": args.result_id,
            "name": args.name,
            "value": value,
            "unit": args.unit,
            "precision": args.precision,
            "display_rounding": args.display_rounding,
            "run_id": args.run,
            "output_locator": locator,
            "scope": args.scope,
            "evidence_state": args.evidence_state,
            "validation_checks": args.check,
            "supersedes": args.supersedes,
        }
        results = [item for item in results if str(item.get("result_id")) != args.result_id] + [entry]

    if not results:
        parser.error("index must contain at least one formal result")
    index["results"] = sorted(results, key=lambda item: str(item.get("result_id")))
    index["updated_at"] = utc_now()
    index["schema_version"] = WORKFLOW_VERSION
    write_atomic(index_path, index)
    print(f"results indexed: {len(index['results'])} -> {index_path.relative_to(root)}")
    return 0


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