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-orchestratorto 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 tostatus != "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 topaper-workflow-orchestratorto determine the next step, and usecontext-memory-keeperto 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:
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 therecommended_skillandnext_actionin the report. - Before continuing the workflow, you must treat
paper_output/context/workflow_memory.jsonas a long-term checkpoint record; if itscurrent_step、next_step、recommended_skillandworkflow_guard.py --statusare inconsistent, the guard report prevails. - Each time you complete this skill's artifacts, 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/.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 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-auditordirectly audits results, metrics, tables, charts and conclusions; after the evidence gate PASSes,paper-formal-writerconstructs 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_modelingto 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 everyquestion_id, generate the result contract skeleton, basic field profile table,paper_output/code/modeling/README.md, and generate runnableq*_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
statusorevidence_statusmarkers. - Official results must carry
execution_provenance, including at leastsource_code_path、source_code_sha256、run_command、run_exit_codeandoutput_artifacts。 - Unified entry point
run_modeling.pymust be written after actual execution intopaper_output/results/run_manifest.json, recording the overallstatus, script hash,question_ids, exit code, working directory, Python implementation/version/platform, and thepath、bytes、sha256、exists。 run_manifest.jsonis 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.jsonOfficial entries in must have a non-emptyresult_summary;metrics.jsonInstatus=computedmetrics must have non-empty, finitevalue, and must not usenull、NaNor infinite values.table_index.jsonOfficial 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 thescripts/。 - After formal modeling is completed, the modeling code must actually be run and the real output written back to
paper_output/results/andpaper_output/tables/; do not hand-writemodel_results.jsonto pass it off as a run result. When there is norun_manifest.jsoncorresponding 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.