Global workflow collaboration constraints (long-dialogue drift prevention)
- This skill must not be used as an isolated entry point. When the user requests a complete paper, Word generation, continuing the workflow, or is unsure of the stage, first return to
paper-workflow-orchestratorto determine the current S0-S8 stage. - Before starting or continuing a formal task for 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 it reportsstatus != "PASS", stop this skill, and backfill the prerequisite stages according to the failed items inpaper_output/qa/workflow_guard_report.json. Do not continue from memory. - This skill only writes the
paper_output/artifacts within its own contract scope; after completion, you must return topaper-workflow-orchestratorto determine the next step, and usecontext-memory-keeperto record completed artifacts, blockers, and next steps. - In a long dialogue, if the context grows long, the stage is uncertain, or the user invokes skills separately, first run:
then readpython .claude/skills/paper-workflow-orchestrator/scripts/workflow_guard.py --statuspaper_output/qa/workflow_guard_report.json、paper_output/preflight_report.json、paper_output/input_manifest.json、paper_output/results/run_manifest.jsonand this skill's upstream JSON contract, and continue according to the report'srecommended_skillandnext_action. - Before continuing the workflow,
paper_output/context/workflow_memory.jsonmust be treated as a long-term checkpoint record; if itscurrent_step、next_step、recommended_skillandworkflow_guard.py --statusare inconsistent, the guard report takes precedence. - After completing this skill's artifacts each time, first return to
paper-workflow-orchestratoror runworkflow_guard.py --status, then update workflow memory:
after updating, readpython .claude/skills/context-memory-keeper/scripts/update_workflow_memory.pypaper_output/context/workflow_memory.json/.md, and confirm that the next step and recommended skill have been recorded.
Objective
This skill is not an all-purpose automated modeling system. Its role is to give the Agent a stable "results evidence layer" and a runnable starting point for competition-problem-specific modeling code, avoiding a main text written only from the model route in the abstract, and avoiding the Agent flailing around 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, secondarily modify the generated q*_model.py. Generated code is fixed 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 scanpaper_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.pyor thequestion_idcorresponding toq*_model.py。 - Downstream handoff:
quality-assurance-auditorAfter reading the results and table evidence, write intotasks.json;paper-micro-unit-generatorReference results, metrics, tables, and conclusions through the task list. - Failure fallback: if there is no cleaned data or real modeling code, still generate the contract skeleton, and use
needs_real_modelingto mark it, without pretending it is a final competition result.
Script
scripts/build_result_contracts.py- When to use: when a model route already exists and it is necessary to generate the results contract, table index, and q1/q2/q3 modeling code scaffolding for the current competition problem.
- What it does: scan
model_route.jsonfor eachquestion_id, generate the results contract skeleton, basic field profile tables,paper_output/code/modeling/README.md, and generate a runnableq*_model.py。 - Overwrite rules: generated files carry a managed marker; if the Agent has already manually rewritten and removed the marker, this script will preserve 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 to do: provide contract templates for forecasting, optimization, evaluation, classification, clustering, simulation, and general modeling.
Task Type Dispatch
- Forecasting/regression/time series -> forecasting scaffold: generate the target column, feature columns, predicted values, residuals, RMSE, MAE, MAPE.
- Optimization/planning/scheduling/site selection/routing -> optimization scaffold: generate a surrogate objective function, solution ranking, and constraint satisfaction rate items to be completed.
- Evaluation/ranking/weighting/TOPSIS/AHP/entropy weight -> evaluation scaffold: generate metric normalization, composite scores, ranking, and weight sensitivity items to be completed.
- Classification/recognition/discrimination -> classification scaffold: generate surrogate classification labels, accuracy/F1 items to be completed.
- Clustering/segmentation -> clustering scaffold: generate surrogate cluster labels, number of clusters, and intra-cluster compactness.
- Simulation/mechanism/dynamics/differential -> simulation scaffold: generate trend surrogates, scenario results, fitting error, and sensitivity parameters.
- Other -> general scaffold: generate a statistical summary of numeric fields 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
statusorevidence_statusmarkers. - Official results must carry
execution_provenance, includingsource_code_path、run_command、run_exit_codeandoutput_artifacts; the unified entry pointrun_modeling.pymust also writepaper_output/results/run_manifest.json, recording the script command, exit code, input file hash, and output artifact hash. The official evidence gate will reject results that have no real code execution source or no corresponding run record in run_manifest. - 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. Then rerun QA to let paper_output/tasks.json read the refreshed model_results.json、metrics.json、conclusions.json、run_manifest.json and table_index.json。
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, and do not modifyscripts/。 - inside the skill package. After formal modeling is complete, the modeling code must actually run and write the real output back to
paper_output/results/andpaper_output/tables/; do not handwritemodel_results.jsonto pass it off as run results. Withoutrun_manifest.jsoncorresponding run records, it cannot enter the official evidence gate. - If a question has no real results, QA should keep the warning, and the main text must not describe that question as having completed precise calculations.