Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane.io/blob/main/evidence/discoverability-issue7/qualify.py # interplane.io Source of interplane.io: a Rust generator that renders the page from the protocol repository's public record, deployed hourly from the Spark. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane.io / evidence / discoverability-issue7 / qualify.py` 61 lines ยท 3474 bytes Raw Blame History 1 #!/usr/bin/env python3 2 """External qualification oracle; not part of the website runtime.""" 3 from pathlib import Path 4 from html.parser import HTMLParser 5 import json, subprocess, xml.etree.ElementTree as ET 6 root = Path(__file__).resolve().parents[2] 7 evidence = Path(__file__).resolve().parent 8 dist = root / 'dist' 9 facts = json.loads((dist/'facts.json').read_text()) 10 class Page(HTMLParser): 11 def __init__(self): 12 super().__init__(); self.links=[]; self.scripts=[]; self.canonicals=[]; self.images=[]; self.headings=[] 13 def handle_starttag(self, tag, attrs): 14 a=dict(attrs) 15 if tag=='a': self.links.append(a.get('href','')) 16 if tag=='script': self.scripts.append(a) 17 if tag=='link' and a.get('rel')=='canonical': self.canonicals.append(a['href']) 18 if tag=='img': self.images.append(a) 19 if tag in ('h1','h2','h3','h4','h5','h6'): self.headings.append(int(tag[1])) 20 p=Page(); html=(dist/'index.html').read_text(); p.feed(html) 21 assert p.scripts==[{'type':'application/ld+json'}] 22 assert p.canonicals==['https://interplane.io/'] 23 assert p.headings.count(1)==1 24 assert all(b<=a+1 for a,b in zip(p.headings,p.headings[1:])) 25 assert all(x.get('alt','').strip() for x in p.images) 26 sitemap=ET.parse(dist/'sitemap.xml').getroot() 27 assert [x.text for x in sitemap.findall('{*}url/{*}loc')]==p.canonicals 28 assert not sitemap.findall('{*}url/{*}lastmod') 29 # Resolve all pinned GitHub source links against the authentic protocol tree once. 30 full,sha=facts['pin']['full_name'],facts['pin']['sha'] 31 r=subprocess.run(['gh','api',f'repos/{full}/git/trees/{sha}?recursive=1'],capture_output=True,text=True) 32 assert r.returncode==0,r.stderr 33 tree=json.loads(r.stdout); assert not tree.get('truncated') 34 paths={x['path'] for x in tree['tree']} 35 source_links=[] 36 for link in p.links: 37 marker=f'/blob/{sha}/' 38 if marker in link: 39 path=link.split(marker,1)[1] 40 assert path in paths,('broken pinned path',path) 41 source_links.append(link) 42 (evidence/'protocol-tree.json').write_text(r.stdout+'\n') 43 (evidence/'facts.json').write_text(json.dumps(facts,indent=2)+'\n') 44 # Exercise the actual CLI verifier, not a mocked callback. 45 index=dist/'index.html'; original=index.read_bytes(); outcomes=[] 46 try: 47 candidates=[('valid',html,0),('executable-script',html+'',1), 48 ('wrong-canonical',html.replace('rel="canonical" href="https://interplane.io/"','rel="canonical" href="https://wrong.example/"'),1), 49 ('invalid-json',html.replace('"@context":"https://schema.org"','"@context": INVALID'),1), 50 ('missing-local-link',html.replace('href="facts.json"','href="missing.json"'),1)] 51 for name,text,expected in candidates: 52 index.write_text(text) 53 r=subprocess.run([str(root/'target/debug/site-builder'),'verify',str(dist)],capture_output=True,text=True) 54 assert r.returncode==expected,(name,r.returncode,r.stdout,r.stderr) 55 outcomes.append(dict(case=name,exit=r.returncode,stdout=r.stdout,stderr=r.stderr)) 56 finally:index.write_bytes(original) 57 result=dict(schema='interplane-discoverability-qualification/1',protocol_sha=sha,heading_sequence=p.headings, 58 pinned_source_links=source_links,cli_controls=outcomes,local_only=True, 59 limitation='Single current route; issue6 route expansion, deployed HTTP and organic ranking are not qualified here.') 60 (evidence/'qualification.json').write_text(json.dumps(result,indent=2)+'\n') 61 print(json.dumps(result,indent=2))