@@ -46,6 +46,7 @@ describe("SupervisorRepo", () => {
4646 id : "sup-1" ,
4747 sessionId : "sess-1" ,
4848 workspaceId : "ws-1" ,
49+ targetId : "target-1" ,
4950 state : "idle" ,
5051 objective : "Finish supervisor persistence" ,
5152 evaluatorProviderId : "codex" ,
@@ -64,6 +65,7 @@ describe("SupervisorRepo", () => {
6465 id : "sup-1" ,
6566 sessionId : "sess-1" ,
6667 workspaceId : "ws-1" ,
68+ targetId : "target-initial" ,
6769 state : "stopped" ,
6870 objective : "Stop when objective is complete" ,
6971 evaluatorProviderId : "codex" ,
@@ -87,6 +89,31 @@ describe("SupervisorRepo", () => {
8789 } ) ;
8890 } ) ;
8991
92+ it ( "persists targetId on create and update" , ( ) => {
93+ supervisorRepo . create ( {
94+ id : "sup-1" ,
95+ sessionId : "sess-1" ,
96+ workspaceId : "ws-1" ,
97+ targetId : "target-alpha" ,
98+ state : "idle" ,
99+ objective : "Track target scope" ,
100+ evaluatorProviderId : "codex" ,
101+ createdAt : 10 ,
102+ updatedAt : 10 ,
103+ } ) ;
104+
105+ const created = supervisorRepo . findById ( "sup-1" ) ;
106+ expect ( created ?. targetId ) . toBe ( "target-alpha" ) ;
107+
108+ const updated = supervisorRepo . update ( "sup-1" , {
109+ targetId : "target-beta" ,
110+ updatedAt : 11 ,
111+ } ) ;
112+
113+ expect ( updated . targetId ) . toBe ( "target-beta" ) ;
114+ expect ( supervisorRepo . findById ( "sup-1" ) ?. targetId ) . toBe ( "target-beta" ) ;
115+ } ) ;
116+
90117 it ( "rejects a supervisor whose workspace does not match its session workspace" , ( ) => {
91118 db . prepare (
92119 "INSERT INTO workspaces (id, path, target_runtime, opened_at, last_active_at, ui_state) VALUES (?, ?, ?, ?, ?, ?)"
@@ -103,6 +130,7 @@ describe("SupervisorRepo", () => {
103130 id : "sup-bad" ,
104131 sessionId : "sess-2" ,
105132 workspaceId : "ws-1" ,
133+ targetId : "target-bad" ,
106134 state : "idle" ,
107135 objective : "This insert must fail" ,
108136 evaluatorProviderId : "claude" ,
@@ -124,6 +152,7 @@ describe("SupervisorRepo", () => {
124152 id : "sup-1" ,
125153 sessionId : "sess-1" ,
126154 workspaceId : "ws-1" ,
155+ targetId : "target-1" ,
127156 state : "idle" ,
128157 objective : "Enforce supervisor/session integrity" ,
129158 evaluatorProviderId : "claude" ,
@@ -152,6 +181,7 @@ describe("SupervisorRepo", () => {
152181 id : "sup-1" ,
153182 sessionId : "sess-1" ,
154183 workspaceId : "ws-1" ,
184+ targetId : "target-1" ,
155185 state : "idle" ,
156186 objective : "Keep nullable fields intact" ,
157187 evaluatorProviderId : "claude" ,
@@ -178,6 +208,7 @@ describe("SupervisorRepo", () => {
178208 id : "sup-1" ,
179209 sessionId : "sess-1" ,
180210 workspaceId : "ws-1" ,
211+ targetId : "target-1" ,
181212 state : "idle" ,
182213 objective : "Clear nullable fields" ,
183214 evaluatorProviderId : "claude" ,
@@ -205,6 +236,7 @@ describe("SupervisorRepo", () => {
205236 id : "sup-1" ,
206237 sessionId : "sess-1" ,
207238 workspaceId : "ws-1" ,
239+ targetId : "target-1" ,
208240 state : "idle" ,
209241 objective : "Clear execution policy fields" ,
210242 evaluatorProviderId : "claude" ,
@@ -236,6 +268,7 @@ describe("SupervisorRepo", () => {
236268 id : "sup-1" ,
237269 sessionId : "sess-1" ,
238270 workspaceId : "ws-1" ,
271+ targetId : "target-1" ,
239272 state : "idle" ,
240273 objective : "Keep cycle fields intact" ,
241274 evaluatorProviderId : "claude" ,
@@ -276,6 +309,7 @@ describe("SupervisorRepo", () => {
276309 id : "sup-1" ,
277310 sessionId : "sess-1" ,
278311 workspaceId : "ws-1" ,
312+ targetId : "target-1" ,
279313 state : "idle" ,
280314 objective : "Clear cycle fields" ,
281315 evaluatorProviderId : "claude" ,
@@ -336,6 +370,7 @@ describe("SupervisorRepo", () => {
336370 id : "sup-1" ,
337371 sessionId : "sess-1" ,
338372 workspaceId : "ws-1" ,
373+ targetId : "target-1" ,
339374 state : "idle" ,
340375 objective : "Keep the newest 100 cycles" ,
341376 evaluatorProviderId : "claude" ,
@@ -371,6 +406,7 @@ describe("SupervisorRepo", () => {
371406 id : "sup-1" ,
372407 sessionId : "sess-1" ,
373408 workspaceId : "ws-1" ,
409+ targetId : "target-1" ,
374410 state : "idle" ,
375411 objective : "Allow scheduled cancelled cycle" ,
376412 evaluatorProviderId : "claude" ,
@@ -399,6 +435,7 @@ describe("SupervisorRepo", () => {
399435 id : "sup-1" ,
400436 sessionId : "sess-1" ,
401437 workspaceId : "ws-1" ,
438+ targetId : "target-1" ,
402439 state : "idle" ,
403440 objective : "Track attempts" ,
404441 evaluatorProviderId : "claude" ,
@@ -456,6 +493,7 @@ describe("SupervisorRepo", () => {
456493 id : "sup-1" ,
457494 sessionId : "sess-1" ,
458495 workspaceId : "ws-1" ,
496+ targetId : "target-1" ,
459497 state : "idle" ,
460498 objective : "Update attempts" ,
461499 evaluatorProviderId : "claude" ,
0 commit comments