Retail Facial Tracking · 09 / 26

Tool and API (Application Programming Interface) Contracts

The tool catalogue and contracts of the retail face platform: OpenAPI and MCP (Model Context Protocol) definitions, error model, idempotency, contract tests and what AI (artificial intelligence) may never call.

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.

The tool catalogue

ToolPurposeChanges dataSafe to retryScopeNeeds approval
get_store_summaryRead store facts, zones and signage statusNoYesstore.readNo
get_aggregate_countsRead anonymous counts and dwell, with suppressionNoYesanalytics.readNo
get_consent_statusRead consent status counts or one member's consent statusNoYesconsent.readNo
get_register_statusRead template register reconciliation statusNoYesregister.readNo
search_policiesRetrieve privacy policies and notices with citation and versionNoYesknowledge.readNo
propose_staffingRecord an advisory staffing suggestion from countsYes, a proposal onlyYes, by keystaffing.proposeThe manager decides
draft_privacy_reportCreate a draft monthly privacy reportYes, a draft onlyYes, by keyreport.draftThe privacy officer signs before filing
draft_rights_responseCreate a draft rights-request responseYes, a draft onlyYes, by keyresponse.draftThe privacy officer sends
draft_impact_assessmentCreate a draft impact assessmentYes, a draft onlyYes, by keypia.draftThe privacy officer signs
file_reportFile a report to the recordYesYes, by keyreport.fileSignature required; not callable by AI
send_rights_responseSend a response to a memberYesYes, by keyresponse.sendPrivacy officer only; not callable by AI
delete_templateDelete a template on withdrawalYesYes, by keytemplate.deleteTriggered 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.

retail-platform-tools.openapi.yaml · excerpt
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.

get_consent_status · MCP tool definition
{
  "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

CodeMeaningWhat the platform does
invalid_argumentA field failed validationRoute to a person with the reason; never retry unchanged
not_foundStore, member or report unknownCheck the identifier; do not guess
conflictA report already signed or filedRe-read state; never overwrite a signed record
forbiddenScope or signature check failedDo not retry; route to a person; raise a security event
rate_limitedToo many callsBack off, then queue
unavailableBackend down or timed outRetry once with the same key, then fall back to manual documentation

Rules every tool follows

  1. Idempotency

    Every write takes an idempotency key. A replay returns the original result and never creates a second one.

  2. 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.

  3. Uncertainty always

    A proposal without a stated uncertainty and its evidence is refused.

  4. Versioning

    Contracts are versioned. A breaking change is a new major version, run side by side until the evaluation set passes on it.

  5. Audit

    Each call writes an audit record with the arguments hash, the caller, the model version, the outcome and the trace identifier.

A lost response, a safe retry and a refused identity request A staffing proposal is recorded but the response is lost. The service retries once with the same idempotency key and receives the original proposal. A separate attempt to include identity data in a proposal is refused and audited. Staffing advisor Retail gateway Planning store Audit log propose_staffing, key K1 check scope, uncertainty, evidence store proposal, key K1 proposal P-318 recorded response lost: timeout unavailable retry once, same key K1 propose_staffing, key K1 store, key K1 key seen: return original P-318, 200 P-318 propose_staffing with member identity identity data is not accepted audit: refused unprocessable
A lost response, a safe retry and a refused identity request

Contract tests

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