feat(editorial): wire serialized Stage runtime install and PMO proposal client

This commit is contained in:
devops committed 2026-10-24 03:41:11 +00:00
1 parent 8869ce2583
commit f7cf2c8f5d
8 files changed
+387 -4

No files matched your search

+4 -2
View File
@@ -28,16 +28,18 @@ class WiringTests(unittest.TestCase):
db.execute("INSERT INTO sessions VALUES ('cli',1,2,3,0.1,'PRIVATE TITLE')");db.commit();db.close()
helper=repo/'scripts/rollout-stage.sh'
helper.write_text(helper.read_text().replace('/opt/services/canina/stage-runtime',str(root)))
editorial=repo/'scripts/provision-editorial-runtime.py'
editorial.write_text(editorial.read_text().replace('/opt/services/canina/stage-runtime',str(root)))
def git(*args):return subprocess.check_output(['git',*args],cwd=repo,text=True).strip()
git('init','-q');git('config','user.email','fixture@example.invalid');git('config','user.name','Fixture');git('add','.');git('commit','-qm','fixture')
sha=git('rev-parse','HEAD')
subject='12345678-1234-1234-1234-123456789abc'
fixture={'backend':{'Config':{'User':'node'},'HostConfig':{'UsernsMode':''},'State':{'Running':True,'Pid':os.getpid()}},'hermes':{'Config':{'Env':['HERMES_HOME=/home/runtime']},'Mounts':[{'Type':'bind','Destination':'/home','Source':str(base)}]}}
fixture={'backend':{'Config':{'User':'node'},'HostConfig':{'UsernsMode':''},'State':{'Running':True,'Pid':os.getpid()}},'hermes':{'State':{'Running':True},'HostConfig':{'UsernsMode':''},'Config':{'Env':['HERMES_HOME=/home/runtime']},'Mounts':[{'Type':'bind','Destination':'/home','Source':str(base)}]}}
# /home/runtime resolves to base/runtime; point home at the SQLite fixture.
fixture['hermes']['Mounts'][0]['Source']=str(home)
fixture['hermes']['Config']['Env']=['HERMES_HOME=/home']
(base/'inspect.json').write_text(json.dumps(fixture))
(tools/'docker').write_text('#!/usr/bin/env python3\nimport os,sys,json\na=sys.argv[1:]\nif a[0]=="compose": os.execv("/usr/bin/docker",["docker",*a])\nf=json.load(open(os.environ["INSPECT"]))\nif a[0]=="inspect": print(json.dumps([f["backend" if a[1]=="canino_backend_stage" else "hermes"]]))\nelif a[0]=="exec":\n assert "SET TRANSACTION READ ONLY" in a[-1] and "role::text" in a[-1]\n print(json.dumps([{ "id":os.environ["SUBJECT"]}]))\nelse: raise RuntimeError(a)\n');(tools/'docker').chmod(0o755)
(tools/'docker').write_text('#!/usr/bin/env python3\nimport os,sys,json,subprocess\na=sys.argv[1:]\nif a[0]=="compose": os.execv("/usr/bin/docker",["docker",*a])\nf=json.load(open(os.environ["INSPECT"]))\nif a[0]=="inspect": print(json.dumps([f["backend" if a[1]=="canino_backend_stage" else "hermes"]]))\nelif a[0]=="exec" and "-i" in a:\n p=json.load(sys.stdin); p["home"]=f["hermes"]["Mounts"][0]["Source"]; subprocess.run([sys.executable,"-B","-c",a[-1]],input=json.dumps(p),text=True,check=True)\nelif a[0]=="exec" and "skills" in a:\n print("canina-editorial-v4")\nelif a[0]=="exec":\n assert "SET TRANSACTION READ ONLY" in a[-1] and "role::text" in a[-1]\n print(json.dumps([{ "id":os.environ["SUBJECT"]}]))\nelse: raise RuntimeError(a)\n');(tools/'docker').chmod(0o755)
env=dict(os.environ,PATH=str(tools)+':'+os.environ['PATH'],INSPECT=str(base/'inspect.json'),SUBJECT=subject,GITHUB_ACTIONS='true',STAGE_PROVISION_ENABLED='true',PYTHONDONTWRITEBYTECODE='1')
command='set -euo pipefail; source scripts/rollout-stage.sh; DEPLOY_SHA='+sha+'; unset STAGE_PROVISION_APPROVED_SHA; stage_runtime_provision'
# DEPLOY_SHA is deliberately shell-local: helper must export it.