Repository navigation
Add e2b_id: the Python half of the prefixed-ID format - #1628
mishushakov wants to merge 3 commits into
Conversation
PR SummaryLow Risk Overview Reviewed by Cursor Bugbot for commit 20103e3. Bugbot is set up for automated code reviews on this repo. Configure here. |
🦋 Changeset detectedLatest commit: 20103e3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Package ArtifactsBuilt from d00c315. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-dockerfile-utils-0.1.2-python-id.0.tgz ./e2b-2.63.1-python-id.0.tgzCLI ( npm install ./e2b-cli-2.23.1-python-id.0.tgzCode Interpreter JS SDK ( npm install ./e2b-code-interpreter-2.9.2-python-id.0.tgzDesktop JS SDK ( npm install ./e2b-desktop-2.5.1-python-id.0.tgzID JS ( npm install ./e2b-id-0.0.1-python-id.0.tgzPython SDK ( pip install ./e2b_dockerfile_utils-0.1.1+python.id-py3-none-any.whl ./e2b-2.63.0+python.id-py3-none-any.whlCode Interpreter Python SDK ( pip install ./e2b_code_interpreter-2.11.9+python.id-py3-none-any.whlDesktop Python SDK ( pip install ./e2b_desktop-2.7.2+python.id-py3-none-any.whlID Python ( pip install ./e2b_id-0.0.0+python.id-py3-none-any.whl |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
6da96f9 to
058e250
Compare
058e250 to
6749ed3
Compare
The same format as @e2b/id, name for name: create_id, encode_id, decode_id, parse_id, is_id, create_uuid, encode_bytes/decode_bytes. Standard library only — no dependencies at all, so an ID codec that every service depends on can never be the reason a resolution fails. The codec is base64.b32encode behind a translation table: four zero bytes in front make 20, which is 32 RFC 4648 digits with no padding, of which the last 26 are the TypeID suffix once mapped onto the Crockford alphabet. The tests check that against an arithmetic encoder stated independently of it, and against the Go suite's own vectors. Agreement with the JS half is enforced rather than asserted. Both suites carry the same golden vectors — the Go side's among them — both build the same 1306-value corpus from the same seeded LCG, and both pin the same CORPUS_DIGEST over it, so a format change on one side alone fails on both. UUIDs are read and minted the way github.com/google/uuid does it, as in @e2b/id: encode_id takes exactly the four spellings Go's Parse takes — narrower than uuid.UUID(), which also strips hyphens from anywhere — and create_uuid is NewV7 line for line, the sequence being the clock's sub-millisecond bits bumped so every UUID a process mints is strictly greater than the last. The one place the surfaces differ is downstream of JavaScript having no UUID type: this package moves uuid.UUID objects where @e2b/id moves canonical hex strings, so decode_id and ParsedId.uuid return UUIDs and there is no uuid_to_bytes/bytes_to_uuid — the standard library already is those. uuids.py and the README both enumerate it. Also wires the two together: the id_tests workflow grows a Python leg, lint and typecheck sync the new uv env, and js-id's docs now name their counterpart. Wired into the release pipeline as e2b-id on PyPI: versioned from 0.0.0 with an "Initial release" changeset so the next release mints 0.1.0, gated on the id_tests workflow in release.yml, and published by the same postPublish step python-sdk uses — `uv publish` over PyPI's OIDC trusted publishing, no token. The e2b-id project already exists on PyPI as a 0.0.0 placeholder with the trusted publisher attached, so 0.1.0 is the first real version and publishing needs no manual step. Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
decode_id and parse_id raise InvalidIdException("prefix") for a non-string
id (None, a number, bytes, ...) instead of an AttributeError, matching
@e2b/id. decode_id also names no kind for an id with no separator, as
parse_id and @e2b/id already do, so "prj" is no longer reported as a
project ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds tests/test_uuids.py, the counterpart of @e2b/id's uuid.test.ts: hex_digits_of against the standard library over the shared corpus, each of Go's four forms probed one character short, one long and with a bad digit (plus the spellings uuid.UUID accepts and Go does not), non-string UUIDs, and create_uuid on fresh module state: version and variant on every mint, the 48-bit timestamp at its boundaries, random bits confined to rand_b, the clock-derived sequence counting up, resetting and carrying. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6749ed3 to
20103e3
Compare
Stack: 2 of 2, on top of #1627. Review that one first — this PR's diff is the Python package plus the wiring that ties the two halves together.
e2b_idis the same format as@e2b/id, name for name:create_id,encode_id,decode_id,parse_id,is_id,create_uuid,encode_bytes/decode_bytes. Standard library only — no dependencies at all, so an ID codec every service depends on can never be the reason a resolution fails. It is the TypeID encoding E2B's Go services use (packages/shared/pkg/idin e2b-dev/infra), and the Go suite's own vectors are pinned here.Part of SDK-303
Usage
InvalidIdExceptionsubclassesValueErrorand carriesreason("kind" | "prefix" | "length" | "alphabet" | "overflow" | "uuid") plusactual_kind.UUIDs are read and minted the way
github.com/google/uuiddoes it, as in@e2b/id:encode_idtakes auuid.UUIDor exactly the four string spellings Go'sParsetakes — narrower thanuuid.UUID(), which also strips hyphens from anywhere — andcreate_uuidisNewV7line for line, with the sequence taken from the clock's sub-millisecond bits and bumped so every UUID a process mints is strictly greater than the last.Where it differs from
@e2b/idOnly downstream of JavaScript having no UUID type: this package moves
uuid.UUIDobjects where@e2b/idmoves canonical hex strings.decode_idandParsedId.uuidreturn auuid.UUID,encode_idaccepts either, and there is nouuid_to_bytes/bytes_to_uuidbecause the standard library already is those.Notes for reviewers
base64.b32encodebehind a translation table: four zero bytes in front make 20, which is 32 RFC 4648 digits with no padding, of which the last 26 are the TypeID suffix once mapped onto the Crockford alphabet. The tests check that against an arithmetic encoder stated independently of it.CORPUS_DIGEST, so a format change on one side alone fails on both.e2b-idon PyPI. Versioned from0.0.0with an "Initial release" changeset so the next release mints0.1.0, gated on theid_testsworkflow inrelease.yml, and published by the samepostPublishstep python-sdk uses:uv publishover PyPI's OIDC trusted publishing, no token. Thee2b-idproject already exists on PyPI as a0.0.0placeholder with the trusted publisher attached, so0.1.0is the first real version and the release needs no manual step.Verification
124 tests; ruff and ty clean;
uv buildsucceeds. Theid_testsworkflow runs both suites on ubuntu-22.04 and windows-latest.🤖 Generated with Claude Code