Record source-backed calendar contract and exact timezone-independent release

This commit is contained in:
huncode committed 2026-10-26 20:28:14 +03:00
1 parent 5d5fbf06e9
commit 339adb0765
38 files changed
+7718 -54

No files matched your search

@@ -0,0 +1,32 @@
from pathlib import Path
from bs4 import BeautifulSoup
import json,hashlib,datetime
r=Path('/Users/gavrilovdev/tmp/progcode.ru');roots={'UTC':Path('/tmp/progcode-dates-utc-out'),'Europe/Moscow':r/'web/out'};old=Path('/tmp/progcode-v2-frozen-656da6da3e89');ledger=json.loads(Path('/tmp/progcode-date-content/ledger.json').read_text());records={v['preserveDateTimeMetadata']:v for v in ledger['records']};shortMonths=['янв.','февр.','мар.','апр.','мая','июн.','июл.','авг.','сент.','окт.','нояб.','дек.'];extracted={};checks={};oldMismatches=[]
for tz,root in roots.items():
out={};count=0
for path in sorted(root.rglob('*.html')):
route=str(path.relative_to(root));s=BeautifulSoup(path.read_bytes(),'html.parser');times=[]
for t in s.select('main time[datetime]'):
stamp=t['datetime'];assert stamp in records,(route,stamp);v=records[stamp];expected=v['expectedRussianDateLabel'].split(' ',1)[0].zfill(2)+' '+v['expectedRussianDateLabel'].split(' ',1)[1]
if route=='index.html':
y,m,d=map(int,v['expectedPublicationCalendarDate'].split('-'));expected=f'{d} {shortMonths[m-1]} {y} г.'
label=t.get_text(' ',strip=True);assert label==expected,(tz,route,stamp,label,expected)
times.append({'datetime':stamp,'text':label});count+=1
out[route]=times
if tz=='UTC' and (old/route).exists():
before=[{'datetime':t['datetime'],'text':t.get_text(' ',strip=True)} for t in BeautifulSoup((old/route).read_bytes(),'html.parser').select('main time[datetime]')]
if before!=times:oldMismatches.append({'path':route,'before':before,'after':times})
assert len(out)==81
for v in records.values():
for route in ['articles/'+v['slug']+'/index.html',v['legacyPath'].strip('/')+'/index.html']:
assert out[route]==[{'datetime':v['preserveDateTimeMetadata'],'text':v['expectedRussianDateLabel'].split(' ',1)[0].zfill(2)+' '+v['expectedRussianDateLabel'].split(' ',1)[1]}]
extracted[tz]=out;checks[tz]={'HTML':len(out),'timeElements':count,'sourceHash':json.loads((root/'build-identity.json').read_text())['sourceHash'],'historicalDaysAndISOmetadataMatchLedger':True}
assert extracted['UTC']==extracted['Europe/Moscow'];assert checks['UTC']['sourceHash']==checks['Europe/Moscow']['sourceHash'];bodyChecks=[]
for v in records.values():
route=Path('articles')/v['slug']/'index.html';a=BeautifulSoup((old/route).read_bytes(),'html.parser').select_one('.article-content');b=BeautifulSoup((roots['Europe/Moscow']/route).read_bytes(),'html.parser').select_one('.article-content');assert str(a)==str(b);bodyChecks.append(v['slug'])
mediaChecks=[]
for p in sorted((old/'visuals').rglob('*')):
if p.is_file():
route=p.relative_to(old);assert p.read_bytes()==(roots['Europe/Moscow']/route).read_bytes();mediaChecks.append(str(route))
result={'recordedAtUTC':datetime.datetime.now(datetime.timezone.utc).isoformat(),'contract':'Historical raw-visible calendar date; source+00:00 and legacypath agree; explicitUTC formatter; fullISOmetadata unchanged','builds':checks,'all81DateAndMetadataManifestsIdentical':True,'all14CanonicalAnd14LegacyHeadersMatchIndependentLedger':True,'dates':extracted['Europe/Moscow'],'oldFrozen656SupersededMismatchPages':len(oldMismatches),'oldFrozenDateDifferences':oldMismatches,'articleBodiesUnchanged':bodyChecks,'visualBytesUnchanged':mediaChecks,'wholeHTMLByteParityClaimed':False,'harnessNote':'Initial comparator treated reviewer calendar-label day width as UI width (3vs03); corrected expected long-label zero-padding to preserved UI policy, no product changes.'}
Path('/tmp/progcode-date-build-parity.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n');print({k:v for k,v in result.items() if k not in ['dates','oldFrozenDateDifferences','articleBodiesUnchanged','visualBytesUnchanged']})