Skip to content

refactor(agent-core-v2): align xstate machine naming with command/fact/streaming conventions - #3635

Merged
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:refact-162-09-08-xstate-event-naming
Sep 8, 2026
Merged

refactor(agent-core-v2): align xstate machine naming with command/fact/streaming conventions#3635
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:refact-162-09-08-xstate-event-naming

Conversation

@sailist

@sailist sailist commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

N/A — internal refactor, no user-facing change.

Problem

The XState machines in agent-core-v2 had drifted from the naming conventions we adopted (XState official guidance + messaging convention: commands imperative, events past tense): noun/past-participle command events (turn.notifications, input.reminder), mixed segment casing (llm.message-id kebab, turn.spawnTools/turn.remindersConsumed camel), preposition state names (before/after in the tool machine), and no visible distinction for streaming data events (llm.delta/headers/usage/finish/message-id).

What changed

Pure renames, no behavior change; wire contracts (klient / kap-server / bus event names) are untouched.

  • Event naming rule documented: events are classified by what the receiver does with them — command (imperative verb), fact (past participle), or data stream (noun). Added docs/en/event-name.md and docs/zh/event-name.md under packages/agent-core-v2/docs/.
  • Command events fixed: turn.notificationsturn.notify, input.reminderinput.remind, turn.spawnToolsturn.spawn_tools.
  • Fact events aligned: turn.remindersConsumedturn.reminders_consumed, turn.startturn.started (matches the bus event name), agent.erroragent.failed, tool.asynctool.detached.
  • Data-stream events namespaced: llm.deltallm.streaming.part, llm.headersllm.streaming.headers, llm.usagellm.streaming.usage, llm.finishllm.streaming.finish, llm.message-idllm.streaming.message_id. The five identical streaming handlers in the agent and session machines each collapse into one 'llm.streaming.*' wildcard declaration.
  • Tool machine states: before/afterpreparing/finishing (invoke actors renamed to preparingActor/finishingActor accordingly).
  • Synced the acp-server test stub (LlmRequestEvent is a public subpath export) and the shorthand event lists in docs/{en,zh}/llm.md.

providerCatalog's naming deviations are deliberately excluded: PR #3606 is rewiring that file, its rename will follow after that lands.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ac45588

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 8, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@ac45588
npx https://pkg.pr.new/@moonshot-ai/kimi-code@ac45588

commit: ac45588

@sailist
sailist merged commit 0527dae into MoonshotAI:main Sep 8, 2026
15 of 16 checks passed
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.

1 participant