@@ -62,6 +62,92 @@ describe("parseActorNotification", () => {
6262 } )
6363 } )
6464
65+ test ( "completed lifecycle but reportedStatus=failed reads as failed, never completed" , ( ) => {
66+ const text = renderActorNotification ( {
67+ actorID : "general-4" ,
68+ description : "Fix the flaky test" ,
69+ status : "completed" ,
70+ reportedStatus : "failed" ,
71+ reportedSummary : "could not reproduce" ,
72+ result : "full body" ,
73+ } )
74+ // Top line states the outcome and must never imply success.
75+ expect ( text ) . toContain ( "finished (status: failed)" )
76+ expect ( text ) . not . toContain ( "completed" )
77+ expect ( parseActorNotification ( text ) ) . toEqual ( {
78+ status : "failed" ,
79+ description : "Fix the flaky test" ,
80+ summary : "could not reproduce" ,
81+ } )
82+ } )
83+
84+ test ( "completed lifecycle but reportedStatus=blocked reads as failed" , ( ) => {
85+ const text = renderActorNotification ( {
86+ actorID : "general-5" ,
87+ description : "Wire up the API" ,
88+ status : "completed" ,
89+ reportedStatus : "blocked" ,
90+ result : "waiting on credentials" ,
91+ } )
92+ expect ( text ) . toContain ( "finished (status: blocked)" )
93+ expect ( parseActorNotification ( text ) ) . toEqual ( {
94+ status : "failed" ,
95+ description : "Wire up the API" ,
96+ summary : "waiting on credentials" ,
97+ } )
98+ } )
99+
100+ test ( "completed lifecycle with reportedStatus=unknown reads as neutral ended" , ( ) => {
101+ const text = renderActorNotification ( {
102+ actorID : "general-6" ,
103+ description : "Do the thing" ,
104+ status : "completed" ,
105+ reportedStatus : "unknown" , // sub-session ran but did not report a task outcome
106+ result : "some output" ,
107+ } )
108+ // Must NOT imply success, and must NOT emit the misleading "Status: unknown".
109+ expect ( text ) . toContain ( "ended (status not reported)" )
110+ expect ( text ) . not . toContain ( "Status: unknown" )
111+ expect ( parseActorNotification ( text ) ) . toEqual ( {
112+ status : "ended" ,
113+ description : "Do the thing" ,
114+ summary : "some output" ,
115+ } )
116+ } )
117+
118+ test ( "completed lifecycle with no reportedStatus at all reads as a plain completion" , ( ) => {
119+ const text = renderActorNotification ( {
120+ actorID : "general-8" ,
121+ description : "Plain job" ,
122+ status : "completed" ,
123+ result : "done" ,
124+ } )
125+ expect ( text ) . toContain ( "completed" )
126+ expect ( text ) . not . toContain ( "Status:" )
127+ expect ( parseActorNotification ( text ) ) . toEqual ( {
128+ status : "completed" ,
129+ description : "Plain job" ,
130+ summary : "done" ,
131+ } )
132+ } )
133+
134+ test ( "completed lifecycle with reportedStatus=partial still reads as completed" , ( ) => {
135+ const text = renderActorNotification ( {
136+ actorID : "general-7" ,
137+ description : "Partial job" ,
138+ status : "completed" ,
139+ reportedStatus : "partial" ,
140+ reportedSummary : "did half" ,
141+ result : "body" ,
142+ } )
143+ expect ( text ) . toContain ( "completed" )
144+ expect ( parseActorNotification ( text ) ) . toEqual ( {
145+ status : "completed" ,
146+ description : "Partial job" ,
147+ summary : "did half" ,
148+ } )
149+ } )
150+
65151 test ( "parses a cancelled notification (no summary)" , ( ) => {
66152 const text = renderActorNotification ( {
67153 actorID : "peer-3" ,
@@ -76,7 +162,7 @@ describe("parseActorNotification", () => {
76162
77163 test ( "parses a stalled notification (watchdog variant)" , ( ) => {
78164 const text =
79- '<actor-notification>\nBackground actor "Wedged agent" (actor_id: general-7) stalled.\nSummary: no output for 10m\n</actor-notification>'
165+ '<actor-notification>\nBackground sub-session "Wedged agent" (actor_id: general-7) stalled.\nSummary: no output for 10m\n</actor-notification>'
80166 expect ( parseActorNotification ( text ) ) . toEqual ( {
81167 status : "stalled" ,
82168 description : "Wedged agent" ,
@@ -93,4 +179,14 @@ describe("parseActorNotification", () => {
93179 test ( "returns null when the wrapper is present but the header is malformed" , ( ) => {
94180 expect ( parseActorNotification ( "<actor-notification>\ngarbage\n</actor-notification>" ) ) . toBeNull ( )
95181 } )
182+
183+ test ( "backward compat: parses legacy 'Background actor' format as a card" , ( ) => {
184+ const text =
185+ '<actor-notification>\nBackground actor "Legacy task" (actor_id: explore-1) completed.\nResult: done\n</actor-notification>'
186+ expect ( parseActorNotification ( text ) ) . toEqual ( {
187+ status : "completed" ,
188+ description : "Legacy task" ,
189+ summary : "done" ,
190+ } )
191+ } )
96192} )
0 commit comments