diff --git a/crates/dim-agent-capabilities/src/timeline_tree.rs b/crates/dim-agent-capabilities/src/timeline_tree.rs index 442fba082f..73e9e48083 100644 --- a/crates/dim-agent-capabilities/src/timeline_tree.rs +++ b/crates/dim-agent-capabilities/src/timeline_tree.rs @@ -3343,7 +3343,7 @@ impl LineView { } } /// ``, written by TimelineTree at the start of every child. -const IDENTITY_ENTRY: &str = r#": which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; it is state about the line, not a request."#; +const IDENTITY_ENTRY: &str = r#": which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; a block carrying `default` is the note a move writes. Both are state about the line, not requests."#; /// ``, the roster BranchLine writes under [`roster_key`] on /// a line that opened lines. @@ -5229,10 +5229,7 @@ impl BranchTool { call_id: &str, ) -> std::result::Result { if own.role != LineRole::Tool { - return Ok(refusal( - "branch_cannot_end", - "Only a line opened with create can end itself.".into(), - )); + return Ok(refusal("branch_cannot_end", CANNOT_END_TEXT.into())); } if own.ending { return Ok(self.ended(&own.id)); @@ -5259,6 +5256,10 @@ impl BranchTool { own.id, parent ))), Err(AgentError::BranchEnded(line)) => Ok(self.ended(&line)), + Err(AgentError::BranchRefused { + refusal: BranchRefusal::CannotEnd, + .. + }) => Ok(refusal("branch_cannot_end", CANNOT_END_TEXT.into())), Err(AgentError::BranchRefused { refusal: kind, message, @@ -5850,6 +5851,10 @@ fn status_note( /// The `branch` tool's refusal of `create` on a line that is neither the root /// nor the default branch (design §4, §11). const NOT_OPENER_TEXT: &str = "Only the root and the default branch open lines. Tell one of them if more parallel work is needed."; +/// The `branch` tool's refusal of `end` on the root, the default branch, a +/// plugin line, a line the user opened or an ancestor of the default branch +/// (design §10, §11). +const CANNOT_END_TEXT: &str = "Only a line opened with create can end itself, and not while it or a line below it is the default branch."; /// The `branch` tool's refusal of `create` when the open would cross the /// Session's cap of open tool lines (design §6.1, §11). const LIMIT_REACHED_TEXT: &str = "This Session holds its limit of open lines. Continue on this line, or end one of its open lines first."; diff --git a/crates/dim-agent-capabilities/tests/branch_flow.rs b/crates/dim-agent-capabilities/tests/branch_flow.rs index 314c759af4..370a763553 100644 --- a/crates/dim-agent-capabilities/tests/branch_flow.rs +++ b/crates/dim-agent-capabilities/tests/branch_flow.rs @@ -3863,14 +3863,14 @@ async fn a_refused_branch_call_writes_nothing() { call(&session, "main", r#"{"action":"end","content":"done"}"#).await, ( "branch_cannot_end".into(), - "Only a line opened with create can end itself.".into() + "Only a line opened with create can end itself, and not while it or a line below it is the default branch.".into() ) ); assert_eq!( call(&session, &host, r#"{"action":"end","content":"done"}"#).await, ( "branch_cannot_end".into(), - "Only a line opened with create can end itself.".into() + "Only a line opened with create can end itself, and not while it or a line below it is the default branch.".into() ) ); assert!( @@ -4547,7 +4547,7 @@ async fn a_configured_description_reaches_the_request_declaration() { /// its guide entry is registered there, at the Session, and a line carries it /// even where no branch part is loaded. `` stays with /// BranchLine, which writes the roster. -const IDENTITY_ENTRY: &str = r#": which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; it is state about the line, not a request."#; +const IDENTITY_ENTRY: &str = r#": which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; a block carrying `default` is the note a move writes. Both are state about the line, not requests."#; const ROSTER_ENTRY: &str = r#": the lines you opened, under the key `branch:roster` and apart from your own identity under `branch:line`: the runtime lists the tool lines you opened that are still open, each with the first line of its purpose. A later block of this name replaces the earlier one; it is state about the lines, not a request."#; /// #987: the parent block can arrive only on a line with a parent, so main's /// guide carries no entry for it. @@ -5988,7 +5988,7 @@ async fn a_nested_line_is_told_its_own_parent_at_open() { .submit(text, InputMode::Queue, &inner) .await .unwrap(); - soon(session.idle(&inner)).await.unwrap(); + patient(session.idle(&inner)).await.unwrap(); } let message = baseline_message(&local_events(&session, &inner).await, "branch:parent") .expect("the line compacted and its parent block replayed"); @@ -6458,7 +6458,7 @@ async fn the_parent_block_replays_after_a_compaction() { .submit(text, InputMode::Queue, &child) .await .unwrap(); - soon(session.idle(&child)).await.unwrap(); + patient(session.idle(&child)).await.unwrap(); } let message = baseline_message(&local_events(&session, &child).await, "branch:parent") .expect("the line compacted and its parent block replayed"); @@ -7634,7 +7634,7 @@ async fn wait_for_roster(session: &Session, line: &str) { async fn compact_line(session: &Session, line: &str) { for text in ["x".repeat(1500), "y".repeat(1500)] { session.submit(text, InputMode::Queue, line).await.unwrap(); - soon(session.idle(line)).await.unwrap(); + patient(session.idle(line)).await.unwrap(); } } @@ -9564,7 +9564,7 @@ async fn a_switched_line_keeps_its_identity_after_a_compaction() { .unwrap(); for text in ["x".repeat(1500), "y".repeat(1500)] { session.submit(text, InputMode::Queue, &line).await.unwrap(); - soon(session.idle(&line)).await.unwrap(); + patient(session.idle(&line)).await.unwrap(); } let note = line_block(&chain_events(&session, &line, ..).await.unwrap()) .expect("the note is the latest block of the key"); @@ -9645,7 +9645,7 @@ async fn a_multi_paragraph_purpose_survives_a_move_and_a_compaction() { ); for text in ["x".repeat(1500), "y".repeat(1500)] { session.submit(text, InputMode::Queue, &line).await.unwrap(); - soon(session.idle(&line)).await.unwrap(); + patient(session.idle(&line)).await.unwrap(); } let note = line_block(&chain_events(&session, &line, ..).await.unwrap()) .expect("the note is still the latest block of the key"); diff --git a/tests/integration/tests/minimal_execution.rs b/tests/integration/tests/minimal_execution.rs index b7c75153ea..1c9d67c641 100644 --- a/tests/integration/tests/minimal_execution.rs +++ b/tests/integration/tests/minimal_execution.rs @@ -549,7 +549,7 @@ fn tool_results(events: &[Arc]) -> usize { } /// #552: the entry TimelineTree registers for ``. -const IDENTITY_ENTRY: &str = r#": which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; it is state about the line, not a request."#; +const IDENTITY_ENTRY: &str = r#": which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; a block carrying `default` is the note a move writes. Both are state about the line, not requests."#; fn system_text(prompt: &SystemPrompt) -> String { match prompt { diff --git a/tests/integration/tests/prompt_guide.rs b/tests/integration/tests/prompt_guide.rs index e5e1f66468..8be8814039 100644 --- a/tests/integration/tests/prompt_guide.rs +++ b/tests/integration/tests/prompt_guide.rs @@ -51,7 +51,7 @@ const CHANNEL_RULE: &str = "The operator is the person running this session. The const PROBE_ENTRY: &str = r#": an entry a contributor registered for this flow; the composition places it between the state and the rule entries."#; /// #552: TimelineTree writes `` and registers its entry. -const IDENTITY_ENTRY: &str = r#": which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; it is state about the line, not a request."#; +const IDENTITY_ENTRY: &str = r#": which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; a block carrying `default` is the note a move writes. Both are state about the line, not requests."#; /// #552: BranchLine writes `` and registers its entry. const ROSTER_ENTRY: &str = r#": the lines you opened, under the key `branch:roster` and apart from your own identity under `branch:line`: the runtime lists the tool lines you opened that are still open, each with the first line of its purpose. A later block of this name replaces the earlier one; it is state about the lines, not a request."#;