Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 24s
Foundation / server-image (push) Successful in 4m33s
Foundation / image (push) Successful in 4m59s
Session v14 carries the rules-13 revamp: a body block in the owner's view (members, emergence threshold, exclusions, Emerge open, payable energy, mass and the 20 traits), become, emerge and channel exclusions on actions, become on mutation choices, catalog offers (id, chance, cost) and the emerged ending. Older sessions never see a v14 field. The client shows Stay / Become offspring offers named from the shared catalog, continuing as a bud, the organism and its Emerge button, kept channels, the body and the emerged end screen. Bundle 15 (rules 13 on owner format 11) is durable: schema 60 admits it raw-only, stores become as bit 15 of the choice's operator, widens the action input and mutation results, and publishes the 14 -> 15 revamp profile migration. evo-world-clone opens cellular-v10 (cellular-v9 plus the revamp upgrade from --revamp-tuning), resumable and recoverable. Wildlife counts reserve matter as energy, waits for the bud fee, grows organisms one short of emerging, and hunts by the region step's rules-13 engulf test. The play summary adds organisms, offers and the spent pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
142 lines
11 KiB
Bash
142 lines
11 KiB
Bash
#!/usr/bin/env bash
|
|
# Private postgres-check cluster only. No deployed database or biological rules.
|
|
set -euo pipefail
|
|
root="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
createdb evo_history_domain
|
|
export PGDATABASE=evo_history_domain
|
|
bash "$root/tools/migrate-postgres.sh" > /dev/null
|
|
sql() { psql -XAt --no-password -v ON_ERROR_STOP=1 "$@"; }
|
|
fail() { echo "history-domain qualification FAILED: $*" >&2; exit 1; }
|
|
original="$(sql -c 'SELECT evolution.load_history_domain_v1()')"
|
|
[ -n "$original" ] || fail 'missing adoption domain'
|
|
bash "$root/tools/migrate-postgres.sh" > /dev/null
|
|
[ "$(sql -c 'SELECT evolution.load_history_domain_v1()')" = "$original" ] || fail 'no-op changed domain'
|
|
work="$(mktemp -d /tmp/evo-history-domain.XXXXXXXX)"
|
|
objects="$work/objects"
|
|
mkdir -m 700 "$objects"
|
|
trap 'rm -rf -- "$work"' EXIT
|
|
"${EVO_WORLD_CLONE_BIN:?private fixture tool}" provision --world 70201 --region 1 \
|
|
--opening development-v1 --pg-host "$PGHOST" --pg-port "$PGPORT" \
|
|
--pg-database "$PGDATABASE" --pg-user "$PGUSER" --objects "$objects" \
|
|
--build "$(printf 'cd%.0s' {1..32})" --retain-build true > /dev/null
|
|
request=51515151-5151-5151-5151-515151515151
|
|
if sql -c "SELECT evolution.fork_restored_history_v1('$request')" > /dev/null 2>&1; then
|
|
fail 'fork accepted a current build'
|
|
fi
|
|
[ "$(sql -c 'SELECT evolution.load_history_domain_v1()')" = "$original" ] || fail 'refusal mutated domain'
|
|
sql -c 'UPDATE evolution.retained_builds SET retired_at=clock_timestamp()' > /dev/null
|
|
if PGUSER="$EVO_PG_RUNTIME_USER" sql -c "SELECT evolution.fork_restored_history_v1('$request')" > /dev/null 2>&1; then
|
|
fail 'runtime can fork history'
|
|
fi
|
|
if PGUSER="$EVO_PG_RUNTIME_USER" sql -c 'SELECT * FROM evolution.current_history_domain' > /dev/null 2>&1; then
|
|
fail 'runtime can access context tables'
|
|
fi
|
|
sql -c "UPDATE evolution.region_leases SET epoch=1, holder=pg_catalog.gen_random_uuid(), expires_at=clock_timestamp()+interval '1 hour'" > /dev/null
|
|
if sql -c "SELECT evolution.fork_restored_history_v1('$request')" > /dev/null 2>&1; then
|
|
fail 'fork accepted a held lease'
|
|
fi
|
|
sql -c 'UPDATE evolution.region_leases SET holder=NULL, expires_at=NULL' > /dev/null
|
|
# An aborted transaction leaves both the namespace and provenance unchanged.
|
|
sql -c "BEGIN; SELECT evolution.fork_restored_history_v1('$request'); ROLLBACK" > /dev/null
|
|
[ "$(sql -c 'SELECT count(*) FROM evolution.history_domains')" = 1 ] &&
|
|
[ "$(sql -c 'SELECT count(*) FROM evolution.history_domain_cuts')" = 0 ] || fail 'rollback retained fork evidence'
|
|
fork="$(sql -c "SELECT evolution.fork_restored_history_v1('$request')")"
|
|
[ "$fork" != "$original" ] && [ -n "$fork" ] || fail 'fork reused parent domain'
|
|
[ "$(sql -c "SELECT evolution.fork_restored_history_v1('$request')")" = "$fork" ] &&
|
|
[ "$(sql -c 'SELECT count(*) FROM evolution.history_domains')" = 2 ] || fail 'retry duplicated fork'
|
|
[ "$(PGUSER="$EVO_PG_RUNTIME_USER" sql -c 'SELECT evolution.load_history_domain_v1()')" = "$fork" ] || fail 'runtime context read'
|
|
[ "$(sql -c "SELECT parent::text||':'||kind FROM evolution.history_domains WHERE domain='$fork'")" = "$original:restore" ] || fail 'parent provenance'
|
|
[ "$(sql -c "SELECT count(*) FROM evolution.history_domain_cuts d JOIN evolution.region_heads h USING(world_id,region_id) JOIN evolution.region_leases l USING(world_id,region_id) WHERE d.domain='$fork' AND d.frame_id=l.frame_id AND d.commit_sequence=h.commit_sequence AND d.commit_id=h.commit_id AND d.digest=h.digest AND d.end_tick=h.end_tick")" = 1 ] || fail 'exact fork cuts'
|
|
sql -c "SELECT evolution.fork_restored_history_v1('52525252-5252-5252-5252-525252525252')" > /dev/null
|
|
if sql -c "SELECT evolution.fork_restored_history_v1('$request')" > /dev/null 2>&1; then
|
|
fail 'stale request switched context backwards'
|
|
fi
|
|
for invalid in NULL "'00000000-0000-0000-0000-000000000000'"; do
|
|
if sql -c "SELECT evolution.fork_restored_history_v1($invalid)" > /dev/null 2>&1; then
|
|
fail 'invalid request accepted'
|
|
fi
|
|
done
|
|
# Reconstruct the exact pre-context metadata schema in this disposable database.
|
|
# Restore the resulting real legacy backup through both supported workflows.
|
|
# Undo schema 60's bundle-15 wrappers, schema 59's queue publishers, schema 58's bundle-14 wrappers, schema 57's bundle-13 wrappers, schema 56's joint profile, schema 55's plan validators, schema 54's three
|
|
# replacements and schema 53; the backup must contain the actual pre-context
|
|
# function contracts and privileges.
|
|
awk '/^CREATE FUNCTION evolution\.admit_population_interval\(/ {capture=1; sub(/^CREATE FUNCTION/,"CREATE OR REPLACE FUNCTION")} capture {print} capture && /^END \$\$;/ {capture=0}' \
|
|
"$root/migrations/0045_owned_population_intervals.sql" | sql > /dev/null
|
|
awk '/^CREATE FUNCTION evolution\.(check_cellular_migration_trace|prepare_cellular_migration_freeze|publish_cellular_migration)\(/ {capture=1; sub(/^CREATE FUNCTION/,"CREATE OR REPLACE FUNCTION")} capture {print} capture && /^END \$\$;/ {capture=0}' \
|
|
"$root/migrations/0047_cellular_migration_freeze.sql" \
|
|
"$root/migrations/0049_cellular_migration_publication.sql" | sql > /dev/null
|
|
awk '/^CREATE OR REPLACE FUNCTION evolution\.(cellular_mutation_selections|check_cellular_mutation_block)\(/ {capture=1} capture {print} capture && /^END \$\$;/ {capture=0}' \
|
|
"$root/migrations/0040_cellular_mutation_decline.sql" | sql > /dev/null
|
|
# Schema 59 removed the exact-tick refusals; restore schema 35's two publishers.
|
|
awk '/^CREATE FUNCTION evolution\.(publish_cellular_checkpoint|publish_cellular_mutation_checkpoint)\(/ {capture=1; sub(/^CREATE FUNCTION/,"CREATE OR REPLACE FUNCTION")} capture {print} capture && /^END \$\$;/ {capture=0}' \
|
|
"$root/migrations/0035_cellular_mutation_publication.sql" | sql > /dev/null
|
|
# Schema 58 widened the canonical action input; restore schema 36's validator.
|
|
awk '/^CREATE OR REPLACE FUNCTION evolution\.valid_cellular_action_input\(/ {capture=1} capture {print} capture && /^END \$\$;/ {capture=0}' \
|
|
"$root/migrations/0036_cellular_v5_budding_bundle.sql" | sql > /dev/null
|
|
sql -v runtime_role="$EVO_PG_RUNTIME_ROLE" > /dev/null <<'SQL'
|
|
DROP FUNCTION evolution.publish_cellular_profile_migration(bytea);
|
|
ALTER FUNCTION evolution.publish_cellular_profile_migration_v59(bytea) RENAME TO publish_cellular_profile_migration;
|
|
DROP FUNCTION evolution.cellular_births(bytea,bytea);
|
|
ALTER FUNCTION evolution.cellular_births_v59(bytea,bytea) RENAME TO cellular_births;
|
|
DROP FUNCTION evolution.parse_checkpoint_manifest(bytea);
|
|
ALTER FUNCTION evolution.parse_checkpoint_manifest_v59(bytea) RENAME TO parse_checkpoint_manifest;
|
|
DROP FUNCTION evolution.publish_cellular_profile_migration(bytea);
|
|
ALTER FUNCTION evolution.publish_cellular_profile_migration_v57(bytea) RENAME TO publish_cellular_profile_migration;
|
|
DROP FUNCTION evolution.cellular_births(bytea,bytea);
|
|
ALTER FUNCTION evolution.cellular_births_v57(bytea,bytea) RENAME TO cellular_births;
|
|
DROP FUNCTION evolution.parse_checkpoint_manifest(bytea);
|
|
ALTER FUNCTION evolution.parse_checkpoint_manifest_v57(bytea) RENAME TO parse_checkpoint_manifest;
|
|
DROP FUNCTION evolution.publish_cellular_profile_migration(bytea);
|
|
ALTER FUNCTION evolution.publish_cellular_profile_migration_v56(bytea) RENAME TO publish_cellular_profile_migration;
|
|
DROP FUNCTION evolution.cellular_births(bytea,bytea);
|
|
ALTER FUNCTION evolution.cellular_births_v56(bytea,bytea) RENAME TO cellular_births;
|
|
DROP FUNCTION evolution.parse_checkpoint_manifest(bytea);
|
|
ALTER FUNCTION evolution.parse_checkpoint_manifest_v56(bytea) RENAME TO parse_checkpoint_manifest;
|
|
DROP TRIGGER region_environment_evidence ON evolution.region_commits;
|
|
DROP FUNCTION evolution.refuse_unpublished_environment();
|
|
DROP FUNCTION evolution.load_environment_evidence(evolution.u64,evolution.u64,uuid,evolution.u64,uuid);
|
|
DROP FUNCTION evolution.resolve_environment_commit(evolution.u64,evolution.u64,uuid,bytea,bytea);
|
|
DROP FUNCTION evolution.publish_environment_profile_transition(bytea);
|
|
DROP FUNCTION evolution.publish_environment_checkpoint(bytea,bytea);
|
|
DROP FUNCTION evolution.check_environment_trace(bytea,bytea);
|
|
DROP TABLE evolution.environment_publications, evolution.environment_profile_transitions;
|
|
DROP FUNCTION evolution.parse_checkpoint_manifest(bytea);
|
|
DROP FUNCTION evolution.parse_checkpoint_manifest_v55(bytea);
|
|
DROP FUNCTION evolution.parse_checkpoint_manifest_v54(bytea);
|
|
ALTER FUNCTION evolution.parse_checkpoint_manifest_v52(bytea) RENAME TO parse_checkpoint_manifest;
|
|
DROP FUNCTION evolution.cellular_births(bytea,bytea);
|
|
DROP FUNCTION evolution.cellular_births_v54(bytea,bytea);
|
|
ALTER FUNCTION evolution.cellular_births_v52(bytea,bytea) RENAME TO cellular_births;
|
|
DROP FUNCTION evolution.check_population_trace(bytea,bytea);
|
|
ALTER FUNCTION evolution.check_population_trace_v52(bytea,bytea) RENAME TO check_population_trace;
|
|
DROP FUNCTION evolution.publish_cellular_profile_migration(bytea);
|
|
DROP FUNCTION evolution.publish_cellular_profile_migration_v54(bytea);
|
|
ALTER FUNCTION evolution.publish_cellular_profile_migration_v52(bytea) RENAME TO publish_cellular_profile_migration;
|
|
GRANT EXECUTE ON FUNCTION evolution.publish_cellular_profile_migration(bytea) TO :"runtime_role";
|
|
DROP FUNCTION evolution.publish_population_profile_transition_v44(bytea);
|
|
ALTER FUNCTION evolution.publish_population_profile_transition_v52(bytea) RENAME TO publish_population_profile_transition_v44;
|
|
DROP FUNCTION evolution.fork_restored_history_v1(uuid);
|
|
DROP FUNCTION evolution.load_world_cellular_migrations_v1(evolution.u64);
|
|
DROP FUNCTION evolution.load_history_domain_v1();
|
|
DROP TABLE evolution.history_domain_cuts, evolution.current_history_domain, evolution.history_domains;
|
|
ALTER TABLE evolution.cellular_mutation_action_publications DROP CONSTRAINT cellular_mutation_action_publications_result_check;
|
|
ALTER TABLE evolution.cellular_mutation_action_publications ADD CONSTRAINT cellular_mutation_action_publications_result_check CHECK(result BETWEEN 0 AND 3);
|
|
DELETE FROM evolution.schema_migrations WHERE version>=51;
|
|
UPDATE evolution.retained_builds SET retired_at=NULL;
|
|
SQL
|
|
bash "$root/tools/backup/backup-world.sh" --objects "$objects" --out "$work/legacy" --label legacy-context > /dev/null
|
|
createdb evo_history_legacy_isolated
|
|
PGDATABASE=evo_history_legacy_isolated bash "$root/tools/backup/restore-world.sh" \
|
|
--bundle "$work/legacy" --objects "$work/isolated" > "$work/isolated.log" 2>&1 ||
|
|
{ cat "$work/isolated.log" >&2; fail 'legacy isolated restore'; }
|
|
[ "$(PGDATABASE=evo_history_legacy_isolated sql -c "SELECT to_regprocedure('evolution.load_history_domain_v1()') IS NULL")" = t ] || fail 'invented legacy source context'
|
|
createdb evo_history_legacy_inplace
|
|
PGDATABASE=evo_history_legacy_inplace bash "$root/tools/backup/restore-world.sh" \
|
|
--bundle "$work/legacy" --objects "$work/inplace" --in-place \
|
|
--runtime-role "$EVO_PG_RUNTIME_ROLE" --accept-rewind > "$work/inplace.log" 2>&1 ||
|
|
{ cat "$work/inplace.log" >&2; fail 'legacy in-place restore'; }
|
|
[ "$(PGDATABASE=evo_history_legacy_inplace sql -c "SELECT count(*) FROM evolution.history_domains WHERE kind='adoption' AND parent IS NULL AND request IS NULL")" = 1 ] &&
|
|
[ "$(PGDATABASE=evo_history_legacy_inplace sql -c 'SELECT count(*) FROM evolution.history_domain_cuts')" = 0 ] || fail 'invented legacy branch provenance'
|
|
echo 'history-domain adoption, quarantine, rollback, exact cuts, retries, privileges and legacy restores passed'
|