Skip to content

fix(core): make state visible before finalize#37480

Open
armancharan wants to merge 2 commits into
anomalyco:v2from
armancharan:fix/catalog-update-order
Open

fix(core): make state visible before finalize#37480
armancharan wants to merge 2 commits into
anomalyco:v2from
armancharan:fix/catalog-update-order

Conversation

@armancharan

@armancharan armancharan commented Jul 17, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #37422

#37422

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

State.commit ran finalize before assigning the new snapshot. Domains publish *.updated from finalize, so a client could refetch on the event and still see the old state.

Assign the rebuilt state first, then run finalize. Same ID schemas and transform behavior otherwise.

Note: this changes the finalize contract so get() already sees the new state while finalize runs.

How did you verify your code works?

  • bun test test/state.test.ts test/agent.test.ts test/catalog.test.ts test/command.test.ts test/skill.test.ts
  • added checks that read agent/command/skill/catalog state immediately on the update event

Screenshots / recordings

n/a

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

Comment thread packages/core/test/state.test.ts Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant