import re,sys
p='traceable-reqs.toml'
b=open(p,'rb').read().decode('utf-8')
disp=open(r'C:/Users/decid/Documents/projects/spt-core/.spt/preserved/331/dispatch-todlando-w5.md',encoding='utf-8').read()
title=re.search(r'^title = (".*")$',disp,re.M).group(1)
assert '"' not in title[1:-1], "a real quote inside the title kills the TOML parse"
block=('[[requirements]]\r\nid = "REQ-BUNDLE-APPLY-MEMBERS"\r\ntitle = '+title+'\r\n'
 'required_stages = ["doc", "impl", "unit", "int"]  # ACTIVATED #331 W5 (todlando 2026-09-24, seed text doyle dispatch-todlando-w5.md verbatim). doc = docs-site self-update bundled-adapters section; impl = relcache stage/retain bundle, cli.rs fetch leg + land_staged_bundle + member install/upgrade through complete_adapter_add / update_one_adapter, registry built_in mark, propagate/pump peer bundle pull; unit = the four dispatch rows (bundle-less set no-op, ./ prefix with bare-name negative control, equal-or-newer untouched, member sha mismatch registers nothing); int = bundled_adapters_e2e (also discharges REQ-BUNDLE-RELEASE-ASSET int).\r\n\r\n')
anchor='[[requirements]]\r\nid = "REQ-RELEASE-CHANNEL-PRIVATE"'
assert b.count(anchor)==1
b=b.replace(anchor,block+anchor)
g='  "REQ-BUNDLE-RELEASE-ASSET",\r\n'
assert b.count(g)==1
b=b.replace(g,'  "REQ-BUNDLE-APPLY-MEMBERS",\r\n'+g)
open(p,'wb').write(b.encode('utf-8'))
print("ok")
