Simulation primitives: useful-flow (Phi) + sensitivity, in both languages - #5
Merged
Conversation
…n both languages Adds the cmg-native simulation capability the Tower simulations surfaced: score configurations by useful flow (Phi = quality/cost) and rank knobs by sensitivity (what to tune next). Configuration what-if + sensitivity is cmg's lane; flow-network min-cut stays in intelligence-flow. - core: usefulFlowScore + combineCost/combineQuality (TS + Python), beside compareRuns. - math: sensitivity + rankSensitivity, finite-difference gradient (TS + Python), beside errorSensitivity. - example 08-system-simulation in both languages: sweep a parameterized pipeline, score by Phi, pick the best, rank knobs by sensitivity. TS and Python output is byte-identical; each has a self-check + expected-output.txt. - docs/05-useful-flow-and-sensitivity.md: the math/principle (network flow for Phi, finite-difference gradient for sensitivity), framed for math / engineering / CS. - CHANGELOG entries (Change / Why / Domain influence / Languages). No modelgraph changes (cmg is standalone). Parity enforced. Domain-free. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first feature on the dual-language structure (follows #4). Adds the cmg-native simulation capability the Tower simulations surfaced: score configurations by useful flow (Phi = quality / cost) and rank knobs by sensitivity (what to tune next). Configuration what-if + sensitivity is cmg's lane; flow-network min-cut/critical-path stay in intelligence-flow.
New primitives (TS + Python, parity)
usefulFlowScore+combineCost/combineQualityincore(besidecompareRuns): Phi = Q / C, useful output per unit cost. Placed in the zero-depcoreso every layer can use it. Domain influence: network flow / OR.sensitivity+rankSensitivityinmath(besideerrorSensitivity): the central finite-difference gradient d(objective)/d(knob), ranked by magnitude. Domain influence: calculus / neural gradient / control.Example
08-system-simulationin both languages: sweep a parameterized pipeline, score each config by Phi (quality bounded viasigmoid, cost summed from recorded trace signals), pick the best, then rank knobs by sensitivity. The cost lives on the trace, so the run is inspectable.TS and Python output is byte-identical (verified by diff); each ships a PASS/FAIL self-check and
expected-output.txt. Example output:Math in the code
Per the request, the principle is documented, not just named:
docs/05-useful-flow-and-sensitivity.mdframes Phi (network flow / OR) and sensitivity (calculus / gradient / control) for a math, engineering, or CS reader, and each primitive carries a full math docstring.Discipline
Both languages at parity; CHANGELOG entry per capability (Change / Why / Domain / Languages); domain-free; no modelgraph changes (cmg is standalone);
pnpm typecheck+ tests green, Python smoke green. Deferred (noted): Monte-Carlo sampling, and Python parity-catchup ofcompareRuns/evaluators/feedback.🤖 Generated with Claude Code