Skip to content

feat(cli): initialize chat defaults and workspace roots from stdin - #6909

Open
Colafornia wants to merge 1 commit into
apache:rust-previewfrom
Colafornia:feat/cli-init-workspace-and-sandbox-defaults
Open

Colafornia wants to merge 1 commit into
apache:rust-previewfrom
Colafornia:feat/cli-init-workspace-and-sandbox-defaults

Conversation

@Colafornia

@Colafornia Colafornia commented Nov 14, 2026 •

Copy link
Copy Markdown
Member
English

Summary

Extend maka host init --settings-stdin to accept optional chatDefaults and projectDirectoryRoots, completing headless State Root bootstrap so containerized ACP clients and evaluation harnesses (maka-eval) can set default sandbox policy and register explicit workspace roots outside $HOME before any Host starts.

Refs #6667 and #6805.

  • Extend stdin JSON parsing (Settings / PreparedSettings in products/maka/cli/src/initialize.rs) with chatDefaults: Option<ChatDefaults> and projectDirectoryRoots: Option<Vec<DirectoryRootSpec>>.
  • Validate projectDirectoryRoots via DirectoryRootSpec::normalize inside Settings::prepare() before RootOwner::create, returning a redacted "invalid initial settings: invalid project directory roots" error without leaking caller paths or creating .maka-storage-root.json. Reject any root whose path falls inside a pre-existing State Root directory.
  • Chain the policy revision returned by store.update_network_proxy into store.set_chat_defaults(policy_revision, chat_defaults).
  • Call crate::application::configure_workspace_locations(owner, roots) after shutting down ConfigurationStore so workspace root configuration persists cleanly on initial bootstrap.
  • Update products/maka/cli/README.md and products/maka/cli/README.zh-CN.md to mention chatDefaults.sandboxMode and projectDirectoryRoots.
  • Extend products/maka/cli/tests/integration/initialize.rs to verify chatDefaults.sandboxMode (danger-full-access), projectDirectoryRoots outside $HOME via a real maka acp --root subprocess (initialize -> session/new asserting sessionId and sandbox_mode.currentValue == "danger_full_access"), and redacted rejection of invalid or self-overlapping roots.

Verification

Validated at 89f5925e2d3c341e7182b0b6ba09e7d7023976e0 (based on origin/rust-preview 2e52be5293346bdca975cca7c6356d96ad22bd87):

  • cargo test --locked -p maka-cli --test integration initialize: 4 passed, 0 failed (public_init_persists_settings_from_stdin_and_rejects_reconfiguration, public_init_persists_connections_and_default_target_from_stdin, public_init_rejects_invalid_settings_without_exposing_input, public_init_times_out_unfinished_input_without_leaving_a_reader_or_root).
  • cargo clippy --locked -p maka-cli --bins --no-deps -- -D warnings: passed (0 errors).
  • cargo clippy --locked -p maka-cli --test integration --no-deps: passed with 0 warnings in initialize.rs (--all-targets -D warnings stops on pre-existing dead_code warnings in products/maka/cli/tests/integration/main.rs, products/maka/cli/tests/integration/candidate.rs, and products/maka/cli/tests/support/host.rs, outside this PR's diff).
  • cargo fmt -p maka-cli -- --check: passed.
  • node scripts/asf-license-headers.mjs check and git diff --check: passed.

Full just check, live upstream model requests, and remote CI were not run locally.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Google Antigravity authored the implementation, integration test additions, documentation updates, and local verification. Preserve the Generated-by trailer when squashing.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
中文

概述

扩展 maka host init --settings-stdin 支持可选的 chatDefaults 与 projectDirectoryRoots,补齐无界面 State Root 初始化闭环,使容器内 ACP 客户端和评测工具(maka-eval)无需人工操作即可在 Host 启动前预设默认沙盒策略并注册 $HOME 之外的工作区根目录。

关联 #6667 与 #6805。

  • 在 products/maka/cli/src/initialize.rs 的 Settings / PreparedSettings 中新增 chatDefaults: Option<ChatDefaults> 与 projectDirectoryRoots: Option<Vec<DirectoryRootSpec>>。
  • 在 Settings::prepare() 阶段(早于 RootOwner::create)执行 DirectoryRootSpec::normalize,失败时统一返回脱敏错误 "invalid initial settings: invalid project directory roots",既不泄露输入路径,也不残留 .maka-storage-root.json;同时拦截落入已有 State Root 目录内的 root。
  • 将 store.update_network_proxy 返回的 policy_revision 串联传入 store.set_chat_defaults(policy_revision, chat_defaults)。
  • 在关闭并释放 ConfigurationStore 后调用 crate::application::configure_workspace_locations(owner, roots) 持久化工作区根目录。
  • 更新 products/maka/cli/README.md 与 products/maka/cli/README.zh-CN.md 的说明。
  • 在 products/maka/cli/tests/integration/initialize.rs 增加真实 maka acp --root 子进程 initialize -> session/new 端到端断言(校验 $HOME 外工作区可创建会话且 sandbox_mode == "danger_full_access"),并覆盖非法路径脱敏与自包含拦截。

验证

验证提交:89f5925e2d3c341e7182b0b6ba09e7d7023976e0(基于 origin/rust-preview 2e52be5293346bdca975cca7c6356d96ad22bd87):

  • cargo test --locked -p maka-cli --test integration initialize:4 项通过,0 项失败。
  • cargo clippy --locked -p maka-cli --bins --no-deps -- -D warnings:通过(0 错误)。
  • cargo clippy --locked -p maka-cli --test integration --no-deps:initialize.rs 零告警(带 --all-targets -D warnings 会在 diff 之外的 main.rs、candidate.rs、tests/support/host.rs 既有的 dead_code 告警处中断)。
  • cargo fmt -p maka-cli -- --check、node scripts/asf-license-headers.mjs check 与 git diff --check:通过。

未在本地执行完整 just check、真实上游模型请求及远端 CI。

AI 使用

  • 没有生成式工具作出实质性贡献
  • 生成式工具作出了实质性贡献

工具与范围:Google Antigravity 完成实现编写、集成测试补充、文档更新与本地验证。Squash 合并时保留 Generated-by trailer。

审查清单

  • 测试覆盖本次变更且无修复前会失败
  • 格式化、类型检查与受影响测试集已在本地通过

本 PR 是否带来行为变更?

  • 是 — 如上文概述所述
  • 否

@Colafornia
Colafornia force-pushed the feat/cli-init-workspace-and-sandbox-defaults branch from 3e6ec54 to 89f5925 Compare November 14, 2026 15:46
@Colafornia
Colafornia marked this pull request as ready for review November 14, 2026 15:46

This branch has not been deployed

No deployments
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