diff --git a/CHANGELOG.md b/CHANGELOG.md index f898898..ca5f8c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,51 @@ ## Unreleased +Future changes will be listed here. + +## v0.6.0 - 2026-12-01 + +OpenStatSpec `v0.6.0` is a minor release. It publishes a normative +conformance supplement with new supplement manifests and relaxes the Dolt +negative-zero boundary rule. Every published conformance manifest, request +and plan schema and `sql/schema-outline.sql` stays byte-identical, and no +profile contract or contract identifier changes (the profile documents only +gain a pointer to the supplement), so claims pinned to earlier releases stay +valid; the supplement binds claims that pin +`v0.6.0` or later. The rulings settle the implementation differences +collected in issue #27. + +- Added the normative [Conformance Supplement 0.6](docs/conformance-supplement-0.6.md) + for Frontend 0.1 to 0.3, Plan 0.1 and 0.2, the in-place bindings, the + SAV/ZSAV 1.0 catalog and the SQL dialect profiles. It fixes + `request_schema_invalid` for invalid requests, comment and command + termination, name characters, reserved words and case-insensitive + matching, the Frontend 0.1 boundary, slash-separated `RECODE` and + `FORMATS` groups, `F8` as `F8.0`, the codes for unary minus, function + calls, arithmetic and string-number comparisons, replace plans whose + target is not their source, and `SYSMIS`-only `RECODE ... INTO` targets. + The `RECODE` diagnostics and the `LOWEST`/`HIGHEST` NULL endpoints noted in + `v0.5.1` become normative. +- SAV/ZSAV 1.0 catalog: `dataset.spec_version` is `"1.0"` and + `catalog_identity.schema_version` is `1`; the measurement level, role, + alignment, category-label and label-source vocabularies are text values; + attributes export in name order and compare by name; NaN becomes NULL only + under a declared reader policy and negative zero is never changed silently; + `physical_table_schema` is NULL for the catalog namespace and on SQLite. +- Added seven self-contained supplement manifests beside their published + manifests: Frontend 0.1 (16 cases), 0.2 (14) and 0.3 (14), Plan 0.1 (2) and + 0.2 (2), In-Place 0.1 (1) and SAV/ZSAV 1.0 (9 fixtures, two generated by the + runner). The published manifests are unchanged. +- Dolt, MySQL and MariaDB may refuse negative zero before mutation as a + declared policy; the Dolt declaration validator accepts + `reject_before_mutation` for the `negative_zero` boundary case. +- Repository validation pins the SHA-256 of every published manifest and + schema and of `sql/schema-outline.sql`, and validates the supplements, + including their hashes and ruling coverage. +- The `openstatspec-specification` companion package goes to `0.2.0`: its + artifact validator adds `validate_published_artifacts` and reports + supplement case counts, and the Dolt validator accepts the negative-zero + refusal. It is released separately under a `package-v0.2.0` tag. - Added an informative [Statscraft independent implementation record](docs/implementation-profiles/statscraft.md) with its declared profiles, refusals and CI evidence at an exact development commit and the `v0.5.1` pin. It changes no normative profile or conformance diff --git a/README.md b/README.md index e771e54..d7e08a3 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ The first profile targets IBM SPSS Statistics system files. It maps one source d The [SPSS SAV/ZSAV profile](docs/spss-sav-zsav-profile-1.0.md) defines normative conformance language, a canonical relational schema, generated fixtures, and reference-adapter coverage. The SQL layer includes independent SQLite, PostgreSQL, MySQL/MariaDB/InnoDB, and Dolt profiles. Implementations must pin the exact specification commit they test against. Release identifiers and immutable provenance belong in tagged releases and capability declarations rather than in this README. +The normative [Conformance Supplement 0.6](docs/conformance-supplement-0.6.md) +settles the implementation differences found by comparing independent +implementations. It is binding for claims that pin `v0.6.0` or later and adds +self-contained supplement manifests beside the published ones, which stay +unchanged; claims pinned to earlier releases stay valid. + The [server-version policy](sql/server-version-policy.md) covers the maintained MySQL 8.4.x/9.7.x, MariaDB 11.4.x/11.8.x/12.3.x and PostgreSQL 17.x/18.x series while requiring exact patch-version CI evidence. Microsoft SQL Server @@ -73,6 +79,8 @@ released Plan 0.1/0.2 contracts and does not change SQL binding behavior. - `sql/server-version-policy.md` — server release-series claims and exact reference-CI targets. - `docs/mssql-dialect-roadmap.md` — unsupported future SQL Server dialect plan. +- `docs/conformance-supplement-0.6.md` and `conformance/*-supplement-1.json`: + normative rulings and supplement cases for claims that pin `v0.6.0` or later. - `docs/architecture.md` — model boundary and catalog outline. - `docs/spss-profile.md` — SPSS source-faithful mapping rules. - [Python / pinned pyspssio implementation profile](docs/implementation-profiles/python-pyspssio-0.5.1.md) — Python adapter pyspssio capability boundary; it does not relax the normative SAV/ZSAV profile. diff --git a/ROADMAP.md b/ROADMAP.md index 24659c8..788eed5 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -2,8 +2,15 @@ This is a working to-do list for OpenStatSpec. Items below describe intended work, not promises of a release date or expanded scope. -## Current status (2026-11-21) - +## Current status (2026-12-01) + +- Specification `v0.6.0` is a minor release over `v0.5.1`: the normative + [Conformance Supplement 0.6](docs/conformance-supplement-0.6.md) and its + supplement manifests settle the implementation differences of issue #27, + and Dolt may refuse negative zero as a declared policy. Published + manifests and schemas are unchanged, so earlier pins remain valid. Python + `0.10.0`, PHP `0.9.0` and the next Statscraft minor release are planned to + pin `v0.6.0`; the companion package goes to `0.2.0`. - Specification `v0.5.1` is a documentation patch over `v0.5.0`: informative notes where the published implementations agree, and release bookkeeping. No contract or artifact changed, so `v0.5.0` pins remain valid. Open @@ -71,7 +78,7 @@ Prerequisite: the core mapping and canonical fixtures are stable enough to test and fixtures. - [x] Define adapter conformance guidance; each adapter repository owns its runtime CI and evidence. - [x] Define versioning and compatibility guidance for the specification and profiles. -- [x] Publish release notes and tagged specification releases; `v0.5.1` is the +- [x] Publish release notes and tagged specification releases; `v0.6.0` is the current public specification release and is immutable. - [ ] Expand implementation, dialect-profile, and adoption documentation from real adapter experience. The [Statscraft record](docs/implementation-profiles/statscraft.md) documents @@ -179,6 +186,10 @@ follows and does not block specification publication. 11. [x] Published documentation patch release `v0.5.1` with informative clarifications found by an independent implementation; no normative contract or conformance artifact changed. +12. [x] Prepared minor release `v0.6.0`: the normative conformance supplement, + seven supplement manifests and the Dolt negative-zero relaxation, with the + published manifests and schemas pinned unchanged. Adapter adoption follows + the tag and is gated separately. Optional workflow conformance and future frontend generations remain downstream implementation work. Frontend 0.3 has its own completed adapter evidence in the diff --git a/conformance/README.md b/conformance/README.md index ef534c2..d131f25 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -91,6 +91,66 @@ The `preflight-failure` source `fixtures/preflight-too-wide.sav` is not committed: as [`fixtures/README.md`](fixtures/README.md) states, the runner generates it with one more variable than the target profile permits. +## Supplement manifests + +The files named `-supplement-1.json` hold the conformance cases of the +normative [Conformance Supplement 0.6](../docs/conformance-supplement-0.6.md). +They apply to implementation claims that pin `v0.6.0` or later, in addition +to the published manifest `.json`, which stays byte-identical. + +- `spss-syntax-frontend-0.1-supplement-1.json` (16 cases), + `spss-syntax-frontend-0.2-supplement-1.json` (14) and + `spss-syntax-frontend-0.3-supplement-1.json` (14); +- `transformation-plan-0.1-supplement-1.json` (2) and + `transformation-plan-0.2-supplement-1.json` (2); +- `in-place-transformation-0.1-supplement-1.json` (1); and +- `spss-sav-zsav-1.0-supplement-1.json` (9 fixtures). + +A supplement manifest uses the top-level keys and the case shape of its base +manifest, so a runner of the base manifest can run it. It adds: + +- `supplement_to`, the file name of the base manifest, and + `supplement_document`, the path of the supplement document; +- `rulings` on every case or fixture: the rulings it covers, keyed as in the + traceability table of the supplement document. A runner may ignore it. + +A supplement manifest is self-contained. It has no `inherited_manifests`, and +a successful frontend case gives its plan inline as `expected_plan` (or as +`expected_plan_0_1` in the 0.2 and 0.3 supplements), never as a reference to a +case of another manifest. + +Every manifest request is schema-valid, with one exception: a frontend +supplement case that expects `request_schema_invalid` may give a request that +violates the request schema. Such a case may also give a schema-valid request +that declares two names equal case-insensitively, or a numeric value label on +a string variable. + +The In-Place 0.1 supplement case states the created target in `after`: +`created_target`, `created_target_storage_kind`, +`created_target_all_system_missing` and `audit_physical_table_schema`, the +value the compact audit copies from the `dataset` row. + +The SAV/ZSAV supplement keeps the fixture shape of `spss-sav-zsav-1.0.json`. +Its new `expects` values and `expected_catalog` keys are: + +- `dataset_spec_version` with `expected_catalog.dataset.spec_version`, and + `catalog_schema_version` with `expected_catalog.catalog_identity`; +- `physical_table_schema_rule`: `dataset.physical_table_schema` follows the + supplement rule for the SQL profile under test; +- `measurement_level_vocabulary`, `variable_role_vocabulary` and + `display_alignment_vocabulary` with `expected_catalog.variables` (only the + columns that the fixture sets explicitly are listed), and + `category_label_behavior_vocabulary` and `label_source_vocabulary` with + `expected_catalog.multiple_response_sets`; +- `attribute_export_order` with `expected_catalog.dataset_attribute_export_order` + and `variable_attribute_export_order`, and `attribute_comparison_by_name`; +- `lowest_highest_null_endpoints` with `expected_catalog.missing_rules`; and +- `negative_zero_preserved_refused_or_reported` and + `nan_preserved_refused_or_declared_null` for the runner-generated fixtures + `fixtures/negative-zero.sav` and `fixtures/nan.sav`, which, like the + preflight fixture, are not committed: [`fixtures/README.md`](fixtures/README.md) + states how the runner generates them. + ## SQL Transformation Workflow manifest `sql-transformation-workflow-0.1.json` gives the `hash_profile`, input diff --git a/conformance/fixtures/README.md b/conformance/fixtures/README.md index 1608728..b5a2df6 100644 --- a/conformance/fixtures/README.md +++ b/conformance/fixtures/README.md @@ -21,3 +21,16 @@ SAV file. The preflight fixture is profile-specific: the conformance runner must generate it with one more variable than the target profile permits. + +The supplement manifest `../spss-sav-zsav-1.0-supplement-1.json` names two more +fixtures that are not committed. The runner generates each with any SAV writer +that keeps the exact binary64 bits, as one numeric variable `value` (format +`F8.2`) and three cases in this order: + +- `negative-zero.sav`: bits `0000000000000000` (positive zero), + `8000000000000000` (negative zero) and `3ff0000000000000` (1). +- `nan.sav`: bits `3ff0000000000000` (1), `7ff8000000000000` (a quiet NaN) + and `4000000000000000` (2). + +The expected outcomes are those of the special numeric value rules in +[`../../docs/conformance-supplement-0.6.md`](../../docs/conformance-supplement-0.6.md). diff --git a/conformance/in-place-transformation-0.1-supplement-1.json b/conformance/in-place-transformation-0.1-supplement-1.json new file mode 100644 index 0000000..21bbd0f --- /dev/null +++ b/conformance/in-place-transformation-0.1-supplement-1.json @@ -0,0 +1,66 @@ +{ + "manifest_version": "0.1", + "profile": "OpenStatSpec In-Place Transformation Binding 0.1 conformance supplement 1", + "contract": "openstatspec-in-place-transformation-v0.1", + "supplement_to": "in-place-transformation-0.1.json", + "supplement_document": "../docs/conformance-supplement-0.6.md", + "cases": [ + { + "id": "sqlite-sysmis-only-recode-creates-numeric-target", + "rulings": [ + "18", + "25" + ], + "database_profile": "sqlite", + "source_text": "RECODE q1 (1 = SYSMIS) INTO r.", + "before": { + "dataset_id": "11111111-1111-4111-8111-111111111111", + "physical_table_schema": null, + "physical_table_name": "data_survey", + "dataset_count": 1, + "persistent_data_table_count": 1 + }, + "after": { + "dataset_id": "11111111-1111-4111-8111-111111111111", + "physical_table_schema": null, + "physical_table_name": "data_survey", + "dataset_count": 1, + "persistent_data_table_count": 1, + "created_target": "r", + "created_target_storage_kind": "numeric", + "created_target_all_system_missing": true, + "audit_physical_table_schema": null + }, + "forbidden_artifacts": [ + "derived_dataset_row", + "persistent_output_table", + "full_table_copy", + "staging_dataset", + "staging_relation", + "snapshot_table", + "rollback_table", + "dataset_version_row", + "retirement_or_recovery_row", + "temporary_object_residue" + ], + "required_audit_fields": [ + "apply_id", + "contract_id", + "database_profile", + "dataset_id", + "physical_table_schema", + "physical_table_name", + "plan_hash", + "source_hash", + "actor", + "status", + "dolt_branch", + "dolt_head_before", + "dolt_head_after", + "operation_count", + "started_at", + "completed_at" + ] + } + ] +} diff --git a/conformance/spss-sav-zsav-1.0-supplement-1.json b/conformance/spss-sav-zsav-1.0-supplement-1.json new file mode 100644 index 0000000..a355370 --- /dev/null +++ b/conformance/spss-sav-zsav-1.0-supplement-1.json @@ -0,0 +1,224 @@ +{ + "manifest_version": "1.0", + "profile": "OpenStatSpec SPSS SAV/ZSAV 1.0 conformance supplement 1", + "supplement_to": "spss-sav-zsav-1.0.json", + "supplement_document": "../docs/conformance-supplement-0.6.md", + "fixtures": [ + { + "id": "dataset-spec-version", + "rulings": [ + "13" + ], + "source": "fixtures/core-numeric-string.sav", + "directions": [ + "import" + ], + "expects": [ + "dataset_spec_version" + ], + "expected_catalog": { + "dataset": { + "spec_version": "1.0" + } + } + }, + { + "id": "physical-table-schema", + "rulings": [ + "25" + ], + "source": "fixtures/core-numeric-string.sav", + "directions": [ + "import" + ], + "expects": [ + "physical_table_schema_rule" + ] + }, + { + "id": "catalog-schema-version", + "rulings": [ + "13" + ], + "source": "fixtures/core-numeric-string.sav", + "directions": [ + "import" + ], + "expects": [ + "catalog_schema_version" + ], + "expected_catalog": { + "catalog_identity": { + "contract_id": "openstatspec-strict-wide-table-v1", + "schema_version": 1 + } + } + }, + { + "id": "variable-vocabularies", + "rulings": [ + "16" + ], + "source": "fixtures/dictionary-and-display.sav", + "directions": [ + "import", + "semantic_round_trip" + ], + "expects": [ + "measurement_level_vocabulary", + "variable_role_vocabulary", + "display_alignment_vocabulary" + ], + "expected_catalog": { + "variables": [ + { + "variable": "respondent_id", + "variable_role": "none", + "display_alignment": "right" + }, + { + "variable": "gender", + "measurement_level": "nominal", + "variable_role": "input", + "display_alignment": "center" + }, + { + "variable": "satisfaction", + "measurement_level": "ordinal", + "variable_role": "target", + "display_alignment": "center" + }, + { + "variable": "income", + "measurement_level": "scale", + "variable_role": "input" + }, + { + "variable": "comment", + "measurement_level": "nominal", + "variable_role": "none", + "display_alignment": "left" + } + ] + } + }, + { + "id": "multiple-response-vocabularies", + "rulings": [ + "16" + ], + "source": "fixtures/weight-and-string-mr.sav", + "directions": [ + "import", + "semantic_round_trip" + ], + "expects": [ + "category_label_behavior_vocabulary", + "label_source_vocabulary" + ], + "expected_catalog": { + "multiple_response_sets": [ + { + "name": "$contact_text", + "category_label_behavior": "counted_values", + "label_source": "variable_label" + } + ] + } + }, + { + "id": "attribute-export-order", + "rulings": [ + "14" + ], + "source": "fixtures/long-utf8-and-attributes.sav", + "directions": [ + "export", + "semantic_round_trip" + ], + "expects": [ + "attribute_export_order", + "attribute_comparison_by_name" + ], + "expected_catalog": { + "dataset_attribute_export_order": [ + "$VariableView2", + "fixture_metadata" + ], + "variable_attribute_export_order": [ + { + "variable": "long_utf8_text", + "names": [ + "source_tags" + ] + } + ] + } + }, + { + "id": "lowest-highest-null-endpoints", + "rulings": [ + "lowest-highest-endpoints" + ], + "source": "fixtures/missing-rules.sav", + "directions": [ + "import", + "semantic_round_trip" + ], + "expects": [ + "lowest_highest_null_endpoints" + ], + "expected_catalog": { + "missing_rules": [ + { + "variable": "lowest_to_zero", + "ordinal": 1, + "rule_kind": "numeric_range", + "lower_special": "LOWEST", + "numeric_lower": null, + "upper_special": null, + "numeric_upper": 0.0 + }, + { + "variable": "highest_from_100", + "ordinal": 1, + "rule_kind": "numeric_range", + "lower_special": null, + "numeric_lower": 100.0, + "upper_special": "HIGHEST", + "numeric_upper": null + } + ] + } + }, + { + "id": "negative-zero", + "rulings": [ + "21", + "23" + ], + "source": "fixtures/negative-zero.sav", + "directions": [ + "import", + "semantic_round_trip" + ], + "expects": [ + "negative_zero_preserved_refused_or_reported" + ] + }, + { + "id": "nan", + "rulings": [ + "21" + ], + "source": "fixtures/nan.sav", + "directions": [ + "import", + "semantic_round_trip" + ], + "expects": [ + "nan_preserved_refused_or_declared_null" + ] + } + ] +} diff --git a/conformance/spss-syntax-frontend-0.1-supplement-1.json b/conformance/spss-syntax-frontend-0.1-supplement-1.json new file mode 100644 index 0000000..aca1891 --- /dev/null +++ b/conformance/spss-syntax-frontend-0.1-supplement-1.json @@ -0,0 +1,445 @@ +{ + "manifest_version": "0.1", + "profile": "OpenStatSpec SPSS-like Syntax Frontend 0.1 conformance supplement 1", + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "plan_contract": "openstatspec-transformation-plan-v0.1", + "request_schema": "../transformation/spss-syntax-frontend-0.1.schema.json", + "plan_schema": "../transformation/plan-0.1.schema.json", + "supplement_to": "spss-syntax-frontend-0.1.json", + "supplement_document": "../docs/conformance-supplement-0.6.md", + "cases": [ + { + "id": "reject-request-schema-violation", + "rulings": [ + "4" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "date" + } + ] + }, + "source_text": "RECODE q1 (1 = 0)." + }, + "expected_source_hash": "68c05b0cae01476642c70956ddcaa693311be1a653ead1d1caf8b006843ed55b", + "expected_error": "request_schema_invalid" + }, + { + "id": "reject-case-insensitive-duplicate-names", + "rulings": [ + "4" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "Q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (1 = 0)." + }, + "expected_source_hash": "68c05b0cae01476642c70956ddcaa693311be1a653ead1d1caf8b006843ed55b", + "expected_error": "request_schema_invalid" + }, + { + "id": "reject-numeric-value-label-on-string-variable", + "rulings": [ + "4" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "color", + "storage_kind": "string", + "value_labels": [ + { + "value": { + "type": "binary64", + "bits": "3ff0000000000000" + }, + "label": "One" + } + ] + } + ] + }, + "source_text": "VALUE LABELS color 'R' 'Red'." + }, + "expected_source_hash": "9d41e3144bd4f93d074fd464695cac178393fe0de7478db8ea3bf85897ac7c38", + "expected_error": "request_schema_invalid" + }, + { + "id": "reject-else-only-recode", + "rulings": [ + "5" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (ELSE = 0)." + }, + "expected_source_hash": "7b34f487ff9dac83c9fe8bca03a3059d1456ab620fe64503a46ee2eb36589c51", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-final-command-without-period", + "rulings": [ + "6" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (1 = 0).\nVARIABLE LABELS q1 'Recoded'" + }, + "expected_source_hash": "0c12c5267801967545b68e784f04a5af73022b3cbd97e4fdf00bc799b4781bf9", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-trailing-comment-without-period", + "rulings": [ + "6" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (1 = 0).\n* note without its period" + }, + "expected_source_hash": "1c24dc99edec8f35f8f812ff3987e144e4c69d68bac2231d60a7a2ef3f9b3538", + "expected_error": "spss_syntax_error" + }, + { + "id": "inner-period-in-names", + "rulings": [ + "7" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a.b", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE a.b (1 = 0) INTO c.d." + }, + "expected_plan": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "recode", + "source": "a.b", + "target": "c.d", + "target_mode": "create", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "3ff0000000000000" + } + ] + }, + "result": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "0000000000000000" + } + } + } + ], + "unmatched": { + "kind": "system_missing" + } + } + ] + }, + "expected_plan_hash": "f55961d64e59f68e7c7d4549019132d67b29af2ad6b05393040889369a322d76", + "expected_source_hash": "9897e2c5e5e8f848512fbd5351f0fb6a75448b85955dda99aefe5bf5ef2dbe8e", + "expected_error": null + }, + { + "id": "reject-reserved-word-into-target", + "rulings": [ + "7" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (1 = 0) INTO with." + }, + "expected_source_hash": "9b1c09748ee0f8c60e52a804996a669c017d34644f00df4b4f0bed3a004583f5", + "expected_error": "spss_syntax_error" + }, + { + "id": "lowercase-mapping-matches-non-ascii-name", + "rulings": [ + "7" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "ära", + "storage_kind": "numeric" + } + ] + }, + "source_text": "VARIABLE LABELS ÄRA 'Era'." + }, + "expected_plan": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "set_variable_label", + "variable": "ära", + "label": "Era" + } + ] + }, + "expected_plan_hash": "57cacc0a67c8204b8fdf32454f4c14c3af1d260607a45f46381bcf334a010d76", + "expected_source_hash": "e6ab2fa9bef49e984bedd8ec4ad38329fc21c3561f6470fdb310356a186f3769", + "expected_error": null + }, + { + "id": "reject-case-folding-only-match", + "rulings": [ + "7" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "straße", + "storage_kind": "numeric" + } + ] + }, + "source_text": "VARIABLE LABELS STRASSE 'Street'." + }, + "expected_source_hash": "e3837949236df37085e1bf2a27a232ba6d70b152b6476359f91504cd6514fb6a", + "expected_error": "unknown_variable" + }, + { + "id": "reject-frontend-0.2-command", + "rulings": [ + "0.1-boundary" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "COMPUTE q1 = 1." + }, + "expected_source_hash": "141d0749394be35f14acaf9bdd3c99bd969a7f274355f46eced2f3abdd127fa1", + "expected_error": "unsupported_spss_command" + }, + { + "id": "reject-var-lab-abbreviation", + "rulings": [ + "abbreviations" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "VAR LAB q1 'Score'." + }, + "expected_source_hash": "3a11b2e45bbed67ada58283924bdccc451cb330ab96b71fb75b31a78a72c0b26", + "expected_error": "unsupported_spss_command" + }, + { + "id": "reject-reversed-numeric-range", + "rulings": [ + "recode-diagnostics" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (5 THRU 3 = 1)." + }, + "expected_source_hash": "5460164a9d185e5bd29b778558bf6b2e9e1629141b451be5409da3c07e0745fc", + "expected_error": "invalid_numeric_range" + }, + { + "id": "reject-into-existing-variable", + "rulings": [ + "recode-diagnostics" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "q2", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (1 = 0) INTO Q2." + }, + "expected_source_hash": "5b2088656f8c9d8ddd9148bb3596133fcb002fd63ec1d4b4a51a8ef55019ad27", + "expected_error": "target_already_exists" + }, + { + "id": "reject-value-list-joined-with-range", + "rulings": [ + "recode-diagnostics" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (1, 2 THRU 3 = 0)." + }, + "expected_source_hash": "c0f7595e7753eb94f8bf47cf8696a639e94ec605b69ef93720d5044244f4b073", + "expected_error": "spss_syntax_error" + }, + { + "id": "sysmis-only-recode-into-creates-numeric-target", + "rulings": [ + "18" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.1", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (1 = SYSMIS) INTO r." + }, + "expected_plan": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "recode", + "source": "q1", + "target": "r", + "target_mode": "create", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "3ff0000000000000" + } + ] + }, + "result": { + "kind": "system_missing" + } + } + ], + "unmatched": { + "kind": "system_missing" + } + } + ] + }, + "expected_plan_hash": "32c2911658c3a624072ee44101c926647de7af7ea4e4707098489de49b9918c0", + "expected_source_hash": "3e1487d7e8b9b299d4f0e53a782925ce1f0e3939a539143d5d8dbb23633dff1e", + "expected_error": null + } + ] +} diff --git a/conformance/spss-syntax-frontend-0.2-supplement-1.json b/conformance/spss-syntax-frontend-0.2-supplement-1.json new file mode 100644 index 0000000..f44f363 --- /dev/null +++ b/conformance/spss-syntax-frontend-0.2-supplement-1.json @@ -0,0 +1,505 @@ +{ + "manifest_version": "0.2", + "profile": "OpenStatSpec SPSS-like Syntax Frontend 0.2 conformance supplement 1", + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "plan_contracts": [ + "openstatspec-transformation-plan-v0.1", + "openstatspec-transformation-plan-v0.2" + ], + "request_schema": "../transformation/spss-syntax-frontend-0.2.schema.json", + "plan_schemas": { + "openstatspec-transformation-plan-v0.1": "../transformation/plan-0.1.schema.json", + "openstatspec-transformation-plan-v0.2": "../transformation/plan-0.2.schema.json" + }, + "supplement_to": "spss-syntax-frontend-0.2.json", + "supplement_document": "../docs/conformance-supplement-0.6.md", + "cases": [ + { + "id": "reject-request-schema-violation", + "rulings": [ + "4" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "target", + "storage_kind": "numeric", + "measurement_level": "interval" + } + ] + }, + "source_text": "COMPUTE target = 1." + }, + "expected_source_hash": "ed73fae5032a31e05307c948aa04e63b89d235d73f1a95720bb50eec002d89b3", + "expected_error": "request_schema_invalid" + }, + { + "id": "formats-width-without-decimals", + "rulings": [ + "9" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "FORMATS target (F8)." + }, + "expected_plan": { + "contract": "openstatspec-transformation-plan-v0.2", + "input_alias": "parent", + "operations": [ + { + "op": "set_format", + "variable": "target", + "family": "F", + "width": 8, + "decimals": 0 + } + ] + }, + "expected_plan_contract": "openstatspec-transformation-plan-v0.2", + "expected_plan_hash": "5970c1e54ba7743fe228a75de352e4483c47c9a067790354433c2ea5bea5e0a3", + "expected_source_hash": "e7e1cce3edf097f6e5ebc3847525ebb2fdcb0f4b4a5e6f61bc13c1e8b049b56d", + "expected_error": null + }, + { + "id": "reject-slash-separated-formats-groups", + "rulings": [ + "9" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "FORMATS source_a (F8.2) / source_b (F4.0)." + }, + "expected_source_hash": "dbee8dc9a3e89e45c634f1fb09a5c2b3412b0df4c0c0943f8e0c891297c38224", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-unary-minus", + "rulings": [ + "11" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "COMPUTE target = -source_a." + }, + "expected_source_hash": "ede9ed1798d41be733749a46f816e191e9beda2b0318a10b843bf1748089074f", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-function-call", + "rulings": [ + "11" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "COMPUTE target = ABS(source_a)." + }, + "expected_source_hash": "0f9a7379819507e9516ecfe53a96445783e8fb1c85a932e0b90ecce678ed840c", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-string-variable-compared-with-number", + "rulings": [ + "20" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "IF (color = 1) target = 1." + }, + "expected_source_hash": "7c7b840762e8a64894fe1acf38b0e335a37599f8412e8a7690113984923b5a81", + "expected_error": "expression_type_unsupported" + }, + { + "id": "reject-number-compared-with-string-literal", + "rulings": [ + "20" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "IF (source_a = '1') target = 1." + }, + "expected_source_hash": "48ab85a14d29d59989249f011fbdc321a852d8b3672a57114ab739cb074f649b", + "expected_error": "expression_type_unsupported" + }, + { + "id": "reject-multiplication-inside-if", + "rulings": [ + "arithmetic-in-if" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "IF (source_a * 2 = 4) target = 1." + }, + "expected_source_hash": "dc722c2b8bdd854710c7caf56c001bbddc4ed59bb356375fd0567c77b17b8057", + "expected_error": "expression_type_unsupported" + }, + { + "id": "reject-addition-inside-if", + "rulings": [ + "arithmetic-in-if" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "IF (source_a + 1 > 2) target = 1." + }, + "expected_source_hash": "3705b6bba3af101a7a872a158fe9b14142366382316fa02971dd2247fa941e72", + "expected_error": "expression_type_unsupported" + }, + { + "id": "nan-is-a-name-outside-operand-position", + "rulings": [ + "7" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + }, + { + "name": "NaN", + "storage_kind": "numeric" + } + ] + }, + "source_text": "VARIABLE LABELS NaN 'Not a number'." + }, + "expected_plan_0_1": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "set_variable_label", + "variable": "NaN", + "label": "Not a number" + } + ] + }, + "expected_plan_contract": "openstatspec-transformation-plan-v0.1", + "expected_plan_hash": "a599b8c357c0b5002d2f98259031cc3082e6d2190d1f99a397252015a657f478", + "expected_source_hash": "f3d6977688e08c85ff659242815b90caed1f536f9bcc701d24025914d95ae44e", + "expected_error": null + }, + { + "id": "reject-nan-variable-in-operand-position", + "rulings": [ + "7" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + }, + { + "name": "NaN", + "storage_kind": "numeric" + } + ] + }, + "source_text": "COMPUTE target = NaN." + }, + "expected_source_hash": "73519477685fa98ea68625926a28d7dd4cde76587a755bb754bd8983ccd09ad2", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-to-as-into-target", + "rulings": [ + "7" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE source_a (1 = 0) INTO to." + }, + "expected_source_hash": "d4927c983cda4ad7ddc0b1360e6d4a2df8a0d46a5218ec170e78efea8538b804", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-two-ranges-joined", + "rulings": [ + "recode-diagnostics" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE source_a (1 THRU 2, 3 THRU 4 = 0)." + }, + "expected_source_hash": "e6e78fb7b044c214510f9faaab84b1e805ae33674f408acf9832270e921baf10", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-reversed-numeric-range", + "rulings": [ + "recode-diagnostics" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.2", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "source_a", + "storage_kind": "numeric" + }, + { + "name": "source_b", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE source_a (5 THRU 3 = 1)." + }, + "expected_source_hash": "f40068184c4cc84a3599cfe0578d9a73351aaaff784b3d82cd1ad017f0b3fb20", + "expected_error": "invalid_numeric_range" + } + ] +} diff --git a/conformance/spss-syntax-frontend-0.3-supplement-1.json b/conformance/spss-syntax-frontend-0.3-supplement-1.json new file mode 100644 index 0000000..e4f7414 --- /dev/null +++ b/conformance/spss-syntax-frontend-0.3-supplement-1.json @@ -0,0 +1,761 @@ +{ + "manifest_version": "0.3", + "profile": "OpenStatSpec SPSS-like Syntax Frontend 0.3 conformance supplement 1", + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "plan_contracts": [ + "openstatspec-transformation-plan-v0.1", + "openstatspec-transformation-plan-v0.2" + ], + "request_schema": "../transformation/spss-syntax-frontend-0.3.schema.json", + "plan_schemas": { + "openstatspec-transformation-plan-v0.1": "../transformation/plan-0.1.schema.json", + "openstatspec-transformation-plan-v0.2": "../transformation/plan-0.2.schema.json" + }, + "supplement_to": "spss-syntax-frontend-0.3.json", + "supplement_document": "../docs/conformance-supplement-0.6.md", + "cases": [ + { + "id": "star-comment-ends-at-period-before-whitespace", + "rulings": [ + "6" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "* ratio 1.5 is kept.\nRECODE q1 (1 = 0)." + }, + "expected_plan_0_1": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "recode", + "source": "q1", + "target": "q1", + "target_mode": "replace", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "3ff0000000000000" + } + ] + }, + "result": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "0000000000000000" + } + } + } + ], + "unmatched": { + "kind": "copy" + } + } + ] + }, + "expected_plan_contract": "openstatspec-transformation-plan-v0.1", + "expected_plan_hash": "091a2daeb490deb3369cba83b5197d1c43767432c9a04cbf3e55bd69296b67a8", + "expected_source_hash": "9ac5397bc8f932eb29f6da3b7acb38d63463d19dc60cdf70cead5f23772234c9", + "expected_error": null + }, + { + "id": "comment-command-and-final-comment", + "rulings": [ + "6" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "COMMENT see section 2.3.\nRECODE q1 (1 = 0).\n* done." + }, + "expected_plan_0_1": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "recode", + "source": "q1", + "target": "q1", + "target_mode": "replace", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "3ff0000000000000" + } + ] + }, + "result": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "0000000000000000" + } + } + } + ], + "unmatched": { + "kind": "copy" + } + } + ] + }, + "expected_plan_contract": "openstatspec-transformation-plan-v0.1", + "expected_plan_hash": "091a2daeb490deb3369cba83b5197d1c43767432c9a04cbf3e55bd69296b67a8", + "expected_source_hash": "24724869665248c31dfb3a4fbe303538aa7fe13f8e4ada8e063aba69b0245828", + "expected_error": null + }, + { + "id": "reject-trailing-comment-without-period", + "rulings": [ + "6" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (1 = 0).\n* trailing note" + }, + "expected_source_hash": "67619982c7c0d938faa82e9f2153ff4a2092887914e52277116c6e9a819e7d1a", + "expected_error": "spss_syntax_error" + }, + { + "id": "slash-separated-recode-groups", + "rulings": [ + "8" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE a (1 = 0) / b (2 = 0)." + }, + "expected_plan_0_1": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "recode", + "source": "a", + "target": "a", + "target_mode": "replace", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "3ff0000000000000" + } + ] + }, + "result": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "0000000000000000" + } + } + } + ], + "unmatched": { + "kind": "copy" + } + }, + { + "op": "recode", + "source": "b", + "target": "b", + "target_mode": "replace", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "4000000000000000" + } + ] + }, + "result": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "0000000000000000" + } + } + } + ], + "unmatched": { + "kind": "copy" + } + } + ] + }, + "expected_plan_contract": "openstatspec-transformation-plan-v0.1", + "expected_plan_hash": "d989158f5d878ae9e395d25881df0856cb52f0bbe5ffe1f6770cc4d22a34a223", + "expected_source_hash": "6760ac96ffd029f362bacb15e14acb3594b8043e3caaf705ec16beeb7c5e147f", + "expected_error": null + }, + { + "id": "later-recode-group-sees-earlier-target", + "rulings": [ + "8" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE a (1 = 10) INTO t / t (10 = 20)." + }, + "expected_plan_0_1": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "recode", + "source": "a", + "target": "t", + "target_mode": "create", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "3ff0000000000000" + } + ] + }, + "result": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "4024000000000000" + } + } + } + ], + "unmatched": { + "kind": "system_missing" + } + }, + { + "op": "recode", + "source": "t", + "target": "t", + "target_mode": "replace", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "4024000000000000" + } + ] + }, + "result": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "4034000000000000" + } + } + } + ], + "unmatched": { + "kind": "copy" + } + } + ] + }, + "expected_plan_contract": "openstatspec-transformation-plan-v0.1", + "expected_plan_hash": "beda89984cbcc5ca26eba04736122840964384e5ddcbd05cd93e5781cc5d12ea", + "expected_source_hash": "b9d22467cf2ee96fbd539c88d11665a9c0cf2b1ce5d187ac0398f3c2372855af", + "expected_error": null + }, + { + "id": "slash-separated-formats-groups", + "rulings": [ + "9" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "FORMATS a (F8.2) / b (F4)." + }, + "expected_plan": { + "contract": "openstatspec-transformation-plan-v0.2", + "input_alias": "parent", + "operations": [ + { + "op": "set_format", + "variable": "a", + "family": "F", + "width": 8, + "decimals": 2 + }, + { + "op": "set_format", + "variable": "b", + "family": "F", + "width": 4, + "decimals": 0 + } + ] + }, + "expected_plan_contract": "openstatspec-transformation-plan-v0.2", + "expected_plan_hash": "7cf25fb5201de5466709f5f4ed2a8baf2ab31fad714ecc5d0bf574850f63aa84", + "expected_source_hash": "b5351182a2c2037754bb543cf4a4782f6155f21113253f51cac9c94e6a57b302", + "expected_error": null + }, + { + "id": "reject-function-call-in-predicate", + "rulings": [ + "11" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "IF (ABS(a) = 1) target = 1." + }, + "expected_source_hash": "2813cc731de6d25f5a3a8299067600acff1f3a39a5ae5b9bdab753072d25bafe", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-multiplication-inside-if", + "rulings": [ + "arithmetic-in-if" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "IF (a * 2 = 1) target = 1." + }, + "expected_source_hash": "46e91fcca21e007395cbdea0133ba88f012378bfea06b4b2949cbc7cb7b2106b", + "expected_error": "expression_type_unsupported" + }, + { + "id": "reject-val-lab-abbreviation", + "rulings": [ + "abbreviations" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "VAL LAB q1 1 'One'." + }, + "expected_source_hash": "a435175d25e0c716b429e100943990683b18babfe13586af9851bff1989b800d", + "expected_error": "unsupported_spss_command" + }, + { + "id": "reject-reversed-numeric-range", + "rulings": [ + "recode-diagnostics" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (5 THRU 3 = 1)." + }, + "expected_source_hash": "5460164a9d185e5bd29b778558bf6b2e9e1629141b451be5409da3c07e0745fc", + "expected_error": "invalid_variable_range" + }, + { + "id": "reject-sysmis-joined-with-value-list", + "rulings": [ + "recode-diagnostics" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE q1 (1, SYSMIS = 0)." + }, + "expected_source_hash": "41a319e1e0d0acf048a1a9eef10b16eb240d9e5c7366f3ab7578e790abbf7230", + "expected_error": "spss_syntax_error" + }, + { + "id": "reject-repeated-into-target", + "rulings": [ + "recode-diagnostics" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "RECODE a b (1 = 0) INTO t T." + }, + "expected_source_hash": "d28cbc3c65dde07865f313a75254c89aaa4a889e2557aac45a83327c75bb1a21", + "expected_error": "target_already_exists" + }, + { + "id": "reject-string-variable-compared-with-number-alias", + "rulings": [ + "20" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "a", + "storage_kind": "numeric" + }, + { + "name": "b", + "storage_kind": "numeric" + }, + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string" + }, + { + "name": "target", + "storage_kind": "numeric" + } + ] + }, + "source_text": "IF (color NE 1) target = 1." + }, + "expected_source_hash": "ee41ac7f103fea5a2967d99a51fd0d3ba916fd2a0edbd691956c10aeace28548", + "expected_error": "expression_type_unsupported" + }, + { + "id": "reject-numeric-value-label-on-string-variable", + "rulings": [ + "4" + ], + "request": { + "contract": "openstatspec-spss-syntax-frontend-v0.3", + "input_alias": "parent", + "input_schema": { + "variables": [ + { + "name": "q1", + "storage_kind": "numeric" + }, + { + "name": "color", + "storage_kind": "string", + "value_labels": [ + { + "value": { + "type": "binary64", + "bits": "3ff0000000000000" + }, + "label": "One" + } + ] + } + ] + }, + "source_text": "RECODE q1 (1 = 0)." + }, + "expected_source_hash": "68c05b0cae01476642c70956ddcaa693311be1a653ead1d1caf8b006843ed55b", + "expected_error": "request_schema_invalid" + } + ] +} diff --git a/conformance/transformation-plan-0.1-supplement-1.json b/conformance/transformation-plan-0.1-supplement-1.json new file mode 100644 index 0000000..e3e2c64 --- /dev/null +++ b/conformance/transformation-plan-0.1-supplement-1.json @@ -0,0 +1,92 @@ +{ + "manifest_version": "0.1", + "profile": "OpenStatSpec Transformation Plan 0.1 conformance supplement 1", + "contract": "openstatspec-transformation-plan-v0.1", + "schema": "../transformation/plan-0.1.schema.json", + "supplement_to": "transformation-plan-0.1.json", + "supplement_document": "../docs/conformance-supplement-0.6.md", + "cases": [ + { + "id": "reject-replace-target-not-source", + "rulings": [ + "17" + ], + "plan": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "recode", + "source": "q1", + "target": "q2", + "target_mode": "replace", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "3ff0000000000000" + } + ] + }, + "result": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "0000000000000000" + } + } + } + ], + "unmatched": { + "kind": "copy" + } + } + ] + }, + "expected_plan_hash": null, + "expected_error": "target_already_exists" + }, + { + "id": "create-target-with-only-system-missing-results", + "rulings": [ + "18" + ], + "plan": { + "contract": "openstatspec-transformation-plan-v0.1", + "input_alias": "parent", + "operations": [ + { + "op": "recode", + "source": "q1", + "target": "r", + "target_mode": "create", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "3ff0000000000000" + } + ] + }, + "result": { + "kind": "system_missing" + } + } + ], + "unmatched": { + "kind": "system_missing" + } + } + ] + }, + "expected_plan_hash": "32c2911658c3a624072ee44101c926647de7af7ea4e4707098489de49b9918c0", + "expected_error": null + } + ] +} diff --git a/conformance/transformation-plan-0.2-supplement-1.json b/conformance/transformation-plan-0.2-supplement-1.json new file mode 100644 index 0000000..db26a50 --- /dev/null +++ b/conformance/transformation-plan-0.2-supplement-1.json @@ -0,0 +1,97 @@ +{ + "manifest_version": "0.2", + "profile": "OpenStatSpec Transformation Plan 0.2 conformance supplement 1", + "contract": "openstatspec-transformation-plan-v0.2", + "schema": "../transformation/plan-0.2.schema.json", + "canonicalization": "restricted-rfc8785-utf8-sha256", + "supplement_to": "transformation-plan-0.2.json", + "supplement_document": "../docs/conformance-supplement-0.6.md", + "cases": [ + { + "id": "reject-replace-target-not-source", + "rulings": [ + "17" + ], + "plan": { + "contract": "openstatspec-transformation-plan-v0.2", + "input_alias": "parent", + "operations": [ + { + "op": "recode", + "source": "q1", + "target": "q2", + "target_mode": "replace", + "rules": [ + { + "match": { + "kind": "values", + "values": [ + { + "type": "binary64", + "bits": "3ff0000000000000" + } + ] + }, + "result": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "0000000000000000" + } + } + } + ], + "unmatched": { + "kind": "copy" + } + } + ] + }, + "expected_plan_hash": null, + "expected_error": "target_already_exists" + }, + { + "id": "reject-string-literal-compared-with-number", + "rulings": [ + "20" + ], + "plan": { + "contract": "openstatspec-transformation-plan-v0.2", + "input_alias": "parent", + "operations": [ + { + "op": "conditional_assign", + "condition": { + "expression": "comparison", + "left": { + "kind": "literal", + "value": { + "type": "string", + "value": "1" + } + }, + "operator": "=", + "right": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "3ff0000000000000" + } + } + }, + "target": "target", + "value": { + "kind": "literal", + "value": { + "type": "binary64", + "bits": "3ff0000000000000" + } + } + } + ] + }, + "expected_plan_hash": null, + "expected_error": "expression_type_unsupported" + } + ] +} diff --git a/docs/conformance-supplement-0.6.md b/docs/conformance-supplement-0.6.md new file mode 100644 index 0000000..b06ccbb --- /dev/null +++ b/docs/conformance-supplement-0.6.md @@ -0,0 +1,331 @@ +# OpenStatSpec Conformance Supplement 0.6 + +## Status and scope + +Status: published with OpenStatSpec `v0.6.0`. The key words **MUST**, +**MUST NOT**, **SHOULD**, **SHOULD NOT**, and **MAY** are normative. + +This supplement settles the implementation differences collected in +[issue #27](https://github.com/OpenStatSpec/specification/issues/27). It adds +no profile version and changes no contract identifier. The published +conformance manifests, request and plan schemas, and `sql/schema-outline.sql` +stay byte-identical; repository validation pins their SHA-256. The published +profile documents keep their contracts and only gain a pointer to this +supplement. + +The supplement is binding for an implementation claim that pins +specification `v0.6.0` or a later release. A claim pinned to an earlier +release stays valid under the documents and manifests of its pin. Within its +scope, a rule here takes precedence over a profile document that is silent or +that leaves the point implementation-defined. No rule here changes the +expected result of a published conformance case. + +A claim that pins `v0.6.0` or later and declares one of the profiles below +MUST pass the published manifest and the supplement manifest of that profile. +Each supplement manifest is self-contained: it inherits no case and references +no case of another manifest. + +| Profile | Published manifest | Supplement manifest | Cases | +| --- | --- | --- | --- | +| SPSS Syntax Frontend 0.1 | `spss-syntax-frontend-0.1.json` | `spss-syntax-frontend-0.1-supplement-1.json` | 16 | +| SPSS Syntax Frontend 0.2 | `spss-syntax-frontend-0.2.json` | `spss-syntax-frontend-0.2-supplement-1.json` | 14 | +| SPSS Syntax Frontend 0.3 | `spss-syntax-frontend-0.3.json` | `spss-syntax-frontend-0.3-supplement-1.json` | 14 | +| Transformation Plan 0.1 | `transformation-plan-0.1.json` | `transformation-plan-0.1-supplement-1.json` | 2 | +| Transformation Plan 0.2 | `transformation-plan-0.2.json` | `transformation-plan-0.2-supplement-1.json` | 2 | +| In-Place Binding 0.1 | `in-place-transformation-0.1.json` | `in-place-transformation-0.1-supplement-1.json` | 1 | +| SPSS SAV/ZSAV 1.0 | `spss-sav-zsav-1.0.json` | `spss-sav-zsav-1.0-supplement-1.json` | 9 fixtures | + +All manifests are in [`../conformance/`](../conformance/). The supplement +manifests use the case shape and keys of their published manifests and are +described in [`../conformance/README.md`](../conformance/README.md). The +Frontend 0.3 adapter claim gate in its profile document stays unchanged. Its +first item, which names the exact `v0.4.0` commit, is met by a claim that pins +`v0.6.0` or a later release, because the Frontend 0.3 manifests and schemas +in that release are byte-identical to `v0.4.0`; every other gate item still +applies. Such a claim runs the 14 supplement cases in addition to the 90 +effective Frontend 0.3 cases. + +## SPSS Syntax Frontend 0.1 + +The rules in this section apply to Frontend 0.1. Unless a later section says +otherwise, they also apply unchanged to Frontend 0.2 and 0.3. + +### Request validation + +A request that does not conform to the request schema of its contract MUST +fail with `request_schema_invalid`. The same code applies to a request whose +input schema declares two variable names that are equal under the +case-insensitive matching rule below, and to a request whose input schema +gives a numeric value label to a string variable. Request validation comes +before lowering, so such a request fails with this code whatever its source +text contains, and no plan is produced. + +### Command termination and comments + +Every command ends with its terminating period, including the last command of +the program. A program whose last command, or any text after the last +terminated command, has no terminating period MUST fail with +`spss_syntax_error`. Whitespace and, under Frontend 0.3, a complete `/* */` +block comment are not text for this rule, so `EXECUTE. /* note */` is valid +under Frontend 0.3; an unterminated block comment still fails. + +A `*` comment and a `COMMENT` command end at the first period that is followed +by whitespace or by the end of the input. Any other period inside them is +comment text. Under Frontend 0.1 and 0.2 a recognized comment still returns +`unsupported_spss_command`, as those profiles state; this rule fixes where +the comment ends. The termination rule is checked first: text after the last +terminated command that has no terminating period fails with +`spss_syntax_error` under every profile, even when it is a comment or an +unsupported command. + +### Names + +The name characters are letters, decimal digits, `_`, `@`, `#` and `$`. A +period inside a name is part of the name when a name character follows it; a +name never ends with a period, so a period after the last name character +terminates the command. This supplement does not change which characters may +begin a name. Whether a combining mark is a name character is +implementation-defined. + +Informative note: because a period followed by a name character stays inside +the name, text such as `F8.2` or `x.RECODE` is one name token to a lexer. +Implementations recognize a format where the grammar expects a format, not by +lexing it differently. + +`AND`, `OR`, `NOT`, `TO`, `EQ`, `NE`, `LT`, `LE`, `GT`, `GE`, `BY`, `ALL` and +`WITH`, in any ASCII letter case, are reserved words. A reserved word is never +read as a variable name and is never accepted as an `INTO` target or any other +new target; such a use MUST fail with `spss_syntax_error`. + +`NaN` and `Infinity` are not reserved words and may name variables. In an +expression operand position (the value of `COMPUTE` or `IF`, or a comparison +operand) the tokens `NaN` and `Infinity` MUST fail with `spss_syntax_error`, +as the published Frontend 0.2 cases require, even when the input schema +declares a variable of that name. + +Keywords stay ASCII case-insensitive. Case-insensitive name matching +(variable resolution, `INTO` target uniqueness and the duplicate-name check of +the request) compares names after the unconditional per-code-point lowercase +mapping: each code point is replaced by its Unicode lowercase mapping, +including the unconditional mappings of `SpecialCasing.txt` and excluding its +conditional, language-sensitive or context-sensitive mappings. Case folding is +not used, so `STRASSE` does not match `straße`, while `ÄRA` matches `ära`. + +### Profile boundary + +An implementation that claims Frontend 0.1 and receives a request with the +Frontend 0.1 contract MUST refuse each command that Frontend 0.2 or 0.3 adds +(`COMPUTE`, `IF`, `FORMATS`, `VARIABLE LEVEL`, `EXECUTE` and +`ADD VALUE LABELS`) with `unsupported_spss_command`. + +Command names are written in full. Abbreviations such as `VAR LAB` and +`VAL LAB` are outside the bounded grammar of every frontend profile and MUST +fail with `unsupported_spss_command`. + +### RECODE diagnostics + +The `RECODE` diagnostics recorded as informative notes in `v0.5.1` are +normative: + +- an `INTO` target that already exists case-insensitively (the command's own + source, a variable created by an earlier command, or a target repeated in + the same `INTO` list) MUST fail with `target_already_exists`; +- a comma that joins a literal list with a range or `SYSMIS`, or joins two + ranges, MUST fail with `spss_syntax_error`; +- a range whose `lower` is greater than its `upper` MUST fail with + `invalid_numeric_range` under Frontend 0.1 and 0.2 (equal bounds are + valid); and +- a `RECODE` whose only clause is `ELSE` MUST fail with `spss_syntax_error`. + +`RECODE q1 (1 = SYSMIS) INTO r.` and every other `RECODE ... INTO` whose +results are all `SYSMIS`, written or implied by the omitted `ELSE`, determine +a numeric target. The frontend lowers it to a `create` operation whose rule +results and `unmatched` are `system_missing`; it MUST NOT fail with +`target_type_ambiguous`. + +## SPSS Syntax Frontend 0.2 + +The Frontend 0.1 section applies. In addition: + +- `Fw` in `FORMATS` means `Fw.0`: `FORMATS target (F8).` lowers to + `set_format` with width 8 and decimals 0. The width and decimals rules of + Plan 0.2 are unchanged. +- Slash-separated `FORMATS` groups MUST fail with `spss_syntax_error` under + Frontend 0.2. +- A unary minus that is not part of a finite-number token, and a function + call, MUST fail with `spss_syntax_error`, as the published leading-plus case + already requires for unary plus. A `-` directly followed by a digit remains + part of the finite-number token, so `-1` is still a number. +- Binary arithmetic (`+`, `-`, `*`, `/`, `**`) in a `COMPUTE` value or inside + an `IF` predicate MUST fail with `expression_type_unsupported`, as the + published arithmetic case already requires for `COMPUTE`. +- A comparison between a string operand (a string variable or a quoted + literal) and a numeric operand MUST fail with + `expression_type_unsupported`, never `type_mismatch`. `RECODE` selector and + value-label type errors keep `type_mismatch`. + +## SPSS Syntax Frontend 0.3 + +The Frontend 0.1 and 0.2 sections apply, except that slash-separated +`FORMATS` groups are accepted. In addition: + +- The comment ending rule above applies to accepted comments: a period that + is not followed by whitespace or the end of the input does not end a `*` + comment or a `COMMENT` command. A program that ends inside a comment + without its terminating period MUST fail with `spss_syntax_error`. +- `RECODE` accepts slash-separated groups: + `RECODE varlist (spec)... [INTO targets] [/ varlist (spec)... [INTO targets]]...`. + The groups lower in source order exactly as the same groups written as + consecutive `RECODE` commands, so a later group sees the targets created by + earlier groups. Within one group every pair still reads the state before + that group. +- `FORMATS` accepts slash-separated groups, which lower in source order + exactly as consecutive `FORMATS` commands. +- A reversed numeric range such as `5 THRU 3` MUST fail with + `invalid_variable_range`. `HIGHEST THRU number` and `number THRU LOWEST` + MUST fail with `spss_syntax_error`. +- The string and number comparison rule applies to every comparison operator, + including the aliases `NE`, `<>` and `~=` and comparisons under `NOT`. + +## Transformation Plan 0.1 + +- A `recode` with `target_mode=replace` whose `target` is not its `source` + MUST fail with `target_already_exists`. The check belongs to plan + validation and does not need a bound dataset. +- A `create` `recode` whose rule results and `unmatched` are all + `system_missing` determines a numeric target. It is valid and MUST NOT fail + with `target_type_ambiguous`. + +## Transformation Plan 0.2 + +The Plan 0.1 rules apply to Plan 0.2 `recode` operations. In addition, a +comparison between a string operand and a numeric operand MUST fail with +`expression_type_unsupported`, never `type_mismatch`. A plan whose comparison +uses a string literal fails in plan validation; a plan whose comparison uses a +variable that binds to a string variable fails in binding, before mutation. + +## In-Place Transformation Binding 0.1 and 0.2 + +- An apply of `RECODE q1 (1 = SYSMIS) INTO r.`, or of any `create` `recode` + whose results are all `system_missing`, creates one nullable numeric + target. On a profile that permits target creation, the target holds SQL + NULL in every case. A profile that cannot create a target in one native + transaction still refuses with `schema_change_not_atomic` before mutation; + no profile refuses this apply with `target_type_ambiguous`. +- The plan and type diagnostics above apply to a raw plan before mutation, + with the same codes. +- The compact audit copies `physical_table_schema` from the `dataset` row, + including NULL. + +## SPSS SAV/ZSAV 1.0 catalog + +### Identity values + +A writer MUST store `dataset.spec_version` as `"1.0"` and +`catalog_identity.schema_version` as the version of +[`../sql/schema-outline.sql`](../sql/schema-outline.sql), which is `1`. An +implementation MUST keep reading, or migrate, catalogs that its own earlier +releases wrote with a legacy value (for example `spec_version = +"spss-sav-zsav-1.0"` or another `schema_version`). This supplement does not +require a reader to accept legacy values written by another implementation. + +### Vocabularies + +The following catalog columns hold these text values. NULL means the source +declares no value. + +| Column | Values | +| --- | --- | +| `variable.measurement_level` | `nominal`, `ordinal`, `scale`, `unknown`; for a source that declares no known level a writer MAY write `unknown` or NULL, and readers treat the two as equal | +| `variable.variable_role` | `input`, `target`, `both`, `none`, `partition`, `split` | +| `variable.display_alignment` | `left`, `right`, `center` | +| `multiple_response_set.category_label_behavior` | `variable_labels`, `counted_values` | +| `multiple_response_set.label_source` | `set_label`, `variable_label` | + +A writer MUST write these text values. An implementation whose earlier +releases wrote the numeric strings of the SPSS dictionary codes MUST keep +reading, or migrate, them: for `measurement_level`, `0` +(unknown), `1` (`nominal`), `2` (`ordinal`) and `3` (`scale`); for +`display_alignment`, `0` (`left`), `1` (`right`) and `2` (`center`); for +`variable_role`, `0` (`input`), `1` (`target`), `2` (`both`), `3` (`none`), +`4` (`partition`) and `5` (`split`). + +### Attributes + +The catalog schema is unchanged. An exporter writes dataset attributes, and +the attributes of each variable, ordered by `attribute_name` compared by +Unicode code point and then by `array_ordinal`. A semantic round trip +compares attributes by name: for each attribute name, the ordered array of +values MUST match; the order of distinct names is not compared. + +### Missing-value endpoints + +In a `missing_rule` numeric range, a `LOWEST` endpoint MUST be recorded in +`lower_special` with `numeric_lower` NULL, and a `HIGHEST` endpoint in +`upper_special` with `numeric_upper` NULL. The other endpoint holds its +finite value. + +### Special numeric values + +Turning a NaN source value into SQL NULL is allowed only as a reader policy +that the capability declaration states. Without such a declaration NaN MUST be +stored exactly or refused before mutation. + +A negative-zero source value MUST be stored with its exact bits, refused +before mutation, or imported with a reported loss: a `fidelity_event` of the +import operation whose `source_item` names the affected variable. Storing +positive zero without a reported loss is not conformant. A refusal before +mutation follows the atomic preflight failure rule of the profile. + +### Physical table schema + +`dataset.physical_table_schema` is NULL when the data table is in the catalog +namespace, as the published Dolt binding cases require. A non-NULL value names +the PostgreSQL schema, or the MySQL, MariaDB or Dolt database, that holds the +data table. On SQLite it is NULL. A reader MUST accept both forms. + +## SQL dialect profiles + +On Dolt, MySQL and MariaDB the server returns positive zero for a negative-zero +parameter. On these profiles negative zero MAY therefore be a declared refusal +before mutation, like NaN and the infinities. In the Dolt boundary matrix the +`negative_zero` case MAY declare `reject_before_mutation` instead of +`accept_bit_exact_round_trip`; [`../sql/dialect-profiles.md`](../sql/dialect-profiles.md) +and the declaration validator accept either. On every profile the special +numeric value rules of the SAV/ZSAV section apply. + +## Informative notes kept informative + +The remaining informative notes published in `v0.5.1` stay informative: +quoting every identifier as one way to meet the reserved-word preflight, the +string create-target width note of the in-place bindings, the Dolt +completion-check runner note, and the implementation-declared MySQL, MariaDB +and Dolt catalog column types. + +## Traceability + +Each supplement case names the rulings it covers in its `rulings` key. + +| Issue #27 item | Ruling key | Section | Supplement coverage | +| --- | --- | --- | --- | +| 4 | `4` | Request validation | Frontend 0.1, 0.2, 0.3 | +| 5 | `5` | RECODE diagnostics | Frontend 0.1 | +| 6 | `6` | Command termination and comments | Frontend 0.1, 0.3 | +| 7 | `7` | Names | Frontend 0.1, 0.2 | +| 0.1 boundary | `0.1-boundary` | Profile boundary | Frontend 0.1 | +| 8 | `8` | Frontend 0.3 | Frontend 0.3 | +| 9 | `9` | Frontend 0.2 and 0.3 | Frontend 0.2, 0.3 | +| 11 | `11` | Frontend 0.2 | Frontend 0.2, 0.3 | +| 17 | `17` | Transformation Plan 0.1 and 0.2 | Plan 0.1, 0.2 | +| 18 | `18` | RECODE diagnostics, Plan 0.1, In-place binding | Frontend 0.1, Plan 0.1, In-place 0.1 | +| 20 | `20` | Frontend 0.2 and 0.3, Plan 0.2 | Frontend 0.2, 0.3, Plan 0.2 | +| 13 | `13` | Identity values | SAV/ZSAV 1.0 | +| 14 | `14` | Attributes | SAV/ZSAV 1.0 | +| 16 | `16` | Vocabularies | SAV/ZSAV 1.0 | +| 21 | `21` | Special numeric values | SAV/ZSAV 1.0 (generated fixtures) | +| 23 | `23` | SQL dialect profiles | SAV/ZSAV 1.0 (generated fixture), Dolt declaration validator | +| 25 | `25` | Physical table schema | SAV/ZSAV 1.0, In-place 0.1 | +| 1, 2, 3, 10, 15 | `recode-diagnostics`, `lowest-highest-endpoints` | RECODE diagnostics, Missing-value endpoints | Frontend 0.1, 0.2, 0.3, SAV/ZSAV 1.0 | +| Found while verifying | `arithmetic-in-if` | Frontend 0.2 | Frontend 0.2, 0.3 | +| Found while verifying | `abbreviations` | Profile boundary | Frontend 0.1, 0.3 | +| 19, 22, 26, 27, 29 | none | Informative notes kept informative | none | diff --git a/docs/spss-sav-zsav-profile-1.0.md b/docs/spss-sav-zsav-profile-1.0.md index 909eaa7..304adb5 100644 --- a/docs/spss-sav-zsav-profile-1.0.md +++ b/docs/spss-sav-zsav-profile-1.0.md @@ -1,5 +1,7 @@ # SPSS SAV/ZSAV Profile 1.0 +Implementation claims that pin OpenStatSpec `v0.6.0` or later also follow the normative [Conformance Supplement 0.6](conformance-supplement-0.6.md). + ## Status and conformance language This is a versioned normative profile for unencrypted IBM SPSS Statistics system files: SAV and ZSAV. Terms **MUST**, **MUST NOT**, **SHOULD**, **SHOULD NOT**, and **MAY** are normative. diff --git a/docs/spss-syntax-frontend-profile-0.1.md b/docs/spss-syntax-frontend-profile-0.1.md index e7ead11..948ebfe 100644 --- a/docs/spss-syntax-frontend-profile-0.1.md +++ b/docs/spss-syntax-frontend-profile-0.1.md @@ -1,5 +1,7 @@ # OpenStatSpec SPSS-like Syntax Frontend Profile 0.1 +Implementation claims that pin OpenStatSpec `v0.6.0` or later also follow the normative [Conformance Supplement 0.6](conformance-supplement-0.6.md). + ## Status and boundary This optional frontend profile maps a deliberately small SPSS-like command diff --git a/docs/spss-syntax-frontend-profile-0.2.md b/docs/spss-syntax-frontend-profile-0.2.md index 2e05cfa..0421f25 100644 --- a/docs/spss-syntax-frontend-profile-0.2.md +++ b/docs/spss-syntax-frontend-profile-0.2.md @@ -1,5 +1,7 @@ # OpenStatSpec SPSS-like Syntax Frontend Profile 0.2 +Implementation claims that pin OpenStatSpec `v0.6.0` or later also follow the normative [Conformance Supplement 0.6](conformance-supplement-0.6.md). + ## Status and boundary Status: released in OpenStatSpec `v0.3.0` at immutable specification commit diff --git a/docs/spss-syntax-frontend-profile-0.3.md b/docs/spss-syntax-frontend-profile-0.3.md index 6808896..f8825a2 100644 --- a/docs/spss-syntax-frontend-profile-0.3.md +++ b/docs/spss-syntax-frontend-profile-0.3.md @@ -1,5 +1,7 @@ # OpenStatSpec SPSS-like Syntax Frontend Profile 0.3 +Implementation claims that pin OpenStatSpec `v0.6.0` or later also follow the normative [Conformance Supplement 0.6](conformance-supplement-0.6.md). + ## Status and boundary Status: released in OpenStatSpec `v0.4.0`. The protected specification tag is diff --git a/docs/transformation-plan-profile-0.1.md b/docs/transformation-plan-profile-0.1.md index 78e072b..7f76f59 100644 --- a/docs/transformation-plan-profile-0.1.md +++ b/docs/transformation-plan-profile-0.1.md @@ -1,5 +1,7 @@ # OpenStatSpec Transformation Plan Profile 0.1 +Implementation claims that pin OpenStatSpec `v0.6.0` or later also follow the normative [Conformance Supplement 0.6](conformance-supplement-0.6.md). + ## Status and scope This optional profile defines a canonical, dialect-neutral transformation plan. diff --git a/docs/transformation-plan-profile-0.2.md b/docs/transformation-plan-profile-0.2.md index 2340ee1..3c56df9 100644 --- a/docs/transformation-plan-profile-0.2.md +++ b/docs/transformation-plan-profile-0.2.md @@ -1,5 +1,7 @@ # OpenStatSpec Transformation Plan Profile 0.2 +Implementation claims that pin OpenStatSpec `v0.6.0` or later also follow the normative [Conformance Supplement 0.6](conformance-supplement-0.6.md). + ## Status and scope Status: released in OpenStatSpec `v0.3.0` at immutable specification commit diff --git a/docs/transformation-plan-sql-binding-0.1.md b/docs/transformation-plan-sql-binding-0.1.md index 2d5a3bf..b118b57 100644 --- a/docs/transformation-plan-sql-binding-0.1.md +++ b/docs/transformation-plan-sql-binding-0.1.md @@ -1,5 +1,7 @@ # In-Place Transformation Binding 0.1 +Implementation claims that pin OpenStatSpec `v0.6.0` or later also follow the normative [Conformance Supplement 0.6](conformance-supplement-0.6.md). + ## Normative decision This binding applies an OpenStatSpec Transformation Plan 0.1 to one existing diff --git a/docs/transformation-plan-sql-binding-0.2.md b/docs/transformation-plan-sql-binding-0.2.md index f7c7d8d..e82c173 100644 --- a/docs/transformation-plan-sql-binding-0.2.md +++ b/docs/transformation-plan-sql-binding-0.2.md @@ -1,5 +1,7 @@ # In-Place Transformation Binding 0.2 +Implementation claims that pin OpenStatSpec `v0.6.0` or later also follow the normative [Conformance Supplement 0.6](conformance-supplement-0.6.md). + ## Status Status: released in OpenStatSpec `v0.3.0` at immutable specification commit diff --git a/pyproject.toml b/pyproject.toml index e4f844a..dfd9cac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "openstatspec-specification" -version = "0.1.0" +version = "0.2.0" description = "Installable OpenStatSpec specification resources and semantic validators" readme = "README.md" requires-python = ">=3.11" diff --git a/sql/dialect-profiles.md b/sql/dialect-profiles.md index 6a42afb..3176a30 100644 --- a/sql/dialect-profiles.md +++ b/sql/dialect-profiles.md @@ -103,6 +103,11 @@ policy that cannot collide through folding. | Row/value boundary | InnoDB row-size and LOB limits; the adapter MUST publish and preflight its effective boundary. | | Atomicity | InnoDB DDL may cause implicit commits. Complete all preflight first and provide compensating cleanup for every created catalog/table object on failure. | +On MySQL and MariaDB negative zero MAY be a declared refusal before mutation, +like NaN and the infinities, because the server returns positive zero for a +negative-zero parameter; see the +[Conformance Supplement 0.6](../docs/conformance-supplement-0.6.md). + The profile applies only when all OpenStatSpec catalog and data tables use an engine with the declared behavior. An adapter MUST reject a non-transactional or incompatible storage configuration rather than claiming atomic import. @@ -238,12 +243,16 @@ The matrix requires: 3. introspected `LONGTEXT NOT NULL`; empty and UTF-8 byte-exact round trips; rejected SQL NULL; successful encoded 65,535- and 65,536-byte probes; acceptance at `V - 1` and `V`, and rejection before mutation at `V + 1`; -4. bit-exact round trips for signed zero, subnormal boundaries, the minimum +4. bit-exact round trips for positive zero, subnormal boundaries, the minimum normal, maximum finite, and representative ordinary finite values; semantic SPSS system-missing round trip through SQL NULL; and an explicit policy for each of NaN, positive infinity, and negative infinity. This template selects rejection before mutation for all three exceptional classes, so they cannot - collide with the SQL-NULL system-missing representation; + collide with the SQL-NULL system-missing representation. Negative zero + either round trips bit-exactly or, because the server returns positive zero + for a negative-zero parameter, is a declared rejection before mutation + (`reject_before_mutation`), as the + [Conformance Supplement 0.6](../docs/conformance-supplement-0.6.md) permits; 5. exactly one structural-row variant in a concrete declaration: numeric `R - 1`/`R` acceptance with `R + 1` rejection, or the structured version-specific not-applicable proof; diff --git a/src/openstatspec_specification/artifacts.py b/src/openstatspec_specification/artifacts.py index d9e200f..11094d7 100644 --- a/src/openstatspec_specification/artifacts.py +++ b/src/openstatspec_specification/artifacts.py @@ -3,7 +3,7 @@ import hashlib import json from copy import deepcopy -from dataclasses import dataclass +from dataclasses import dataclass, field from pathlib import Path, PurePosixPath from typing import Mapping @@ -24,16 +24,73 @@ "0.1": "conformance/in-place-transformation-0.1.json", "0.2": "conformance/in-place-transformation-0.2.json", } +SUPPLEMENT_DOCUMENT = "docs/conformance-supplement-0.6.md" +PLAN_SUPPLEMENTS = { + "0.1": "conformance/transformation-plan-0.1-supplement-1.json", + "0.2": "conformance/transformation-plan-0.2-supplement-1.json", +} +FRONTEND_SUPPLEMENTS = { + "0.1": "conformance/spss-syntax-frontend-0.1-supplement-1.json", + "0.2": "conformance/spss-syntax-frontend-0.2-supplement-1.json", + "0.3": "conformance/spss-syntax-frontend-0.3-supplement-1.json", +} +BINDING_SUPPLEMENTS = {"0.1": "conformance/in-place-transformation-0.1-supplement-1.json"} +SAV_MANIFEST = "conformance/spss-sav-zsav-1.0.json" +SAV_SUPPLEMENT = "conformance/spss-sav-zsav-1.0-supplement-1.json" +# Every ruling of the v0.6.0 decision record that a supplement case covers. +SUPPLEMENT_RULINGS = frozenset({ + "4", "5", "6", "7", "0.1-boundary", "8", "9", "11", "13", "14", "16", "17", "18", + "20", "21", "23", "25", "recode-diagnostics", "lowest-highest-endpoints", + "arithmetic-in-if", "abbreviations", +}) +RUNNER_GENERATED_SAV_FIXTURES = frozenset({"fixtures/negative-zero.sav", "fixtures/nan.sav"}) +SAV_SUPPLEMENT_CATALOG_KEYS = { + "dataset_spec_version": "dataset", + "catalog_schema_version": "catalog_identity", + "measurement_level_vocabulary": "variables", + "variable_role_vocabulary": "variables", + "display_alignment_vocabulary": "variables", + "category_label_behavior_vocabulary": "multiple_response_sets", + "label_source_vocabulary": "multiple_response_sets", + "attribute_export_order": "dataset_attribute_export_order", + "lowest_highest_null_endpoints": "missing_rules", +} +CATALOG_VOCABULARIES = { + "measurement_level": {"nominal", "ordinal", "scale"}, + "variable_role": {"input", "target", "both", "none", "partition", "split"}, + "display_alignment": {"left", "right", "center"}, + "category_label_behavior": {"variable_labels", "counted_values"}, + "label_source": {"set_label", "variable_label"}, +} V030_COMMIT = "cd8f198c68b849eb8ed018a894670a0904c2181d" V040_RELEASE = "v0.4.0" V041_RELEASE = "v0.4.1" -CURRENT_RELEASE = "v0.5.1" +V051_RELEASE = "v0.5.1" +CURRENT_RELEASE = "v0.6.0" V030_PROFILE_DOCUMENTS = ( "docs/transformation-plan-profile-0.2.md", "docs/spss-syntax-frontend-profile-0.2.md", "docs/transformation-plan-sql-binding-0.2.md", ) FRONTEND_03_PROFILE_DOCUMENT = "docs/spss-syntax-frontend-profile-0.3.md" +# Published manifests and schemas stay byte-identical; later rulings go to supplements. +PUBLISHED_ARTIFACT_SHA256 = { + "conformance/in-place-transformation-0.1.json": "18efa223da1901b10265862e9a2e828b8ac73fb9aaa1d497e2d0eed8fcdeaa2f", + "conformance/in-place-transformation-0.2.json": "80f747e1b036f1070fdadd4a7539f3aa013134210c88e92465445e1d3b61d67e", + "conformance/spss-sav-zsav-1.0.json": "4e504b0fcdfa48d22ae7b03a317ee122aac506561da8ccfddde6a2b5e7d43da2", + "conformance/spss-syntax-frontend-0.1.json": "2b122cc7c17bca2d3ebb429e608b869880e878f8cd72dd0526ad7c629d05cb03", + "conformance/spss-syntax-frontend-0.2.json": "ae25501cee13636d6bf668b29309ce0344518676714f237a4a52a04613d91ba3", + "conformance/spss-syntax-frontend-0.3.json": "295d12cb786ea5dcb0ba761136b0a9b6ad2533748f2cf071ea69c8612b113c98", + "conformance/sql-transformation-workflow-0.1.json": "662e45c82000599e43597aedfd1340cd20b823c97dfa7df2fd6c272c6e343c99", + "conformance/transformation-plan-0.1.json": "7625ffcb18b809269de25e58475efd260859167803f11551467a7c40736593cf", + "conformance/transformation-plan-0.2.json": "fa278e33d4bebc0da127b57b19917dc922a769d0e2738079ee3e6a90603636a5", + "transformation/plan-0.1.schema.json": "9d93de41ba3d9ca1877976c194f68a045e3b75f45c46cad11ac6d63a076b04d2", + "transformation/plan-0.2.schema.json": "953da8b1302e3b4299514c73afed56a4bb074cfedddcdac70ae697762a038394", + "transformation/spss-syntax-frontend-0.1.schema.json": "d80ed76293b2f0f4d916a91741377416e7b8b4df025b5dfb2fb58cfadf9b1081", + "transformation/spss-syntax-frontend-0.2.schema.json": "eb0c4092b384dedbc2c0f47a604f0a112354c157b14fb18cd10033b6102b2a26", + "transformation/spss-syntax-frontend-0.3.schema.json": "57e8285311d39c9e6958cdd00a9cfd815e02a36cf30bafaaa28d4cef52983f20", + "sql/schema-outline.sql": "22715708b47e1b4f9bd659e5ac89c45b9cdabdf1576cd823f4ddbeaf43f36aff", +} class ArtifactValidationError(ValueError): @@ -46,6 +103,7 @@ class ArtifactInventory: frontend_declared_cases: Mapping[str, int] frontend_effective_cases: Mapping[str, int] binding_cases: Mapping[str, int] + supplement_cases: Mapping[str, int] = field(default_factory=dict) def canonical_json_bytes(value: object) -> bytes: @@ -131,6 +189,24 @@ def _load_text(root: Path, relative: str) -> str: ) from None +def validate_published_artifacts(root: Path) -> None: + """Fail when a published manifest, schema or the schema outline changed.""" + for relative, expected in PUBLISHED_ARTIFACT_SHA256.items(): + candidate = _safe_candidate(root, relative) + try: + _require(candidate.is_file(), f"artifact is missing: {relative}") + # Hash the LF form so a CRLF checkout (core.autocrlf) verifies the same bytes. + content = candidate.read_bytes().replace(b"\r\n", b"\n") + except OSError as error: + raise ArtifactValidationError( + f"artifact cannot be read: {relative} ({type(error).__name__})" + ) from None + _require( + _sha256(content) == expected, + f"{relative}: published artifact changed; publish later rulings in a supplement", + ) + + def _require_file(root: Path, relative: str) -> None: candidate = _safe_candidate(root, relative) try: @@ -231,11 +307,12 @@ def _validate_plan_manifests( root: Path, manifests: Mapping[str, Mapping[str, object]], schema_map: dict[str, Mapping[str, object]], + paths: Mapping[str, str] = PLAN_MANIFESTS, ) -> Mapping[str, Mapping[str, object]]: """Return version -> case-id -> successful canonical plan case.""" successful: dict[str, Mapping[str, object]] = {} for version, manifest in manifests.items(): - manifest_relative = PLAN_MANIFESTS[version] + manifest_relative = paths[version] schema_reference = manifest.get("schema") _require( isinstance(schema_reference, str), @@ -628,9 +705,10 @@ def _validate_binding_manifests( plan_cases: Mapping[str, Mapping[str, object]], frontend_plans: Mapping[str, Mapping[str, Mapping[str, object]]], frontend_manifests: Mapping[str, Mapping[str, object]], + paths: Mapping[str, str] = BINDING_MANIFESTS, ) -> None: for version, manifest in manifests.items(): - manifest_relative = BINDING_MANIFESTS[version] + manifest_relative = paths[version] cases = manifest.get("cases") _require(isinstance(cases, list), f"{manifest_relative}: cases must be a list") for index, case in enumerate(cases): @@ -722,6 +800,249 @@ def _require_exact_field(value: object, expected: object, context: str) -> None: _require(value == expected, f"{context}: has an unexpected value") +def _lowercase_name(name: str) -> str: + # Per-code-point mapping; str.lower() on a whole string would apply Final_Sigma. + return "".join(character.lower() for character in name) + + +def _request_semantically_invalid(request: Mapping[str, object]) -> bool: + """A schema-valid request the supplement still refuses with request_schema_invalid.""" + variables = request["input_schema"]["variables"] + names = [_lowercase_name(variable["name"]) for variable in variables] + return len(names) != len(set(names)) or any( + variable["storage_kind"] == "string" + and any(label["value"]["type"] == "binary64" for label in variable.get("value_labels", [])) + for variable in variables + ) + + +def _load_supplement( + root: Path, + relative: str, + version: str, + contract: str | None, + base_relative: str, +) -> dict[str, object]: + value = _load_json(root, relative) + _require(isinstance(value, dict), f"{relative}: manifest must be an object") + _require(value.get("manifest_version") == version, f"{relative}: manifest_version must be {version}") + _require(value.get("contract") == contract, f"{relative}: contract must be {contract}") + _require( + value.get("supplement_to") == PurePosixPath(base_relative).name, + f"{relative}: supplement_to must name {base_relative}", + ) + document = value.get("supplement_document") + _require( + isinstance(document, str) + and _resolve_manifest_reference(relative, document) == SUPPLEMENT_DOCUMENT, + f"{relative}: supplement_document must name {SUPPLEMENT_DOCUMENT}", + ) + _require_file(root, SUPPLEMENT_DOCUMENT) + _require("inherited_manifests" not in value, f"{relative}: a supplement inherits no cases") + return value + + +def _case_rulings(case: Mapping[str, object], context: str) -> set[str]: + rulings = case.get("rulings") + _require( + isinstance(rulings, list) + and bool(rulings) + and len(rulings) == len(set(rulings)) + and all(ruling in SUPPLEMENT_RULINGS for ruling in rulings), + f"{context}: rulings must be a non-empty list of known supplement rulings", + ) + return set(rulings) + + +def _validate_frontend_supplement( + root: Path, + version: str, + manifest: Mapping[str, object], + base_manifest: Mapping[str, object], + schema_map: dict[str, Mapping[str, object]], +) -> set[str]: + relative = FRONTEND_SUPPLEMENTS[version] + for key in ("request_schema", "plan_contract", "plan_schema", "plan_contracts", "plan_schemas"): + _require_exact_field(manifest.get(key), base_manifest.get(key), f"{relative}: {key}") + request_schema = _schema( + root, _resolve_manifest_reference(relative, manifest["request_schema"]), schema_map + ) + plan_schemas = _frontend_plan_schemas(root, version, manifest, schema_map) + plan_fields = ("expected_plan", "expected_plan_0_1") + rulings: set[str] = set() + for index, case in enumerate(manifest["cases"]): + context = f"{relative}.cases[{index}]" + rulings |= _case_rulings(case, context) + expected_error = _expected_error(case, context) + request = case.get("request") + _require(isinstance(request, dict), f"{context}.request: must be an object") + source_text = request.get("source_text") + _require( + isinstance(source_text, str) and case.get("expected_source_hash") == source_hash(source_text), + f"{context}: source hash mismatch", + ) + if not _schema_is_valid(request, request_schema): + _require( + expected_error == "request_schema_invalid", + f"{context}.request: schema-invalid request must expect request_schema_invalid", + ) + elif _request_semantically_invalid(request): + _require( + expected_error == "request_schema_invalid", + f"{context}.request: duplicate names or a numeric label on a string variable " + "must expect request_schema_invalid", + ) + elif expected_error == "request_schema_invalid": + _require( + _request_semantically_invalid(request), + f"{context}: request_schema_invalid needs a schema-invalid request, " + "duplicate names or a numeric label on a string variable", + ) + for field in ("expected_plan_case", "expected_plan_case_0_1"): + _require(field not in case, f"{context}: a supplement case must not reference {field}") + if expected_error is not None: + for field in (*plan_fields, "expected_plan_contract", "expected_plan_hash"): + _require(field not in case, f"{context}: failing case must omit {field}") + continue + present = [field for field in plan_fields if field in case] + _require(len(present) == 1, f"{context}: successful case must declare exactly one inline plan") + plan = case[present[0]] + _require(isinstance(plan, dict), f"{context}.{present[0]}: must be an object") + contract = plan.get("contract") + _require( + isinstance(contract, str) and contract in plan_schemas, + f"{context}: unsupported expected plan contract", + ) + _require( + present[0] == "expected_plan" or contract == "openstatspec-transformation-plan-v0.1", + f"{context}: expected_plan_0_1 must hold a Plan 0.1 object", + ) + try: + Draft202012Validator(plan_schemas[contract]).validate(plan) + except ValidationError as error: + raise ArtifactValidationError( + f"{context}: expected plan schema validation failed: {error.message}" + ) from None + _require( + case.get("expected_plan_contract", contract) == contract, + f"{context}: expected_plan_contract does not match plan", + ) + _require( + case.get("expected_plan_hash") == _sha256(canonical_json_bytes(plan)), + f"{context}: plan hash mismatch", + ) + return rulings + + +def _validate_sav_supplement(root: Path) -> tuple[int, set[str]]: + manifest = _load_supplement(root, SAV_SUPPLEMENT, "1.0", None, SAV_MANIFEST) + fixtures = manifest.get("fixtures") + _require(isinstance(fixtures, list) and bool(fixtures), f"{SAV_SUPPLEMENT}: fixtures must be a non-empty list") + readme = _load_text(root, "conformance/fixtures/README.md") + seen: set[str] = set() + rulings: set[str] = set() + for index, fixture in enumerate(fixtures): + context = f"{SAV_SUPPLEMENT}.fixtures[{index}]" + _require(isinstance(fixture, dict), f"{context}: must be an object") + identifier = fixture.get("id") + _require( + isinstance(identifier, str) and bool(identifier) and identifier not in seen, + f"{context}: id must be a unique non-empty string", + ) + seen.add(identifier) + rulings |= _case_rulings(fixture, context) + for key, allowed in (("directions", {"import", "export", "semantic_round_trip"}), ("expects", None)): + values = fixture.get(key) + _require( + isinstance(values, list) + and bool(values) + and len(values) == len(set(values)) + and all(isinstance(value, str) and value and (allowed is None or value in allowed) for value in values), + f"{context}: {key} must be a non-empty list of unique known strings", + ) + source = fixture.get("source") + _require(isinstance(source, str), f"{context}: source must be a string") + resolved = _resolve_manifest_reference(SAV_SUPPLEMENT, source) + if source in RUNNER_GENERATED_SAV_FIXTURES: + _require( + not _safe_candidate(root, resolved).exists(), + f"{context}: a runner-generated fixture must not be committed", + ) + _require(PurePosixPath(source).name in readme, f"{context}: fixtures/README.md must describe {source}") + else: + _require_file(root, resolved) + catalog = fixture.get("expected_catalog", {}) + _require(isinstance(catalog, dict), f"{context}.expected_catalog: must be an object") + for expectation in fixture["expects"]: + key = SAV_SUPPLEMENT_CATALOG_KEYS.get(expectation) + _require(key is None or key in catalog, f"{context}: {expectation} requires expected_catalog.{key}") + entries = [*catalog.get("variables", []), *catalog.get("multiple_response_sets", [])] + _require(all(isinstance(entry, dict) for entry in entries), f"{context}: catalog entries must be objects") + for entry in entries: + for column, allowed in CATALOG_VOCABULARIES.items(): + _require( + column not in entry or entry[column] in allowed, + f"{context}: {column} value is outside its vocabulary", + ) + return len(fixtures), rulings + + +def _validate_supplements( + root: Path, + frontend_manifests: Mapping[str, Mapping[str, object]], + schema_map: dict[str, Mapping[str, object]], +) -> Mapping[str, int]: + counts: dict[str, int] = {} + rulings: set[str] = set() + + plan_supplements = { + version: _load_supplement( + root, relative, version, f"openstatspec-transformation-plan-v{version}", PLAN_MANIFESTS[version] + ) + for version, relative in PLAN_SUPPLEMENTS.items() + } + for version, manifest in plan_supplements.items(): + _require_unique_case_ids(manifest, PLAN_SUPPLEMENTS[version]) + _require_exact_field( + manifest.get("schema"), + f"../transformation/plan-{version}.schema.json", + f"{PLAN_SUPPLEMENTS[version]}: schema", + ) + for index, case in enumerate(manifest["cases"]): + rulings |= _case_rulings(case, f"{PLAN_SUPPLEMENTS[version]}.cases[{index}]") + counts[f"plan-{version}"] = len(manifest["cases"]) + _validate_plan_manifests(root, plan_supplements, schema_map, PLAN_SUPPLEMENTS) + + for version, relative in FRONTEND_SUPPLEMENTS.items(): + manifest = _load_supplement( + root, relative, version, f"openstatspec-spss-syntax-frontend-v{version}", FRONTEND_MANIFESTS[version] + ) + _require_unique_case_ids(manifest, relative) + rulings |= _validate_frontend_supplement( + root, version, manifest, frontend_manifests[version], schema_map + ) + counts[f"frontend-{version}"] = len(manifest["cases"]) + + binding_supplements = { + version: _load_supplement( + root, relative, version, f"openstatspec-in-place-transformation-v{version}", BINDING_MANIFESTS[version] + ) + for version, relative in BINDING_SUPPLEMENTS.items() + } + for version, manifest in binding_supplements.items(): + _require_unique_case_ids(manifest, BINDING_SUPPLEMENTS[version]) + for index, case in enumerate(manifest["cases"]): + rulings |= _case_rulings(case, f"{BINDING_SUPPLEMENTS[version]}.cases[{index}]") + counts[f"binding-{version}"] = len(manifest["cases"]) + _validate_binding_manifests(binding_supplements, {}, {}, {}, BINDING_SUPPLEMENTS) + + counts["sav-1.0"], sav_rulings = _validate_sav_supplement(root) + rulings |= sav_rulings + missing = sorted(SUPPLEMENT_RULINGS - rulings) + _require(not missing, f"supplement manifests cover no case for rulings: {', '.join(missing)}") + return counts + + def validate_release_metadata(root: Path) -> None: for relative in V030_PROFILE_DOCUMENTS: text = " ".join(_load_text(root, relative).split()) @@ -775,8 +1096,14 @@ def validate_release_metadata(root: Path) -> None: "CHANGELOG v0.4.1 release entry is missing", ) _require( - f"## {CURRENT_RELEASE} - 2026-11-21" in changelog - and f"OpenStatSpec `{CURRENT_RELEASE}` is a documentation patch." in changelog, + f"## {V051_RELEASE} - 2026-11-21" in changelog + and f"OpenStatSpec `{V051_RELEASE}` is a documentation patch." in changelog, + f"CHANGELOG {V051_RELEASE} release entry is missing", + ) + _require( + f"## {CURRENT_RELEASE} - 2026-12-01" in changelog + and f"OpenStatSpec `{CURRENT_RELEASE}` is a minor release." in changelog + and "claims pinned to earlier releases stay valid" in changelog, f"CHANGELOG {CURRENT_RELEASE} release entry is missing", ) readme = " ".join(_load_text(root, "README.md").split()) @@ -928,6 +1255,8 @@ def validate_contract_artifacts(root: Path) -> ArtifactInventory: frontend_manifests, ) + supplement_cases = _validate_supplements(root, frontend_manifests, schema_map) + return ArtifactInventory( plan_cases={version: len(manifest["cases"]) for version, manifest in plan_manifests.items()}, frontend_declared_cases={ @@ -942,4 +1271,5 @@ def validate_contract_artifacts(root: Path) -> ArtifactInventory: version: len(manifest["cases"]) for version, manifest in binding_manifests.items() }, + supplement_cases=supplement_cases, ) diff --git a/src/openstatspec_specification/dolt.py b/src/openstatspec_specification/dolt.py index 3d09dbc..4aa1e2d 100644 --- a/src/openstatspec_specification/dolt.py +++ b/src/openstatspec_specification/dolt.py @@ -950,6 +950,8 @@ def validate_boundary_cases( require(set(case_ids) == set(expected_cases), f"{context} case IDs are incomplete.") for case in case_group: expected_measurement, expected_unit, expected_result = expected_cases[case["id"]] + # A tuple lists the results a declaration may select for this case. + allowed_results = expected_result if isinstance(expected_result, tuple) else (expected_result,) if concrete_declaration: expected_unit = { "declared_identifier_unit": records_by_dimension["identifier"]["effective"]["unit"], @@ -957,7 +959,8 @@ def validate_boundary_cases( "declared_structural_row_unit": records_by_dimension["structural_row"]["effective"]["unit"], }.get(expected_unit, expected_unit) require( - (case["measurement"], case["unit"], case["expected"]) == (expected_measurement, expected_unit, expected_result), + (case["measurement"], case["unit"]) == (expected_measurement, expected_unit) + and case["expected"] in allowed_results, f"{context}.{case['id']} expected result, concrete unit, or measurement is incorrect.", ) exact_versions = validate_exact_versions( @@ -1038,7 +1041,8 @@ def validate_boundary_cases( boundary["double_cases"], { "positive_zero": ("ieee_754_binary64", "64_bit_pattern", "accept_bit_exact_round_trip"), - "negative_zero": ("ieee_754_binary64", "64_bit_pattern", "accept_bit_exact_round_trip"), + # Conformance Supplement 0.6: the server returns +0 for -0, so a declared refusal is allowed. + "negative_zero": ("ieee_754_binary64", "64_bit_pattern", ("accept_bit_exact_round_trip", "reject_before_mutation")), "minimum_positive_subnormal": ("ieee_754_binary64", "64_bit_pattern", "accept_bit_exact_round_trip"), "maximum_subnormal": ("ieee_754_binary64", "64_bit_pattern", "accept_bit_exact_round_trip"), "minimum_normal": ("ieee_754_binary64", "64_bit_pattern", "accept_bit_exact_round_trip"), diff --git a/tests/test_contract_artifacts.py b/tests/test_contract_artifacts.py index 7703f16..0df0118 100644 --- a/tests/test_contract_artifacts.py +++ b/tests/test_contract_artifacts.py @@ -12,10 +12,20 @@ from openstatspec_specification.artifacts import canonical_json_bytes from openstatspec_specification.artifacts import validate_release_metadata from openstatspec_specification.artifacts import validate_contract_artifacts +from openstatspec_specification.artifacts import validate_published_artifacts from openstatspec_specification.artifacts import source_hash ROOT = Path(__file__).resolve().parents[1] +SUPPLEMENT_CASES = { + "plan-0.1": 2, + "plan-0.2": 2, + "frontend-0.1": 16, + "frontend-0.2": 14, + "frontend-0.3": 14, + "binding-0.1": 1, + "sav-1.0": 9, +} def test_frontend_03_final_inventory() -> None: @@ -30,6 +40,7 @@ def test_released_contract_artifact_inventory_is_valid() -> None: assert inventory.frontend_declared_cases == {"0.1": 13, "0.2": 44, "0.3": 35} assert inventory.frontend_effective_cases == {"0.1": 13, "0.2": 44, "0.3": 90} assert inventory.binding_cases == {"0.1": 6, "0.2": 11} + assert inventory.supplement_cases == SUPPLEMENT_CASES def test_frontend_03_request_schema_is_registered() -> None: @@ -270,3 +281,79 @@ def test_superseded_replacement_must_keep_request_identity(tmp_path: Path) -> No path.write_text(json.dumps(manifest), encoding="utf-8") with pytest.raises(ArtifactValidationError, match="superseded case request mismatch"): validate_contract_artifacts(root) + + +def test_published_artifacts_are_unchanged() -> None: + validate_published_artifacts(ROOT) + + +@pytest.mark.parametrize( + "relative", + ["conformance/spss-syntax-frontend-0.3.json", "transformation/plan-0.1.schema.json", "sql/schema-outline.sql"], +) +def test_changed_published_artifact_fails_closed(tmp_path: Path, relative: str) -> None: + root = copied_artifacts(tmp_path) + path = root / relative + path.write_bytes(path.read_bytes() + b" ") + with pytest.raises(ArtifactValidationError, match="published artifact changed"): + validate_published_artifacts(root) + + +def _edit_supplement(root: Path, name: str, case_id: str, edit) -> None: + path = root / "conformance" / name + manifest = json.loads(path.read_text(encoding="utf-8")) + cases = manifest.get("cases", manifest.get("fixtures")) + edit(next(case for case in cases if case["id"] == case_id)) + path.write_text(json.dumps(manifest), encoding="utf-8") + + +def test_schema_invalid_request_must_expect_request_schema_invalid(tmp_path: Path) -> None: + root = copied_artifacts(tmp_path) + _edit_supplement( + root, "spss-syntax-frontend-0.1-supplement-1.json", "reject-request-schema-violation", + lambda case: case.update(expected_error="spss_syntax_error"), + ) + with pytest.raises(ArtifactValidationError, match="must expect request_schema_invalid"): + validate_contract_artifacts(root) + + +@pytest.mark.parametrize("names", [("q1", "q2"), ("stra\u00dfe", "STRASSE")]) +def test_request_schema_invalid_needs_an_invalid_request(tmp_path: Path, names: tuple[str, str]) -> None: + root = copied_artifacts(tmp_path) + + def edit(case: dict) -> None: + for variable, name in zip(case["request"]["input_schema"]["variables"], names): + variable["name"] = name + + _edit_supplement( + root, "spss-syntax-frontend-0.1-supplement-1.json", "reject-case-insensitive-duplicate-names", edit, + ) + with pytest.raises(ArtifactValidationError, match="request_schema_invalid needs"): + validate_contract_artifacts(root) + + +def test_supplement_plan_hash_mismatch_fails_closed(tmp_path: Path) -> None: + root = copied_artifacts(tmp_path) + _edit_supplement( + root, "spss-syntax-frontend-0.3-supplement-1.json", "slash-separated-recode-groups", + lambda case: case.update(expected_plan_hash="0" * 64), + ) + with pytest.raises(ArtifactValidationError, match="plan hash mismatch"): + validate_contract_artifacts(root) + + +def test_every_ruling_needs_a_supplement_case(tmp_path: Path) -> None: + root = copied_artifacts(tmp_path) + _edit_supplement( + root, "spss-syntax-frontend-0.1-supplement-1.json", "reject-else-only-recode", + lambda case: case.update(rulings=["recode-diagnostics"]), + ) + with pytest.raises(ArtifactValidationError, match="rulings: 5"): + validate_contract_artifacts(root) + + +def test_runner_generated_fixture_must_not_be_committed(tmp_path: Path) -> None: + root = copied_artifacts(tmp_path) + (root / "conformance/fixtures/negative-zero.sav").write_bytes(b"$FL2") + with pytest.raises(ArtifactValidationError, match="must not be committed"): + validate_contract_artifacts(root) diff --git a/tests/test_dolt_declarations.py b/tests/test_dolt_declarations.py index ff36e75..32e8504 100644 --- a/tests/test_dolt_declarations.py +++ b/tests/test_dolt_declarations.py @@ -368,3 +368,42 @@ def fail_is_symlink(path: Path) -> bool: monkeypatch.setattr(Path, "is_symlink", fail_is_symlink) _assert_sanitized_io_error(source.declaration_resources) + + +def _baseline_dolt() -> dict: + return copy.deepcopy(json.loads( + (REPOSITORY_ROOT / "sql/dialect-profile-baseline.json").read_text(encoding="utf-8") + )["profiles"]["dolt"]) + + +@pytest.mark.parametrize( + ("expected", "valid"), + [("accept_bit_exact_round_trip", True), ("reject_before_mutation", True), ("accept", False)], +) +def test_negative_zero_may_be_a_declared_refusal(expected: str, valid: bool) -> None: + declaration = _baseline_dolt() + case = next( + case for case in declaration["boundary_conformance"]["double_cases"] + if case["id"] == "negative_zero" + ) + case["expected"] = expected + source = DoltDeclarationSource.from_directory(REPOSITORY_ROOT) + if valid: + validate_dolt_declaration(declaration, "synthetic negative zero", source=source) + else: + with pytest.raises(DoltDeclarationError, match="negative_zero expected result"): + validate_dolt_declaration(declaration, "synthetic negative zero", source=source) + + +def test_positive_zero_refusal_stays_invalid() -> None: + declaration = _baseline_dolt() + case = next( + case for case in declaration["boundary_conformance"]["double_cases"] + if case["id"] == "positive_zero" + ) + case["expected"] = "reject_before_mutation" + with pytest.raises(DoltDeclarationError, match="positive_zero expected result"): + validate_dolt_declaration( + declaration, "synthetic positive zero", + source=DoltDeclarationSource.from_directory(REPOSITORY_ROOT), + ) diff --git a/tools/validate_repository.py b/tools/validate_repository.py index b933e5a..feb54bc 100644 --- a/tools/validate_repository.py +++ b/tools/validate_repository.py @@ -16,6 +16,7 @@ from openstatspec_specification.artifacts import ( # noqa: E402 ArtifactValidationError, validate_contract_artifacts, + validate_published_artifacts, validate_release_metadata, ) @@ -166,13 +167,15 @@ def validate_repository_controls() -> None: if __name__ == "__main__": try: main() + validate_published_artifacts(ROOT) inventory = validate_contract_artifacts(ROOT) validate_repository_controls() print( "Validated contract artifacts: " f"Plan {dict(inventory.plan_cases)}, " f"Frontend {dict(inventory.frontend_effective_cases)}, " - f"Binding {dict(inventory.binding_cases)}." + f"Binding {dict(inventory.binding_cases)}, " + f"Supplements {dict(inventory.supplement_cases)}." ) except (DoltDeclarationError, ArtifactValidationError) as error: raise SystemExit(str(error)) from error