Problem: Agents need checks that give the same answer every time and leave proof of each decision.
GuardrailAI is a deterministic workflow layer with explicit rule checks, fallback routing and a tamper-evident SHA-256 audit ledger. The current rules and demos are bounded examples, not production compliance coverage.
Verified locally: 53 tests passed on 30 Oct 2026.
TODO: Add the demo video after it is recorded.
This one Windows command writes the demo's ledger to the temporary directory and then runs the source-checkout form of verify-ledger on that file:
cmd.exe /d /c "python demos\aml_ofac_demo.py --ledger-path %TEMP%\guardrailai-synthetic-aml-ledger.json && python -m guardrailai.cli %TEMP%\guardrailai-synthetic-aml-ledger.json"Synthetic data, demonstration only, not legal or compliance advice. The names, two-name watchlist, transaction values and demo thresholds are invented. No real sanctions list or real people are used.
Real output captured on 30 Oct 2026:
SYNTHETIC DATA: invented names, watchlist, values, and demo thresholds.
No real sanctions list or real people are used.
CASE: clean_transaction
OUTCOME: PASS
RULE_ID: DEMO-PASS-000
LEDGER_ENTRY: {"agent_name":"SyntheticDemo","block_index":1,"current_block_hash":"bb682de26d44f9e52b7895a504672ae9cc686e8c021792b6598a7021aea8288b","input_hash":"ac87f7394560c0c62a96f1096c5d3dc22bfa40724f78cba0407fdc7f362fcffe","metadata":{"data_classification":"SYNTHETIC","rule_id":"DEMO-PASS-000"},"output_hash":"d9a15ada8502a0db498a1ad8d4ed755dfc3df347f326593926c682a73064f88c","previous_block_hash":"dc281a434ef44a114105280dfa323836dfc0434f25d018d4c1259e78f9043d09","step_name":"SYNTHETIC_AML_OFAC_DEMO","timestamp":1.0,"workflow_id":"synthetic-aml-ofac-demo"}
CASE: structuring_pattern
OUTCOME: AML_FLAG
RULE_ID: DEMO-AML-STRUCTURING-001
LEDGER_ENTRY: {"agent_name":"SyntheticDemo","block_index":2,"current_block_hash":"d4c4b86437b55a384571b4022c3eb87f129daef60dbcd8f60baa869404073c91","input_hash":"bb25cd96cce71d5f8bdb58f79fda1a5354f6e2f54472ce2b39af476880e66bf7","metadata":{"data_classification":"SYNTHETIC","rule_id":"DEMO-AML-STRUCTURING-001"},"output_hash":"277d9ee6b216c3c3824e1d9b4ce73ea0c24a59b0aa25581953d2081525d1e529","previous_block_hash":"bb682de26d44f9e52b7895a504672ae9cc686e8c021792b6598a7021aea8288b","step_name":"SYNTHETIC_AML_OFAC_DEMO","timestamp":2.0,"workflow_id":"synthetic-aml-ofac-demo"}
CASE: near_name_match
OUTCOME: SCREENING_FLAG
RULE_ID: DEMO-SCREEN-NAME-001
LEDGER_ENTRY: {"agent_name":"SyntheticDemo","block_index":3,"current_block_hash":"d1aa443d1dd88f0c78a15b24de61266c90f05d810a68ce93eb0b83df087ccbea","input_hash":"942c68d7744749db1310bc94b9c7bf67f261b4fd85aa81d35fabbe3d0a382470","metadata":{"data_classification":"SYNTHETIC","rule_id":"DEMO-SCREEN-NAME-001"},"output_hash":"ddb34a17a90220776dce6c304e809417642769003994c9c1fcf430b699947db3","previous_block_hash":"d4c4b86437b55a384571b4022c3eb87f129daef60dbcd8f60baa869404073c91","step_name":"SYNTHETIC_AML_OFAC_DEMO","timestamp":3.0,"workflow_id":"synthetic-aml-ofac-demo"}
OK
flowchart LR
Input["SYNTHETIC_CASES<br/>demos.aml_ofac_demo"] --> Rules["_evaluate(case)<br/>synthetic amount pattern + _screen_name(name)"]
Rules --> Decision["DemoResult<br/>PASS / AML_FLAG / SCREENING_FLAG"]
Decision --> Append["AuditLedger.append_entry()"]
Append --> Ledger["AuditLedger._hash_block()<br/>SHA-256 hash-chained ledger"]
The diagram names the functions used by the demo and the ledger.
- Explicit control flow:
ComplianceAgent,ProcessAgent, andAuditAgenthave separate responsibilities. BothBLOCKINGandCRITICALviolations route to fallback; warnings remain visible in the response. - Reproducible processing: financial references use a canonical payload digest; escalation references use a workflow ID digest. Regression tests compare separate Python processes with different hash seeds and reordered payload keys.
- Field-complete audit hashing: every stored block field except its own digest participates in SHA-256, including genesis contents, timestamps and metadata. Verification also checks workflow identity, sequence and previous links; caller-owned metadata is deep-copied on append.
- Executable failure paths: tests cover field mutation, an empty ledger, pre-flight blocking, injected post-flight blocking, fallback responses and API access.
flowchart LR
Request --> Pre[Pre-flight checks]
Pre -->|Pass or warning| Process[Deterministic processor]
Process --> Post[Post-flight checks]
Pre -->|Blocking or critical| Fallback[Fallback response]
Post -->|Blocking or critical| Fallback
Post -->|Pass or warning| Result[Result]
Fallback --> Audit[Hash-chained audit seal]
Result --> Audit
The processor contains local domain demonstrations. The orchestration boundary is the extension point for an application-owned processor. No model API key is needed to run the current pipeline.
| Domain | Pre-flight | Post-flight |
|---|---|---|
| Financial | Configured destination denylist; amount threshold | Debt-ratio warning |
| Healthcare | Dashed SSN pattern detection | Configured medication/dosage rule |
| Legal | Liability and indemnity phrase checks | Disclaimer flag warning |
See rule implementations and workflow routing.
git clone https://github.com/asadullah48/guardrailai.git
cd guardrailai
python -m pip install -e ".[dev]"
python -m pytest tests -v
uvicorn guardrailai.server:app --host 127.0.0.1 --port 8003 --reloadOpen the Studio or OpenAPI docs.
from guardrailai.core.models import WorkflowExecutionRequest
from guardrailai.orchestration.workflow import DeterministicWorkflowEngine
engine = DeterministicWorkflowEngine()
response = engine.execute_workflow(WorkflowExecutionRequest(
workflow_id="demo-wire",
payload={"amount_usd": 4500, "destination_country": "US"},
))
print(response.final_status.value)
print(engine.active_ledgers["demo-wire"].verify_integrity())The check runs the same synthetic input set in two fresh processes with an injected fixed clock, then hashes canonical JSON (sorted keys, no whitespace). VERIFIED on 28 Oct 2026 at commit b353237:
> python scripts/determinism_check.py
RUN 1 SHA-256: 4da4fc7a13122a98e804faa2ea05273b433970ea758bea2a754fdf299ae1d545
RUN 2 SHA-256: 4da4fc7a13122a98e804faa2ea05273b433970ea758bea2a754fdf299ae1d545
MATCH
Installation registers the verify-ledger <path> command. The file must contain a JSON array of audit-block objects in chain order. The command recomputes each block digest and previous-hash link, prints OK for a valid chain, or prints BROKEN <index> for the first invalid position and exits with status 1.
This output was captured on 29 Oct 2026 from the repository's clearly labelled synthetic fixture:
> python -m guardrailai.cli examples\synthetic-ledger.json
OK
After python -m pip install -e ., the equivalent installed command is:
verify-ledger examples\synthetic-ledger.jsonDeleting the final block cannot be detected from the chain alone; detecting tail truncation requires an external trusted checkpoint.
Run python -m pytest to execute the full test suite.
Synthetic data, demonstration only, not legal or compliance advice.
- Rule coverage: the financial, healthcare and legal checks are a small set of hard-coded thresholds, patterns and phrases. They are not complete AML, sanctions, HIPAA, clinical or legal compliance programs, and the repository does not establish regulatory certification or production accuracy.
- Real sanctions data:
FinancialGuardrailsuses a hard-coded destination-country list. The AML/name-screening demo uses a two-name invented watchlist anddifflib.SequenceMatcher; it does not download, update or screen against a real sanctions list. - Storage: API ledgers live in
DeterministicWorkflowEngine.active_ledgers, an in-memory dictionary. They are lost on process restart, and running the same workflow ID again replaces the earlier ledger. The demo writes JSON only when--ledger-pathis supplied. - Scale: the FastAPI app owns one synchronous in-process engine. The code has no shared database, queue, distributed coordination, rate limiting, backpressure or load-test evidence.
- Authentication: the API routes have no authentication, authorization, roles or tenant isolation. CORS is configured with wildcard origins, methods and headers.
- Financial payload fields are converted with
float()inside the rule and processor code. Non-numeric values can raise an unhandled conversion error instead of returning a typed validation response. - The default clock uses wall time, so timestamps and audit seals vary between runs unless a fixed clock is injected.
- Hash chaining detects stored-field edits and broken links, but a writer who can recompute the whole chain can replace it. Tail deletion cannot be detected without an external trusted checkpoint.
- The synthetic name matcher can produce false positives or false negatives; it performs only a normalized string-similarity comparison against the invented watchlist.
HUMAN_ESCALATIONreturns a generated reference but does not create an external ticket or approval task.REDACTIONfollows the rejection branch and does not redact payload data.
- Connect a licensed or official sanctions-data source with versioned snapshots, update history, provenance and tests for list changes.
- Replace generic payload dictionaries with domain-specific validated models and explicit error responses.
- Move ledgers to durable append-only storage and anchor checkpoints outside the process so truncation and full-chain replacement can be detected.
- Add authentication, role-based authorization, tenant isolation and restricted CORS configuration before exposing the API.
- Add multi-worker-safe coordination, idempotency, queues where needed, rate limits, observability and measured load tests before making scale claims.