In this section
- GlobalGrid2050 Repair V6 Electricity Annual Year Selector render · globalgrid2050 / scripts/repair_v6_electricity_annual_year_selector.py lines 1–250
- GlobalGrid2050 Repair V6 Event Boxes Visible storage · globalgrid2050 / scripts/repair_v6_event_boxes_visible.py lines 1–97
- GlobalGrid2050 Repair V6 Fullscreen Summary Box render · globalgrid2050 / scripts/repair_v6_fullscreen_summary_box.py lines 1–80
- GlobalGrid2050 Repair V6 Fullscreen Swipe interaction · globalgrid2050 / scripts/repair_v6_fullscreen_swipe.py lines 1–71
GlobalGrid2050 Repair V6 Electricity Annual Year Selector
A Python command-line tool in the scripts folder that reads procedural documents (`read_procedural_documents`) and patches v6 control (`patch_v6_control`) and article (`patch_article`).
renderglobalgrid2050 / scripts/repair_v6_electricity_annual_year_selector.py · lines 1–250 of 250 · Entry point · pattern must_not_contain (shared by 2 files)
- What it does
- It draws its content. Defines 13 functions or classes, including read, write, must_contain, must_not_contain, replace_once. Uses libraries pathlib, datetime. Side effects: changes the web page (DOM); reads or writes files; makes network requests.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Repair V6 Electricity Annual Year Selector Workflow (globalgrid2050).
- What it achieves
- It replaces once (`replace_once`) and is built from the must not contain helper (`must_not_contain`) and the article helper text helper (`article_helper_text`). Defines `read`, `write`, `must_contain` and 9 more.
- Why it matters
- Run by GlobalGrid2050 Repair V6 Electricity Annual Year Selector Workflow.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- pathlib, datetime
- Used by
- run by GlobalGrid2050 Repair V6 Electricity Annual Year Selector Workflow (workflow run)
- Produces
- read, write, must_contain, must_not_contain, replace_once, read_procedural_documents, patch_v6_control, patch_v6_index_cache_bust, article_helper_text, patch_article, assert_final_state, write_report
- Defines here
- read, write, must_contain, must_not_contain, replace_once, read_procedural_documents, patch_v6_control, patch_v6_index_cache_bust, article_helper_text, patch_article, assert_final_state, write_report, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/repair_v6_electricity_annual_year_selector.py:1-250 · blob b402aa44169ddabdae2c3e5023b40e0fc8ebfb4d · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, filesystem, network · domain stage: unknown · users: none · canonical: production_core
from pathlib import Path
from datetime import datetime, timezone
ROOT = Path(__file__).resolve().parents[1]
FILES = {
"ai_start": ROOT / "AI_START_HERE.md",
"architecture": ROOT / "ARCHITECTURE.md",
"philosophy": ROOT / "PHILOSOPHY.md",
"launch_freeze": ROOT / "LAUNCH_FREEZE.md",
"operator_manual": ROOT / "OPERATOR_MANUAL_V1.md",
"workflow_registry": ROOT / "WORKFLOW_REGISTRY.md",
"gridbot_instructions": ROOT / "GRIDBOT_FEATURE_INSTALL_INSTRUCTIONS.md",
"v5_readme": ROOT / "uk_energy_tracking_v5" / "README.md",
"v5_reload": ROOT / "uk_energy_tracking_v5" / "AI_RELOAD_INSTRUCTIONS.md",
"v6_comparison": ROOT / "uk_energy_tracking_v6" / "V5_V6_COMPARISON_REPORT.md",
"v6_protocol": ROOT / "uk_energy_tracking_v6" / "V6_ARCHITECTURAL_INTEGRITY_PROTOCOL.md",
"control": ROOT / "uk_energy_tracking_v6" / "price_history_chart" / "control_price_history" / "control_price_history.js",
"index": ROOT / "uk_energy_tracking_v6" / "index.md",
"article": ROOT / "data" / "grid_studies_public" / "great_britain_electricity_price_grid_constraint_trends_2016_2026.html",
"article_helper": ROOT / "data" / "grid_studies_public" / "gb_electricity_year_selector.js",
"report": ROOT / "uk_energy_tracking_v6" / "V6_REPAIR_ELECTRICITY_ANNUAL_YEAR_SELECTOR_REPORT.md",
}
TOUCHED = []
def read(path):
if not path.exists():
raise SystemExit(f"Missing required file: {path.relative_to(ROOT)}")
return path.read_text(encoding="utf-8")
def write(path, text):
old = path.read_text(encoding="utf-8") if path.exists() else ""
if old != text:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(text, encoding="utf-8")
rel = str(path.relative_to(ROOT))
if rel not in TOUCHED:
TOUCHED.append(rel)
def must_contain(text, needle, label):
if needle not in text:
raise SystemExit(f"Missing expected marker in {label}: {needle[:160]}")
def must_not_contain(text, needle, label):
if needle in text:
raise SystemExit(f"Unexpected marker in {label}: {needle[:160]}")
def replace_once(text, old, new, label):
count = text.count(old)
if count != 1:
raise SystemExit(f"Expected exactly 1 match in {label}, found {count}: {old[:160]}")
return text.replace(old, new, 1)
def read_procedural_documents():
checks = {
"ai_start": "Do not directly rewrite large HTML, CSS or JavaScript files",
"architecture": "Use Python, YAML and GitHub Actions for repeatable large file operations",
"philosophy": "GridBot does not copy and paste entire files",
"launch_freeze": "Freeze structure. Fix function. Document risks. Clean later.",
"operator_manual": "AI proposes. Python processes. GitHub records. GridBot executes. The maintainer approves.",
"workflow_registry": "No workflow should be removed, renamed or archived",
"gridbot_instructions": "Do not leave the feature field blank unless every earlier feature is repeat safe",
"v5_readme": "UK Energy Tracking",
"v5_reload": "AI",
"v6_comparison": "UK Energy Tracking V5 to V6 Comprehensive Comparison Report",
"v6_protocol": "All V6 changes, however small or large, must be made through a named GitHub workflow",
}
for key, marker in checks.items():
text = read(FILES[key])
must_contain(text, marker, key)
def patch_v6_control():
path = FILES["control"]
text = read(path)
must_contain(text, "function ensureYearOptions()", "V6 control existing year selector")
must_contain(text, "function ensureStartDate()", "V6 control existing start date")
must_contain(text, "window.V6LoadPriceHistoryData.loadWindow", "V6 control data loader")
old_head = "var FIRST_YEAR=2016;\n var STATE={timeMode:'all'};"
new_head = "var FIRST_YEAR=2016;\n var YEAR_ROLLOVER_MONTH=0;\n var YEAR_ROLLOVER_DAY=15;\n var STATE={timeMode:'all'};"
if "var YEAR_ROLLOVER_DAY=15;" not in text:
text = replace_once(text, old_head, new_head, "V6 control rollover constants")
old_block = "function ensureYearOptions(){var y=$('price-history-year');if(!y||y.options.length)return;var now=futureMaxDate().getUTCFullYear();for(var n=now;n>=FIRST_YEAR;n--){var o=document.createElement('option');o.value=String(n);o.textContent=String(n);y.appendChild(o)}y.value=String(maxDate().getUTCFullYear())}\n function ensureStartDate(){var y=$('price-history-year'),s=$('price-histor … [line shortened here: 728 characters; full line on GitHub]
new_block = "function activeDataYear(){var d=new Date();var y=d.getUTCFullYear();if(d.getUTCMonth()===YEAR_ROLLOVER_MONTH&&d.getUTCDate()<YEAR_ROLLOVER_DAY)return y-1;return y}\n function yearCutoff(year){var m=maxDate(),active=activeDataYear();if(year===active&&year===m.getUTCFullYear())return m;return new Date(Date.UTC(year,11,31,23,59,59))}\n function yearLabel(year){return year===activeD … [line shortened here: 1,221 characters; full line on GitHub]
if "function activeDataYear()" not in text:
text = replace_once(text, old_block, new_block, "V6 control annual year selector logic")
old_return = "return{start:start,load:load};"
new_return = "return{start:start,load:load,activeDataYear:activeDataYear};"
if new_return not in text:
text = replace_once(text, old_return, new_return, "V6 control export activeDataYear")
must_contain(text, "function activeDataYear()", "V6 control active year function")
must_contain(text, "YEAR_ROLLOVER_DAY=15", "V6 control rollover day")
must_contain(text, "String(year)+' YTD'", "V6 control YTD label")
write(path, text)
def patch_v6_index_cache_bust():
path = FILES["index"]
text = read(path)
old = "control_price_history.js?v=20260601d"
new = "control_price_history.js?v=20260604year2"
must_contain(text, "price-history-year", "V6 index year select")
if new not in text:
text = replace_once(text, old, new, "V6 index control script cache bust")
must_contain(text, new, "V6 index cache bust new value")
write(path, text)
def article_helper_text():
return """(function(){
var FIRST_YEAR=2016;
var YEAR_ROLLOVER_MONTH=0;
var YEAR_ROLLOVER_DAY=15;
function $(id){return document.getElementById(id)}
function activeDataYear(){var d=new Date();var y=d.getUTCFullYear();if(d.getUTCMonth()===YEAR_ROLLOVER_MONTH&&d.getUTCDate()<YEAR_ROLLOVER_DAY)return y-1;return y}
function ymd(d){return d.toISOString().slice(0,10)}
function label(year){return year===activeDataYear()?String(year)+' YTD':String(year)}
function maxDate(){return window.V6LoadPriceHistoryData&&window.V6LoadPriceHistoryData.maxDate?window.V6LoadPriceHistoryData.maxDate():new Date()}
function cutoff(year){return year===activeDataYear()?maxDate():new Date(Date.UTC(year,11,31,23,59,59))}
function addStyles(){if($('gg2050-year-selector-style'))return;var s=document.createElement('style');s.id='gg2050-year-selector-style';s.textContent='.gg2050-year-select-label{display:flex;align-items:center;gap:8px;border:1px solid rgba(0,255,255,.45);border-radius:10px;padding:8px 10px;color:#00ffff;background:#051014;font-family:Courier New,Courier,monospace;font-weight:bold}.gg2050-year-sele … [line shortened here: 738 characters; full line on GitHub]
function renderYear(year){var start=new Date(Date.UTC(year,0,1,0,0,0));var end=cutoff(year);window.V6LoadPriceHistoryData.loadWindow(start,'12m','all').then(function(result){result.end=end;result.rows=(result.rows||[]).filter(function(r){var t=new Date((r.date?r.date+'T12:00:00Z':(r.priceTimeUTC||r.time)));return t>=start&&t<=end});result.period='12m';window.V6RenderPriceChart.render(result);var … [line shortened here: 731 characters; full line on GitHub]
function init(){var grid=$('preset-grid');if(!grid||$('gg2050-electricity-year-select'))return;if(!window.V6LoadPriceHistoryData||!window.V6RenderPriceChart)return;addStyles();var lab=document.createElement('label');lab.className='gg2050-year-select-label';lab.appendChild(document.createTextNode('Year'));var sel=document.createElement('select');sel.id='gg2050-electricity-year-select';var active= … [line shortened here: 770 characters; full line on GitHub]
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
})();
"""
def patch_article():
helper_path = FILES["article_helper"]
helper = article_helper_text()
must_contain(helper, "YEAR_ROLLOVER_DAY=15", "article helper rollover day")
must_contain(helper, "loadWindow(start,'12m','all')", "article helper annual window")
write(helper_path, helper)
path = FILES["article"]
text = read(path)
tag = ' <script src="/data/grid_studies_public/gb_electricity_year_selector.js?v=20260604year2"></script>\n'
must_contain(text, 'id="preset-grid"', "article preset grid")
must_contain(text, 'V6LoadPriceHistoryData.loadWindow', "article chart loader")
if tag not in text:
text = replace_once(text, "</body>", tag + "</body>", "article helper script tag")
must_contain(text, "gb_electricity_year_selector.js?v=20260604year2", "article helper script tag installed")
write(path, text)
def assert_final_state():
control = read(FILES["control"])
index = read(FILES["index"])
article = read(FILES["article"])
helper = read(FILES["article_helper"])
must_contain(control, "function activeDataYear()", "control final")
must_contain(control, "YEAR_ROLLOVER_DAY=15", "control final")
must_contain(control, "String(year)+' YTD'", "control final")
must_contain(index, "control_price_history.js?v=20260604year2", "index final")
must_contain(article, "gb_electricity_year_selector.js?v=20260604year2", "article final")
must_contain(helper, "id='gg2050-electricity-year-select'", "helper final")
must_contain(helper, "var FIRST_YEAR=2016", "helper final")
must_contain(helper, "YEAR_ROLLOVER_DAY=15", "helper final")
must_contain(control, "window.V6LoadPriceHistoryData.loadWindow", "data path preserved")
must_contain(read(FILES["v6_protocol"]), "preserves the raw published data chart", "protocol approval sentence")
must_not_contain(control, "fetch(", "control should not fetch directly")
def write_report():
body = f"""# V6 Repair Report: Electricity Annual Year Selector
Generated UTC: {datetime.now(timezone.utc).isoformat()}
## Procedural documents read
- AI_START_HERE.md
- ARCHITECTURE.md
- PHILOSOPHY.md
- LAUNCH_FREEZE.md
- OPERATOR_MANUAL_V1.md
- WORKFLOW_REGISTRY.md
- GRIDBOT_FEATURE_INSTALL_INSTRUCTIONS.md
- uk_energy_tracking_v5/README.md
- uk_energy_tracking_v5/AI_RELOAD_INSTRUCTIONS.md
- uk_energy_tracking_v6/V5_V6_COMPARISON_REPORT.md
- uk_energy_tracking_v6/V6_ARCHITECTURAL_INTEGRITY_PROTOCOL.md
## Scope
This repair adds annual selector behaviour for the GB electricity price charts without changing the source data paths, CSV loader or raw chart renderer contract.
## Intended behaviour
1. The V6 chart year dropdown labels the current active data year as YTD.
2. The active YTD year rolls forward on 15 January UTC.
3. From 1 January to 14 January the previous year remains the active completed data year.
4. The public grid study chart receives a small annual selector generated by a helper script.
5. The article helper loads a 12 month daily window for the selected year.
6. Elexon annual CSV and daily aggregate paths remain unchanged.
## Files touched by script
{chr(10).join('- ' + x for x in TOUCHED) if TOUCHED else '- No file content changes were required'}
## Guardrails checked
- Direct V6 app editing is avoided by running this deterministic script through a named workflow.
- The script asserts expected old structure before editing.
- The workflow commits only intended files and this report.
- The raw chart continues to use existing V6 loader and renderer functions.
- No shared dataset path is moved.
- V5 remains untouched as the reference twin.
## Maintainer test checklist
1. Open /uk_energy_tracking_v6/.
2. Confirm the Year dropdown shows 2026 YTD during 2026, and historic years back to 2016.
3. Test 2019, 2020, 2021, 2022, 2025 and the current YTD year.
4. Open /data/grid_studies_public/great_britain_electricity_price_grid_constraint_trends_2016_2026.html.
5. Confirm the new annual Year selector appears before preset buttons.
6. Select 2020 to inspect pre crisis baseline.
7. Select 2022 to inspect crisis period.
8. Select 2025 or current YTD to inspect high renewables and negative price period.
9. Confirm Latest 24 hours, Latest 48 hours and Latest 1 week still work.
"""
write(FILES["report"], body)
def main():
read_procedural_documents()
patch_v6_control()
patch_v6_index_cache_bust()
patch_article()
assert_final_state()
write_report()
print("V6 electricity annual year selector repair completed.")
for item in TOUCHED:
print("touched:", item)
if __name__ == "__main__":
main()GlobalGrid2050 Repair V6 Event Boxes Visible
A Python module in the scripts folder.
storageglobalgrid2050 / scripts/repair_v6_event_boxes_visible.py · lines 1–97 of 97 · Entry point
- What it does
- It loads data. Uses libraries pathlib. Side effects: reads or writes files.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Repair V6 Event Boxes Visible Workflow (globalgrid2050).
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- Run by GlobalGrid2050 Repair V6 Event Boxes Visible Workflow.
- Application
- globalgrid2050 · scripts · Python module
- Uses
- pathlib
- Used by
- run by GlobalGrid2050 Repair V6 Event Boxes Visible Workflow (workflow run)
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/repair_v6_event_boxes_visible.py:1-97 · blob 950c47f0bfa96017d0182792542b5133d8b89ede · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: unknown · users: none · canonical: production_core
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
V6 = ROOT / "uk_energy_tracking_v6"
TARGET = V6 / "price_history_chart/render_price_chart/render_price_chart.js"
INDEX = V6 / "index.md"
REPORT = V6 / "V6_REPAIR_EVENT_BOXES_VISIBLE_REPORT.md"
for rel in [
"AI_START_HERE.md",
"uk_energy_tracking_v6/V6_ARCHITECTURAL_INTEGRITY_PROTOCOL.md",
"uk_energy_tracking_v6/V5_V6_COMPARISON_REPORT.md",
"uk_energy_tracking_v5/price-history-ui.js",
"uk_energy_tracking_v6/price_history_chart/render_price_chart/render_price_chart.js",
"uk_energy_tracking_v6/index.md",
]:
p = ROOT / rel
if not p.exists():
raise FileNotFoundError(f"Required file missing: {rel}")
p.read_text(encoding="utf-8")
text = TARGET.read_text(encoding="utf-8")
if "function drawHighAverageLowTrackers" not in text:
raise RuntimeError("Previous tracker function missing. Run or inspect high low tracker repair first.")
old_tracker = """ function drawHighAverageLowTrackers(g,s,q,w,h,pad,X,Y,isFull,isLandscape){if(isFull&&isLandscape)return;var avgX=(pad.left+w-pad.right)/2,avgY=Y(s.avg);var items=[{label:'HIGH',val:s.hiValue,date:s.hiDate,clock:s.hiClock,x:X(s.hi),y:Y(s.hiValue),kind:'edge'},{label:'AVERAGE',val:s.avg,date:'Visible period',clock:'',x:avgX,y:avgY,kind:'center'},{label:'LOW',val:s.loValue,date:s.l … [line shortened here: 959 characters; full line on GitHub]
"""
new_tracker = """ function drawHighAverageLowTrackers(g,s,q,w,h,pad,X,Y,isFull,isLandscape){if(isFull&&isLandscape)return;var avgX=(pad.left+w-pad.right)/2,avgY=Y(s.avg),top=pad.top,bottom=h-pad.bottom;var highX=X(s.hi),highY=Y(s.hiValue),lowX=X(s.lo),lowY=Y(s.loValue);var items=[{label:'HIGH',val:s.hiValue,date:s.hiDate,clock:s.hiClock,x:highX,y:highY,tx:Math.min(w-pad.right-150*q,highX+22*q),ty … [line shortened here: 966 characters; full line on GitHub]
"""
if old_tracker not in text:
raise RuntimeError("Expected previous tracker function not found. Refusing uncontrolled repair.")
text = text.replace(old_tracker, new_tracker, 1)
old_call = "drawHighAverageLowTrackers(g,s,q,w,h,pad,X,Y,isFull,isLandscape);drawSummary(g,s,q,w,h,pad,isFull,isLandscape);"
new_call = "if(isFull){drawSummary(g,s,q,w,h,pad,isFull,isLandscape);drawHighAverageLowTrackers(g,s,q,w,h,pad,X,Y,isFull,isLandscape)}else{drawHighAverageLowTrackers(g,s,q,w,h,pad,X,Y,isFull,isLandscape)}"
if old_call not in text:
raise RuntimeError("Expected tracker plus summary call not found. Refusing uncontrolled repair.")
text = text.replace(old_call, new_call, 1)
TARGET.write_text(text, encoding="utf-8")
updated = TARGET.read_text(encoding="utf-8")
for token in [
"if(isFull){drawSummary",
"else{drawHighAverageLowTrackers",
"top=pad.top,bottom=h-pad.bottom",
"ty:Math.max(top+70*q",
]:
if token not in updated:
raise RuntimeError(f"Post repair assertion failed: {token}")
idx = INDEX.read_text(encoding="utf-8")
old_src = "/uk_energy_tracking_v6/price_history_chart/render_price_chart/render_price_chart.js?v=20260602hilo1"
new_src = "/uk_energy_tracking_v6/price_history_chart/render_price_chart/render_price_chart.js?v=20260602boxes2"
if old_src in idx:
idx = idx.replace(old_src, new_src, 1)
elif new_src not in idx:
raise RuntimeError("Expected render script cache version not found")
INDEX.write_text(idx, encoding="utf-8")
REPORT.write_text("""# V6 Repair Report: Event Boxes Visible
Status: prepared by deterministic repair script.
## Problem observed
The previous high low tracker repair committed successfully, but the visual result did not show the floating boxes on the live V6 chart. The existing bottom summary box also remained in normal in-page mode.
## Behaviour changed
1. Repositions HIGH, AVERAGE and LOW tracker boxes inside the visible plot area using explicit top and bottom plot bounds.
2. Draws in-page tracker boxes without drawing the bottom summary box.
3. Keeps the fullscreen portrait bottom summary box, then draws tracker boxes above it.
4. Keeps fullscreen landscape clean by preserving the existing no-tracker behaviour there.
5. Bumps the V6 render script query string so the live page loads the corrected renderer.
## Files changed by workflow execution
1. `uk_energy_tracking_v6/price_history_chart/render_price_chart/render_price_chart.js`
2. `uk_energy_tracking_v6/index.md`
3. `uk_energy_tracking_v6/V6_REPAIR_EVENT_BOXES_VISIBLE_REPORT.md`
## Explicit non scope
No V5 file changed.
No CSS changed.
No data feed changed.
No forecast wiring changed.
No period dropdown changed.
## Required maintainer test
Open `/uk_energy_tracking_v6/`. In normal page mode confirm the old bottom summary box is gone and the HIGH, AVERAGE and LOW tracker boxes are visible on the chart. Then test fullscreen portrait and confirm the bottom summary box remains while chart tracker boxes are visible above it. Landscape should stay clean.
""", encoding="utf-8")
print("V6 event boxes visible repair prepared locally by script.")GlobalGrid2050 Repair V6 Fullscreen Summary Box
A Python module in the scripts folder.
renderglobalgrid2050 / scripts/repair_v6_fullscreen_summary_box.py · lines 1–80 of 80 · Entry point
- What it does
- It loads data. Uses libraries pathlib. Side effects: reads or writes files.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Repair V6 Fullscreen Summary Box Workflow (globalgrid2050).
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- Run by GlobalGrid2050 Repair V6 Fullscreen Summary Box Workflow.
- Application
- globalgrid2050 · scripts · Python module
- Uses
- pathlib
- Used by
- run by GlobalGrid2050 Repair V6 Fullscreen Summary Box Workflow (workflow run)
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/repair_v6_fullscreen_summary_box.py:1-80 · blob 34e71358ff9e06f0c5b9019aaf4caaee18699198 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: unknown · users: none · canonical: production_core
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
V6 = ROOT / "uk_energy_tracking_v6"
for rel in [
"AI_START_HERE.md",
"uk_energy_tracking_v6/V6_ARCHITECTURAL_INTEGRITY_PROTOCOL.md",
"uk_energy_tracking_v6/V5_V6_COMPARISON_REPORT.md",
"uk_energy_tracking_v6/price_history_chart/render_price_chart/render_price_chart.js",
]:
path = ROOT / rel
if not path.exists():
raise FileNotFoundError(f"Required file missing: {rel}")
path.read_text(encoding="utf-8")
protocol = (V6 / "V6_ARCHITECTURAL_INTEGRITY_PROTOCOL.md").read_text(encoding="utf-8")
if "Full screen, period arrows, mobile portrait, mobile landscape and desktop" not in protocol:
raise RuntimeError("V6 protocol fullscreen contract not recognised")
path = V6 / "price_history_chart/render_price_chart/render_price_chart.js"
text = path.read_text(encoding="utf-8")
old_summary = """ function drawSummary(g,s,q,w,h,pad,isFull){var boxH=(isFull?92:118)*q,y=h-pad.bottom+(isFull?44:64)*q,x=pad.left,bw=w-pad.left-pad.right;if(!isFull)y=h-128*q;g.save();g.fillStyle='rgba(5,7,12,.82)';g.strokeStyle='rgba(0,255,255,.35)';g.lineWidth=1*q;g.shadowColor='rgba(0,255,255,.18)';g.shadowBlur=8*q;g.beginPath();g.roundRect(x,y,bw,boxH,8*q);g.fill();g.stroke();g.shadowBlur=0; … [line shortened here: 1,311 characters; full line on GitHub]
"""
new_summary = """ function drawSummary(g,s,q,w,h,pad,isFull){var boxH=(isFull?92:118)*q,y=h-pad.bottom+(isFull?64:64)*q,x=pad.left,bw=w-pad.left-pad.right;if(isFull)y=h-pad.bottom+66*q;if(!isFull)y=h-128*q;g.save();g.fillStyle='rgba(5,7,12,.86)';g.strokeStyle='rgba(0,255,255,.42)';g.lineWidth=1*q;g.shadowColor='rgba(0,255,255,.20)';g.shadowBlur=8*q;g.beginPath();g.roundRect(x,y,bw,boxH,8*q);g.fil … [line shortened here: 1,506 characters; full line on GitHub]
"""
old_pad = """var pad=isFull?{left:58*q,right:18*q,top:112*q,bottom:176*q}:{left:74*q,right:24*q,top:96*q,bottom:284*q};"""
new_pad = """var pad=isFull?{left:58*q,right:18*q,top:112*q,bottom:260*q}:{left:74*q,right:24*q,top:96*q,bottom:284*q};"""
if old_summary not in text:
raise RuntimeError("Expected V6 drawSummary function not found. Refusing uncontrolled repair.")
if old_pad not in text:
raise RuntimeError("Expected V6 fullscreen pad expression not found. Refusing uncontrolled repair.")
text = text.replace(old_summary, new_summary, 1)
text = text.replace(old_pad, new_pad, 1)
path.write_text(text, encoding="utf-8")
updated = path.read_text(encoding="utf-8")
for token in ["row('High'", "row('Average'", "row('Low'", "bottom:260*q", "isFull?7.7"]:
if token not in updated:
raise RuntimeError(f"Post repair assertion failed: {token}")
report = V6 / "V6_REPAIR_FULLSCREEN_SUMMARY_BOX_REPORT.md"
report.write_text("""# V6 Repair Report: Fullscreen Summary Box
Status: prepared by deterministic repair script.
## Scope
This repair improves the V6 electricity price fullscreen chart summary box.
## Behaviour changed
1. Moves the fullscreen summary box higher above the mobile browser bottom bar.
2. Increases fullscreen bottom chart padding so the axis date and summary box no longer collide.
3. Renders one clean line each for High, Average and Low.
4. Spells out High, Average and Low in the fullscreen summary box.
## Files changed by workflow execution
1. `uk_energy_tracking_v6/price_history_chart/render_price_chart/render_price_chart.js`
2. `uk_energy_tracking_v6/V6_REPAIR_FULLSCREEN_SUMMARY_BOX_REPORT.md`
## Explicit non scope
No data paths changed.
No forecast logic changed.
No V5 file changed.
## Required maintainer test
Open `/uk_energy_tracking_v6/`, enter fullscreen on mobile and verify that the bottom date, axis and summary box are readable without awkward clipping.
""", encoding="utf-8")
print("V6 fullscreen summary box repair completed locally by script.")GlobalGrid2050 Repair V6 Fullscreen Swipe
A Python module in the scripts folder.
interactionglobalgrid2050 / scripts/repair_v6_fullscreen_swipe.py · lines 1–71 of 71 · Entry point
- What it does
- It loads data. Uses libraries pathlib. Side effects: changes the web page (DOM); reads or writes files.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Repair V6 Fullscreen Swipe Workflow (globalgrid2050).
- What it achieves
- It writes `uk_energy_tracking_v6/V6_REPAIR_FULLSCREEN_SWIPE_REPORT.md`.
- Why it matters
- Run by GlobalGrid2050 Repair V6 Fullscreen Swipe Workflow.
- Application
- globalgrid2050 · scripts · Python module
- Uses
- pathlib
- Used by
- run by GlobalGrid2050 Repair V6 Fullscreen Swipe Workflow (workflow run)
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/repair_v6_fullscreen_swipe.py:1-71 · blob 0dee8b3e7558930c3e98e49c2e3dc44ee6b46747 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: unknown · users: none · canonical: production_core
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
V6 = ROOT / "uk_energy_tracking_v6"
for rel in [
"AI_START_HERE.md",
"uk_energy_tracking_v6/V6_ARCHITECTURAL_INTEGRITY_PROTOCOL.md",
"uk_energy_tracking_v6/V5_V6_COMPARISON_REPORT.md",
"uk_energy_tracking_v6/price_history_chart/control_price_history/control_price_history.js",
]:
path = ROOT / rel
if not path.exists():
raise FileNotFoundError(f"Required file missing: {rel}")
path.read_text(encoding="utf-8")
protocol = (V6 / "V6_ARCHITECTURAL_INTEGRITY_PROTOCOL.md").read_text(encoding="utf-8")
if "Full screen, period arrows, mobile portrait, mobile landscape and desktop" not in protocol:
raise RuntimeError("V6 protocol fullscreen contract not recognised")
path = V6 / "price_history_chart/control_price_history/control_price_history.js"
text = path.read_text(encoding="utf-8")
if "attachFullscreenSwipe" in text:
raise RuntimeError("Fullscreen swipe already appears to be installed")
old = """ function closeFullscreen(){var o=$('price-history-fullscreen-overlay');if(!o)return;o.classList.remove('open');document.documentElement.classList.remove('v5-chart-open');document.body.classList.remove('v5-chart-open')}
function start(){ensureYearOptions();ensureModeTabs();ensurePeriodControls();ensureStartDate();attachPeriodButtons('price-history-fullscreen-period');var btn=$('price-history-refresh'),period=$('price-history-period'),startEl=$('price-history-start'),year=$('price-history-year');if(btn)btn.addEventListener('click',load);if(period)period.addEventListener('change',load);if(startEl)startEl.addEvent … [line shortened here: 799 characters; full line on GitHub]
"""
new = """ function closeFullscreen(){var o=$('price-history-fullscreen-overlay');if(!o)return;o.classList.remove('open');document.documentElement.classList.remove('v5-chart-open');document.body.classList.remove('v5-chart-open')}
function attachFullscreenSwipe(){var c=$('price-history-fullscreen-canvas');if(!c||c.dataset.swipeBound)return;c.dataset.swipeBound='1';var sx=0,sy=0,active=false;c.addEventListener('touchstart',function(e){if(!e.touches||!e.touches.length)return;var t=e.touches[0];sx=t.clientX;sy=t.clientY;active=true},{passive:true});c.addEventListener('touchend',function(e){if(!active)return;active=false;var … [line shortened here: 587 characters; full line on GitHub]
function start(){ensureYearOptions();ensureModeTabs();ensurePeriodControls();ensureStartDate();attachPeriodButtons('price-history-fullscreen-period');attachFullscreenSwipe();var btn=$('price-history-refresh'),period=$('price-history-period'),startEl=$('price-history-start'),year=$('price-history-year');if(btn)btn.addEventListener('click',load);if(period)period.addEventListener('change',load);if( … [line shortened here: 823 characters; full line on GitHub]
"""
if old not in text:
raise RuntimeError("Expected control file structure not found. Refusing uncontrolled swipe patch.")
text = text.replace(old, new, 1)
path.write_text(text, encoding="utf-8")
updated = path.read_text(encoding="utf-8")
for token in ["attachFullscreenSwipe", "touchstart", "touchend", "nudgePeriod(dx<0?1:-1)"]:
if token not in updated:
raise RuntimeError(f"Post repair assertion failed: {token}")
report = V6 / "V6_REPAIR_FULLSCREEN_SWIPE_REPORT.md"
report.write_text("""# V6 Repair Report: Fullscreen Swipe
Status: prepared by deterministic repair script.
## Scope
This repair adds left and right touch swipe handling to the V6 electricity price fullscreen canvas.
## Files changed by workflow execution
1. `uk_energy_tracking_v6/price_history_chart/control_price_history/control_price_history.js`
2. `uk_energy_tracking_v6/V6_REPAIR_FULLSCREEN_SWIPE_REPORT.md`
## Explicit non scope
No V5 panels were restored.
No forecast logic was changed.
No V5 file was modified.
## Required maintainer test
Open `/uk_energy_tracking_v6/`, enter fullscreen chart on a mobile device, swipe left and right, and confirm the period changes exactly as the visible arrows do.
""", encoding="utf-8")
print("V6 fullscreen swipe repair completed locally by script.")