Skip to main content
SDK concepts

Set the posture once. Let each goal carry the detail.

Baselines hold shared rules. Scopes hold goals. Assets do the work. Every path returns the same result model, so the integration stays readable as the system grows.

Status: Beta Companion docs: Get started · Scopes and assets · Result

Three layers keep setup clear​

The three-layer model, three nouns, one rule

Scope

A goal

Declare the goal once. Every asset bound to this scope shares the goal and its stacked policies.

tr.scope("refund-flow", goal="Resolve refunds within policy")
  1. A baseline holds the common posture for governed work.
  2. A scope names a goal and groups the work that shares it.
  3. An asset is the model client, MCP server, CLI, Skill, connector, sandbox, or RAG system that does the work.

An asset at the root inherits the baseline. An asset created from a scope also inherits that scope’s goal and focused settings.

Baseline, scope, and asset

The same object model is available in Python and TypeScript.

Python / TypeScript
refunds.py
from trinitite import Trinitite

tr = Trinitite()
tr.govern(
frameworks=["soc2"],
policies=["refund-policy"],
mode="enforce",
)

refunds = tr.scope(
"refunds",
goal="Resolve valid refunds without exposing customer data.",
)

client = refunds.client(
"openai",
credential="cred_openai_prod",
)

Asset constellation, one binding model

Selected asset

Client

Binding
Bind at the baseline or from a scope.
Acquisition
Inline (wrap), or split-govern for a direct provider call.

An asset with no scope inherits the baseline house rules. A scoped asset also inherits the scope goal and policies.

Start at the level you need​

The ladder, one line, then composable, then fully customizable

Inherited

Platform-default Guardian and policy bundle

You add

Your governed call

Drop deeper only when you need to customize.

  • Start simple: connect a model and inherit the shared baseline.
  • Add a scope: group assets that work toward the same goal.
  • Tune one edge: override a setting only for the asset or call that needs it.

This keeps common policy out of every request while preserving a clear escape hatch for sensitive work.

A result can reach you three ways​

Three ways a result reaches you, one shape on every path

  1. 01Your codeThen
  2. 02tr.clientThen
  3. 03GuardianThen
  4. 04ProviderProduces
  5. One Result shapeverdict + diff + controls+ compliance + risk + receipt
How you get ittr.result(resp)

Only acquisition differs. The result is the same, whichever path it came in on.

Inline​

Your code makes a wrapped model call. Use tr.result(response) right away. This is the main path in both Python and TypeScript.

Observed​

Another system makes the call. Query the stored decision by ID, filters, or correlation. Both SDKs provide result lookup and correlation helpers.

Wait for an observed result

Python / TypeScript
observed.py
result = tr.results.wait_for_correlation(
"refund-4821",
poll_interval_seconds=0.5,
max_wait_seconds=15,
)

Split governance​

Split governance checks input and output around a provider call the platform cannot wrap. The current split-govern handle is Python-only. This is a local method difference, not a limit on the TypeScript SDK’s wrapped or observed paths.

input_result = tr.govern.input(
instructions="Do not expose customer data.",
input=messages,
masking=["pii"],
)

provider_messages = input_result.masked_body or messages
provider_response = provider.chat.completions.create(
model="gpt-4o",
messages=provider_messages,
)

output_result = tr.govern.output(
flow_id=input_result.flow_id,
instructions="Do not expose customer data.",
input=provider_messages + [{
"role": "assistant",
"content": provider_response.choices[0].message.content,
}],
)

Always forward masked_body when it is present. Unmask only inside the approved trust boundary.

One result shape keeps app code steady​

Each path gives you a GovernanceResult. Common fields include verdict, diff, violations, compliance, and risk. Optional handles appear only when that call produced them.

Governance result

One object, clear next steps

Selected field
explanation
explain()
Value
Structured trace
Use
Call the method when a person needs the decision steps.

Methods such as explain() fetch deeper context only when you need it. Optional receipt handles verify the decision without making every app path carry audit logic.

Go deeper​