Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v7
with: &specification-checkout
repository: OpenStatSpec/specification
ref: 864e84479f554b8ee250ffed44c4dfb963750d4a
ref: d76121ec343cf9614fb8ad2f8cc50f72ee29966e
path: openstatspec-specification
- name: Checkout required SPSS engine
uses: actions/checkout@v7
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: OpenStatSpec/specification
ref: 864e84479f554b8ee250ffed44c4dfb963750d4a
ref: d76121ec343cf9614fb8ad2f8cc50f72ee29966e
path: openstatspec-specification
- name: Checkout specification package source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,59 @@

All notable changes to this reference implementation are documented here.

## 0.10.0 - 2026-12-01

This minor release aligns the adapter with Conformance Supplement 0.6 of
specification `v0.6.0`. Several diagnostics change for existing callers, and
imports that contain negative zero are now refused instead of silently
storing positive zero.

### Changed

- `compile_spss_request` and the `frontend_contract` selector report
`request_schema_invalid` instead of `invalid_spss_request`. Duplicate
variable names (case-insensitive) and a numeric value label on a string
variable report the same code.
- A string compared with a number reports `expression_type_unsupported`
instead of `type_mismatch`, in both frontends and for raw plans in binding.
- Arithmetic in a `COMPUTE` value or inside an `IF` predicate, including `*`
and `**`, reports `expression_type_unsupported`. `*` is now a token, so
`SELECT * FROM q1.` reports `unsupported_spss_command`.
- A `replace` recode whose target is not its source reports
`target_already_exists` instead of `invalid_transformation_plan`.
- `RECODE q1 (ELSE = 0).` and text after the last terminated command without
a period report `spss_syntax_error`.
- `AND OR NOT TO EQ NE LT LE GT GE BY ALL WITH` are never variable names or
targets (`spss_syntax_error`). `NaN` and `Infinity` may now name variables
and are refused only in operand position.
- Official Frontend 0.3 `*` and `COMMENT` comments end at a period followed
by whitespace or the end of the input, so `* ratio 1.5 is kept.` is one
comment.
- The default frontend (Frontend 0.2) refuses slash-separated `FORMATS`
groups with `spss_syntax_error`. Keywords match ASCII case-insensitively
only, on both frontends.
- Variable names match by the unconditional per-code-point lowercase mapping
instead of Unicode case folding, in the frontends, plan binding and
in-place apply. `STRASSE` no longer matches `straße`; `ÄRA` still matches
`ära`.
- SAV/ZSAV import refuses negative zero before mutation with
`target_capability_exceeded` (reason `negative_zero_numeric_value`) on every
SQL profile. Capabilities declare `negative_zero: reject_before_mutation`;
the NaN reader policy is unchanged.

### Added

- `tests/test_conformance_supplement.py` runs the seven supplement manifests
of the pinned specification checkout: Frontend 0.1, 0.2 and 0.3, Plan 0.1
and 0.2, In-Place 0.1 on SQLite, and SAV/ZSAV 1.0 on SQLite with the
runner-generated negative-zero and NaN fixtures.

The specification is pinned to released `v0.6.0` at exact commit
`d76121ec343cf9614fb8ad2f8cc50f72ee29966e`; the required SPSS codec remains
`openstatspec-pyspssio==0.5.1.post2`. Python claims no Frontend 0.1 contract,
so the supplement case that refuses Frontend 0.2 commands under the 0.1
contract is skipped.

## 0.9.1 - 2026-11-09

This patch release speeds up SAV import and export. Behavior, error codes and
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ The reference Python implementation of the OpenStatSpec specification.

This package implements the specification; it does not define or extend it.
The normative model lives in the `OpenStatSpec/specification` repository.
Python 0.9.1 pins released specification `v0.5.0` at
`864e84479f554b8ee250ffed44c4dfb963750d4a` and selects SAV/ZSAV 1.0 with
Python 0.10.0 pins released specification `v0.6.0` at
`d76121ec343cf9614fb8ad2f8cc50f72ee29966e` and selects SAV/ZSAV 1.0 with
`database_io_policy=openstatspec-database-io-v1`. It implements the explicitly
selected optional official SPSS Frontend 0.3 over unchanged Plan 0.1/0.2, not
the separate optional Transformation Workflow 0.3 profile.
Expand All @@ -25,6 +25,12 @@ Unsupported source features, SQL targets, or export paths fail explicitly.
There is no silent truncation, type conversion, metadata loss, or partial
import.

Numeric source values must be finite binary64 or system missing. A SAV NaN
becomes SQL NULL (system missing) under the declared
`canonicalize_to_sql_null_during_spss_decode` reader policy. Infinities and
negative zero are refused before mutation on every SQL profile, because not
every profile keeps the sign of zero.

## Package layout

- `openstatspec.core`: pure standard concepts, validation, versions,
Expand Down
11 changes: 6 additions & 5 deletions docs/release-readiness.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ The canonical transformation core and SPSS syntax frontend are separate public
surfaces. A release must run the specification-owned canonical-plan and SPSS
frontend conformance fixtures, including `tests/test_frontend_v03.py` with all
90 effective official Frontend 0.3 cases (35 declared plus inherited cases with
published overrides/supersessions) from exact specification commit
`864e84479f554b8ee250ffed44c4dfb963750d4a`. Then exercise the generic plan apply
published overrides/supersessions) and `tests/test_conformance_supplement.py`
with the seven Conformance Supplement 0.6 manifests from exact specification
commit `d76121ec343cf9614fb8ad2f8cc50f72ee29966e`. Then exercise the generic plan apply
API, SPSS compatibility apply path, and explicitly selected official 0.3 apply.
Python schema-extension and legacy acceptance tests are separate compatibility
evidence, not official Plan 0.3 conformance; no official Plan 0.3 exists.
Expand Down Expand Up @@ -260,9 +261,9 @@ publication evidence. No push, PR, tag or publication was performed.
without a database connection.
5. Confirm `openstatspec capabilities` reflects the intended support boundary.
6. Confirm CI, release fixtures, and capabilities use the published OpenStatSpec
specification `v0.5.0` at exact commit
`864e84479f554b8ee250ffed44c4dfb963750d4a`, publish
`specification_status=released`, and set `specification_release` to `v0.5.0`.
specification `v0.6.0` at exact commit
`d76121ec343cf9614fb8ad2f8cc50f72ee29966e`, publish
`specification_status=released`, and set `specification_release` to `v0.6.0`.
Use an exact checkout via `OPENSTATSPEC_SPECIFICATION_DIR` for local tests.
7. Review this document, the README, and CHANGELOG for accurate scope. Finalize
the 0.9.0 changelog date as 2026-09-10 before selecting the final release commit.
Expand Down
19 changes: 17 additions & 2 deletions docs/transformations.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ boundary. It accepts **only** `openstatspec-spss-syntax-frontend-v0.3`, with
exact required fields `contract`, `input_alias`, `input_schema`, and
`source_text`. Unknown fields, missing fields, wrong types, noncanonical or
nonfinite typed codes, ambiguous variable names, and mismatched label types
fail closed. Request-shape failures report `invalid_spss_request`; source
fail closed. Request-shape failures report `request_schema_invalid`; source
failures retain the normative diagnostics. It returns no partial compilation.

```python
Expand Down Expand Up @@ -104,6 +104,19 @@ Comments remain in the LF-normalized source hash but emit no operation;
comment-only input is invalid. Python `STRING` and `DELETE VARIABLES` are
rejected under the official selector.

Conformance Supplement 0.6 rules apply to the official request and to the
default frontend: a `*` or `COMMENT` comment ends at a period followed by
whitespace or the end of the input; every command, including the last, needs
its terminating period; `AND OR NOT TO EQ NE LT LE GT GE BY ALL WITH` are
never variable names or targets; `NaN` and `Infinity` may name variables but
are refused as operands; `ELSE`-only `RECODE` is a syntax error; arithmetic
(including `*`) in a `COMPUTE` value or an `IF` predicate and any string to
number comparison report `expression_type_unsupported`. The default frontend
refuses slash-separated `FORMATS` groups, as Frontend 0.2 requires. Variable
names match by the unconditional per-code-point lowercase mapping, not case
folding, so `STRASSE` does not match `straße`. A plan `replace` recode whose
target is not its source reports `target_already_exists`.

**Explicit implementation decision:** precedence is standard SPSS order,
comparisons → `NOT` → `AND` → `OR` (tightest first). Thus `NOT a = 1 AND
b = 1` means `(NOT (a = 1)) AND b = 1`, not negation of the conjunction.
Expand All @@ -127,9 +140,11 @@ the existing CLI remains on that compatibility path.

Evidence: `tests/test_frontend_v03.py` runs the 35 declared and all 90 effective
cases from specification commit
`864e84479f554b8ee250ffed44c4dfb963750d4a`, applying only the published inherited
`d76121ec343cf9614fb8ad2f8cc50f72ee29966e` (`v0.6.0`), applying only the published inherited
contract overrides and two comment supersessions. It checks exact Plan 0.1/0.2
objects/hashes, source hashes, diagnostics, and declared output metadata.
`tests/test_conformance_supplement.py` runs the Conformance Supplement 0.6
manifests of the same checkout.
Local SQLite integration checks UNKNOWN, sequential data and metadata,
identity, audit provenance, and absence of copy/history artifacts. Existing
frontend, plan, and in-place suites remain in the gate. This is not new service
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "openstatspec"
version = "0.9.1"
version = "0.10.0"
description = "Reference adapter for the OpenStatSpec relational contract"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
24 changes: 9 additions & 15 deletions src/openstatspec/frontends/spss/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
TransformationPlan, TypedValue, ValueLabel,
)
from ...transform.schema import (
BoundTransformation, StorageKind, VariableDefinition, VariableSchema,
BoundTransformation, StorageKind, VariableDefinition, VariableSchema, name_key,
)
from ...transform.validation import bind_transformation_plan
from .syntax import (
Expand Down Expand Up @@ -48,7 +48,7 @@ def _resolve(
) -> tuple[int, VariableDefinition]:
matches = [
(index, variable) for index, variable in enumerate(variables)
if variable.name.casefold() == name.casefold()
if name_key(variable.name) == name_key(name)
]
if len(matches) != 1:
raise frontend_error(
Expand Down Expand Up @@ -86,18 +86,12 @@ def _bind_predicate(
return _bind_predicate(expanded, variables, negated=negated and syntax.operator == "ne")
left, left_type = _bind_operand(syntax.left, variables)
right, right_type = _bind_operand(syntax.right, variables)
if left_type != right_type:
if "string" in (left_type, right_type):
raise frontend_error(
"type_mismatch",
"Comparison operands must have the same storage kind.",
"expression_type_unsupported",
"String comparisons are outside the bounded frontend.",
span=syntax.span, left_type=left_type, right_type=right_type,
)
if syntax.operator != "=" and left_type != "binary64":
raise frontend_error(
"type_mismatch",
"Ordered comparisons require numeric operands.",
span=syntax.span, operator=syntax.operator,
)
operator = ({"=": "=", "<": ">=", "<=": ">", ">": "<=", ">=": "<"}[syntax.operator] if negated else syntax.operator)
return ComparisonExpression(left, operator, right)
assert isinstance(syntax, BooleanSyntax)
Expand Down Expand Up @@ -129,7 +123,7 @@ def _assignment(
)
matches = [
(index, variable) for index, variable in enumerate(variables)
if variable.name.casefold() == target_name.casefold()
if name_key(variable.name) == name_key(target_name)
]
if matches:
_, target = matches[0]
Expand Down Expand Up @@ -286,7 +280,7 @@ def _bind_recode(
span=target_span, target=target_name,
)
if any(
variable.name.casefold() == target_name.casefold()
name_key(variable.name) == name_key(target_name)
for variable in variables
):
raise frontend_error(
Expand Down Expand Up @@ -404,7 +398,7 @@ def bind_spss_syntax(
target=variable_token.text,
)
if any(
variable.name.casefold() == variable_token.text.casefold()
name_key(variable.name) == name_key(variable_token.text)
for variable in variables
):
raise frontend_error(
Expand Down Expand Up @@ -446,7 +440,7 @@ def bind_spss_syntax(
condition = _bind_predicate(command.condition, variables)
target_matches = [
(index, variable) for index, variable in enumerate(variables)
if variable.name.casefold() == command.target.text.casefold()
if name_key(variable.name) == name_key(command.target.text)
]
if len(target_matches) != 1:
raise frontend_error(
Expand Down
6 changes: 3 additions & 3 deletions src/openstatspec/frontends/spss/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def compile_spss_syntax(
) -> SpssFrontendCompilation:
"""Parse and bind source without SQL generation or database mutation."""
if frontend_contract not in (None, SPSS_FRONTEND_V03_CONTRACT):
raise frontend_error("invalid_spss_request", "Select the exact official Frontend 0.3 contract or omit the selector for legacy behavior.")
raise frontend_error("request_schema_invalid", "Select the exact official Frontend 0.3 contract or omit the selector for legacy behavior.")
normalized = normalize_spss_source(source)
program = parse_spss_syntax(normalized, official_v03=frontend_contract is not None)
try:
Expand All @@ -81,7 +81,7 @@ def compile_spss_syntax(
def compile_spss_request(request: Mapping[str, Any]) -> SpssFrontendCompilation:
"""Validate the exact official Frontend 0.3 request, then use the shared frontend."""
def invalid():
raise frontend_error("invalid_spss_request", "Request must conform to the official Frontend 0.3 schema.")
raise frontend_error("request_schema_invalid", "Request must conform to the official Frontend 0.3 schema.")

if not isinstance(request, Mapping) or set(request) != {"contract", "input_alias", "input_schema", "source_text"}:
invalid()
Expand Down Expand Up @@ -133,5 +133,5 @@ def invalid():
))
schema = VariableSchema(tuple(variables))
except (ValueError, TypeError, OverflowError) as error:
raise frontend_error("invalid_spss_request", "Invalid Frontend 0.3 input schema.") from error
raise frontend_error("request_schema_invalid", "Invalid Frontend 0.3 input schema.") from error
return compile_spss_syntax(request["source_text"], schema, input_alias=request["input_alias"], frontend_contract=SPSS_FRONTEND_V03_CONTRACT)
Loading