"""Golden corpus layer definitions (spec 19, G01-G17). Case inputs live in tests/golden/cases/*.txt (committed; the repo ignores *.csv so fixtures use .txt). Expected outputs live in tests/golden/expected/*.json. Expected content ids are computed with the INDEPENDENT verifier (engine.verify.vparse) and anchored by hand-computed primitive values (epoch ms / micro prices); the runner then requires producer == verifier == expected. """ # Hand-computed anchors (independent truth for tiny inputs): # 2023-01-02 03:04:05.100 UTC -> 1672628645100 ms # 2023-01-01 00:00:00.000 UTC -> 1672531200000 ms # "100.000000" * 1e6 = 100_000_000 ; "100.000100" = 100_000_100 ANCHOR_TS = 1672628645100 ANCHOR_TS_2023_01_01 = 1672531200000 ANCHOR_BID = 100000000 ANCHOR_ASK = 100000100 GOLDEN_TIMEFRAMES = ["M1", "M5", "M15", "M30", "H1"] # Default golden config (test-established tz offset = 0 UTC; has_volume False) def golden_cfg(chunk_bytes=25_165_824, tz_offset=0): return { "source_tz_offset_minutes": tz_offset, "has_volume": False, "timeframes": list(GOLDEN_TIMEFRAMES), "chunk_bytes_nominal": chunk_bytes, "workload_bytes_nominal": 536_870_912, } G01_ROWS = [ "2023.01.02 03:04:05.100,100.000000,100.000100", "2023.01.02 03:04:05.200,100.000100,100.000200", "2023.01.02 03:04:05.300,100.000200,100.000300", "2023.01.02 03:04:05.400,100.000300,100.000400", ] G03_ROWS = [ "datetime,bid,ask", "2023.01.02 03:04:05.100,100.000000,100.000100", "2023.01.02 03:04:05.200,100.000100,100.000200", ] G05_ROWS = list(G01_ROWS) # 45 chars + LF = 46 bytes per line G07_ROWS = [ "2023.13.01 00:00:00.000,100.000000,100.000100", "2023.01.01 25:00:00.000,100.000000,100.000100", "garbage,100.000000,100.000100", "2023.01.01 00:00:00.000,100.000000,100.000100", "1999.12.31 23:59:59.999,100.000000,100.000100", ] G08_ROWS = [ "2023.01.01 00:00:00.000,abc,100.000100", "2023.01.01 00:00:01.000,-1.5,100.000100", "2023.01.01 00:00:02.000,1.23456789,100.000100", "2023.01.01 00:00:03.000,0.000000,100.000100", "2023.01.01 00:00:04.000,100.000000,100.000100", ] G09_ROWS = [ "2023.01.01 00:00:00.000,100.000100,100.000000", "2023.01.01 00:00:01.000,100.000000,100.000100", ] G10_ROWS = [ "2023.01.01 00:00:00.000,100.000000,100.000100", "2023.01.01 00:00:00.000,100.000000,100.000100", "2023.01.01 00:00:01.000,100.000000,100.000100", ] G11_ROWS = [ "2023.01.01 00:00:00.000,100.000000,100.000100", "2023.01.01 00:00:01.000,100.000100,100.000200", "2023.01.01 00:00:02.000,100.000200,100.000300", ] G12_ROWS = [ "2023.01.01 00:00:03.000,100.000300,100.000400", "2023.01.01 00:00:02.000,100.000100,100.000200", "2023.01.01 00:00:04.000,100.000000,100.000100", ] G17_ROWS = [ "1672628645100|100000000|100000100|1", ] def case_bytes(case_id): """Return the case input bytes, exactly as committed.""" if case_id == "G01": return ("\r\n".join(G01_ROWS) + "\r\n").encode("utf-8") if case_id == "G02": return ("\n".join(G01_ROWS) + "\n").encode("utf-8") if case_id == "G03": return ("\n".join(G03_ROWS) + "\n").encode("utf-8") if case_id == "G04": return ("\n".join(G01_ROWS[:2]) + "\n").encode("utf-8") if case_id in ("G05", "G13"): return ("\n".join(G05_ROWS) + "\n").encode("utf-8") if case_id == "G06": return ("\n".join(G05_ROWS) + "\n").encode("utf-8") if case_id == "G07": return ("\n".join(G07_ROWS) + "\n").encode("utf-8") if case_id == "G08": return ("\n".join(G08_ROWS) + "\n").encode("utf-8") if case_id == "G09": return ("\n".join(G09_ROWS) + "\n").encode("utf-8") if case_id == "G10": return ("\n".join(G10_ROWS) + "\n").encode("utf-8") if case_id == "G11": return ("\n".join(G11_ROWS) + "\n").encode("utf-8") if case_id == "G12": return ("\n".join(G12_ROWS) + "\n").encode("utf-8") if case_id == "G17": return ("\n".join(G17_ROWS) + "\n").encode("utf-8") raise KeyError(case_id) def case_chunk_nominal(case_id): if case_id in ("G05", "G13"): return 46 # exact boundary on line end (G05) / multi-chunk (G13) if case_id == "G06": return 40 # boundary lands inside a line return 25_165_824