Parity Sentinel by LOGIC

Docs / Configuration

Configuration reference

One installation, one file: instance.toml holds everything an installation connects to, compares, tolerates, classifies and repairs.

Format version. This page describes the single-file configuration format adopted in November 2026: one self-contained instance file, secrets as plain values, no environment variables. Parts of it arrive with the next release and are marked Next release; today, every rule kind runs: tolerance, classifier, check, policy, condition, guard and settlement rules. If your version still reads a separate schema profile or environment variables, follow the documentation shipped with it.

Contents

The file

Changing it

CommandWhat it does
manage.py config validate FILEChecks a file without applying it
manage.py config apply FILE --by NAME --reason …Applies a file as a new configuration version
manage.py config diff A BShows what differs between two files or versions
manage.py config export [--version N]Writes a version exactly as it was applied, secrets redacted

Every version records who applied it, when, why and which keys changed; the dashboard’s configuration page shows them with their diffs. Most settings take effect at each lane’s next cycle; the others are listed as waiting for that lane’s restart. An invalid or missing setting does not stop Sentinel: it shows as a configuration problem on every page and holds only the lanes that need it.

With [instance] editable = false the configuration is managed outside Sentinel. The dashboard shows it read-only and config apply refuses. On Azure the file lives in Key Vault: edit the secret there, then run sudo systemctl start parity-sentinel-config on the virtual machine to place the new version.

Changes to tolerances, scope, exclusions, classification rules or policies are gated Next release: they apply only with a justification and after the regression check regenerates the recorded reports and plans.

A minimal example

# /var/lib/parity-sentinel/instance.toml (mode 0600)
[instance]
name = "orders-acme"
project = "Orders Platform"
tenant = "Acme"
public_url = "https://sentinel.capsulecorp.example"
time_zone = "Europe/Berlin"

[databases.baseline]
server = "capsulecorp-orders.database.windows.net"
database = "orders_v1"
auth.mode = "managed_identity"

[databases.candidate]
server = "capsulecorp-orders.database.windows.net"
database = "orders_v2"
auth.mode = "managed_identity"

[access.initial_admin]
username = "root"
password = "change-me-on-first-sign-in"

[tables."dbo.Warehouse"]
role = "input"
natural_key = ["Code"]

[tables."dbo.PricingRule"]
role = "input"
natural_key = ["WarehouseId", "Sku"]

[roles]
context = ["dbo.Region"]
ignored = ["dbo.AuditLog"]

A real installation also declares its output tables, identity kinds and rules, described under the schema.

[instance]

KeyDefaultMeaning
name—A short name for this installation
projectrequiredThe project this installation serves, shown on every page and report
tenant—The tenant it belongs to, shown first in titles
public_urlhttp://localhost:8765The dashboard’s public HTTPS address, for links and as the trusted origin
time_zoneUTCIANA time zone for dates on the dashboard
state_dirthe file’s directoryWhere the database, job evidence and keys are kept
editabletruefalse: managed outside Sentinel; shown read-only, never applied from the dashboard

[databases]

[databases.baseline] is the database the old version writes; Sentinel never writes it. [databases.candidate] is the one the new version writes; Sentinel measures it and repairs its configuration tables. Both take the same keys.

KeyDefaultMeaning
enginesqlserverSQL Server or Azure SQL
serverrequiredHost name, such as capsulecorp-orders.database.windows.net
databaserequiredDatabase name
auth.modeazure_climanaged_identity (an Azure virtual machine), sql_password, or azure_cli (a developer machine)
auth.client_id—A user-assigned managed identity’s client ID
auth.user, auth.password—For sql_password; the password is a plain value
auth.trust_server_certificatefalseOnly for a test server with a self-signed certificate

[databases] odbc_driver names the ODBC driver, by default ODBC Driver 18 for SQL Server.

[databases.candidate]
server = "capsulecorp-orders-next.database.windows.net"
database = "orders_v2"

[databases.candidate.auth]
mode = "sql_password"
user = "sentinel"
password = "a-long-generated-password"

[access]

Sentinel has its own sign-in (mode = "django", the default): every page, the API and MCP need a signed-in user or a user’s API token.

[access.initial_admin] creates the first administrator. While no active administrator exists, Sentinel creates this user, at start or on the next request, so a corrected file needs no restart. Once any administrator exists the block is ignored: it never creates a second administrator and never changes or resets anyone. The password must have at least 12 characters, must not be a common password or only digits, and must not resemble the username; a block that fails is refused without repeating the password.

With no administrator and no usable block, Sentinel has a configuration problem: every page answers 503 with it, the API answers 503 in JSON, and MCP refuses.

[access]
mode = "django"

[access.initial_admin]
username = "root"
password = "change-me-on-first-sign-in"

[lanes]

Intervals are in seconds. Each lane is one process with its own lock.

KeyDefaultMeaning
repair.interval300Time between scheduled configuration scans
derived.interval300The derived-configuration lane, which owns its tables while above 0; 0 hands them back to the full scan
catchup.interval60Catch-up probes
catchup.probe_rows50000Rows read per probe
parity.interval60How often the parity lane looks for a new window
parity.window_minutes60The length of each measured window
identity.interval900Identity map refreshes
timeline.interval60Release timeline polls
timeline.github_interval300GitHub polls of the timeline

[auto_apply]

Off by default. With enabled = true, the scheduled scan applies its plan without review, except when an operation needs inspection, the capture has gaps, or a policy has more actions than its limit. Over a limit, that policy’s actions are set aside as a surge for review and the rest of the plan still applies. Each policy’s limit is the auto_apply_limit of its [policies.<name>] table in the schema. Scoped plans are never applied automatically. Turn it on only when no other installation applies to the same candidate.

[auto_apply]
enabled = true

[releases]

Optional. The release timeline links each release of the new version to the rollouts that ran it. It reads three sources, each chosen in [releases]:

KeyValuesMeaning
code_sourcegithub, gitWhere commits come from
deployment_recordsgithub, azure_devops, noneWhere deployments are recorded
rollout_evidencekubernetes, noneWhere running workloads are observed
grace_seconds3300How long a release may take to settle
config_pathpathThe new version’s cache settings file in the code source
mutable_tagtagA tag that deployments retag and restart, such as dev
[releases]
code_source = "git"
deployment_records = "azure_devops"
rollout_evidence = "kubernetes"

[releases.git]
url = "https://dev.azure.com/capsulecorp/Orders/_git/orders-processor"
token_scheme = "managed_identity"

[releases.azure_devops]
organization = "capsulecorp"
project = "Orders"
environment = "production"
auth = "managed_identity"

[releases.kubernetes]
namespace = "orders"
deployment = "orders-processor"
auth = "managed_identity"
cluster_id = "/subscriptions/…/resourceGroups/orders/providers/Microsoft.ContainerService/managedClusters/orders-aks"

[releases.registry]
host = "capsulecorp.azurecr.io"
repository = "orders-processor"
tag = "{run_id}"
auth = "azure"

The schema

The rest of the file describes the two databases: what each table is for, how a record in one is paired with the same record in the other, and how results are compared. Sentinel itself knows no table names; everything about your application is here.

Tables and roles

Every table has exactly one role:

RoleMeaning
inputConfiguration both versions read. Captured from both databases, compared, and copied baseline → candidate by repair plans
outputWhat each version produces. Read from both and compared within tolerances; never written by a scan
contextRead only, to attribute and explain rows; never captured or written
ignoredNever read, compared or written

A table is declared once, as [tables."<name>"] with a role, or in a [roles] list when it needs nothing else. An input table can set natural_key, match_key, changes (insert, update, replace), runtime_columns (written by the running system, never compared), protected_columns (only fingerprints leave the database) and sensitive (protected values are copied, encrypted). A table found in the databases but not in the file is reported on every scan and holds automatic apply until it is given a role.

Identity

Both databases allocate IDs independently, so [identity.<kind>] says how a resource is recognised in each: its table, id_column, natural key, references to parent kinds and definition columns. A resource that can’t be paired is reported as a finding, never guessed.

[identity.warehouse]
table = "dbo.Warehouse"
id_column = "WarehouseId"
key = ["Code"]
definition = ["Name", "RegionId"]

[identity.pricing_rule]
table = "dbo.PricingRule"
id_column = "PricingRuleId"
key = ["WarehouseId", "Sku"]
references = { WarehouseId = "warehouse" }

Output tables and tolerances

An output table names its time_column, an increasing insert_order_column, its comparison key, its categories and compared columns (numeric or exact), its scope (rows left out of a window and counted separately) and how rows are read without blocking production.

Its tolerances are tolerance rules, which name the table.

[tables."dbo.OrderTotal"]
role = "output"
time_column = "ComputedAt"
insert_order_column = "OrderTotalId"
key = ["OrderNumber"]

[tables."dbo.OrderTotal".columns]
Net = { compare = "numeric", noise = true }
Tax = { compare = "numeric", noise = true }
Currency = { compare = "exact" }

Rows known to be wrong in the stored data are not configuration: they are recorded in the installation’s database, each with its evidence and history Next release.

Scoping

[scoping] says which unit (such as a site or a region) a row belongs to, through a chain of lookups between tables. Scoped scans, case attribution and per-unit verification use it.

Rules

Everything Sentinel decides about your data is a rule in the file. [[rules]] holds every rule, in file order. Each has a stable id (letters, digits, ., _ and -), written to reports and never renamed or reused, and a kind. Its logic is either a declarative form that Sentinel implements, or embedded Python in code.

KeyMeaning
idRequired. The stable ID
kindRequired. One of the kinds below
formA declarative form of the kind; instead of code
codePython defining the kind’s function; instead of form
time_limit_secondsWith code: the limit of one call, above 0 and at most 60; default 1
name, descriptionHow reports and the explorer name the rule
reasonThe evidence text recorded with each row the rule decides

Kinds

Each kind has one function, which code must define at the top level with exactly two parameters: the data, and ctx (the rule’s id and what the caller adds). Data arrive as read-only dictionaries and tuples, so a field is row["column"].

Kind and functionReceivesReturns
tolerancetolerate(pair, ctx)The two values, the column, the row’s category and magnitudeTrue if covered
classifierclassify(row, ctx)One comparison row at the rule’s stage{id, class, evidence}, optionally noncomparable; {id, unresolved: True, evidence}; an evidence request; or None
checkcheck(run, ctx)The report’s moment (now), the catch-up lag and the sites the comparison left outA record {summary, findings, …}, or an evidence request
policyreview(plan, ctx)A scan’s planned actions; both catalogs, the scan’s sites, the policy’s options and the capture timeA list of decisions: keep, set, follow, exclude, hold or block an action, block a row for review, or add an update or a delete
conditionholds(pair, ctx)An exception and the two values it compares, each with its sideTrue or False
guardguard(action, ctx)One planned actionNone to allow, or the refusal: its reason, or {reason, code, detail}
settlementsettle(release, ctx)The release timeline’s deployments, ReplicaSets and pods, and the deployment each ReplicaSet was matched to{verdict, statuses}: the GitHub deployment statuses to post

Every kind runs today: tolerance, classifier, check, policy, condition, guard and settlement.

Embedded code and helpers

code may import only math, datetime, decimal, re, sentinel.rules (generic helpers: ULP distance, single-precision rounding, numbers, time parsing, formulas, a per-run memo, and ask, ask_all and request for evidence) and the file’s own helpers. It never gets a database connection, a file or the network.

[helpers.<name>] blocks hold shared code, which rules import as sentinel.helpers.<name>. Helpers pass the same import check and may import each other, without cycles.

[helpers.money]
code = '''
from decimal import Decimal

def cents(value):
    return Decimal(str(value)).quantize(Decimal("0.01"))
'''

Tolerance rules

A tolerance rule names its output table and may limit itself to categories and columns. A table’s rules apply in file order: the first must be form = "ulp" without categories (the base), and a base of ulps = 0 turns every rule of the table off. A tolerated difference counts as a match but is never silent: it is listed under its rule’s ID, and the rule recorded for a row is the first, in file order, whose bound covers it. The older [[tables."…".tolerances]] entries with rule and type are refused, with a pointer to [[rules]].

FormKeysCovers
ulpulpsThe two doubles are at most ulps representable values apart. For one row, the bound is the largest ulps among the ulp rules that apply to it
magnitudeulps_of_magnitude, magnitude_floor, relativeWith M the largest absolute value of the row’s noise columns on both sides, |a − b| ≤ max(relative × M, ulps_of_magnitude × ulp(max(M, magnitude_floor))). Noise columns only; relative defaults to 0
absoluteabsolute|a − b| ≤ absolute. Required; numeric columns only
relativerelative|a − b| ≤ relative × max(|a|, |b|). Required; numeric columns only

The absolute, relative and code rules are asked, in file order, about each numeric difference the ulp and magnitude rules leave; the first that covers it is recorded. A tolerance with code may only cover numeric columns. Its pair holds column, category, baseline and candidate (the two values, as finite numbers; releases before the rename call them upstream and downstream) and magnitude.

[[rules]]
id = "float-rounding"
kind = "tolerance"
table = "dbo.OrderTotal"
form = "ulp"
ulps = 4

[[rules]]
id = "net-magnitude"
kind = "tolerance"
table = "dbo.OrderTotal"
form = "magnitude"
columns = ["Net"]
ulps_of_magnitude = 16
magnitude_floor = 1.0

[[rules]]
id = "amount-cent"
kind = "tolerance"
table = "dbo.OrderTotal"
form = "absolute"
columns = ["Amount"]
absolute = 0.01

[[rules]]
id = "tax-cents"
kind = "tolerance"
table = "dbo.OrderTotal"
columns = ["Tax"]
reason = "tax within one cent, rounded per line in the new version"
code = '''
def tolerate(pair, ctx):
    return abs(pair["baseline"] - pair["candidate"]) <= 0.01
'''

Classifier rules

A classifier explains a difference no tolerance covers. It declares its stage, the classes it may return and whether they are noncomparable (left out of the parity figure). Within a stage the first rule, in file order, that returns a classification decides the row; a class outside the declaration fails the run, naming the rule.

StageThe rows it sees
unmatchedEvery row that is not an exact match, before presence evidence (not reached, comparison window) is asked
settledRows that presence, an exact match and configuration evidence leave unresolved
unresolvedRows still unexplained once every row has a class, with their classification and different_columns; rules may ask for evidence here
fixpointRows still unexplained after that, classified again with every row’s latest outcome until nothing changes, for a class one row takes from another

At the unresolved and fixpoint stages, ctx["rows"] shows every row’s current outcome (keys(*columns), value(place, column)), and a rule may answer {"id", "unresolved": True, "evidence"}: the row stays unexplained, with that evidence. [comparison] fixpoint_passes caps the fixpoint stage; one that has not settled by then fails the run.

[[rules]]
id = "late-exchange-rate"
kind = "classifier"
stage = "settled"
classes = ["late_rate"]
noncomparable = true
description = "Totals computed before the day's exchange rate arrived"
code = '''
def classify(row, ctx):
    if row["status"] == "value_diff" and row["category"] == "foreign-currency":
        return {
            "id": ctx["rule_id"],
            "class": "late_rate",
            "noncomparable": True,
            "evidence": "foreign-currency totals use the day's rate, published later",
        }
    return None
'''

Causes

[causes.<id>] declares what may explain a difference no classifier explains. People and agents attribute a report’s unresolved rows to a cause, with evidence, on the report’s page or with the MCP tool set_cause; whoever sets it is recorded, and there is no approval step. A row no cause explains is not triaged. A report shows its measured parity and, beside it, the same figure counting rows whose cause is explained or accepted; the measured figure never changes. A file that declares no causes gets a generic catalogue: baseline_behaviour, candidate_defect, environment and configuration.

KeyValueMeaning
<id>lower-case letters, digits and _Permanent: never renamed or reused. untriaged is built in and refused
titletext, requiredWhat the cause is
sidebaseline, candidate, environment or config, requiredWhose behaviour it is
effectexplained, defect or accepted, requiredA defect stays a difference in the figure with attributions
issue"#123" or an http(s) linkWhere it is tracked
descriptiontextMore detail
[causes.rounding_per_line]
title = "The new version rounds tax per line"
side = "candidate"
effect = "accepted"
issue = "#42"

Evidence rules ask for

A rule never connects to a database. When it needs to read one, it asks for a query declared in [comparison.evidence.<name>] with form = "query": sentinel.rules.ask(ctx, name, side, **parameters) returns the query’s rows, and when the run has none yet it ends the call with a request. Sentinel runs every waiting row’s distinct requests once, then calls the rules again, in passes capped by [comparison] evidence_passes. Answers, failures included, are kept beside the run, so a replay or revision sees exactly what the live run saw and sends no SQL.

KeyMeaning
sidesbaseline, candidate or both (a request names one)
sqlA read-only statement starting with SELECT, WITH or DECLARE; :name marks a parameter, a list or an inlined function
columnsThe result’s column names, in order
parameters, listsScalar parameters, and list parameters with the most items each may hold
max_rowsThe most rows an answer may hold; a larger one is unavailable
fileThe .jsonl file beside the run that keeps the answers
inlineA table-valued function the login may read but not call, inlined with its table parameter given as VALUES
timeout_secondsHow long a statement may run (default 120)
[comparison.evidence.order_lines]
form = "query"
sides = ["baseline", "candidate"]
parameters = ["order_id"]
columns = ["line_id", "amount"]
max_rows = 1000
file = "order_evidence.jsonl"
sql = "SELECT LineId, Amount FROM dbo.OrderLine WHERE OrderId = :order_id"

Check, policy, condition, guard and settlement rules

What reports record

Beside every report, two files show which rules decided what:

Neither changes a report’s figures.

Trying a rule

manage.py rules try <rule-id> --report N runs a classifier rule over a stored report’s rows and the evidence it holds, and prints each verdict with its evidence and how many agree with the report (--all for every row, --json for JSON). It writes nothing and sends no SQL: a request for evidence the report doesn’t hold is counted, not asked.