diff --git a/.github/workflows/validation-ci.yml b/.github/workflows/validation-ci.yml index e97717293..d52de0f0c 100644 --- a/.github/workflows/validation-ci.yml +++ b/.github/workflows/validation-ci.yml @@ -33,6 +33,8 @@ on: - "examples/renamed_fields.yaml" - ".github/workflows/validation-ci.yml" - "scripts/generate-spec-types.py" + - "scripts/audit-spec-changes.py" + - "scripts/tests/**" pull_request: branches: ["main"] paths: @@ -46,6 +48,8 @@ on: - "examples/renamed_fields.yaml" - ".github/workflows/validation-ci.yml" - "scripts/generate-spec-types.py" + - "scripts/audit-spec-changes.py" + - "scripts/tests/**" permissions: contents: read @@ -81,6 +85,9 @@ jobs: - name: Run shared Python model tests run: uv run --with pytest --with jsonschema --with ./python -m pytest python/tests/ + - name: Run spec change audit tests + run: uv run --with pytest -m pytest scripts/tests/ + - name: Check spec.yaml enums are in sync with ossie-schema.json run: uv run scripts/generate-spec-types.py --check diff --git a/docs/spec_changes.md b/docs/spec_changes.md index 853be8399..51bce7fb7 100644 --- a/docs/spec_changes.md +++ b/docs/spec_changes.md @@ -39,14 +39,20 @@ the [current core specification](../core-spec/spec.md) and | Merged (UTC) | Area / source | Change and rationale | Impact on producers and consumers | | --- | --- | --- | --- | +| 2026-09-15 | Core [#397](https://github.com/apache/ossie/pull/397) | **Drop root-level `dialects` and `vendors`.** The two arrays had been added to the schema root to mirror the Python model, but the specification never defined them and no validator or consumer read them. | **Breaking within the unreleased schema.** The document root does not allow additional properties, so documents that declare root-level `dialects` or `vendors` no longer validate; remove both keys. Per-expression `dialects` entries and `custom_extensions` are unchanged. | | 2026-09-16 | Core [#383](https://github.com/apache/ossie/pull/383) | **One model per document.** Model properties moved to the document root to remove the wrapper and make the exchange unit unambiguous. | **Breaking within the unreleased schema.** Unwrap a single `semantic_model`; split a multi-model wrapper into separate documents. Old wrapped documents do not validate against the new root. See [migration guidance](../core-spec/spec.md#migrating-earlier-document-shapes). | | 2026-09-22 | Core [#439](https://github.com/apache/ossie/pull/439) | **Register `OSSIE_SQL_2026` as a portable expression dialect.** Its existing language definition could not be used in documents while the dialect token was absent from schema validation. | Additive at merge time; no change to the default dialect. This initially used `expression.dialects`; the later [#617](https://github.com/apache/ossie/pull/617) adds the preferred `expression.sql` form. | +| 2026-09-27 | Ontology [#400](https://github.com/apache/ossie/pull/400) | **Rename the ontology `uri` property to `iri`.** The optional global identifier on concepts and relationships is an IRI (RFC 3987), so the property name, the `prefixes` format, and the descriptions now say so. | **Breaking within the unreleased schema.** Concepts and relationships do not allow additional properties, so documents that still use `uri` no longer validate; rename it to `iri`. See [global identifiers](../ontology/ontology.md#global-identifiers). | | 2026-10-04 | Ontology [#458](https://github.com/apache/ossie/pull/458) | **Separate ontology, model, and mapping documents.** Independent references allow an ontology and a semantic model to be reused without embedding copies of either. | Mapping authors can use standalone documents validated by `ontology/mapping.json` and references to one ontology and one model. The older embedded `ontology_mappings` form remains accepted but is deprecated; importers should support the standalone form. | -| 2026-10-13 | Expression language [#577](https://github.com/apache/ossie/pull/577) | **Explicit `NULLS FIRST` / `NULLS LAST` in window `ORDER BY`.** Engine defaults differ, so explicit ordering is needed for portable window results. | Expression parsers and SQL translators should accept and preserve the new clause. The default when the clause is omitted was *not* decided by this change. | +| 2026-10-13 | Expression language [#577](https://github.com/apache/ossie/pull/577) | **Explicit `NULLS FIRST` / `NULLS LAST` in window `ORDER BY`.** Engine defaults differ, so explicit ordering is needed for portable window results. | Expression parsers and SQL translators should accept and preserve the new clause. The placement when the clause is omitted was set later by [#587](https://github.com/apache/ossie/pull/587). | | 2026-10-19 | Relational interface [#354](https://github.com/apache/ossie/pull/354) | **Layer 2 Relational Query Interface added.** It describes querying model measures through SQL relations and `MEASURE()` with correct aggregation semantics. | Additive specification document, not a new core JSON/YAML field. Query-engine implementers can adopt the interface; schema-only consumers need no migration. See [relational semantics](../core-spec/relational_semantics.md). | -| 2026-10-22 | Core [#591](https://github.com/apache/ossie/pull/591) | **Dataset-scoped metrics.** Metrics can live with the dataset they describe instead of all metrics living at the model root. | Additive optional `datasets[].metrics`. Resolving a dataset metric uses unqualified declared field names; model-scoped metric expressions use qualified `dataset.field` names. Consumers must account for both scopes when reading metrics. | -| 2026-10-26 | Core [#617](https://github.com/apache/ossie/pull/617) | **Portable `expression.sql` and open vendor dialect tokens.** The Ossie-defined portable expression becomes primary, while vendor-specific dialects stay opaque and extensible. | Existing `expression.dialects` remains accepted; writers should prefer `expression.sql` for portable SQL, and readers should give it precedence over a duplicate `OSSIE_SQL_2026` dialect entry. Dialect names are no longer a closed enum; consumers must tolerate unknown values. | +| 2026-10-22 | Core [#591](https://github.com/apache/ossie/pull/591) | **Dataset-scoped metrics.** Metrics can live with the dataset they describe instead of all metrics living at the model root. | Additive optional `datasets[].metrics`. A dataset metric references its own dataset's declared fields by unqualified name; model-scoped metric expressions use qualified `dataset.field` names. The later [#633](https://github.com/apache/ossie/pull/633) also lets dataset metrics reference source columns as `source.column`. Consumers must account for both scopes when reading metrics. | +| 2026-10-22 | Core [#486](https://github.com/apache/ossie/pull/486) | **Name resolution for fields, keys, relationships, and metrics.** The specification did not say whether these names meant dataset fields or source columns, and converters disagreed. Following the dev@ discussion, it now mirrors SQL views: field expressions read source columns, and the constructs above a dataset read its fields. | **Breaking.** `primary_key`, `unique_keys`, relationship `from_columns`/`to_columns`, and metric expressions refer to dataset fields, not source columns, and model-scoped metric expressions must use qualified `dataset.field` references. A dataset that declares no fields exposes nothing to keys, relationships, or model-scoped metrics. Converters that read these names as warehouse columns must resolve them as fields; SQL generators replace each field reference with the field's expression. See [name resolution](../core-spec/spec.md#name-resolution). | +| 2026-10-26 | Core [#617](https://github.com/apache/ossie/pull/617) | **Portable `expression.sql` and open vendor dialect tokens.** The Ossie-defined portable expression becomes primary, while vendor-specific dialects stay opaque and extensible. | Existing `expression.dialects` remains accepted; writers should prefer `expression.sql` for portable SQL, and readers must give it precedence over a duplicate `OSSIE_SQL_2026` dialect entry. Dialect names are no longer a closed enum; consumers must tolerate unknown values. | | 2026-11-01 | Ontology [#668](https://github.com/apache/ossie/pull/668) | **Non-empty ontology identifiers.** Validation now rejects empty names, IRIs, references, and mapping SQL expressions, matching existing restrictions elsewhere. | Authors should supply non-empty values for identifying strings. Some malformed documents that previously passed schema validation now fail earlier, with schema-layer errors. | +| 2026-11-03 | Core [#633](https://github.com/apache/ossie/pull/633) | **Dataset metrics can reference source columns.** A dataset-scoped metric can aggregate a column of its own `source` directly, written `source.column`. The qualifier is required so that a reference cannot change meaning when a field is added later. | Additive. In `datasets[].metrics`, `source.column` names a column of the dataset's `source`; the qualifier is case-insensitive, and `source.amount` means the source column even when the dataset declares a field `amount`. Unqualified names must still be declared fields. If a dataset declares a field named `source`, its metrics cannot reference source columns. Model-scoped metrics, keys, and relationships still refer to fields only. See [metric scoping](../core-spec/spec.md#metric-scoping). | +| 2026-11-04 | Wide table interface [#653](https://github.com/apache/ossie/pull/653) | **Layer 3 Wide Table Query Interface added.** A query names dimensions, metrics, and an optional filter; the engine chooses the joins and lowers the query to Layer 2, keeping guarantees such as preserving fact rows and avoiding fan-out double counting. | Additive specification document, not a new core JSON/YAML field. Query-engine implementers can adopt the interface; schema-only consumers need no migration. See [wide table semantics](../core-spec/wide_table_semantics.md). | +| 2026-11-05 | Expression language [#587](https://github.com/apache/ossie/pull/587) | **Default NULL placement in window `ORDER BY`.** When `NULLS FIRST` or `NULLS LAST` is omitted, NULL sorts as the largest value: last for `ASC`, first for `DESC`. Engine defaults differ, so portable window results need one defined placement. | Implementations must produce this order whatever the engine's native default: emit the clause where the engine supports it, or a leading `CASE` sort key on MySQL and SQL Server. Converters from native SQL must add the clause where the native placement differs. Only Oracle, PostgreSQL, Redshift, and Snowflake share this default natively. See [window ORDER BY NULL placement](../core-spec/expression_language.md#window-order-by-null-placement). | | 2026-11-09 | Core / Ontology [#691](https://github.com/apache/ossie/pull/691) | **Move the in-development version to `0.3.0.dev0`.** The next planned release is `0.3.0-incubating`; no `0.2.0` release is planned. | **Breaking for development documents.** Version constants in the current schemas reject `0.2.0.dev0`; producers must declare `0.3.0.dev0` and coordinate schema/package/converter versions. This is a development-version change, not a release announcement. | ## Semi-automated discovery and upkeep @@ -63,13 +69,17 @@ audit from a repository checkout: python scripts/audit-spec-changes.py --since 2026-09-01 ``` -The audit examines first-parent commits touching `core-spec/` or `ontology/`, +The audit examines the commits reachable from `--git-ref` (default `HEAD`) +that touch `core-spec/` or `ontology/` since the `--since` date (UTC), recognizes squash subjects ending in `(#123)` and `Merge pull request #123` subjects, and lists those **not yet represented** in this history. It is advisory, not a release gate: editorial PRs may be intentionally omitted, and commits without PR numbers cannot be discovered automatically. Reviewers decide which changes materially affect interoperability, rather than inferring migration advice from code. +A branch only sees the `main` commits it contains, so run the audit on a branch +that is up to date with `main`, or pass the upstream branch, for example +`--git-ref origin/main`. For a significant specification PR, add its history entry **in the same PR** or explain why no entry is warranted in the PR checklist. diff --git a/scripts/audit-spec-changes.py b/scripts/audit-spec-changes.py index aa683837e..bad90e702 100644 --- a/scripts/audit-spec-changes.py +++ b/scripts/audit-spec-changes.py @@ -23,6 +23,7 @@ """ import argparse +from datetime import date from pathlib import Path import re import subprocess @@ -33,7 +34,7 @@ def candidate_prs(git_log: str) -> dict[str, str]: - """Map PR number to commit subject for eligible mainline commits.""" + """Map PR number to commit subject for eligible commits.""" candidates = {} for subject in git_log.splitlines(): match = PR_IN_LOG.search(subject) @@ -48,14 +49,21 @@ def recorded_prs(history: str) -> set[str]: def main() -> int: parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--since", default="2026-09-01", help="Earliest merge date, YYYY-MM-DD") - parser.add_argument("--history", type=Path, default=Path("docs/spec_changes.md")) + parser.add_argument("--since", type=date.fromisoformat, default=date(2026, 9, 1), + help="Earliest merge date in UTC, YYYY-MM-DD") + parser.add_argument("--history", type=Path, + help="History file, default docs/spec_changes.md at the repository root") parser.add_argument("--git-ref", default="HEAD", help="Git ref to inspect, default HEAD") args = parser.parse_args() try: - history = args.history.read_text(encoding="utf-8") + # Resolve paths from the repository root so the audit works from any subdirectory. + root = Path(subprocess.run( + ["git", "rev-parse", "--show-toplevel"], + check=True, text=True, capture_output=True, + ).stdout.strip()) + history = (args.history or root / "docs/spec_changes.md").read_text(encoding="utf-8") result = subprocess.run( - ["git", "log", "--first-parent", f"--since={args.since}", + ["git", "-C", str(root), "log", f"--since={args.since} 00:00:00 +0000", "--format=%s", args.git_ref, "--", "core-spec", "ontology"], check=True, text=True, capture_output=True, ) diff --git a/scripts/tests/test_audit_spec_changes.py b/scripts/tests/test_audit_spec_changes.py index 2f4f92e17..f11541798 100644 --- a/scripts/tests/test_audit_spec_changes.py +++ b/scripts/tests/test_audit_spec_changes.py @@ -57,7 +57,11 @@ def setUp(self): self.temp = tempfile.TemporaryDirectory() self.addCleanup(self.temp.cleanup) self.repo = Path(self.temp.name) - self.env = dict(os.environ, GIT_AUTHOR_DATE="2026-11-01T12:00:00+00:00", + # Drop GIT_DIR and the like, which git hooks set, so git only touches the temp repo, + # and ignore the user's git config (signing, hooks). + env = {key: value for key, value in os.environ.items() if not key.startswith("GIT_")} + self.env = dict(env, GIT_CONFIG_GLOBAL=os.devnull, GIT_CONFIG_NOSYSTEM="1", + GIT_AUTHOR_DATE="2026-11-01T12:00:00+00:00", GIT_COMMITTER_DATE="2026-11-01T12:00:00+00:00") self.git("init", "-q", "-b", "main") self.git("config", "user.name", "Audit Test") @@ -81,8 +85,8 @@ def commit_file(self, name, content, subject): self.git("add", name) self.git("commit", "-qm", subject) - def audit(self, *args): - return subprocess.run([sys.executable, str(SCRIPT), *args], cwd=self.repo, + def audit(self, *args, cwd=None): + return subprocess.run([sys.executable, str(SCRIPT), *args], cwd=cwd or self.repo, env=self.env, text=True, capture_output=True) def test_reports_only_unrecorded_spec_candidates_in_numeric_order(self): @@ -94,6 +98,27 @@ def test_reports_only_unrecorded_spec_candidates_in_numeric_order(self): self.assertLess(result.stdout.index("/pull/9 "), result.stdout.index("/pull/100 ")) self.assertIn("Review suggestions manually", result.stdout) + def test_branch_that_merged_main_sees_main_commits(self): + self.git("switch", "-q", "-c", "feature", self.recorded_head) + self.commit_file("notes.md", "feature", "docs: feature work") + self.git("merge", "-q", "--no-ff", "--no-edit", "main") + result = self.audit("--since", "2026-10-01") + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("candidate PRs not in history: 2", result.stdout) + + def test_runs_from_subdirectory(self): + result = self.audit("--since", "2026-10-01", cwd=self.repo / "core-spec") + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("candidate PRs not in history: 2", result.stdout) + + def test_since_covers_the_whole_utc_day(self): + self.env["GIT_COMMITTER_DATE"] = "2026-11-02T00:00:01+00:00" + self.commit_file("core-spec/spec.md", "early", "spec: just after midnight (#101)") + result = self.audit("--since", "2026-11-02") + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("candidate PRs not in history: 1", result.stdout) + self.assertIn("/pull/101 ", result.stdout) + def test_explicit_ref_limits_history(self): result = self.audit("--git-ref", self.recorded_head) self.assertEqual(result.returncode, 0, result.stderr)