From 7d26d10d3fff3b4aa8d7a82731dd533b02493378 Mon Sep 17 00:00:00 2001 From: Mark Gregory Date: Mon, 30 Nov 2026 10:02:56 +0000 Subject: [PATCH] Record integrated ABSDEV-CI qualification --- evidence/combined-qualification/README.md | 6 + evidence/combined-qualification/SHA256SUMS | 19 + evidence/combined-qualification/checks.jsonl | 22 + evidence/combined-qualification/closure.sh | 16 + evidence/combined-qualification/db_tools.py | 311 +++++++++++ .../forward-activation.json | 14 + .../framework/capabilities.json | 19 + .../framework/framework-ci.txt | 108 ++++ .../framework/mismatch.txt | 3 + .../framework/runner-image.txt | 1 + .../framework/runner-pinning.txt | 3 + .../framework/scope.txt | 2 + .../framework/toolchain.txt | 2 + .../manual-reconciliation.json | 29 ++ .../combined-qualification/migration-test.py | 484 ++++++++++++++++++ evidence/combined-qualification/observed.json | 13 + .../ordinary-after.json | 19 + .../ordinary-before.json | 19 + .../reconciliation-result.json | 28 + evidence/combined-qualification/summary.json | 8 + 20 files changed, 1126 insertions(+) create mode 100644 evidence/combined-qualification/README.md create mode 100644 evidence/combined-qualification/SHA256SUMS create mode 100644 evidence/combined-qualification/checks.jsonl create mode 100644 evidence/combined-qualification/closure.sh create mode 100644 evidence/combined-qualification/db_tools.py create mode 100644 evidence/combined-qualification/forward-activation.json create mode 100644 evidence/combined-qualification/framework/capabilities.json create mode 100644 evidence/combined-qualification/framework/framework-ci.txt create mode 100644 evidence/combined-qualification/framework/mismatch.txt create mode 100644 evidence/combined-qualification/framework/runner-image.txt create mode 100644 evidence/combined-qualification/framework/runner-pinning.txt create mode 100644 evidence/combined-qualification/framework/scope.txt create mode 100644 evidence/combined-qualification/framework/toolchain.txt create mode 100644 evidence/combined-qualification/manual-reconciliation.json create mode 100644 evidence/combined-qualification/migration-test.py create mode 100644 evidence/combined-qualification/observed.json create mode 100644 evidence/combined-qualification/ordinary-after.json create mode 100644 evidence/combined-qualification/ordinary-before.json create mode 100644 evidence/combined-qualification/reconciliation-result.json create mode 100644 evidence/combined-qualification/summary.json diff --git a/evidence/combined-qualification/README.md b/evidence/combined-qualification/README.md new file mode 100644 index 0000000..c1010b2 --- /dev/null +++ b/evidence/combined-qualification/README.md @@ -0,0 +1,6 @@ +Integrated ABSDEV-CI qualification at 84a7a5b23796b15cab830034aae256b9414e9693. +All 909 framework tests and 22 live PostgreSQL and recovery fixture checks passed. +The recovery fixture used real PostgreSQL interruption and on-disk release switching, +with synthetic service and health callbacks. The forward activation and archival +each required their own confirmation. The ordinary journal remained byte-identical. +Production execution, readiness and permanent deletion remained disabled. diff --git a/evidence/combined-qualification/SHA256SUMS b/evidence/combined-qualification/SHA256SUMS new file mode 100644 index 0000000..4258219 --- /dev/null +++ b/evidence/combined-qualification/SHA256SUMS @@ -0,0 +1,19 @@ +44b544c9c43c35b084dbaf8ad65b368a2b32e05c2cf781fc3fbbc1afa3422057 ./checks.jsonl +94408e6242b4a5eff91a673c65f88c3dfac0fc9959bf435bbff6739116f7faa9 ./forward-activation.json +e5869afcf31ff3c1f4792e6b8c8593e0283260ae4b1ab136aed938f166cfd82d ./manual-reconciliation.json +6416cf3cb4ea0e945dbca1c89c1e45d78d3cc999f5161994bfbc5e2c758047f2 ./observed.json +0bc7aa6f50486d8b1a054213ce63c280fbc8f221113e7f9f09d0b7cfeafb1107 ./ordinary-after.json +0bc7aa6f50486d8b1a054213ce63c280fbc8f221113e7f9f09d0b7cfeafb1107 ./ordinary-before.json +a6cf2cfbcbbab675b044321df36f80f83de40c3c8242f0b3dc2ea6e6f9aced8a ./reconciliation-result.json +0e5f3b1532329ed9730b8da488e10f76884ec14d305de9973b2b14e0845f3686 ./summary.json +94897e03792498140e061b2dac59b6274ce301ecc80a0fe6b7fa895bb9ee4c93 README.md +4e1e18362ec5d995139d84c92495ff20ab93c410d95af09aa9b5c5bad45e5f7f closure.sh +f426e892950040f3514093a3263cf73e16aca95488c552d1c921ecc8329080c0 migration-test.py +72724b88e2afa930b8244f8546092c233040c987ce5f2dad2298c306cc91601f db_tools.py +934a04b5d6ec9aa62cb991fb2f57256c439bac4b2ac110cabd524ad456e59491 framework/capabilities.json +3747e20ed6fc26ea1165308ee774233cf09a418eab799209ea06eb94ae0f5d59 framework/framework-ci.txt +56c2f6135efd08c8ae2f207545e8079c05df362d4bbef7226286b3e5439c535d framework/mismatch.txt +9a7ae4c05f2640cce03a9df76b547c270084401822a8f357125d8e2ff0f4d840 framework/runner-image.txt +20cbc1539965bbf519926da678e0cdc5489d05da2960dfdde007d83d8638d0da framework/runner-pinning.txt +f28fed24f9740bf08a74a6652628f1ec6dc7c71fd66e8577c8bbf60e97579e5f framework/scope.txt +b442066a4584b5b2698c99ac42a5e59a47b9c118d00c31fc1dab5998066d1338 framework/toolchain.txt diff --git a/evidence/combined-qualification/checks.jsonl b/evidence/combined-qualification/checks.jsonl new file mode 100644 index 0000000..4649aef --- /dev/null +++ b/evidence/combined-qualification/checks.jsonl @@ -0,0 +1,22 @@ +{"check": "production gates before", "detail": {"commands": ["validate", "capabilities", "inventory", "retention-plan", "provision-plan", "site-policy", "registry-validate", "preflight"], "database_restore_enabled": false, "deployment_execution_enabled": false, "format_version": 1, "migration_execution_enabled": false, "permanent_deletion_enabled": false, "production_ready": false, "provisioning_execution_enabled": false}, "engine": "framework", "result": "PASS"} +{"check": "container isolation", "detail": {"host_mounts": 0, "image_id": "sha256:e742a2668255221388004f3a42b6150a2103f5054ab3a4a93ae9e4f01e551c35", "network": "none", "privileged": false, "published_ports": 0}, "engine": "postgres", "result": "PASS"} +{"check": "real transactionally consistent PostgreSQL backup verified", "detail": "fbc8b0749f2f2adbce9e94555bc24e73e1e50ca7fdbae2a92d10feaf295b9ec3", "engine": "postgres", "result": "PASS"} +{"check": "restored backup to a separate disposable database and rehearsed both migration steps", "engine": "postgres", "result": "PASS"} +{"check": "live migration excluded a competing site operation", "engine": "framework", "result": "PASS"} +{"check": "abruptly stopped coordinator and interrupted an in-flight PostgreSQL transaction", "engine": "postgres", "result": "PASS"} +{"check": "interrupted transaction rolled back, committed prefix survives, migration history unchanged", "engine": "postgres", "result": "PASS"} +{"check": "restart inspection and activation refuse incomplete migration evidence", "engine": "framework", "result": "PASS"} +{"check": "interrupted migration approval could not be replayed", "engine": "framework", "result": "PASS"} +{"check": "standard paths left original release and ordinary journal byte-for-byte intact", "detail": {"journal_sha256": "0bc7aa6f50486d8b1a054213ce63c280fbc8f221113e7f9f09d0b7cfeafb1107", "release": "2"}, "engine": "framework", "result": "PASS"} +{"check": "reopened ordinary journal denies direct transition during unfinished migration", "engine": "framework", "result": "PASS"} +{"check": "bound journal also rejects direct creation while migration is unfinished", "engine": "framework", "result": "PASS"} +{"check": "durable migration intent binds original release, revision and provenance", "detail": {"fingerprint": "215281691a508f42a57945a017f78f871317e08e079d1faacac69b3dadb1416e", "release": "2", "revision": "01dda29c1d2313f5b359df427051f09e555957e9"}, "engine": "framework", "result": "PASS"} +{"check": "incomplete history cannot produce a reconciliation proposal", "engine": "framework", "result": "PASS"} +{"check": "review drill completed only the rolled-back suffix; prefix identity and journal stayed unchanged", "engine": "postgres", "result": "PASS"} +{"check": "manual SQL did not authorise replay, activation or containment release", "engine": "framework", "result": "PASS"} +{"check": "ungranted operator and incorrect plan fingerprint denied with no result", "engine": "framework", "result": "PASS"} +{"check": "authorised review persisted once; separate forward confirmation still required", "engine": "framework", "result": "PASS"} +{"check": "separate forward confirmation activated the fixture without rerunning migration", "engine": "framework", "result": "PASS"} +{"check": "verified archival cleared the migration guard without rewriting ordinary journal", "engine": "framework", "result": "PASS"} +{"check": "disposable PostgreSQL container and anonymous data volume removed", "engine": "framework", "result": "PASS"} +{"check": "production gates after", "detail": {"commands": ["validate", "capabilities", "inventory", "retention-plan", "provision-plan", "site-policy", "registry-validate", "preflight"], "database_restore_enabled": false, "deployment_execution_enabled": false, "format_version": 1, "migration_execution_enabled": false, "permanent_deletion_enabled": false, "production_ready": false, "provisioning_execution_enabled": false}, "engine": "framework", "result": "PASS"} diff --git a/evidence/combined-qualification/closure.sh b/evidence/combined-qualification/closure.sh new file mode 100644 index 0000000..9b7594b --- /dev/null +++ b/evidence/combined-qualification/closure.sh @@ -0,0 +1,16 @@ +set -euo pipefail +umask 077 +test "$(hostname -s | tr A-Z a-z)" = absdev-ci +test "$(id -u)" -ne 0 +stage=$(mktemp -d /var/tmp/absdev-live-reconcile.XXXXXX) +trap 'rm -rf -- "$stage"' EXIT +cd "$stage" +tar -xm -f - +git clone -q --branch combined-qualification framework.bundle framework +mkdir tmp +export TMPDIR="$stage/tmp" +python3 -B migration-test.py >&2 +mkdir evidence +cp checks.jsonl summary.json observed.json manual-reconciliation.json reconciliation-result.json forward-activation.json ordinary-before.json ordinary-after.json evidence/ +(cd evidence && sha256sum ./* > SHA256SUMS) +tar -czf - -C evidence . diff --git a/evidence/combined-qualification/db_tools.py b/evidence/combined-qualification/db_tools.py new file mode 100644 index 0000000..48d0ad8 --- /dev/null +++ b/evidence/combined-qualification/db_tools.py @@ -0,0 +1,311 @@ +import hashlib +import json +import os +import re +import secrets +import shlex +import subprocess +import sys +import time +from pathlib import Path + +EXPECTED = "74645a2173a3dba44e760094baa6e2d961bcff8c" +IMAGES = { + "mysql": "sha256:8c233bad33d520a7aae1c1e619c3a9775f4a1ba2d463d692fada04ec7f40be00", + "postgres": "sha256:e742a2668255221388004f3a42b6150a2103f5054ab3a4a93ae9e4f01e551c35", +} +FIELDS = ("production_ready", "deployment_execution_enabled", "migration_execution_enabled", + "provisioning_execution_enabled", "database_restore_enabled", "permanent_deletion_enabled") +ROLES = ("app_user", "migration_user", "backup_user") +PASSWORDS = {role: secrets.token_hex(24) for role in (*ROLES, "admin")} +RUN = secrets.token_hex(5) +ROOT = Path.cwd() +DOCKER = ("sudo", "-n", "docker") +REPO = next(Path("/var/tmp/absdev-dev3-ci.8yBxcV/state/attempts").glob("29-*/checkout")) +events = [] +containers = [] + + +def cmd(args, sql=None, timeout=90): + return subprocess.run(args, input=sql, text=True, capture_output=True, timeout=timeout) + + +def safe(output): + for password in PASSWORDS.values(): + output = output.replace(password, "[redacted]") + return output.strip() + + +def require(condition, message): + if not condition: + raise RuntimeError(message) + + +def good(args, sql=None, timeout=90): + result = cmd(args, sql, timeout) + require(result.returncode == 0, safe(result.stderr) or f"{args[0]} returned {result.returncode}") + return result.stdout.strip() + + +def record(engine, name, result, detail=None): + event = {"engine": engine, "check": name, "result": result} + if detail is not None: + event["detail"] = detail + events.append(event) + with (ROOT / "checks.jsonl").open("a") as out: + out.write(json.dumps(event, sort_keys=True) + "\n") + print(f"{result} {engine}: {name}", flush=True) + + +def capability(when): + require(good(("git", "-C", str(REPO), "rev-parse", "HEAD")) == EXPECTED, "Unexpected dev.3 revision") + require(not good(("git", "-C", str(REPO), "status", "--porcelain")), "Unexpected checkout changes") + report = json.loads(good((sys.executable, "-B", str(REPO / "bin/absdev-deploy"), "capabilities"))) + require(all(report.get(field) is False for field in FIELDS), "Production capability enabled") + for verb in ("deploy", "migrate", "rollback", "restore", "provision", "delete"): + result = cmd((sys.executable, "-B", str(REPO / "bin/absdev-deploy"), verb)) + require(result.returncode != 0, f"Production CLI accepted {verb}") + record("framework", "production gates " + when, "PASS", report) + + +def start(engine): + name = f"absdev-lp-{engine}-{RUN}" + env = ("-e", "MYSQL_ROOT_PASSWORD=" + PASSWORDS["admin"]) if engine == "mysql" else ( + "-e", "POSTGRES_PASSWORD=" + PASSWORDS["admin"], "-e", "POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256") + extra = ("--skip-name-resolve", "--event-scheduler=OFF", "--log-bin-trust-function-creators=ON") if engine == "mysql" else () + containers.append(name) + good((*DOCKER, "run", "-d", "--pull", "never", "--name", name, "--network", "none", + "--cap-drop", "NET_RAW", "--security-opt", "no-new-privileges", "--memory", "1g", + "--pids-limit", "256", "--label", "absdev.qualification=" + RUN, + *env, IMAGES[engine], *extra)) + report = json.loads(good((*DOCKER, "inspect", "--format", + "{{json .HostConfig}}", name))) + require(report["NetworkMode"] == "none" and not report["Privileged"] and + not report.get("PortBindings") and not report.get("Binds") and + report["SecurityOpt"] == ["no-new-privileges"], "Container isolation check failed") + record(engine, "container isolation", "PASS", {"image_id": IMAGES[engine], "network": "none", + "host_mounts": 0, "published_ports": 0, "privileged": False}) + return name + + +def connect(engine, name, role, database="fixture"): + password = PASSWORDS[role] + if engine == "mysql": + user = "root" if role == "admin" else role + endpoint = ("--protocol=SOCKET",) if role == "admin" else ("--protocol=TCP", "-h", "127.0.0.1") + return (*DOCKER, "exec", "-i", "-e", "MYSQL_PWD=" + password, name, "mysql", + "--batch", "--skip-column-names", "--connect-timeout=4", *endpoint, "-u", user, database) + user = "postgres" if role == "admin" else role + return (*DOCKER, "exec", "-i", "-e", "PGPASSWORD=" + password, name, "psql", "-X", + "-qAt", "-v", "ON_ERROR_STOP=1", "-h", "127.0.0.1", "-U", user, "-d", database) + + +def ready(engine, name, base): + for _ in range(75): + result = cmd(connect(engine, name, "admin", base), "SELECT 1;", timeout=12) + if result.returncode == 0 and result.stdout.strip() == "1": + if engine != "mysql" or cmd((*DOCKER, "exec", name, "sh", "-c", + 'test "$(cat /proc/1/comm)" = mysqld')).returncode == 0: + return + time.sleep(2) + raise RuntimeError("Disposable database startup timed out") + + +def expect(engine, name, role, label, sql, value=None, *, database="fixture"): + result = cmd(connect(engine, name, role, database), sql) + observed = safe(result.stdout) + require(result.returncode == 0 and (value is None or observed == value), + f"{engine} {label}: {safe(result.stderr) or repr(observed)}") + record(engine, label, "PASS", observed or None) + return observed + + +def deny(engine, name, role, label, sql, database="fixture"): + result = cmd(connect(engine, name, role, database), sql) + error = safe(result.stderr) + require(result.returncode != 0 and re.search(r"access denied|permission denied|command denied|must be|not permitted", error, re.I), + f"{engine} {label}: expected a privilege denial, got {error or repr(result.stdout)}") + record(engine, label, "PASS", error.splitlines()[0]) + + +def identity_checks(engine, name, sql, server, user_format): + def verify(observed, user, expected_server): + return observed == ["fixture", user_format(user), expected_server] + for role in ROLES: + result = expect(engine, name, role, f"{role} observed identity", sql) + fields = result.split("\t" if engine == "mysql" else "|") + require(verify(fields, role, server), f"Unexpected {engine} server/database/account") + require(not verify(fields, role, "intentional-wrong-server") and + not verify(fields, "wrong_user", server), "Identity comparison accepted mismatch") + record(engine, f"{role} identity mismatch rejected by harness", "PASS") + + +def mysql(name): + ready("mysql", name, "mysql") + admin = connect("mysql", name, "admin", "mysql") + users = "\n".join( + f"CREATE USER '{role}'@'127.0.0.1' IDENTIFIED BY '{PASSWORDS[role]}' PASSWORD EXPIRE NEVER;" + for role in ROLES + ) + good(admin, f""" +CREATE DATABASE fixture; +CREATE DATABASE other_fixture; +CREATE TABLE fixture.items(id INT PRIMARY KEY, label VARCHAR(32)); +INSERT INTO fixture.items VALUES (1,'seed'); +CREATE TABLE other_fixture.private_items(id INT); +INSERT INTO other_fixture.private_items VALUES (99); +CREATE VIEW fixture.items_view AS SELECT * FROM fixture.items; +CREATE TRIGGER fixture.fixture_trigger BEFORE INSERT ON fixture.items +FOR EACH ROW SET NEW.label = NEW.label; +CREATE PROCEDURE fixture.fixture_proc() SELECT 1; +CREATE EVENT fixture.fixture_event ON SCHEDULE EVERY 1 DAY DISABLE DO SELECT 1; +{users} +GRANT SELECT, INSERT, UPDATE, DELETE ON fixture.* TO 'app_user'@'127.0.0.1'; +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, INDEX, REFERENCES +ON fixture.* TO 'migration_user'@'127.0.0.1'; +GRANT SELECT, SHOW VIEW ON fixture.* TO 'backup_user'@'127.0.0.1'; +""") + server = good(admin, "SELECT @@server_uuid;") + require(re.fullmatch(r"[a-f0-9-]{36}", server) is not None, "Missing MySQL server UUID") + expect("mysql", name, "admin", "server version", "SELECT VERSION();") + identity_checks("mysql", name, "SELECT DATABASE(), CURRENT_USER(), @@server_uuid;", server, + lambda user: user + "@127.0.0.1") + for role in ROLES: + expect("mysql", name, role, f"{role} grants captured", "SHOW GRANTS;") + role_checks("mysql", name, "fixture.", "other_fixture.private_items", + "GRANT SELECT ON fixture.items TO 'backup_user'@'127.0.0.1';") + dump = (*DOCKER, "exec", "-e", "MYSQL_PWD=" + PASSWORDS["backup_user"], name, "mysqldump", + "--protocol=TCP", "-h", "127.0.0.1", "-u", "backup_user", "--single-transaction", + "--quick", "--no-tablespaces", "--skip-lock-tables", "--set-gtid-purged=OFF", "--hex-blob") + data = good((*dump, "--skip-triggers", "fixture")) + require("seed" in data and "CREATE TABLE `items`" in data and "private_items" not in data, + "MySQL table/view dump is incomplete") + record("mysql", "read-only table and view export", "PASS", + {"sha256": hashlib.sha256(data.encode()).hexdigest()}) + full = cmd((*dump, "--triggers", "--routines", "--events", "fixture")) + missing = [marker for marker in ("fixture_trigger", "fixture_proc", "fixture_event") + if marker not in full.stdout] + record("mysql", "framework-equivalent full dump with read-only backup account", + "PASS" if full.returncode == 0 and not missing else "GAP", + {"exit_code": full.returncode, "missing_objects": missing, "diagnostics": safe(full.stderr)}) + for label, sql in (("trigger creation", "CREATE TRIGGER fixture.forbidden_trigger BEFORE UPDATE ON fixture.items FOR EACH ROW SET NEW.label=NEW.label;"), + ("event creation", "CREATE EVENT fixture.forbidden_event ON SCHEDULE EVERY 1 DAY DISABLE DO SELECT 1;"), + ("routine creation", "CREATE PROCEDURE fixture.forbidden_proc() SELECT 1;")): + deny("mysql", name, "backup_user", f"backup account denied {label}", sql) + + +def postgres(name): + ready("postgres", name, "postgres") + admin = connect("postgres", name, "admin", "postgres") + for role in ROLES: + good(admin, f"CREATE ROLE {role} LOGIN PASSWORD '{PASSWORDS[role]}' NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;") + for db in ("fixture", "other_fixture"): + good(admin, f"CREATE DATABASE {db};") + for db in ("fixture","other_fixture","postgres","template1"): + good(admin, f"REVOKE CONNECT, TEMPORARY ON DATABASE {db} FROM PUBLIC;") + good(admin, "GRANT CONNECT ON DATABASE fixture TO app_user, migration_user, backup_user;") + good(connect("postgres", name, "admin", "other_fixture"), "CREATE TABLE public.private_items(id INT);") + fixture = connect("postgres", name, "admin") + good(fixture, """ +REVOKE ALL ON SCHEMA public FROM PUBLIC; +CREATE SCHEMA work AUTHORIZATION migration_user; +GRANT USAGE ON SCHEMA work TO app_user, backup_user; +ALTER DEFAULT PRIVILEGES FOR ROLE migration_user IN SCHEMA work + GRANT SELECT,INSERT,UPDATE,DELETE ON TABLES TO app_user; +ALTER DEFAULT PRIVILEGES FOR ROLE migration_user IN SCHEMA work + GRANT SELECT ON TABLES TO backup_user; +REVOKE ALL ON FUNCTION pg_catalog.pg_control_system() FROM PUBLIC; +GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO app_user, migration_user, backup_user; +""") + good(connect("postgres", name, "migration_user"), """ +CREATE TABLE work.items(id INT PRIMARY KEY, label VARCHAR(32)); +INSERT INTO work.items VALUES (1,'seed'); +CREATE VIEW work.items_view AS SELECT * FROM work.items; +CREATE FUNCTION work.fixture_trigger_function() RETURNS trigger LANGUAGE plpgsql AS +$$BEGIN RETURN NEW; END;$$; +CREATE TRIGGER fixture_trigger BEFORE INSERT ON work.items +FOR EACH ROW EXECUTE FUNCTION work.fixture_trigger_function(); +""") + server = good(fixture, "SELECT system_identifier FROM pg_control_system();") + require(server.isdigit(), "Missing PostgreSQL cluster identifier") + expect("postgres", name, "admin", "server version", "SHOW server_version;") + identity_checks("postgres", name, + "SELECT current_database(), current_user, system_identifier FROM pg_control_system();", + server, lambda user: user) + for role in ROLES: + expect("postgres", name, role, f"{role} has no elevated role attributes", + "SELECT (rolsuper OR rolcreatedb OR rolcreaterole OR rolreplication OR rolbypassrls)::int " + "FROM pg_roles WHERE rolname=current_user;", "0") + deny("postgres", name, role, f"{role} cannot connect to other database", + "SELECT 1;", "other_fixture") + role_checks("postgres", name, "work.", "public.private_items", "CREATE ROLE escalate_fixture;") + binary = subprocess.run((*DOCKER, "exec", "-e", "PGPASSWORD=" + PASSWORDS["backup_user"], + name, "pg_dump", "--no-password", "-h", "127.0.0.1", "-U", "backup_user", + "--format=custom", "--no-owner", "--no-privileges", "--dbname=fixture"), + capture_output=True, timeout=90) + require(binary.returncode == 0 and binary.stdout.startswith(b"PGDMP"), safe(binary.stderr.decode())) + sql = subprocess.run((*DOCKER, "exec", "-i", name, "pg_restore", "--file=-"), + input=binary.stdout, capture_output=True, timeout=90) + require(sql.returncode == 0 and all(marker in sql.stdout for marker in + (b"CREATE TABLE work.items", b"CREATE VIEW work.items_view", + b"fixture_trigger_function", b"CREATE TRIGGER fixture_trigger", b"seed")) and + b"private_items" not in sql.stdout, "PostgreSQL archive objects/data did not match requirements") + record("postgres", "framework-equivalent read-only full dump", "PASS", + {"sha256": hashlib.sha256(binary.stdout).hexdigest(), "bytes": len(binary.stdout)}) + + +def role_checks(engine, name, schema, other, elevate): + table = schema + "items" + probe = schema + "migration_probe" + expect(engine, name, "app_user", "application reads assigned table", + f"SELECT label FROM {table} WHERE id=1;", "seed") + expect(engine, name, "app_user", "application DML works", + f"INSERT INTO {table} VALUES (2,'temp'); UPDATE {table} SET label='changed' WHERE id=2;" + f"SELECT label FROM {table} WHERE id=2; DELETE FROM {table} WHERE id=2;", "changed") + deny(engine, name, "app_user", "application denied schema creation", f"CREATE TABLE {probe}(id INT);") + deny(engine, name, "app_user", "application denied schema changes", f"ALTER TABLE {table} ADD COLUMN forbidden INT;") + deny(engine, name, "app_user", "application denied privilege escalation", elevate) + expect(engine, name, "migration_user", "migration DDL works in assigned schema", + f"CREATE TABLE {probe}(id INT); ALTER TABLE {probe} ADD COLUMN name VARCHAR(10); DROP TABLE {probe};") + deny(engine, name, "migration_user", "migration denied creating databases", "CREATE DATABASE forbidden_fixture;") + expect(engine, name, "backup_user", "backup account reads assigned table", + f"SELECT label FROM {table} WHERE id=1;", "seed") + deny(engine, name, "backup_user", "backup account denied data writes", f"DELETE FROM {table} WHERE id=1;") + deny(engine, name, "backup_user", "backup account denied schema changes", f"ALTER TABLE {table} ADD COLUMN forbidden INT;") + if engine == "mysql": + for role in ROLES: + deny(engine, name, role, f"{role} denied other database", f"SELECT * FROM {other};") + + +def main(): + require(good(("hostname", "-s")) == "absdev-ci", "Wrong host") + capability("before") + try: + mysql(start("mysql")) + postgres(start("postgres")) + finally: + errors = [] + for name in reversed(containers): + result = cmd((*DOCKER, "rm", "-f", "-v", name)) + if result.returncode != 0 and "No such container" not in result.stderr: + errors.append(safe(result.stderr)) + remaining = good((*DOCKER, "ps", "-aq", "--filter", "label=absdev.qualification=" + RUN)) + require(not remaining and not errors, "Could not clean up disposable database containers") + record("framework", "disposable containers removed", "PASS") + capability("after") + summary = {"commit": EXPECTED, "host": "ABSDEV-CI", "scope": "isolated database privilege and backup compatibility", + "production_ready": False, "production_execution_enabled": False, + "framework_native_live_identity_gate_qualified": False, + "checks_passed": sum(event["result"] == "PASS" for event in events), + "gaps": [event for event in events if event["result"] == "GAP"]} + (ROOT / "summary.json").write_text(json.dumps(summary, indent=2) + "\n") + print(json.dumps(summary, indent=2), flush=True) + + +if __name__ == "__main__": + os.umask(0o077) + try: + main() + except Exception as error: + print(safe(str(error)), file=sys.stderr) + sys.exit(1) diff --git a/evidence/combined-qualification/forward-activation.json b/evidence/combined-qualification/forward-activation.json new file mode 100644 index 0000000..3723c4a --- /dev/null +++ b/evidence/combined-qualification/forward-activation.json @@ -0,0 +1,14 @@ +{ + "active_release": "3", + "approval_id": "597fb572f6994e0687e1e71b7538e47a", + "checksum": "5073931361d0903eb93237971f5e097b616e917a2778a358ddd8f1e965faa249", + "completed_at": "2026-11-30T10:01:54.383439+00:00", + "database_restored": false, + "format_version": 1, + "health_verified": true, + "intent_checksum": "61e96ce130885d03ff58eaaa8dd628340e148a33f9f9e82a0273e5e5fa7ce206", + "migration_reexecuted": false, + "plan_fingerprint": "d8c2e6c1e2b42af767a74c6d7c2e6ecb117e92ba7130cfb971f454c9976a5886", + "site": "absdev-migration-lab", + "status": "VERIFIED" +} diff --git a/evidence/combined-qualification/framework/capabilities.json b/evidence/combined-qualification/framework/capabilities.json new file mode 100644 index 0000000..30d3c30 --- /dev/null +++ b/evidence/combined-qualification/framework/capabilities.json @@ -0,0 +1,19 @@ +{ + "commands": [ + "validate", + "capabilities", + "inventory", + "retention-plan", + "provision-plan", + "site-policy", + "registry-validate", + "preflight" + ], + "database_restore_enabled": false, + "deployment_execution_enabled": false, + "format_version": 1, + "migration_execution_enabled": false, + "permanent_deletion_enabled": false, + "production_ready": false, + "provisioning_execution_enabled": false +} diff --git a/evidence/combined-qualification/framework/framework-ci.txt b/evidence/combined-qualification/framework/framework-ci.txt new file mode 100644 index 0000000..2572c7f --- /dev/null +++ b/evidence/combined-qualification/framework/framework-ci.txt @@ -0,0 +1,108 @@ +=== ABSDEV FRAMEWORK CI === +Python 3.14.4 + +=== PYTHON SYNTAX VALIDATION === +PASS: 90 Python sources compiled + +=== COMPLETE UNIT REGRESSION SUITE === +............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. +---------------------------------------------------------------------- +Ran 909 tests in 20.182s + +OK + +=== VERIFY PRODUCTION CAPABILITY RESTRICTIONS === +PASS: production_ready=false +PASS: deployment_execution_enabled=false +PASS: migration_execution_enabled=false +PASS: provisioning_execution_enabled=false +PASS: database_restore_enabled=false +PASS: permanent_deletion_enabled=false +PASS: Unsupported command rejected: deploy +PASS: Unsupported command rejected: migrate +PASS: Unsupported command rejected: rollback +PASS: Unsupported command rejected: restore +PASS: Unsupported command rejected: provision +PASS: Unsupported command rejected: delete + +=== EXAMPLE CONFIGURATION === +PASS: Configuration valid +Site: example-absdev-net +Domain: example.absdev.net +Database: mysql +Schema: 1 +No deployment performed +{ + "configuration_fingerprint": "8067fa8477a7d50cbcc42b585961bcd4dbce5407fc7e4bffcfb3e07af529e483", + "execution_permitted": false, + "fingerprint": "d271a3a3ed2cbda032f905558fe9ada653c380c74306fc714ebc594483a63042", + "format_version": 1, + "runtime_verified": false, + "site": "example-absdev-net", + "static_policy_verified": true, + "status": "VALID" +} +{ + "configuration_fingerprint": "8067fa8477a7d50cbcc42b585961bcd4dbce5407fc7e4bffcfb3e07af529e483", + "database": { + "container": "platform-mysql", + "driver": "mysql", + "name": "example_db", + "username": "example_app" + }, + "database_creation_permitted": false, + "directories": [ + "/opt/laravel-sites/example-absdev-net", + "/opt/laravel-sites/example-absdev-net/app", + "/opt/laravel-sites/example-absdev-net/app/releases", + "/opt/laravel-sites/example-absdev-net/app/shared", + "/opt/laravel-sites/example-absdev-net/deployment", + "/opt/laravel-sites/example-absdev-net/backups", + "/opt/laravel-sites/example-absdev-net/deployment/state", + "/opt/laravel-sites/example-absdev-net/deployment/approvals", + "/opt/laravel-sites/example-absdev-net/deployment/archives" + ], + "docker": { + "networks": [ + "laravel_backend", + "laravel_proxy" + ], + "project": "site-example-absdev-net", + "services": [ + "php", + "web", + "queue", + "scheduler" + ] + }, + "domain": "example.absdev.net", + "execution_permitted": false, + "filesystem_permissions_verified": false, + "fingerprint": "d8432e17dc1b91ce4712ab656c14c0b5a0957c54700b027b22444dc3a4c19feb", + "format_version": 1, + "origin_port": 8199, + "repository": { + "branch": "main", + "url": "git@example.invalid:example/application.git" + }, + "resource_conflicts_checked": false, + "retention": { + "automatic_deletion": false, + "keep_releases": 5 + }, + "root": "/opt/laravel-sites/example-absdev-net", + "secrets_required": true, + "site": "example-absdev-net", + "site_policy_fingerprint": "d271a3a3ed2cbda032f905558fe9ada653c380c74306fc714ebc594483a63042", + "static_policy_verified": true, + "status": "PLAN_ONLY" +} + +=== REFERENCE INTEGRITY === +SKIP: Private reference excluded from checkout + +======================================== +PASS: FRAMEWORK CI +UNIT TESTS AND STATIC VALIDATION ONLY +DATABASE INTEGRATION NOT EXECUTED +======================================== diff --git a/evidence/combined-qualification/framework/mismatch.txt b/evidence/combined-qualification/framework/mismatch.txt new file mode 100644 index 0000000..ef2cd5b --- /dev/null +++ b/evidence/combined-qualification/framework/mismatch.txt @@ -0,0 +1,3 @@ +/usr/bin/python3: FAILED +sha256sum/usr/bin/git: OK +: WARNING: 1 computed checksum did NOT match diff --git a/evidence/combined-qualification/framework/runner-image.txt b/evidence/combined-qualification/framework/runner-image.txt new file mode 100644 index 0000000..dd5e41e --- /dev/null +++ b/evidence/combined-qualification/framework/runner-image.txt @@ -0,0 +1 @@ +sha256:66d80966792e621c9761c47919644198d35fd1c297e9a01e69ed3c1ae37db0c7 diff --git a/evidence/combined-qualification/framework/runner-pinning.txt b/evidence/combined-qualification/framework/runner-pinning.txt new file mode 100644 index 0000000..9db80a4 --- /dev/null +++ b/evidence/combined-qualification/framework/runner-pinning.txt @@ -0,0 +1,3 @@ + - "absdev-ci:docker://docker.gitea.com/runner-images@sha256:203ba5eff144b485821fc41c47f29ed24333304660e953e8983b9b852e013ca0" + force_pull: false + force_rebuild: false diff --git a/evidence/combined-qualification/framework/scope.txt b/evidence/combined-qualification/framework/scope.txt new file mode 100644 index 0000000..119d8ff --- /dev/null +++ b/evidence/combined-qualification/framework/scope.txt @@ -0,0 +1,2 @@ +host=absdev-ci +revision=84a7a5b23796b15cab830034aae256b9414e9693 diff --git a/evidence/combined-qualification/framework/toolchain.txt b/evidence/combined-qualification/framework/toolchain.txt new file mode 100644 index 0000000..cabd5c5 --- /dev/null +++ b/evidence/combined-qualification/framework/toolchain.txt @@ -0,0 +1,2 @@ +/usr/bin/python3: OK +/usr/bin/git: OK diff --git a/evidence/combined-qualification/manual-reconciliation.json b/evidence/combined-qualification/manual-reconciliation.json new file mode 100644 index 0000000..2a467cd --- /dev/null +++ b/evidence/combined-qualification/manual-reconciliation.json @@ -0,0 +1,29 @@ +{ + "after": { + "active_release": "2", + "contained": true, + "history": [ + "2026_01_01_000000_create_fixture", + "2026_11_28_000001_recovery_probe" + ], + "journal_sha256": "0bc7aa6f50486d8b1a054213ce63c280fbc8f221113e7f9f09d0b7cfeafb1107", + "prefix_oid": "16429", + "suffix_exists": true + }, + "plan": { + "before": { + "active_release": "2", + "contained": true, + "history": [ + "2026_01_01_000000_create_fixture" + ], + "journal_sha256": "0bc7aa6f50486d8b1a054213ce63c280fbc8f221113e7f9f09d0b7cfeafb1107", + "prefix_oid": "16429", + "suffix_exists": false + }, + "intent_checksum": "e2576145ef72872aea1317f1ce579847fb2491a1598c195376b4f46758d010fc", + "operation": "complete only interrupted suffix in disposable fixture" + }, + "plan_fingerprint": "923cac36d0168c9f646969141f78364f338d2a26a99f8f19d2bc46a0f037857e", + "scope": "Fixture repair followed by framework-recorded reconciliation" +} diff --git a/evidence/combined-qualification/migration-test.py b/evidence/combined-qualification/migration-test.py new file mode 100644 index 0000000..2c3719f --- /dev/null +++ b/evidence/combined-qualification/migration-test.py @@ -0,0 +1,484 @@ +import hashlib +import json +import os +import signal +import shutil +import subprocess +import sys +import time +from datetime import datetime,timedelta,timezone +import secrets +from pathlib import Path + +ROOT=Path.cwd() +REPO=ROOT/"framework" +sys.path.insert(0,str(REPO)) +import db_tools as fixture +from db_tools import cmd, good, record, require, DOCKER, PASSWORDS + +from core.approval import issue_approval +from core.backup import BackupEngine +from core.compatibility import canonical_hash +from core.database import get_adapter +from core.database_identity import DatabaseIdentityProbe +from core.deployment import DeploymentController, DeploymentError +from core.dev3.operations import SiteOperations +from core.execution import CommandRunner +from core.locking import LockError +from core.migration import MigrationCoordinator, MigrationError +from core.migration_recovery import MigrationRecovery, MigrationRecoveryError +from core.migration_archive import MigrationArchive +from core.trusted_rehearsal import TrustedRehearsal +from core.operator_approval import OperatorApprovalPolicy, OperatorGrant +from core.releases import ReleaseManager +from core.transactions import TransactionError, TransactionJournal + +REVISION="84a7a5b23796b15cab830034aae256b9414e9693" +fixture.EXPECTED=REVISION +fixture.REPO=REPO +MIGRATION="2026_11_28_000001_recovery_probe" +BASE="2026_01_01_000000_create_fixture" +SITE="absdev-migration-lab" + + +def digest(path): + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def write(name,data): + (ROOT/name).write_text(json.dumps(data,indent=2,sort_keys=True)+"\n") + + +def exercise(name): + fixture.ready("postgres",name,"postgres") + admin=fixture.connect("postgres",name,"admin","postgres") + good(admin,"CREATE DATABASE fixture;") + database=fixture.connect("postgres",name,"admin") + for account in ("migration_user","backup_user"): + good(database,f"CREATE ROLE {account} LOGIN PASSWORD '{PASSWORDS[account]}';") + good(database,f""" +REVOKE CONNECT, TEMPORARY ON DATABASE fixture FROM PUBLIC; +GRANT CONNECT ON DATABASE fixture TO migration_user,backup_user; +CREATE SCHEMA work AUTHORIZATION migration_user; +GRANT USAGE ON SCHEMA work TO backup_user; +ALTER DEFAULT PRIVILEGES FOR ROLE migration_user IN SCHEMA work GRANT SELECT ON TABLES TO backup_user; +REVOKE ALL ON FUNCTION pg_catalog.pg_control_system() FROM PUBLIC; +GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO backup_user,migration_user; +""") + migration=fixture.connect("postgres",name,"migration_user") + good(migration,f""" +CREATE TABLE work.migrations(name TEXT PRIMARY KEY); +INSERT INTO work.migrations VALUES ('{BASE}'); +CREATE TABLE work.items(id INT PRIMARY KEY, label TEXT); +INSERT INTO work.items VALUES (1,'original'); +""") + server=good(database,"SELECT system_identifier FROM pg_control_system();") + pgpass="".join(f"127.0.0.1:5432:fixture:{role}:{PASSWORDS[role]}\n" + for role in ("backup_user","migration_user")) + good((*DOCKER,"exec","-i",name,"sh","-c","umask 077; mkdir -p /run/secrets; cat >/run/secrets/absdev-pgpass"),pgpass) + config=json.loads((REPO/"config/site.example.json").read_text()) + config["database"].update(driver="pgsql",container=name,host="127.0.0.1",port=5432,name="fixture",username="backup_user") + backup_adapter=get_adapter(config) + config["database"]["username"]="migration_user" + migration_adapter=get_adapter(config) + commands=[backup_adapter.live_identity_command(),backup_adapter.backup_command(),migration_adapter.live_identity_command()] + runner=CommandRunner([["sudo","-n",*args] for args in commands],timeout=50) + def run(args,out): + runner(["sudo","-n",*args],out) + backup_probe=DatabaseIdentityProbe(backup_adapter,run,server_id=server) + identity=DatabaseIdentityProbe(migration_adapter,run,server_id=server) + db_identity=canonical_hash(identity.observe()) + backup_dir=ROOT/"backups" + backup_dir.mkdir() + backup=BackupEngine(backup_adapter,backup_dir,run,live_identity=backup_probe) + artifact=backup.create() + manifest=backup.verify(artifact) + require(backup_probe(),"Backup identity not verified") + write("backup-manifest.json",manifest) + record("postgres","real transactionally consistent PostgreSQL backup verified","PASS",manifest["sha256"]) + + scratch="isolated_restore_migration_ci" + rehearsal_id=canonical_hash({"database":scratch,"cluster":server}) + + app=ROOT/"app" + versions={} + for version in ("1","2","3"): + p=app/"releases"/version + (p/"vendor").mkdir(parents=True) + (p/"public/build").mkdir(parents=True) + (p/"vendor/autoload.php").write_text("