Lucasuiii/modeling-workbench / .agents/skills/cumcm-workflow
cumcm-workflow
VerifiedBuild 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.
scripts/refresh_evidence.py
View on GitHub#!/usr/bin/env python3
"""Recompute the size/hash metadata that used to be maintained by hand.
This only refreshes observed facts about files that already exist. It never adds,
removes or re-roles an artifact, and it never touches an official source's
declared origin -- an official hash mismatch stays a finding for a human.
"""
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
from provenance import sha256_file
TARGETS = {
"figures": "figures/FIGURE_MANIFEST.json",
"delivery": "delivery/DELIVERY_MANIFEST.json",
}
def utc_now() -> str:
return datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
def write_atomic(path: Path, payload: dict[str, Any]) -> None:
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 refresh_entries(root: Path, entries: list[Any], *, hash_key: str = "sha256", only_existing_hash: bool = False) -> int:
root = root.resolve()
changed = 0
for entry in entries:
if not isinstance(entry, dict) or not isinstance(entry.get("path"), str):
continue
declared = entry["path"]
target = (root / declared).resolve() if not Path(declared).is_absolute() else Path(declared).resolve()
if not target.is_relative_to(root):
raise ValueError(f"manifest path resolves outside project: {declared}")
if not target.is_file():
continue
if only_existing_hash and not entry.get(hash_key):
continue
digest = sha256_file(target)
size = target.stat().st_size
if entry.get(hash_key) != digest or entry.get("size") != size:
changed += 1
entry[hash_key] = digest
entry["size"] = size
return changed
def main() -> int:
parser = argparse.ArgumentParser(description="Refresh size/hash metadata for files already declared in the workspace")
parser.add_argument("--project", required=True, type=Path)
parser.add_argument("--package", action="store_true", help="build ZIPs from existing delivery/LaTeX/result declarations, preserving directories")
parser.add_argument("--only", choices=sorted(TARGETS), help="refresh only this existing manifest; official sources are never refreshed")
parser.add_argument("--runs", action="store_true", help="also refresh run manifest input/output metadata")
args = parser.parse_args()
root = args.project.resolve()
if not root.is_dir():
parser.error(f"project is not a directory: {root}")
if args.package:
if args.only and args.only != "delivery":
parser.error("--package updates delivery; use --only delivery or omit --only")
from delivery_archives import build_archives
build_archives(root, json.loads((root / TARGETS["delivery"]).read_text(encoding="utf-8")))
total = 0
for name, rel in TARGETS.items():
if args.only and name != args.only:
continue
path = root / rel
if not path.is_file():
continue
data = json.loads(path.read_text(encoding="utf-8"))
entries = data.get("figures" if name == "figures" else "files", [])
changed = refresh_entries(root, entries, only_existing_hash=(name != "delivery"))
if changed:
total += changed
data["updated_at"] = utc_now()
write_atomic(path, data)
print(f"refreshed {rel}")
else:
print(f"unchanged {rel}")
if args.runs:
for manifest_path in sorted((root / "runs").glob("*/RUN_MANIFEST.json")):
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
if manifest.get("official_run") is True:
# An official run's hashes describe a preserved execution. Rewriting them
# would erase exactly the drift the checker exists to catch.
print(f"skipped official run {manifest.get('run_id')}; re-record it with record_run.py --rerun instead")
continue
changed = refresh_entries(root, manifest.get("inputs", []), only_existing_hash=True)
changed += refresh_entries(root, manifest.get("outputs", []), only_existing_hash=True)
if changed:
total += changed
manifest["updated_at"] = utc_now()
write_atomic(manifest_path, manifest)
print(f"refreshed {manifest_path.relative_to(root)}")
print(f"{total} metadata field group(s) updated")
return 0
if __name__ == "__main__":
raise SystemExit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |