falaw.schema_export#
Export the Python SSOT as committed JSON for the TypeScript twin (ts/).
falaw ships twice: as this Python package and as the npm package falaw-client
(ts/), which plans in the browser and executes through a server relay.
The two must agree on the plan and result shapes, the model catalogue and its
prices, the cost rules, the model-picking rules, the response parser, and the
canonical byte-form every hash is taken over. None of that is re-authored on
the TypeScript side: this module writes it out as JSON, the TS build generates
its types from the schemas and reads the catalogue as data, and its parity tests
replay the fixtures below and assert the same output, hash for hash.
What lands in <out_dir>:
call-plan.schema.json,result.schema.json,model-record.schema.json— the dataclasses as JSON Schema (viapydantic.TypeAdapter), the codegen inputs for the Zod types.models.json— the catalogue, byte for byte, so the TS side can compute the samemodels_table_versiondigest afalaw.CostBasisrecords.constants.json— the default backend, the plan dict schema tag, the catalogue pricer identity, the tier order, the response-kind keys, and the literal vocabularies (OutputKind,CacheStatus).fixtures/plans.json— planner inputs → theCallPlandict this package builds (cost, basis and all) and itsplan_hash; plus multi-call plans.fixtures/responses.json— raw fal responses → theResultthis package parses them into.fixtures/pick_model.json,fixtures/cost.json,fixtures/canonical.json— model selection, cost estimation, and the canonical blob + SHA-256 for a set of payloads (the byte-form parity that makesplan_hashagree).
tests/test_schema_export.py pins the committed directory to a fresh export,
so a change here that forgets python -m falaw export-schema fails CI on this
side, before the TS side can drift.
>>> from falaw.schema_export import PLAN_CASES
>>> PLAN_CASES[0]["tool"]
'generate_image'
Functions
|
Write the JSON contract under |
- falaw.schema_export.export_schema(out_dir=None)#
Write the JSON contract under
out_dir; return the paths written.out_dirdefaults to theschema/directory of this checkout. This is repository tooling: from an installed wheel (nopyproject.tomlbeside the package) it refuses rather than writing a strayschema/wherever the shell happens to be.