fix(orchestration): provision explicit Stage owner Gate1 review access
Deploy Canina / deploy (push) Successful in 4m40s

Preserve independent proposer checks, canonical Admin UUID allowlist and deny ordinary admins. Revalidate pinned owner in read-only CI preflight; expose server-advertised card decisions and distinguish reservation from unknown real cost. Verified backend 42 HTTP/service/config tests and build; admin 18 relevant tests, app tsc and Vite build; 3 CI config tests and bash syntax.
This commit is contained in:
devops committed 2026-10-24 04:25:35 +00:00
1 parent bfb1841370
commit 3e78b89cc1
11 files changed
+172 -11

No files matched your search

+15 -3
View File
@@ -5,6 +5,7 @@ stage_runtime_provision() {
[ "${GITHUB_ACTIONS:-${GITEA_ACTIONS:-}}" = true ]
[ "${STAGE_PROVISION_ENABLED:-}" = true ]
export DEPLOY_SHA STAGE_PROVISION_APPROVED_SHA="$DEPLOY_SHA" CI=true
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts -p test_stage_owner_review.py
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s infra/hermes-editorial/tests
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts -p test_editorial_provision.py
PYTHONDONTWRITEBYTECODE=1 python3 - <<'PY'
@@ -59,11 +60,14 @@ root=Path('/opt/services/canina/stage-runtime')
query="""const {PrismaClient}=require('@prisma/client');const p=new PrismaClient();
(async()=>{try{const rows=await p.$transaction(async tx=>{
await tx.$executeRawUnsafe('SET TRANSACTION READ ONLY');
return tx.$queryRawUnsafe(\"SELECT id::text FROM users WHERE lower(replace(replace(role::text, '_', ''), '-', '')) IN ('admin','superadmin') ORDER BY id LIMIT 1001\");
return tx.$queryRawUnsafe(\"SELECT id::text, role::text FROM users WHERE lower(replace(replace(role::text, '_', ''), '-', '')) IN ('admin','superadmin') ORDER BY id LIMIT 1001\");
});process.stdout.write(JSON.stringify(rows));}catch{process.exitCode=1;}finally{await p.$disconnect();}})();"""
rows=json.loads(docker('exec','-w','/app','canino_backend_stage','node','-e',query))
if not 1<=len(rows)<=1000 or any(not isinstance(r,dict) or set(r)!={'id'} or not isinstance(r['id'],str) or not re.fullmatch('[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}',r['id']) for r in rows):
if not 1<=len(rows)<=1000 or any(not isinstance(r,dict) or set(r)!={'id','role'} or not isinstance(r['id'],str) or not re.fullmatch('[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}',r['id']) for r in rows):
raise ValueError('Verified admin subjects required')
spec=importlib.util.spec_from_file_location('owner','scripts/stage-owner-review.py')
owner=importlib.util.module_from_spec(spec);spec.loader.exec_module(owner)
owner_ids=owner.verified_owner_ids(rows)
m.provision(root,uid,gid)
spec=importlib.util.spec_from_file_location('editorial','scripts/provision-editorial-runtime.py')
editorial=importlib.util.module_from_spec(spec);spec.loader.exec_module(editorial)
@@ -74,7 +78,7 @@ dest=root/'snapshots'/capture
m.export_snapshot(db,dest,'default',uid,gid)
grants=root/'snapshots'/(capture+'-grants.json')
m.write_private(grants,json.dumps({r['id']:['default'] for r in rows}),uid,gid)
Path('.stage-runtime.json').write_text(json.dumps({'snapshot':str(dest),'grants':str(grants)}))
Path('.stage-runtime.json').write_text(json.dumps({'snapshot':str(dest),'grants':str(grants),'ownerReviewerIds':owner_ids}))
print('Stage projected snapshot captured; existing admin grants verified; no executor started')
PY
}
@@ -93,6 +97,14 @@ from pathlib import Path
p=Path('.stage-runtime-merged.json');c=json.loads(p.read_text())
b=c['services']['backend_stage']
b.setdefault('environment',{})['CANINA_RUNTIME_READ_ENABLED']='true'
owner_ids=json.loads(Path('.stage-runtime.json').read_text())['ownerReviewerIds']
spec_path=Path('scripts/stage-owner-review.py')
import importlib.util
spec=importlib.util.spec_from_file_location('owner',spec_path)
owner=importlib.util.module_from_spec(spec);spec.loader.exec_module(owner)
assert owner_ids==[owner.STAGE_OWNER_SUBJECT], 'Explicit verified owner required'
b['environment']['CANINA_ENV']='staging'
b['environment']['CANINA_WORKFLOW_OWNER_REVIEWER_IDS']=','.join(owner_ids)
b.setdefault('networks',{})['traefik_public']=None
b.setdefault('labels',{})['traefik.docker.network']='traefik_public'
c['secrets']['hermes_runtime_grants']['file']=json.loads(Path('.stage-runtime.json').read_text())['grants']