refactor(agent-core-v2): extract goal domain into a self-contained feature - #3130
Conversation
|
commit: |
There was a problem hiding this comment.
💡 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".
| this.contributeAgentService(IAgentGoalService, AgentGoalService, { | ||
| activation: ScopeActivation.OnScopeCreated, | ||
| }); |
There was a problem hiding this comment.
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 👍 / 👎.
d943314 to
d12fa49
Compare
…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/).
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 insrc/agent/goal/+src/agent/tools/goal/and self-registered viaregisterScopedService/registerAgentToolService, unlikeplan,externalHooks,swarm, andtower, which are self-contained Feature units undersrc/features/— named, introspectable (IFeatureManager.units()), and individually retractable.What changed
Pure structural migration; no externally visible behavior change.
src/agent/goal/+src/agent/tools/goal/tosrc/features/goal/(service, deadline scheduler, injection templates, four tools, ops, types, errors). NewGoalFeature(goalFeature.ts, viaregisterFeature) contributes the runtime capabilities through the Feature seams:contributeAgentService(IAgentGoalService, …, OnScopeCreated)preserving eager semantics,contributeService(App, IGoalDeadlineScheduler, …, OnDemand), andcontributeTool×4 carrying the unchangeddomain: 'goal'and main-agent-onlywhengates. All legacy static registrations removed.Event2classes and replayable keys remain statically registered so history stays replayable after retraction.goalForkNoticeKeymoved intogoalOps.tsnext togoalKey(planOps/swarmOps pattern).goalOpsis 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.test/features/goal/; new assembly test asserts thegoalunit is introspectable viaIFeatureManager.units()and thatIAgentGoalServiceretracts/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
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.