From 7ed5d0e2ea351180fb7f123ba914fec512bb3a08 Mon Sep 17 00:00:00 2001 From: joelteply Date: Sat, 31 Oct 2026 09:19:49 -0500 Subject: [PATCH] Read-only verbs declare they observe: an unchanged code/search, glob, list, tree, exists or git status/diff/log reaches her view as a repeat (card 7d7b1ace) MIND-CONTEXT invariant 4 (#5652) renders an unchanged observation as "repeat of #n" only for a command that declares ToolEffect::Observes; code/read was the only one, so a re-run of an unchanged search or `git status` still arrived whole. The validator's Undeclared count is this gap. - action_command! takes an optional `effect: ,` clause (both arms), resolved through the kernel's own re-export (`$crate::sdk_codegen::ToolEffect`), so every crate that expands the macro compiles without naming continuum-base; absent keeps the trait default, Undeclared. - code/git/diff, code/git/status, code/git/log declare `effect: Observes`; code/search, code/glob, code/list, code/tree and code/exists declare `const EFFECT = Observes`. - normalize_edit_mode.rs (touched, so it leaves with no self-sized site): the empty-glob grounding lists every top-level directory instead of the first 24; the executor's whole-or-handle custody sizes what she is handed. Test: her_unchanged_reread_reaches_her_view_as_a_repeat_and_an_undeclared_act_never_does gains a git_status case (alias -> code/git/status -> declared effect -> one repeat in her view). Mutation: dropping `effect: Observes` from status.rs fails it (repeats 0). Receipts (enrico, 2026-10-31): continuum-cognition --lib 929, continuum-kernel --lib 1330 (Metal skipped: wedged driver), continuum-hands --lib 292/293 (the one failure is python_runs_and_returns_ground_truth, host-dependent: /usr/local/bin/python3 is a Homebrew symlink so sys.executable differs from the reported interpreter; run.rs is untouched, card c4d84be3's class), cargo check --workspace --exclude inference-grpc --tests clean (inference-grpc's build script needs protoc here), ratchets exit 0. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE --- .../src/cognition/context_streams/tests.rs | 14 ++++++++++++++ .../continuum-hands/src/commands/code/git/diff.rs | 1 + core/continuum-hands/src/commands/code/git/log.rs | 1 + .../src/commands/code/git/status.rs | 1 + .../modules/code_commands/normalize_edit_mode.rs | 8 +++++++- core/continuum-kernel/src/sdk_codegen/mod.rs | 15 ++++++++++++--- 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/core/continuum-cognition/src/cognition/context_streams/tests.rs b/core/continuum-cognition/src/cognition/context_streams/tests.rs index 7785cd5df9..4155df02a1 100644 --- a/core/continuum-cognition/src/cognition/context_streams/tests.rs +++ b/core/continuum-cognition/src/cognition/context_streams/tests.rs @@ -241,4 +241,18 @@ fn her_unchanged_reread_reaches_her_view_as_a_repeat_and_an_undeclared_act_never memory.record_settlement("wrote", None); assert_eq!(view.advance(&[&actions as &dyn Source<_>]).repeats, 0, "an undeclared act is never a repeat"); } + + // Card 7d7b1ace: the read-only verbs declare it too. `git_status` resolves to `code/git/status`, + // declared through action_command!'s `effect:` clause, so an unchanged status is a repeat. + let memory = WorkingMemory::new(8); + let actions = Actions { memory: &memory, persona: uuid::Uuid::nil() }; + let (mut view, _) = View::start(Vec::new(), &[&actions as &dyn Source<_>], whole).unwrap(); // unwrap: one grant per claim cannot mismatch + let status = "On branch main\nnothing to commit, working tree clean\n".repeat(20); + let mut repeats = 0; + for _ in 0..2 { + memory.record_receipt_typed(&[act("git_status", None)], &status, None, unsaved()); + memory.record_settlement("checked", None); + repeats += view.advance(&[&actions as &dyn Source<_>]).repeats; + } + assert_eq!(repeats, 1, "an unchanged status, asked again, arrives as a repeat"); } diff --git a/core/continuum-hands/src/commands/code/git/diff.rs b/core/continuum-hands/src/commands/code/git/diff.rs index c605aca153..3034c4a469 100644 --- a/core/continuum-hands/src/commands/code/git/diff.rs +++ b/core/continuum-hands/src/commands/code/git/diff.rs @@ -40,6 +40,7 @@ crate::action_command! { access: AiSafe, native: true, aliases: &["git_diff"], + effect: Observes, params: GitDiffParams, output: GitDiffResult, run(this, ctx, p) => { diff --git a/core/continuum-hands/src/commands/code/git/log.rs b/core/continuum-hands/src/commands/code/git/log.rs index 6b98098ad2..d7fd6d0f11 100644 --- a/core/continuum-hands/src/commands/code/git/log.rs +++ b/core/continuum-hands/src/commands/code/git/log.rs @@ -39,6 +39,7 @@ crate::action_command! { name: "code/git/log", access: AiSafe, aliases: &["git_log"], + effect: Observes, params: GitLogParams, output: GitLogResult, run(this, ctx, p) => { diff --git a/core/continuum-hands/src/commands/code/git/status.rs b/core/continuum-hands/src/commands/code/git/status.rs index 93c688f2b4..855f7827e3 100644 --- a/core/continuum-hands/src/commands/code/git/status.rs +++ b/core/continuum-hands/src/commands/code/git/status.rs @@ -28,6 +28,7 @@ crate::action_command! { access: AiSafe, native: true, aliases: &["git_status"], + effect: Observes, params: GitStatusParams, output: GitStatusInfo, run(this, ctx, _p) => { diff --git a/core/continuum-hands/src/modules/code_commands/normalize_edit_mode.rs b/core/continuum-hands/src/modules/code_commands/normalize_edit_mode.rs index 4f8eeb7ed5..f9eaf20863 100644 --- a/core/continuum-hands/src/modules/code_commands/normalize_edit_mode.rs +++ b/core/continuum-hands/src/modules/code_commands/normalize_edit_mode.rs @@ -156,6 +156,7 @@ pub struct CodeListParams { #[async_trait] impl ActionCommand for CodeList { const NAME: &'static str = "code/list"; + const EFFECT: continuum_base::tool_effect::ToolEffect = continuum_base::tool_effect::ToolEffect::Observes; const ALIASES: &'static [&'static str] = &["list_files", "list_dir", "glob", "ls"]; const NATIVE: bool = true; // core agentic working set — offered natively (auto-derived) const DESCRIPTION: &'static str = @@ -293,6 +294,7 @@ pub struct CodeExistsParams { #[async_trait] impl ActionCommand for CodeExists { const NAME: &'static str = "code/exists"; + const EFFECT: continuum_base::tool_effect::ToolEffect = continuum_base::tool_effect::ToolEffect::Observes; const DESCRIPTION: &'static str = "Check whether a path exists and its kind (file / directory / symlink) in one roundtrip."; type Params = CodeExistsParams; @@ -325,6 +327,7 @@ pub struct CodeGlobParams { #[async_trait] impl ActionCommand for CodeGlob { const NAME: &'static str = "code/glob"; + const EFFECT: continuum_base::tool_effect::ToolEffect = continuum_base::tool_effect::ToolEffect::Observes; const DESCRIPTION: &'static str = "Find files by glob pattern (e.g. `**/*.rs` matches Rust files at any depth, layout-independent). Returns matching workspace-relative paths."; type Params = CodeGlobParams; @@ -361,6 +364,7 @@ pub struct CodeTreeParams { #[async_trait] impl ActionCommand for CodeTree { const NAME: &'static str = "code/tree"; + const EFFECT: continuum_base::tool_effect::ToolEffect = continuum_base::tool_effect::ToolEffect::Observes; const ALIASES: &'static [&'static str] = &["file_tree", "directory_tree", "tree"]; const NATIVE: bool = true; // core agentic working set — offered natively (auto-derived) const DESCRIPTION: &'static str = @@ -420,6 +424,7 @@ pub struct CodeSearchParams { #[async_trait] impl ActionCommand for CodeSearch { const NAME: &'static str = "code/search"; + const EFFECT: continuum_base::tool_effect::ToolEffect = continuum_base::tool_effect::ToolEffect::Observes; const ALIASES: &'static [&'static str] = &["grep", "search_files", "ripgrep", "rg", "search"]; const NATIVE: bool = true; // core agentic working set — offered natively (auto-derived) const DESCRIPTION: &'static str = @@ -521,8 +526,9 @@ impl ActionCommand for CodeSearch { .collect() }) .unwrap_or_default(); + // Every top-level directory: the layout is the grounding, and the shared executor's + // whole-or-handle custody sizes what she is handed (no count cut here). tops.sort(); - tops.truncate(24); error = Some(format!( "No files matched glob {:?}. Workspace root is {} and all paths are \ relative to it; its top-level directories are: [{}]. Re-check the \ diff --git a/core/continuum-kernel/src/sdk_codegen/mod.rs b/core/continuum-kernel/src/sdk_codegen/mod.rs index 87f10cec49..e7c80d0db8 100644 --- a/core/continuum-kernel/src/sdk_codegen/mod.rs +++ b/core/continuum-kernel/src/sdk_codegen/mod.rs @@ -69,6 +69,9 @@ pub use command::{ }; #[cfg(feature = "ts-codegen")] pub use emit::write_typescript_sdk; +/// What a command does to the world, declared on it (`ActionCommand::EFFECT`); re-exported so +/// `action_command!`'s `effect:` clause resolves in any crate that expands it. +pub use continuum_base::tool_effect::ToolEffect; pub use events::{event_registry, EventDescriptor, EventSpec}; #[cfg(feature = "ts-codegen")] pub use events::{generate_event_api, generate_event_map}; @@ -204,6 +207,7 @@ macro_rules! action_command { access: $access:ident, $(native: $native:expr,)? $(aliases: $aliases:expr,)? + $(effect: $effect:ident,)? params: $params:ty, output: $output:ty, run($this:ident, $ctx:ident, $p:ident) => $body:block @@ -211,7 +215,7 @@ macro_rules! action_command { $(#[doc = $doc])* #[derive(::std::default::Default)] $vis struct $cmd; - $crate::action_command!(@impl $cmd, $name, $access, [$($doc)*], [$($native)?], [$($aliases)?], $params, $output, $this, $ctx, $p, $body); + $crate::action_command!(@impl $cmd, $name, $access, [$($doc)*], [$($native)?], [$($aliases)?], [$($effect)?], $params, $output, $this, $ctx, $p, $body); $crate::register_stateless_command!($cmd); }; @@ -224,13 +228,14 @@ macro_rules! action_command { access: $access:ident, $(native: $native:expr,)? $(aliases: $aliases:expr,)? + $(effect: $effect:ident,)? params: $params:ty, output: $output:ty, run($this:ident, $ctx:ident, $p:ident) => $body:block ) => { $(#[doc = $doc])* $vis struct $cmd { $($(#[$field_meta])* pub $field: $fty),+ } - $crate::action_command!(@impl $cmd, $name, $access, [$($doc)*], [$($native)?], [$($aliases)?], $params, $output, $this, $ctx, $p, $body); + $crate::action_command!(@impl $cmd, $name, $access, [$($doc)*], [$($native)?], [$($aliases)?], [$($effect)?], $params, $output, $this, $ctx, $p, $body); // Register the DESCRIPTOR (type-only — no instance needed) so the command // appears in `command_registry()`, the persona tool surface, the ACL, and // codegen. Its RUNTIME object is constructed with deps by the owning @@ -239,7 +244,7 @@ macro_rules! action_command { }; // ── Internal: the shared `ActionCommand` impl both forms expand to. ── - (@impl $cmd:ident, $name:expr, $access:ident, [$($doc:literal)*], [$($native:expr)?], [$($aliases:expr)?], $params:ty, $output:ty, $this:ident, $ctx:ident, $p:ident, $body:block) => { + (@impl $cmd:ident, $name:expr, $access:ident, [$($doc:literal)*], [$($native:expr)?], [$($aliases:expr)?], [$($effect:ident)?], $params:ty, $output:ty, $this:ident, $ctx:ident, $p:ident, $body:block) => { #[::async_trait::async_trait] impl $crate::sdk_codegen::ActionCommand for $cmd { const NAME: &'static str = $name; @@ -255,6 +260,10 @@ macro_rules! action_command { // model reaches for, resolved inbound by tool_dialect). Absent ⇒ the trait // default (empty). Emitted only when present, so the default stands otherwise. $(const ALIASES: &'static [&'static str] = $aliases;)? + // Optional `effect: ,` clause ⟹ EFFECT (MIND-CONTEXT invariant 4: + // only a command that declares it `Observes` can have an unchanged result render as a + // repeat). Absent ⇒ the trait default, `Undeclared`, which authorizes nothing. + $(const EFFECT: $crate::sdk_codegen::ToolEffect = $crate::sdk_codegen::ToolEffect::$effect;)? type Params = $params; type Output = $output; async fn run(