Skip to Content
Recodocs

Niyati compliance stays governable when rules own the allow-lists

Deterministic modules own health bands, actions, and policy allow-lists. The model may fill constrained JSON fields, including an allow-listed next step, and cannot invent policy or send without the approval gate.

7 min read

A compliance obligation needs an owner, a due date and evidence of its current status. A review can propose the next step, but the recorded obligation and the authorized decision remain distinct.

An operator posts daily_case_review with snapshot date 2026-03-14 to /v1/compliance/triggers. SQLite already holds fourteen seeded obligations, including task T-OVERDUE-ACK for the PF monthly return. run_case_intelligence scores that row, plan_case fixes the next operator and owner actions, and verify_item requires human approval for an unhealthy case whose target actor is owner or operator, or whose next action is escalate_compliance or request_owner_verification. For each non-resolved case, decide_workflow_step in compliance/workflow_brain.py may call call_llm_json to draft a message, but _normalize_decision keeps a proposed case_action or recommended_transition when it is in _allowed_case_actions, and otherwise uses fallback["case_action"]. queue_outbox_for_decision writes notification_outbox with status pending_human_approval when the plan says so. Nothing leaves the host as a real notification.

Ask the same API to close_case and the request never enters the workflow. SUPPORTED_TRIGGERS has no such name, so the route answers with HTTP 400 and the unsupported-trigger guard.

Compliance automation stays governable when SQLite snapshots and rule modules own health bands, actions, and policy allow-lists, while the model may supply constrained wording and allow-listed next-step fields. Rules own those fences. The customer, owners, and obligation rows are synthetic; fresh databases receive the original seed described in the README, not production payroll data.

The argument

  1. Case state is computed, not narrated. assessor.py, planner.py, and verification.py derive risk, root cause, and approval flags before any explanation call.
  2. The model’s job is constrained JSON. compliance/llm.py supplies a deterministic fallback when the model is off. decide_workflow_step is one model call on the review path; investigation, evidence review, and policy review also accept constrained model fields.
  3. Send and close are host actions. approve_send_requested demands approved: true and a named approver; delivery remains simulated_only, and there is no close_case trigger.
  4. Migration tests are the contract. Five cases in history/compliance_migration_tests.py.txt cover the guard and timeline, an unapproved send, policy and closure, a patched provider fallback, and the seeded row count.

Who is allowed to decide

The tempting design lets a single model read obligations, pick an intervention, approve closure, and push a message. Niyati Compliance is deliberately not that shape. MIGRATION_HISTORY.md calls it a deterministic workflow with constrained model explanations, and explicitly says the model does not choose state transitions, approve closure, or send messages. Triggers are explicit strings routed through compliance/trigger_router.py into run_workflow_trigger in compliance/workflow.py. There is no open-ended tool loop where the model selects the next capability.

Niyati compliance boundaryAn operator posts a trigger into a bounded workflow. Deterministic assessor and planner rules run first. workflow_brain may propose a next step. Policy metadata and the notification outbox enforce allow-lists. Simulated delivery requires an explicit human approver.OperatorPOST /triggersdaily_case_reviewapprove_send_requestedBlockedclose_caseNo such trigger.Workflow hostcompliance/*API gatebearer + approve flagsCase intelligenceassess · plan · verifyworkflow_brainJSON step proposalpolicy + outboxallow-lists · queueSimulated sendhuman approver onlySQLitecompliance_itemspolicy_chunks · casesnotification_outboxExplanation lanecall_llm_jsonCodex when enableddeterministic fallbackNIYATI_RUNTIME_MODEtriggerresultpacketrows
Triggers cross the API gate; rules and SQLite own case state.

The dashed box is labelled Workflow host and contains the compliance/* stack mounted from compliance/app.py. The shared Kit runtime bearer guard sits in front of /v1/compliance/* as described in the README. Inside the boundary, order matters. A POST must pass schema validation on TriggerRequest in compliance/api.py. After TriggerRequest parses, approve_send_requested returns HTTP 403 unless approved is true and approved_by is non-blank, and that check runs before handle_webhook_payload. An accepted daily_case_review or manual_case_review then ensures snapshot cases, decides and reviews each non-resolved case, and queues outbox rows; other triggers take their own branches.

The orange card is labelled Blocked and shows close_case with the text “No such trigger.” Closure review’s fallback sets required_human_approval to true, and the normalizer keeps a model value of false when that key is present. Operators cannot invoke a close_case trigger because it is absent from SUPPORTED_TRIGGERS. Owner nudges stop earlier when can_send_owner_action in compliance/policy.py returns false for unverified owners or verification-needed modes. Those outcomes live in Python control flow, not in a system prompt.

decide_workflow_step is one model call on the review path; investigation, evidence review, and policy review also accept constrained model fields. It builds a case packet from stored rows, computes _fallback_decision from deterministic_decision, and optionally asks the model for JSON with keys such as workflow_step, recommended_transition, and message_draft. _normalize_decision keeps a proposed case_action or recommended_transition when it is in _allowed_case_actions, drawn from recommended_action, operator_action, and owner_action on the plan, and otherwise uses fallback["case_action"]. normalize_investigation accepts model recommended_steps actions, normalize_evidence_review accepts a recommended_next_step in EVIDENCE_NEXT_STEPS, and normalize_policy_review accepts a recommended_path in allowed_actions. normalize_policy_review copies the fallback action lists, which start from chunk metadata and may also append the evidence path and close_case.

Even the workflow prompt repeats the fence. WORKFLOW_SYSTEM_PROMPT in workflow_brain.py tells the model it may propose the next safe workflow step and draft messages, that deterministic rules validate it, and that it cannot send, approve, close, escalate, reassign, or mutate deterministic risk fields. When the model is disabled or the provider raises ValueError or OSError, call_llm_json returns the fallback with used_llm false and error set only on provider failure.

What the evidence shows

It is easy to describe “AI compliance” and sound as if each mechanism was measured in production. The repository instead records rules, triggers, and tests. The figure below shows the cards Proposal, Allow-list, Fallback, and Outbox: model text in, deterministic plan fields out, outbox status as the observable commitment.

Workflow step normalizationThe model may propose case_action or recommended_transition. _normalize_decision keeps the proposal only when it appears in _allowed_case_actions built from the deterministic plan; otherwise the fallback step is used.LLM JSONqueue_owner_nudgeallowed setescalate_compliancerejecteddeterministic_decisionowner_actionoperator_actionnotification_outboxpending_human_approvalsimulated_sentProposalcase_actionAllow-listplan fields onlyFallback_fallback_decisionOutboxqueue_outboxworkflow_brain chooses wording; _normalize_decision chooses the stored action.
Model proposals survive only when they match deterministic plan actions.

The HTTP client is installed with runtime_mode="deterministic", and the provider test separately calls call_llm_json with enabled=True under a patched client. Policy and evidence reviews through that client assert used_llm: false while still exercising real SQL and HTTP. test_policy_evidence_and_closure_remain_deterministic_and_human_reviewed picks case T-OVERDUE-ACK, fires policy_review_requested, and expects close_case inside blocked_actions from seeded policy chunk metadata in compliance/sql/seed.sql. A POST with trigger: close_case must return 400, matching the absence from SUPPORTED_TRIGGERS. That deterministic closure review keeps required_human_approval true.

Parallel boundaries show up elsewhere in the same file. Wrong bearer tokens receive 401 on /v1/compliance/status. test_explicit_approval_gate_and_simulated_only_outbox proves that approve_send_requested without both approved: true and approved_by stops at HTTP 403, while a properly attributed approval yields simulated_sent and delivery: simulated_only in the trigger response—consistent with GET /status reporting delivery: simulated_only. Provider failure is a scripted test: test_portfolio_and_provider_fallback_are_labelled patches the Codex client to raise, expects used_llm: false, records an error string, and returns the explicit fallback dict from call_llm_json.

Supported triggers that pass the approval gate are inserted into company_compliance_executions with lane deterministic or codex, the model name when enabled, a source hash, and a terminal state. That table makes partial failures visible, which MIGRATION_HISTORY.md notes is not an atomic transaction across domain steps. Evidence strength is scoped in compliance/verification.py: owner actions are allowed only when the owner is verified, an owner action exists, verification mode is verified, and owner health is ok. severity_verified is false for a critical band with a weak or stale source when deadline risk does not apply, and that flag is stored on the snapshot payload.

Root cause ordering in compliance/policy.py is another silent authority. ROOT_CAUSE_PRIORITY picks the first matching bucket among candidates such as overdue_missing_evidence, owner_gap, and acknowledgement_gap, so two true signals still collapse to one deterministic label that downstream prompts and fallbacks must respect. Portfolio-facing triggers like operator_brief_requested and weekly_forecast_requested appear in SUPPORTED_TRIGGERS, and tests assert the brief contains the phrase Top priorities today, but those strings are reporting overlays on the same stored cases rather than alternate decision engines.

What would falsify the claim is a test where an unapproved send reaches simulated_sent, or where policy review surfaces a recommended_path outside stored allowed_actions without normalization correcting it. One migration test checks that an unapproved send stays at HTTP 403; the other four cover the guard and timeline, policy and closure, provider fallback, and seeded row count. They do not prove model prose quality when NIYATI_RUNTIME_MODE is not deterministic.

The turn we ran

Each non-resolved case runs investigate_case, decide_workflow_step, review_policy, and queue_outbox_for_decision, after an earlier conditional snapshot ensure. Tests call daily_case_review with snapshot 2026-03-14. The figure’s cards are daily_case_review, run_case_intelligence, decide_workflow_step, review_policy, and queue_outbox.

One daily case review passdaily_case_reviewtrigger_routerrun_case_intelligenceassessor · plannerdecide_workflow_stepworkflow_brainreview_policypolicy_memoryqueue_outboxoutbox.pyEach open case on the snapshot runs this chain inside run_case_review_workflow.
Daily review is a fixed pipeline, not a tool-picking loop.

run_case_review_workflow calls run_case_intelligence when the snapshot date has no snapshot rows, or when snapshot rows exist but no cases do. It records workflow_decisions from decide_workflow_step, including optional used_llm. The workflow calls review_policy, queues the outbox, and then records policy_review_created with blocked_actions. queue_outbox_for_decision sets pending_human_approval when human_approval_required is true on the decision.

The approval leg is a separate trigger, not an implicit side effect of review. After setup_cases() in the migration tests, an outbox row exists in drafted or pending_human_approval. The test posts approve_send_requested without approval and expects 403. The same case reaches simulated_sent only when approved is true and approved_by is a non-blank name. approve_and_simulate_send in compliance/outbox.py then moves status to simulated_sent and emits human_approved_and_simulated_send on the case timeline. Owner responses and portfolio briefs exist as other triggers in SUPPORTED_TRIGGERS, but the daily review plus simulated send pair is the spine the tests treat as non-negotiable.

The one check to copy

Copy the allow-list intersection from workflow_brain, not the compliance nouns. After the model returns JSON, keep a proposed case_action or recommended_transition when it is in _allowed_case_actions; otherwise keep the fallback action chosen from root cause, owner action, or operator action. Health band only sets confidence.

The migration test to keep beside that code is test_explicit_approval_gate_and_simulated_only_outbox in history/compliance_migration_tests.py.txt. It ties HTTP 403 on missing human approval to the same case id that later reaches simulated_sent only when approved is true and approved_by is a non-blank name.

    output = dict(fallback)
    output.update({key: value for key, value in payload.items() if value is not None})
    allowed_case_actions = _allowed_case_actions(packet)
    proposed_case_action = str(output.get("case_action") or "")
    proposed_transition = str(output.get("recommended_transition") or "")
    if proposed_case_action in allowed_case_actions:
        case_action = proposed_case_action
    elif proposed_transition in allowed_case_actions:
        case_action = proposed_transition
    else:
        case_action = fallback["case_action"]

The same shape fits any regulated workflow where plans are relational facts and models draft text: persist allow-lists in metadata, normalize model JSON before writes, and require named human approval on the single send trigger you actually implement.

Close

Niyati Compliance is tempting to describe as a model with tools. The code describes a trigger-driven workflow on SQLite snapshots. Deterministic modules set who may act and which policy paths exist; investigation, evidence review, policy review, and workflow_brain may fill constrained fields; the API and outbox decide whether a simulated send may occur. Closure review’s fallback sets required_human_approval to true, and the normalizer keeps a model value of false when that key is present. Real delivery is explicitly out of scope. Extend the system by adding triggers and tests for new host-owned mutations, not by widening what the model may call without an allow-list check.

How is this page?

Last updated on