import os, json, subprocess
pool = os.path.normcase(os.path.normpath('C:/actions-runner/_work/spt-bs-core/spt-bs-core/target'))
links, errors = [], []
for base in ['C:/actions-runner', 'C:/Users/decid/Documents/projects']:
    for root, dirs, files in os.walk(base, followlinks=False, onerror=lambda e: errors.append(str(e))):
        kept = []
        for d in dirs:
            p = os.path.join(root, d)
            if os.path.isjunction(p) or os.path.islink(p):
                resolved = os.path.normcase(os.path.realpath(p))
                if resolved == pool or resolved.startswith(pool + os.sep):
                    links.append({'link': p, 'target': resolved})
            else:
                kept.append(d)
        dirs[:] = kept
result = {'roots': ['C:/actions-runner', 'C:/Users/decid/Documents/projects'], 'inbound_links': links, 'errors': errors}
print(json.dumps(result), flush=True)
with open('.spt/preserved/deployah-v069-release-20260911/pool-inbound-audit.json', 'w') as f:
    json.dump(result, f, indent=2)
