fix(release): scope missing-column guard and allow exact schema repair
This commit is contained in:
1 parent
688a0e4de5
commit
c69a779ecc
3 files changed
+74
-6
No files matched your search
@@ -12,6 +12,11 @@ ALLOWED = {'nginx.conf', 'Dockerfile', 'backend/Dockerfile', '.dockerignore',
|
||||
'.gitea/workflows/deploy.yml', 'scripts/deploy.sh', 'scripts/ci-host-deploy.sh',
|
||||
'scripts/rollout-production.sh', 'scripts/production-release.py', 'scripts/test_production_release.py',
|
||||
'scripts/tests/test_release_schema_guard.py',
|
||||
# Exact CEO-approved schema CI repair; no migration/workflow wildcard.
|
||||
'.gitea/workflows/auth-schema-reconcile.yml',
|
||||
'docs/auth-schema-reconciliation.md', 'docs/auth-schema-rehearsal.json',
|
||||
'scripts/auth-schema-reconcile.sql', 'scripts/auth-schema-verify.sql',
|
||||
'scripts/ci-auth-schema-reconcile.sh', 'scripts/test_auth_schema_reconcile.py',
|
||||
'scripts/compose.stage.yml', 'scripts/rollout-stage.sh', 'scripts/revalidation-runtime.py',
|
||||
'scripts/provision-revalidation-env.py', 'scripts/tests/test_revalidation_runtime.py',
|
||||
'scripts/tests/test_ci_host_boundary.py', 'scripts/tests/test_stage_provision_wiring.py',
|
||||
@@ -45,6 +50,16 @@ def validate_receipt(r, sha, baseline, paths):
|
||||
and sorted(r.get('paths',[])) == sorted(paths)
|
||||
and paths and set(paths) <= ALLOWED):
|
||||
raise ValueError('Exact SHA, audited Stage acceptance and narrow reviewed diff required')
|
||||
# The runtime probe below checks missing columns only. Independent reviewed
|
||||
# catalog evidence must cover native types and constraints; it is not inferred
|
||||
# from Prisma DMMF scalar names or from this probe passing.
|
||||
typed = r.get('typed_catalog_acceptance')
|
||||
if not (isinstance(typed, dict) and typed.get('accepted') is True
|
||||
and typed.get('sha') == sha
|
||||
and typed.get('scope') == 'native-types-and-constraints'
|
||||
and isinstance(typed.get('reviewer'), str) and typed['reviewer'].strip()
|
||||
and re.fullmatch(r'[0-9a-f]{64}', typed.get('evidence_sha256', ''))):
|
||||
raise ValueError('Independent reviewed typed catalog acceptance required')
|
||||
|
||||
def private_json(path):
|
||||
p=Path(path); s=p.lstat()
|
||||
@@ -77,7 +92,11 @@ def snapshot(items):
|
||||
return c
|
||||
|
||||
def validate_catalog(models, catalog):
|
||||
"""Check every persisted scalar required by the generated target client."""
|
||||
"""Missing-column guard only; does not validate native types or constraints.
|
||||
|
||||
A String field backed by int4 still passes here. Independent typed catalog
|
||||
acceptance is mandatory in validate_receipt before production replacement.
|
||||
"""
|
||||
if not models or not catalog:
|
||||
raise ValueError('Empty generated model or production catalog evidence')
|
||||
actual = {(r['table'], r['column']): r['type'] for r in catalog}
|
||||
@@ -91,11 +110,11 @@ def validate_catalog(models, catalog):
|
||||
if (table, column) not in actual:
|
||||
missing.append(table + '.' + column)
|
||||
if missing:
|
||||
raise ValueError('Incompatible production catalog: ' + ', '.join(missing))
|
||||
raise ValueError('Missing production catalog columns: ' + ', '.join(missing))
|
||||
|
||||
|
||||
def schema_gate(target):
|
||||
"""Read only: inspect immutable target client and the actual running DB catalog.
|
||||
"""Read-only missing-column guard, not a full schema compatibility check.
|
||||
|
||||
No checkout/schema diff can substitute for this check. A newly generated
|
||||
client may require columns which were already in both source revisions.
|
||||
@@ -129,9 +148,11 @@ WHERE n.nspname='public' AND c.relkind IN ('r','p','v','m') AND a.attnum>0 AND N
|
||||
validate_catalog(models, catalog)
|
||||
after = read(['docker', 'inspect', 'canino_backend_prod'])[0]
|
||||
if after['Id'] != before['Id'] or after['Image'] != before['Image'] or not after['State']['Running']:
|
||||
raise ValueError('Production runtime changed during compatibility check')
|
||||
raise ValueError('Production runtime changed during missing-column check')
|
||||
return {'target_image': image, 'runtime_image': before['Image'],
|
||||
'runtime_container': before['Id'], 'catalog_columns': len(catalog)}
|
||||
'runtime_container': before['Id'], 'catalog_columns': len(catalog),
|
||||
'scope': 'missing-columns-only', 'native_types_checked': False,
|
||||
'constraints_checked': False}
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in new issue
Block a user