Repository navigation
feat(agent): enforce control-plane session execution grants - #7233
Conversation
M4n5ter
left a comment
There was a problem hiding this comment.
English
The follow-up fixes from #7085 look solid — recovery scoping, central mutation gating in service.rs, read-first FileRepository::observe, Arc<Grant>, bounded stopped acknowledgement, migrations.lock.json + upgrade_compat coverage, and the rewritten behavioral Host tests all address the earlier findings cleanly.
I pushed one small follow-up commit to finish two remaining edges:
- Moved live
require_execution()out ofRunAccess::check_tool()intoNativeDriver::validate_tool,NativeCellPort::invoke, and around interactive approval waits intools.rs. This covers non-Servicetools (MCP,todo,Recall, Code Modeexec/wait) at live admission while eliminating redundant 3–4xobserve()calls per nativeServicetool call. - Disabled
goals,scheduled_tasks, andbotsettings inOwner::openunder managed execution so in-processCreateGoal/GoalStatus/ScheduledTask/Bottools match the single-Session boundary enforced byservice.rsandOwner::activated. - Trimmed the redundant permission/checkpoint loop from the lease-expiry test and added assertions for both fixes above.
Verified locally with cargo fmt --check, strict cargo clippy -p maka-agent-native --lib --tests --no-deps -- -D warnings, and all 3 model_recovery::execution tests passing. LGTM!
简体中文
针对 #7085 的改动都很扎实:恢复范围收口、service.rs 统一 mutation 拦检、FileRepository::observe 先读后写、Arc<Grant>、stopped 超时保护、migrations.lock.json + upgrade_compat 胶囊验证,以及重写后的端到端行为测试都到位了。
我顺手补推了一个小 commit 把最后两处边角收干净:
- 把实时
require_execution()从RunAccess::check_tool()移到NativeDriver::validate_tool、NativeCellPort::invoke以及tools.rs的交互式审批前后——这样非Service工具(MCP、todo、Recall、Code Modeexec/wait)都能走实时 authority 校验,同时消掉了原生Service工具单次调用 3–4 次重复observe()。 - 受管模式下在
Owner::open直接关闭goals/scheduled_tasks/bot,让进程内的CreateGoal/GoalStatus/ScheduledTask/Bot工具和service.rs及Owner::activated的单 Session 边界保持一致。 - 顺手去掉了租约过期用例里重复跑的那段写文件/网络/checkpoint 套件,并补上了上面两处改动的断言。
本地跑过 cargo fmt --check、maka-agent-native 严格 clippy 以及 3 个 model_recovery::execution 实测用例全部通过。LGTM!
Add a durable execution authority, generation-fenced checkpoint commits, Host admission and permission ceilings, and confirmed stop-before-handoff. Cover concurrent claims, lost replies, expiry, cleanup failures and real Host model/tool/checkpoint behavior. Refs apache#2370 Generated-by: Codex
Reject captured sandbox and approval ceilings that exceed the active execution grant. Cover the restore boundary in the real Host fixture and document it in both guides. Generated-by: Codex
Gate Session mutations centrally and reject foreign or overprivileged recovery before claims, queue consumption, or preflight failure writes. Keep global producers outside the single-Session execution scope. Remove redundant authority observations, share grant policy ownership, avoid write locks for active observations, and bound stopped acknowledgement. Replace internal test hooks with persisted Host recovery, real permission boundaries and autonomous drain tests; cover execution state in the upgrade capsule and seal the appended repository migration. Refs apache#7085 Generated-by: Codex
Check live execution authority once per top-level tool in NativeDriver::validate_tool (and per nested Code Mode tool in NativeCellPort::invoke, plus around interactive approval waits) so non-Service tools like MCP, todo, Recall and exec cells cannot slip past revocation while avoiding 3-4x redundant observe() calls on native Service tools. Disable Goal, ScheduledTask and Bot tool registration in managed execution mode so in-process tools match the single-Session boundary enforced by service.rs and Owner::activated.
55a89e0 to
4f28629
Compare
Summary
A published checkpoint does not authorize a Host to continue its Session. Add an optional, control-plane-independent execution grant so a trusted embedding can bind one native Session to an execution generation, enforce its permission ceiling, and fence checkpoint publication. The default local Host remains unchanged.
The file-backed reference authority durably arbitrates claims and renewals, and commits generation validation, Head CAS, and the original receipt in one transaction. Revocation or expiry closes admission and autonomously drains the Host; a successor remains blocked until the supervisor supplies confirmed cleanup. Grant fields alone are not credentials, and lease expiry alone does not authorize takeover.
This replaces #7085, which closed when
rust-previewwas deleted. GitHub rejects reopening or retargeting that closed PR, so this continuation targetsmainand addresses its review:Arc, and checkpoint commits avoid redundant authority round trips.Migration
0003_execution.sqladds the reference authority's tables without rewriting published migrations; its digest is sealed in the migration lock. The upgrade capsule now preserves and cold-replays claims, renewals, publication receipts, the Head and an unacknowledged draining generation. Historical capsules without this optional scenario remain readable.Scope is one existing native Session in its existing Root/deployment/namespace. Cross-Root activation, external executors, cloud adapters and user-facing configuration remain separate work. This does not promise isolation from unmanaged workspace writers.
Refs #2370.
Verification
Rust builds and tests ran on a Mac mini with two build jobs and one test thread:
Checkpoint execution/repository: 30 passed; one existing manual I/O baseline ignored.
Managed Host execution/recovery: 3 passed.
State stop/steering recovery: 10 passed.
Existing Host permission boundaries: 4 passed; unmanaged queued recovery: 1 passed.
CLI upgrade capsule round trip: 1 passed.
The CLI background HTTP-service regression that failed in the old PR CI: 1 passed on this macOS run.
Strict Clippy (
--lib --tests --no-deps -- -D warnings) passed for event-log, agent-state, host-runtime and agent-native.cargo fmtchecks passed for the five affected packages; migration lock validation andgit diff --checkpassed. The remote full-workspacecargo fmt --allattempt was blocked by the nested checkout making an excluded vendored crate discover the parent checkout's workspace, so the scoped format check was used instead.Total: 50 passed, plus one ignored manual baseline. This is targeted macOS validation, not a claim that the new PR's cross-platform CI has passed. The tested main baseline is
b5c50b10a5; the subsequent Windows namespace change indd4c1581eatouches no PR files.AI use
Tool(s) and scope: Codex assisted with implementation, review fixes, tests, documentation and validation. Commits retain
Generated-by: Codextrailers.Checklist
Does this PR entail a breaking change or persisted-data migration?
Does this PR entail a change in behavior?