projects:write and rulesets:write. Set AETHIS_API_KEY in your environment. If you’re using MCP, the key goes in the MCP client config (see MCP install).
Phase 1 — Section discovery
Legislation often covers multiple independent criteria. Split each into its own section so they can be tested and regenerated separately. The two interfaces approach this differently. MCP has an explicitaethis_discover_sections tool the agent calls before authoring. The CLI infers section structure at generate time from the source documents plus any guidance you provide — if you want explicit sections, drop one source file per section into sources/ or add section hints to guidance/hints.yaml.
- CLI
- MCP
Authoring is multi-step and tightly stateful (project → sources → fields → generate → publish). The CLI and MCP tools orchestrate this for you. The Python SDK does not yet expose authoring endpoints; the raw HTTP endpoints are listed in the REST API reference for completeness but are not the recommended path.
Phase 2 — Field vocabulary
Define the input fields each section will consume. Shared vocabulary across sections lets rulebooks compose cleanly. The two interfaces approach this differently too. MCP exposes explicit discovery and pinning tools the agent invokes before generation. The CLI infers fields at generate time from your test inputs intests/scenarios.yaml — the field IDs you write into your tests become the field vocabulary. Use prefixed names (applicant.age, household.income) to keep namespaces tidy across sections.
- CLI
- MCP
guidance/hints.yaml — e.g. “applicant.visa_status is an enum with values student, work, settled.”Phase 3 — Rule generation (TDD loop)
The only phase with an automated test gate. Test-first is non-negotiable: write the tests, THEN generate, THEN iterate until green.Step 3.1 — Write tests
Test cases drive everything — the generator iterates until every test passes, the publish endpoint refuses to ship a ruleset with a failing test, and (for the CLI) the field vocabulary is inferred from your test inputs. The default location afteraethis init is tests/scenarios.yaml for the CLI; for MCP-driven authoring, test cases are supplied inline to aethis_create_ruleset or aethis_generate_and_test.
Step 3.2 — Generate
- CLI
- MCP
Step 3.3 — Review + refine
- CLI
- MCP
refine command. If a test fails:- Re-read the failing case — was the relevant clause in
sources/actually clear? - Add a guidance hint in
guidance/hints.yaml, e.g. “The age cap is 65, not 60 — see Section 7.2.” - Re-run
aethis generate --poll && aethis test.
Step 3.4 — Publish
Only publish whenaethis test shows 100% pass. The publish endpoint runs the tests again server-side as a gate.
- CLI
- MCP
Composing sections into a rulebook
Once each section has an active ruleset with a stable slug, create the rulebook. See the worked UK Free School Meals example for a full multi-section composition including theoutcome_logic AST.
outcome_logic must be a proper Expr AST. The server rejects the text shorthand { "expr": "A AND B" } with HTTP 422 at ingress since aethis-core 0.7.2. To find the group names your sections emit, inspect each ruleset’s compiled criteria — or use a known pattern like the one in the FSM example.
Verification checklist
Before declaring a rule complete:aethis testpasses 100% on the ruleset that’s about to be published/decidewith the publishedruleset_idreturns the expected decision for each test input- If the rule is public-facing,
visibilityispublic(auto-set foraethis/*slugs; usePATCH /rulesets/<id>/visibilityotherwise) - The ruleset shows up in
GET /api/v1/public/rulesets(public) or via the authored key (private)
Next steps
- Debug a failing decide — when tests pass but
/decidesurprises you - Worked examples — full projects you can crib from
- MCP tools reference — every authoring tool