Skip to content

Commit 274a80d

Browse files
committed
Disable shared turn-end weak-point digest followups
1 parent 629c56b commit 274a80d

2 files changed

Lines changed: 43 additions & 33 deletions

File tree

‎crates/jcode-todo-policy/src/followup.rs‎

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//!
33
//! This is the client-side state machine that decides, after a turn ends, what
44
//! (if anything) to send next: the incomplete-todo poke, the one-shot
5-
//! long-session review, the deferred gate digest, the ownership gate, the
6-
//! completion-confidence and confidence-spike checks, and the final-response
5+
//! long-session review, the ownership gate, the completion-confidence and
6+
//! confidence-spike checks, and the final-response
77
//! handoff. It is a faithful port of the TUI's `schedule_auto_poke_followup`
88
//! so every client (TUI, Desktop, SDK users) runs the same policy.
99
//!
@@ -14,10 +14,10 @@
1414
use crate::{
1515
ConfidenceState, GateObservation, TODO_FINAL_RESPONSE_CONTINUATION_MESSAGE,
1616
TODO_LONG_SESSION_REVIEW_MESSAGE, TodoGoal, TodoItem, TodoPlan, build_auto_poke_message,
17-
build_gate_digest, build_todo_completion_continuation_message,
18-
build_todo_confidence_spike_continuation_message, build_todo_ownership_continuation_message,
19-
completed_groups_have_sufficient_delivery, completion_confidence_passes, spike_completed_todos,
20-
todo_status_is_cancelled, todo_status_is_completed,
17+
build_todo_completion_continuation_message, build_todo_confidence_spike_continuation_message,
18+
build_todo_ownership_continuation_message, completed_groups_have_sufficient_delivery,
19+
completion_confidence_passes, spike_completed_todos, todo_status_is_cancelled,
20+
todo_status_is_completed,
2121
};
2222
use serde::{Deserialize, Serialize};
2323

@@ -113,7 +113,6 @@ pub struct FollowUpPolicy {
113113
default_on: bool,
114114
final_response_requested: bool,
115115
final_response_fingerprint: Option<String>,
116-
digest_delivered: bool,
117116
gate_attempts: u8,
118117
spike_challenged: bool,
119118
last_ownership_fingerprint: Option<String>,
@@ -180,7 +179,6 @@ impl FollowUpPolicy {
180179
}
181180
self.final_response_fingerprint = None;
182181
self.final_response_requested = false;
183-
self.digest_delivered = false;
184182
self.gate_attempts = 0;
185183
self.spike_challenged = false;
186184
self.last_ownership_fingerprint = None;
@@ -213,22 +211,12 @@ impl FollowUpPolicy {
213211
return Decision::default();
214212
}
215213

216-
// Deferred quality checks land once, at the end of the work.
217-
let mut effects = TodoEffects::default();
218-
if !self.digest_delivered && !snapshot.gate_observations.is_empty() {
219-
effects.clear_gate_observations = true;
220-
if let Some(digest) =
221-
build_gate_digest(&snapshot.gate_observations, &snapshot.plan, goals)
222-
{
223-
self.digest_delivered = true;
224-
return Decision::send(
225-
FollowUpKind::GateDigest,
226-
digest,
227-
"🔍 We asked the agent to double-check this turn's weak points.",
228-
)
229-
.with_effects(effects);
230-
}
231-
}
214+
// Weak-point observations remain diagnostic data, not a reason to
215+
// inject another conversation turn before the agent can finish.
216+
let effects = TodoEffects {
217+
clear_gate_observations: !snapshot.gate_observations.is_empty(),
218+
..TodoEffects::default()
219+
};
232220

233221
let ownership_needs_followup = !completed_groups_have_sufficient_delivery(todos, goals);
234222
let gate_budget_left = self.gate_attempts < MAX_GATE_ATTEMPTS;
@@ -278,7 +266,6 @@ impl FollowUpPolicy {
278266
self.armed = false;
279267
self.spike_challenged = false;
280268
self.gate_attempts = 0;
281-
self.digest_delivered = false;
282269
return Decision {
283270
notice: Some(
284271
"⚠️ We nudged the agent several times but its validation still isn't holding up. We stopped poking; review the remaining todos yourself."
@@ -291,7 +278,6 @@ impl FollowUpPolicy {
291278

292279
// Cycle finished cleanly.
293280
self.armed = self.default_on;
294-
self.digest_delivered = false;
295281
self.gate_attempts = 0;
296282
if !self.final_response_requested {
297283
self.final_response_requested = true;

‎crates/jcode-todo-policy/src/followup_tests.rs‎

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn no_todos_stays_armed_and_quiet() {
7676
}
7777

7878
#[test]
79-
fn completed_work_runs_digest_then_validation_then_final_response_once() {
79+
fn completed_work_skips_digest_and_runs_validation_then_final_response_once() {
8080
let mut policy = FollowUpPolicy::new(true);
8181
let mut state = TodoSnapshot {
8282
todos: vec![done("ship", ConfidenceState::Plausible)],
@@ -92,13 +92,9 @@ fn completed_work_runs_digest_then_validation_then_final_response_once() {
9292
..Default::default()
9393
};
9494

95-
let digest = policy.decide(&state);
96-
assert_eq!(kind(&digest), Some(FollowUpKind::GateDigest));
97-
assert!(digest.effects.clear_gate_observations);
98-
assert!(is_auto_poke_message(&digest.follow_up.unwrap().message));
99-
state.gate_observations.clear();
100-
10195
let validation = policy.decide(&state);
96+
assert!(validation.effects.clear_gate_observations);
97+
state.gate_observations.clear();
10298
assert_eq!(kind(&validation), Some(FollowUpKind::CompletionValidation));
10399
assert!(validation.follow_up.unwrap().message.contains("\"ship\""));
104100

@@ -122,6 +118,34 @@ fn completed_work_runs_digest_then_validation_then_final_response_once() {
122118
);
123119
}
124120

121+
#[test]
122+
fn weak_points_do_not_delay_completed_work() {
123+
let mut policy = FollowUpPolicy::new(true);
124+
let state = TodoSnapshot {
125+
todos: vec![done("ship", ConfidenceState::Verified)],
126+
gate_observations: [
127+
GateObservationKind::IntentUnderstanding,
128+
GateObservationKind::ClosedFeedbackLoop,
129+
GateObservationKind::FeedbackLoopRelevance,
130+
GateObservationKind::FeedbackLoopCoverage,
131+
GateObservationKind::FeedbackLoopTraceability,
132+
]
133+
.into_iter()
134+
.map(|kind| GateObservation {
135+
kind,
136+
group: None,
137+
state: None,
138+
})
139+
.collect(),
140+
..Default::default()
141+
};
142+
let decision = policy.decide(&state);
143+
assert_eq!(kind(&decision), Some(FollowUpKind::FinalResponse));
144+
assert!(decision.effects.clear_gate_observations);
145+
// Even an unacknowledged observation log cannot restart the cycle.
146+
assert_eq!(policy.decide(&state), Decision::default());
147+
}
148+
125149
#[test]
126150
fn empty_digest_still_consumes_the_log() {
127151
let mut policy = FollowUpPolicy::new(true);

0 commit comments

Comments
 (0)