Translate a Policy
Install the SDK
Section titled “Install the SDK”pip install sasyWrite Your English Policy
Section titled “Write Your English Policy”Create policy_english.md describing your authorization
rules in plain language:
# Airline Booking Policy
## Default behavior- All actions are authorized by default
## Cancellation policy- Gold members can cancel any reservation, regardless of insurance status- Silver and regular members can only cancel if the reservation has travel insurance
## Flight modification policy- Economy reservations can be modified by any member- Basic economy reservations can only be modified by silver or gold membersTranslate It
Section titled “Translate It”from sasy.policy import write_policy
with open("policy_english.md") as f: english = f.read()
result = write_policy( english=english, on_progress=lambda stage, elapsed: print( f" {stage} ({elapsed:.0f}s)" ),)
result.print_summary()result.save_datalog("policy_compiled.dl")result.save_truth_table("truth_table.tsv")make translateWhat You Get Back
Section titled “What You Get Back”| Artifact | Access | Description |
|---|---|---|
| Datalog policy | result.datalog | Generated Soufflé rules |
| Structured spec | result.structured_spec | Numbered clauses (C1, C2, …) |
| Truth table | result.truth_table_tsv | Every test scenario + decision |
| Verification | result.verification | Assertion counts, checks, audit |
Save artifacts to files:
result.save_datalog("policy_compiled.dl")result.save_truth_table("truth_table.tsv")Upload and Enforce
Section titled “Upload and Enforce”from sasy.policy import upload_policy
with open("policy_compiled.dl") as f: datalog = f.read()
resp = upload_policy( policy_source=datalog, hot_reload=True,)print("Uploaded!" if resp.accepted else resp.error_output)Or:
make upload-compiledThe policy is now live. Every tool call is checked against it in real time.
Compare Variants
Section titled “Compare Variants”Test whether different phrasings produce the same policy:
from sasy.policy import write_policies
results = write_policies( [variant_a, variant_b],)
for i, r in enumerate(results): print(f"\nVariant {i+1}:") r.print_summary()If both variants produce the same truth table shape (same ALLOW/DENY/GUARD_DENY counts), the translation is robust to phrasing differences.