Completes the "go all" reach: the standalone `invariants` command and the new
one-shot `analyze` are now first-class in both SDKs.
python/lawsynth analysis.py: invariants() and analyze() methods + frozen
dataclasses (Invariant/InvariantReport, Skipped, AnalyzeReport). _parse_analyze
composes the existing _parse_stability/_parse_lyapunov/_parse_invariants over the
sub-objects (asserted identical to the standalone parsers) and narrows a
{skipped:true} slot to Skipped. analyze/invariants attached to Study/
DiscoveryResult. test_analysis 66 passed; full suite 160 passed / 9 skipped.
packages/world-schema + api-client: InvariantReport + AnalyzeReport interfaces,
parseInvariantReport/parseAnalyzeReport (+ validators, isSkipped guard).
parseAnalyzeReport reuses the standalone validators and re-paths child issues.
api-client 34 pass; world-schema green.
Keys confirmed against crates/lawsynth-cli/src/{invariants,analyze}.rs render_json
AND verbatim CLI capture. Honest note: invariants --box is a single shared LO:HI
interval (vs analyze's per-state box) — the clients encode each correctly.
@lawsynth/world-schema
Dependency-free TypeScript contracts and validation for the LawSynth world boundary.
This package does not decode .lsworld archives or simulate a world. Those are
Rust responsibilities (lawsynth-bundle and lawsynth-sim). Its job is to
reject source data that cannot be represented by the current Rust core before a
client submits it for encoding.
Current executable boundary
The bundle manifest is exactly:
{
"format": "lawsynth-world",
"format_version": "0.1.0",
"world_encoding": "lawsynth-world-binary-v1"
}
validateManifest accepts only those three fields. This mirrors the Rust
reader, which compares the manifest bytes against its current supported form.
validateRustWorldSource validates the JSON-shaped source form for the scalar
Rust World IR:
- variables have one of the implemented roles:
state,control,exogenous,observed,latent, orderived; - parameters and expression constants are finite scalar numbers;
- only continuous or discrete laws are accepted, with exactly one law per state variable;
- expressions use constants, symbols,
neg|exp|log|sin|cos, andadd|sub|mul|div|pow, with Rust's depth limit of 127 nested nodes; - identifier, symbol, unit, and dimensional checks mirror the current Rust
Identifier,Unit, and World construction rules.
Events, regimes, stochastic laws, custom calls, delay expressions, graph metadata, signatures, and catalog metadata are deliberately rejected by that validator because the current binary world encoding cannot persist them. The related TypeScript interfaces are descriptive data contracts for future-facing tools; they must not be treated as executable-core support.
Usage
import { assertRustWorldSource, validateManifest } from "@lawsynth/world-schema";
const manifest = validateManifest({
format: "lawsynth-world",
format_version: "0.1.0",
world_encoding: "lawsynth-world-binary-v1",
});
const world = assertRustWorldSource({
formatVersion: "0.1.0",
id: "decay",
time: { kind: "continuous", unit: "s" },
variables: [{ id: "x", role: "state", unit: "1" }],
parameters: [{ id: "rate", value: 0.2, unit: "1/s" }],
laws: [{
kind: "continuous",
target: "x",
expression: {
kind: "binary", operator: "mul",
left: { kind: "unary", operator: "neg", operand: { kind: "symbol", id: "rate" } },
right: { kind: "symbol", id: "x" },
},
}],
});
validateBundleCatalog is intentionally separate from validateManifest: a
catalog describes artifacts for a UI or registry, while manifest.json is the
small fixed document embedded in a Rust bundle.
Development
Run npm test inside this package (or tsc -p tsconfig.json --noEmit for a
type-only check). The test runner uses no test framework or runtime dependency.