Why contracts come first
The tools are the only way the advisory and documentation components can touch retail systems. Their contracts are the stable layer: the Microsoft Foundry build and the LangGraph build both call the same operations, and the evaluation set checks the same arguments. A strict contract makes the system testable and limits what a manipulated model can do.
- Arguments are typed, bounded and validated by the retail gateway, never trusted from the model.
- Every tool declares whether it changes anything, whether it is safe to retry and what scope it needs.
- AI-facing tools can read aggregates and draft. Confirming a match, withdrawing consent, deleting a template and sending a rights response are acts of a person.
- No tool, and no path from any tool, can read an image or a template, change the privacy gate or enrol or match anyone.
The tool catalogue
| Tool | Purpose | Changes data | Safe to retry | Scope | Needs approval |
|---|---|---|---|---|---|
| get_store_summary | Read store facts, zones and signage status | No | Yes | store.read | No |
| get_aggregate_counts | Read anonymous counts and dwell, with suppression | No | Yes | analytics.read | No |
| get_consent_status | Read consent status counts or one member's consent status | No | Yes | consent.read | No |
| get_register_status | Read template register reconciliation status | No | Yes | register.read | No |
| search_policies | Retrieve privacy policies and notices with citation and version | No | Yes | knowledge.read | No |
| propose_staffing | Record an advisory staffing suggestion from counts | Yes, a proposal only | Yes, by key | staffing.propose | The manager decides |
| draft_privacy_report | Create a draft monthly privacy report | Yes, a draft only | Yes, by key | report.draft | The privacy officer signs before filing |
| draft_rights_response | Create a draft rights-request response | Yes, a draft only | Yes, by key | response.draft | The privacy officer sends |
| draft_impact_assessment | Create a draft impact assessment | Yes, a draft only | Yes, by key | pia.draft | The privacy officer signs |
| file_report | File a report to the record | Yes | Yes, by key | report.file | Signature required; not callable by AI |
| send_rights_response | Send a response to a member | Yes | Yes, by key | response.send | Privacy officer only; not callable by AI |
| delete_template | Delete a template on withdrawal | Yes | Yes, by key | template.delete | Triggered by the consent register; not callable by AI |
An operation, in OpenAPI
Proposing staffing is the most consequential AI-facing write, and it is only a proposal. The operation requires an idempotency key, model version, uncertainty and evidence, and refuses anything that looks like identity or recognition settings.
openapi: 3.1.0
info: { title: Retail platform tools, version: 1.2.0 }
paths:
/stores/{store_id}/staffing-proposals:
post:
operationId: propose_staffing
summary: Record an advisory staffing suggestion from anonymous counts. A proposal only: it identifies nobody and changes no setting.
parameters:
- { name: store_id, in: path, required: true, schema: { type: string } }
- { name: Idempotency-Key, in: header, required: true, schema: { type: string, minLength: 16 } }
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [model_version, slots, uncertainty, evidence]
properties:
model_version: { type: string }
slots: { type: array, description: Time slices with suggested staff counts, items: { type: object } }
uncertainty: { type: array, description: Per-slot uncertainty as a fraction, items: { type: number, minimum: 0, maximum: 1 } }
evidence: { type: array, description: Pointers to the aggregate tables used, items: { type: string } }
responses:
"201": { description: Recorded as a proposal for the manager }
"200": { description: Same Idempotency-Key replayed; returns the original proposal }
"422": { description: Missing uncertainty, or an attempt to include identity or recognition settings }
"403": { description: Caller scope failed }A read tool, as an MCP definition
The platform sees tools through the Model Context Protocol. The definition repeats the constraints that matter: required fields, an enumerated list of what to include, no images or templates and read-only hints.
{
"name": "get_consent_status",
"description": "Read the consent status counts for a store or the status of one member's consents. Read only. No images, no templates.",
"inputSchema": {
"type": "object",
"required": ["scope"],
"properties": {
"scope": { "enum": ["store", "member"] },
"id": { "type": "string" },
"include": { "type": "array", "maxItems": 3,
"items": { "enum": ["status", "purposes", "withdrawn_count"] } }
}
},
"annotations": { "readOnlyHint": true, "idempotentHint": true }
}Error model
| Code | Meaning | What the platform does |
|---|---|---|
| invalid_argument | A field failed validation | Route to a person with the reason; never retry unchanged |
| not_found | Store, member or report unknown | Check the identifier; do not guess |
| conflict | A report already signed or filed | Re-read state; never overwrite a signed record |
| forbidden | Scope or signature check failed | Do not retry; route to a person; raise a security event |
| rate_limited | Too many calls | Back off, then queue |
| unavailable | Backend down or timed out | Retry once with the same key, then fall back to manual documentation |
Rules every tool follows
Idempotency
Every write takes an idempotency key. A replay returns the original result and never creates a second one.
Propose, never decide
AI-facing writes create proposals and drafts. Confirming, sending, filing and deleting are acts of a person or of the consent register.
Uncertainty always
A proposal without a stated uncertainty and its evidence is refused.
Versioning
Contracts are versioned. A breaking change is a new major version, run side by side until the evaluation set passes on it.
Audit
Each call writes an audit record with the arguments hash, the caller, the model version, the outcome and the trace identifier.
Contract tests
- Every tool definition validates against the schema and has an owner, a scope and a retry rule.
- Property tests send out-of-range, oversized and malformed arguments and expect invalid_argument, never a partial write.
- A replay test sends each write twice with the same key and expects one result.
- A reachability test proves that no AI-facing credential or route can reach the template vault, the privacy gate or the edge appliances.
- The Foundry build and the LangGraph build run the same contract suite against a mock backend.
Build this for your business
This example is speculative and not a recommendation to deploy, but the same pattern, consent first, a deterministic privacy gate, a governed gateway, runtime security, advisory-only AI and measured fairness, fits any service that handles sensitive personal data. We can scope a pilot on your own systems.
Book a discovery call