rule-authoring

Convert natural-language lottery rules into a verifiable schemaVersion 3 rule DSL AST.

Updated Jun 2, 2026
One-click install
npx skills add https://github.com/IagoPrandi/ai-dealer --skill rule-authoring-iagoprandi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rule-authoring
Source: https://github.com/IagoPrandi/ai-dealer/tree/main/packages/rule-compiler/rule-authoring
Command: npx skills add https://github.com/IagoPrandi/ai-dealer --skill rule-authoring-iagoprandi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Players propose winning rules in plain English or Portuguese, but the Tyche game engine needs a deterministic, auditable rule AST to verify outcomes. This Skill guides an LLM compile harness to translate free-text rule intents into the compositional rule DSL without losing or flipping the player's intent. ## Core Features & Use Cases - Intent-to-AST compilation: Emits a JSON candidate containing the rule AST, exact consumed source spans, per-path provenance records, and worked examples that act as an independent oracle. - Predicate vs ranking decision: Distinguishes absolute win/lose tests ("at least N matches") from comparative rankings ("the most matches"), including eligibility filters and folded primary/tiebreak scores. - Macro cookbook and pattern rules: Provides ready compositions for match counts, sums, positional pairs, digits, negation, compound AND/OR clauses, and Portuguese trigger terms like "acertar", "errar", and "dezena". - Use Case: A player writes "ganhar quem errar mais números"; the Skill produces a ranking AST maximizing the count of difference(guess,draw) with correct polarity, spans, and validated examples. ## Quick Start Ask the assistant to compile the player's proposed lottery rule text into a rule AST candidate following the rule-authoring guidance.

Frequently Asked Questions about rule-authoring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compile a natural-language lottery rule into a rule AST?▼

Emit a single JSON object with an `ast` field using schemaVersion 3 compositional nodes, plus consumedSpans, provenanceRecords, and workedExamples. Choose a predicate for absolute win/lose tests and a ranking for comparative rules, composing core nodes like intersection, reduce, and pairs_forall.

What is the difference between a predicate and a ranking rule?▼

A predicate is an absolute win/lose test for a single guess, used for thresholds like "at least N matches". A ranking compares guesses against other players, such as "the most matches", and carries a direction, a single score, and optionally an eligibleWhen filter.

Does the rule compiler support Portuguese rule text?▼

Yes, the patterns reference includes a Portuguese trigger glossary mapping terms like acertar to intersection, errar to difference, and pelo menos N to a gte threshold predicate. Ambiguous words like "dezena" default to the drawn-number meaning unless a digit is explicitly stated.

How are tiebreaker or fallback criteria handled in a ranking?▼

A ranking has exactly one score, so primary and fallback criteria are folded into a single arithmetic expression: SCALE times the primary minus or plus the secondary. SCALE must exceed the secondary's maximum possible value so the fold stays exact.

What data can a compiled rule reference?▼

Rules may reference only `guess` and `draw`, each six distinct integers from 1 to 100. Wallets, votes, prize pools, time, history, randomness, oracles, and other external events are unverifiable and must never appear in the AST.

Why is a rule candidate rejected by the validator?▼

Candidates are rejected for unconsumed intent-bearing text, missing provenance records per AST path, or worked examples that fail execution or shape checks. Examples must use exactly six distinct 1-100 numbers per guess and draw, with no repeats or out-of-domain values.