Files
codex/codex-rs/state/migrations/0063_session_model_ids.sql
T
Adam Perry @ OpenAI a4b69a0ae9 Add session-scoped stores for stable model-facing IDs (#61339)
## What changed

- Add `SessionModelIdStore` with SQLite and in-memory implementations for looking up and assigning aliases by session, namespace, and external key.
- Commit SQLite assignments before returning them, and recheck under a write transaction so concurrent writers reuse the same alias.
- Support snapshotting and initializing alias maps from generator state and ordered keys, and remove mappings when their thread is deleted.
- Expose alias stores through `ThreadStore` and add distinct types for registered environment IDs and model-facing `env` aliases.

## Testing

Add a test using two SQLite runtime instances to verify that concurrent assignments return the same alias, different keys receive different aliases, and lookups and snapshots preserve the assignments.

GitOrigin-RevId: 2668f605251ca76d4891f70f94bfb4151ba8142c
2026-11-13 18:43:58 +00:00

11 lines
343 B
SQL

CREATE TABLE session_model_ids (
session_id TEXT NOT NULL,
kind TEXT NOT NULL,
external_key TEXT NOT NULL,
ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
initial_state TEXT,
PRIMARY KEY (session_id, kind, external_key),
UNIQUE (session_id, kind, ordinal),
CHECK ((ordinal = 0) = (initial_state IS NOT NULL))
);