columna-core 0.7.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- columna_core-0.7.8/.gitignore +23 -0
- columna_core-0.7.8/CHANGELOG.md +83 -0
- columna_core-0.7.8/LICENSE +202 -0
- columna_core-0.7.8/PKG-INFO +128 -0
- columna_core-0.7.8/README.md +100 -0
- columna_core-0.7.8/demos/benchmark.cml +61 -0
- columna_core-0.7.8/demos/build_benchmark.py +211 -0
- columna_core-0.7.8/demos/coanchor_demo.py +131 -0
- columna_core-0.7.8/demos/confine_demo.py +156 -0
- columna_core-0.7.8/demos/hll_case_study_demo.py +135 -0
- columna_core-0.7.8/demos/holistic_demo.py +97 -0
- columna_core-0.7.8/demos/locus_demo.py +82 -0
- columna_core-0.7.8/demos/operator_umbrella_demo.py +130 -0
- columna_core-0.7.8/demos/parse_benchmark.py +45 -0
- columna_core-0.7.8/demos/projection_demo.py +120 -0
- columna_core-0.7.8/demos/types_demo.py +101 -0
- columna_core-0.7.8/demos/universe_check_demo.py +70 -0
- columna_core-0.7.8/pyproject.toml +89 -0
- columna_core-0.7.8/src/columna_core/__init__.py +25 -0
- columna_core-0.7.8/src/columna_core/connector.py +120 -0
- columna_core-0.7.8/src/columna_core/disclosure.py +229 -0
- columna_core-0.7.8/src/columna_core/disclosure_wire.py +210 -0
- columna_core-0.7.8/src/columna_core/engine.py +548 -0
- columna_core-0.7.8/src/columna_core/frameql.py +55 -0
- columna_core-0.7.8/src/columna_core/model.py +182 -0
- columna_core-0.7.8/src/columna_core/operators.py +149 -0
- columna_core-0.7.8/src/columna_core/parser.py +289 -0
- columna_core-0.7.8/src/columna_core/planner.py +520 -0
- columna_core-0.7.8/src/columna_core/projection.py +129 -0
- columna_core-0.7.8/src/columna_core/sketch.py +110 -0
- columna_core-0.7.8/src/columna_core/types.py +73 -0
- columna_core-0.7.8/tests/CHECK_MAPPING.md +188 -0
- columna_core-0.7.8/tests/_demo_driver.py +79 -0
- columna_core-0.7.8/tests/_run_demos.py +57 -0
- columna_core-0.7.8/tests/conftest.py +97 -0
- columna_core-0.7.8/tests/fixtures/benchmark.cml +61 -0
- columna_core-0.7.8/tests/fixtures/expected.json +72 -0
- columna_core-0.7.8/tests/fixtures/make_fixture.py +208 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/calendar.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/categories.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/customers.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/daily_revenue_summary.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/engagement_scores.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/eom_inventory.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/monthly_avg_order_value.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/monthly_store_inventory.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/monthly_unique_visitors.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/product_categories.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/products.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/stores.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/support_tickets.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/transactions.parquet +0 -0
- columna_core-0.7.8/tests/fixtures/mini_warehouse/warehouse_notes.parquet +0 -0
- columna_core-0.7.8/tests/smoke_wheel.py +52 -0
- columna_core-0.7.8/tests/test_benchmark_warehouse.py +36 -0
- columna_core-0.7.8/tests/test_coanchor.py +17 -0
- columna_core-0.7.8/tests/test_confine.py +17 -0
- columna_core-0.7.8/tests/test_disclosure_wire.py +182 -0
- columna_core-0.7.8/tests/test_fixture_drift.py +87 -0
- columna_core-0.7.8/tests/test_hll_case_study.py +17 -0
- columna_core-0.7.8/tests/test_holistic.py +17 -0
- columna_core-0.7.8/tests/test_locus.py +17 -0
- columna_core-0.7.8/tests/test_operator_umbrella.py +17 -0
- columna_core-0.7.8/tests/test_parse_benchmark_warehouse.py +35 -0
- columna_core-0.7.8/tests/test_projection.py +17 -0
- columna_core-0.7.8/tests/test_types.py +17 -0
- columna_core-0.7.8/tests/test_universe_check.py +17 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.venv/
|
|
9
|
+
venv/
|
|
10
|
+
.env
|
|
11
|
+
|
|
12
|
+
# Test / tooling caches
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
.coverage
|
|
16
|
+
htmlcov/
|
|
17
|
+
|
|
18
|
+
# OS / editor
|
|
19
|
+
.DS_Store
|
|
20
|
+
*.swp
|
|
21
|
+
|
|
22
|
+
# Raw handoff bundle (provenance, not part of the deliverable)
|
|
23
|
+
attachments/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to **columna-core** are recorded here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/); this project uses the `-core` version line
|
|
5
|
+
carried in `columna_core.__version__`.
|
|
6
|
+
|
|
7
|
+
The entries below are extracted from the README version-history blocks (the de-facto changelog to
|
|
8
|
+
date); future changes are recorded here going forward.
|
|
9
|
+
|
|
10
|
+
## [0.7.8-core] — packaging hardening + the disclosure wire adapter
|
|
11
|
+
|
|
12
|
+
**Packaging / correctness (crediting the WP-0 acceptance audit):**
|
|
13
|
+
- Declare the hard `pyarrow>=15` runtime dependency. `connector.py` calls
|
|
14
|
+
`pl.from_arrow(con.execute(q).arrow())` on every fetch and polars does not pull pyarrow
|
|
15
|
+
transitively, so a clean-venv install imported fine but failed on first fetch. A wheel smoke test
|
|
16
|
+
(fresh venv → real fetch) now guards this in CI.
|
|
17
|
+
- Resolve `COLUMNA_BENCH_WAREHOUSE` to an absolute path at read time, so a relative value no longer
|
|
18
|
+
silently mis-resolves against the demo runner's cwd.
|
|
19
|
+
- Reconcile `benchmark.cml` with the code-built Manifold by adding the `region_label` measure
|
|
20
|
+
(parser now yields 6 measures == the code set; `parse_benchmark` exits 0 on parity YES). A
|
|
21
|
+
structural parity test guards against re-drift.
|
|
22
|
+
|
|
23
|
+
**v0.7.8 worklist (items 1–2), cleared:**
|
|
24
|
+
- `parser.py`: import `Optional` (fixes F821 — annotation-only, was masked by
|
|
25
|
+
`from __future__ import annotations`; would have broken `typing.get_type_hints(parse_predicate)`).
|
|
26
|
+
- Remove unused imports / dead locals / a placeholder-less f-string across `disclosure.py`,
|
|
27
|
+
`engine.py`, `model.py`, `parser.py`; the corresponding per-file-ignores are tightened back out.
|
|
28
|
+
|
|
29
|
+
**New:**
|
|
30
|
+
- `columna_core.disclosure_wire` — the structured `{code, materiality, …}` wire adapter (the
|
|
31
|
+
category → (code, default materiality) table is normative, one dict). This is the ADR-032 D8 "one
|
|
32
|
+
contract" serialization the MCP surface (WP-2.2) and every other surface share; WP-1.3 collapses
|
|
33
|
+
into it.
|
|
34
|
+
|
|
35
|
+
## [0.7.7-core] — ON UNIVERSE pin wiring (Option A)
|
|
36
|
+
The population pin recorded by `Frame.on_universe(u)` is threaded to the planner (`run`/`plan` →
|
|
37
|
+
`_infer`) where it asserts the frame's intended population: a measure bound to `u` serves; a measure
|
|
38
|
+
bound to a *different* universe is out-of-domain and **refuses** (`out_of_universe`); an unknown `u`
|
|
39
|
+
is an **error**. Resolves the multi-universe / D5 co-anchoring ambiguity to the one chosen
|
|
40
|
+
population. 124 checks across 11 suites.
|
|
41
|
+
|
|
42
|
+
## [0.7.6-core] — the no-result is a value, not an exception
|
|
43
|
+
The structured no-result splits into a plain `Outcome` value (kind · discriminator · reason ·
|
|
44
|
+
alternatives) and a private internal `Refusal` *signal*. `ColumnResult.refusal` now holds an
|
|
45
|
+
`Outcome`: clarify/refuse/error is **data** every surface reads, never an `Exception`. 116 checks.
|
|
46
|
+
|
|
47
|
+
## [0.7.5-core] — ratio/rate co-anchoring (ADR-032 D5)
|
|
48
|
+
A ratio `N / D` is determinate only when numerator and denominator resolve over one shared
|
|
49
|
+
population. The planner checks this statically: a cross-universe ratio is a **clarify**
|
|
50
|
+
(`co_anchor_ambiguous`), naming the candidate populations, never a silent number. 115 checks.
|
|
51
|
+
|
|
52
|
+
## [0.7.4-core] — the two-level correctness contract (ADR-032)
|
|
53
|
+
The column engine never judges: it attempts and returns a result or a *no-result carrying a
|
|
54
|
+
discriminator* (`ambiguous` / `unsupported`). The **planner** owns the four outcomes
|
|
55
|
+
(serve · disclose · clarify · refuse) plus `error`, classifying every no-result at one chokepoint.
|
|
56
|
+
|
|
57
|
+
## [0.7.3-core] — attribute-anchor resolution hardened
|
|
58
|
+
`_attr_anchor` no longer picks the first edge a table provides: single-grain is unambiguous, a
|
|
59
|
+
denormalized multi-grain table is pinned by the delivery frame, and a genuinely ambiguous case is
|
|
60
|
+
**refused with the candidate levels named**. 107 checks across 10 suites.
|
|
61
|
+
|
|
62
|
+
## [0.7.2-core] — universe-predicate evaluation hardened to typed predicates
|
|
63
|
+
The universe predicate is evaluated at base grain by **broadcast-and-filter, never a join**;
|
|
64
|
+
compared sides are coerced to a common dtype. Fixes numeric / real-`Date` predicate handling.
|
|
65
|
+
101 checks across 10 suites.
|
|
66
|
+
|
|
67
|
+
## [0.7.1-core] — B-anchor crossing locus refinement + EXPLAIN-without-execution
|
|
68
|
+
Crossing *detection* moves from engine (execute time) to planner (compile time);
|
|
69
|
+
`frame(...).plan()` / `explain(execute=False)` returns the would-be annotation touching zero
|
|
70
|
+
backend data.
|
|
71
|
+
|
|
72
|
+
## [0.7.0-core] — a custom type + three custom operators, planner untouched (HLL case study)
|
|
73
|
+
The `distinct` family is decomposed into a parametric type `HLLSketch(p)` and three registered
|
|
74
|
+
operators (`hll_count`, `hll_merge`, `hll_estimate`) that slot in via the registry + engine only;
|
|
75
|
+
`planner.py` and `projection.py` hold zero sketch references. A publish-time witness store makes
|
|
76
|
+
sketches **stored, not cached**.
|
|
77
|
+
|
|
78
|
+
## [0.6.0-core] — inform-and-serve reconciliation (Frame-QL Manual)
|
|
79
|
+
A B-anchor crossing is **served with a critical `b_anchor_crossing` disclosure** naming the
|
|
80
|
+
alternative reducer, no longer refused. Disclosures carry a severity lattice
|
|
81
|
+
(none < info < caution < critical) with a frame-level rollup. 57 checks across 7 suites.
|
|
82
|
+
|
|
83
|
+
[0.7.7-core]: https://github.com/datumwise/columna
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: columna-core
|
|
3
|
+
Version: 0.7.8
|
|
4
|
+
Summary: Columna Core — the column-foundation analytic framework (multi-table, transport-based, correctness-governed) over a single backend.
|
|
5
|
+
Project-URL: Homepage, https://github.com/datumwise/columna
|
|
6
|
+
Project-URL: Repository, https://github.com/datumwise/columna
|
|
7
|
+
Author: Datumwise
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: analytics,duckdb,frame-ql,manifold,polars,semantic-layer
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Database :: Front-Ends
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: datasketches<6.0,>=5.0
|
|
22
|
+
Requires-Dist: duckdb<2.0,>=1.0
|
|
23
|
+
Requires-Dist: polars<2.0,>=1.0
|
|
24
|
+
Requires-Dist: pyarrow>=15
|
|
25
|
+
Provides-Extra: test
|
|
26
|
+
Requires-Dist: pytest>=8.0; extra == 'test'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# Columna Core (0.7.8-core)
|
|
30
|
+
|
|
31
|
+
> **v0.7.8-core — packaging hardening + the disclosure wire adapter.** Declares the hard `pyarrow`
|
|
32
|
+
> runtime dependency and resolves `COLUMNA_BENCH_WAREHOUSE` absolutely (WP-0 audit finds); reconciles
|
|
33
|
+
> `benchmark.cml` with the code-built Manifold (adds `region_label`); clears the v0.7.8 worklist
|
|
34
|
+
> (parser `Optional` import; unused-import / dead-local / f-string cruft). Adds
|
|
35
|
+
> `columna_core.disclosure_wire` — the structured `{code, materiality, …}` wire adapter (ADR-032 D8 /
|
|
36
|
+
> WP-1.3), the one contract every surface serializes. See `CHANGELOG.md`.
|
|
37
|
+
|
|
38
|
+
> **v0.7.7-core — `ON UNIVERSE` pin wiring (Option A).** The population pin recorded by `Frame.on_universe(u)` is now threaded to the planner (`run`/`plan` → `_infer`), where it asserts the frame's intended population. A measure bound to `u` serves; a measure bound to a *different* universe is out-of-domain for that population and **refuses** (`out_of_universe`); an unknown `u` is an **error**. This resolves the multi-universe and D5 co-anchoring ambiguity to the one chosen population — so a cross-universe ratio that *clarifies* unpinned becomes a serve or an honest refuse once pinned, and a multi-universe frame's coverage caveat is resolved. (Resolving a measure over a universe *other* than its declared one — true cross-universe confinement — is Option B, future.) `coanchor_demo` §D covers it. 124 checks across 11 suites.
|
|
39
|
+
|
|
40
|
+
> **v0.7.6-core — the no-result is a value, not an exception.** The structured no-result is split into a plain `Outcome` value (kind · discriminator · reason · alternatives) and a private internal `Refusal` *signal* that merely carries it from deep in the recursive walk to the planner's single assembly point. `ColumnResult.refusal` now holds an `Outcome`: a clarify/refuse/error is **data** every surface and agent reads, never an `Exception` a caller could swallow with `except Exception`. (`Refusal` remains the internal control-flow goto; eliminating even that would mean return-threading the recursive type-inferencer — deliberately not done.) `coanchor_demo` asserts the clarify is an `Outcome`, not an exception. 116 checks across 11 suites.
|
|
41
|
+
|
|
42
|
+
> **v0.7.5-core — ratio/rate co-anchoring (ADR-032 D5).** A ratio `N / D` is determinate only when numerator and denominator resolve over one shared population. The planner now checks this statically: a ratio whose operands span different universes is a **clarify** (`co_anchor_ambiguous`, discriminator `ambiguous`) naming the candidate populations — "which population is the rate over?" — never a silent number. It is *not* eager (a same-universe ratio, or a constant denominator, just serves) and is distinct from avg-of-averages (a B-anchor hazard). Scoped to the ratio: the same two measures as *separate columns* still serve with the multi-universe coverage caveat. New `coanchor_demo`; 115 checks across 11 suites.
|
|
43
|
+
|
|
44
|
+
> **v0.7.4-core — the two-level correctness contract (ADR-032).** The column engine never judges: it attempts and returns either a result or a *no-result carrying a discriminator* — `ambiguous` (no unique answer under the rules) or `unsupported` (the data can't support a result). The **planner** owns the four outcomes (serve · disclose · clarify · refuse), plus `error` for vocabulary/capability failures, and classifies every no-result at one chokepoint (`Refusal.classified`). The multi-grain attribute case is now a **clarify** (ambiguous), not an `unknown` error lumped with real failures; out-of-universe is a **refuse**; an unimplemented operator is an **error**. `FrameResult.outcome / .clarifies / .refusals / .errors` surface the verdicts; `confine_demo` verifies the classification.
|
|
45
|
+
|
|
46
|
+
> **v0.7.3-core — attribute-anchor resolution hardened.** When a universe predicate references an attribute `T.col`, the engine must broadcast it at the level `T` is keyed. `_attr_anchor` no longer picks the first edge `T` provides: a single-grain table is unambiguous, a denormalized multi-grain table (one `geo` table providing `store→region` *and* `region→country`) is **pinned by the delivery frame**, and a genuinely ambiguous case is **refused with the candidate levels named** — never a silent wrong grain. `confine_demo` proves the pin and the refusal. 107 checks across 10 suites.
|
|
47
|
+
|
|
48
|
+
> **v0.7.2-core — universe-predicate evaluation hardened to typed predicates.** The universe predicate is evaluated at the base grain by **broadcast-and-filter, never a join**: each referenced attribute is delivered single-table and broadcast onto the frame along its key (transport), the compared sides are **coerced to a common dtype**, and the frame is filtered. Fixes a real gap — a numeric (`qty >= 10`) or real-`Date` predicate previously raised a dtype error because predicate literals arrive as strings, and only the benchmark's ISO-date *strings* compared correctly by luck. `confine_demo` now proves numeric / Date / AND-ed predicates alongside out-of-domain exclusion. 101 checks across 10 suites.
|
|
49
|
+
|
|
50
|
+
> **v0.7.1-core — B-anchor crossing locus refinement + EXPLAIN-without-execution.** Crossing *detection* moved from the engine (execute time) to the planner (compile time): `blocked_lineages` and the operator's `is_monoid` are now surfaced on the shape projection, so a crossing is knowable from structure alone. The served contract is unchanged (still served-with-critical, never refused), but `frame(...).plan()` / `explain(execute=False)` returns the would-be annotation — the critical crossing plus spec-only provenance caveats — touching **zero backend data**.
|
|
51
|
+
|
|
52
|
+
> **v0.7.0-core — a custom type + three custom operators, planner untouched (HLL case study).** The `distinct` family is decomposed into a parametric type `HLLSketch(p)` and three registered operators — `hll_count` (deliver), `hll_merge` (a monoid union, combine), `hll_estimate` (project) — that slot into the umbrella via the **registry and engine only**; `planner.py` and `projection.py` hold zero sketch references. Precision is type identity (a mismatched merge is a type error; a raw sketch is opaque to arithmetic). A publish-time **witness store** makes sketches **stored, not cached**, so `distinct@region` merges stored witnesses with **zero base scans at query time**.
|
|
53
|
+
|
|
54
|
+
> **v0.6.0-core — inform-and-serve reconciliation (Frame-QL Manual).** A B-anchor crossing (e.g. summing a stock over time) is now **served with a critical `b_anchor_crossing` disclosure** that names the alternative reducer — no longer refused. Refusals are reserved for the planner's static clarify/inform cases (fan-out across an M:N edge — now naming all three remedies; out-of-universe; unknown operator; type error). The engine, once handed an executable atom, never withholds on analytical grounds. Disclosures now carry a severity lattice (none<info<caution<critical) with a frame-level rollup. 57 checks across 7 suites pass.
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
The column-foundation implementation specified in **ADR-031** and the **Manifold object model** — multi-table, transport-based, validated against the real benchmark warehouse (299,934 transactions).
|
|
58
|
+
|
|
59
|
+
This is **not** the ADR-030 kernel. The kernel proved correctness *techniques* on a single denormalized table; Core implements the architecture: **the backend delivers single-table column-atoms and functional relationship-columns; the engine *transports* and relates them; the backend never joins.**
|
|
60
|
+
|
|
61
|
+
## The discipline, in code
|
|
62
|
+
|
|
63
|
+
- `connector.py` — **single-table delivery only.** `deliver_measure` (one-table group-by), `deliver_edge` (one-table key→key mapping), `deliver_base_rows` (one-table, for sketches). No SQL join is ever generated.
|
|
64
|
+
- `model.py` — the Manifold object model. Two layers: **universes** (populations) and the **coordinate DAG** (`FunctionalEdge`s). A rollup (`day→month`) and a relationship (`store→region`) are the *same* object — a functional edge the engine transports along, tagged with a lineage. The **B-anchor** blocks per-lineage.
|
|
65
|
+
- `engine.py` — the center. For `(measure, family-member) @ anchor`: find the functional path, **B-anchor-check every transport edge *and* every collapsed dimension**, resolve cheapest-faithful (cache vs delivery), **transport** the measure along functional edges (in-engine; no join pushdown), co-compute disclosure, cache.
|
|
66
|
+
- `planner.py` — provenance-blind. Parses logical `family.member @ anchor`, expands derived columns, **typechecks addressability — fan-out and out-of-universe are refused HERE, statically** — then assembles frames and folds disclosures.
|
|
67
|
+
- `disclosure.py` — the disclosure shadow-value and its sibling, the structured, dialog-capable `Refusal` (carries named alternatives).
|
|
68
|
+
|
|
69
|
+
## What `build_benchmark.py` proves (10/10, real data)
|
|
70
|
+
|
|
71
|
+
1. **Transport replaces the join** — `revenue@region` computed from a single-table `revenue@store` delivery + the `store→region` mapping, related *in the engine*; exact vs. ground truth; **zero joins pushed down**.
|
|
72
|
+
2. **Coordinate rollup is the same operation** — `revenue@cal.month` via the `day→month` mapping.
|
|
73
|
+
3. **★ Fan-out is inexpressible ★** — `revenue@category` is **refused** at the planner (`transaction↔category` is M:N); for contrast, the naive join *silently inflates revenue 1.44× — a 44% overcount*. The refusal names its alternatives (allocation = Pro; membership = rephrase). The flagship.
|
|
74
|
+
4. **B-anchor blocks per-lineage** — `level.sum@(region,day)` *works* (additive over the store axis); `level.sum@store` is *refused* (would sum a stock across days — non-reconciling over the calendar lineage). Same metric, opposite verdicts, by edge.
|
|
75
|
+
5. **Pre/post-agg boundary** — `aov = revenue/orders` computed post-aggregation = correct AOV (not the avg-of-avgs the shipped `monthly_avg_order_value` would give).
|
|
76
|
+
6. **Sketch reaggregation** — `visitors@cal.quarter` by HLL-merging per-day sketches; ≈ true distinct, vs. a naive sum-of-daily-distincts that overcounts.
|
|
77
|
+
7. **Out-of-universe** — `level@product` refused as a *distinct* reason (out of domain — undefined, not missing).
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
engine: 5 single-table deliveries, 5 transports, 1 cache-hit, 10 backend fetches (all single-table)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Run
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install --break-system-packages polars duckdb datasketches pyarrow
|
|
87
|
+
python3 build_benchmark.py # 10 checks against the benchmark warehouse
|
|
88
|
+
```
|
|
89
|
+
(The script reads the warehouse parquets from the benchmark instance path; adjust `WAREHOUSE` if needed.)
|
|
90
|
+
|
|
91
|
+
## Ingest-first: the definition language
|
|
92
|
+
|
|
93
|
+
A written `MANIFOLD` definition (the `.cf` successor) parses to the Manifold object and is queryable end-to-end — no hand-construction. See `benchmark.cml` for the whole benchmark Manifold as text, and run:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
python3 parse_benchmark.py # parse benchmark.cml, then the SAME 10 checks on the PARSED Manifold
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The parser (`parser.py`) reproduces the hand-built object with full structural parity, the corrected semantics survive the parse (`M_ANCHOR { }` → MCAR; `FAMILY { sum : additive BLOCKED { calendar } }` → per-member B-anchor), and publish-time well-formedness checks reject malformed definitions (impure predicate referencing a measure, unknown level/universe/column, etc.).
|
|
100
|
+
|
|
101
|
+
Grammar (statement-oriented; `#` comments; `{ }` blocks):
|
|
102
|
+
```
|
|
103
|
+
MANIFOLD <name> VERSION <n>
|
|
104
|
+
UNIVERSE <name> = <dim> * <dim> ... [WHERE <predicate>]
|
|
105
|
+
LEVEL <name> = <column> [BASE]
|
|
106
|
+
EDGE <from> -> <to> ALONG <lineage> VIA <table>(<from_col>, <to_col>)
|
|
107
|
+
RELATE <a> <-> <b> VIA <table> [NOTE "<text>"]
|
|
108
|
+
MEASURE <name> ON <universe> FROM <table> AS <agg>(<expr>)
|
|
109
|
+
MEASURE <name> ON <universe> FROM <table> VALUE <expr>
|
|
110
|
+
[M_ANCHOR { <col>, ... }] [FAMILY { <agg> [: <tier>] [BLOCKED { <lineage>, ... }] ... }]
|
|
111
|
+
DERIVED <name> = <expr>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Scope (Core, per ADR-031)
|
|
115
|
+
|
|
116
|
+
**Logical types, checked at compile time** (`types.py`, `types_demo.py`): every measure declares a **logical (Polars) dtype** and every operator carries a **type signature** (`sum: Numeric∪Duration→same`, `distinct: any→Int64`, `median: Numeric∪Temporal→same`, `last: T→T`). The *signature* is vocabulary the planner holds; the *mechanics* (witness/combine/deliver_sql) stay engine-side. So "operator not supported" and "wrong type for this operator" are **vocabulary errors caught at the planner, before the engine is ever asked** — proven by zero backend fetches on a refused frame. A static type-inference pass runs as a compile step ahead of resolution (`type_error` is its refusal reason, a sibling of unknown-operator). The **connector owns logical→physical**: a measure declares logical `Float64` over a raw column, and the connector supplies the `TRY_CAST` when the physical type is a dirty `VARCHAR` — so the author writes no casts, and a cast *failure* is a coverage fact at resolution, never a type error.
|
|
117
|
+
|
|
118
|
+
In scope and working: multi-table Manifolds, universes **with runtime predicate confinement**, the coordinate DAG, transport, measure-families with per-lineage B-anchors, **the operator registry (reaggregation as a monoid property, plus type signatures)**, **logical types with a compile-time planner typecheck**, derived columns, structured refusals, EXPLAIN, the definition-language parser + well-formedness checks, **the universe-support consistency check**, **the two projections as an enforced boundary**. Deliberately out (Pro): multiple backends/federation, cloud, custom operators/types, sophisticated optimization, **allocation** (the M:N split — Core catches the case rather than computing it).
|
|
119
|
+
|
|
120
|
+
**Two projections, enforced** (`projection.py`, `projection_demo.py`): one authored Manifold has two projections. The **planner** holds a `PlannerView` — vocabulary/shape only: logical names, the DAG *topology* (`frm→to` + lineage, no physical columns), family member *names*, derived formulas, M:N pairs for fan-out. The **engine** holds the full Manifold — sources, realizations, the universe predicate, missingness, costs, the operator registry. This makes "the planner cannot see provenance" *structural*: `home_table`, `pre_expr`, `realized_by`, `provider_table`, and the predicate are simply absent from the planner's object — no source string is reachable from it — yet it still does real work (fan-out and out-of-universe are refused from shape alone). The handoff down is a logical request `(measure, member, anchor)`; the return up is a frame + a `Disclosure` (caveats, not sources). Disclosures cross the boundary; provenance does not.
|
|
121
|
+
|
|
122
|
+
**Reaggregation is a monoid property of the operator** (`operators.py` — the registry, which is the Core/Pro extension point). An operator is reaggregable iff a possibly-enriched witness makes it a monoid; the engine reduces in *witness-space* and projects to the answer at the boundary: `sum`/`count` carry the value (combine `+`), `min`/`max` the value (combine min/max), `distinct` an HLL sketch (combine union), `last`/`first` the **(value, order_key)** pair (combine argmax/argmin — the order key is carried as the witness), and `median`/`mode` are **holistic** (no finite witness → recompute-from-base, never reduced). Two independent gates compose: **monoid-ness** (operator-level, *possible*) and the **B-anchor** (column-level, *permitted*). The headline (`holistic_demo.py`): `level.last@(store, cal.month)` *works* by carrying the day and reducing by argmax, while `level.sum@(store, cal.month)` *refuses* — same column, same target, the two gates disagree.
|
|
123
|
+
|
|
124
|
+
**Universe-support consistency** (`universe_check_demo.py`): a universe is one population, so every measure bound to it must reduce to the same base-point support (modulo declared coverage). The check reduces each measure to its universe and compares supports; a mismatch not explained by coverage flags a mis-declared universe. (Benchmark passes; a measure mis-sourced from a half-coverage table is flagged "50% short".) This is the **count-reducer instance** of a more general *path-independence* check — reduce a measure to the universe singleton along every anchoring and assert the reduced values agree — which becomes exercisable once a second coordinatization of an axis (e.g. a fiscal calendar forking from `day`) exists; with a single anchoring there is nothing to reconcile against.
|
|
125
|
+
|
|
126
|
+
**Universe-predicate confinement** (`confine_demo.py`): a measure bound to a predicated universe is confined to its valid points *at the base grain, at delivery, before aggregation* — logically prior to any query `WHERE` (domain before selection), inherited through cache and transport. A cross-table predicate like `day >= stores.opened_date` is evaluated *in the engine*: `opened_date` is delivered from `stores` (single table) and **broadcast** onto `(store, day)` by transport, then compared and filtered — **never a backend join**. The demo injects out-of-domain rows; the engine excludes them while an unconfined Manifold silently includes them.
|
|
127
|
+
|
|
128
|
+
Still thin in this build (next): the full cached-vs-stored cost search (resolution is correct but the cost model is minimal); hoisting the **B-anchor permission** refusal (`blocked_reaggregation`) from the engine to the planner (it is structural and belongs there, but it currently sits in the engine to preserve behaviour — moving it means the `PlannerView` carries family-member shape); automated Discovery (the parser consumes a written definition; generating one from a warehouse is the layer above).
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Columna Core (0.7.8-core)
|
|
2
|
+
|
|
3
|
+
> **v0.7.8-core — packaging hardening + the disclosure wire adapter.** Declares the hard `pyarrow`
|
|
4
|
+
> runtime dependency and resolves `COLUMNA_BENCH_WAREHOUSE` absolutely (WP-0 audit finds); reconciles
|
|
5
|
+
> `benchmark.cml` with the code-built Manifold (adds `region_label`); clears the v0.7.8 worklist
|
|
6
|
+
> (parser `Optional` import; unused-import / dead-local / f-string cruft). Adds
|
|
7
|
+
> `columna_core.disclosure_wire` — the structured `{code, materiality, …}` wire adapter (ADR-032 D8 /
|
|
8
|
+
> WP-1.3), the one contract every surface serializes. See `CHANGELOG.md`.
|
|
9
|
+
|
|
10
|
+
> **v0.7.7-core — `ON UNIVERSE` pin wiring (Option A).** The population pin recorded by `Frame.on_universe(u)` is now threaded to the planner (`run`/`plan` → `_infer`), where it asserts the frame's intended population. A measure bound to `u` serves; a measure bound to a *different* universe is out-of-domain for that population and **refuses** (`out_of_universe`); an unknown `u` is an **error**. This resolves the multi-universe and D5 co-anchoring ambiguity to the one chosen population — so a cross-universe ratio that *clarifies* unpinned becomes a serve or an honest refuse once pinned, and a multi-universe frame's coverage caveat is resolved. (Resolving a measure over a universe *other* than its declared one — true cross-universe confinement — is Option B, future.) `coanchor_demo` §D covers it. 124 checks across 11 suites.
|
|
11
|
+
|
|
12
|
+
> **v0.7.6-core — the no-result is a value, not an exception.** The structured no-result is split into a plain `Outcome` value (kind · discriminator · reason · alternatives) and a private internal `Refusal` *signal* that merely carries it from deep in the recursive walk to the planner's single assembly point. `ColumnResult.refusal` now holds an `Outcome`: a clarify/refuse/error is **data** every surface and agent reads, never an `Exception` a caller could swallow with `except Exception`. (`Refusal` remains the internal control-flow goto; eliminating even that would mean return-threading the recursive type-inferencer — deliberately not done.) `coanchor_demo` asserts the clarify is an `Outcome`, not an exception. 116 checks across 11 suites.
|
|
13
|
+
|
|
14
|
+
> **v0.7.5-core — ratio/rate co-anchoring (ADR-032 D5).** A ratio `N / D` is determinate only when numerator and denominator resolve over one shared population. The planner now checks this statically: a ratio whose operands span different universes is a **clarify** (`co_anchor_ambiguous`, discriminator `ambiguous`) naming the candidate populations — "which population is the rate over?" — never a silent number. It is *not* eager (a same-universe ratio, or a constant denominator, just serves) and is distinct from avg-of-averages (a B-anchor hazard). Scoped to the ratio: the same two measures as *separate columns* still serve with the multi-universe coverage caveat. New `coanchor_demo`; 115 checks across 11 suites.
|
|
15
|
+
|
|
16
|
+
> **v0.7.4-core — the two-level correctness contract (ADR-032).** The column engine never judges: it attempts and returns either a result or a *no-result carrying a discriminator* — `ambiguous` (no unique answer under the rules) or `unsupported` (the data can't support a result). The **planner** owns the four outcomes (serve · disclose · clarify · refuse), plus `error` for vocabulary/capability failures, and classifies every no-result at one chokepoint (`Refusal.classified`). The multi-grain attribute case is now a **clarify** (ambiguous), not an `unknown` error lumped with real failures; out-of-universe is a **refuse**; an unimplemented operator is an **error**. `FrameResult.outcome / .clarifies / .refusals / .errors` surface the verdicts; `confine_demo` verifies the classification.
|
|
17
|
+
|
|
18
|
+
> **v0.7.3-core — attribute-anchor resolution hardened.** When a universe predicate references an attribute `T.col`, the engine must broadcast it at the level `T` is keyed. `_attr_anchor` no longer picks the first edge `T` provides: a single-grain table is unambiguous, a denormalized multi-grain table (one `geo` table providing `store→region` *and* `region→country`) is **pinned by the delivery frame**, and a genuinely ambiguous case is **refused with the candidate levels named** — never a silent wrong grain. `confine_demo` proves the pin and the refusal. 107 checks across 10 suites.
|
|
19
|
+
|
|
20
|
+
> **v0.7.2-core — universe-predicate evaluation hardened to typed predicates.** The universe predicate is evaluated at the base grain by **broadcast-and-filter, never a join**: each referenced attribute is delivered single-table and broadcast onto the frame along its key (transport), the compared sides are **coerced to a common dtype**, and the frame is filtered. Fixes a real gap — a numeric (`qty >= 10`) or real-`Date` predicate previously raised a dtype error because predicate literals arrive as strings, and only the benchmark's ISO-date *strings* compared correctly by luck. `confine_demo` now proves numeric / Date / AND-ed predicates alongside out-of-domain exclusion. 101 checks across 10 suites.
|
|
21
|
+
|
|
22
|
+
> **v0.7.1-core — B-anchor crossing locus refinement + EXPLAIN-without-execution.** Crossing *detection* moved from the engine (execute time) to the planner (compile time): `blocked_lineages` and the operator's `is_monoid` are now surfaced on the shape projection, so a crossing is knowable from structure alone. The served contract is unchanged (still served-with-critical, never refused), but `frame(...).plan()` / `explain(execute=False)` returns the would-be annotation — the critical crossing plus spec-only provenance caveats — touching **zero backend data**.
|
|
23
|
+
|
|
24
|
+
> **v0.7.0-core — a custom type + three custom operators, planner untouched (HLL case study).** The `distinct` family is decomposed into a parametric type `HLLSketch(p)` and three registered operators — `hll_count` (deliver), `hll_merge` (a monoid union, combine), `hll_estimate` (project) — that slot into the umbrella via the **registry and engine only**; `planner.py` and `projection.py` hold zero sketch references. Precision is type identity (a mismatched merge is a type error; a raw sketch is opaque to arithmetic). A publish-time **witness store** makes sketches **stored, not cached**, so `distinct@region` merges stored witnesses with **zero base scans at query time**.
|
|
25
|
+
|
|
26
|
+
> **v0.6.0-core — inform-and-serve reconciliation (Frame-QL Manual).** A B-anchor crossing (e.g. summing a stock over time) is now **served with a critical `b_anchor_crossing` disclosure** that names the alternative reducer — no longer refused. Refusals are reserved for the planner's static clarify/inform cases (fan-out across an M:N edge — now naming all three remedies; out-of-universe; unknown operator; type error). The engine, once handed an executable atom, never withholds on analytical grounds. Disclosures now carry a severity lattice (none<info<caution<critical) with a frame-level rollup. 57 checks across 7 suites pass.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
The column-foundation implementation specified in **ADR-031** and the **Manifold object model** — multi-table, transport-based, validated against the real benchmark warehouse (299,934 transactions).
|
|
30
|
+
|
|
31
|
+
This is **not** the ADR-030 kernel. The kernel proved correctness *techniques* on a single denormalized table; Core implements the architecture: **the backend delivers single-table column-atoms and functional relationship-columns; the engine *transports* and relates them; the backend never joins.**
|
|
32
|
+
|
|
33
|
+
## The discipline, in code
|
|
34
|
+
|
|
35
|
+
- `connector.py` — **single-table delivery only.** `deliver_measure` (one-table group-by), `deliver_edge` (one-table key→key mapping), `deliver_base_rows` (one-table, for sketches). No SQL join is ever generated.
|
|
36
|
+
- `model.py` — the Manifold object model. Two layers: **universes** (populations) and the **coordinate DAG** (`FunctionalEdge`s). A rollup (`day→month`) and a relationship (`store→region`) are the *same* object — a functional edge the engine transports along, tagged with a lineage. The **B-anchor** blocks per-lineage.
|
|
37
|
+
- `engine.py` — the center. For `(measure, family-member) @ anchor`: find the functional path, **B-anchor-check every transport edge *and* every collapsed dimension**, resolve cheapest-faithful (cache vs delivery), **transport** the measure along functional edges (in-engine; no join pushdown), co-compute disclosure, cache.
|
|
38
|
+
- `planner.py` — provenance-blind. Parses logical `family.member @ anchor`, expands derived columns, **typechecks addressability — fan-out and out-of-universe are refused HERE, statically** — then assembles frames and folds disclosures.
|
|
39
|
+
- `disclosure.py` — the disclosure shadow-value and its sibling, the structured, dialog-capable `Refusal` (carries named alternatives).
|
|
40
|
+
|
|
41
|
+
## What `build_benchmark.py` proves (10/10, real data)
|
|
42
|
+
|
|
43
|
+
1. **Transport replaces the join** — `revenue@region` computed from a single-table `revenue@store` delivery + the `store→region` mapping, related *in the engine*; exact vs. ground truth; **zero joins pushed down**.
|
|
44
|
+
2. **Coordinate rollup is the same operation** — `revenue@cal.month` via the `day→month` mapping.
|
|
45
|
+
3. **★ Fan-out is inexpressible ★** — `revenue@category` is **refused** at the planner (`transaction↔category` is M:N); for contrast, the naive join *silently inflates revenue 1.44× — a 44% overcount*. The refusal names its alternatives (allocation = Pro; membership = rephrase). The flagship.
|
|
46
|
+
4. **B-anchor blocks per-lineage** — `level.sum@(region,day)` *works* (additive over the store axis); `level.sum@store` is *refused* (would sum a stock across days — non-reconciling over the calendar lineage). Same metric, opposite verdicts, by edge.
|
|
47
|
+
5. **Pre/post-agg boundary** — `aov = revenue/orders` computed post-aggregation = correct AOV (not the avg-of-avgs the shipped `monthly_avg_order_value` would give).
|
|
48
|
+
6. **Sketch reaggregation** — `visitors@cal.quarter` by HLL-merging per-day sketches; ≈ true distinct, vs. a naive sum-of-daily-distincts that overcounts.
|
|
49
|
+
7. **Out-of-universe** — `level@product` refused as a *distinct* reason (out of domain — undefined, not missing).
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
engine: 5 single-table deliveries, 5 transports, 1 cache-hit, 10 backend fetches (all single-table)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Run
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install --break-system-packages polars duckdb datasketches pyarrow
|
|
59
|
+
python3 build_benchmark.py # 10 checks against the benchmark warehouse
|
|
60
|
+
```
|
|
61
|
+
(The script reads the warehouse parquets from the benchmark instance path; adjust `WAREHOUSE` if needed.)
|
|
62
|
+
|
|
63
|
+
## Ingest-first: the definition language
|
|
64
|
+
|
|
65
|
+
A written `MANIFOLD` definition (the `.cf` successor) parses to the Manifold object and is queryable end-to-end — no hand-construction. See `benchmark.cml` for the whole benchmark Manifold as text, and run:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
python3 parse_benchmark.py # parse benchmark.cml, then the SAME 10 checks on the PARSED Manifold
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The parser (`parser.py`) reproduces the hand-built object with full structural parity, the corrected semantics survive the parse (`M_ANCHOR { }` → MCAR; `FAMILY { sum : additive BLOCKED { calendar } }` → per-member B-anchor), and publish-time well-formedness checks reject malformed definitions (impure predicate referencing a measure, unknown level/universe/column, etc.).
|
|
72
|
+
|
|
73
|
+
Grammar (statement-oriented; `#` comments; `{ }` blocks):
|
|
74
|
+
```
|
|
75
|
+
MANIFOLD <name> VERSION <n>
|
|
76
|
+
UNIVERSE <name> = <dim> * <dim> ... [WHERE <predicate>]
|
|
77
|
+
LEVEL <name> = <column> [BASE]
|
|
78
|
+
EDGE <from> -> <to> ALONG <lineage> VIA <table>(<from_col>, <to_col>)
|
|
79
|
+
RELATE <a> <-> <b> VIA <table> [NOTE "<text>"]
|
|
80
|
+
MEASURE <name> ON <universe> FROM <table> AS <agg>(<expr>)
|
|
81
|
+
MEASURE <name> ON <universe> FROM <table> VALUE <expr>
|
|
82
|
+
[M_ANCHOR { <col>, ... }] [FAMILY { <agg> [: <tier>] [BLOCKED { <lineage>, ... }] ... }]
|
|
83
|
+
DERIVED <name> = <expr>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Scope (Core, per ADR-031)
|
|
87
|
+
|
|
88
|
+
**Logical types, checked at compile time** (`types.py`, `types_demo.py`): every measure declares a **logical (Polars) dtype** and every operator carries a **type signature** (`sum: Numeric∪Duration→same`, `distinct: any→Int64`, `median: Numeric∪Temporal→same`, `last: T→T`). The *signature* is vocabulary the planner holds; the *mechanics* (witness/combine/deliver_sql) stay engine-side. So "operator not supported" and "wrong type for this operator" are **vocabulary errors caught at the planner, before the engine is ever asked** — proven by zero backend fetches on a refused frame. A static type-inference pass runs as a compile step ahead of resolution (`type_error` is its refusal reason, a sibling of unknown-operator). The **connector owns logical→physical**: a measure declares logical `Float64` over a raw column, and the connector supplies the `TRY_CAST` when the physical type is a dirty `VARCHAR` — so the author writes no casts, and a cast *failure* is a coverage fact at resolution, never a type error.
|
|
89
|
+
|
|
90
|
+
In scope and working: multi-table Manifolds, universes **with runtime predicate confinement**, the coordinate DAG, transport, measure-families with per-lineage B-anchors, **the operator registry (reaggregation as a monoid property, plus type signatures)**, **logical types with a compile-time planner typecheck**, derived columns, structured refusals, EXPLAIN, the definition-language parser + well-formedness checks, **the universe-support consistency check**, **the two projections as an enforced boundary**. Deliberately out (Pro): multiple backends/federation, cloud, custom operators/types, sophisticated optimization, **allocation** (the M:N split — Core catches the case rather than computing it).
|
|
91
|
+
|
|
92
|
+
**Two projections, enforced** (`projection.py`, `projection_demo.py`): one authored Manifold has two projections. The **planner** holds a `PlannerView` — vocabulary/shape only: logical names, the DAG *topology* (`frm→to` + lineage, no physical columns), family member *names*, derived formulas, M:N pairs for fan-out. The **engine** holds the full Manifold — sources, realizations, the universe predicate, missingness, costs, the operator registry. This makes "the planner cannot see provenance" *structural*: `home_table`, `pre_expr`, `realized_by`, `provider_table`, and the predicate are simply absent from the planner's object — no source string is reachable from it — yet it still does real work (fan-out and out-of-universe are refused from shape alone). The handoff down is a logical request `(measure, member, anchor)`; the return up is a frame + a `Disclosure` (caveats, not sources). Disclosures cross the boundary; provenance does not.
|
|
93
|
+
|
|
94
|
+
**Reaggregation is a monoid property of the operator** (`operators.py` — the registry, which is the Core/Pro extension point). An operator is reaggregable iff a possibly-enriched witness makes it a monoid; the engine reduces in *witness-space* and projects to the answer at the boundary: `sum`/`count` carry the value (combine `+`), `min`/`max` the value (combine min/max), `distinct` an HLL sketch (combine union), `last`/`first` the **(value, order_key)** pair (combine argmax/argmin — the order key is carried as the witness), and `median`/`mode` are **holistic** (no finite witness → recompute-from-base, never reduced). Two independent gates compose: **monoid-ness** (operator-level, *possible*) and the **B-anchor** (column-level, *permitted*). The headline (`holistic_demo.py`): `level.last@(store, cal.month)` *works* by carrying the day and reducing by argmax, while `level.sum@(store, cal.month)` *refuses* — same column, same target, the two gates disagree.
|
|
95
|
+
|
|
96
|
+
**Universe-support consistency** (`universe_check_demo.py`): a universe is one population, so every measure bound to it must reduce to the same base-point support (modulo declared coverage). The check reduces each measure to its universe and compares supports; a mismatch not explained by coverage flags a mis-declared universe. (Benchmark passes; a measure mis-sourced from a half-coverage table is flagged "50% short".) This is the **count-reducer instance** of a more general *path-independence* check — reduce a measure to the universe singleton along every anchoring and assert the reduced values agree — which becomes exercisable once a second coordinatization of an axis (e.g. a fiscal calendar forking from `day`) exists; with a single anchoring there is nothing to reconcile against.
|
|
97
|
+
|
|
98
|
+
**Universe-predicate confinement** (`confine_demo.py`): a measure bound to a predicated universe is confined to its valid points *at the base grain, at delivery, before aggregation* — logically prior to any query `WHERE` (domain before selection), inherited through cache and transport. A cross-table predicate like `day >= stores.opened_date` is evaluated *in the engine*: `opened_date` is delivered from `stores` (single table) and **broadcast** onto `(store, day)` by transport, then compared and filtered — **never a backend join**. The demo injects out-of-domain rows; the engine excludes them while an unconfined Manifold silently includes them.
|
|
99
|
+
|
|
100
|
+
Still thin in this build (next): the full cached-vs-stored cost search (resolution is correct but the cost model is minimal); hoisting the **B-anchor permission** refusal (`blocked_reaggregation`) from the engine to the planner (it is structural and belongs there, but it currently sits in the engine to preserve behaviour — moving it means the `PlannerView` carries family-member shape); automated Discovery (the parser consumes a written definition; generating one from a warehouse is the layer above).
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
MANIFOLD benchmark VERSION 1
|
|
2
|
+
|
|
3
|
+
# ============================================================================
|
|
4
|
+
# Layer 1 — populations (universes). predicate carves the real population.
|
|
5
|
+
# ============================================================================
|
|
6
|
+
UNIVERSE transactions = customer * store * product * day
|
|
7
|
+
UNIVERSE store_days = store * day WHERE day >= stores.opened_date
|
|
8
|
+
|
|
9
|
+
# ============================================================================
|
|
10
|
+
# Layer 2 — coordinate. Base levels, then functional edges.
|
|
11
|
+
# A rollup (day->month) and a relationship (store->region) are the SAME thing:
|
|
12
|
+
# a functional edge the engine transports along, tagged with a lineage.
|
|
13
|
+
# ============================================================================
|
|
14
|
+
LEVEL customer = customer_id BASE
|
|
15
|
+
LEVEL store = store_id BASE
|
|
16
|
+
LEVEL product = product_id BASE
|
|
17
|
+
LEVEL day = day BASE
|
|
18
|
+
LEVEL region = region
|
|
19
|
+
LEVEL cal.week = week
|
|
20
|
+
LEVEL cal.month = month
|
|
21
|
+
LEVEL cal.quarter = quarter
|
|
22
|
+
LEVEL cal.year = year
|
|
23
|
+
LEVEL category = category_id
|
|
24
|
+
|
|
25
|
+
EDGE store -> region ALONG store_geo VIA stores(store_id, region)
|
|
26
|
+
EDGE day -> cal.week ALONG calendar VIA calendar(day, week)
|
|
27
|
+
EDGE day -> cal.month ALONG calendar VIA calendar(day, month)
|
|
28
|
+
EDGE day -> cal.quarter ALONG calendar VIA calendar(day, quarter)
|
|
29
|
+
EDGE day -> cal.year ALONG calendar VIA calendar(day, year)
|
|
30
|
+
|
|
31
|
+
# non-functional (M:N) — declared only so a fan-out refusal can name the edge.
|
|
32
|
+
RELATE product <-> category VIA product_categories NOTE "a product belongs to up to 3 categories"
|
|
33
|
+
|
|
34
|
+
# ============================================================================
|
|
35
|
+
# Measures. Inline AS for single-member families; VALUE + FAMILY for multi.
|
|
36
|
+
# ============================================================================
|
|
37
|
+
MEASURE revenue ON transactions FROM transactions AS sum(amount)
|
|
38
|
+
MEASURE orders ON transactions FROM transactions AS count(*)
|
|
39
|
+
MEASURE visitors ON transactions FROM transactions AS distinct(customer_id)
|
|
40
|
+
|
|
41
|
+
# semi-additive stock. sum: blocked over calendar (totalling stock across time is
|
|
42
|
+
# non-reconciling). last: an ORDERED monoid over day (carry day as witness) — the
|
|
43
|
+
# period-end snapshot is the point, so last is NOT blocked over calendar.
|
|
44
|
+
# Tier (additive/sketch/holistic) is NOT declared here: it is operator-level, from the registry.
|
|
45
|
+
MEASURE level ON store_days FROM eom_inventory VALUE level
|
|
46
|
+
M_ANCHOR { }
|
|
47
|
+
FAMILY {
|
|
48
|
+
sum BLOCKED { calendar }
|
|
49
|
+
last ORDER day
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# holistic measure: median basket amount — non-monoid, recompute-from-base, never reduced
|
|
53
|
+
MEASURE med_amount ON transactions FROM transactions AS median(amount)
|
|
54
|
+
|
|
55
|
+
# a CATEGORICAL measure — only count/distinct/mode are well-typed over it (never sum/median)
|
|
56
|
+
MEASURE region_label ON transactions FROM transactions AS mode(customer_region)
|
|
57
|
+
|
|
58
|
+
# ============================================================================
|
|
59
|
+
# Derived columns — post-aggregation over measures.
|
|
60
|
+
# ============================================================================
|
|
61
|
+
DERIVED aov = revenue / orders
|