"""Recover HeatWatch author-chart evidence without evaluating workbook formulas. This is a bounded OOXML reader for the pinned author artifact, not an Excel engine or a raw-NAND dataset loader. Original XML numeric strings are retained. """ import argparse from decimal import Decimal, localcontext import hashlib import io import json import math from pathlib import Path import posixpath import re import zipfile import xml.etree.ElementTree as ET URL = "https://people.inf.ethz.ch/omutlu/pub/heatwatch-3D-nand-errors-and-self-recovery_hpca18_talk.pptx" EXPECTED_SHA256 = "a64090138056a11afe8f768f19cd555ce3f92b022a3a4998c53319fcce06c3ed" NS = { "a": "http://schemas.openxmlformats.org/drawingml/2006/main", "c": "http://schemas.openxmlformats.org/drawingml/2006/chart", "p": "http://schemas.openxmlformats.org/presentationml/2006/main", "s": "http://schemas.openxmlformats.org/spreadsheetml/2006/main", "r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships", } RID = "{" + NS["r"] + "}id" def require(condition, message): if not condition: raise ValueError(message) def sha(data): return hashlib.sha256(data).hexdigest() def relationships(z, part): parent, name = posixpath.split(part) relpart = posixpath.join(parent, "_rels", name + ".rels") root = ET.fromstring(z.read(relpart)) result = {} for rel in root: target = rel.attrib["Target"] if rel.attrib.get("TargetMode") == "External": result[rel.attrib["Id"]] = {"external": target} else: path = posixpath.normpath(posixpath.join(parent, target)) require(not path.startswith("../") and not path.startswith("/"), "Relationship escaped the package") result[rel.attrib["Id"]] = {"part": path} return result def workbook(data): with zipfile.ZipFile(io.BytesIO(data)) as z: strings = [] if "xl/sharedStrings.xml" in z.namelist(): strings = ["".join(e.itertext()) for e in ET.fromstring(z.read("xl/sharedStrings.xml"))] rels = relationships(z, "xl/workbook.xml") sheets = {} for sheet in ET.fromstring(z.read("xl/workbook.xml")).findall("s:sheets/s:sheet", NS): part = rels[sheet.attrib[RID]]["part"] cells = {} for cell in ET.fromstring(z.read(part)).findall(".//s:sheetData/s:row/s:c", NS): kind = cell.get("t", "n") raw = cell.findtext("s:v", namespaces=NS) if kind == "s": value = strings[int(raw)] elif kind == "inlineStr": value = "".join(cell.find("s:is", NS).itertext()) else: value = raw formula = cell.find("s:f", NS) cells[cell.attrib["r"]] = { "type": kind, "xml_value": raw, "value": value, "formula": None if formula is None else { "text": formula.text or "", "attributes": dict(formula.attrib) } } sheets[sheet.attrib["name"]] = {"part": part, "cells": cells} return sheets def cache(series, axis): ref = series.find("c:" + axis, NS) require(ref is not None and len(ref) == 1, "Missing or unsupported chart reference") ref = ref[0] formula = ref.findtext("c:f", namespaces=NS) cached = next((e for e in ref if e.tag.endswith("Cache")), None) require(cached is not None, "Missing chart cache") points = {int(p.attrib["idx"]): p.findtext("c:v", namespaces=NS) for p in cached.findall("c:pt", NS)} count = int(cached.find("c:ptCount", NS).attrib["val"]) require(sorted(points) == list(range(count)), "Sparse/duplicate chart cache") return {"reference": formula, "values": [points[i] for i in range(count)]} def extract(data): with zipfile.ZipFile(io.BytesIO(data)) as z: rels = relationships(z, "ppt/presentation.xml") slides = ET.fromstring(z.read("ppt/presentation.xml")).findall("p:sldIdLst/p:sldId", NS) charts = [] for ordinal, slide in enumerate(slides, 1): part = rels[slide.attrib[RID]]["part"] xml = ET.fromstring(z.read(part)) slide_rels = relationships(z, part) for chart_link in xml.findall(".//c:chart", NS): chart_part = slide_rels[chart_link.attrib[RID]]["part"] chart_bytes = z.read(chart_part) chart = ET.fromstring(chart_bytes) external = chart.find("c:externalData", NS) require(external is not None, "No embedded workbook reference") book_part = relationships(z, chart_part)[external.attrib[RID]]["part"] book_bytes = z.read(book_part) series = [] # Deliberately exclude c15:filteredBarSeries from displayed data. for ser in chart.findall(".//c:plotArea/c:scatterChart/c:ser", NS): series.append({"kind": "scatter", "label": cache(ser, "tx"), "x": cache(ser, "xVal"), "y": cache(ser, "yVal")}) for ser in chart.findall(".//c:plotArea/c:barChart/c:ser", NS): series.append({"kind": "bar", "label": cache(ser, "tx"), "x": cache(ser, "cat"), "y": cache(ser, "val")}) require(series, "No supported displayed series") charts.append({ "slide": ordinal, "slide_part": part, "slide_text": [t.text for t in xml.findall(".//a:t", NS)], "chart_part": chart_part, "chart_sha256": sha(chart_bytes), "workbook_part": book_part, "workbook_sha256": sha(book_bytes), "axes": ["".join(e.itertext()) for e in chart.findall(".//c:valAx/c:title/c:tx/c:rich", NS)], "series": series, "sheets": workbook(book_bytes) }) return {"source_sha256": sha(data), "source_bytes": len(data), "charts": charts} def geomean(values): require(len(values) > 0, "Empty geometric mean") values = [float(v) for v in values] require(all(math.isfinite(v) and v > 0 for v in values), "Nonpositive/nonfinite geometric mean") return math.exp(math.fsum(math.log(v) for v in values) / len(values)) def formula_range(cell): formula = cell["formula"] require(formula is not None, "Expected formula") match = re.fullmatch(r"GEOMEAN\(([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)\)", formula["text"]) require(match is not None and match[1] == match[3], "Unsupported GEOMEAN formula") return match[1], int(match[2]), int(match[4]) def audit(packet): require([c["slide"] for c in packet["charts"]] == [16, 17, 18, 57], "Chart/slide mapping changed") checks = 0 for chart in packet["charts"][:3]: cells = chart["sheets"]["Sheet1"]["cells"] ser, = chart["series"] require(ser["x"]["reference"] == "Sheet1!$A$2:$A$9", "Unexpected x range") require(ser["y"]["reference"] == "Sheet1!$B$2:$B$9", "Unexpected y range") require(len(ser["x"]["values"]) == len(ser["y"]["values"]) == 8, "Point count changed") for i, (x, y) in enumerate(zip(ser["x"]["values"], ser["y"]["values"]), 2): require(Decimal(x) == Decimal(cells[f"A{i}"]["value"]), "Scatter x mismatch") require(Decimal(y) == Decimal(cells[f"B{i}"]["value"]), "Scatter y mismatch") checks += 2 chart = packet["charts"][3] cells = chart["sheets"]["Sheet1"]["cells"] labels = {cells[f"A{i}"]["value"]: i for i in range(2, 32)} require(len(labels) == 30 and labels.get("mixed") == 30 and labels.get("GMean") == 31, "Workload identities changed") require(formula_range(cells["B31"]) == ("B", 2, 29), "Dwell summary cohort changed") require(formula_range(cells["C31"]) == ("C", 2, 29), "Lifetime summary cohort changed") shared = cells["C31"]["formula"]["attributes"] require(shared.get("ref") == "C31:G31" and shared.get("t") == "shared", "Shared formula range changed") for col in "DEFG": f = cells[col + "31"]["formula"] require(f is not None and f["text"] == "" and f["attributes"].get("si") == shared["si"] and f["attributes"].get("t") == "shared", "Unresolved shared formula") for col in "BCDEFG": expected = geomean([cells[f"{col}{i}"]["value"] for i in range(2, 30)]) require(math.isclose(expected, float(cells[col + "31"]["value"]), rel_tol=2e-14), "GEOMEAN cached result mismatch") cache_rows = None column_for = {"Fixed Vref": "D", "Retention-Only": "F", "HeatWatch": "G", "Oracle": "E"} require(len(chart["series"]) == 4, "Lifetime series count changed") for ser in chart["series"]: label, = ser["label"]["values"] col = column_for[label] require(ser["y"]["reference"] == f"Sheet1!\u0024{col}\u00242:\u0024{col}\u002431", "Lifetime formula changed") cats, vals = ser["x"]["values"], ser["y"]["values"] require(len(cats) == len(vals) == 14 and len(set(cats)) == 14, "Filtered cache cardinality changed") rows = [labels[x] for x in cats] if cache_rows is None: cache_rows = rows require(rows == cache_rows, "Displayed categories differ between series") # Cache indices are compacted after chart filtering. Join by exact label, # never pretend cache index k means worksheet row k+2. for row, value in zip(rows, vals): require(Decimal(value) == Decimal(cells[f"{col}{row}"]["value"]), "Lifetime chart/workbook mismatch") checks += 1 require(cache_rows[-1] == 31 and 30 not in cache_rows, "Mixed row in displayed cohort") cohort = list(range(2, 30)) visible = [r for r in cache_rows if r != 31] ratios = [float(cells[f"G{i}"]["value"]) / float(cells[f"D{i}"]["value"]) for i in cohort] ratio = geomean(ratios) for cell, formula, numerator, denominator in [ ("E32", "E31/D31", "E31", "D31"), ("F32", "F31/D31", "F31", "D31"), ("G32", "G31/D31", "G31", "D31"), ("G33", "G31/F31", "G31", "F31")]: require(cells[cell]["formula"]["text"] == formula, "Summary ratio formula changed") require(math.isclose(float(cells[cell]["value"]), float(cells[numerator]["value"]) / float(cells[denominator]["value"]), rel_tol=2e-14), "Ratio cache mismatch") require(math.isclose(ratio, float(cells["G32"]["value"]), rel_tol=2e-14), "Ratio GEOMEAN mismatch") with localcontext() as ctx: ctx.prec = 60 product = Decimal(1) for i in cohort: product *= Decimal(cells[f"G{i}"]["value"]) / Decimal(cells[f"D{i}"]["value"]) decimal_ratio = product ** (Decimal(1) / Decimal(len(cohort))) require(abs(Decimal(str(ratio)) - decimal_ratio) < Decimal("2e-14"), "Independent product-root mismatch") return { "schema_version": 1, "source_url": URL, "source_sha256": packet["source_sha256"], "source_bytes": packet["source_bytes"], "evidence_class": "author-presentation-derived chart values and arithmetic", "raw_measurements_recovered": False, "model_or_hardware_replication": False, "upstream_redistribution_license": "not established", "charts": [{"slide": c["slide"], "chart_part": c["chart_part"], "chart_sha256": c["chart_sha256"], "workbook_part": c["workbook_part"], "workbook_sha256": c["workbook_sha256"]} for c in packet["charts"]], "numeric_cache_cell_checks": checks, "lifetime": { "unit": "model-estimated P/E cycles, not observed service years", "workload_range": "Sheet1!A2:G29", "workload_count": len(cohort), "mixed_row": 30, "summary_row": 31, "summary_formula": "GEOMEAN(G2:G29)/GEOMEAN(D2:D29)", "heatwatch_over_fixed_vref": ratio, "decimal_product_root_crosscheck": str(decimal_ratio), "mixed_heatwatch_over_fixed_vref": float(cells["G30"]["value"]) / float(cells["D30"]["value"]), "displayed_workload_count": len(visible), "displayed_aggregate_count": 1, "displayed_workbook_rows": cache_rows, "displayed_subset_geomean_ratio": geomean([float(cells[f"G{i}"]["value"]) / float(cells[f"D{i}"]["value"]) for i in visible]), "arithmetic_mean_per_workload_ratio": math.fsum(ratios) / len(ratios), "ratio_of_summed_endpoints": math.fsum(float(cells[f"G{i}"]["value"]) for i in cohort) / math.fsum(float(cells[f"D{i}"]["value"]) for i in cohort), }, "limitations": [ "Workbook rows are already reduced or modeled results, not raw cells, chips or traces.", "Shared formula bodies are preserved; only the explicit known GEOMEAN group is checked.", "Chart-cache agreement checks package consistency, not truth of the experiment.", "No uncertainty interval or chip-level sample size can be recovered from these rows.", "Do not infer seconds for unlabeled workbook time columns without independent support." ] } def main(): parser = argparse.ArgumentParser() parser.add_argument("pptx", type=Path) parser.add_argument("--output", type=Path, required=True) parser.add_argument("--private-extraction", type=Path) args = parser.parse_args() data = args.pptx.read_bytes() require(sha(data) == EXPECTED_SHA256, "Source version differs from reviewed artifact") packet = extract(data) result = audit(packet) args.output.write_text(json.dumps(result, indent=2, sort_keys=True) + "\n", encoding="utf-8") if args.private_extraction: args.private_extraction.write_text(json.dumps(packet, indent=2, sort_keys=True) + "\n", encoding="utf-8") print(json.dumps(result["lifetime"], indent=2)) if __name__ == "__main__": main()