Skip to content

feat: useful-flow Phi + sensitivity primitives (+ example 08 system-simulation) - #6

Merged
bigboateng merged 1 commit into
mainfrom
feat/cmg-simulation
Jun 14, 2026
Merged

feat: useful-flow Phi + sensitivity primitives (+ example 08 system-simulation)#6
bigboateng merged 1 commit into
mainfrom
feat/cmg-simulation

Conversation

@bigboateng

Copy link
Copy Markdown
Contributor

What

Adds the two simulation-derived primitives to both languages, plus a domain-free example that exercises them.

  • usefulFlowScore (core) - Phi = Q / C, the useful-flow-to-an-accepted-sink score (network flow / OR), with combineCost / combineQuality helpers.
  • sensitivity / rankSensitivity (math) - finite-difference d(objective)/d(knob); ranking knobs answers "what to tune next".
  • Example 08 - system simulation: sweep a parameterized pipeline by Phi, pick the config that earns its cost, then rank knobs by sensitivity. The graph is real (each stage records its cost signal; the self-check confirms trace-Phi == model-Phi).
  • docs/05-useful-flow-and-sensitivity.md, CHANGELOG.md, smoke test.

Parity

Primitives ship in TypeScript and Python; example 08 output is byte-identical across both (expected-output.txt).

Verify

pnpm --filter @composable-model-graph/example-08-system-simulation start   # PASS
python3 python/examples/08-system-simulation/main.py                       # PASS, identical output

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants