Mokum Solutions logoMokum Solutions, LLC

Agent builder

Connect an AI agent to governed data: what to ask for, how the platform answers, and what your agent must do when the answer is no.

Volume 6 of 8 · Platform v1.0.0 · Responses in this volume are real, captured on 21 October 2026 from a demonstration agent against the Northwind demo data · Read Volumes 0 and 1 first

1. How an agent meets the platform

People are not the platform's data consumers: agents are. An agent is an AI program with an identity, an owner who answers for it, roles and a key. It reaches data through one of two front doors, both feeding the same governance pipeline:

Front doorUse it whenCredential
mcp-gateway (MCP tools) port 8022, path /mcpYour agent speaks the Model Context Protocol. This is the intended long-term front door.The agent's API key, as a bearer token.
pg-gateway (Postgres wire protocol) host port 8020You use SQL tooling: psql, JDBC, ODBC, a BI tool.A Statement of Intent token as the connection password.

Four ideas explain everything the platform does to your agent:

  1. Purpose, not query. Access is granted for a stated purpose, in plain words, signed by a person. Your queries are then checked against that purpose.
  2. Trust sets autonomy. The better the data's trust score, and the lower the impact of a wrong decision, the more your agent may do alone. Below the line it decides nothing and a person does.
  3. A person is in the loop where it matters. The platform holds, steps down or refuses rather than guess. It tells you which, and why.
  4. Recalls are binding. If a product is recalled, your access to it ends and you are told.
Build for refusalA well-built agent treats "held", "stepped down" and "denied" as normal answers with defined next steps, not as errors to retry. Chapter 7 lists them.

2. Get ready

  1. An Ops Administrator registers the agent with its owner and roles, then generates its key (Volume 5, chapter 3). The key is shown once. Store it in your secret manager.
  2. Choose roles for what the agent does. The roles are CONSUMER, SERVICE_ACCOUNT, SECURITY_ANALYST, DATA_SCIENTIST and AUDITOR. A Statement of Intent can name the roles allowed to use it, and the platform scopes your requests to your own roles.
  3. Optionally set a recall webhook (https only) so you are pushed a Recall Token. Without one you read recalls by pull (chapter 8).
  4. Ask for access to each product with submit_statement_of_intent (chapter 6) and wait for a person to sign.
The Agents screen
Figure 1. The Agents screen (Volume 5). An agent must be ACTIVE and have a key. A frozen or deactivated agent's key stops verifying.

3. Connect

mcp-gateway

Point your MCP client at the streamable HTTP endpoint and send the key as a bearer token.

SettingValue
URLhttp://<host>:8022/mcp
TransportStreamable HTTP
HeaderAuthorization: Bearer <agent API key>

The gateway checks the key with the agent registry on every call. A missing, wrong, deactivated or frozen key is refused before any tool runs. This example uses the Python MCP SDK (tested with version 2.3.0, which bundles its own HTTP client; the client calls differ between SDK versions, so follow your version's documentation):

import asyncio, os
import httpx2  # the HTTP client bundled with this SDK version
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client

async def main():
    http = httpx2.AsyncClient(headers={"Authorization": "Bearer " + os.environ["FIDULOCK_AGENT_KEY"]})
    async with streamable_http_client("http://localhost:8022/mcp", http_client=http) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            tools = await session.list_tools()
            print([t.name for t in tools.tools])
            result = await session.call_tool("get_recall_notices", {})
            print(result.content[0].text)

asyncio.run(main())

pg-gateway

Any tool that speaks Postgres connects as to a real database. Only the password matters: it is the Statement of Intent's bearer token, forwarded to the platform on every call. The username and database name are not checked.

psql "postgresql://agent:<soi-token>@localhost:8020/governed?sslmode=disable"
  • The gateway declines TLS negotiation, so set sslmode=disable (put TLS in front of it, as the platform's reverse proxy does).
  • A SoI's token is minted when the statement becomes ACTIVE. An agent fetches it with get_temporary_access_token once a person has approved.
  • A held query cannot wait on a live connection, so it fails at once with SQLSTATE 42501 and a message naming the ticket: "Query held for governance review". A hard denial uses the same code with the specific reason.

4. The tools

The gateway offers fifteen tools. Every one forwards to a REST endpoint that exists independently and is independently role-guarded: there are no MCP-only capabilities.

Discover (no access needed)

ToolGives you
list_data_productsEvery product in the catalog with its badge, score, drift state, owner and sensitivity. Browsing needs no Statement of Intent. Where the platform has switched on region filtering, a product whose Data Passport excludes your registered region is left out of the list. If your region is unknown you see everything.
get_data_product_metadata(data_product_id)The best first call. Live trust and the six pillar scores, and with them trust.drivers (one sentence per pillar saying why it scored what it did) and trust.volatility (over 90 days: recalls, the lowest and highest score, the swing, and days spent below Certified). Also the weight version, the badge, drift state, safety mode, any consumption warning; every field's meaning and valid range; regulated_terms (the glossary definition of each regulated term, such as a legal or compliance term, that the description or a field's meaning uses); survivorship (for a harmonized product, which source system won each field and why, never the values); jurisdiction from the passport and classification. A part it cannot read is null, not guessed.
get_data_contract(data_product_id)The ACTIVE contract: schema, quality rules, service levels, write scope. A failing description is withheld; the schema and rules are not.
get_contract_yaml(data_product_id)The same contract as ODCS YAML, to read the rules before you read the data.
get_lineage(data_product_id)Upstream sources and downstream consumers: the chain of custody.
get_metric_definition(metric_id)What a registered business metric means before you quote its number: for example METRIC_FIN_004. Returns found: true and the live definition (version, plain-language description, the acronyms and terms it defines, owner), or found: false if no active metric has that id. Needs no Statement of Intent.

Ask for access

ToolDoes
submit_statement_of_intent(data_product_id, purpose, use_case, days=1)Files a request as a DRAFT, scoped to your own roles, valid for 1 to 3 days once approved. Nothing is granted by asking.
list_my_access_requests()Your requests and where each stands: DRAFT (waiting for a person to sign), ACTIVE (approved), anything else (not usable).
get_temporary_access_token(soi_id)The token for an approved request, for clients that connect with a token rather than through the gateway. Only the agent that asked may fetch it; it stops working when the days run out.

Consume

ToolDoes
validate_query(data_product_id, sql, …)A dry run: parsing, triage and intent alignment, never executing. Answers ALIGNED, ESCALATED (a person must decide) or UNCERTIFIED_FAILOPEN. Use it before spending a real call.
describe_query(data_product_id, sql, …)Just the columns a query would produce. No alignment check, no execution.
execute_query(data_product_id, sql, …)Runs a read through the governance pipeline and returns the rows plus a trust context: the score, the badge and the six pillar scores behind it, with the weight version, a trust_level and a high_volatility flag (chapter 6). Add include_definitions=true to also get, for every returned column, the glossary term that speaks for it and its definition (definitions: column, term, definition). It is null if the glossary cannot be read.
execute_write(data_product_id, sql, …)An UPDATE or DELETE, gated on trust, on the Statement of Intent's Impact Class and on the contract's write scope. It may execute, be held for a person or be refused.
transfer_data(data_product_id, receiver_agent_id, receiver_soi_id, data_hash, receiver_action, …)Hands data you read to another agent. A new disclosure, decided by the platform (chapter 6, "Transfers"). You send the SHA-256 hash of the data; the platform never sees the data.

The consume tools accept optional session fields: session_id, step_number, action (recommend, draft, approve, execute or transfer) and value (what the step moves, for example a refund amount). Declaring them puts you under the step floors and chain limits (chapter 6). Declaring nothing leaves the call as plain as before.

Stay safe

ToolDoes
get_recall_notices()The signed Recall Tokens addressed to you whose recall is still in force, and signed advisory notices (chapter 8). Call it at the start of every task and whenever a query is denied.

5. A worked session

Everything below was returned by a real call to the gateway. Long fields are shortened with ….

Step 1: judge the product

get_data_product_metadata("2a35b15e-…")
{
  "name": "Northwind Product Catalog",
  "description": "The list of everything Northwind sells, with its price and category.",
  "trust": {
    "tdk_score": 82.0,
    "pillars": { "clarity": 76, "security": 90, "freshness": 75,
                 "governance": 100, "dataQuality": 50, "dataContract": 100 },
    "weights_version": 3,
    "badge_status": "CERTIFIED",
    "blast_radius_tier": "PASSIVE",
    "drift_state": "NONE",
    "safety_mode": false,
    "consumption_warning": null
  },
  "fields": [
    { "name": "Product ID", "column": "product_id",
      "meaning": "The unique code for one product we sell.",
      "type": "string", "required": true,
      "valid_range": { "example": "NW-10432", … },
      "sensitivity": "INTERNAL", "masking": "NONE" },
    …
  ],
  "jurisdiction": { … }
}
  • It is CERTIFIED at 82.0, so the product clears the certification line. The weakest pillar is dataQuality at 50, "unassessed": nothing has measured the data's rules yet.
  • consumption_warning is null. For a product below the Managed line it holds the text "high hallucination risk for AI models" and your agent should not act on that data without a human check.
  • The answer was shortened here. A full answer also holds trust.drivers (why each pillar scored what it did), trust.volatility, regulated_terms and, for a harmonized product, survivorship. Read drivers before you decide the weakest pillar does not matter for your task.
  • The field list is exactly what the platform gives an agent: each field's plain-language meaning, never its regulatory annex or calculation logic (Volume 1, chapter 4).

Step 2: ask for access

submit_statement_of_intent("2a35b15e-…",
    purpose="Quote current prices to resellers.",
    use_case="Look up the price of a product when a reseller asks for it.")
{
  "soi_id": "f24fc058-…",
  "status": "DRAFT",
  "purpose": "Quote current prices to resellers.",
  "use_case": "Look up the price of a product when a reseller asks for it.",
  "expiry_date": "2026-10-22",
  "next_step": "Waiting for the product's owner to sign it. Nothing is granted yet."
}

A person signs it (Volume 2, chapter 3). Until then, asking for the token is refused:

get_temporary_access_token("f24fc058-…")
Error: Query denied (409): This request is DRAFT; a person has to approve it first.

Step 3: check a query, and declare what you mean to do

validate_query("8ee6f923-…",
    sql="SELECT order_date, SUM(order_total) AS revenue FROM northwind.orders GROUP BY order_date",
    action="execute", session_id="run-2", step_number=1)
{
  "status": "ALIGNED",
  "step": {
    "declared_action": "execute",
    "granted_action": "draft",
    "stepped_down": true,
    "tdk_score": 77.8,
    "declared_floor": 80.0,
    "explanation": "TDK 77.8 does not support the execute step (needs 80) for an Impact Class B decision; the highest step it supports is draft."
  },
  "tables": [ { "table": "northwind.orders", "soi_id": "651ee466-…", "contract_id": "47f54d67-…" } ]
}

The query is aligned with its purpose, but the data is not trusted enough for the execute step. The platform stepped the agent down to draft and says so. Treat your next action as a draft, for a person to approve. Declaring action="recommend" for the same query is granted as asked ("TDK 77.8 supports the recommend step").

Step 4: when the answer is no

execute_write("8ee6f923-…", sql="UPDATE northwind.orders SET order_status = 'cancelled' WHERE …")
Error: Query denied (403): This contract's write_scope does not permit UPDATE.

execute_query("2a35b15e-…", sql="SELECT product_name, list_price FROM northwind.catalog")
Error: Query denied (403): Could not mint an ephemeral credential for this data product.

The first is a rule: the contract does not allow an update, and no retry will change that. The second is an operational fact: this demonstration product is not connected to a real database, so the platform cannot mint the short-lived database role that every read needs. Read the message, do not guess.

Step 5: check for recalls

get_recall_notices()
{ "notices": [] }

An empty list means nothing you rely on is recalled.

6. How the platform treats your requests

The pipeline

Every query goes through four stages: Parsing (is it valid, which tables), Triage (identity, the HITL floor, the step floor, the contract), Rewriting (row filters and masking are applied for you) and the JIT gate (a short-lived database role is minted for this query and revoked after).

The HITL Floor: below the line, you decide nothing

If the product's trust score is below the effective floor, missing, or stale, a person decides and your request goes to the human queue (Volume 4, chapter 5). The effective floor is the platform floor (60 by default) or the highest floor on any active contract for the product, whichever is greater. The check runs before anything that could skip it.

Trust levels and the volatility flag

The trust context in an answer names the band of the score in trust_level. The names are for people to read; they change no rule.

ScoreLevelWhat an AI can rely on
90 or moreIndustrializedReliable for autonomous decisions.
70 to under 90ManagedReliable with human oversight.
50 to under 70DevelopingUnreliable: expect errors.
Under 50AmbiguousNot to be relied on.

high_volatility: true means the score sits between 60 (the shipped HITL floor) and 80, the lowest Trusted line. The platform served the answer, but the data is not yet where the badge is CERTIFIED. Treat the result as provisional: say so to your users, and do not take an irreversible action on it alone. Your floor decides what you may do; the flag is a hint.

Autonomy by Impact Class

Each Statement of Intent has an Impact Class (Volume 2, chapter 4). It sets how much trust your agent needs to execute alone:

ClassExecutes alone at
Ascore 70 or more
B80 or more
C95 or more on a low-impact product (96 and 98 on more critical ones)
D (and a statement with no class)never alone: held for an expert at 95 or more; stopped under the Fail-Close line

Write autonomy is held the same way over time: the band is the stricter of the live score and the product's lowest score over the recovery hold (24 hours by default). If the history cannot be read, a write is capped at supervised, never higher.

Step floors

Riskier steps need more trust. When you declare an action, you are held to that step's floor: the platform's, raised (never lowered) by the contract's own step_floors. A riskier step never needs less trust than a safer one. Three outcomes:

OutcomeYou seeYou do
Supportedstepped_down: falseProceed.
Stepped downstepped_down: true, granted_action lower. A write becomes a held draft.Treat the next action as the lower step.
None supportedThe request goes to the human queue, reason STEP_FLOOR.Wait for a person.

Chain controls

Give the same session_id on every step of a run. The platform tracks it as a chain, with limits by Impact Class on the number of steps, the records changed, the declared value and the speed; no unbroken run of draft, approve and execute without a person in between; and a trust floor that rises half a point per step after the fifth (to a ten point cap).

  • Past a limit, the step waits for a person (reason SESSION_LIMIT).
  • A second hit freezes the session and your credential: your key stops verifying. A governance lead, the product's Business Owner or the value guardian must unfreeze it. Stay inside the limits rather than hoping to be unfrozen.

Escalations

A query that does not match the statement's purpose, or that the intent check cannot judge with confidence, is escalated: it returns ESCALATED with an escalation id and the reasoning, and waits for a person. Poll the escalation's status rather than retrying the query; a retry is a new escalation. An approval is single-use and is void if the asset changed since it was given.

Transfers

Handing data to another agent is a new disclosure and is not left to the agents. The answer is ALLOWED, STAGED (a person approves or rejects) or BLOCKED. The receiver must be an active, unfrozen agent with its own active Statement of Intent on that product (purpose does not travel), the data's live trust must clear the receiver's floor for what it will do with it plus a two-point margin, and a receiver whose contract allows writes is held to execute.

Masking and joins

Fields marked HASH or PARTIAL come back masked. A contract can ask for more modes: FULL, LAST4 (only the last four characters), NOISE:<scale> (a number with random noise added), GENERALIZE_YEAR and GENERALIZE_MONTH (a date cut to its year or month), BUCKET:<width> (a number put in a range of that width) and PLACEHOLDER. A role the contract lists as an exception, or an intent it lists, may see less masking. Your own role or intent may be on that list, and nothing the catalog masks is ever lifted. A field with no class yet (UNCLASSIFIED) comes back fully masked. A non-production contract serves no confidential or restricted field unmasked when the platform enforces that rule. A join that touches a CONFIDENTIAL or higher product masks the linking field in what is shown (not in the join itself), and the answer lists masked_links with the reason. Do not try to unmask by re-joining: the rule follows the data.

Consent, region and stale data

  • Consent. You may read a product only if its owner has recorded consent for AI use (PERMITTED_FOR_AI). Otherwise you are refused before anything is queued: CONSENT_NOT_PERMITTED, CONSENT_ANALYTICS_ONLY, or CONSENT_UNDECLARED where the platform has chosen to refuse undeclared data. When consent is withdrawn you are refused at once and may receive a recall token.
  • Consent filter and record age. A contract may name a consent column (consentFilter). You then get only the rows whose value in that column is permitted, and a row with no value is withheld. A contract may also set a maxRecordAge, which adds a filter so that you only see rows newer than that many hours. A smaller row count than you expect is not an error. Do not treat the result as the whole table.
  • Region. Your registered region travels in your signed identity. Where a Data Passport restricts jurisdictions you may be refused with CALLER_REGION_UNKNOWN, REGION_MISMATCH or SOVEREIGNTY_RESTRICTED. The platform may be running the check in shadow mode, which only logs.
  • Stale data. A read whose data is older than the contract's freshness promise still succeeds, but the answer carries stale, data_age_hours and freshness_sla_hours, and the response has an X-Stale-Data: true header. Do not present it as current.
  • Masking by intent. If your statement declares an intent and the contract lists it for a field, that field may come back partially masked instead of fully. Do not infer the hidden part.

7. Write a request a person will sign

A Statement of Intent is read by a human owner and checked by the platform. Write it for both.

  • Purpose (10 to 500 characters): the business reason, in plain words. "Quote current prices to resellers."
  • Use case (10 to 500 characters): what the agent will do with the data. "Look up the price of a product when a reseller asks for it."
  • Days: 1, 2 or 3. Ask for as long as you need and no more. Access is never open-ended. The days give the request its expiry date, which the platform requires.
Be specificA purpose of fewer than 6 words, or a use case of fewer than 4, is too short. Text that could describe any request ("for analysis", "business purposes", "reporting") is too vague, because after the filler words are taken out too little is left. Name the decision, the team or the process the data supports. Where the platform has switched this check on you get 422 intent-too-vague and the reasons; where it has not, the request is accepted and only logged, but write it as if the check were on: a person has to sign it.
No SQL, no field names, no filtersA purpose that reads as a query is refused with 422 intent-has-syntax. Table and column names, comparisons and SQL keywords are all caught. Describe the work, not the data access. The same rule applies to people (Volume 5, chapter 7).
DoDo not
"Summarise sales by day for the weekly review.""SELECT order_date, SUM(order_total) FROM orders".
"Answer a reseller's question about the price of one product.""Read list_price where category = 'outdoor'".
"Help customer service find which orders belong to a customer.""Join customers and orders on customer_id".

Then write queries that fit the purpose. A statement that says "summarise by day" is satisfied by a grouped sum and held for raw rows: the intent check judges the shape of the query against the stated purpose (Volume 1, chapter 7).

8. Recalls and safety mode

When a product's badge is recalled, or it enters safety mode, the platform makes a Recall Token for every active agent whose roles the affected statements name. A token says what to do: stop using the product, or enter your own safety mode.

  • Push. An agent with a recall webhook is sent the token every 30 seconds until accepted, with retry and back-off, six attempts at most.
  • Pull. Every agent can read the same tokens with get_recall_notices(). Call it at the start of every task and whenever a query is denied.
  • Verify. Each token is signed by the trust badge engine's Ed25519 key. Check the signature against the published public key (GET /recalls/public-key) before acting. A token you cannot verify is not an order.
  • The kill switch is also in the data path. Once a recall is in force, queries on that product return a denial regardless of what your agent does. Honouring the token is how your agent stops cleanly instead of failing.
  • Clearing a recall is recorded and the agents told are told again.

Advisory notices

Besides recalls, get_recall_notices() can return signed advisory notices. Each has advisory: true and a kind:

KindMeans
DRIFTThe product is halted or quarantined for drift.
RECERT_LAPSEDIts badge fell from CERTIFIED to WARNING because a recertification was overdue.
FRESHNESSA late load or a missed heartbeat on a Class C or D product.
CONTRACT_CHANGEA breaking version of its contract is coming. Read the new contract and plan the move.

A notice goes to the agents whose Statements of Intent name the product, at most once a day per product and kind, and stays in the list for 7 days. It warns; it does not stop you. A notice never hides a recall that is in force. Verify its signature the same way as a recall token.

What an agent does on a token is its own business: stop its task, release its work, tell its users. The platform guarantees the delivery and the record, not the response.

9. Errors and what to do

You getIt meansDo this
INSUFFICIENT_TOKEN_BALANCE with an estimated costYour department's balance is lower than what the query is estimated to cost (about the rows Postgres expects it to return).Narrow the query (a filter or a LIMIT lowers the estimate) or ask for a top-up. Nothing was read or charged.
CONSENT_NOT_PERMITTED, CONSENT_ANALYTICS_ONLY, CONSENT_UNDECLAREDThe product's consent flag does not allow AI use.Do not retry. Choose another product, or ask the owner to record consent.
CONSENT_REGISTRY_UNREACHABLEThe consent registry could not be read and the product is sensitive.Retry later; nothing was run.
CALLER_REGION_UNKNOWN, REGION_MISMATCH, SOVEREIGNTY_RESTRICTEDYour region is missing, disagrees with your statement, or is outside the passport.Ask an administrator to set your region; do not retry.
PASSPORT_INTEGRITY_FAILEDThe passport's integrity check failed on a Class C or D statement.Stop; check get_recall_notices.
401 or "invalid_api_key"The key is wrong, regenerated, or the agent is deactivated or frozen.Check the agent on the Agents screen; get a new key from an Ops Administrator.
"No active Statement of Intent" for your rolesYou have not been approved for this product, or it expired.list_my_access_requests; ask again.
409 "This request is DRAFT; a person has to approve it first"Still waiting for a signature.Wait and poll list_my_access_requests.
422 intent-has-syntaxYour purpose reads as a query.Rewrite it in plain words.
403 "column outside the data contract"You asked for a field the contract does not expose.Read get_data_contract and ask only for what it lists.
403 "write_scope does not permit UPDATE"The contract allows no such write.Do not retry. Ask the product's steward to change the contract if it should.
403 HITL_FLOOR (validate, describe)The data is below the effective floor.Choose a more trusted product, or wait. No queue item is made for a dry run.
DRIFT_CIRCUIT_OPENThe product has technical drift (a column dropped or retyped, a late load) and your statement is Class C or D: reads are halted. A Class A or B statement is told of drift, not refused.Stop; check get_recall_notices for a DRIFT notice and try again later.
CONTRACT_SUSPENDED, with a reasonThe data contract failed (a breached service level, a retired version with children left, or a person suspended it) and stopped serving. A child contract that fails suspends only itself; a parent that fails takes its children with it. A suspended child never falls back to its parent.Do not retry. Read the reason. Access returns when the contract does. Tell the steward if it lasts.
422 intent-too-vagueYour purpose or use case is too short or could fit any request, or it has no expiry.Name the decision, the team or the process (chapter 7).
A product in quarantine (a drift or safety signal, no refusal)The product is served obfuscated, row-capped and read-only.Expect fewer rows and masked fields; do not try to write.
Denied because the badge is revokedThe product was recalled.Call get_recall_notices, then stop using it.
ESCALATEDA person must decide.Keep the escalation id, poll its status, do not retry.
Reason RECOVERINGThe score is back over the floor but the hold has not ended.Wait.
Reason STEP_FLOOR or SESSION_LIMITThe step needs more trust than the data has, or the chain hit a limit.Lower the step, or wait for a person.
"Could not mint an ephemeral credential"The product has no usable database connection.Tell the steward; it is not your query.
Your key stops working mid-taskA second limit hit froze the session.Stop. A governance lead or the owner must unfreeze it.

10. A checklist for a well-behaved agent

  1. Start every task with get_recall_notices.
  2. Judge before you ask: get_data_product_metadata. Do not rely on a product with a consumption warning without a human check.
  3. Read the contract (get_contract_yaml) and ask only for what it exposes. Look up any metric you quote with get_metric_definition.
  4. Ask for access in plain words, for as few days as you need.
  5. validate_query before execute_query. Declare the action you intend.
  6. Use one session_id for a whole run, and a truthful value.
  7. Treat high_volatility as provisional, and act on an advisory notice before it becomes a recall.
  8. Obey a step-down. Never retry a refusal with a clever rewording; a repeated escalation is a signal, not a loophole.
  9. Never store the key in code, prompts or logs.
  10. Never pass data to another agent except through transfer_data.
  11. When the answer is "a person must decide", stop and report it. That is the system working.

The full request and response reference for every REST endpoint and tool is in the repository's docs/api-guide.md. The Postgres-protocol front door has its own guide in docs/pg-gateway/.