@riddledc/riddle-proof 0.5.13 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/runtime/lib/recon.py
CHANGED
|
@@ -244,7 +244,7 @@ def score_route_candidate(path, tokens):
|
|
|
244
244
|
def choose_target_path(explicit_path, prod_url, route_hints, tokens=None, explicit_source=''):
|
|
245
245
|
explicit = (explicit_path or '').strip()
|
|
246
246
|
explicit_source = (explicit_source or '').strip()
|
|
247
|
-
is_meaningful_explicit = bool(explicit) and (explicit != '/' or explicit_source
|
|
247
|
+
is_meaningful_explicit = bool(explicit) and (explicit != '/' or bool(explicit_source))
|
|
248
248
|
if is_meaningful_explicit:
|
|
249
249
|
return explicit if explicit.startswith('/') else '/' + explicit
|
|
250
250
|
candidates = route_candidates(route_hints, prod_url)
|
|
@@ -719,7 +719,7 @@ initial_target_path = choose_target_path(s.get('server_path', ''), s.get('prod_u
|
|
|
719
719
|
selected_route = next((item for item in route_options if item.get('path') == initial_target_path), None)
|
|
720
720
|
initial_hypothesis = {
|
|
721
721
|
'target_path': initial_target_path,
|
|
722
|
-
'path_source': 'state.server_path' if (s.get('server_path') or '').strip() and (s.get('server_path') != '/' or server_path_source) else ((selected_route or {}).get('reason') or 'fallback root'),
|
|
722
|
+
'path_source': ('state.server_path:' + server_path_source) if (s.get('server_path') or '').strip() and (s.get('server_path') != '/' or server_path_source) else ((selected_route or {}).get('reason') or 'fallback root'),
|
|
723
723
|
'reference': requested_reference,
|
|
724
724
|
'mode': s.get('mode', 'server'),
|
|
725
725
|
'wait_for_selector': (s.get('wait_for_selector') or '').strip(),
|
|
@@ -207,6 +207,30 @@ class FakeRiddle:
|
|
|
207
207
|
'largeVisibleElements': [{'tag': 'button', 'text': 'Reset Game'}],
|
|
208
208
|
}),
|
|
209
209
|
}
|
|
210
|
+
if (
|
|
211
|
+
'preview.example.com' in script
|
|
212
|
+
and '/pricing' not in script
|
|
213
|
+
and '/games/tic-tac-toe' not in script
|
|
214
|
+
and '/wrong' not in script
|
|
215
|
+
):
|
|
216
|
+
return {
|
|
217
|
+
'ok': True,
|
|
218
|
+
'screenshots': [{'url': 'https://cdn.example.com/home-before.png'}],
|
|
219
|
+
'outputs': [{'name': 'before.png', 'url': 'https://cdn.example.com/home-before.png'}],
|
|
220
|
+
'console': state_console({
|
|
221
|
+
'bodyTextLength': 180,
|
|
222
|
+
'visibleTextSample': 'Riddle Proof homepage hero Start Free',
|
|
223
|
+
'interactiveElements': 4,
|
|
224
|
+
'visibleInteractiveElements': 4,
|
|
225
|
+
'pathname': '/',
|
|
226
|
+
'title': 'Riddle',
|
|
227
|
+
'buttons': ['Start Free'],
|
|
228
|
+
'headings': ['Riddle Proof'],
|
|
229
|
+
'links': [],
|
|
230
|
+
'canvasCount': 0,
|
|
231
|
+
'largeVisibleElements': [{'tag': 'button', 'text': 'Start Free'}],
|
|
232
|
+
}),
|
|
233
|
+
}
|
|
210
234
|
raise AssertionError(f'unexpected riddle_script payload: {script}')
|
|
211
235
|
raise AssertionError(f'unexpected invoke_retry tool: {tool}')
|
|
212
236
|
|
|
@@ -581,6 +605,53 @@ def run_recon_prefers_route_literals_over_import_paths():
|
|
|
581
605
|
shutil.rmtree(tempdir, ignore_errors=True)
|
|
582
606
|
|
|
583
607
|
|
|
608
|
+
def run_recon_prefers_hint_root_over_single_route_literal():
|
|
609
|
+
tempdir = Path(tempfile.mkdtemp(prefix='riddle-proof-hint-root-'))
|
|
610
|
+
state_path = tempdir / 'state.json'
|
|
611
|
+
try:
|
|
612
|
+
route_snippet = "export const routes = [{ path: '/docs/riddle-proof/markdown', element: <Docs /> }];\n"
|
|
613
|
+
state = base_state(tempdir, reference='before')
|
|
614
|
+
make_project(tempdir / 'before', route_snippet)
|
|
615
|
+
make_project(tempdir / 'after', route_snippet)
|
|
616
|
+
state.update({
|
|
617
|
+
'server_path': '/',
|
|
618
|
+
'server_path_source': 'hint_cache',
|
|
619
|
+
'capture_hint': {
|
|
620
|
+
'source': 'hint_cache',
|
|
621
|
+
'applied_fields': ['server_path'],
|
|
622
|
+
'selected': {'server_path': '/'},
|
|
623
|
+
},
|
|
624
|
+
'change_request': 'Make a tiny harmless homepage copy tweak',
|
|
625
|
+
'success_criteria': 'The homepage hero copy reflects the tiny tweak.',
|
|
626
|
+
})
|
|
627
|
+
write_state(state_path, state)
|
|
628
|
+
os.environ['RIDDLE_PROOF_STATE_FILE'] = str(state_path)
|
|
629
|
+
|
|
630
|
+
fake = FakeRiddle()
|
|
631
|
+
load_util_with_fake(fake)
|
|
632
|
+
load_module('recon_hint_root_preference', RECON_PATH)
|
|
633
|
+
after_recon = json.loads(state_path.read_text())
|
|
634
|
+
|
|
635
|
+
current_plan = after_recon['recon_results']['current_plan']
|
|
636
|
+
candidate_paths = [item['path'] for item in current_plan['route_candidates']]
|
|
637
|
+
assert current_plan['target_path'] == '/', current_plan
|
|
638
|
+
assert current_plan['path_source'] == 'state.server_path:hint_cache', current_plan
|
|
639
|
+
assert '/docs/riddle-proof/markdown' in candidate_paths, candidate_paths
|
|
640
|
+
details = after_recon['recon_results']['attempt_history'][-1]['observations']['before']['details']
|
|
641
|
+
assert details['observed_path'] == '/'
|
|
642
|
+
assert 'Start Free' in details['visible_text_sample'], details
|
|
643
|
+
assert details['buttons'] == ['Start Free'], details
|
|
644
|
+
|
|
645
|
+
return {
|
|
646
|
+
'ok': True,
|
|
647
|
+
'target_path': current_plan['target_path'],
|
|
648
|
+
'path_source': current_plan['path_source'],
|
|
649
|
+
'candidate_paths': candidate_paths,
|
|
650
|
+
}
|
|
651
|
+
finally:
|
|
652
|
+
shutil.rmtree(tempdir, ignore_errors=True)
|
|
653
|
+
|
|
654
|
+
|
|
584
655
|
def run_author_applies_supervisor_packet():
|
|
585
656
|
tempdir = Path(tempfile.mkdtemp(prefix='riddle-proof-supervisor-apply-'))
|
|
586
657
|
state_path = tempdir / 'state.json'
|
|
@@ -1182,6 +1253,7 @@ if __name__ == '__main__':
|
|
|
1182
1253
|
'verify_quality_ignores_proof_telemetry_console_text': run_verify_quality_ignores_proof_telemetry_console_text(),
|
|
1183
1254
|
'recon_then_author_request': run_recon_then_author_request(),
|
|
1184
1255
|
'recon_route_literal_preference': run_recon_prefers_route_literals_over_import_paths(),
|
|
1256
|
+
'recon_hint_root_preference': run_recon_prefers_hint_root_over_single_route_literal(),
|
|
1185
1257
|
'author_applies_supervisor_packet': run_author_applies_supervisor_packet(),
|
|
1186
1258
|
'verify_requests_supervisor_assessment': run_verify_requests_supervisor_assessment(),
|
|
1187
1259
|
'verify_structured_evidence_without_screenshot': run_verify_structured_evidence_without_screenshot(),
|