from pathlib import Path from urllib.parse import urlsplit,parse_qsl,urlencode import json,shutil,hashlib P=Path(__file__).resolve().parents[2];D=P/'docs/rebuild-v2/semrush';D.mkdir(exist_ok=True) source=Path('/Users/gavrilovdev/tmp/pupline/site-restoration-status/semrush-recovery/videoreg.ru');raw=json.loads((source/'observed-indexed-pages.json').read_text()) for name in ['observed-indexed-pages.json','observed-indexed-pages.md','observed-anchors.partial.json','observed-anchors.partial.md','observed-lost-vital.json','observed-lost-vital.md']:shutil.copyfile(source/name,D/name) inv=json.loads((P/'docs/rebuild-v2/url-inventory.json').read_text());by={i['normalizedPath']:i for i in inv} def norm(url): u=urlsplit(url);q=[(k,v) for k,v in parse_qsl(u.query) if k!='sid'];return u.path+('?' +urlencode(sorted(q)) if q else '') rows=[] for row in raw['rows']: k=norm(row['url']);found=by.get(k);status=found['publicationStatus'] if found else 'unresolved-new-lead' if row['classification']=='later_expired_domain_state':status='later-state-not-original-body' rows.append(dict(observed=row,normalizedPath=k,matchedInventoryUrl=found['originalUrl'] if found else None,recoveryDisposition=status,rawFile=found['rawFile'] if found else None,sourceHash=found['rawSha256'] if found else None,currentDestination=found['currentDestination'] if found else None,bodyRecoveredFromAnchor=False,review='Specific target reconciled to actual source inventory; metrics not treated as body proof')) extra=[('/moves.htm','Универсальный цифровой видеорегистратор СВК','recovered-original-Russia1clip-context'),('/autopredpr.shtml',None,'matched'),('/demo.shtml',None,'unresolved-media'),('/shop/index.php?productID=133',None,'matched'),('/shop/index.php?productID=138',None,'unresolved'),('/forum/viewtopic.php?t=196',None,'unresolved'),('/forum/viewforum.php?f=1',None,'navigation-only'),('/account',None,'unresolved-epoch-body-not-verified'),('/join',None,'unresolved-epoch-body-not-verified'),('/withdraw',None,'unresolved-epoch-body-not-verified')] report=dict(domain='videoreg.ru',evidenceOrigin='Coordinator inspected Noxtools/Semrush in shared built-in browser; this executor ingested actual supplied transcription without taking over session',reportUrl=raw['reportUrl'],additionalEvidenceFiles=['observed-anchors.partial.json','observed-lost-vital.json','referrer-verification.json'],reportedTotal=raw['reportedTotal'],actualDOMRowsReported=raw['actualDOMRowsReportedByParent'],transcribedRows=raw['transcribedRows'],complete=False,scopeLimitation=raw['scopeLimit'],originalExportSha256=hashlib.sha256((D/'observed-indexed-pages.json').read_bytes()).hexdigest(),rows=rows,additionalCoordinatorMessageLeads=[dict(url='http://www.videoreg.ru'+k,title=t,disposition=s,evidence='Direct coordinator message2026-10-26; exact per-row metrics/date not supplied') for k,t,s in extra],remainingRequirements=['Remaining66observedDOM rows and6unloaded reported rows not provided as full export','Anchors52DOM/3transcribed; LostVital18DOM/6transcribed.5actualreferrersfetched;3HTTP200,2unavailable. Full rowtranscriptions and remainingreferrers remain mandatory.','Unresolved target bodies/media must be recovered from actual sources; no text synthesized from anchors']) all83=D/'observed-indexed-all83-urls.json' if all83.exists(): report.update(urlRowsTranscribed=83,metadataRowsTranscribed=17,reportedButUnseen=6,exactUrlReconciliation='indexed83-reconciliation.json',urlTranscriptSha256=hashlib.sha256(all83.read_bytes()).hexdigest(),expandedInventoryKnownUrls=len(inv),currentUnresolvedTargets=sum(x['publicationStatus'].startswith('unresolved') for x in inv),lateEpochPolicy='URL-only does not prove Blox/expiry/spam; epoch-unverifiedtargets retainedunresolved.') report['remainingRequirements']=['SixreportedURLrowsnotobserved; nofabrication','Metadatafor17only;52Anchorrows/3transcribedand18LostVitalrows/6transcribed remainpartial','Actualunresolvedbodiesandunknown-epochtargets remainmandatory; no URL/title synthesis'] (D/'reconciliation.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n') (D/'scope.md').write_text('# Semrush / Noxtools — actual partial scope\n\nCoordinator used the shared built-in browser. Report total89, actualDOM83, supplied transcription17selected rows. This executor ingested exactly those17 and the explicit additional coordinator message leads; it did not independently inspect the UI or manufacture the remaining rows.\n\n`reconciliation.json` maps each supplied target to actual raw body/status. Late expiry and Blox account/join/withdraw states do not replace original technical content. Backlink counts are not recovered text.\n\nMandatory issue videoreg-7oy.7 stays open: complete exported row coverage and actual referringURL/anchor contexts are still missing.\n') print('Semrush matched observed rows',len(rows),'of reported',raw['reportedTotal'],'scope remains partial')