已关闭
[SESSION-02] Implement YDB canonical session schema and bounded indexes #21
urandon创建于 8月3日关闭于 8月5日
8月4日 修改了issue 的描述
8月4日 关联了pull request:SESSION-01: define canonical session and event contracts
8月5日 关联了pull request:SESSION-02: persist the canonical Session model
urandon
8月5日 评论:
8月5日 评论:
Implementation update — canonical Session persistence
Implementation is published in MR !20, branch ai/session-02-canonical-schema, commit 470f4b6.
Implemented
- Rebased the disposable pre-production migration baseline: legacy
conversationsandcontext_epochstables are replaced by canonicalsessionsand append-onlysession_events. - Added tenant-first YDB tables for event idempotency, frontend bindings and their lookup keys, participants, fixed-fanout session activity, snapshots, and runs-by-session.
- Extended runs with
session_idandtrigger_event_id; the YDB store maintains the session index atomically. - Implemented serializable, gap-free event sequence allocation with exact retry semantics. The live concurrency test proves that parallel appenders produce one contiguous sequence and that retrying an idempotency key returns the original event.
- Implemented session lifecycle, binding creation/switching, participant authorization, bounded history/snapshot reads, activity listing, and per-session run listing with tenant mismatch rejection.
- Updated Telegram identity resolution so Telegram remains a frontend adapter: the initial interaction creates a canonical Session, and
/newcreates another Session and atomically switches the binding. - Added canonical Object Storage key contracts under
tenants/{tenant_id}/sessions/{session_id}/...; cross-session and cross-tenant references fail closed. - Kept YDB automatic partition management on canonical hot tables. The logical contract fixes tenant-first keys and 16 deterministic activity buckets, but does not assert or manage an exact physical partition count.
- Added
preprod-reset,make cloud-app-reset-plan, andmake cloud-app-reset. The destructive path requires the exact Terraform-resolved cloud-dev folder, YDB endpoint, bucket,tenants/prefix, and a target-derived typed confirmation. It drops only the explicit Sessionless table allowlist and preserves infrastructure and unrelated object prefixes. - Updated the public architecture/development documentation to describe Sessionless-owned canonical conversations and the intentional cloud-dev reset/rebase procedure.
Verified
make cipassed: generation, vet, race tests, all ten binaries, and foundation integration tests.- A clean YDB Local migration and a repeated migration both passed.
make ydb-integrationpassed, including concurrent append, idempotency, bindings, participant/activity reads, snapshots, runs-by-session, tenant isolation, and partition contracts.make local-integrationpassed after a clean local application-data reset.make e2e-localpassed all deterministic multi-user scenarios, including the/newbinding transition.git diff --checkand shell syntax validation passed.
No production or irreplaceable data exists yet, so this MR intentionally performs a baseline rebase instead of adding compatibility backfill or dual-read paths. The cloud-dev reset remains an explicit operator action; merging or deploying the application does not trigger it automatically.


urandon
8月5日 评论:
8月5日 评论:
Completion report
MR !20 has been merged into main as commit 76804cd.
The final implementation includes the canonical append-only Session schema, bounded tenant-first indexes, atomic frontend binding switches, Session-scoped Object Storage contracts, the guarded pre-production reset, and both review follow-ups:
- bindings cannot be switched to an archived Session;
CreateSessionidempotency requires an exact owner match and rejects conflicting owners.
Verification after merge:
- GitCode push mirror completed successfully and GitHub
mainresolves to the exact merge SHA76804cd; - GitHub Actions CI #62 passed all five jobs: Go verification, YDB schema/state store, local multi-service stand, Terraform environments, and runtime images;
- the YDB job applied the schema twice and ran the live Session invariant/concurrency suite.
All acceptance criteria for #21 are satisfied.


8月5日 关闭了 issue
21 天前 添加了label:mvpsessionydb
21 天前 关联了里程碑:MVP — Core platform (#6)
Parent and architecture
Outcome
Implement the authoritative YDB schema and Object Storage manifest layout for canonical sessions, ordered events, bindings, participants and snapshots using bounded tenant-scoped access paths.
Estimate
Scope
sessions;session_events;frontend_bindings;session_participants;session_snapshots;session_idandtrigger_event_idto runs and related atomic procedures.conversations + context_epochsschema from the canonical baseline. Do not build a row-level backfill, dual-read, shadow-write or compatibility adapter for existing local/cloud-dev records.docs/ydb-state-store.md;docs/ydb-partitioning.md;Pre-production schema reset policy
There is no production conversation data and existing local/cloud-dev application data is disposable. Before the first production deployment:
The migration runner still owns checksums, locking and crash behavior. Disposable data removes compatibility work; it does not permit an unguarded destructive command.
Non-goals
Verification
Acceptance criteria