@@ -147,3 +147,70 @@ def review(value, turn_id=turn, *, expected=0):
147147 refused = review (next_packet , next_turn , expected = 1 )
148148 assert "declared work" in refused ["error" ] and not refused .get ("appended" ), refused
149149 assert index .read_bytes () == before
150+
151+
152+ @pytest .mark .parametrize ("provider" , ["file" , "sqlite" ])
153+ def test_wide_result_page_replays_every_linked_outcome_at_writeback (tmp_path , monkeypatch , provider ):
154+ isolate_sqlite_runtime (tmp_path , monkeypatch )
155+ monkeypatch .setenv ("LOOPX_USAGE_PING" , "0" )
156+ monkeypatch .setenv ("PYTHONPATH" , str (fixture .REPO_ROOT ))
157+ project , runtime , registry = fixture ._write_fixture (tmp_path )
158+ monkeypatch .chdir (project )
159+ fixture ._initialize_fixture_authority (project , runtime , provider = provider )
160+
161+ def cli (* args , expected = 0 ):
162+ code , result = fixture ._run_cli (registry , runtime , * args , cwd = project )
163+ assert code == expected , result
164+ return result
165+
166+ identity = ("--goal-id" , fixture .GOAL_ID , "--agent-id" , fixture .AGENT_ID )
167+ cli ("configure-goal" , "--goal-id" , fixture .GOAL_ID , "--explore-mode" , "planning" ,
168+ "--execution-replan-after-turns" , "1" , "--execution-stride-strategy" , "evidence_conditioned_v1" , "--execute" )
169+ training = project / "training.json"
170+ training .write_text (json .dumps ([{"x" : 2 , "y" : 3 , "observed" : 6 }]))
171+ request = {"project" : str (project ), "registry" : str (registry ), "runtime" : str (runtime ),
172+ "goal_id" : fixture .GOAL_ID , "agent_id" : fixture .AGENT_ID , "todo_id" : fixture .TODO_ID ,
173+ "objective" : "Use the exact scoped measurement that informs the next experiment." ,
174+ "training" : str (training ), "budget" : 25 , "seed" : 17 }
175+ actor .probe (request , "retained" )
176+ for index in range (4 ):
177+ cli ("explore" , "finding" , * identity , "--finding-id" , f"wide-result-{ index } " ,
178+ "--node" , "comparison-retained" , "--title" , f"Observed input scope { index } " ,
179+ "--summary" , f"Only the recorded input scope { index } ; other inputs remain unknown." ,
180+ "--status" , "confirmed" , "--tag" , "writeback-result" , "--evidence-ref" , f"measured:scope-{ index } " )
181+ turn = "wide-page-review"
182+ cli ("quota" , "should-run" , * identity , "--codex-app" , "--scan-path" , str (project ), "--turn-instance-id" , turn )
183+ guard = cli ("quota" , "should-run" , * identity , "--codex-app" , "--scan-path" , str (project ),
184+ "--turn-instance-id" , turn , "--todo-id" , fixture .TODO_ID )
185+ control = guard ["replan_action_packet" ]["stride_control" ]
186+ page = cli ("explore" , "turn-context" , * identity , "--result-limit" , "20" )
187+ [card ] = [row for row in page ["harness" ]["comparison_candidates" ] if row ["todo_id" ] == fixture .TODO_ID ]
188+ assert len (page ["graph" ]["writeback_results" ]) == len (card ["outcomes" ]) == 5
189+ # Choose the last displayed outcome; the default three-row view omits it.
190+ selected = {"todo_id" : fixture .TODO_ID , ** card ["outcomes" ][- 1 ]}
191+ assert selected ["finding_id" ] not in {row ["finding_id" ] for row in
192+ control ["explore_basis" ]["comparison_candidates" ][0 ]["outcomes" ]}
193+ decision = deepcopy (control ["minimal_example" ])
194+ decision ["explore_review" ] = {"revision" : control ["explore_basis" ]["revision" ],
195+ "disposition" : "used" , "considered_refs" : [selected ["finding_id" ]],
196+ "selected_candidate" : selected , "reason" : "This exact measured scope informs the next experiment." ,
197+ "result_pages" : [{k : page ["graph" ]["result_page" ][k ] for k in ("revision" , "offset" , "limit" )}]}
198+ packet = actor .vision (request , selected ["finding_id" ], outcome = "replan" )
199+ packet .update (stride_decision = decision , todo_delta = ["retain:" + fixture .TODO_ID ])
200+ path = project / "wide-review.json"
201+ command = ("refresh-state" , * identity , "--todo-id" , fixture .TODO_ID , "--turn-instance-id" , turn ,
202+ "--classification" , "scoped_page_review" , "--delivery-batch-scale" , "implementation" ,
203+ "--delivery-outcome" , "outcome_progress" , "--agent-vision-json" , str (path ),
204+ "--no-global-sync" , "--suppress-external-sinks" )
205+ bad = deepcopy (packet )
206+ bad ["stride_decision" ]["explore_review" ]["selected_candidate" ]["source_sha256" ] = "f" * 64
207+ path .write_text (json .dumps (bad ))
208+ index = runtime / "goals" / fixture .GOAL_ID / "runs/index.jsonl"
209+ before = index .read_bytes ()
210+ refused = cli (* command , expected = 1 )
211+ assert "exact scoped result" in refused ["error" ] and index .read_bytes () == before
212+ path .write_text (json .dumps (packet ))
213+ accepted = cli (* command )
214+ persisted = json .loads (Path (accepted ["json_path" ]).read_text ())
215+ assert persisted ["agent_vision" ]["stride_decision" ]["explore_review" ]["selected_candidate" ] == selected
216+ assert accepted ["autonomous_replan_ack" ]["semantic_delta" ]["accepted" ]
0 commit comments