Space Mining · 09 / 26

Tool and API (Application Programming Interface) Contracts

The tool catalogue and contracts of the space mining 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 mission records. 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_campaign_summaryRead campaign facts without buyer dataNoYescampaign.readNo
get_survey_productRead survey product pointers and metadataNoYessurvey.readNo
get_ledger_statusRead mass ledger statusNoYesledger.readNo
get_vehicle_statusRead vehicle mode, health and last heartbeatNoYesvehicle.readNo
search_proceduresRetrieve procedures and licence terms with citation and versionNoYesknowledge.readNo
propose_sitesRecord an advisory site ranking with uncertaintyYes, a proposal onlyYes, by keysite.proposeEngineers review and a director signs
draft_shift_reportCreate a draft shift report from structured factsYes, a draft onlyYes, by keyreport.draftAn engineer signs before filing
draft_notificationCreate a draft regulator notificationYes, a draft onlyYes, by keynotice.draftThe compliance officer files
draft_handover_noteCreate a draft handover noteYes, a draft onlyYes, by keynote.draftA person reviews
file_reportFile a report to the recordYesYes, by keyreport.fileSignature required; not callable by AI
sign_planSign a plan and its envelopeYesYes, by keyplan.signDirector only; not callable by AI
release_shipmentRelease a shipmentYesYes, by keyshipment.releaseDirector approval; not callable by AI

An operation, in OpenAPI

Proposing sites 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 a vehicle command.

mining-planning-tools.openapi.yaml · excerpt
openapi: 3.1.0
info: { title: Mining planning tools, version: 1.2.0 }
paths:
  /campaigns/{campaign_id}/site-proposals:
    post:
      operationId: propose_sites
      summary: Record an advisory site ranking. A proposal only: it changes nothing and cannot be sent to any vehicle.
      parameters:
        - { name: campaign_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, ranking, uncertainty, evidence]
              properties:
                model_version: { type: string }
                ranking:       { type: array, description: Site ids in rank order, items: { type: string } }
                uncertainty:   { type: array, description: Per-site uncertainty as a fraction, items: { type: number, minimum: 0, maximum: 1 } }
                evidence:      { type: array, description: Pointers to the survey products used, items: { type: string } }
      responses:
        "201": { description: Recorded as a proposal for the engineers }
        "200": { description: Same Idempotency-Key replayed; returns the original proposal }
        "422": { description: Ranking missing uncertainty, or an attempt to include vehicle commands }
        "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 buyer data and read-only hints.

get_ledger_status · MCP tool definition
{
  "name": "get_ledger_status",
  "description": "Read mass ledger status for a batch or campaign. Read only. No buyer or price data.",
  "inputSchema": {
    "type": "object",
    "required": ["campaign_id"],
    "properties": {
      "campaign_id": { "type": "string" },
      "include": { "type": "array", "maxItems": 3,
                   "items": { "enum": ["status", "gap_pct", "open_batches"] } }
    }
  },
  "annotations": { "readOnlyHint": true, "idempotentHint": true }
}

Error model

CodeMeaningWhat the platform does
invalid_argumentA field failed validationRoute to an engineer with the reason; never retry unchanged
not_foundCampaign, product or batch unknownCheck the identifier; do not guess
conflictA plan or 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. Signing, approving, releasing and filing are acts of a named person with strong authentication.

  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 vehicle command A site proposal is recorded but the response is lost. The planning service retries once with the same idempotency key and receives the original proposal. A separate attempt to include a vehicle command in a proposal is refused and audited. Site advisor Ground gateway Planning store Audit log propose_sites, key K1 check scope, uncertainty, evidence store proposal, key K1 proposal P-318 recorded response lost: timeout unavailable retry once, same key K1 propose_sites, key K1 store, key K1 key seen: return original P-318, 200 P-318 propose_sites with a vehicle command vehicle commands are not accepted audit: refused unprocessable
A lost response, a safe retry and a refused vehicle command

Contract tests

Build this for your business

This example is speculative and describes no real mission, but the same pattern, deterministic safety for every hard duty, a governed gateway, runtime security, advisory-only AI and measured quality, fits any remote, high-consequence operation. We can scope a pilot on your own systems.

Book a discovery call