refactor(op-devstack): introduce unified ID type system (Phase 1)#18872
Merged
refactor(op-devstack): introduce unified ID type system (Phase 1)#18872
Conversation
pcw109550
approved these changes
Feb 3, 2026
Introduce a new unified ID type system using Go generics to address the
parallel type system problem in op-devstack. The current system has 19
separate ID types, each with ~150 lines of boilerplate for marshal/unmarshal,
String(), sorting, and matcher methods.
The new system provides:
- ComponentID: single underlying struct for all IDs
- ID[T]: generic wrapper with KindMarker constraint for type safety
- Marker types (L2BatcherMarker, etc.) to avoid circular dependencies
- IDShape enum to handle three ID formats (key+chain, chain-only, key-only)
- Conversion helpers for incremental migration from old to new types
New types use a "2" suffix (L2BatcherID2, NewL2BatcherID2) to coexist with
the existing system during migration. Serialization output is identical to
the old system for compatibility.
This is Phase 1 of a multi-phase refactor. Future phases will introduce a
unified registry and capability interfaces for polymorphic lookups.
See docs/design/id-type-system-refactor.md for the full design document.
6c97f16 to
e52819a
Compare
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.
This PR introduces a new unified ID type system for op-devstack that addresses the parallel type system problem where 19 separate ID types each require ~150 lines of boilerplate code. The new system uses Go generics to provide type safety with a single underlying implementation.
This is Phase 1 of a multi-phase refactor. It introduces the new types alongside the existing system, with no breaking changes.
Problem
The current ID system has several issues:
L2BatcherID) has separate marshal/unmarshal, String(), sorting functionsRollupBoostNodeis-aL2ELNode, but their ID types are separate, requiring manual conversion in lookupsSee the design document for the full rationale.
Solution
Introduce a unified
ComponentIDtype with a generic wrapperID[T]for type safety:Changes
New Files
stack/component_id.gostack/component_id_test.goKey Features
MarshalText/UnmarshalTextimplementation for all ID typesL2BatcherID2andL2ELNodeID2are distinct types at compile timeConvertL2BatcherID(old) L2BatcherID2for incremental migration"L2Batcher-mynode-420")Non-Breaking
L2BatcherID, etc.) remain unchangedL2BatcherID2,NewL2BatcherID2())Test Plan
Future Phases
RWMapinstancesL2ELCapable) for polymorphic lookupsHow to Review
Start with
stack/component_id.go:ComponentIDstruct and its methods (lines 1-200)KindMarkerinterface and marker types (lines 200-260)ID[T]methods (lines 360-400)Review
stack/component_id_test.goto understand the expected behaviorCheck the design document for the full rationale