بنقرة واحدة
generate-calculations
// Use when the user wants to turn a validated extract-parameters-from-full JSON into a Python module of deterministic functions implementing the formula_hint expressions for downstream scenario runs and Monte Carlo
// Use when the user wants to turn a validated extract-parameters-from-full JSON into a Python module of deterministic functions implementing the formula_hint expressions for downstream scenario runs and Monte Carlo
Use when the user wants to extract parameters from a PlanExe extraction-input digest (the markdown produced by experiments/napkin_math/prepare_extract_input.py — the 137-recommended section bundle, with the four "Keep or compress" sections compressed) instead of the full PlanExe HTML report
Use when the user wants to extract parameters, modelling values, or key variables from a PlanExe report (HTML or text) for napkin math, triage, or Monte Carlo simulation
Use when the user wants to generate low/base/high assumption ranges (bounds) for missing or uncertain variables in a validated extract-parameters-from-full JSON, in preparation for deterministic scenarios or Monte Carlo
Use when the user wants to run the napkin-math pipeline end-to-end on a PlanExe report, or resume a partially populated output directory by filling in only the missing stages. Orchestrates digest preparation, parameter extraction, validation, bounds, calculations, scenarios, Monte Carlo, and assessment rendering. Never copies artifacts forward from prior runs, and never re-runs a stage whose output is already on disk.
Use after the napkin_math pipeline has produced parameters/bounds/scenarios/montecarlo JSON to generate a plan assessment (assessment.md) — a thin interpretation layer over the intermediary artifacts. Emits a JSON manifest, a provenance map, gate verdicts (Critical / Fragile / Marginal / Robust), failure drivers, confidence and trust boundaries, scenario sanity check, and suggested next actions. The artifact is a navigation/judgment file, not a copy of the raw simulation data.
Use after the napkin_math pipeline has produced parameters.json (from extract-parameters-from-digest or extract-parameters-from-full) to validate it against the 16 structural checks the rest of the pipeline assumes. Writes validation.json next to parameters.json. Deterministic Python — no LLM call.
| name | generate-calculations |
| description | Use when the user wants to turn a validated extract-parameters-from-full JSON into a Python module of deterministic functions implementing the formula_hint expressions for downstream scenario runs and Monte Carlo |
Wraps the calculation-generator system prompt at system-prompt.txt (next to this file) and applies it to a parameter JSON produced by extract-parameters-from-full (validated by validate-parameters). Output is a single Python module of small, pure functions — one per formula_hint declared in recommended_first_calculations and derived_questions.
Stage 5 of the pipeline described in planexe_simulator/README.md.
validate-parameters (passes clean) / generate-bounds and run-scenariosNot for: regenerating the parameter JSON (use extract-parameters-from-full), validating it (use validate-parameters), producing low/base/high ranges (use generate-bounds), or running scenarios (use run-scenarios).
system-prompt.txt (sibling of this SKILL.md). Its function-shape, division-guard, and module-structure rules are authoritative.validate-parameters; if it visibly hasn't, tell the user and offer to validate first.<input-basename>.calculations.py next to the input. Print the file path back, plus a one-line summary (function count, any # skipped lines, any TODO stubs for P(...) notation).| Input list | Action |
|---|---|
recommended_first_calculations | one function each |
derived_questions | one function each |
key_values | not converted — these are caller-supplied inputs |
missing_values_to_estimate | not converted — supplied via bounds at scenario time |
Skip an entry whose formula_hint is null, empty, or unparseable. Replace with a # skipped: <id> -- <reason> comment.
def x(a: float, b: float) -> float:
return a * b
formula_hint if present, else the entry's iddepends_on id in declared order, all typed floatfloatif, optional intermediate, return)Division guards: every variable denominator must short-circuit to float("inf") when ≤ 0. Numeric-literal denominators (e.g. value / 100) need no guard.
| Source | Translation |
|---|---|
max(...), min(...), abs(...), sum(...) | Python builtins |
exp(...), log(...), sqrt(...), ln(...) | math.exp, math.log, math.sqrt (add import math) |
mean(...), avg(...) | _mean(*args) helper at top of module |
P(...), p(...) | raise NotImplementedError(...) stub with TODO comment carrying the original formula |
"""
Generated PlanExe deterministic calculations.
Plan: <plan_name>
Plan type: <plan_type>
One function per formula_hint entry...
"""
from __future__ import annotations
import math # only if needed
# _mean helper, only if needed
# functions, in order: recommended_first_calculations, then derived_questions
No top-level executable code, no __main__ block, no file I/O, no classes, no decorators, no per-function docstrings, no in-body comments (except the P(...) TODO).
| Mistake | Fix |
|---|---|
Wrapping the Python output in ```python fences | Raw Python only |
Adding a if __name__ == "__main__": demo block | This stage emits a library, not a runnable script |
| Generating a class hierarchy | One function per formula; no classes unless required by the formulas themselves (they aren't) |
| Inventing or omitting arguments to "make the formula work" | Args must match depends_on exactly, in order |
| Forgetting the divide-by-zero guard | Every variable denominator gets a guard; numeric literals don't |
Emitting def people_contacted(...) -> float: """People contacted""" | No per-function docstrings — the signature is self-documenting |
Translating P(x >= y) as a literal Python comparison | P(...) is probability notation; emit a NotImplementedError stub instead |
Including functions for key_values or missing_values_to_estimate ids | Those are inputs, not calculations |
system-prompt.txt../../README.md, Stage 5../extract-parameters-from-full/SKILL.md, ../validate-parameters/SKILL.md, ../generate-bounds/SKILL.md/tmp/extract-params-heatwave-v10.json (passes validate-parameters with valid: true)