Add versioned metric graph authority, owned browser evidence, paginated and all-tab traversal, deterministic sampling policies, and analyst-facing run inspection. Provision the DEV/PREPROD/PROD Superset, Gitea and million-row ClickHouse lab; retain reproducible lifecycle evidence and explicit incomplete-traversal limits.
43 lines
2.6 KiB
Python
43 lines
2.6 KiB
Python
# #region FullFlow.FinanceBrowserReconstruct [C:3] [TYPE Module] [SEMANTICS fixture,readonly,pagination,reconstruction]
|
|
# @BRIEF Test real numbered-control reconstruction without treating skipped navigation as retained coverage.
|
|
# @INVARIANT Only rendered controls matched by the exact admitted chart-relative selector navigate; no state injection or shadow query.
|
|
import math
|
|
|
|
|
|
# #region FullFlow.FinanceBrowserReconstruct.Target [C:3] [TYPE Function]
|
|
# @POST Choose a visible numeric candidate that strictly reduces distance to the requested source-bounded ordinal.
|
|
async def candidate(reader, target, total):
|
|
pager = reader.root.locator(reader.limits.pagination_selector)
|
|
texts = await pager.locator('a').all_text_contents()
|
|
numbers = {int(text.strip()) for text in texts if text.strip().isdecimal()}
|
|
options = sorted((value for value in numbers if 1 <= value <= total and
|
|
abs(target-value) < abs(target-reader.position)),key=lambda value:abs(target-value))
|
|
for value in options:
|
|
selector = reader.limits.next_page_selector.replace('{next_page_index}',str(value-1))
|
|
control = await reader.control(selector)
|
|
if await control.is_visible() and await control.is_enabled():
|
|
return value
|
|
raise ValueError('BROWSER_TRAVERSAL_RECONSTRUCTION_CONTROL_UNAVAILABLE')
|
|
# #endregion FullFlow.FinanceBrowserReconstruct.Target
|
|
|
|
|
|
# #region FullFlow.FinanceBrowserReconstruct.Navigate [C:3] [TYPE Function]
|
|
# @PRE Reader captured actual first-page response; target is within the runtime-observed source count.
|
|
# @POST Every navigation response preserves source identity/count/context; skipped pages produce no coverage receipts.
|
|
async def reconstruct(reader, target, retain_navigation):
|
|
original = reader.exchange
|
|
total = math.ceil(original['source_total']/reader.limits.page_size)
|
|
if not 1 <= target <= total:
|
|
raise ValueError('BROWSER_TRAVERSAL_RECONSTRUCTION_TARGET_INVALID')
|
|
keys = ('source_total','dataset_id','context_digest')
|
|
while reader.position != target:
|
|
ordinal = await candidate(reader,target,total)
|
|
await reader.click(reader.limits.next_page_selector,ordinal,70)
|
|
if any(reader.exchange[key] != original[key] for key in keys):
|
|
raise ValueError('BROWSER_TRAVERSAL_RECONSTRUCTION_CONTEXT_CHANGED')
|
|
await reader.read_page(ordinal,timeout_seconds=70)
|
|
retain_navigation({'scope':'navigation only; not coverage','ordinal':ordinal,
|
|
'target':target,'source_total':reader.exchange['source_total']})
|
|
# #endregion FullFlow.FinanceBrowserReconstruct.Navigate
|
|
# #endregion FullFlow.FinanceBrowserReconstruct
|