Files
progcode/docs/rebuild-v2/evidence/diet-successor/reviews/check-content.py
T

47 lines
7.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pathlib import Path
import json,re,hashlib,subprocess,urllib.request,urllib.parse,html
r=Path('/Users/gavrilovdev/tmp/progcode.ru');out=Path('/tmp/progcode-diet-reviews');c=json.loads((r/'docs/rebuild-v2/evidence/diet-successor/candidate.json').read_text());data=json.loads((r/'web/data/articles.json').read_text());old=json.loads(subprocess.check_output(['git','show','0cb1ce1:web/data/articles.json'],cwd=r));slug='особенности-vibe-d';a=next(x for x in data if x['slug']==slug);b=next(x for x in old if x['slug']==slug);paragraph=next(x for x in re.findall(r'<p>.*?</p>',a['contentHtml'],re.S) if 'Если вы меняете <code>.dt</code>' in x)
assert [x for x in a['contentHtml'].replace(paragraph,'').splitlines() if x.strip()]==[x for x in b['contentHtml'].splitlines() if x.strip()]
changed=[dict(slug=x['slug'],fields=[k for k in x if x[k]!=y[k]]) for x,y in zip(data,old) if x!=y];assert changed==[dict(slug=slug,fields=['contentHtml'])]
root=Path(c['staticRoot']);http=[]
for kind,path in [('canonical','/articles/'+slug+'/'),('legacy',a['legacyPath'])]:
url=c['local']['url']+urllib.parse.quote(path,safe='/')
with urllib.request.urlopen(url,timeout=10) as res:body=res.read();status=res.status
f=root/path.strip('/')/'index.html';assert body==f.read_bytes();assert paragraph in body.decode();assert a['date'] in body.decode()
http.append(dict(kind=kind,url=url,HTTP=status,bytes=len(body),sha256=hashlib.sha256(body).hexdigest(),matchesFrozen=True,newParagraphPresent=True,originalDateTimePreserved=a['date']))
h=hashlib.sha256();files=sorted(x for x in root.rglob('*') if x.is_file())
for f in files:h.update(str(f.relative_to(root)).encode());h.update(f.read_bytes())
assert h.hexdigest()==c['buildHash']
ledger=json.loads((r/'docs/rebuild-v2/editorial-ledger.json').read_text());entry=next(x for x in ledger['pages'] if x['slug']==slug);outbound=next(x for x in entry['outboundLinks'] if x['url']=='https://vibed.org/templates/diet');assert outbound['anchor']=='компиляции шаблона в D' and outbound['decision']=='keep'
raw=r/'docs/rebuild-v2/semrush/first100/raw/comment-source-4.capture';rawSHA=hashlib.sha256(raw.read_bytes()).hexdigest();assert rawSHA=='d7917eb53e21ea423d9dd76fd217945092afdf989f48f0e86fc65627082defe6'
aggregate=json.loads((r/'docs/rebuild-v2/outbound-links.json').read_text());newOcc=[x for x in aggregate['occurrences'] if x['destination']=='https://vibed.org/templates/diet']
evidence=dict(reviewer='/root/content_manager',scope='Bounded Diet paragraph successor only',commit=subprocess.check_output(['git','rev-parse','HEAD'],cwd=r,text=True).strip(),candidate=c,baselineCommit='0cb1ce1f150a8361e6479843c9b0701701871baf',baselineBuild='3bb33db05c55c1fba415dffcd8df509603b970b349f90fbaab3fd2c93092d7c9',newParagraph=paragraph,delta=changed,onlyOneParagraphAddition=True,deltaWhitespaceNote='One adjacent blank line is also added; no other nonblank body line changed.',other13ArticleRecordsIdentical=True,rawCommentSource=dict(file=str(raw.relative_to(r)),sha256=rawSHA,exactCaptureTimestamp='20191208181939',personallyRereadComments=[dict(id=4,lineRange=[296,314],author='Илья',date='2017-07-09T22:56:21+00:00'),dict(id=5,lineRange=[317,336],author='DarkRiDDeR',date='2017-07-10T12:31:42+00:00')]),technicalSource=dict(url='https://vibed.org/templates/diet',personallyRead=True,reviewRelevantSections='Introduction: originalDiet superseded by DietNG; static compilation to native D',noInventedHistoricalQuotation=True,noUniversalCleanRebuildClaim=True,noTempleRecommendationCopied=True),outboundReason=outbound,outboundReasonPersonallyApproved=True,aggregateNewURLOccurrencesAtReview=len(newOcc),httpChecks=http,computedBuildHash=h.hexdigest(),frozenFiles=len(files),verdict='ACCEPT bounded editorial paragraph for exact successor',publicationEvidenceDependency='Resolved: successor aggregate reviewed for new URL; edited-body1/build2/boundedDOM4 with correct purpose, all7 reviewed; baseline fullDOM is not claimed as new completeDOM.',scopeExclusions=['No new full14-body rereview claimed','No deployment/publicdate/CI verdict','Mandatory unseen74 and webprogcode-v2.6 remain open'])
(out/'content-evidence.json').write_text(json.dumps(evidence,ensure_ascii=False,indent=2)+'\n')
(out/'content.md').write_text(f'''# Diet successor — scoped content ACCEPT
Reviewer `/root/content_manager`. Git `{evidence['commit']}`; source `{c['sourceHash']}`; frozen build `{c['buildHash']}`. Local `{c['local']['url']}`, PID{c['local']['pid']}; immutable `{root}`. Accepted previous build `3bb33db0…` remains a baseline, not replaced in old evidence.
## Personal inspection
Read the new paragraph and the complete surrounding Diet section in `web/data/articles.json`, `paragraph-delta.md` and `primary-source-check.json`. Independently compared data to `0cb1ce1`: exactly one paragraph was added to `особенности-vibe-d`; removing it gives the previous complete body with only one adjacent added blank line. The other13 article records are identical.
Re-read full raw comments4/5 in `docs/rebuild-v2/semrush/first100/raw/comment-source-4.capture`, selector `#div-comment-4 .comment-content` / `#div-comment-5 .comment-content`, lines296–314 and317–336. SHA256 `{rawSHA}` matches the independently corroborated exact capture20191208181939. Comment4 raises template-edit/recompilation; comment5 agrees and adds historical opinions. The successor adopts the concrete consequence, not the author's dislike of Diet, temple suggestion, or speculative double-development-effort claim.
Personally read [official Diet documentation](https://vibed.org/templates/diet): it describes static compilation to native D and explicitly notes originalDiet superseded by DietNG. The paragraph is correctly bounded to the statically compiled variant described in this article. It does not generalize to every template engine/version or watcher. It correctly says to rebuild the consuming code and run the updated application, and explicitly avoids an every-dependency clean-build claim.
This is ordinary editorial explanation, not a fabricated historical quotation or first-person experience. The new source link anchor `компиляции шаблона в D` directly supports the specific mechanism. Its per-page editorial-ledger keep reason was read and independently approved; it is not advertising or a domain-whitelist decision.
## Exact output verification
Canonical and dated legacy URLs each returned HTTP200, identical bytes to the new immutable files, containing the exact paragraph and unchanged source ISO date. Recomputed the sorted-relative-path/file-byte build hash over{len(files)}files: matches `{c['buildHash']}`. No claim of reopening all14 bodies or all screenshots is made by this narrow review.
## Verdict and remaining dependency
**ACCEPT this one paragraph at the exact successor source/build identity.** It closes the useful Diet development-cycle omission identified from comments4/5 in this bounded editorial scope. No product files were edited by this reviewer.
Successor aggregate outbound register now contains{len(newOcc)} occurrences of the new URL: edited-body1, built canonical/legacy2, bounded DOM4. Every occurrence carries the specific reviewed purpose. The earlier stale-rollup dependency is resolved. The DOM scope is explicitly the four Vibe cases; this is not a claim of reopening the entire site DOM in this review.
This review gives no CI/deployment/public-date verdict and no full-restoration PASS. The unseen74 Semrush rows and broader mandatory `webprogcode-v2.6` remain OPEN.
''')
print('ACCEPT paragraph; canonical+legacy200frozenmatch; buildhashverified;',len(newOcc),'aggregate newURLoccurrences')