Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/continuum-cognition/src/cognition/context_streams/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
1 change: 1 addition & 0 deletions core/continuum-hands/src/commands/code/git/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ crate::action_command! {
access: AiSafe,
native: true,
aliases: &["git_diff"],
effect: Observes,
params: GitDiffParams,
output: GitDiffResult,
run(this, ctx, p) => {
Expand Down
1 change: 1 addition & 0 deletions core/continuum-hands/src/commands/code/git/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions core/continuum-hands/src/commands/code/git/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ crate::action_command! {
access: AiSafe,
native: true,
aliases: &["git_status"],
effect: Observes,
params: GitStatusParams,
output: GitStatusInfo,
run(this, ctx, _p) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 \
Expand Down
15 changes: 12 additions & 3 deletions core/continuum-kernel/src/sdk_codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -204,14 +207,15 @@ 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])*
#[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);
};

Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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: <ToolEffect variant>,` 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(
Expand Down
Loading