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.
70 lines
3.6 KiB
Python
70 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
# #region Verification.FinanceMillion.PartialAudit [C:3] [TYPE Module] [SEMANTICS traversal,partial,evidence,ownership]
|
|
# @BRIEF Validate owned incomplete finance rows without upgrading them to full-coverage PASS.
|
|
# @INVARIANT Successful audit exits zero only for explicitly VERIFIED_PARTIAL; the full625 acceptance remains unmet.
|
|
import argparse
|
|
import json
|
|
from audit_traversal import verify_receipt,verify_values
|
|
|
|
|
|
# #region Verification.FinanceMillion.PartialAudit.Stream [C:3] [TYPE Function]
|
|
def audit(lines,args):
|
|
header=None
|
|
count=0
|
|
next_key=1
|
|
chain=''
|
|
context=None
|
|
ended=False
|
|
for line in lines:
|
|
record=json.loads(line)
|
|
if record['record_type']=='header':
|
|
assert header is None and count==0
|
|
header=record
|
|
assert header['run']['id']==args.run_id and header['run']['status']=='inconclusive'
|
|
journal=header['journal']
|
|
assert journal['run_id']==args.run_id and journal['logical_step_id']==args.step_id and journal['attempt']==args.attempt
|
|
assert journal['action']=='pagination' and journal['status']=='inconclusive'
|
|
elif record['record_type']=='page':
|
|
assert header is not None and not ended
|
|
count+=1
|
|
page,chain=verify_receipt(record,run_id=args.run_id,step_id=args.step_id,attempt=args.attempt,chain=chain)
|
|
assert page['ordinal']==count and page['chart_id']==args.chart_id and page['dataset_id']==args.dataset_id
|
|
assert page['source_total']==125000 and page['page_size']==200 and page['row_offset']==(count-1)*200
|
|
assert len(page['rows'])==200 and page['next_available'] is True
|
|
context=context or page['context_digest']
|
|
assert page['context_digest']==context
|
|
next_key=verify_values(page,next_key)
|
|
else:
|
|
assert record['record_type']=='end' and not ended and record['run_id']==args.run_id and record['logical_step_id']==args.step_id and record['attempt']==args.attempt
|
|
ended=True
|
|
assert header is not None and ended and 0<count<625
|
|
state=header['journal']['state']
|
|
assert state['row_count']==count*200 and state['next_ordinal']==count+1 and state['last_key']==next_key-1
|
|
assert state['terminal'] is False and state['chain_digest']==chain
|
|
return {'status':'VERIFIED_PARTIAL','full625_acceptance':'NOT_MET','run_id':args.run_id,'logical_step_id':args.step_id,'owned_pages':count,'ordered_rows':next_key-1,'source_rows':125000,'remaining_pages':625-count,'chain_digest':chain,'limitation':'Original network response bytes not retained; their hashes cannot be independently recomputed'}
|
|
# #endregion Verification.FinanceMillion.PartialAudit.Stream
|
|
|
|
|
|
# #region Verification.FinanceMillion.PartialAudit.Main [C:2] [TYPE Function]
|
|
def main():
|
|
parser=argparse.ArgumentParser()
|
|
parser.add_argument('input')
|
|
for key in ['run-id','step-id']:
|
|
parser.add_argument('--'+key,required=True)
|
|
for key in ['chart-id','dataset-id']:
|
|
parser.add_argument('--'+key,type=int,required=True)
|
|
parser.add_argument('--attempt',type=int,default=1)
|
|
args=parser.parse_args()
|
|
try:
|
|
with open(args.input) as lines:
|
|
result=audit(lines,args)
|
|
except (AssertionError,ValueError,KeyError,TypeError) as exc:
|
|
result={'status':'FAIL','reason':type(exc).__name__,'full625_acceptance':'NOT_MET'}
|
|
print(json.dumps(result,ensure_ascii=False,indent=2))
|
|
return int(result['status']!='VERIFIED_PARTIAL')
|
|
# #endregion Verification.FinanceMillion.PartialAudit.Main
|
|
|
|
if __name__=='__main__':
|
|
raise SystemExit(main())
|
|
# #endregion Verification.FinanceMillion.PartialAudit
|