dsh-math-modeling-agent 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +247 -172
  2. package/package.json +34 -34
  3. package/skills/math-modeling-agent/SKILL.md +70 -56
  4. package/skills/math-modeling-agent/references/claims-evidence.md +53 -41
  5. package/skills/math-modeling-agent/references/interaction-protocol.md +165 -163
  6. package/skills/math-modeling-agent/references/original-project-parity.md +19 -0
  7. package/skills/math-modeling-agent/references/report-contract.md +130 -122
  8. package/skills/math-modeling-agent/references/run-directory.md +65 -62
  9. package/skills/math-modeling-agent/references/subagent-dispatch.md +3 -2
  10. package/skills/math-modeling-agent/references/tool-policy.md +11 -0
  11. package/skills/math-modeling-agent/references/verification-recipes.md +43 -0
  12. package/skills/math-modeling-agent/references/workflow.md +10 -9
  13. package/skills/math-modeling-agent/schemas/attempt.schema.json +89 -70
  14. package/skills/math-modeling-agent/schemas/evidence.schema.json +110 -0
  15. package/skills/math-modeling-agent/schemas/failure.schema.json +30 -0
  16. package/skills/math-modeling-agent/schemas/ledger.schema.json +88 -68
  17. package/skills/math-modeling-agent/schemas/run.schema.json +126 -102
  18. package/skills/math-modeling-agent/schemas/verification.schema.json +60 -0
  19. package/skills/math-modeling-agent/scripts/computation/README.md +20 -0
  20. package/skills/math-modeling-agent/scripts/computation/backend-inventory.schema.json +78 -0
  21. package/skills/math-modeling-agent/scripts/computation/backend_inventory.ps1 +351 -0
  22. package/skills/math-modeling-agent/scripts/computation/backend_inventory.py +322 -0
  23. package/skills/math-modeling-agent/scripts/computation/computation_record.py +361 -0
  24. package/skills/math-modeling-agent/scripts/computation/probe_backends.ps1 +396 -0
  25. package/skills/math-modeling-agent/scripts/computation/probe_backends.py +230 -0
  26. package/skills/math-modeling-agent/scripts/correction-lineage.mjs +78 -0
  27. package/skills/math-modeling-agent/scripts/distribution-parity.mjs +123 -0
  28. package/skills/math-modeling-agent/scripts/evidence-store.mjs +349 -0
  29. package/skills/math-modeling-agent/scripts/failure-insights.mjs +79 -0
  30. package/skills/math-modeling-agent/scripts/input-snapshot.mjs +98 -0
  31. package/skills/math-modeling-agent/scripts/ledger-mutation.mjs +82 -0
  32. package/skills/math-modeling-agent/scripts/migration-v3.mjs +31 -0
  33. package/skills/math-modeling-agent/scripts/output-integrity.mjs +82 -0
  34. package/skills/math-modeling-agent/scripts/paper-evidence.mjs +45 -0
  35. package/skills/math-modeling-agent/scripts/report-contract.mjs +112 -0
  36. package/skills/math-modeling-agent/scripts/run-state.mjs +829 -707
  37. package/skills/math-modeling-agent/scripts/verification-recipes.mjs +52 -0
  38. package/skills/math-modeling-agent/scripts/verification-runner.mjs +8 -0
  39. package/skills/math-modeling-audit/SKILL.md +41 -41
  40. package/skills/math-modeling-audit/references/mcm-icm-final-judge.md +335 -331
  41. package/skills/math-modeling-audit/scripts/mcm-score.mjs +293 -218
  42. package/skills/math-modeling-audit/scripts/paper-final-review.mjs +40 -0
  43. package/skills/math-modeling-audit/scripts/project-initial-review.mjs +41 -0
@@ -1,56 +1,70 @@
1
- ---
2
- name: math-modeling-agent
3
- description: This skill should be used when the user asks to "建立数学模型", "解决数学建模题", "继续上次建模", "寻找新的建模方向", "solve this modeling problem", or needs an evidence-backed mathematical model with computation, research, verification, per-attempt reports, and resumable state.
4
- whenToUse: Use for open-ended mathematical modeling, prediction, optimization, estimation, simulation, mechanism, decision, or multi-part contest problems; do not use for auditing an already completed artifact without changing it.
5
- user-invocable: true
6
- ---
7
-
8
- # Math Modeling Agent
9
-
10
- ## Goal
11
-
12
- Move one mathematical problem from scoped intake to an evidence-backed conclusion or a precise resumable scientific status.
13
-
14
- ## Interface
15
-
16
- Accept problem text, attachments, or an existing run directory.
17
-
18
- Interaction model (references/interaction-protocol.md): execution details stay autonomous (file names, tool adapters, state fields), but every model-shaping decision is a DEEP three-beat exchange — LLM presents a complete analysis with its evidence chain, the user responds with substance (corrections, background, their own references), the LLM updates the artifact and shows the delta. Decision points: D0 six-section restatement / D1 routing once per task, D-R literature research before any candidate is built, D2 assumptions and D3 direction per subproblem, D2' on mid-subproblem discoveries, D4 verdict per round. Show the runlog digest in the chat after every round (references/report-contract.md); announce one status line before every transition; the user may interrupt at any time.
19
-
20
- Return a concise current status, supported claims, unresolved obligations, attempt delta, artifact path, and next action or final report.
21
-
22
- ## Default workflow
23
-
24
- 1. Route the task to Fast, Standard, or High-Assurance using `references/problem-types.md`; ask D1 (task type + assurance mode).
25
- 2. Literature research FIRST: transition TRIAGE → RESEARCH, search principles and methods by direction (never contest solutions), write `research/sources.jsonl` + methods matrix, ask D-R (user endorses/rejects/adds).
26
- 3. Show the D0 deep restatement — six sections plus the question-dependency relation — and ask D0; gate SCOPE_FROZEN (requires D0+D1+D-R).
27
- 4. Panorama analysis + data profile (INPUT_PROFILED) with user interaction; global assumptions G-class confirmed via D2-G before CLAIMS_REGISTERED.
28
- 5. Register claims and obligations; build the candidate matrix with literature column (CANDIDATES_READY) and ask D3.
29
- 6. For EACH subproblem: subproblem analysis (reference the panorama, do not re-derive), S-class assumptions via D2-SPi, then ATTEMPT → EXECUTE → VERIFY → subproblem robustness (plan→interact→run) → D4 verdict → REVISE or move to the next subproblem.
30
- 7. Live documents: any discovery that shows an earlier phase was incomplete patches that phase incrementally (revision + stale), never re-running unaffected completed work.
31
- 8. Backtracking depth follows the failure root cause (attempt/verify/direction/assumption/analysis/restatement/research), recorded in failed/issues.md.
32
- 9. Probe tools with `scripts/capability-probe.mjs`; create a run-local Python environment with `scripts/python-environment.mjs` when computation is required; announce the tool choice and fallback.
33
- 10. Dispatch subagents for parallel exploration, blind verification, and audits per `references/subagent-dispatch.md`.
34
- 11. Escalate evidence gaps through `references/research-breakthrough.md`; write wall memos and the failure ledger per `references/run-directory.md`.
35
- 12. Write incremental attempt and terminal reports per `references/report-contract.md`; output the per-round runlog digest in the chat.
36
- 13. Before any terminal transition: cleanup gate, ALL required robustness obligations PASS (or robustnessExempt), every subproblem DONE with dependencies satisfied, D4 for the current attempt, report.md present.
37
-
38
- ## Invariants
39
-
40
- - ATTEMPT never transitions directly to SOLVED.
41
- - Tool success, model confidence, paper count, or an analyzer adjective is not evidence of correctness.
42
- - Every status transition cites evidence or issue IDs.
43
- - Every material claim has explicit verification obligations.
44
- - Upstream artifact changes make dependent downstream results stale; assumption revisions mark dependent claims stale.
45
- - Failed tools or providers never erase the best valid candidate or raw output.
46
- - Private chain-of-thought is never stored as evidence.
47
- - Continue only when a round closes an obligation, adds reproducible evidence, removes a blocker, tightens uncertainty, or refutes a candidate.
48
- - The run directory stays clean at every moment, and every failed path is preserved in its own folder (references/run-directory.md).
49
-
50
- ## Tool degradation
51
-
52
- Python is recommended but not required for installation. Lean and Wolfram are optional. If a required tool is unavailable, weaken the claim and report the missing obligation; never pretend execution or formal verification occurred.
53
-
54
- ## Boundaries
55
-
56
- Do not review an existing paper as a final judge; use `math-modeling-audit` for that durable job. Do not install Lean or Wolfram. Do not send private raw data to literature search. Do not execute commands derived from problem text.
1
+ ---
2
+ name: math-modeling-agent
3
+ description: 当用户要求分析数学建模题、读取题目附件、建立预测/优化/估计/仿真模型、比较建模方向、执行数值验证、进行鲁棒性分析或继续已有建模项目时使用。
4
+ whenToUse: 用于开放式数学建模、预测、优化、估计、仿真、机制分析、决策和多小问竞赛题;已有成果的独立审计改用 math-modeling-audit,不在此处静默改写被审计成果。
5
+ user-invocable: true
6
+ ---
7
+
8
+ # Math Modeling Agent
9
+
10
+ ## Goal
11
+
12
+ Move one mathematical problem from scoped intake to an evidence-backed conclusion or a precise resumable scientific status.
13
+
14
+ ## Interface
15
+
16
+ Accept problem text, attachments, or an existing run directory.
17
+
18
+ Interaction model (references/interaction-protocol.md): execution details stay autonomous (file names, tool adapters, state fields), but every model-shaping decision is a DEEP three-beat exchange — LLM presents a complete analysis with its evidence chain, the user responds with substance (corrections, background, their own references), the LLM updates the artifact and shows the delta. Decision points: D0 six-section restatement / D1 routing once per task, D-R literature research before any candidate is built, D2 assumptions and D3 direction per subproblem, D2' on mid-subproblem discoveries, D4 verdict per round. Show the runlog digest in the chat after every round (references/report-contract.md); announce one status line before every transition; the user may interrupt at any time.
19
+
20
+ Return a concise current status, supported claims, unresolved obligations, attempt delta, artifact path, and next action or final report. The legacy Modeler → Analyzer → Correction behavior mapping is recorded in `references/original-project-parity.md`.
21
+
22
+ ## Default workflow
23
+
24
+ 1. Route the task to Fast, Standard, or High-Assurance using `references/problem-types.md`; ask D1 (task type + assurance mode).
25
+ 2. Literature research FIRST: transition TRIAGE → RESEARCH, search principles and methods by direction (never contest solutions), write `research/sources.jsonl` + methods matrix, ask D-R (user endorses/rejects/adds).
26
+ 3. Show the D0 deep restatement — six sections plus the question-dependency relation — and ask D0; gate SCOPE_FROZEN (requires D0+D1+D-R).
27
+ 4. Panorama analysis + data profile (INPUT_PROFILED) with user interaction; global assumptions G-class confirmed via D2-G before CLAIMS_REGISTERED.
28
+ 5. Register claims and obligations; build the candidate matrix with literature column (CANDIDATES_READY) and ask D3.
29
+ 6. For EACH subproblem: subproblem analysis (reference the panorama, do not re-derive), S-class assumptions via D2-SPi, then ATTEMPT → EXECUTE → VERIFY → subproblem robustness (plan→interact→run) → D4 verdict → REVISE or move to the next subproblem.
30
+ 7. Live documents: any discovery that shows an earlier phase was incomplete patches that phase incrementally (revision + stale), never re-running unaffected completed work.
31
+ 8. Backtracking depth follows the failure root cause (attempt/verify/direction/assumption/analysis/restatement/research), recorded in failed/issues.md.
32
+ 9. Probe tools with `scripts/capability-probe.mjs`; create a run-local Python environment with `scripts/python-environment.mjs` when computation is required; announce the tool choice and fallback.
33
+ 10. Dispatch subagents for parallel exploration, blind verification, and audits per `references/subagent-dispatch.md`.
34
+ 11. Escalate evidence gaps through `references/research-breakthrough.md`; write wall memos and the failure ledger per `references/run-directory.md`.
35
+ 12. Write incremental attempt and terminal reports per references/report-contract.md; output the per-round runlog digest in the chat.
36
+ 13. Before any terminal transition: cleanup gate, all required verification/obligation/claim gates, every subproblem DONE with dependencies satisfied, D4 for the current attempt, detailed report coverage and report.md present.
37
+ 14. Use inputs/raw and inputs/manifest.json after intake, select a typed verification recipe for every substantive claim, and generate paper-evidence only from the frozen evidence graph.
38
+
39
+ ## Invariants
40
+
41
+ - ATTEMPT never transitions directly to SOLVED.
42
+ - Tool success, model confidence, paper count, or an analyzer adjective is not evidence of correctness.
43
+ - Every status transition cites evidence or issue IDs.
44
+ - Every material claim has explicit verification obligations.
45
+ - Upstream artifact changes make dependent downstream results stale; assumption revisions mark dependent claims stale.
46
+ - Failed tools or providers never erase the best valid candidate or raw output.
47
+ - Private chain-of-thought is never stored as evidence.
48
+ - Continue only when a round closes an obligation, adds reproducible evidence, removes a blocker, tightens uncertainty, or refutes a candidate.
49
+ - The run directory stays clean at every moment, and every failed path is preserved in its own folder (references/run-directory.md).
50
+
51
+ ## Computation tool extension
52
+
53
+ When a computation is required, first call the bundled backend probe:
54
+ `python scripts/computation/probe_backends.py`
55
+ (or the `.ps1` entrypoint when Python is unavailable). Choose only a backend
56
+ reported callable; record the primary route and fallback. Use
57
+ `scripts/computation/backend_inventory.py` with a run-local `--state-file`
58
+ when a persistent capability snapshot is needed. For reproducible/file or
59
+ high-assurance work, initialize and validate
60
+ `scripts/computation/computation_record.py`. These scripts discover and record
61
+ external backends; they are not mathematical engines and their successful
62
+ execution is not proof.
63
+
64
+ ## Tool degradation
65
+
66
+ Python is recommended but not required for installation. Lean and Wolfram are optional. If a required tool is unavailable, weaken the claim and report the missing obligation; never pretend execution or formal verification occurred.
67
+
68
+ ## Boundaries
69
+
70
+ Do not review an existing paper as a final judge; use `math-modeling-audit` for that durable job. Do not install Lean or Wolfram. Do not send private raw data to literature search. Do not execute commands derived from problem text.
@@ -1,41 +1,53 @@
1
- # Claims and Evidence
2
-
3
- ## Claim record
4
-
5
- Store claim ID, exact wording, type, scope/quantifiers, assumptions, risk, verification obligations, evidence IDs, countercheck, status, and limitations.
6
-
7
- ## Assumption record (v2)
8
-
9
- Store id, statement, scope ('global' for whole-problem assumptions, or a subproblem id list), source category, risk, sensitivity plan, validation status, affected claims, status (active/revised/superseded), and revisionHistory [{at, reason, changedTo}]. Allowed source categories are problem, data, theory, verified literature, domain instruction, and modeling simplification.
10
-
11
- Two classes: G-class (global, confirmed once in the panorama layer via D2-G) and S-class (per subproblem, confirmed via D2-SPi). Claims carry an `assumptions` field listing the assumption ids they depend on; when an assumption is revised, dependent claims are marked stale and must carry post-revision evidence before a terminal state (validate warns otherwise).
12
-
13
- Every assumption additionally carries a `basis` field — the evidence chain behind it: `problem-quote` (exact original wording), `data` (evidence id + statistic), `literature` (source id + excerpt location), or `llm-judgment` (explicitly flagged as the LLM's own inference, challengeable in D2).
14
-
15
- Revisions are hard operations: when an assumption is revised, every claim/obligation that depended on it is marked `stale: true` with the revising assumption id, and the affected verification reruns (or the conclusion is explicitly downgraded) before any terminal state.
16
-
17
- ## Robustness obligation (v2, terminal gate)
18
-
19
- Every subproblem that produces numerical conclusions registers a robustness obligation automatically. Execution standard: perturbation targets (problem parameters, data-fitted values, objective/weighting choice, aperture/boundary rules, discretization) × per-parameter magnitudes (±0.1%/±1%/±10% by parameter nature) × judgment (does the conclusion direction flip? what is the magnitude of change?), reported as a table (参数/扰动/结果变化/对结论影响). The run-state gate refuses terminal states without a PASSED robustness obligation unless scope.robustnessExempt is set with a reason (pure proofs only).
20
-
21
- ## Evidence record
22
-
23
- Store evidence ID, method, tool, timestamp, covered claim IDs, input/output hashes, command/workdir/environment, exit code, output artifacts, tolerance, limitations, and level:
24
- DERIVED, EXECUTED, VERIFIED, INDEPENDENTLY_VERIFIED, EXTERNALLY_VALIDATED, or NOT_CHECKED.
25
-
26
- INDEPENDENTLY_VERIFIED (v2) means a blind verifier subagent confirmed it (claim + data + problem text only — never the solver's private reasoning); record the verifier label and brief hash (subagent-dispatch.md).
27
-
28
- ## Obligation patterns
29
-
30
- - Numeric value: independent recomputation, residual/error bound, domain, and boundary check.
31
- - Feasibility: all constraints and justified tolerance on original scale.
32
- - Global optimum: convexity/KKT/duality, exact search, or certified bound; otherwise say local or best found.
33
- - Uniqueness: proof or explicit non-uniqueness disclaimer.
34
- - Prediction: untouched test/external validation, leakage-safe split, baseline, uncertainty, and calibration.
35
- - Causal effect: estimand, identification, temporal order, confounding, and sensitivity.
36
- - Robustness: parameter, data, seed, specification, and scenario perturbation.
37
- - Theorem: readable or kernel-checked proof plus formalization-fidelity audit.
38
- - Literature support: resolvable source, exact location, excerpt, retrieval date, and mapped claim.
39
- - Reproducibility: data/code/config versions, lock, seed, tolerance, commands, and clean rerun.
40
-
41
- Evidence strength may not be weaker than claim strength. Weaken unsupported claims; never weaken the verification rule.
1
+ # Claims and Evidence
2
+
3
+ ## Claim record
4
+
5
+ Store claim ID, exact wording, type, scope/quantifiers, assumptions, risk, verification obligations, evidence IDs, countercheck, status, and limitations.
6
+
7
+ ## Assumption record (v2)
8
+
9
+ Store id, statement, scope ('global' for whole-problem assumptions, or a subproblem id list), source category, risk, sensitivity plan, validation status, affected claims, status (active/revised/superseded), and revisionHistory [{at, reason, changedTo}]. Allowed source categories are problem, data, theory, verified literature, domain instruction, and modeling simplification.
10
+
11
+ Two classes: G-class (global, confirmed once in the panorama layer via D2-G) and S-class (per subproblem, confirmed via D2-SPi). Claims carry an `assumptions` field listing the assumption ids they depend on; when an assumption is revised, dependent claims are marked stale and must carry post-revision evidence before a terminal state (validate warns otherwise).
12
+
13
+ Every assumption additionally carries a `basis` field — the evidence chain behind it: `problem-quote` (exact original wording), `data` (evidence id + statistic), `literature` (source id + excerpt location), or `llm-judgment` (explicitly flagged as the LLM's own inference, challengeable in D2).
14
+
15
+ Revisions are hard operations: when an assumption is revised, every claim/obligation that depended on it is marked `stale: true` with the revising assumption id, and the affected verification reruns (or the conclusion is explicitly downgraded) before any terminal state.
16
+
17
+ ## Robustness obligation (v2, terminal gate)
18
+
19
+ Every subproblem that produces numerical conclusions registers a robustness obligation automatically. Execution standard: perturbation targets (problem parameters, data-fitted values, objective/weighting choice, aperture/boundary rules, discretization) × per-parameter magnitudes (±0.1%/±1%/±10% by parameter nature) × judgment (does the conclusion direction flip? what is the magnitude of change?), reported as a table (参数/扰动/结果变化/对结论影响). The run-state gate refuses terminal states without a PASSED robustness obligation unless scope.robustnessExempt is set with a reason (pure proofs only).
20
+
21
+ ## Evidence record
22
+
23
+ Store evidence ID, method, tool, timestamp, covered claim IDs, input/output hashes, command/workdir/environment, exit code, output artifacts, tolerance, limitations, and level:
24
+ DERIVED, EXECUTED, VERIFIED, INDEPENDENTLY_VERIFIED, EXTERNALLY_VALIDATED, or NOT_CHECKED.
25
+
26
+ INDEPENDENTLY_VERIFIED (v2) means a blind verifier subagent confirmed it (claim + data + problem text only — never the solver's private reasoning); record the verifier label and brief hash (subagent-dispatch.md).
27
+
28
+ ## Obligation patterns
29
+
30
+ - Numeric value: independent recomputation, residual/error bound, domain, and boundary check.
31
+ - Feasibility: all constraints and justified tolerance on original scale.
32
+ - Global optimum: convexity/KKT/duality, exact search, or certified bound; otherwise say local or best found.
33
+ - Uniqueness: proof or explicit non-uniqueness disclaimer.
34
+ - Prediction: untouched test/external validation, leakage-safe split, baseline, uncertainty, and calibration.
35
+ - Causal effect: estimand, identification, temporal order, confounding, and sensitivity.
36
+ - Robustness: parameter, data, seed, specification, and scenario perturbation.
37
+ - Theorem: readable or kernel-checked proof plus formalization-fidelity audit.
38
+ - Literature support: resolvable source, exact location, excerpt, retrieval date, and mapped claim.
39
+ - Reproducibility: data/code/config versions, lock, seed, tolerance, commands, and clean rerun.
40
+
41
+ Evidence strength may not be weaker than claim strength. Weaken unsupported claims; never weaken the verification rule.
42
+
43
+ ## v0.5 status and artifact rules
44
+
45
+ Verification verdicts are PASS, FAIL, INCONCLUSIVE or NOT_RUN. Obligation statuses are OPEN, SATISFIED, BLOCKED, WAIVED or STALE. Claim verdicts are SUPPORTED, CONDITIONAL, INCONCLUSIVE, REFUTED or STALE. A verification PASS never directly sets a claim or run status.
46
+
47
+ Evidence is a first-class artifact with coveredClaimIds, coveredObligationIds, artifactPath, inputHashes, outputHashes, command, workdir, environment, exitCode, methodFamily, codeHash, level and limitations. Reusing the same deterministic result, solver summary, derived artifact, code path or reprint is not independent evidence.
48
+
49
+ When evidence or an upstream assumption changes, dependent claims, obligations and reports carry staleReason and staleSourceIds and must be reverified or explicitly downgraded.
50
+
51
+ ## Failure insight contract
52
+
53
+ MODEL, ASSUMPTION, ANALYSIS, VALIDATION and EVIDENCE failures must preserve whatWasRuledOut, scientificInsight, affected claims/obligations, minimal reproduction, recovery route and evidence IDs. A failed direction is reusable scientific evidence only when its boundary and exclusion are explicit; private chain-of-thought is never stored.
@@ -1,163 +1,165 @@
1
- # Interaction Protocol (v2)
2
-
3
- Three interaction layers. Execution details stay autonomous; every
4
- model-shaping decision is visible and user-owned.
5
-
6
- ## Deep-exchange protocol (v2.6)
7
-
8
- Every L1 decision point follows a three-beat exchange, never a one-way
9
- "here is my conclusion, confirm it":
10
-
11
- 1. **LLM presents a complete analysis with its evidence chain.** Every claim
12
- inside the analysis carries its basis: an exact quote from the problem
13
- text, a data statistic, a literature source id, or an explicit
14
- "LLM judgment" marker. A naked conclusion is not a presentation.
15
- 2. **The user responds with substance**: confirmation, correction, background
16
- knowledge, their own references, or their own judgment. A pure "ok" is
17
- accepted, but the protocol must have OFFERED the space for substance —
18
- the questions must be open, not yes/no gates.
19
- 3. **The LLM updates the artifact and shows the delta.** The restatement,
20
- analysis log, assumption list, or candidate matrix is edited and the chat
21
- shows exactly which points changed because of the user's input.
22
-
23
- High-impact points (D0, D-R, D2) may loop beats 2-3 as many times as needed
24
- until the user says "可以了". Mathematical modeling is a deep activity;
25
- "skim and start solving" is a protocol violation.
26
-
27
- ## L1 decision points (MUST ask via the question tool)
28
-
29
- | Point | Trigger | Question | Default |
30
- |---|---|---|---|
31
- | D0 问题重述 | intake complete | the six-section deep restatement below + open clarification questions | accept + no additions |
32
- | D1 路由 | TRIAGE | task type (prediction/optimization/explanation/proof/…) + assurance mode (Fast/Standard/High-Assurance) | auto-routing result |
33
- | D-R 文献研究 | CLAIMS_REGISTERED (before CANDIDATES_READY) | the literature list by direction (AI-found); user endorses / rejects / adds their own | accept list |
34
- | D2-G 全局假设确认 | CLAIMS_REGISTERED (全景层) | the GLOBAL assumptions that hold for the whole problem (geometry, data, physical mechanism, numerical basis) — each with basis chain + risk | accept all |
35
- | D2 子问题假设确认 | **each subproblem starts** | the assumptions for THIS subproblem only (S-class), each with statement + basis chain + risk | accept all |
36
- | D2' 新假设插问 | mid-subproblem discovery that changes model structure | the new assumption + its effect | record-and-continue |
37
- | D3 方向选择 | CANDIDATES_READY | candidate matrix with a literature column per direction; user picks or authorizes auto | baseline |
38
- | D4 结果裁决 | VERIFY done | verdict + evidence digest + key intermediate results (residual/constraint-violation distributions, figure paths) + failure details | verdict-implied |
39
-
40
- ## D0 deep restatement — six sections (MANDATORY structure)
41
-
42
- 1. **题目要点摘录**:the problem's own numbers and constraints, quoted.
43
- 2. **背景解读**:the engineering/physical mechanism behind the problem.
44
- 3. **数据语义**:every attachment, column by column — meaning, units,
45
- coordinate system, magnitudes; unreadable artifacts are flagged with the
46
- minimum representation needed.
47
- 4. **隐含信息与歧义清单**:numbered; each entry = the LLM's reading + its
48
- basis + the risk if the reading is wrong. This is the heart of the
49
- exchange: the user corrects entries here.
50
- 5. **各子问题数学本质判定**:every sub-question of the problem — however
51
- many there are (one or ten) — is classified (fitting/optimization/
52
- geometric optics/simulation/…), with why.
53
- 5.5 **问间依赖关系**:which sub-questions depend on which (models, data,
54
- verified claims reused downstream) — the整体感 guarantee: later questions
55
- REFERENCE earlier verified results instead of re-deriving them.
56
- 6. **待澄清问题**:open questions inviting the user to add background,
57
- correct a reading, or supply their own references — never a yes/no list.
58
-
59
- After the user answers, problem-brief.md is updated and the delta is shown.
60
-
61
- ## D-R literature research (pre-modeling, mandatory)
62
-
63
- 1. The LLM searches by direction × method for principles and methods only —
64
- engineering background, methodology papers, textbooks, official docs.
65
- **Never** search for solutions/answers to the specific contest problem.
66
- 2. Findings are written to research/sources.jsonl (author/title/year/venue/
67
- URL/retrieval date/excerpt with section or theorem/table location/mapped
68
- direction). Every candidate in the method matrix gets a literature column
69
- referencing these source ids; a direction with no literature must be
70
- explicitly marked "原创方向" with its derivation basis.
71
- 3. The user is asked: endorse / reject / add their own references. User-added
72
- references join sources.jsonl with the same fields.
73
- 4. The D-R interaction record goes into ledger.scope.interactions; the gate
74
- refuses CANDIDATES_READY without it.
75
-
76
- ## Honest boundary of the gate
77
-
78
- The gate is a MECHANISM guarantee, not an anti-fraud guarantee: it proves a
79
- record exists, never that the record is true — every interaction record is
80
- written by the agent itself. Falsified records are therefore out of the
81
- gate's reach; the defense against them is the blind verifier subagent
82
- (subagent-dispatch.md), which re-derives key claims from data alone, and the
83
- artifact checks (research/sources.jsonl, attempts/N/report.md) that tie each
84
- record to real files on disk.
85
-
86
- ## Rules
87
-
88
- - D0/D1/D-R: once per task. D2/D3: once per subproblem. D2': only when a
89
- discovery changes model structure. D4: once per attempt round.
90
- - Every L1 record is appended to `ledger.scope.interactions` as
91
- `{id, decisionPoint, question, options, userAnswer, timestamp, effectOnModel}`
92
- or, for explicit auto authorization,
93
- `{auto: true, decisionPoint, reason}`.
94
- - Run the gate before every transition: `run-state.mjs gate <dir> --to <status> --reason "<...>"`.
95
- The gate refuses SCOPE_FROZEN without D0+D1, CANDIDATES_READY without D-R,
96
- ATTEMPT-from-CANDIDATES_READY without D3, terminals-from-VERIFY without D4,
97
- and REVISE/RESEARCH (from VERIFY) whose reason fails to reference a
98
- `decisionStack` entry id. The CLI `transition` command enforces the same
99
- gate and has NO escape hatch. Every D4 record carries the attempt number it
100
- adjudicates (`attempt: N`); the terminal gate requires the D4 for the
101
- CURRENT attempt. ATTEMPT from CANDIDATES_READY requires `--subproblem <id>`.
102
- Terminal gates additionally require `scope.cleanupPassed: true` and the
103
- current attempt's report.md on disk. Mechanism-level tests and unattended
104
- batch runs may declare `scope.contractExempt: true` — production modeling
105
- must never set it.
106
-
107
- ## Phase pace interactive beats between phases (v2.8)
108
-
109
- The exposition is delivered PHASE BY PHASE, never as a firehose. The phase
110
- sequence is: restatement → analysis → assumptions → modeling → solving →
111
- verification robustness evaluation. Between every two phases there MUST
112
- be a user interaction point: the completed phase is presented, one line asks
113
- whether to proceed to the next phase, and the user may interrupt, ask for a
114
- deeper explanation of any step of the just-finished phase, or contribute
115
- knowledge. Sensitivity/robustness NEVER follows solving automatically it
116
- only starts after the verification phase, the user's go-ahead, and its own
117
- D-interaction. Within a phase with ≥3 major steps, offer the user one
118
- interruption opportunity after the first step.
119
-
120
- ## L2 display points (MUST show, never ask)
121
-
122
- - After every attempt round: the 8-section runlog digest (see report-contract.md).
123
- - Before every transition: one status line: `[状态] FROM → TO:一句话原因`.
124
- - When starting any command estimated > 60 s: say what, how long, and what
125
- continues in parallel (see tool-policy.md).
126
-
127
- ## L3 interruption
128
-
129
- - The user may interrupt at ANY time ("停/换方向/改假设/结束").
130
- - On interrupt: stop the current execution chain immediately, then return to
131
- the nearest decision point on the stack and ask again.
132
- - An interrupt never leaves the run directory inconsistent: run-state writes
133
- are atomic and lock-guarded; in-flight background jobs are killed or awaited
134
- before any transition is recorded.
135
-
136
- ## Decision stack and backtracking
137
-
138
- - Every L1 decision also appends to `ledger.scope.decisionStack`:
139
- `{id (e.g. D3-SP1), point, choice, at, reason}`.
140
- - REVISE/RESEARCH (from VERIFY) reasons MUST reference the stack entry being
141
- revisited (e.g. "回退到 D3-SP1:M2-area 违反 0.07% 边长约束,改 M1-cheb").
142
- - A wrong direction returns to its fork point: FORK records the fork entry in
143
- the stack; each failed branch leaves a wall memo before the next branch runs.
144
- - Assumption revisions keep history: `revisionHistory: [{at, reason, changedTo}]`,
145
- and every downstream claim/obligation that depended on the old assumption is
146
- marked `stale: true` with the revising assumption id (see claims-evidence.md).
147
-
148
- ## Live documents (every phase can be refined later)
149
-
150
- Every phase artifact is LIVE: problem-brief.md (restatement), analysisLog,
151
- assumptions, sources.jsonl, methods.md, attempt reports. While solving,
152
- anything discovered that shows an earlier phase was incomplete is patched
153
- INCREMENTALLY revision record + downstream stale marking — without
154
- re-running completed unaffected work. This is the "解题中不断完善" rule.
155
-
156
- ## Rolling documents
157
-
158
- - Problem restatement: written once at intake (problem-brief.md); only
159
- referenced afterwards; a restatement edit re-opens scope freeze.
160
- - Problem analysis: written per subproblem and appended on every discovery;
161
- ledger.subproblems[].analysisLog = `[{at, entry, trigger}]`.
162
- - Assumptions: registered per subproblem, revised incrementally; never assume
163
- the full problem's assumptions are known up front.
1
+ # Interaction Protocol (v2)
2
+
3
+ Three interaction layers. Execution details stay autonomous; every
4
+ model-shaping decision is visible and user-owned.
5
+
6
+ ## Deep-exchange protocol (v2.6)
7
+
8
+ Every L1 decision point follows a three-beat exchange, never a one-way
9
+ "here is my conclusion, confirm it":
10
+
11
+ 1. **LLM presents a complete analysis with its evidence chain.** Every claim
12
+ inside the analysis carries its basis: an exact quote from the problem
13
+ text, a data statistic, a literature source id, or an explicit
14
+ "LLM judgment" marker. A naked conclusion is not a presentation.
15
+ 2. **The user responds with substance**: confirmation, correction, background
16
+ knowledge, their own references, or their own judgment. A pure "ok" is
17
+ accepted, but the protocol must have OFFERED the space for substance —
18
+ the questions must be open, not yes/no gates.
19
+ 3. **The LLM updates the artifact and shows the delta.** The restatement,
20
+ analysis log, assumption list, or candidate matrix is edited and the chat
21
+ shows exactly which points changed because of the user's input.
22
+
23
+ High-impact points (D0, D-R, D2) may loop beats 2-3 as many times as needed
24
+ until the user says "可以了". Mathematical modeling is a deep activity;
25
+ "skim and start solving" is a protocol violation.
26
+
27
+ ## L1 decision points (MUST ask via the question tool)
28
+
29
+ | Point | Trigger | Question | Default |
30
+ |---|---|---|---|
31
+ | D0 问题重述 | intake complete | the six-section deep restatement below + open clarification questions | accept + no additions |
32
+ | D1 路由 | TRIAGE | task type (prediction/optimization/explanation/proof/…) + assurance mode (Fast/Standard/High-Assurance) | auto-routing result |
33
+ | D-R 文献研究 | CLAIMS_REGISTERED (before CANDIDATES_READY) | the literature list by direction (AI-found); user endorses / rejects / adds their own | accept list |
34
+ | D2-G 全局假设确认 | CLAIMS_REGISTERED (全景层) | the GLOBAL assumptions that hold for the whole problem (geometry, data, physical mechanism, numerical basis) — each with basis chain + risk | accept all |
35
+ | D2 子问题假设确认 | **each subproblem starts** | the assumptions for THIS subproblem only (S-class), each with statement + basis chain + risk | accept all |
36
+ | D2' 新假设插问 | mid-subproblem discovery that changes model structure | the new assumption + its effect | record-and-continue |
37
+ | D3 方向选择 | CANDIDATES_READY | candidate matrix with a literature column per direction; user picks or authorizes auto | baseline |
38
+ | D4 结果裁决 | VERIFY done | verdict + evidence digest + key intermediate results (residual/constraint-violation distributions, figure paths) + failure details | verdict-implied |
39
+
40
+ ## D0 deep restatement — six sections (MANDATORY structure)
41
+
42
+ 1. **题目要点摘录**:the problem's own numbers and constraints, quoted.
43
+ 2. **背景解读**:the engineering/physical mechanism behind the problem.
44
+ 3. **数据语义**:every attachment, column by column — meaning, units,
45
+ coordinate system, magnitudes; unreadable artifacts are flagged with the
46
+ minimum representation needed.
47
+ 4. **隐含信息与歧义清单**:numbered; each entry = the LLM's reading + its
48
+ basis + the risk if the reading is wrong. This is the heart of the
49
+ exchange: the user corrects entries here.
50
+ 5. **各子问题数学本质判定**:every sub-question of the problem — however
51
+ many there are (one or ten) — is classified (fitting/optimization/
52
+ geometric optics/simulation/…), with why.
53
+ 5.5 **问间依赖关系**:which sub-questions depend on which (models, data,
54
+ verified claims reused downstream) — the整体感 guarantee: later questions
55
+ REFERENCE earlier verified results instead of re-deriving them.
56
+ 6. **待澄清问题**:open questions inviting the user to add background,
57
+ correct a reading, or supply their own references — never a yes/no list.
58
+
59
+ After the user answers, problem-brief.md is updated and the delta is shown.
60
+
61
+ ## D-R literature research (pre-modeling, mandatory)
62
+
63
+ 1. The LLM searches by direction × method for principles and methods only —
64
+ engineering background, methodology papers, textbooks, official docs.
65
+ **Never** search for solutions/answers to the specific contest problem.
66
+ 2. Findings are written to research/sources.jsonl (author/title/year/venue/
67
+ URL/retrieval date/excerpt with section or theorem/table location/mapped
68
+ direction). Every candidate in the method matrix gets a literature column
69
+ referencing these source ids; a direction with no literature must be
70
+ explicitly marked "原创方向" with its derivation basis.
71
+ 3. The user is asked: endorse / reject / add their own references. User-added
72
+ references join sources.jsonl with the same fields.
73
+ 4. The D-R interaction record goes into ledger.scope.interactions; the gate
74
+ refuses CANDIDATES_READY without it.
75
+
76
+ ## Honest boundary of the gate
77
+
78
+ The gate is a MECHANISM guarantee, not an anti-fraud guarantee: it proves a
79
+ record exists, never that the record is true — every interaction record is
80
+ written by the agent itself. Falsified records are therefore out of the
81
+ gate's reach; the defense against them is the blind verifier subagent
82
+ (subagent-dispatch.md), which re-derives key claims from data alone, and the
83
+ artifact checks (research/sources.jsonl, attempts/N/report.md) that tie each
84
+ record to real files on disk.
85
+
86
+ ## Rules
87
+
88
+ - D0/D1/D-R: once per task. D2/D3: once per subproblem. D2': only when a
89
+ discovery changes model structure. D4: once per attempt round.
90
+ - Every L1 record is appended to `ledger.scope.interactions` as
91
+ `{id, decisionPoint, question, options, userAnswer, timestamp, effectOnModel}`
92
+ or, for explicit auto authorization,
93
+ `{auto: true, decisionPoint, reason}`.
94
+ - Run the gate before every transition: `run-state.mjs gate <dir> --to <status> --reason "<...>"`.
95
+ The gate refuses SCOPE_FROZEN without D0+D1, CANDIDATES_READY without D-R,
96
+ ATTEMPT-from-CANDIDATES_READY without D3, terminals-from-VERIFY without D4,
97
+ and REVISE/RESEARCH (from VERIFY) whose reason fails to reference a
98
+ `decisionStack` entry id. The CLI `transition` command enforces the same
99
+ gate and has NO escape hatch. Every D4 record carries the attempt number it
100
+ adjudicates (`attempt: N`); the terminal gate requires the D4 for the
101
+ CURRENT attempt. ATTEMPT from CANDIDATES_READY requires `--subproblem <id>`.
102
+ Terminal gates additionally require `scope.cleanupPassed: true` and the
103
+ current attempt's report.md on disk. Mechanism-level tests and unattended
104
+ batch runs may declare `scope.contractExempt: true` — production modeling
105
+ must never set it.
106
+
107
+ In v0.5, report/evaluation/terminal transitions also read answer-coverage.json when the v3 ledger has registered requirements. Missing or stale mappings are hard blockers; partial mappings and explicit waivers are conditional-only. EVALUATE and CORRECTION_REQUIRED are non-final lifecycle states. An evaluation finding creates a correction lineage and never rewrites the parent run or silently upgrades a claim.
108
+
109
+ ## Phase pace interactive beats between phases (v2.8)
110
+
111
+ The exposition is delivered PHASE BY PHASE, never as a firehose. The phase
112
+ sequence is: restatement analysis assumptions modeling solving
113
+ verification robustness evaluation. Between every two phases there MUST
114
+ be a user interaction point: the completed phase is presented, one line asks
115
+ whether to proceed to the next phase, and the user may interrupt, ask for a
116
+ deeper explanation of any step of the just-finished phase, or contribute
117
+ knowledge. Sensitivity/robustness NEVER follows solving automatically it
118
+ only starts after the verification phase, the user's go-ahead, and its own
119
+ D-interaction. Within a phase with ≥3 major steps, offer the user one
120
+ interruption opportunity after the first step.
121
+
122
+ ## L2 display points (MUST show, never ask)
123
+
124
+ - After every attempt round: the 8-section runlog digest (see report-contract.md).
125
+ - Before every transition: one status line: `[状态] FROM → TO:一句话原因`.
126
+ - When starting any command estimated > 60 s: say what, how long, and what
127
+ continues in parallel (see tool-policy.md).
128
+
129
+ ## L3 interruption
130
+
131
+ - The user may interrupt at ANY time ("停/换方向/改假设/结束").
132
+ - On interrupt: stop the current execution chain immediately, then return to
133
+ the nearest decision point on the stack and ask again.
134
+ - An interrupt never leaves the run directory inconsistent: run-state writes
135
+ are atomic and lock-guarded; in-flight background jobs are killed or awaited
136
+ before any transition is recorded.
137
+
138
+ ## Decision stack and backtracking
139
+
140
+ - Every L1 decision also appends to `ledger.scope.decisionStack`:
141
+ `{id (e.g. D3-SP1), point, choice, at, reason}`.
142
+ - REVISE/RESEARCH (from VERIFY) reasons MUST reference the stack entry being
143
+ revisited (e.g. "回退到 D3-SP1:M2-area 违反 0.07% 边长约束,改 M1-cheb").
144
+ - A wrong direction returns to its fork point: FORK records the fork entry in
145
+ the stack; each failed branch leaves a wall memo before the next branch runs.
146
+ - Assumption revisions keep history: `revisionHistory: [{at, reason, changedTo}]`,
147
+ and every downstream claim/obligation that depended on the old assumption is
148
+ marked `stale: true` with the revising assumption id (see claims-evidence.md).
149
+
150
+ ## Live documents (every phase can be refined later)
151
+
152
+ Every phase artifact is LIVE: problem-brief.md (restatement), analysisLog,
153
+ assumptions, sources.jsonl, methods.md, attempt reports. While solving,
154
+ anything discovered that shows an earlier phase was incomplete is patched
155
+ INCREMENTALLY — revision record + downstream stale marking — without
156
+ re-running completed unaffected work. This is the "解题中不断完善" rule.
157
+
158
+ ## Rolling documents
159
+
160
+ - Problem restatement: written once at intake (problem-brief.md); only
161
+ referenced afterwards; a restatement edit re-opens scope freeze.
162
+ - Problem analysis: written per subproblem and appended on every discovery;
163
+ ledger.subproblems[].analysisLog = `[{at, entry, trigger}]`.
164
+ - Assumptions: registered per subproblem, revised incrementally; never assume
165
+ the full problem's assumptions are known up front.
@@ -0,0 +1,19 @@
1
+ # Original GitHub workflow parity
2
+
3
+ The DSH bundle is a faithful workflow migration of the original
4
+ MathModelingAgent project, not a replacement of its useful behavior.
5
+
6
+ | Original GitHub behavior | DSH realization |
7
+ |---|---|
8
+ | PDF/problem extraction in `code/agent.py` | intake D0 and the subproblem DAG |
9
+ | Excel attachment profiling in `code/data_analyzer.py` | INPUT_PROFILED and the run input manifest |
10
+ | sequential subproblem solving | dependency-ordered SPi loop |
11
+ | Modeler → Analyzer → Correction loop in `code/prompts.py` | explorer/modeler → verifier/analyzer → corrector/revise |
12
+ | per-round thinking and run logs | attempts/<n>/report.md, events.jsonl, and chat runlog digest |
13
+ | acceptance/rejection and stagnation control | D4 verdict, progress test, REVISE/FORK, and resumable non-SOLVED states |
14
+ | hash-based cache and resume | run-local artifacts, evidence links, and state recovery |
15
+
16
+ The migration deliberately replaces private chain-of-thought storage with
17
+ human-readable reasoning, evidence, and reproducible artifacts. The roles and
18
+ loop semantics remain; only the execution substrate changes from the legacy
19
+ Python CLI to DSH skills and state files.