Dev#25
Conversation
# Conflicts: # .github/workflows/tauri-build.yml # README.md
新增 phase-based workflow 运行时,将 LLM 会话组织为 Planning → Executing 阶段, 并重构 session-runtime 状态管理层以支持更精细的生命周期控制。 crates/core/ - 新增 workflow.rs 定义工作流域类型(WorkflowDef/PhaseDef/Signal/BridgeState) - 新增 TurnTerminalKind 枚举替代原有 reason 字符串,统一终止语义 - 新增 ProjectionRegistrySnapshot 端口抽象 crates/application/workflow/ - 新增 WorkflowOrchestrator 管理工作流定义与状态转换 - 新增 WorkflowStateService 持久化工作流状态 - 新增 PlanToExecuteBridgeState 实现计划→执行的桥接载荷 - 扩展 session_use_cases 支持工作流驱动的会话编排 crates/session-runtime/state/ - 抽取 ProjectionRegistry 统一管理 7+ 个独立 mutex 投影 - 重构 TurnRuntimeState 使用 generation 计数器防止过期完成 - 新增 post_llm_policy.rs 抽取 LLM 后续决策为可测试策略 - 新增 TurnJournal 记录轮次执行日志 - 重构 turn/runner.rs 和 turn/submit.rs 适配新状态模型 crates/adapter-tools/ - 更新 plan mode 工具集成工作流 artifact 引用 crates/adapter-storage/ - 适配 SessionRecoveryCheckpoint 新字段,保持向后兼容 openspec/specs/ - 更新工作流、执行追踪、运行时可观测等规范文档 PROJECT_ARCHITECTURE.md - 新增项目架构全景文档
…ntime 的稳定合同边界
application 层引入自有的 session 编排 DTO(session_contracts),
port trait 签名不再暴露 session-runtime/kernel 内部快照类型;
session-runtime 拆分 command/turn 子模块厘清写路径职责;
server 测试适配新 API;同步 openspec 提案归档与新建。
application/ports/session_contracts.rs
- 新增 SessionTurnOutcomeSummary、SessionTurnTerminalState、SessionObserveSnapshot、
RecoverableParentDelivery 等 app-owned DTO,隔离 runtime 内部类型
application/session_identity.rs
- 提取 session ID 规范化为 application 层桥接函数
application/ports/{agent_session,agent_kernel,app_session}.rs
- port trait 签名统一使用 DTO 和 &str,增加 runtime→app 映射
session-runtime/command/input_queue.rs, turn/{finalize,projector,subrun_events,compact_events}.rs
- 从 submit.rs / state/ 中拆出命令/投影/终态/压缩子模块
session-runtime/identity.rs
- 导出公开的 session ID 规范化函数
server/tests/
- 适配 prepare_execution 替代直接操作 running 标志
openspec/
- 归档 extract-governance-prompt-hooks、introduce-hooks-platform-crate
- 新增 application-decomposition、core-slimming、hooks-platform、
server-session-runtime-isolation、session-runtime-state-turn-boundary 提案
- 更新 linearize-session-runtime-application-boundaries 设计与任务
将 SessionState 中 turn 运行时状态(锁、CancelToken、compact 控制)抽离到 turn/runtime.rs,turn 终态等待循环抽离到 turn/watcher.rs,使 SessionState 只保留 durable truth 与 projection/cache/broadcast 基础设施职责。 在 application 层新增 terminal/contracts.rs 定义对话领域事实类型, terminal/runtime_mapping.rs 负责跨 crate 类型映射,terminal/stream_projection.rs 封装 ConversationStreamProjector,server 层不再直接依赖 session-runtime 的投影类型。 fork 操作引入 SessionForkSelector 替代裸 ForkPoint,app_session port 消费 application 领域类型而非 runtime 内部类型。 crates/session-runtime/src/turn/runtime.rs - 从 state/mod.rs 抽离 TurnRuntimeState、ActiveTurnState、CompactRuntimeState crates/session-runtime/src/turn/watcher.rs - 从 query/service.rs 抽离 wait_for_turn_terminal_snapshot 等待循环 crates/application/src/terminal/contracts.rs - 新增 ConversationBlockFacts 等对话领域事实类型,不依赖 session-runtime crates/application/src/terminal/runtime_mapping.rs - application ↔ session-runtime 的类型双向映射 crates/application/src/terminal/stream_projection.rs - 封装 ConversationStreamProjector,server 不再直接引用 runtime 投影器 crates/application/src/ports/app_session.rs - fork 接口改为接收 SessionForkSelector,返回 SessionMeta crates/application/src/session_use_cases.rs - 新增 SessionForkSelector 枚举与 working_dir 规范化 crates/session-runtime/src/lib.rs - wait_for_turn_terminal 改为委托 watcher 模块 crates/session-runtime/src/query/service.rs - 移除 wait_for_turn_terminal_snapshot,控制状态查询改用 turn_runtime() crates/session-runtime/src/turn/subrun_events.rs - 默认摘要改为语言中性文本,新增完成/取消场景单元测试 crates/server/src/http/routes/conversation.rs - 使用 application 层 ConversationStreamProjector 替代 runtime 类型 crates/server/src/tests/test_support.rs - 新增 seed_completed_root_turn 辅助函数 openspec/ - 归档 linearize-session-runtime-application-boundaries、session-runtime-state-turn-boundary - 新增 server-session-runtime-isolation design/specs/tasks
将 core 中依赖宿主环境的模块(home 路径解析、shell 检测、 tool result 磁盘持久化)迁入新建的 astrcode-support crate, 使 core 只保留纯领域类型和零副作用逻辑。同时将 agent 协作 参数类型拆分为独立子模块(collaboration/delivery/lineage/spawn)。 所有 adapter-*、server、cli、plugin、eval 等消费方统一将 home/project/shell/tool_result_persist 导入源从 core 切换到 support。 边界脚本新增 support 的消费许可,归档 server-session-runtime-isolation change,同步 delta specs 到主 specs。 crates/support/ (NEW) - hostpaths: resolve_home_dir, astrcode_dir, projects_dir, project_dir - shell: resolve_shell, detect_shell_family(403 行跨平台 shell 检测) - tool_results: persist_tool_result, maybe_persist_tool_result crates/core/ - 移除 home 模块、project::projects_dir/project_dir、shell 模块 - 移除 dirs/reqwest/toml 依赖 - 新增 agent/collaboration.rs, delivery.rs, lineage.rs, spawn.rs crates/adapter-*, server, cli, plugin, eval - 统一切换到 astrcode_support 导入路径 openspec/ - 归档 server-session-runtime-isolation - 新增 core-slimming change artifacts - 同步 delta specs: application-use-cases, session-fork, server-http-routes
…me logic - Introduced a proposal for slimming down the `astrcode-core` crate by removing runtime logic and I/O operations. - Migrated replay algorithms from `InputQueueProjection` to `session-runtime`, retaining only the DTOs in core. - Moved `RuntimeCoordinator` to the server layer, keeping core focused on pure contracts. - Split `tool_result_persist.rs` into shared protocol and host implementation layers. - Refactored `shell.rs` and `project.rs` to separate shared types from host-specific implementations. - Centralized home directory resolution and plugin manifest parsing in `astrcode-support`. - Decoupled `AstrError::HttpRequest` from `reqwest::Error` to maintain transport neutrality. - Organized `agent/mod.rs` into submodules for better responsibility management. - Updated specifications for adapter contracts and application use cases to reflect new architecture. - Ensured that `session-runtime` owns session projection algorithms and interacts with adapters for side effects. - Documented changes and updated architecture guidelines to clarify new ownership boundaries.
统一治理层 compile-bind 分离:mode spec 新增 artifact/exitGate/promptHooks 声明, GovernanceModeSpec 编译后产出 BoundModeToolContractSnapshot 贯穿 turn 全生命周期。 crates/core/src/mode/mod.rs - 新增 ModeArtifactDef, ModeExitGateDef, ModePromptHooks, CompiledModeContracts, BoundModeToolContractSnapshot 等 mode contract 类型与校验 crates/core/src/workflow.rs - WorkflowInstanceState 和 WorkflowArtifactRef 移入 core 作为磁盘 schema 单一真相 crates/application/src/workflow/compiler.rs - 新增 CompiledWorkflowDef,compile 时校验 phase 图、signal 契约与去重 crates/application/src/workflow/service.rs - 从 session_plan.rs 抽取 workflow 状态管理函数到独立 service 模块 crates/application/src/mode/catalog.rs - 新增 snapshot 模式支持 preview-then-replace,内置 plan/code mode 补全 contract 字段 crates/application/src/governance_surface/ - bound_mode_tool_contract 贯穿 assembler → ResolvedGovernanceSurface → submission 管线 - 提取 governance_prompt_declaration() 工厂减少样板代码 crates/application/src/session_plan.rs - 重构为基于 mode prompt hooks 的声明式 prompt 生成,替代硬编码 plan prompt crates/adapter-tools/src/builtin_tools/exit_plan_mode.rs - 用 mode contract 驱动的 validate_plan_artifact_contract 替代硬编码 heading/checklist crates/adapter-tools/src/builtin_tools/session_plan.rs - 新增 validate_plan_artifact_contract 与 PlanArtifactContractBlockers crates/session-runtime/src/turn/ - current_mode_id 和 bound_mode_tool_contract 穿透 TurnRunRequest → StreamingToolLauncher crates/server/src/bootstrap/governance.rs - 新增 GovernanceReloadRollback 支持原子性 reload 失败回滚 docs/ - 删除 competitor-analysis-and-roadmap.md,更新架构文档与 openspec specs
crates/core, crates/application, crates/adapter-tools - 新增 SESSION_PLAN_DRAFT_APPROVAL_GUARD_MARKER,在用户对 draft plan 发出审批语义时 注入守卫 prompt 阻止模型切换到执行态 - upsertSessionPlan 拒绝模型写入 approved/completed 等终态,防止伪造审批 - exitPlanMode 成功/待审结果增加"禁止输出冗余摘要"约束 - plan mode contract 更新:exitPlanMode 后不再要求 assistant 输出 summary crates/session-runtime/turn - TurnExecutionContext 检测 draft guard marker,抑制该 turn 的 assistant 输出 - exitPlanMode 后的 assistant follow-up 同样不持久化到 journal crates/session-runtime/query/conversation - snapshot 和 replay 路径隐藏 draft-approval turn 的 assistant/thinking block - 抑制 upsertSessionPlan/exitPlanMode 失败重试噪声,只保留 plan surface crates/core, application, session-runtime, protocol, server, frontend (metrics) - 全链路透传 prompt_cache_diagnostics,前端渲染 cache break 检测 UI - 前端 conversation.ts 现在正确解析并投影 prompt_metrics block frontend/src/hooks/useAgent.ts, frontend/vite.config.ts - 处理 rehydrate_required envelope,cursor 缺失时自动恢复会话投影 - vite 配置收紧 run.json PID 校验为 astrcode-server 进程身份验证 crates/core/action.rs, crates/adapter-storage/session/iterator.rs - ContinuationPrompt 添加 serde(alias = "auto_continue_nudge") 兼容历史数据 - 修复历史会话 snapshot 500 错误 crates/application/terminal_queries/snapshot.rs - 检测 transcript 中不存在的 cursor 并触发 rehydrate crates/server/main.rs - 抽取 wait_for_shutdown_pipe 为可测试函数,补充单测 eval-tasks/* - eval task set 从 3 条扩至 10+ 条,覆盖工具精度/compact/plan/prompt 维度 - 新增 core + advanced 任务定义与 fixtures docs/issues.md, docs/自动化测试任务.md - 新增详细 issue 追踪文档和自动化测试任务说明
- Removed legacy handling of output continuation limits and associated stop causes. - Simplified decision-making for output continuation in `decide_output_continuation`. - Updated event handling to use typed terminal kinds instead of legacy reasons. - Refactored `TurnStopCause` to remove unused variants and legacy methods. - Adjusted tests to reflect changes in output handling and terminal event structures. - Updated frontend components to remove references to token exceeding status. - Cleaned up test cases and types to align with the new outcome definitions.
|
@codex review it |
|
To use Codex here, create a Codex account and connect to github. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR continues the architecture refactor by centralizing host-path/tool-result helpers in a new astrcode-support crate, introducing workflow state/bridge scaffolding in application, and aligning multiple crates with updated OpenAI-only and terminal contract models.
Changes:
- Introduce workflow definition/compile/state persistence and expose workflow orchestration APIs from
application. - Migrate path/tool-result/shell helpers out of
coreintoastrcode-supportand update downstream crates to use it. - Update CLI/application terminal contracts + stream replay mapping, plus compatibility for legacy
UserMessageOriginvalues.
Reviewed changes
Copilot reviewed 134 out of 503 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/core/src/action.rs | Removes a legacy origin variant and adds a serde alias + test for backward-compatible parsing. |
| crates/core/Cargo.toml | Drops unused dependencies from core crate. |
| crates/cli/src/state/transcript_cell.rs | Updates DTO types and maps new PromptMetrics block. |
| crates/cli/src/state/shell.rs | Renames client DTO types for shell state. |
| crates/cli/src/state/interaction.rs | Renames client DTO types and streamlines palette setters. |
| crates/cli/src/launcher/mod.rs | Moves home dir resolution to astrcode-support. |
| crates/cli/src/command/mod.rs | Renames slash DTO types and updates parsing/filtering. |
| crates/cli/src/chat/surface.rs | Aligns test DTOs with new assistant block fields. |
| crates/cli/src/bottom_pane/model.rs | Updates model info DTO type in tests. |
| crates/cli/src/app/reducer.rs | Renames client error/DTO types and updates banner mapping. |
| crates/cli/src/app/coordinator.rs | Renames client transport/requests DTO types and replay envelope handling. |
| crates/cli/Cargo.toml | Adds dependency on astrcode-support. |
| crates/application/src/workflow/state.rs | Adds workflow state load/persist/clear service with recovery path + tests. |
| crates/application/src/workflow/mod.rs | Introduces workflow module exports and internal service wiring. |
| crates/application/src/workflow/definition.rs | Adds builtin workflow definition + tests. |
| crates/application/src/workflow/compiler.rs | Adds workflow definition validation/compilation + tests. |
| crates/application/src/workflow/bridge.rs | Adds typed plan→execute bridge payload encoding/decoding + tests. |
| crates/application/src/test_support.rs | Expands session test stub to record submissions/mode switches and new port contracts. |
| crates/application/src/terminal_queries/tests.rs | Updates terminal stream/replay wiring and adds cursor-missing rehydrate test. |
| crates/application/src/terminal_queries/summary.rs | Switches summary logic to new terminal contracts and ignores PromptMetrics. |
| crates/application/src/terminal_queries/snapshot.rs | Uses transcript snapshot for cursor validation and maps runtime facts into terminal contracts. |
| crates/application/src/terminal_queries/resume.rs | Maps runtime snapshots to terminal contracts for child summaries. |
| crates/application/src/terminal/stream_projection.rs | Adds terminal-side stream projector wrapper around runtime projector. |
| crates/application/src/terminal/mod.rs | Introduces terminal contracts + runtime mapping + updated replay facts model. |
| crates/application/src/terminal/contracts.rs | Adds stable terminal-facing contract types for transcript blocks and deltas. |
| crates/application/src/session_identity.rs | Adds a narrow session ID normalization bridge. |
| crates/application/src/ports/session_submission.rs | Extends prompt submission contract with mode/tool-contract fields. |
| crates/application/src/ports/session_contracts.rs | Adds application-owned session contract DTOs for observe/outcomes/terminal state. |
| crates/application/src/ports/mod.rs | Re-exports new session contracts. |
| crates/application/src/ports/app_session.rs | Updates session port signatures; normalizes session IDs; adds subrun status snapshot port. |
| crates/application/src/ports/agent_session.rs | Maps runtime session types into application-owned session contracts. |
| crates/application/src/ports/agent_kernel.rs | Maps kernel parent deliveries into application-owned contract type. |
| crates/application/src/observability/mod.rs | Adjusts tests to match updated metrics shape. |
| crates/application/src/observability/collector.rs | Removes TokenExceeded metric tracking. |
| crates/application/src/mode/mod.rs | Updates module docs to reflect refactor direction. |
| crates/application/src/mode/compiler.rs | Removes tool-surface shrinking and projects mode contracts into compile artifact. |
| crates/application/src/mode/catalog.rs | Adds mode contract fields to builtin modes; adds preview/commit workflow; rejects duplicate IDs. |
| crates/application/src/mode/builtin_prompts/plan_mode_exit.md | Updates plan-mode exit prompt copy. |
| crates/application/src/mode/builtin_prompts/plan_mode.md | Updates plan-mode prompt to rely on mode contracts and avoid redundant summaries. |
| crates/application/src/lib.rs | Wires workflow orchestrator into App and re-exports workflow APIs/contracts. |
| crates/application/src/governance_surface/tests.rs | Updates tests for new bound tool contract snapshot + simplified limits handling. |
| crates/application/src/governance_surface/prompt.rs | Removes capability-limit messaging from child contracts and adds shared prompt declaration helper. |
| crates/application/src/governance_surface/policy.rs | Removes allowed-tools projection from policy metadata and deletes helper. |
| crates/application/src/governance_surface/mod.rs | Updates governance surface to carry bound mode tool contract, and stops exposing allowed tools. |
| crates/application/src/governance_surface/inherited.rs | Switches stored-event reads to string session IDs. |
| crates/application/src/governance_surface/assembler.rs | Stops mutating runtime max_steps and removes tool-surface compilation for child/resumed flows. |
| crates/application/src/execution/subagent.rs | Removes capability-grant tool limiting for subagents. |
| crates/application/src/execution/root.rs | Updates tests for new execution control defaults. |
| crates/application/src/execution/profiles.rs | Updates tests for profile schema changes. |
| crates/application/src/config/validation.rs | Updates provider validation for OpenAI modes and removes deprecated runtime fields checks. |
| crates/application/src/config/selection.rs | Updates test providers/models to OpenAI-only naming. |
| crates/application/src/config/mod.rs | Removes Anthropic constants and deprecated defaults; updates tests accordingly. |
| crates/application/src/config/api_key.rs | Updates profile struct construction to include OpenAI api mode fields. |
| crates/application/src/agent/wake.rs | Switches to normalized session IDs and new parent-delivery contract types; updates tests/harness usage. |
| crates/application/src/agent/test_support.rs | Adds helpers to append events/prepare turn runtime; updates env var path usage; updates LLM output struct fields. |
| crates/application/src/agent/routing/tests.rs | Updates tests for removed capability grants. |
| crates/application/src/agent/routing/parent_delivery.rs | Uses payload methods instead of local mapping helpers; removes duplicated mapping fns. |
| crates/application/src/agent/routing/child_send.rs | Removes allowed-tools selection for resumed child governance. |
| crates/application/src/agent/routing.rs | Removes unused imports related to tool-surface limiting. |
| crates/application/src/agent/observe.rs | Updates tests for removed capability grants. |
| crates/application/src/agent/mod.rs | Removes tool-surface limiting logic and updates child contract tests. |
| crates/application/src/agent/context.rs | Switches session ID normalization helper and adjusts resolved-limits backfill logic. |
| crates/application/Cargo.toml | Adds dependency on astrcode-support. |
| crates/adapter-tools/src/lib.rs | Removes transitional re-export of SubAgentExecutor. |
| crates/adapter-tools/src/builtin_tools/shell.rs | Moves shell resolution and tool-result persistence to astrcode-support. |
| crates/adapter-tools/src/builtin_tools/session_plan.rs | Adds workflow state persistence and plan artifact contract validation helpers. |
| crates/adapter-tools/src/builtin_tools/read_file.rs | Moves tool-result persistence to astrcode-support. |
| crates/adapter-tools/src/builtin_tools/list_dir.rs | Renames size field to sizeBytes and updates docs/tests accordingly. |
| crates/adapter-tools/src/builtin_tools/grep.rs | Skips .git internals when hidden files are enabled and adds regression test. |
| crates/adapter-tools/src/builtin_tools/fs_common.rs | Moves project dir resolution and tool-result persistence to astrcode-support. |
| crates/adapter-tools/src/builtin_tools/find_files.rs | Moves tool-result persistence to astrcode-support. |
| crates/adapter-tools/src/builtin_tools/enter_plan_mode.rs | Renames a test to match new behavior expectation. |
| crates/adapter-tools/src/agent_tools/tests.rs | Removes capabilityGrant parsing expectations and updates error text. |
| crates/adapter-tools/src/agent_tools/spawn_tool.rs | Removes capabilityGrant schema/docs/examples and uses core SubAgentExecutor directly. |
| crates/adapter-tools/src/agent_tools/mod.rs | Removes executor module and transitional export. |
| crates/adapter-tools/src/agent_tools/executor.rs | Deletes transitional SubAgentExecutor re-export file. |
| crates/adapter-tools/src/agent_tools/collab_result_mapping.rs | Removes restricted/capability-limit advisory fields. |
| crates/adapter-tools/Cargo.toml | Adds dependency on astrcode-support. |
| crates/adapter-storage/src/session/repository.rs | Updates checkpoint construction API and test imports. |
| crates/adapter-storage/src/session/query.rs | Moves project dir name helper to astrcode-support. |
| crates/adapter-storage/src/session/paths.rs | Moves host-path helpers to astrcode-support. |
| crates/adapter-storage/src/session/iterator.rs | Adds legacy origin parsing regression test and updates TurnDone payload shape. |
| crates/adapter-storage/src/session/event_log.rs | Updates event log tests for new assistant block field. |
| crates/adapter-storage/src/mcp_settings_store.rs | Moves home dir resolution to astrcode-support. |
| crates/adapter-storage/src/config_store.rs | Moves home dir resolution to astrcode-support. |
| crates/adapter-storage/Cargo.toml | Adds dependency on astrcode-support. |
| crates/adapter-skills/src/skill_loader.rs | Moves home dir resolution to astrcode-support. |
| crates/adapter-skills/src/skill_catalog.rs | Moves home dir resolution to astrcode-support. |
| crates/adapter-skills/src/builtin_skills/mod.rs | Moves home dir resolution to astrcode-support. |
| crates/adapter-skills/Cargo.toml | Adds dependency on astrcode-support. |
| crates/adapter-prompt/src/plan.rs | Adds prompt source metadata projection and tests. |
| crates/adapter-prompt/src/layered_builder.rs | Updates docs to remove Anthropic-specific wording. |
| crates/adapter-prompt/src/core_port.rs | Adds global cache strategy selection and includes prompt sources in output metadata + tests. |
| crates/adapter-prompt/src/context.rs | Moves default shell label to astrcode-support. |
| crates/adapter-prompt/src/block.rs | Adds helper to parse source:* tag into a normalized source name. |
| crates/adapter-prompt/Cargo.toml | Adds dependency on astrcode-support. |
| crates/adapter-mcp/src/transport/sse.rs | Improves HTTP error classification using http_with_source. |
| crates/adapter-mcp/src/transport/http.rs | Improves HTTP error classification using http_with_source. |
| crates/adapter-mcp/src/manager/mod.rs | Adds reload snapshot capture/restore APIs + test. |
| crates/adapter-mcp/src/bridge/resource_tool.rs | Moves project dir + tool result persistence to astrcode-support. |
| crates/adapter-mcp/Cargo.toml | Adds dependency on astrcode-support. |
| crates/adapter-llm/src/openai/dto.rs | Adds shared OpenAI DTOs/converters and an SSE processor trait. |
| crates/adapter-llm/src/lib.rs | Removes Anthropic module exposure and updates docs/error mapping. |
| crates/adapter-llm/src/anthropic/response.rs | Deletes Anthropic non-stream response mapping module. |
| crates/adapter-llm/src/anthropic/mod.rs | Deletes Anthropic provider module. |
| crates/adapter-agents/src/lib.rs | Moves home-dir resolution to astrcode-support and removes tool allow/deny from agent profiles. |
| crates/adapter-agents/Cargo.toml | Adds dependency on astrcode-support. |
| ROADMAP.md | Removes roadmap document. |
| README.md | Updates docs for OpenAI-only support and changes dev/build commands. |
| Cargo.toml | Adds crates/support to workspace members. |
| ASTRCODE_EXPLORATION_REPORT.md | Updates a heading title. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async fn ensure_handle_has_resolved_limits( | ||
| kernel: &dyn crate::AgentKernelPort, | ||
| gateway: &astrcode_kernel::KernelGateway, | ||
| handle: SubRunHandle, | ||
| max_steps: Option<u32>, | ||
| ) -> std::result::Result<SubRunHandle, String> { | ||
| if !handle.resolved_limits.allowed_tools.is_empty() { | ||
| if handle.resolved_limits == ResolvedExecutionLimitsSnapshot { | ||
| return Ok(handle); | ||
| } | ||
|
|
||
| super::persist_resolved_limits_for_handle( | ||
| kernel, | ||
| handle, | ||
| default_resolved_limits_for_gateway(gateway, max_steps), | ||
| default_resolved_limits_for_gateway(gateway), | ||
| ) | ||
| .await | ||
| } |
There was a problem hiding this comment.
The comparisons against ResolvedExecutionLimitsSnapshot look inverted. ensure_handle_has_resolved_limits should persist the default snapshot when the handle is missing limits, but it currently early-returns when limits equal the default and persists when they differ. Similarly, the caller checks != ResolvedExecutionLimitsSnapshot before trying to backfill. Flip these conditions so backfill happens only when the snapshot is missing/empty, and no-op when it’s already present.
| if handle.depth == 0 && handle.resolved_limits != ResolvedExecutionLimitsSnapshot { | ||
| return ensure_handle_has_resolved_limits( | ||
| self.kernel.as_ref(), | ||
| &self.kernel.gateway(), | ||
| handle, | ||
| None, | ||
| ) |
There was a problem hiding this comment.
The comparisons against ResolvedExecutionLimitsSnapshot look inverted. ensure_handle_has_resolved_limits should persist the default snapshot when the handle is missing limits, but it currently early-returns when limits equal the default and persists when they differ. Similarly, the caller checks != ResolvedExecutionLimitsSnapshot before trying to backfill. Flip these conditions so backfill happens only when the snapshot is missing/empty, and no-op when it’s already present.
| pub fn validate_plan_artifact_contract( | ||
| content: &str, | ||
| artifact: &ModeArtifactDef, | ||
| ) -> PlanArtifactContractBlockers { | ||
| let trimmed = content.trim(); | ||
| if trimmed.is_empty() { | ||
| return PlanArtifactContractBlockers { | ||
| missing_headings: artifact | ||
| .required_headings | ||
| .iter() | ||
| .map(|heading| markdown_section_heading(heading)) | ||
| .collect(), | ||
| invalid_sections: Vec::new(), | ||
| }; | ||
| } | ||
|
|
||
| let missing_headings = artifact | ||
| .required_headings | ||
| .iter() | ||
| .map(|heading| markdown_section_heading(heading)) | ||
| .filter(|heading| !trimmed.contains(heading)) | ||
| .collect::<Vec<_>>(); |
There was a problem hiding this comment.
The plan contract validation relies on substring search (contains / find) for headings, which can yield false positives (e.g., mentioning "## Context" in body text) and false negatives (different spacing, heading levels, Windows line endings, etc.). Since this function gates plan-mode exit behavior, it should match headings at line-start (e.g., (?m)^##\\s+Context\\s*$) and extract sections based on real heading boundaries rather than find(\"\\n## \").
| fn section_body<'a>(content: &'a str, heading: &str) -> Option<&'a str> { | ||
| let start = content.find(heading)?; | ||
| let after_heading = &content[start + heading.len()..]; | ||
| let next_heading_offset = after_heading.find("\n## "); | ||
| Some(match next_heading_offset { | ||
| Some(offset) => &after_heading[..offset], | ||
| None => after_heading, | ||
| }) | ||
| } |
There was a problem hiding this comment.
The plan contract validation relies on substring search (contains / find) for headings, which can yield false positives (e.g., mentioning "## Context" in body text) and false negatives (different spacing, heading levels, Windows line endings, etc.). Since this function gates plan-mode exit behavior, it should match headings at line-start (e.g., (?m)^##\\s+Context\\s*$) and extract sections based on real heading boundaries rather than find(\"\\n## \").
| self.list_session_metas() | ||
| .await? | ||
| .into_iter() | ||
| .find(|meta| meta.session_id == result.new_session_id.as_str()) | ||
| .ok_or_else(|| { | ||
| astrcode_core::AstrError::Internal(format!( | ||
| "forked session '{}' was created but metadata is unavailable", | ||
| result.new_session_id | ||
| )) | ||
| }) |
There was a problem hiding this comment.
This implementation performs a full list_session_metas() scan after forking to recover the new SessionMeta, which is O(n) and adds another round-trip. If possible, prefer returning SessionMeta directly from session-runtime::fork_session (or add a targeted get_session_meta(new_session_id) API) to avoid the extra query and reduce the chance of transient 'metadata unavailable' failures.
| self.list_session_metas() | |
| .await? | |
| .into_iter() | |
| .find(|meta| meta.session_id == result.new_session_id.as_str()) | |
| .ok_or_else(|| { | |
| astrcode_core::AstrError::Internal(format!( | |
| "forked session '{}' was created but metadata is unavailable", | |
| result.new_session_id | |
| )) | |
| }) | |
| self.get_session_meta(result.new_session_id.as_str()).await |
| /// assistant 输出被截断后,为同一 turn 续写而注入的内部提示。 | ||
| #[serde(alias = "auto_continue_nudge")] |
There was a problem hiding this comment.
Adding an alias preserves parsing of the legacy value, but serialization will now emit the canonical variant name (likely continuation_prompt under rename_all). If any external consumer or persisted format expects auto_continue_nudge on output, consider using #[serde(rename = \"auto_continue_nudge\", alias = \"continuation_prompt\")] (or otherwise documenting the wire-level breaking change) so outbound compatibility is explicit.
| #[serde(alias = "auto_continue_nudge")] | |
| #[serde(rename = "auto_continue_nudge", alias = "continuation_prompt")] |
No description provided.