Skip to content

feat: the closed check, on the protocol - #56

Merged
AlexeyShalaev merged 1 commit into
masterfrom
feat/closed-on-the-protocol
Sep 3, 2026
Merged

AlexeyShalaev merged 1 commit into
masterfrom
feat/closed-on-the-protocol

Conversation

@AlexeyShalaev

Copy link
Copy Markdown
Member

is_partition_closed(partition_name, *, settle_seconds=0, boundaries=None) joins PartitionMetadataProvider in both mirrors.

Why

PartitionToolkit.from_engine always builds a PostgresMetadataProvider and hands it back as kit.metadata: PartitionMetadataProvider. The closed check lived on the implementation only, so under a type checker kit.metadata.is_partition_closed(...) did not exist and a consumer narrowed with isinstance(kit.metadata, PostgresMetadataProvider) first, which is what the toolkit was built to make unnecessary. The toolkit takes a boundary_codec for that one call and the archiving guide has a section for it; the protocol just never listed it.

What

  • The method on the protocol, aio and its sync mirror, with the contract the Postgres provider keeps: True once the upper bound plus the settle buffer has passed on the database's clock; False rather than an exception when the bound cannot be read.
  • tests/unit/test_protocols.py: every protocol method has the implementation's signature, and every public method of the implementation is on the protocol unless listed as Postgres-only (evaluate_sql_predicate, get_partition_boundaries, get_partition_column). Metadata and repository, both mirrors.
  • Docs: the extending guide's list of reads, the 1.0 cheatsheet, and the migration guide's export paragraph, which now recommends boundaries=config.time_boundaries like every other page.
  • A hand-written 1.4.0 section at the top of the changelog.

A provider of your own now has to implement the method: a stub without it no longer satisfies the protocol under a type checker. At runtime nothing changes until the method is called.

Checks

ruff, mypy (the package plus the new test module), 2792 unit tests. A consumer probe calling the method through PartitionToolkit.from_engine(...).metadata type-checks in both mirrors without narrowing.

is_partition_closed(name, *, settle_seconds=0, boundaries=None) is a
method of PartitionMetadataProvider in both mirrors.

It was always the export pipeline's question: the archiving guide is
written around it, and PartitionToolkit.from_engine takes a
boundary_codec for that one call. But only the Postgres provider
declared it, and the toolkit hands its provider back under the
protocol's type, so under a type checker kit.metadata.is_partition_closed
did not exist and a caller narrowed with isinstance first -- which is
what the toolkit was built to make unnecessary.

A provider of your own now has to answer it, the way the Postgres one
does: True once the upper bound plus the settle buffer has passed on the
database's clock, False rather than an exception when the bound cannot
be read.

A test holds every protocol method to the Postgres implementation's
signature, in both mirrors, so the next method to land on the
implementation alone is caught there.
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@AlexeyShalaev
AlexeyShalaev merged commit 6f5e742 into master Sep 3, 2026
32 checks passed
@AlexeyShalaev
AlexeyShalaev deleted the feat/closed-on-the-protocol branch September 3, 2026 17:44
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