Draft internal contract schemas¶
AskLens packages five machine-readable JSON Schemas for its one current internal shape:
catalogquery-plancapabilitiesresulterror
They use JSON Schema Draft 2020-12 and are available from Python:
from django_asklens import get_contract_schema, list_contract_schemas
assert list_contract_schemas() == (
"catalog",
"query-plan",
"capabilities",
"result",
"error",
)
query_plan_schema = get_contract_schema("query-plan")
Each call to get_contract_schema() returns a fresh mapping loaded from the
installed package. The source files are under
django_asklens/contracts/schemas/.
Status and precedence¶
These schemas are the machine-readable documents of the AskLens specification. They are draft, unfrozen, and unversioned. Django AskLens is the first implementation. They are not an NDC profile, a compatibility promise, or evidence of a second backend.
The documents do not contain embedded AskLens contract versions, revisions, or negotiation fields. There is one current unversioned shape. Do not add schema versions. Do not record or handle previous document shapes.
When an internal contract conflict is found, use this order:
- accepted normative prose defines semantics;
- JSON Schema defines wire shape;
- language-neutral fixtures provide executable cases;
- Django must conform to those sources.
A separate top-level conformance/ corpus provides explicit synthetic positive, negative, security, budget, semantic, ordering, truncation, and serialization cases. The Django implementation replays it on SQLite and on the required PostgreSQL 15/18 CI jobs. The source-checkout PostgreSQL 18 Compose/Playwright reference workflow adds demo-path evidence. It does not freeze the specification or prove a second implementation.
Boundaries¶
Fixed structural objects reject additional properties. The query-plan schema
also represents structural validators that generated Pydantic schemas cannot
express on their own; for example, contains and icontains require nonempty
string values. Development tests run an independent Draft 2020-12 validator
against the packaged JSON files and language-neutral corpus rather than treating
the generating Pydantic model as schema evidence.
Public catalogs omit private Django bindings, expressions, permission tokens, scope providers, QuerySets, and tenant identifiers. Machine capabilities omit resources, labels, descriptions, examples, and human scope guidance. Public errors contain only a stable code, safe message, and optional bounded JSON Pointer. The field-by-field surface audit classifies these exact documents separately from HTTP/MCP wrappers, provider guidance, and audit-detail output without making a portability or stability claim.
The result data member retains the approved list of row maps. Row keys are
dynamic result-column names, so that one map allows additional properties only
when each value is a JSON cell (string, integer, finite JSON number,
boolean, or null). Fixed result envelopes, columns, and metadata remain
closed. Column/row key agreement and canonical type-specific value semantics
are enforced by execution and will also be covered by conformance fixtures;
they cannot be expressed completely by the standalone shape schema.
Schema validation is not authorization. A syntactically valid plan still must
enter execute_plan(), which resolves current server-owned identity,
permissions, catalog, row scope, limits, bindings, execution, serialization,
and audit policy.