Skip to content

Conversation

@syifan
Copy link
Contributor

@syifan syifan commented Oct 8, 2025

Summary

  • introduce a v5/sim/state package with a basic Manager supporting register/load/stage/commit flows
  • provide unit tests covering staging, commit, discard, and example usage for documentation

Testing

  • go test ./v5/sim/state

https://chatgpt.com/codex/tasks/task_e_68e5c31354388325af6f7546f3f549d8

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +112 to +114
e.active = e.staged
e.staged = nil
e.hasStaged = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent post-commit mutation of active state

After Stage returns a mutable pointer to the staged copy, Commit assigns that pointer directly to active (e.active = e.staged). Callers that keep the returned pointer can continue mutating it after the commit without calling Stage again, bypassing the transactional guard and allowing unsynchronized writes to the active state. Any goroutine that edits the previously staged object after Commit will mutate live state without triggering hasStaged, making rollbacks impossible and introducing data races with concurrent Load calls.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants