Skip to content

fix(spiraldb): enforce verified pyspiral write refusals (ITL-1446) - #544

Closed
eywalker wants to merge 4 commits into
mainfrom
eywalker/itl-1446-strict-fake
Closed

eywalker wants to merge 4 commits into
mainfrom
eywalker/itl-1446-strict-fake

Conversation

@eywalker

@eywalker eywalker commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Part of ITL-1446.

  • Model verified SpiralDB behavior in the disk fake, including key-only and zero-row write refusals, duplicate keys in one Arrow batch, reserved value names, struct field order, and null rows for absent keys in a keyed scan.
  • The connector rejects fixed-size binary, duration, and NUL-containing column names. It enforces the service's measured 255-character limit on the table part of a name. Untyped Arrow null values round-trip.
  • Regenerate the database type matrix. Only the four duration units and fixed-size binary now change their SpiralDB verdicts.

PR 542 defines the scope. The verification notes cite the installed client, offline conversion, native diagnostics, and the coordinator's service verification.

Validation

Summary by CodeRabbit

  • Bug Fixes
    • SpiralDB now rejects table names that are empty, contain dots, or exceed 255 characters, and column names containing NUL characters.
    • Writes are rejected when columns use fixed-size binary or duration types, including when these types are nested or dictionary values.
    • Invalid input is checked before writing, helping prevent rejected writes from changing stored data or metadata.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The connector now rejects additional SpiralDB table names and column types before database operations. The fake SpiralDB implementation adds schema and write validation, identifier-based storage, and key-ordered scan results. Tests and reference documents reflect these behaviors.

Changes: SpiralDB validation and fake behavior

Layer / File(s) Summary
Connector refusal rules and integration
src/orcapod/databases/spiraldb_connector.py, docs/reference/database-types.md, tests/test_databases/test_spiraldb_connector_fake.py, tests/test_core/..., changelog.d/ITL-1446.md, docs/dev/...
The connector rejects empty, dotted, and over-255-character table names. It also rejects NUL-containing column names and fixed-size binary or duration types, including nested occurrences. Tests and documents reflect these rules.
Fake table schema and write behavior
tests/test_databases/fake_pyspiral.py, tests/test_databases/test_spiraldb_connector_fake.py
The fake validates table names, key schemas, Arrow types, and write batches. It hashes table identifiers for storage and detects nested struct nulls.
Fake scan ordering and struct fields
tests/test_databases/fake_pyspiral.py, tests/test_databases/test_spiraldb_connector_fake.py
Fake scans can preserve requested key order and return null rows for missing keys. The fake sorts struct fields, and tests cover the read behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant SpiralDBConnector
  participant FakeTable
  participant _Store
  SpiralDBConnector->>SpiralDBConnector: Validate input fields
  SpiralDBConnector->>FakeTable: Write validated record batch
  FakeTable->>FakeTable: Check batch and schema constraints
  FakeTable->>_Store: Persist table data
Loading

Possibly related PRs

Merge Risk: Minimal · up to fd728

The change tightens SpiralDB table-name and column-type refusals in the connector and makes the test fake stricter. The visible evidence shows no concrete merge-blocking risk. Two unverified edge-case questions about the fake and nested field names remain, and neither blocks merging.

Security architecture risk: Minimal · up to fd728

The new checks reject unsupported inputs before changing stored data. Some invalid calls now raise earlier or instead of doing nothing, but the reviewed change does not establish a new security, data-ownership, or recovery risk.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is to callers of the existing connector operating within its configured project and dataset. The changed paths narrow accepted inputs without introducing a new destination, credential, or operation.

Trust Boundaries and Controls

  • observed — Caller-supplied table names still resolve through the configured dataset. Upsert still checks the requested identity column against the resolved table’s key schema and requires all key columns before any write.

Resilience and Maintainability Implications

  • observed — Accepted upserts still use the existing metadata-before-rows sequence and best-effort cleanup on failure. The new refusals occur before that sequence and do not make it atomic or change its interruption and concurrency guarantees.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the primary change: enforcing verified pyspiral write refusals in the SpiralDB connector and fake, tied to ITL-1446. The changeset adds table-name limits, rejects fixed-size binary, du…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the primary change: enforcing verified pyspiral write refusals in the SpiralDB connector and fake, tied to ITL-1446. The changeset adds table-name limits, rejects fixed-size binary, duration, and NUL-containing column names, and updates the fake to match pyspiral write behavior. The title is specific and matches the main change. It uses the conventional 'fix(scope):' form and is 66 characters, within a reasonable length.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7a2248b and fd72822.

Files selected for processing: 10

  • changelog.d/ITL-1446.md
  • docs/dev/design_issues/ITL-1162-CA3.md
  • docs/dev/plans/2026-11-24-itl-1446-strict-fake.md
  • docs/reference/database-types.md
  • src/orcapod/databases/spiraldb_connector.py
  • tests/test_core/data_tags/test_database_capability.py
  • tests/test_core/sources/test_spiraldb_table_source_fake.py
  • tests/test_core/sources/test_spiraldb_table_source_where.py
  • tests/test_databases/fake_pyspiral.py
  • tests/test_databases/test_spiraldb_connector_fake.py

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Recent review details

Context from checks skipped due to timeout: 6

  • GitHub Check: Tests (3.13)
  • GitHub Check: CodeRabbit
  • GitHub Check: PostgreSQL tests (3.13)
  • GitHub Check: PostgreSQL tests (3.11)
  • GitHub Check: PostgreSQL tests (3.12)
  • GitHub Check: Ruff and basedpyright
Additional context used

Code guidelines: 1

CLAUDE.md — auto-discovered
Path-based instructions: 10

Source excerpt: Every fenced `python` block in `README.md`, `docs/index.md`, `docs/getting-started.md`, `docs/troubleshooting.md`, `docs/concepts/`, `docs/reference/` and `docs/tutorial/` is executed by `tests/test_docs/test_doc_samples.py`...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • docs/reference/database-types.md
Source excerpt: Respect the Arrow types the inputs already have, normalized to their large variants (developer, November 10, 2026: large and non-large variants hash identically, so always normalize to large for consistency).

CodeRabbit inference engine (CLAUDE.md)

Files:

  • src/orcapod/databases/spiraldb_connector.py
Source excerpt: `docs/` is the only source.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • docs/dev/design_issues/ITL-1162-CA3.md
  • docs/dev/plans/2026-11-24-itl-1446-strict-fake.md
  • docs/reference/database-types.md
Source excerpt: Tests and golden fixtures that build a source with tag columns pass `tag_only_columns=True` unless the test is about the default (developer, November 16, 2026, ITL-1159).

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/test_core/data_tags/test_database_capability.py
  • tests/test_core/sources/test_spiraldb_table_source_fake.py
  • tests/test_core/sources/test_spiraldb_table_source_where.py
  • tests/test_databases/fake_pyspiral.py
  • tests/test_databases/test_spiraldb_connector_fake.py
Source excerpt: A pull request never edits `CHANGELOG.md` (developer, November 11, 2026; ITL-961).

CodeRabbit inference engine (CLAUDE.md)

Files:

  • changelog.d/ITL-1446.md
Source excerpt: An entry is the file `docs/dev/design_issues/-.md` (e.g.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • docs/dev/design_issues/ITL-1162-CA3.md
Source excerpt: The file holds only the text that would have gone under the release heading in `CHANGELOG.md`: the same category headings `CHANGELOG.md` uses (`### Breaking changes and migration`, `### Added`, `### Changed`, `### Fixed`, `#...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • changelog.d/ITL-1446.md
Source excerpt: Tests use the **public interface** wherever possible (developer, November 10, 2026): drive an operator by calling it, `op(stream)`, and read the result through the stream's public methods.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/test_core/data_tags/test_database_capability.py
  • tests/test_core/sources/test_spiraldb_table_source_fake.py
  • tests/test_core/sources/test_spiraldb_table_source_where.py
  • tests/test_databases/fake_pyspiral.py
  • tests/test_databases/test_spiraldb_connector_fake.py
Source excerpt: Write pages as before: a `# <title>` first line, mkdocs-style admonitions (`!!!

CodeRabbit inference engine (CLAUDE.md)

Files:

  • docs/dev/design_issues/ITL-1162-CA3.md
  • docs/dev/plans/2026-11-24-itl-1446-strict-fake.md
  • docs/reference/database-types.md
Use [Google style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) Python docstrings everywhere.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • src/orcapod/databases/spiraldb_connector.py
  • tests/test_core/data_tags/test_database_capability.py
  • tests/test_core/sources/test_spiraldb_table_source_fake.py
  • tests/test_core/sources/test_spiraldb_table_source_where.py
  • tests/test_databases/fake_pyspiral.py
  • tests/test_databases/test_spiraldb_connector_fake.py
Learnings: 1

Common learnings

Learnt from: CR
Repo: metamorphic-labs/orcapod-python PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-11-24T01:41:10.097Z
Learning: Source excerpt:
# Claude Code instructions for orcapod-python

## Lint, format and type checks

What runs where (developer, November 16, 2026; ITL-1181):

- New and changed code must be ruff-clean and ruff-formatted, and must add no
  basedpyright errors. Warnings are reported but do not fail the check
  (`failOnWarnings = false`); still do not add them needlessly. Run
  `uv run ruff format .` and `uv run ruff check .` before committing;
  `uv run pre-commit install` once per clone runs both on every commit.
Additional comments: 2

tests/test_databases/fake_pyspiral.py: 1

619-619: Functional Correctness

The concern is plausible but not decidable from the available evidence. The fake batches only the key projection at tests/test_databases/fake_pyspiral.py:619. In the pinned pyspiral 0.16.33 path, a plain pa.Table reaches Table.to_reader(), so the native writer may receive batches cut by the full table's chunk layout. Two decisive premises remain unresolved:

  1. The Rust normalize_write_input method, which runs before evaluate, is not available in the inspected artifacts. If it coalesces chunks, the fake's projection produces the same batches and the concern is refuted.
  2. The C++ TableBatchReader batch-boundary semantics were not read. The claim that to_reader splits on the union of column chunk boundaries is unverified.

The native writer's handling of duplicate keys across batches is also unestablished. The notes present cross-batch detection as unmodeled, not as refused.

src/orcapod/databases/spiraldb_connector.py: 1

607-608: Data Integrity & Integration

The concern cannot be decided from the available evidence. The connector checks NUL names only at the top level, so a struct child named before\0after passes its checks. Whether that child name is truncated, preserved, or rejected by pyspiral determines whether the write can store a different schema. The verification notes measure truncation for a column name but do not state the nested case, and the pyspiral source is not available in the sandbox. The claim is therefore undecided, not refuted and not supported.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/orcapod/databases/spiraldb_connector.py 94.28% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/orcapod/databases/spiraldb_connector.py 98.20% <94.28%> (-0.35%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eywalker

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #550 (ITL-1186): the switch to spiral-sdk removed the connector write path and the test fake this PR changes, and the new fake on main already models most of the refusals added here. The three findings not on main (table-name limits, key-table null rows, zero-row writes) are carried over to ITL-1476.

Posted by a Claude Code agent on behalf of @eywalker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant