收紧协作Prompt单一来源
复用Bundle内Supervisor身份合同覆盖后台规划上下文 将首批协作协议错误收敛为结构化事实并由外置fragment给出动作指令 监听Prompt Bundle根目录以阻断增量构建中的孤立section 补齐源码回流门禁、依赖断言和边界文档
This commit is contained in:
@@ -164,7 +164,10 @@ pub fn compile_manifest(manifest_path: &Path) -> Result<CompiledPromptBundle, St
|
||||
.ok_or_else(|| "Prompt Bundle manifest 缺少父目录".to_string())?;
|
||||
let canonical_base = fs::canonicalize(base)
|
||||
.map_err(|error| format!("解析 Prompt Bundle 根目录失败:{error}"))?;
|
||||
let mut dependencies = vec![manifest_path.to_path_buf()];
|
||||
// Watch the Bundle root as well as known files so that adding an unregistered
|
||||
// Markdown section invalidates Cargo's build-script cache and reaches the
|
||||
// fail-closed orphan-section validation below.
|
||||
let mut dependencies = vec![base.to_path_buf(), manifest_path.to_path_buf()];
|
||||
let mut section_paths = BTreeSet::new();
|
||||
let mut sections = BTreeMap::new();
|
||||
if manifest.sections.is_empty() {
|
||||
|
||||
+13
-5
@@ -340,7 +340,7 @@ pub(in crate::agent) fn build_game_creator_background_agent_context(
|
||||
let repository_context = build_repository_startup_context_at(root)?;
|
||||
let repository_prompt = render_repository_startup_context_for_prompt(&repository_context);
|
||||
let identity_instruction = if template_agent_id == GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID {
|
||||
"你是项目唯一面向用户的总控 Agent。持续保留用户原始目标,负责澄清、规划、行动、委派、等待并汇总专业 Agent 结果;专业 Agent 的回执是原目标的证据,不是新的用户目标。"
|
||||
game_creator_project_supervisor_chat_system_prompt()
|
||||
} else {
|
||||
"请只以这个专业 Agent 的身份行动。"
|
||||
};
|
||||
@@ -423,10 +423,10 @@ mod tests {
|
||||
agent_runtime_root_source_at, bind_game_creator_agent_runtime_run_profile_at,
|
||||
build_game_creator_agent_background_tool_plan_request,
|
||||
game_creator_agent_context_preload_notice, game_creator_agent_runtime_role_overlay_prompt,
|
||||
init_local_game_project_at, provider_command_exec_contract,
|
||||
provider_command_start_contract, start_game_creator_agent_runtime_task_at,
|
||||
AgentRuntimeTaskLink, GameCreatorMcpCatalog, GameCreatorMcpCatalogTool,
|
||||
AGENT_RUNTIME_COMPLETION_BLOCKER_TOOL_PLAN_PROTOCOL,
|
||||
game_creator_project_supervisor_chat_system_prompt, init_local_game_project_at,
|
||||
provider_command_exec_contract, provider_command_start_contract,
|
||||
start_game_creator_agent_runtime_task_at, AgentRuntimeTaskLink, GameCreatorMcpCatalog,
|
||||
GameCreatorMcpCatalogTool, AGENT_RUNTIME_COMPLETION_BLOCKER_TOOL_PLAN_PROTOCOL,
|
||||
AGENT_RUNTIME_RUN_PROFILE_AUTONOMOUS_GAME_BUILD, AGENT_RUNTIME_SUPERVISOR_CLI_SOURCE,
|
||||
AGENT_RUNTIME_SUPERVISOR_GAME_CHAT_SOURCE, AGENT_RUNTIME_SUPERVISOR_GUI_SOURCE,
|
||||
GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID,
|
||||
@@ -576,6 +576,13 @@ mod tests {
|
||||
)
|
||||
.expect("build supervisor planning request");
|
||||
let supervisor_prompt = &supervisor_request.messages[1].content;
|
||||
let supervisor_identity_contract = game_creator_project_supervisor_chat_system_prompt();
|
||||
assert_eq!(
|
||||
supervisor_prompt
|
||||
.matches(supervisor_identity_contract)
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
assert!(supervisor_prompt.contains(SUPERVISOR_NOTICE));
|
||||
assert!(!supervisor_prompt.contains(ORDINARY_NOTICE));
|
||||
assert!(supervisor_prompt.contains(MEMORY_MARKER));
|
||||
@@ -709,6 +716,7 @@ mod tests {
|
||||
)
|
||||
.expect("build ordinary planning request");
|
||||
let ordinary_prompt = &ordinary_request.messages[1].content;
|
||||
assert!(!ordinary_prompt.contains(supervisor_identity_contract));
|
||||
assert!(ordinary_prompt.contains(ORDINARY_NOTICE));
|
||||
assert!(!ordinary_prompt.contains(SUPERVISOR_NOTICE));
|
||||
assert!(!ordinary_prompt.contains(MEMORY_MARKER));
|
||||
|
||||
+1
-1
@@ -583,7 +583,7 @@ pub(in crate::agent) async fn request_game_creator_agent_background_tool_plan_at
|
||||
Err(AgentRuntimeToolPlanProtocolError::new(
|
||||
AgentRuntimeToolPlanProtocolErrorKind::PlanSemantics,
|
||||
format!(
|
||||
"{AGENT_RUNTIME_SUPERVISOR_INITIAL_COLLABORATION_LIVENESS_ERROR_PREFIX};当前已到第 {loop_index} 轮,父 run 仍无协作事实,本响应也未提交满足项目 policy 的完整 agent.delegate / agent.spawn_isolated 协作批次。请在本次修复一次性建立完整首批协作,不得继续只更新计划、读取、搜索、查询状态或返回最终回复"
|
||||
"{AGENT_RUNTIME_SUPERVISOR_INITIAL_COLLABORATION_LIVENESS_ERROR_PREFIX};当前轮次={loop_index};父 run 协作事实=无;本响应协作合同=无"
|
||||
),
|
||||
))
|
||||
} else {
|
||||
|
||||
@@ -257,14 +257,19 @@ fn compiles_manifest_in_declared_order_and_emits_all_dependencies() {
|
||||
.dependencies
|
||||
.iter()
|
||||
.map(|path| {
|
||||
path.strip_prefix(fixture.root())
|
||||
.expect("dependency below bundle root")
|
||||
.to_string_lossy()
|
||||
.replace('\\', "/")
|
||||
let relative = path
|
||||
.strip_prefix(fixture.root())
|
||||
.expect("dependency below bundle root");
|
||||
if relative.as_os_str().is_empty() {
|
||||
".".to_string()
|
||||
} else {
|
||||
relative.to_string_lossy().replace('\\', "/")
|
||||
}
|
||||
})
|
||||
.collect::<BTreeSet<_>>();
|
||||
let expected = std::iter::once("manifest.json".to_string())
|
||||
.chain(SECTION_FILES.iter().map(|(_, path)| (*path).to_string()))
|
||||
.chain(std::iter::once(".".to_string()))
|
||||
.collect::<BTreeSet<_>>();
|
||||
assert_eq!(dependencies, expected);
|
||||
}
|
||||
@@ -670,6 +675,7 @@ fn production_sources_cannot_restore_parallel_prompt_or_agent_catalog_truths() {
|
||||
for forbidden in [
|
||||
"一次性建立完整首批合同",
|
||||
"完整的 agent.delegate / agent.spawn_isolated 批次",
|
||||
"请在本次修复一次性建立完整首批协作",
|
||||
"当前父 run 已有 ready 未认领回执",
|
||||
"当前正式 manifest DAG 仍有专业 task 在运行",
|
||||
"向 code-prototype 创建一个新的后续修复委派",
|
||||
@@ -682,6 +688,7 @@ fn production_sources_cannot_restore_parallel_prompt_or_agent_catalog_truths() {
|
||||
for forbidden in [
|
||||
"agent.spawn_isolated 使用",
|
||||
"正式 manifest 任务图是唯一首轮专业执行链",
|
||||
"你是项目唯一面向用户的总控 Agent",
|
||||
] {
|
||||
assert!(
|
||||
!provider_request_production.contains(forbidden),
|
||||
|
||||
@@ -5940,7 +5940,7 @@
|
||||
|
||||
- 决策:把 `prompt.rs` 中依赖长自然语言精确匹配的链式 `.replace()` 拆成仓库内版本化 Prompt Bundle;`build.rs` 读取、校验并生成静态 Rust 定义编译进 Tauri 二进制,生产源码不再直接引用 `prompts/runtime` 的单个 Markdown。
|
||||
- 边界:Supervisor 的角色选择、并行委派、all-join、视觉返工、claim gate 和 repair 自然语言合同,以及 Supervisor / 六组专业 Agent 的编译期静态节点目录进入 Bundle。Bundle 不是完整可执行 graph,也不是生产 Skill;正式 DAG 依赖边、权限、安全门和完成合同继续由 Rust、`shared-contracts` 与校验后的项目协作策略掌控。
|
||||
- 一致性:manifest 是 section、组合顺序、平台 / Editor 变体、role overlay、Provider 协作 fragment 和静态节点目录的单一来源;isolated / all-join、autonomous 首轮、首批协作修复、delivery 收敛、manifest wait、试玩后续委派,以及 Supervisor interaction / final-reply 身份合同不得在 Provider 或 `prompt.rs` 源码中复制。构建期拒绝未知字段、非法 / 重复 / symlink 路径、孤立 Markdown、未知 / 重叠 selector、节点 / alias / 生成标识符冲突,并强制专业节点 taskId / group / role 与正式 seed DAG 一致。原生工具目录仍从 `agent_runtime_native_executable_tools()` 生成,`mcp.call` 不混入静态原生目录;MCP 工具只从当前请求的动态 catalog 暴露。
|
||||
- 一致性:manifest 是 section、组合顺序、平台 / Editor 变体、role overlay、Provider 协作 fragment 和静态节点目录的单一来源;isolated / all-join、autonomous 首轮、首批协作修复、delivery 收敛、manifest wait、试玩后续委派,以及 Supervisor interaction / background planning / final-reply 身份合同不得在 Provider 或 `prompt.rs` 源码中复制。构建脚本同时监听 Bundle 根目录、manifest 和已登记 section,拒绝未知字段、非法 / 重复 / symlink 路径、孤立 Markdown、未知 / 重叠 selector、节点 / alias / 生成标识符冲突,并强制专业节点 taskId / group / role 与正式 seed DAG 一致。原生工具目录仍从 `agent_runtime_native_executable_tools()` 生成,`mcp.call` 不混入静态原生目录;MCP 工具只从当前请求的动态 catalog 暴露。
|
||||
|
||||
## 2026-08-03 AI 游戏生成泥点不足使用确定性中断说明
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
|
||||
V1.11 的受保护仓库控制目录同时包含 `.git / .agent / .agents / .codex / .hermes`;其中 `.agent` 对项目命令隐藏,其余控制目录只读。
|
||||
|
||||
2026-08-04 起,Runtime 的公共工具规划指令、Supervisor 协作编排 playbook、条件 overlay 和编译期静态 Agent 节点目录统一由版本化 Prompt Bundle 驱动,位于 `apps/ai-game-creator-shell/src-tauri/prompts/runtime/`。`manifest.json` 是 section 路径、组合顺序、平台 / Editor 变体、role overlay、Provider 协作 fragment,以及 Supervisor 与六组专业 Agent 静态目录的单一来源;`build.rs` 以失败关闭方式校验 schema、引用、路径 / symlink、孤立 Markdown、selector、节点身份、旧 alias 和生成标识符,再生成 `'static + Copy` Rust 定义并编译进发布二进制。生成的专业节点 taskId / group / role 还必须在构建期与 `shared-contracts::new_game_creation_app_seed_tasks()` 强一致,防止静态目录和正式 seed DAG 漂移。Bundle 承载公共指令、隔离 Agent 合同、平台差异、角色选择、并行委派、all-join、视觉返工、claim gate,Supervisor interaction / final-reply 身份合同,以及首批协作、delivery 收敛、manifest wait、试玩后续委派等 repair 自然语言合同;`agent_runtime_native_executable_tools()` 仍是原生可执行工具的权威源列表,同时供 Prompt 工具目录与 native capability registry 使用,MCP 工具只从当前请求的动态 catalog 暴露。最终 Provider 请求必须通过生成的 section、composition、overlay 与 provider fragment API 构建,禁止恢复直接 `include_str!("prompts/runtime/...")`、在 Provider 或 `prompt.rs` 源码中复制协作 graph 文案,或依赖自然语言精确 `.replace()` 注入工具合同、平台规则或角色规则。Bundle 不是完整可执行 graph:正式 DAG 依赖边、权限、沙箱、委派容量、持久 all-join 状态机、完成门和身份校验仍由 Rust、`shared-contracts` 与经校验的 `.agent/collaboration-policy.json` 强制执行,不允许通过 Skill、外部配置或任意运行时 Prompt 覆盖绕过。
|
||||
2026-08-04 起,Runtime 的公共工具规划指令、Supervisor 协作编排 playbook、条件 overlay 和编译期静态 Agent 节点目录统一由版本化 Prompt Bundle 驱动,位于 `apps/ai-game-creator-shell/src-tauri/prompts/runtime/`。`manifest.json` 是 section 路径、组合顺序、平台 / Editor 变体、role overlay、Provider 协作 fragment,以及 Supervisor 与六组专业 Agent 静态目录的单一来源;`build.rs` 同时监听 Bundle 根目录、manifest 和已登记 section,并以失败关闭方式校验 schema、引用、路径 / symlink、孤立 Markdown、selector、节点身份、旧 alias 和生成标识符,再生成 `'static + Copy` Rust 定义并编译进发布二进制。生成的专业节点 taskId / group / role 还必须在构建期与 `shared-contracts::new_game_creation_app_seed_tasks()` 强一致,防止静态目录和正式 seed DAG 漂移。Bundle 承载公共指令、隔离 Agent 合同、平台差异、角色选择、并行委派、all-join、视觉返工、claim gate,Supervisor interaction / background planning / final-reply 身份合同,以及首批协作、delivery 收敛、manifest wait、试玩后续委派等 repair 自然语言合同;`agent_runtime_native_executable_tools()` 仍是原生可执行工具的权威源列表,同时供 Prompt 工具目录与 native capability registry 使用,MCP 工具只从当前请求的动态 catalog 暴露。最终 Provider 请求必须通过生成的 section、composition、overlay 与 provider fragment API 构建,禁止恢复直接 `include_str!("prompts/runtime/...")`、在 Provider 或 `prompt.rs` 源码中复制协作 graph 文案,或依赖自然语言精确 `.replace()` 注入工具合同、平台规则或角色规则。Bundle 不是完整可执行 graph:正式 DAG 依赖边、权限、沙箱、委派容量、持久 all-join 状态机、完成门和身份校验仍由 Rust、`shared-contracts` 与经校验的 `.agent/collaboration-policy.json` 强制执行,不允许通过 Skill、外部配置或任意运行时 Prompt 覆盖绕过。
|
||||
|
||||
2026-07-12 起,通用开发能力的 Runtime V1.1 增量以 [`【技术方案】AI游戏创作Agent Runtime V1.1-2026-07-12.md`](./【技术方案】AI游戏创作Agent%20Runtime%20V1.1-2026-07-12.md) 为编码级事实源。它补充仓库启动上下文、同一发布二进制独立 Runner、受限本地预览浏览器验证、动态隔离子 Agent 和真实 Provider 全链路验收;本文件中“进程内 tokio task”“首轮不预加载项目内容”和“不创建动态执行实例”的旧口径由 V1.1 明确替代,未涉及能力继续沿用本文件。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user