@yutra/rule-compiler provides the first deterministic Rule Compiler core for the vNext creation layer.
It compiles a validated Pack Config into a fixed set of demo/mock artifacts.
Current scope is intentionally narrow:
- archetypes:
request-resolution,approval-decision, andknowledge-answering - input: public demo Pack Config from
@yutra/pack-config-core - output: six deterministic artifacts
- mode:
previewandpublishgates
It does not connect Runtime directly and does not connect Studio UI directly.
P6-04B adds a thin CLI/export layer on top of this core package. See Rule Compiler CLI. P6-05A adds a local Studio Compile Preview through builder-runner. That preview calls this package in memory and still does not execute Runtime or write artifacts. P6-06A adds Rule Impact Explanation in the Creator Workbench using Pack Config metadata. That layer explains field impact but does not change compiler output. P6-06B adds Certification Readiness Preview derived from compile output. It does not execute Runtime, does not execute test cases, and does not run official certification. P6-11B.1 adds a separate Scenario Composition Compile Preview that calls this package once per namespaced Slot. It does not merge Pack Configs, change the three individual compilers, generate a top-level executable DSL, or execute Runtime.
Natural Requirement
-> AI Draft Config
-> Pack Config JSON
-> Rule Compiler
-> DSL / Policy / Templates / Tests / Trace Expectations
-> Canonical IR
-> Runtime
The compiler is deterministic. AI may draft Pack Config, but AI does not compile or execute runtime control flow.
The input is:
type RuleCompilerInput = {
config: PackConfig
mode?: "preview" | "publish"
locale?: "en" | "zh-CN"
}preview is the default. publish applies stricter gates.
The compiler produces six artifacts:
| Artifact | Purpose |
|---|---|
agent.yutra.yaml |
Generated Yutra DSL execution structure |
policy.yaml |
Governance and fail-closed policy artifact |
adapter.config.json |
Mock / placeholder adapter mapping artifact |
templates.json |
Generic demo response templates |
test-cases.json |
Normal, boundary, exception, and handoff test cases |
trace.expectation.json |
Expected trace event and fail-closed markers |
Each artifact includes deterministic content and a sha256:<hash> value.
Every compile result includes:
packConfigHashcompilerVersionmodefailClosedPolicy=enabled- coverage summary
- artifact hashes
- warnings
This prepares for future audit binding. The compiler does not write trace events.
@yutra/rule-compiler exposes a deterministic readiness preview helper.
It derives readiness gates from a RuleCompilerOutput:
- compile
- artifacts
- test cases
- trace expectation
- fail-closed
- publish gate
- side effect
- adapter safety
- manual runtime run
- official certification
The preview is intentionally conservative. Demo/mock output is expected to remain warning until manual Run Preview evidence and official certification evidence are attached.
It does not call Runtime, execute generated DSL, execute test cases, write artifacts, or claim production readiness.
The compiler blocks:
- invalid Pack Config
- unsupported archetype
requiredButMissingfields- secrets
- real endpoints
- unconfirmed AI fields in publish mode
real_placeholderadapters in production-like publish- missing handoff fallback
- unsafe write-or-higher automatic side effects
Preview mode may allow warnings, but it still blocks secrets, real endpoints, and missing required fields.
The first compiler supports the public request-resolution basic config.
It maps public field groups:
- capabilities
- refund policy basics
- handoff policy basics
- response style basics
It intentionally avoids customer SOP, real adapter mappings, and complete industry rule matrices.
The second compiler supports the public approval-decision basic config.
It maps public field groups:
- capabilities
- approval policy basics
- risk policy basics
- response style basics
It generates the same six artifacts as request-resolution:
agent.yutra.yamlpolicy.yamladapter.config.jsontemplates.jsontest-cases.jsontrace.expectation.json
It intentionally avoids real enterprise approval procedures, real approval hierarchy, production adapter mappings, organization data, customer SOP, and delivery templates.
Creator Workbench UI is demo-enabled for approval-decision. The current support remains demo/mock only: Pack Config + Rule Compiler + CLI + Compile Preview UI, with no Runtime execution or real approval system integration.
The third compiler supports the public knowledge-answering basic config.
It maps public field groups:
- capabilities
- knowledge policy basics
- source citation policy basics
- response style basics
It generates the same six artifacts:
agent.yutra.yamlpolicy.yamladapter.config.jsontemplates.jsontest-cases.jsontrace.expectation.json
It intentionally avoids real answer generation, real knowledge base content, real retrieval provider configuration, real source endpoints, customer knowledge assets, customer SOP, and delivery templates.
Creator Workbench UI is demo-enabled for knowledge-answering. Current support remains demo/mock only and does not call a real LLM, connect a real retrieval provider, or execute Runtime automatically.
@yutra/scenario-composition-compiler reuses compilePackConfig for each
validated Composition Slot. Every Slot retains its own Pack Config identity,
config hash, six canonical artifacts, and artifact hashes under a separate
namespace.
The composition package does not alter Rule Compiler semantics. Its top-level JSON files describe routes, bindings, overlays, precedence, Slot indexes, and the deterministic preview report. They are not an executable Orchestrator DSL. See Scenario Composition Compile Preview.
Rule Impact metadata lives in @yutra/pack-config-core. It explains how a business field can affect Guard, Action, Transition, Policy, Template, Test Case, and Trace Expectation targets.
The Rule Compiler remains deterministic and artifact-focused:
- impact metadata does not execute Runtime
- impact metadata does not change generated artifact content
- impact metadata does not bypass compile gates
- impact metadata does not introduce customer SOP or real adapter mapping
@yutra/rule-compiler does not:
- connect Runtime
- connect Studio UI directly
- execute generated DSL
- call an LLM
- include customer SOP
- include real adapters
- include real endpoints or credentials
- include pricing, UAT, rollout, or delivery playbooks
- implement marketplace or remote registry
Likely next steps:
- P6-05B: optional apply compiled DSL into the existing DSL inspect/run source flow
- P6-06: richer visual business-rule configuration
Keep those separate from this core package.