SuperAPI AI Directory

model-code-and-result-generator

General & other

View repository

Updated 10-16 07:23

About this skill

Modeling code and result evidence generator

Global workflow collaboration constraints (long-conversation drift prevention)

  • This skill must not be used as an isolated entry point. When the user requests a complete paper, Word generation, continuation of the workflow, or the stage is uncertain, first return to paper-workflow-orchestrator to determine the current S0-S8 stage.
  • Before starting or continuing a formal task of this skill, you must run:
    python .claude/skills/paper-workflow-orchestrator/scripts/workflow_guard.py --skill model-code-and-result-generator
    
  • If the output is [WORKFLOW FAIL] or status != "PASS" is reported, stop this skill and, according to status != "PASS"'s failed items, backfill the prerequisite stages; do not continue from memory. paper_output/qa/workflow_guard_report.json 's failed items, backfill the prerequisite stages; do not continue from memory.
  • This skill only writes the paper_output/ artifacts within its own contract scope; after completion, you must return to paper-workflow-orchestrator to determine the next step, and use context-memory-keeper to record completed artifacts, blockers and the next step.
  • In a long conversation, if the context grows long, the stage is uncertain, or the user invokes skills separately, first run:
    python .claude/skills/paper-workflow-orchestrator/scripts/workflow_guard.py --status
    
    then read paper_output/qa/workflow_guard_report.json、paper_output/preflight_report.json、paper_output/input_manifest.json、paper_output/results/run_manifest.json and this skill's upstream JSON contract, and continue according to the recommended_skill and next_action in the report.
  • Before continuing the workflow, you must treat paper_output/context/workflow_memory.json as a long-term checkpoint record; if its current_step、next_step、recommended_skill and workflow_guard.py --status are inconsistent, the guard report prevails.
  • Each time you complete this skill's artifacts, first return to paper-workflow-orchestrator or run workflow_guard.py --status, then update workflow memory:
    python .claude/skills/context-memory-keeper/scripts/update_workflow_memory.py
    
    after updating, read paper_output/context/workflow_memory.json / .mdto confirm that the next step and recommended skill have been recorded.

Objective

This skill is not an all-purpose automatic modeling system. Its role is to give the Agent a stable "result evidence layer" and a runnable starting point for competition-problem-specific modeling code, so that the main text is not written emptily based only on the model route, and the Agent does not flounder aimlessly when faced with data.

In a real competition problem, the Agent must, based on model_route.json, the data fields, the problem constraints and the scoring requirements, modify the generated q*_model.pya second time. The generated code is placed fixedly in paper_output/code/modeling/; do not write it back to the skill package's scripts/。

Execution contract

  • Upstream input: preferentially read paper_output/plan/model_route.json、data_plan.json、visualization_plan.json, and scan paper_output/data_cleaned/。
  • Must output:paper_output/results/model_results.json、metrics.json、conclusions.json、run_manifest.json、paper_output/tables/table_index.json、paper_output/tables/*.csv。
  • Modeling code output:paper_output/code/modeling/result_contract_io.py、run_modeling.py、q1_model.py、q2_model.py、q3_model.py or the question_id corresponding to q*_model.py。
  • Downstream handoff:quality-assurance-auditor directly audits results, metrics, tables, charts and conclusions; after the evidence gate PASSes, paper-formal-writer constructs the formal writing plan.
  • Failure fallback: if there is no cleaned data or real modeling code, still generate the contract skeleton and use needs_real_modeling to mark it; do not disguise it as a final competition result.

Script

  • scripts/build_result_contracts.py
    • When to use: when a model route already exists and you need to generate the result contract, table index and the current problem's q1/q2/q3 modeling code scaffold.
    • What it does: scan model_route.json 's every question_id, generate the result contract skeleton, basic field profile table,paper_output/code/modeling/README.md, and generate runnable q*_model.py。
    • Overwrite rules: generated files carry a managed marker; if the Agent has already manually rewritten a file and removed the marker, this script will keep the user's file and not overwrite it.
  • scripts/result_contract_templates.py
    • When to use: when you need to understand which metrics, tables, and conclusion fields should be produced for different task types.
    • What it does: provides contract templates for forecasting, optimization, evaluation, classification, clustering, simulation, and general modeling.

Task type dispatch

  • Forecasting/regression/time series -> forecasting scaffold: generates target column, feature columns, predicted values, residuals, RMSE, MAE, MAPE.
  • Optimization/planning/scheduling/site selection/routing -> optimization scaffold: generates surrogate objective function, solution ranking, and constraint satisfaction rate items to be filled in.
  • Evaluation/ranking/weighting/TOPSIS/AHP/entropy weight -> evaluation scaffold: generates metric normalization, composite scores, ranking, and weight sensitivity items to be filled in.
  • Classification/recognition/discrimination -> classification scaffold: generates surrogate classification labels, accuracy/F1 items to be filled in.
  • Clustering/segmentation -> clustering scaffold: generates surrogate cluster labels, number of clusters, and within-cluster compactness.
  • Simulation/mechanism/dynamics/differential -> simulation scaffold: generates trend surrogates, scenario results, fitting errors, and sensitivity parameters.
  • Other -> general scaffold: generates numerical field statistical summaries and a general results table.

Output location

paper_output/
|-- code/
|   `-- modeling/
|       |-- run_modeling.py
|       |-- result_contract_io.py
|       |-- q1_model.py
|       |-- q2_model.py
|       |-- q3_model.py
|       `-- README.md
|-- results/
|   |-- model_results.json
|   |-- metrics.json
|   `-- conclusions.json
`-- tables/
    |-- table_index.json
    |-- table_q1_result_skeleton.csv
    |-- table_q1_forecasting_scaffold.csv
    `-- ...

Unified rules:

  • All paths use relative paths.
  • All JSON contains schema_version、generated_by、generated_at。
  • Every result, metric, conclusion, and table should carry question_id。
  • Draft or scaffold results must use status or evidence_status markers.
  • Official results must carry execution_provenance, including at least source_code_path、source_code_sha256、run_command、run_exit_code and output_artifacts。
  • Unified entry point run_modeling.py must be written after actual execution into paper_output/results/run_manifest.json, recording the overall status, script hash,question_ids, exit code, working directory, Python implementation/version/platform, and the path、bytes、sha256、exists。
  • run_manifest.json is not a log placeholder. When the modeling script, input files, or output artifacts change after running, the model must be rerun; the manifest or result JSON must not be manually edited to renew old evidence.
  • model_results.json Official entries in must have a non-empty result_summary;metrics.json In status=computed metrics must have non-empty, finite value, and must not use null、NaN or infinite values.
  • table_index.json Official tables in must point to files that actually exist and are non-empty; only index entries without CSV/XLSX artifacts cannot serve as evidence.
  • The official evidence gate will recompute script, input, and output hashes, and reject results that have no real code execution source, whose run ledger status failed, whose files were modified, or whose run records cannot be associated with question_id .
  • Tables cited in the main text must be findable in paper_output/tables/table_index.json .

How to use

Recommended to be called by paper-workflow-orchestrator after data cleaning and visualization. It can also be run manually:

python .claude/skills/model-code-and-result-generator/scripts/build_result_contracts.py

After generating the scaffold, the Agent should execute according to the real competition problem:

python paper_output/code/modeling/run_modeling.py

This entry point will write paper_output/results/run_manifest.json. After running, do not edit the modeling script or artifacts again; if corrections are needed, modify and rerun the entry point, then rerun the evidence gate and S7 writing preparation, so that the results and writing contract are invalidated and rebuilt in sync.

Principles for using real competition problems

  • Do not directly treat placeholder metrics or surrogate results as final competition results.
  • Prefer to modify paper_output/code/modeling/q*_model.py, do not modify the scripts/。
  • After formal modeling is completed, the modeling code must actually be run and the real output written back to paper_output/results/ and paper_output/tables/; do not hand-write model_results.json to pass it off as a run result. When there is no run_manifest.json corresponding run record, the formal evidence gate cannot be entered.
  • If a certain question has no real result, QA should retain the warning, and the main text must not write that question as having completed precise calculation.