PtcRunner.Kernel.ModelContract (PtcRunner v0.14.0)

Copy Markdown View Source

Projects compiled prelude contracts and normalized capability JSON Schema into one deterministic, renderer-neutral model contract.

The projection uses PtcRunner.Kernel.DeterministicJSON objects. A function contract has parameters (ordered name/type nodes) and returns; a constant contract has value. Type nodes contain kind and nullable, with items for arrays or closed and ordered fields for objects. Each field has an independent required boolean, so omission is never conflated with a nullable value.

JSON Schema annotations and validity constraints retain their normalized names: title, description, enum, const, minimum, maximum, min_length, max_length, min_items, max_items, and format. Missing optional output schemas remain nil; the prompt renderer omits absent information. This structure is presentation data only. Runtime authority remains with the compiled prelude contract and capability JSON Schema validators.

Summary

Functions

capability(input_schema, output_schema)

@spec capability(map(), map() | nil) ::
  {:ok, term()} | {:error, :unsupported_contract}

capability_call(name, arg2)

@spec capability_call(binary(), map()) :: binary()

function(arg1)

@spec function(PtcRunner.Lisp.Signature.signature()) ::
  {:ok, term()} | {:error, :unsupported_contract}

json_value(value)

@spec json_value(term()) :: {:ok, term()} | {:error, :unsupported_contract}

Builds a value contract from only the top-level kind of a JSON value.

value(type)

@spec value(PtcRunner.Lisp.Signature.type()) ::
  {:ok, term()} | {:error, :unsupported_contract}