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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,12 @@ uv run --no-project --isolated --python 3.12 \

uv run --no-project --isolated --python 3.12 \
--with "orcapod[spiraldb] @ git+https://github.com/metamorphic-labs/orcapod-python@<new>" \
--with spiral-sdk==0.16.74 scripts/migrate_spiral_schemas.py \
--with spiral-sdk==0.16.78 scripts/migrate_spiral_schemas.py \
write --project <project> --dataset <dataset> --plan plan.json --digest <printed digest>

uv run --no-project --isolated --python 3.12 \
--with "orcapod[spiraldb] @ git+https://github.com/metamorphic-labs/orcapod-python@<new>" \
--with spiral-sdk==0.16.74 scripts/migrate_spiral_schemas.py \
--with spiral-sdk==0.16.78 scripts/migrate_spiral_schemas.py \
verify --project <project> --dataset <dataset> --plan plan.json
```

Expand Down
3 changes: 3 additions & 0 deletions changelog.d/ITL-1495.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- The `spiraldb` extra pins `spiral-sdk==0.16.78` (was `0.16.74`), the release that reads and writes a SpiralDB table's metadata. Orcapod still only reads SpiralDB; the conformance tests pass on the service with it.
36 changes: 36 additions & 0 deletions docs/dev/plans/2026-11-26-itl-1495-spiral-store-names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# ITL-1495: SpiralDB store, stages 0 and 1

Stages 0 and 1 of `docs/dev/specs/itl-1446-round2-spiral-sdk.md` (PR 588), approved by the
coordinator on the developer's behalf (decisions 1, 2, 3, 4 and 6). One pull request.

## Stage 0: spiral-sdk 0.16.78

1. `pyproject.toml`: `spiral-sdk==0.16.78`; `uv lock --upgrade-package spiral-sdk`. The version
in `RELEASING.md`'s migration commands follows.
2. `tests/test_databases/fake_spiral_sdk.py`: `get_metadata` / `set_metadata` on the fake keyed
table, as measured live with 0.16.78 (rule `table-metadata`): an upsert, never a deletion,
not versioned, readable before any row, a key over 255 UTF-8 bytes, or an entry whose key
and value together are over 8,192 bytes, refused with `status 400` and nothing written.
3. Tests first: a conformance test of table metadata in
`tests/test_databases/test_spiraldb_connector_integration.py`, run on the fake always and
live opt-in, with fixed keys so a live table does not grow. The live conformance suite is
rerun with 0.16.78 (`itl-1186-switch.md` section 7: a bump reruns it).

## Stage 1: store table names

`src/orcapod/databases/spiral_store_names.py`, pure, imports no client:

- `SPIRAL_TABLE_NAME_LABEL = "spiral_table_name_v1"`, beside `store_table_digest(path)`: SHA-256
of the canonical JSON array of the full path components, bare hex (a hash in a name).
- `table_name_hint(path)`, `store_table_name(path)` (`o1_<hint>_<digest>`), and
`store_table_name_prefix(prefix)`, the name prefix every table under a path prefix has.
- `store_table_metadata(path, data_context_key)`: the four entries of spec 2.2.
- `classify_store_table(metadata, path)`: this path's table, or an unmarked one (2.5); any other
path, format or a partial record raises `SpiralStoreTableCollisionError`.

Then: the hash site inventory row in `docs/reference/hashing.md` ("in a name"); a golden group
`spiral_table_name` in `tests/test_hashing/golden/cases.py`, written by the generator into a new
file (the diff adds only that file and its history entry). Tests: determinism, the length bound,
the alphabet, prefix property of the hint, injectivity on adversarial paths, refusals.

Nothing calls the module yet; no other hash, stored path or golden value moves.
46 changes: 46 additions & 0 deletions docs/dev/plans/2026-11-26-itl-1497-spiral-store-codec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# ITL-1497: the codec of a SpiralDB store table, on spiral-sdk

Stage 2 of `docs/dev/specs/itl-1446-round2-spiral-sdk.md` (PR 588), approved by the
coordinator on the developer's behalf (decision 4). It stacks on PR 589 (ITL-1495: spiral-sdk
0.16.78 and its fake).

## What is carried over from PR 545

`src/orcapod/databases/spiral_store.py` and `tests/test_databases/test_spiral_store.py`, from
PR 545's branch, with these changes:

- **The manifest is one payload**, `manifest_bytes` / `read_manifest`. Where it is kept is
stage 3's: decision 4 was revised on 2026-11-26 (ITL-1498), and stage 3 keeps it in the
table's own metadata, in chunks of at most 8 KiB (a key and its value together), beside the
identity record (`spiral_store_names`, PR 589). It is not kept in the dataset's schema table,
which is all or nothing under one completion marker. The format stays a draft
(`orcapod.spiral_store.draft`, version 0) until stage 3 fixes it as version 1.
- **Timestamps are written as they are**, not as integers.
- **A null fixed-size list of structs is kept**, no longer refused.
- Everything else is unchanged: names, types, nullability, refusals before anything is written,
reading by the manifest's stored names, no row order.

## Measured live with spiral-sdk 0.16.78 (2026-11-26, throwaway tables)

| What | Result |
|---|---|
| booleans, integers (`uint64` max), floats (signed zeros and NaN payloads, `float16` too), `decimal128/256`, `date32`, `date64` off midnight, `null` | kept bit for bit |
| timestamps of every unit, with and without a zone, every `int64` value (`datetime.max` and `.min` included) | kept bit for bit: **written as they are** (pyspiral's service refused instants after 9999-12-30) |
| `time32` / `time64` within a day | kept; **outside one day: the whole write refused**, so times stay integers |
| `decimal32/64` | come back as `decimal128`: written as such, restored |
| strings, binaries, lists | come back in their small variants: normalized on read |
| struct fields | sorted by name at the top level (not inside a list): restored by name |
| map `keys_sorted` | dropped: restored from the manifest |
| a null fixed-size list of structs | **kept** (the refusal is lifted) |
| a null struct item inside a list | kept by the service; still refused by the codec, which does not yet carry a struct's validity (a later lift) |
| a null struct at the top level, an empty struct, `fixed_size_binary`, `duration`, `interval` | refused |
| column and struct field names | refused: a `__` or `$` prefix, any `.`, exactly `*`, the empty name. Kept: `$`, `*` and `;` inside a name, control characters, case and Unicode normal forms apart, 1,024 characters. NUL is cut silently. The codec's escape rule covers every refusal and NUL, so it is unchanged |
| a write of no rows | publishes nothing; a key-only write is refused |

The fake (`tests/test_databases/fake_spiral_sdk.py`) now refuses the empty name, `*` and times
outside a day as the service does. The conformance tests (`test_spiraldb_connector_integration.py`)
run the codec through spiral-sdk on the fake and live: the rows written are the rows read. They
also check that the service refuses each name and value listed in the refusal test
(`test_what_the_store_codec_avoids_is_refused`). Not every value the codec avoids is refused by
the service: the codec also refuses what the service keeps but the codec cannot yet carry back
(a null struct item inside a list).
1 change: 1 addition & 0 deletions docs/reference/hashing.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ test session with `-p tests.test_hashing.hash_site_trace`.
| user-class identity | a class's identity record | SHA-256 hex prefix | extension name `name@<fingerprint>` (a name) | `logical_types/user_class_identity.py:identity_string` |
| database registry key | a database config, canonical JSON | SHA-256 hex, 8 digits | `db_<hex>` key in a saved job (a name) | `pipeline/serialization.py:DatabaseRegistry._make_key` |
| SpiralDB schema table digest | the scope and the rows of a dataset's schema table, canonical JSON with the stored schema bytes | SHA-256 hex | completion marker of the schema table (a checksum of stored rows) | `databases/spiraldb_schema_table.py:rows_digest` |
| SpiralDB store table name | a store table's full path components, canonical JSON | SHA-256 hex, `spiral_table_name_v1` (`SPIRAL_TABLE_NAME_LABEL`, not written into the name) | the end of the table's SpiralDB name `o1_<hint>_<hex>` (a name; pinned in the `spiral_table_name` golden group) | `databases/spiral_store_names.py:store_table_digest` |
| synthesized struct class name | the field signature | MD5 hex, 8 digits | a Python class name (a name) | (not reached by a traced test) `semantic_types/universal_converter.py` |
| random ids | nothing | `uuid4`, `uuid7` | run ids, datagram and record uuids, observer ids, correlation keys | (not hashes) |
| unused code | Arrow tables | SHA-256, SHA3, BLAKE2b | no caller; removal is ITL-1156 | (not reached) `hashing/arrow_utils.py`, `hashing/arrow_serialization.py` |
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ postgresql = ["psycopg[binary]>=3.1.17"]
spiraldb = [
# Exact: a pre-alpha that releases daily, and Orcapod reads two attributes that are
# not its public API (ITL-1186). How to move it: RELEASING.md.
"spiral-sdk==0.16.74",
"spiral-sdk==0.16.78",
]
# Convenience extra that installs PyTorch. Orcapod's torch.Tensor support depends only on
# torch being importable, however it was installed (ITL-871). 2.6 is the first version whose
Expand Down
7 changes: 4 additions & 3 deletions src/orcapod/contexts/data/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,14 @@
"digest": "373ad66e7e9cc3a411708a4470a30d2176aedf9c9ba1ecdbe1111359ceb25867"
},
{
"date": "2026-11-23",
"date": "2026-11-26",
"release": null,
"added": {
"pipeline-02.json": "af19c4b5bafcd7428011db8bf5ddb125f8b59083b7c085613411eae36e9e23c2"
"pipeline-02.json": "af19c4b5bafcd7428011db8bf5ddb125f8b59083b7c085613411eae36e9e23c2",
"spiral_table_name-01.json": "23f16efb72cafe90692e1b19bc0cdb7aee694cb255e5685f7b7892fb3d2c80c9"
},
"previous": "373ad66e7e9cc3a411708a4470a30d2176aedf9c9ba1ecdbe1111359ceb25867",
"digest": "57215540370eca6c81d5170c471e0d979482ee04235e47e4bfd05317936f2a27"
"digest": "9954784272f13773cec21434ccb441b064ab640707f556f556ed789c6d5a229f"
}
],
"provisional": {
Expand Down
Loading
Loading