"""Zero DEC10,2 source behavior, preserving MySQL empty('0.00') == false."""
import importlib.util,json,hashlib
from pathlib import Path
HERE=Path(__file__).resolve().parent
def module(path,name):
    spec=importlib.util.spec_from_file_location(name,path);m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);return m
positive=module(HERE.parent/'oracle.py','positive_oracle')
team=module(HERE.parent/'../parallel-store-nutrition-reports-read24-20261011/remaining20/verify.py','original_team_oracle')
def oracle(s,d):
    # The direct zero divisor yields INF; TeamProtein's original serialization
    # replaces INF/NAN with zero after its zong_protein > 0 modal classification.
    t=team.oracle(s)['TeamProtein'];p=t['data'][0][0];modal=t['data'][3][0]
    for r in [p,modal]:
        for k,v in r.items():
            if type(v) in [int,float]:r[k]=0
    # Onto Protein exclusively uses divScale, whose zero denominator returns 0.
    o=positive.oracle(s,d)['Protein']
    for key in ['morning','noon','night','all']:
        row=o['data'][key];row['all_sum']=0;row['yiban']['yiban_sum']=0;row['yiban']['yibandanbai']['gulei']=0
    # The two stage methods retain direct division and cannot serialize INF/NaN.
    error={'code':'2','message':'Inf and NaN cannot be JSON encoded','data':[]}
    return {'TeamProtein':{'status':200,'body':t},'StageTeamProtein':{'status':404,'body':error},'Protein':{'status':200,'body':o},'Stage_protein':{'status':404,'body':error.copy()}}
if __name__=='__main__':
    for lane in ['B','C']:
        source=HERE.parent/'clientheaders/private'/lane;s=json.loads((source/'batch-after10.json').read_text());d=json.loads((source/'dictionary.json').read_text());out=oracle(s,d)
        p=HERE/'private'/lane;p.mkdir(parents=True,exist_ok=True);p.chmod(0o700);f=p/'expected-before-zero-http.json'
        assert not f.exists(),'Frozen zero oracle immutable';f.write_text(json.dumps(out,ensure_ascii=False,indent=2)+'\n');f.chmod(0o600);print(json.dumps(dict(lane=lane,methods=4,sha256=hashlib.sha256(f.read_bytes()).hexdigest(),HTTP=0,DML=0)))
