the-custodian/docs/changes/netkingdom-target-2026-10-17/key39-finalization-scope-clarification-r1/apply.py
codex 423b815782
Some checks are pending
CI Smoke / host-smoke (push) Waiting to run
CI Smoke / container-smoke (push) Waiting to run
Reject generated-only commits / generated-commit-guard (push) Waiting to run
docs: preserve reviewed NetKingdom session artifacts
2026-11-01 23:27:08 +01:00

23 lines
2.7 KiB
Python

from pathlib import Path
import subprocess,json,hashlib,re,yaml,difflib
root=Path('/home/worsch/key-cape');out=Path('/home/worsch/the-custodian/docs/changes/netkingdom-target-2026-10-17/key39-finalization-scope-clarification-r1');out.mkdir()
rel='workplans/KEY-WP-0039-openbao-negative-probe-tokens.md';p=root/rel
def git(*args):return subprocess.check_output(['git','-C',str(root),*args]).decode()
base=git('rev-parse','HEAD').strip();assert base=='40de616e078906e04c692edf7cb7a8bfbc07b5ea';assert not git('status','--porcelain=v1')
before=p.read_text();old='''source acceptance, resolved registration go caafe4be and the standing attended
rule remain valid; no new protocol or blanket approval request is needed. The
''';new='''source acceptance remains valid. Resolved registration go caafe4be covers only
the original secrets-engine-openbao client (KEY-WP-0037-T03, deployed 6f79a2af,
NK-WP-0046 exact-match helper); it does not authorize new probe clients or
coding-client custody, and no renewed original-client approval is requested.
The standing attended rule remains separate, for reviewed commands within
existing scope; no new protocol or blanket approval request is introduced. The
''';assert before.count(old)==1;after=before.replace(old,new)
blocks=lambda text:re.findall(r'^```task\n.*?^```',text,re.M|re.S)
assert blocks(before)==blocks(after);assert before.split('---',2)[1]==after.split('---',2)[1]
(out/'KEY39.preimage.md').write_text(before);(out/'KEY39.proposed.md').write_text(after)
readback=Path('/home/worsch/the-custodian/docs/changes/netkingdom-target-2026-10-17/key39-finalization-owner-followthrough-r1/registration-approval-readback.json')
baseline={'base_commit':base,'branch':git('branch','--show-current').strip(),'status':git('status','--porcelain=v1'),'index':git('ls-files','--stage'),'path':rel,'before_sha256':hashlib.sha256(before.encode()).hexdigest(),'after_sha256':hashlib.sha256(after.encode()).hexdigest(),'frontmatter':yaml.safe_load(before.split('---',2)[1]),'task_blocks':[yaml.safe_load(t.split('\n',1)[1].rsplit('```',1)[0]) for t in blocks(before)],'approval_scope_source':{'path':str(readback),'sha256':hashlib.sha256(readback.read_bytes()).hexdigest()},'assessment':'Clarification needed because previous coordinator wording grouped original-client go with standing rule without naming its object; no historical approval revoked or expanded.'};(out/'baseline.json').write_text(json.dumps(baseline,indent=2)+'\n')
p.write_text(after);(out/'one-path.patch').write_text(git('diff','--',rel));assert git('diff','--name-only').splitlines()==[rel]
print(json.dumps({'status':'current paragraph scope clarified','frontmatter_and_three_blocks_unchanged':True,'base':base}))