Skip to content

refactor(agent-core-v2): extract goal domain into a self-contained feature - #3130

Merged
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:feat-055-08-19-goal-featurize
Aug 20, 2026
Merged

refactor(agent-core-v2): extract goal domain into a self-contained feature#3130
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:feat-055-08-19-goal-featurize

Conversation

@sailist

@sailist sailist commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

N/A — internal refactoring (agent-core-v2 architecture alignment), no linked issue.

Problem

The goal domain was the last built-in capability in agent-core-v2 still on the legacy static registration channel: its services (IAgentGoalService, IGoalDeadlineScheduler) and four tools (CreateGoal/GetGoal/SetGoalBudget/UpdateGoal) lived in src/agent/goal/ + src/agent/tools/goal/ and self-registered via registerScopedService / registerAgentToolService, unlike plan, externalHooks, swarm, and tower, which are self-contained Feature units under src/features/ — named, introspectable (IFeatureManager.units()), and individually retractable.

What changed

Pure structural migration; no externally visible behavior change.

  • Feature extraction: goal domain files moved from src/agent/goal/ + src/agent/tools/goal/ to src/features/goal/ (service, deadline scheduler, injection templates, four tools, ops, types, errors). New GoalFeature (goalFeature.ts, via registerFeature) contributes the runtime capabilities through the Feature seams: contributeAgentService(IAgentGoalService, …, OnScopeCreated) preserving eager semantics, contributeService(App, IGoalDeadlineScheduler, …, OnDemand), and contributeTool ×4 carrying the unchanged domain: 'goal' and main-agent-only when gates. All legacy static registrations removed.
  • Wire vocabulary stays on the static channel: durable Event2 classes and replayable keys remain statically registered so history stays replayable after retraction. goalForkNoticeKey moved into goalOps.ts next to goalKey (planOps/swarmOps pattern). goalOps is now exported from the package root, and the four external deep-subpath imports (kap-server ×2, apps/kimi-code, apps/kimi-inspect) converge to package-root imports.
  • Contract preservation: wire record type names and payloads are byte-identical (wire/state manifests diff owner paths only), tool names and gates, RPC/REST contracts, error codes, and telemetry event names are unchanged.
  • Tests: goal tests moved to test/features/goal/; new assembly test asserts the goal unit is introspectable via IFeatureManager.units() and that IAgentGoalService retracts/re-provides with the Feature (连坐). Test harness gains an App-scope override reassert for feature-contributed services (matching the existing session/agent-scope reasserts).

Verified: agent-core-v2 typecheck, full test suite (335 files / 5379 tests), lint:imports, regenerated wire/state manifests (freshness tests pass), kap-server/node-sdk/klient/apps typechecks, kap-server tests, and root lint all pass.

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 Aug 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d12fa49

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 Aug 20, 2026

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

commit: d12fa49

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

Copy link
Copy Markdown

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.

Reviewed commit: d943314e58

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +25 to +27
this.contributeAgentService(IAgentGoalService, AgentGoalService, {
activation: ScopeActivation.OnScopeCreated,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Dispose goal state registrations when retracting the feature

When unprovideUnit('goal') retracts this service from a live agent, AgentGoalService.dispose() leaves all 14 IAgentStateService.contributeState(...) registrations behind because their disposables are not registered on the service. Re-providing or updating the feature then fails immediately on goalKey with “state key 'goal' is already registered,” while the added lifecycle test misses this by stubbing contributeState as a no-op. Register each returned disposable with the service so feature retraction actually withdraws its state before reload.

AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L22-L22

Useful? React with 👍 / 👎.

@sailist
sailist force-pushed the feat-055-08-19-goal-featurize branch from d943314 to d12fa49 Compare August 20, 2026 11:20
@sailist
sailist merged commit fc0f275 into MoonshotAI:main Aug 20, 2026
15 checks passed
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Aug 20, 2026
…ature (MoonshotAI#3130)

Cherry-picked from upstream 0.38.0 (MoonshotAI#3130) onto fork.
goal-budget-limited-reminder.md kept at fork's new location
(features/goal/injection/).
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