fix(app): migrate app id helper off the legacy 0x1000-shifted 48-bit encoding (#271) - #273
Merged
Conversation
… encoding Root cause: packages/app/src/utils/id.ts still encoded timestamp * 4096 + counter into the 48-bit id prefix — the scheme that wrapped at epoch 1786706395136 (2026-08-14 19:19:55.136 +08) and was replaced everywhere else by the shared fixed generator (PR #265). The app generates message and part ids client-side, so every app-created id after the wrap carried a restarted prefix: it no longer decoded back to wall-clock time and sorted against core-generated ids as if it came from a different era. Migration: generateID now delegates to the shared fixed generator in @opencode-ai/schema/identifier (raw 48-bit ms behind a monotonic latch), so app ids share one encoding with core ids. The Identifier namespace API is unchanged — ascending/descending with the app prefix map and given-id passthrough/validation. The legacy module had no timestamp() decode API with live callers in app/desktop, so nothing needed re-implementing there. Coverage: id.test.ts pins the app boundary — raw-ms decode of live ids, prefix/shape for all six prefixes, app-vs-core same-wall-clock sort consistency, burst and descending ordering, given-id passthrough and validation; two probes were red against the legacy encoder (decoded prefix 189982101517 vs 1786752772485 wall-clock; app-vs-core drift ~1.6e12 ms) and are green after. id-wrap-boundary.test.ts mirrors packages/schema/test/identifier.test.ts through the app's generator seam. Declared @opencode-ai/schema as an app workspace dependency. Evidence: app unit 453/453, desktop 49/49, schema 16/16, typecheck green in packages/app and packages/desktop, rg 0x1000 packages/app clean, root lint 4849 warnings (budget untouched), spot-check app vs core msg_ prefix drift 1 ms. Refs #271
This was referenced Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
packages/appcarried a private legacyts*0x1000 + counter48-bit id generator while core/schema moved to raw 48-bit-ms time-prefix ids (PR #265) — divergent generators risk cross-package ordering breakage and drift.What
generateIDnow wraps the shared@opencode-ai/schema/identifiercreate()(raw 48-bit ms + monotonic latch); theIdentifier.ascending/descendingpublic API is preserved.rg '0x1000' packages/app→ no matches.Tests
Raw-ms decode pinned against legacy 12-bit shift · 6-prefix shape · burst ascending · strict descending · given-id passthrough · wrong-prefix throw · wrap-boundary + clock-regression suite mirroring
packages/schema/test/identifier.test.ts(same WRAP_BOUNDARY) · app-vs-core same-wall-clock decode (drift 0-5ms).Gates
app 453/0 (78 files) · desktop 49/0 · schema 16/0 · app+desktop typecheck exit 0 · lint 4849/0.
Review: independent verify + standards/intent arbitration ACCEPT.
Closes #271.