"""Explicit byte-only packages with no xattrs/AppleDouble."""
from pathlib import Path
import tarfile,io,json,hashlib,shutil
HERE=Path(__file__).resolve().parent;RUN=Path('/tmp/cdx-ai-api-customer-read12-20261011')
for p in (HERE/'tools').iterdir():
 if p.is_file():shutil.copyfile(p,RUN/p.name)
for lane in ['B','C']:
 entries={p.name:p for p in RUN.iterdir() if p.is_file()}
 entries.update({p.relative_to(RUN).as_posix():p for p in (RUN/'source').rglob('*') if p.is_file()})
 entries.update({'private/'+p.name:p for p in (RUN/f'seed-{lane}').iterdir() if p.is_file()})
 root=RUN.name;dirs={root,root+'/private'}
 for n in entries:dirs.update(str(q) for q in (Path(root)/n).parents if str(q)!='.')
 target=Path('/tmp/cdx-ai-customer-read-'+lane+'.tar')
 with tarfile.open(target,'w',format=tarfile.USTAR_FORMAT) as t:
  for n in sorted(dirs):i=tarfile.TarInfo(n);i.type=tarfile.DIRTYPE;i.mode=0o700;t.addfile(i)
  for n,p in sorted(entries.items()):raw=p.read_bytes();i=tarfile.TarInfo(root+'/'+n);i.size=len(raw);i.mode=0o600;t.addfile(i,io.BytesIO(raw))
 target.chmod(0o600);print(json.dumps({'lane':lane,'entries':len(entries),'SHA':hashlib.sha256(target.read_bytes()).hexdigest(),'SQL':0,'HTTP':0}))
