Skip to content

feat(cardinal): add struct system registration - #921

Draft
smsunarto wants to merge 4 commits into
mainfrom
codex/cardinal-private-system-state
Draft

feat(cardinal): add struct system registration#921
smsunarto wants to merge 4 commits into
mainfrom
codex/cardinal-private-system-state

Conversation

@smsunarto

@smsunarto smsunarto commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

  • add cardinal.System and cardinal.RegisterSystemV2 for caller-owned system instances
  • require a non-nil pointer to a struct with BaseSystemState and a pointer-receiver Run() method
  • initialize exported Cardinal dependencies while preserving constructor-owned private dependencies and scratch memory
  • keep the existing RegisterSystem API and behavior unchanged
  • fail early for private or pointer-form Cardinal dependency fields

Developer experience

type MovementSystem struct {
    cardinal.BaseSystemState
    Positions PositionSearch

    runtime *Runtime
    scratch []Input
}

func (s *MovementSystem) Run() {
    // Use initialized Cardinal fields and persistent private state.
}

cardinal.RegisterSystemV2(world, NewMovementSystem(runtime))

The constructor owns external dependencies. Cardinal initializes the same instance and calls Run() on it for every configured hook.

Validation

  • go test ./pkg/cardinal -count=1
  • scoped golangci-lint: 0 issues
  • pointer/value validation, persistent state, private dependency, and hook tests

Stack

This is the base PR for NativeAOT runtime PR #919.

@smsunarto smsunarto changed the title feat(cardinal): allow private system state feat(cardinal): add struct system registration Jul 29, 2026
@smsunarto
smsunarto force-pushed the codex/cardinal-private-system-state branch from d0994eb to 6db6cca Compare July 29, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants