@@ -89,7 +89,9 @@ fn todo_completion_report_is_full_nonblocking_and_independent_of_poke() {
8989 assert ! ( !app. refresh_completed_todo_report( true ) ) ;
9090 assert_eq ! ( completion_report_messages( & app) . len( ) , 1 ) ;
9191
92- // The actual renderer keeps the entire report at narrow terminal widths.
92+ // Descriptive assessments alone never fabricate gate findings.
93+ assert_eq ! ( snapshot[ "observations" ] , serde_json:: json!( [ ] ) ) ;
94+ // The actual renderer retains the full pinned card at narrow widths.
9395 for width in [ 20 , 40 , 80 ] {
9496 let lines = crate :: tui:: ui:: render_system_message (
9597 & report,
@@ -102,23 +104,28 @@ fn todo_completion_report_is_full_nonblocking_and_independent_of_poke() {
102104 . collect :: < Vec < _ > > ( )
103105 . join ( "\n " ) ;
104106 let normalized = plain. split_whitespace ( ) . collect :: < Vec < _ > > ( ) . join ( " " ) ;
105- assert ! ( normalized. contains( "Report task 11" ) , "{plain}" ) ;
107+ if width == 80 {
108+ assert ! ( normalized. contains( "Report task 11" ) , "{plain}" ) ;
109+ }
106110 // Removing wrap whitespace lets us assert every detail even when
107111 // an individual word has to be split at a narrow terminal width.
108112 let unwrapped: String = plain. chars ( ) . filter ( |ch| !ch. is_whitespace ( ) ) . collect ( ) ;
109- for expected in [
110- "Evidence for task 11" ,
113+ for unexpected in [
111114 "FINAL_EVIDENCE_MARKER" ,
112- "acceptance_blocked" ,
113- "acceptance path blocked" ,
114115 "Earlier weak states" ,
115116 "feedback_loop_relevance was indirect" ,
116117 "intent understanding was uncertain" ,
117- "External service unavailable" ,
118118 "Current weaknesses, limitations, or missing assessments" ,
119+ "Disabled turn-end gate findings" ,
119120 ] {
120- let expected: String = expected. chars ( ) . filter ( |ch| !ch. is_whitespace ( ) ) . collect ( ) ;
121- assert ! ( unwrapped. contains( & expected) , "missing {expected}: {plain}" ) ;
121+ let unexpected: String = unexpected
122+ . chars ( )
123+ . filter ( |ch| !ch. is_whitespace ( ) )
124+ . collect ( ) ;
125+ assert ! (
126+ !unwrapped. contains( & unexpected) ,
127+ "unexpected {unexpected}: {plain}"
128+ ) ;
122129 }
123130 for line in & lines {
124131 assert ! ( line. width( ) <= width as usize , "width {width}: {line}" ) ;
@@ -144,13 +151,87 @@ fn todo_completion_report_refreshes_evidence_and_preserves_previous_cycles() {
144151 . content
145152 . contains( "Additional acceptance evidence" )
146153 ) ;
154+ let observations = vec ! [ crate :: todo:: GateObservation {
155+ kind: crate :: todo:: GateObservationKind :: IntentUnderstanding ,
156+ group: None ,
157+ state: Some ( "uncertain" . into( ) ) ,
158+ } ] ;
159+ crate :: todo:: save_gate_observations ( & session_id, & observations) . unwrap ( ) ;
160+ crate :: todo:: save_plan (
161+ & session_id,
162+ & crate :: todo:: TodoPlan {
163+ understands_user_intent : Some ( crate :: todo:: IntentUnderstanding :: Clear ) ,
164+ ..Default :: default ( )
165+ } ,
166+ )
167+ . unwrap ( ) ;
168+ assert ! ( app. refresh_completed_todo_report( true ) ) ;
169+ assert_eq ! ( completion_report_messages( & app) . len( ) , 1 ) ;
170+ assert ! ( !app. refresh_completed_todo_report( true ) ) ;
171+ // Observation-only late writes must invalidate the fingerprint, and
172+ // repeated observations must retain the digest's count and wording.
173+ crate :: todo:: save_gate_observations (
174+ & session_id,
175+ & [ observations[ 0 ] . clone ( ) , observations[ 0 ] . clone ( ) ] ,
176+ )
177+ . unwrap ( ) ;
178+ assert ! ( app. refresh_completed_todo_report( true ) ) ;
179+ assert_eq ! ( completion_report_messages( & app) . len( ) , 1 ) ;
147180 let first_report = completion_report_messages ( & app) [ 0 ] . clone ( ) ;
148181 let first_render = crate :: tui:: ui:: render_system_message (
149182 & first_report,
150183 40 ,
151184 crate :: config:: DiffDisplayMode :: Off ,
152185 ) ;
153186
187+ let plain = first_render
188+ . iter ( )
189+ . map ( |line| line. to_string ( ) )
190+ . collect :: < Vec < _ > > ( )
191+ . join ( " " ) ;
192+ let normalized = plain. split_whitespace ( ) . collect :: < Vec < _ > > ( ) . join ( " " ) ;
193+ assert ! ( normalized. contains( "Disabled turn-end gate findings" ) ) ;
194+ assert ! ( normalized. contains( "started this work without understanding" ) ) ;
195+ assert ! ( normalized. contains( "flagged 2 times this turn" ) ) ;
196+ assert ! ( !plain. contains( "[auto]" ) ) ;
197+ assert ! ( !normalized. contains( "Do not reply or wait for the user" ) ) ;
198+ let snapshot: serde_json:: Value = serde_json:: from_str ( & first_report. content ) . unwrap ( ) ;
199+ assert_eq ! ( snapshot[ "observations" ] . as_array( ) . unwrap( ) . len( ) , 2 ) ;
200+ crate :: todo:: clear_gate_observations ( & session_id) . unwrap ( ) ;
201+ assert ! ( !app. refresh_completed_todo_report( true ) ) ;
202+ assert_eq ! (
203+ completion_report_messages( & app) [ 0 ] . content,
204+ first_report. content
205+ ) ;
206+ crate :: todo:: save_plan (
207+ & session_id,
208+ & crate :: todo:: TodoPlan {
209+ understands_user_intent : Some ( crate :: todo:: IntentUnderstanding :: Uncertain ) ,
210+ ..Default :: default ( )
211+ } ,
212+ )
213+ . unwrap ( ) ;
214+ assert ! ( app. refresh_completed_todo_report( true ) ) ;
215+ let updated = completion_report_messages ( & app) [ 0 ] . clone ( ) ;
216+ let text = crate :: tui:: ui:: render_system_message (
217+ & updated,
218+ 200 ,
219+ crate :: config:: DiffDisplayMode :: Off ,
220+ )
221+ . iter ( )
222+ . map ( |line| line. to_string ( ) )
223+ . collect :: < Vec < _ > > ( )
224+ . join ( " " ) ;
225+ let text = text. split_whitespace ( ) . collect :: < Vec < _ > > ( ) . join ( " " ) ;
226+ assert ! ( text. contains( "never became solid" ) ) ;
227+ assert ! ( text. contains( "flagged 2 times this turn" ) ) ;
228+ // This updated snapshot is the immutable record for the earlier cycle.
229+ let first_render = crate :: tui:: ui:: render_system_message (
230+ & updated,
231+ 40 ,
232+ crate :: config:: DiffDisplayMode :: Off ,
233+ ) ;
234+
154235 todos[ 0 ] . status = "in_progress" . into ( ) ;
155236 crate :: todo:: save_todos ( & session_id, & todos) . unwrap ( ) ;
156237 assert ! ( !app. refresh_completed_todo_report( true ) ) ;
@@ -162,6 +243,7 @@ fn todo_completion_report_refreshes_evidence_and_preserves_previous_cycles() {
162243 assert_eq ! ( reports. len( ) , 2 ) ;
163244 assert ! ( !reports[ 0 ] . content. contains( "Second cycle task" ) ) ;
164245 assert ! ( reports[ 1 ] . content. contains( "Second cycle task" ) ) ;
246+ assert ! ( reports[ 1 ] . content. contains( "\" observations\" :[]" ) ) ;
165247 assert_eq ! (
166248 crate :: tui:: ui:: render_system_message(
167249 reports[ 0 ] ,
0 commit comments