Jaxonomy

From machinavitalis/jaxonomy · View interactive version

Jaxonomy is an AI agent skill from the GitHub repository machinavitalis/jaxonomy. You are using Jaxonomy, a JAX-native engine for modeling and simulating hybrid

How to use this skill

Skill file

Jaxonomy Skill

You are using Jaxonomy, a JAX-native engine for modeling and simulating hybrid

dynamical systems by block-diagram composition. This file is your operating

manual for using the library. Read it before suggesting any Jaxonomy code.

(If you are modifying Jaxonomy itself, read AGENTS.md and the AGENTS/

docs instead.)

What Jaxonomy does

Jaxonomy composes continuous physics, discrete control, and event-driven logic

into a single model, and runs it on JAX — JIT-compilable, vmap-batchable, and

differentiable end to end. Its thesis: modeling and simulation is most

useful when it is optimization-ready, so every output, objective, and

constraint is differentiable w.r.t. parameters, initial conditions, and network

weights by default.

It is the engine at the base of a larger stack (robotics and embedded

deployment layer on top of it). For the full architecture, design philosophy,

and invariants, read AGENTS/CONTEXT.md — don't restate it here.

When to use Jaxonomy

Use it when the user is:

or hybrid) and simulating it.

a plant.

trajectory optimization, controller tuning, neural ODE / SINDy, digital-twin

updates.

jaxonomy.acausal.

When NOT to use Jaxonomy

block-diagram composition, hybrid dynamics, events, and state machines on top

of a solver — if none of that is needed, it's overhead.

the robotics layer built on top of Jaxonomy. Don't re-implement URDF import,

articulated dynamics, or WBC here.

deployment concern, out of scope for Jaxonomy.

what this library is; see AGENTS/CONTEXT.md ("What Jaxonomy is NOT").

Core API surface, in order of how often agents will use it

Build a diagram, create a context, simulate

import jaxonomy as jx

builder = jx.DiagramBuilder()
plant      = builder.add(jx.library.LTISystem(A, B, C, D))
controller = builder.add(jx.library.LinearQuadraticRegulator(A, B, Q, R))
builder.connect(plant.output_ports[0], controller.input_ports[0])
builder.connect(controller.output_ports[0], plant.input_ports[0])

diagram = builder.build()
context = diagram.create_context()          # holds state + parameters
results = jx.simulate(
    diagram,
    context,
    (0.0, 5.0),                             # t_span, a (start, stop) tuple
    recorded_signals={"x": plant.output_ports[0]},
)
print(results.time.shape, results.outputs["x"].shape)

.output_ports[i] you wire with builder.connect(src_out, dst_in).

through; don't mutate it in place.

is differentiable and jit/vmap-friendly. The time span is a

(start, stop) tuple, passed positionally or as t_span= — there is no

stop_time, start_time, or end_time keyword.

the run still succeeds but results.time and results.outputs are both

None. This is the most common reason a first Jaxonomy script appears to

produce nothing.

Library blocks

Standard blocks live under jx.library, split by category (sources, math_ops,

logic, routing, dynamics, nonlinearities, tables); jx.library.primitives

re-exports them for back-compat. Controls/estimation blocks (LQR, MPC, PID,

Kalman/EKF/UKF) are library blocks too — prefer them over hand-rolling.

Analysis and optimization

nyquist_data, step_response, frequency_response, …) return plain dicts

of arrays (no matplotlib inside Jaxonomy — you plot).

dependency structure with autodiff Jacobians on every edge. Use it to answer

"what actually drives this signal" quantitatively rather than structurally —

.slice(target, threshold) (vs .structural_slice(target) for the boolean

over-approximation), .attribute(target, source) (signed per-path chain

rule), .dominant_paths, .dead_edges, .bottlenecks. Read the module

docstring before reading a weight: weights are dimensionless elasticities by

default, edges into a continuous state are scaled by tau (which makes a

path's product its gain at ω = 1/tau), and anything non-differentiable is

labelled local_gradient=False rather than silently zeroed.

analysis.influence_subgraph(graph, focus, budget_tokens=…)

serializes a bounded, citable neighbourhood when you need to reason about one

part of a model too large to read whole.

optimization, and controller tuning are just gradient-based optimizations

over the simulation — use JAX autodiff / the provided tuning helpers.

For exact signatures, see the docs at py.jaxonomy.com and the examples/

notebooks — prefer those over guessing an API.

Key gotchas

goes through the npa abstraction, not jnp directly — it's a load-bearing

invariant. If you write library-style code, follow the pattern in

AGENTS/PATTERNS.md; as a user composing existing blocks you rarely touch

it, but don't assume raw jnp everywhere.

results / context; don't try to assign into it.

break gradients (Python-side branching on traced values, in-place mutation),

reach for the block/pattern that preserves them.

Common pitfalls & idioms

Hard-won usage tips (harvested from prior consumer sessions):

diagram.with_parameters({"block.p": v}) in a Python loop reuses the compiled

kernel, but copies the diagram and creates a context for every value (44 ms at

159 blocks, against 3 ms through the context). For a long sweep change the

value through the context, or use simulate_batch / jax.vmap from the start.

scipy.optimize.minimize_scalar pays the same cost per evaluation.

outer.with_parameters({"inner.gain.gain": jnp.array(5.0)}) — don't reach into

outer["inner"] (you'll get a stale outer diagram). The dot-path form also

composes under vmap.

constructs fine but crashes at the first step deep in the scheduler.

isinstance(x, jax.core.Tracer), not jax.core.is_concrete — the latter is

True under jax.grad's tracer and silently breaks gradients.

library uses mode= on Quantizer/Saturate, so the typo is natural).

upper_limit=+L, lower_limit=-L.

context-less shortcut), the time span is one (start, stop) tuple rather than

two scalars, and options must be a SimulatorOptions, not a dict. Results

come back empty — res.time is None — unless you pass

recorded_signals={name: port}; with it, read res.time and

res.outputs[name].

(the recorder silently truncates to the tail when its ring buffer fills) and

use ode_solver_method="bdf" for stiff fast+slow coupling (the explicit

default collapses its step size).

with declare_continuous_state(..., ode=cb, requires_inputs=True) and the

command with `declare_output_port(..., requires_inputs=True,

prerequisites_of_calc=[DependencyTicket.xc])`. Wiring controller↔plant is not

an algebraic loop if the plant exposes state via

declare_continuous_state_output (a state output, not feedthrough).

When to escalate to the human

Python-control-flow-over-traced-values mistake.

rather than a modeling bug.

rather than bolting kinematics into a Jaxonomy model.

Where to find more

not (read both before relying on a surface).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.