File indexing completed on 2026-11-09 10:47:22
0001
0002 """Architectural boundary: one dashboard document and shared drawing models."""
0003 from pathlib import Path
0004 import hashlib
0005 import re
0006
0007 root = Path(__file__).resolve().parents[1]
0008 assets = root / 'src/monitor_app/static/monitor_app/prod_dashboard'
0009 model = assets / 'epic-pillar-model.js'
0010 trend_model = assets / 'epic-trend-model.js'
0011 for shared in (model, trend_model):
0012 assert shared.is_file(), f'canonical drawing module missing: {shared.name}'
0013 assert not re.search(r'\b(?:document|window|require|import)\b', shared.read_text()), 'shared model must be independent of DOM and module loaders'
0014 for name in ('epic-dashboard-panels.js', 'epic-dashboard-links.js', 'epic-dashboard-weekly.js'):
0015 assert not (root / 'src/static' / name).exists(), f'duplicate dashboard source: {name}'
0016 entry = (root / 'src/static/epic-dashboard-design.html').read_text()
0017 assert "fetch(new URL('../panda/dashboard/'" in entry and 'document.write(html)' in entry, 'development URL must load the canonical dashboard'
0018 assert '<svg' not in entry and entry.count('<script>') == 1 and len(entry) < 1500, 'development URL contains a second dashboard implementation'
0019 template = (root / 'src/monitor_app/templates/monitor_app/prod_dashboard.html').read_text()
0020 assert template.count("static 'monitor_app/prod_dashboard/epic-pillars.js'") == 1
0021 assert template.count("static 'monitor_app/prod_dashboard/epic-pillar-model.js'") == 1
0022 assert template.index('epic-pillar-model.js') < template.index('epic-pillars.js') < template.index('epic-dashboard-panels.js')
0023 assert template.count("static 'monitor_app/prod_dashboard/epic-trend-model.js'") == 1
0024 assert template.index('epic-trend-model.js') < template.index('epic-dashboard-live.js')
0025 live = (assets / 'epic-dashboard-live.js').read_text()
0026 assert 'createEpicTrendModel()' in live and 'trendModel.site(' in live, 'dashboard trends must consume the shared model'
0027
0028
0029
0030 assert 'site.notices' in live and all('item.' + field in live for field in ('n', 'text', 'level', 'link')), \
0031 'panel notices must be the feed\'s numbered report lines'
0032 assert 'queue.pilots.waiting_current' in live, 'waiting pilots must use the feed-resolved count'
0033 assert 'trendModel.hourly(' in live and 'rateMultiplier' not in live, 'hourly conversion must use the shared trend model'
0034 assert 'marker.style.background = trendModel.palette[key]' in live, 'plot legend markers must use the shared palette'
0035 links = (assets / 'epic-dashboard-links.js').read_text()
0036 assert 'record.sites' in links and 'site.queues' in links, 'drilldown queues must come from the feed'
0037 assert 'BNL_OSG_PanDA_1' not in links and 'UM_GREX_PanDA_1' not in links, 'drilldowns contain a second queue catalogue'
0038 assert not re.search(r"['\"](?:at fair share limit|fair share limited)['\"]", live), 'dashboard must not author a second fair-share notice'
0039 room_hash = root.parent / 'tjrepo/etaverse/scripts/audition/comp-room-pillar-model.sha256'
0040 if room_hash.exists():
0041 assert room_hash.read_text().strip() == hashlib.sha256(model.read_bytes()).hexdigest(), 'room pillar-model pin must follow the canonical model'
0042 for source in assets.glob('*.js'):
0043 if source in (model, trend_model):
0044 continue
0045 forbidden = r'function\s+(?:segments|createEpicPillarModel|createEpicTrendModel)\s*\('
0046 assert not re.search(forbidden, source.read_text()), f'drawing model copy in {source}'
0047 if source.name != 'epic-pillars.js':
0048 assert not re.search(r'function\s+(?:renderSitePillars|renderExecPillars)\s*\(', source.read_text()), f'pillar adapter copy in {source}'
0049 print('dashboard drawing boundary: one document, shared pillar and trend models')