Internal semantic decision index¶
Status and use¶
This index maps the accepted semantic decisions implemented by the current
Django 0.2 target to their prose, machine-readable shape, language-neutral
fixture, and focused Django evidence. It records the source tree at
7776fa03cb741eefab55b725e8343eeb6a7337b6, immediately before this index was
added.
The index and the five contract documents are internal, draft, and unfrozen. They support review and drift detection for the AskLens specification. They are not a public specification, not a compatibility promise, not evidence of backend neutrality, and not an independent security review. They do not add serialized versions or authorize a second implementation.
Use the precedence defined by Draft internal contract schemas: accepted prose defines semantics, JSON Schema defines wire shape, language-neutral fixtures provide executable cases, and Django conforms to those sources. Schema validation is never authorization. If these columns conflict, stop and resolve the prose decision before changing schema, fixture, or runtime expectations.
Evidence notation¶
Each row has one stable local decision ID:
- Decision is the concise accepted rule represented by the row. The linked prose supplies its fuller internal-contract explanation.
- Schema names only the document whose wire shape represents part of the
rule. Schema applicability is not semantic coverage.
—means the rule is contextual or behavioral and cannot be established by standalone shape validation. - Fixture names an exact case ID from the draft internal conformance corpus. “No dedicated language-neutral fixture” is explicit. A missing fixture is an explicit evidence gap, not proof of a runtime defect.
- Django evidence links focused executable tests. The implementation is evidence, never the normative source.
Some rows cite a fixture as supporting because it executes the behavior but is not a complete boundary test for that decision. All fixture scenarios receive identity, permissions, row scope, registration, limits, and clock from the trusted replay harness; fixture input cannot provide those values.
Trust and execution¶
| ID | Decision | Prose | Schema | Fixture | Focused Django evidence |
|---|---|---|---|---|---|
| SEM-01 | A plan is read-only, names one resource, uses list or aggregate, and combines filters with implicit AND. |
Usage: supported alpha scope | query-plan and capabilities |
positive.list-scoped; positive.aggregate-grouped; structural-negative.non-integer-limit supports strict plan shape |
tests/planning/test_validation.py: test_intent_specific_shape_is_validated; tests/planning/test_schemas.py: test_mutation_intent_fails_schema_validation |
| SEM-02 | execute_plan(plan, *, request, registry=default_registry) is the trusted public execution facade; every plan input is revalidated. |
Core Python API: validate and execute | query-plan describes input shape only |
Corpus replay routes every case through the facade; no case treats validation as authority | tests/execution/test_facade.py: test_execute_plan_revalidates_direct_query_plan_permissions, test_execute_plan_revalidates_current_limits |
| SEM-03 | Execution context is internal, frozen, request-bound, server-owned, and contains current identity, permissions, registry identity, clock, and audit policy. | Core Python API: safety boundaries | —; trusted context is deliberately absent from all documents | No dedicated language-neutral fixture; replay scenarios keep context outside fixture input | tests/execution/test_context_revalidation.py: test_same_plan_uses_each_current_request_scope, test_resource_and_metric_permissions_are_rechecked_before_sql |
| SEM-04 | Prepared state is private, non-serializable, lazy, current-context-bound, and cannot be supplied or reused by callers. | Draft internal contracts: boundaries | —; no prepared-plan document exists | No dedicated language-neutral fixture | tests/execution/test_internal_boundaries.py: test_prepared_state_is_context_bound_lazy_and_not_serializable |
| SEM-05 | Rejection performs no registered application-data query; database audit may add one metadata insert, while disabled/non-database audit adds no SQL. | Core Python API: safety boundaries | error shapes the safe failure only |
budget.filter-count, member-scope-security.missing-scope, member-scope-security.unauthorized-resource, and member-scope-security.unknown-field each require zero application-data queries |
tests/execution/test_audit_boundary.py: rejection query-count tests and audit-failure ordering; tests/planning/test_budgets.py: pre-SQL budget rejection |
Registration, fields, and metrics¶
| ID | Decision | Prose | Schema | Fixture | Focused Django evidence |
|---|---|---|---|---|---|
| SEM-06 | Public field keys are stable semantic names separated from private Django bindings. | Registration: field metadata | catalog, query-plan, and result expose semantic keys but not bindings |
positive.list-scoped |
tests/catalog/test_registry.py: test_semantic_field_keys_are_separate_from_private_django_bindings; tests/compiler/test_orm.py: test_changing_private_binding_does_not_change_public_plan |
| SEM-07 | Dotted semantic keys are allowed and are never translated implicitly into ORM paths. | Registration: field metadata | catalog, query-plan, and result permit nonempty semantic strings; shape cannot prove binding independence |
No dedicated language-neutral fixture | tests/compiler/test_orm.py: test_semantic_keys_bind_privately_across_query_positions |
| SEM-08 | Plans request a registered metric by semantic name only; operation, source, distinctness, result type, cardinality, and permission policy remain trusted registration. | Registration: metrics | query-plan MetricSpec, catalog CatalogMetricDocument, and capabilities aggregate policies |
positive.aggregate-grouped |
tests/planning/test_schemas.py: test_metric_requests_contain_only_the_registered_semantic_name; tests/execution/test_facade.py: test_execute_plan_rejects_client_metric_redefinition_before_sql |
| SEM-09 | Every resource has effective global or context_scoped scope; only context_scoped may be a project default, and every global resource is explicit. |
Registration: fail-closed resource scope | Public catalog exposes only safe scope guidance, not the private policy |
member-scope-security.cross-scope-isolation; member-scope-security.unauthorized-resource |
tests/catalog/test_scope_policy.py: registration/default/migration tests |
| SEM-10 | A context scope provider returns a lazy QuerySet for the registered model; none() is valid, while missing context, wrong model, None, eager evaluation, or failure rejects before application-data SQL. |
Multi-tenant security: scope provider | —; QuerySets and scope providers are forbidden from serialized documents | member-scope-security.missing-scope; member-scope-security.cross-scope-isolation supports isolation |
tests/catalog/test_scope_policy.py: provider result, laziness, failure, and none() tests |
| SEM-11 | Canonical field/result types are string, boolean, integer, decimal, float, date, datetime, time, UUID, and explicit enum. | Registration: canonical operators and values | catalog field/metric types, capabilities types, and result column types |
serialization.canonical-values |
tests/catalog/test_registry.py: field-type tests; tests/results/test_serialization.py: canonical serialization tests |
| SEM-12 | Operator availability follows the exact type matrix: containment only for strings; ordering only for numeric/temporal types; range/relative operators only for date/datetime; typed equality, in, and isnull as documented. |
Registration: canonical operators and values | capabilities declares operators by type; query-plan constrains operator/value shape |
structural-negative.contains-boolean, structural-negative.contains-empty-string, structural-negative.contains-integer, structural-negative.icontains-boolean, structural-negative.icontains-empty-string, and structural-negative.icontains-integer cover containment value shape; the exact field-type matrix remains Django evidence |
tests/planning/test_validation.py: test_canonical_operator_matrix_is_enforced; tests/contracts/test_schemas.py: structural-value constraints |
| SEM-13 | Every filter has a non-null value; eq null and neq null are rejected, and isnull requires a boolean. |
Registration: canonical operators and values | query-plan FilterSpec |
No dedicated language-neutral fixture | tests/planning/test_schemas.py: test_filter_operator_values_are_strictly_validated |
| SEM-14 | neq excludes null rows rather than inheriting backend three-valued behavior accidentally. |
Registration: canonical operators and values | —; this is execution semantics | No dedicated language-neutral fixture | tests/compiler/test_orm.py: test_neq_explicitly_excludes_null_rows |
Values and temporal semantics¶
| ID | Decision | Prose | Schema | Fixture | Focused Django evidence |
|---|---|---|---|---|---|
| SEM-15 | Nulls sort last for ascending and descending ordering. | Registration: deterministic ordering | —; direction shape cannot express null placement | No dedicated language-neutral fixture | tests/execution/test_ordering_truncation.py: test_nulls_sort_last_for_ascending_and_descending_order |
| SEM-16 | Dates are strict YYYY-MM-DD; times are offset-free local ISO values; datetimes are offset-bearing RFC 3339 instants with at most microsecond precision. |
Registration: canonical operators and values | query-plan permits strings; exact formats are semantic validation |
serialization.canonical-values supports output; semantic.relative-days supports temporal execution |
tests/compiler/test_dates.py: strict date/datetime/time tests; tests/planning/test_validation.py: temporal normalization tests |
| SEM-17 | Date ranges include both calendar-date boundaries. | Registration: canonical operators and values | query-plan requires a two-string date_range value; inclusivity is behavioral |
No dedicated language-neutral fixture | tests/compiler/test_temporal_execution.py: test_date_range_is_inclusive_of_both_calendar_dates |
| SEM-18 | Datetime ranges are half-open [start, end). |
Registration: canonical operators and values | query-plan requires a two-string date_range value; boundary semantics are behavioral |
No dedicated language-neutral fixture | tests/compiler/test_temporal_execution.py: test_datetime_range_is_half_open |
| SEM-19 | Every resource has an explicit server-owned IANA timezone; plans cannot choose it and Django TIME_ZONE is not a fallback. |
Registration: register arguments | catalog requires resource timezone; query-plan has no timezone property |
semantic.relative-days supports trusted-timezone execution |
tests/catalog/test_registry.py: timezone-required/IANA/server-owned tests; tests/execution/test_facade.py: test_execute_plan_rejects_client_controlled_timezone_before_sql |
| SEM-20 | Relative filters use an injected aware request clock, an exclusive trusted upper bound at now, and resource-local DateField projection. |
Registration: canonical operators and values | query-plan shapes relative operator values; clock and boundaries are not serialized |
semantic.relative-days |
tests/compiler/test_temporal_execution.py: relative instant/date projection tests |
| SEM-21 | last_n_days(N) is the rolling half-open instant interval [now - N*24 hours, now), including its start and excluding now/future rows. |
Registration: canonical operators and values | query-plan requires a positive integer |
semantic.relative-days |
tests/compiler/test_dates.py: test_last_n_days_is_exact_rolling_duration_across_dst; tests/compiler/test_temporal_execution.py: exact execution boundaries |
| SEM-22 | last_n_months(N) subtracts local calendar months at the same wall-clock time, clamps month-end, advances DST gaps, chooses the earlier fold, and ends exclusively at now. |
Registration: canonical operators and values | query-plan requires a positive integer |
No dedicated language-neutral fixture | tests/compiler/test_dates.py: month-end/gap/fold tests; tests/compiler/test_temporal_execution.py: test_last_n_months_executes_at_dst_gap_and_fold_boundaries |
| SEM-23 | Week grouping begins Monday in the resource timezone. | Registration: canonical operators and values | query-plan/capabilities include the week grain; start-day semantics are behavioral |
No dedicated language-neutral fixture | tests/compiler/test_temporal_execution.py: test_week_grouping_begins_monday |
| SEM-24 | Decimal inputs/results are finite strings and never pass through binary-float coercion. | Registration: canonical operators and values | catalog/capabilities/result declare decimal type; exact string semantics are runtime validation |
semantic.invalid-decimal; serialization.canonical-values; positive.list-scoped |
tests/compiler/test_orm.py: test_decimal_filter_and_result_preserve_string_precision; tests/results/test_serialization.py: non-finite rejection |
| SEM-25 | Aggregate decimal metrics use minimal plain strings, trim insignificant fractional zeros, normalize zero to "0", and never use exponents; scalar decimal fields preserve scale. |
Core Python API: deterministic results | result permits decimal cells as strings; canonical scale is behavioral |
positive.aggregate-grouped proves "20"; positive.list-scoped and serialization.canonical-values prove scalar scale |
tests/results/test_serialization.py: aggregate canonicalization and scalar-scale tests |
Aggregates and cardinality¶
| ID | Decision | Prose | Schema | Fixture | Focused Django evidence |
|---|---|---|---|---|---|
| SEM-26 | Empty ungrouped count returns one row containing 0. |
Usage: supported alpha scope | result shapes the row/cell |
semantic.empty-aggregate |
tests/compiler/test_orm.py: test_empty_ungrouped_aggregate_returns_one_canonical_row |
| SEM-27 | Other empty ungrouped aggregates return one row containing null. |
Usage: supported alpha scope | result permits null cells |
semantic.empty-aggregate |
tests/compiler/test_orm.py: test_empty_ungrouped_aggregate_returns_one_canonical_row |
| SEM-28 | Empty grouped aggregates return zero rows. | Usage: supported alpha scope | result permits an empty data array |
No dedicated language-neutral fixture | tests/compiler/test_orm.py: test_empty_grouped_aggregate_returns_no_rows |
| SEM-29 | Enums have explicit string/integer canonical values plus optional safe labels/aliases; aliases normalize to canonical values and ambiguous aliases fail registration. | Registration: explicit enums | catalog enum metadata and result enum column/cell shape |
positive.aggregate-grouped; serialization.canonical-values |
tests/catalog/test_registry.py: enum registration/ambiguity/type tests; tests/planning/test_validation.py: enum normalization tests |
| SEM-30 | Django choices are never exposed automatically; any conversion is an explicit opt-in host helper. |
Registration: explicit enums | —; private model introspection is outside serialized shape | No dedicated language-neutral fixture | tests/planning/test_validation.py: test_django_choices_are_not_automatic_enum_aliases |
| SEM-31 | Distinct count is a separately registered metric with a private same-grain non-null unique key. | Registration: metrics | capabilities advertises count_distinct; plan/catalog omit its private key |
No dedicated language-neutral fixture | tests/catalog/test_registry.py: metric cardinality validation; tests/compiler/test_orm.py: test_registered_to_many_count_policies_compile_from_private_keys |
| SEM-32 | Metrics crossing to-many relationships are rejected by default. | Registration: metrics | capabilities declares aggregate policies; private paths stay absent |
No dedicated language-neutral fixture | tests/catalog/test_registry.py: test_metric_registration_enforces_private_cardinality_policy; tests/execution/test_facade.py: fanout rejection before SQL |
| SEM-33 | Initial exceptions are to-one-only, one declared count_rows grain, or private-key count_distinct; independent fanouts and numeric to-many aggregates remain unsupported. |
Registration: metrics | capabilities advertises count policies and numeric_to_many: false |
No dedicated language-neutral fixture | tests/catalog/test_registry.py: test_metric_registration_rejects_unsafe_to_many_policies; tests/planning/test_validation.py: independent-path and plan-level fanout tests |
Ordering, results, and presentation¶
| ID | Decision | Prose | Schema | Fixture | Focused Django evidence |
|---|---|---|---|---|---|
| SEM-34 | List ordering uses semantic default_order and appends missing private row-identity terms; Django Meta.ordering is not a fallback. |
Registration: deterministic ordering | catalog exposes semantic default_order; private identity is absent |
ordering-truncation.list-default |
tests/execution/test_ordering_truncation.py: repeatability/default/explicit tie tests |
| SEM-35 | Alternate row identity requires a non-null unconditional unique constraint; there is no assume_unique escape hatch. |
Registration: deterministic ordering | —; row identity is private registration | ordering-truncation.list-default is supporting only |
tests/execution/test_ordering_truncation.py: test_alternate_row_identity_requires_non_null_unique_field |
| SEM-36 | Grouped ordering appends missing group keys as deterministic tie-breakers. | Core Python API: deterministic results | query-plan shapes grouping/ordering but not injected tie-breakers |
ordering-truncation.group-default |
tests/execution/test_ordering_truncation.py: grouped tie/truncation tests |
| SEM-37 | List/grouped queries fetch limit + 1, return at most limit, and report accurate truncation; ungrouped aggregates have effective limit one and never truncate. |
Core Python API: deterministic results | result ResultMetadataDocument; query-plan positive limit |
ordering-truncation.list-default; ordering-truncation.group-default; serialization.canonical-values supports list truncation |
tests/execution/test_ordering_truncation.py: below/at/above and ungrouped tests |
| SEM-38 | Result metadata is exactly limit, limit_scope, and truncated; obsolete limit_reached is absent. |
Core Python API: deterministic results | result ResultMetadataDocument is closed |
All result fixtures, including positive.aggregate-grouped |
tests/contracts/test_schemas.py: closed-schema/runtime-document tests; tests/execution/test_ordering_truncation.py |
| SEM-39 | Result columns carry stable key, label, canonical type, and nullability; rows match declared columns and unsupported, non-finite, unknown-enum, or mismatched values fail safely. | Core Python API: deterministic results | result column and dynamic JSON-cell shapes |
serialization.canonical-values; positive.list-scoped; positive.aggregate-grouped |
tests/results/test_serialization.py: value, column, enum, nullability, and safe-error tests |
| SEM-40 | Visualization is excluded from QueryPlan and rejected as an unknown plan member. | Core Python API: execution boundary | Closed query-plan has no visualization property |
structural-negative.extra-member supports closed top-level shape but is not visualization-specific |
tests/planning/test_schemas.py: test_unknown_plan_members_are_rejected; tests/execution/test_facade.py: pre-SQL rejection |
| SEM-41 | Presentation is an optional separate envelope and cannot affect authorization, compilation, ordering, limits, or values. | Core Python API: execution boundary | —; presentation is deliberately outside the five exact internal documents | No dedicated language-neutral fixture | tests/results/test_presentation.py: normalization, fail-closed references, and result separation |
Errors, document identity, and audit¶
| ID | Decision | Prose | Schema | Fixture | Focused Django evidence |
|---|---|---|---|---|---|
| SEM-42 | Public execution failures use stable namespaced codes with only a safe message and optional bounded JSON Pointer. | Core Python API: stable execution errors | error is closed and enumerates current codes |
Error fixtures across budget.filter-count, member-scope-security.missing-scope, and all structural-negative cases |
tests/execution/test_public_errors.py: code, opacity, and pointer tests |
| SEM-43 | Unknown and unauthorized resources, fields, and metrics are externally indistinguishable as asklens.member.unavailable. |
Usage: opaque denials | error permits the shared code; catalog is permission-scoped |
member-scope-security.unauthorized-resource; member-scope-security.unknown-field |
tests/execution/test_public_errors.py: test_unknown_and_unauthorized_members_have_identical_public_errors |
| SEM-44 | Catalog, capabilities, query plan, result, and error each have one strict current shape with no embedded version/revision or multi-version negotiation. | Draft internal contracts: status and precedence | All five closed schemas omit version/revision fields | structural-negative.extra-member supports strict replacement |
tests/contracts/test_schemas.py: test_schema_accessors_return_exact_internal_draft_set |
| SEM-45 | There is no public catalog revision or schema version; the internal request-bound registry identity is not serialized and is not an authorization token. | Draft internal contracts: boundaries | —; no public revision property exists | No dedicated language-neutral fixture | tests/contracts/test_schemas.py: private-property omission; tests/execution/test_context_revalidation.py: current catalog revalidation |
| SEM-46 | Default audit stores operational metadata only; questions, filter values, full plans, provider payloads, and rejected raw input require explicit host opt-in and lifecycle policy. | Security checklist: audit safety | —; audit records are not one of the five internal documents | No dedicated language-neutral fixture; audit policy is intentionally server-owned | tests/execution/test_audit_boundary.py: metadata-only default and explicit opt-in tests |
Coverage boundaries¶
The 21 explicit language-neutral cases are representative, not exhaustive.
Notably, DST gap/fold handling, month subtraction, neq null behavior, null
ordering, alternate identity validation, to-many cardinality policy, grouped
empty results, presentation, and audit content currently have focused Django
evidence but no dedicated language-neutral fixture. That classification does not
silently authorize new fixtures or expectation changes.
The schemas establish document shape and closure. They cannot by themselves prove authorization, current request scope, temporal boundaries, database ordering, relationship cardinality, row/column agreement, decimal canonicalization, audit effects, or zero application-data SQL. Those properties require fixture replay and/or implementation tests through the trusted facade.
The corpus is replayed on SQLite and the representative PostgreSQL CI stacks described in Draft internal conformance corpus. Passing those runs does not freeze this index, certify production deployment, establish a public protocol, or replace application-specific permission and scope tests.