Implementation started
Work has started on branch ai/mvp-03a-ydb-partitioning, based on merged main commit b0a087b.
The first schema/access-pattern audit confirmed the planned distinction:
- tenant entity and per-run ordered tables retain tenant-first keys, with a non-time-sortable random ID contract and explicit load-aware settings on expected high-write tables;
- global ready/expiry traversal moves to a versioned 16-bucket physical layout so the reconciler has bounded fan-out and one elephant tenant can be distributed;
- legacy ready/expiry tables remain available during an expand/backfill/cutover compatibility window.
Implementation includes live JSON schema inspection, deterministic distribution tests, dual writes, an idempotent backfill command, YDB Local contract tests, and the cloud metric gate required by #12/#14.


Implementation update — physical partitioning contract
Implementation is published in MR !7, branch ai/mvp-03a-ydb-partitioning, commit 4c4075c.
Implemented
- Production opaque IDs use 128 random bits and non-time-sortable Base32 encoding.
bucket_v1is a golden-vector-tested SHA-256 modulo-16 protocol shared by writers/readers.- Four bucketed v2 ready/expiry tables use
(bucket, time, tenant, object)keys and 16 explicit initial ranges. - Expected high-write tenant tables have explicit load/size partition settings.
- State-store mutations dual-write legacy and v2 ready/expiry rows during the compatibility window.
- The future reconciler has a bounded per-bucket lease-expiry traversal.
schema-inspectemits live primary keys, settings, partition counts and drift as JSON.schema-backfillidempotently copies legacy ready/expiry rows into v2.- Public documentation contains the full 22-table inventory, ID contract, expand/backfill/cutover/contract procedure, and cloud metric gate.
- Tests cover monotonic elephant traffic, many-tenant bursts, bounded fan-out, migration ordering, dual writes, quota/delivery retry, backfill and live partition inspection.
Verified locally
make ci
go test -run '^$' -tags=ydbintegration ./test/ydbintegration
git diff --check
Docker is unavailable on the development workstation, so no YDB Local execution claim is made. The GitHub mirror has not yet received branch ai/mvp-03a-ydb-partitioning; therefore MR !7 remains open and #16 remains in progress until mirror sync triggers the mandatory YDB and image jobs.


Post-merge verification update
MR !7 merged as fb31bf8. The exact mirrored SHA reached GitHub Actions run #9.
The run exposed one integration failure, so this issue remains open:
- all 38 YDB migrations applied successfully twice;
- Go verification passed;
TestPartitioningContractMatchesYDBLocalfailed before reading table metadata because native YDBDescribeTablereceived the relative pathtenantsinstead of the required absolute database-qualified path/local/tenants.
The correction is published in MR !8, commit 275f2f3:
- the YDB client now exposes its native absolute database path;
- the inspector resolves every physical table below that path and rejects relative database roots;
- CLI/integration callers were updated;
- regression tests prove
/local/tenantsresolution and fail-closed relative-path handling.
Local make ci, tagged-package compilation, and git diff --check pass. Issue #16 will close only after MR !8 reaches the GitHub mirror and the YDB integration job is green.


Completion report — YDB partitioning contract
The partitioning contract from this issue is now implemented and verified.
Delivered
- MR !7 added the physical YDB partitioning contract, the repository-owned
ydb-partition-checkinspector, schema documentation, CI coverage, and the required table/index corrections. - The initial post-merge run exposed a real inspection-path defect: native YDB table descriptions require database-qualified absolute paths.
- MR !8, commit
275f2f3, fixed path resolution and added regression coverage for/local/<table>inspection plus fail-closed handling of relative database paths.
Verification
GitHub Actions run 30461247750 completed successfully for 275f2f3:
- Go verification — passed;
- Local multi-service stand — passed;
- YDB schema and state store — passed, including migrations and physical partition inspection;
- Runtime images — passed.
MR !8 was merged into main as fbb9f4e. The tested hotfix commit and the merge commit have the same Git tree, d30ad8094c0aa8d700f48019ca7edc1acc723c02, so the green run verifies the exact source tree now present on main.
All acceptance criteria are satisfied.


Follow-up correction — let YDB own physical partition counts
MR !12 corrects an over-constrained part of the MVP-03A executable contract.
The stable output of this issue remains the primary-key layout, high-entropy identifier policy, logical ready/expiry bucket function, and required load-based auto-partitioning. The exact minimum, maximum, target size, and current number of YDB partitions are operational telemetry and capacity tuning, not application schema invariants.
The 16 ready/expiry buckets bound reader fan-out but do not require 16 physical DataShards. Forward migrations 00041–00044 lower the original minimum floor so YDB can merge ranges under low load and split them again by load or size. CI will continue to validate keys and enabled auto-partitioning while accepting partition-count changes made by YDB or evidence-backed environment tuning.


Pre-deployment baseline cleanup
MR !13 supersedes the provisional forward-migration portion of !12.
Because Sessionless has no persistent YDB deployment or application data, migrations 00023–00040 can still be corrected as a baseline. The MR removes 00041–00044, all manual split boundaries, and all numeric partition-count/size tuning. Clean local and CI databases will apply the resulting 40-file baseline from scratch.
The migration set becomes immutable only when the first persistent cloud-dev environment records it as deployed. This does not change the durable primary-key, logical bucket, or auto-partitioning decisions delivered by MVP-03A.


Parent and architecture
Outcome
Turn the current correctness-oriented YDB schema into an explicit, measurable physical partitioning contract before Telegram ingress and scheduler/reconciler traffic make primary-key changes expensive.
Estimate
Why this is a separate task
YDB row tables are range-partitioned by the lexicographically ordered composite primary key. Size-based automatic partitioning is enabled by default, but load-based partitioning is disabled; a small hot table can therefore remain one partition with one CPU core of update capacity.
The current 22-table schema is correct and tenant-isolated, but it does not yet prove write distribution or scale behavior. This work must remain separate from scheduler business logic and must complete before cloud-dev contains durable application data.
Scope
tenant_id,run_id, attempt, lease, outbox, delivery, manifest and observation identifiers:dispatch_ready,telegram_delivery_ready,lease_expiry,quota_expiry, and any audit/usage path that requires global consumption:shard_bucket Uint32leading key with deterministic derivation and bounded parallel fan-out.AUTO_PARTITIONING_BY_LOAD;ALTER TABLE.Design constraints
tenant_id; a physical bucket never replaces tenant validation.Verification
Acceptance criteria