feat(rescue): add global catalog schema
parent
d2a00767b2
commit
7fd9fa44ca
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
/** Global immutable rescue ISO catalog entry and retirement tombstone. */
|
||||
final class CloudRescueTemplate extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'cloud_rescue_templates';
|
||||
protected $primaryKey = 'id';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
protected $casts = [
|
||||
'size_bytes' => 'int',
|
||||
'revision' => 'int',
|
||||
'active_job_id' => 'int',
|
||||
'created_at' => 'int',
|
||||
'updated_at' => 'int',
|
||||
];
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
/** Canonical immutable object behind one rescue ISO generation. */
|
||||
final class CloudRescueTemplateArtifact extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'cloud_rescue_template_artifacts';
|
||||
protected $primaryKey = 'template_id';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
protected $hidden = ['sealed_storage_runtime'];
|
||||
protected $casts = [
|
||||
'storage_revision' => 'int',
|
||||
'size_bytes' => 'int',
|
||||
'delete_generation' => 'int',
|
||||
'delete_cycle_attempts' => 'int',
|
||||
'delete_presence_confirmations' => 'int',
|
||||
'delete_last_checked_at' => 'int',
|
||||
'delete_next_check_at' => 'int',
|
||||
'delete_attention_at' => 'int',
|
||||
'verified_at' => 'int',
|
||||
'created_at' => 'int',
|
||||
'updated_at' => 'int',
|
||||
];
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
/** Host-local exact rescue ISO copy and retirement cleanup debt. */
|
||||
final class CloudRescueTemplateReplica extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'cloud_rescue_template_replicas';
|
||||
public $incrementing = false;
|
||||
protected $primaryKey = 'template_id';
|
||||
protected $keyType = 'string';
|
||||
protected $casts = [
|
||||
'host_id' => 'int',
|
||||
'revision' => 'int',
|
||||
'size_bytes' => 'int',
|
||||
'job_id' => 'int',
|
||||
'observed_revision' => 'int',
|
||||
'observed_size_bytes' => 'int',
|
||||
'last_verified_at' => 'int',
|
||||
'cleanup_resolved_at' => 'int',
|
||||
'created_at' => 'int',
|
||||
'updated_at' => 'int',
|
||||
];
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$schema = file_get_contents($root . '/sql/cloud.sql');
|
||||
$setup = file_get_contents($root . '/app/Command/CloudSetup.php');
|
||||
$assert = static function (bool $condition, string $message): void {
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
};
|
||||
if (!is_string($schema) || !is_string($setup)) {
|
||||
throw new RuntimeException('Rescue catalog schema sources are unreadable.');
|
||||
}
|
||||
|
||||
foreach ([
|
||||
'cloud_rescue_templates',
|
||||
'cloud_rescue_template_artifacts',
|
||||
'cloud_rescue_template_replicas',
|
||||
] as $table) {
|
||||
$assert(str_contains($schema, 'CREATE TABLE ' . $table . ' ('),
|
||||
'Missing global rescue catalog table: ' . $table);
|
||||
$assert(str_contains($setup, "'" . $table . "'"),
|
||||
'CloudSetup does not require global rescue table: ' . $table);
|
||||
}
|
||||
|
||||
$catalog = preg_match(
|
||||
'/CREATE TABLE cloud_rescue_templates \((.*?)\n\) ENGINE=/s',
|
||||
$schema,
|
||||
$catalogMatch
|
||||
) === 1 ? $catalogMatch[1] : '';
|
||||
$artifact = preg_match(
|
||||
'/CREATE TABLE cloud_rescue_template_artifacts \((.*?)\n\) ENGINE=/s',
|
||||
$schema,
|
||||
$artifactMatch
|
||||
) === 1 ? $artifactMatch[1] : '';
|
||||
$replica = preg_match(
|
||||
'/CREATE TABLE cloud_rescue_template_replicas \((.*?)\n\) ENGINE=/s',
|
||||
$schema,
|
||||
$replicaMatch
|
||||
) === 1 ? $replicaMatch[1] : '';
|
||||
|
||||
$assert($catalog !== ''
|
||||
&& str_contains($catalog, 'generation_token CHAR(32)')
|
||||
&& str_contains($catalog, 'revision BIGINT UNSIGNED')
|
||||
&& str_contains($catalog, 'active_job_id BIGINT UNSIGNED'),
|
||||
'Rescue master does not retain immutable identity and active-job fencing.');
|
||||
$assert($artifact !== ''
|
||||
&& str_contains($artifact, 'sealed_storage_runtime LONGTEXT')
|
||||
&& str_contains($artifact, 'object_version_id VARCHAR(1024)')
|
||||
&& str_contains($artifact, 'delete_presence_confirmations')
|
||||
&& str_contains($artifact, 'delete_attention_at'),
|
||||
'Rescue artifact cannot reconcile exact provider deletion effects.');
|
||||
$assert($replica !== ''
|
||||
&& str_contains($replica, 'observed_generation_token CHAR(32)')
|
||||
&& str_contains($replica, 'observed_sha256 CHAR(64)')
|
||||
&& str_contains($replica, 'cleanup_resolved_at BIGINT UNSIGNED'),
|
||||
'Rescue replica cannot prove exact identity or retain cleanup debt.');
|
||||
$assert(str_contains($setup,
|
||||
"SCHEMA_VERSION = 'go-agent-wss-v17-rescue-artifacts'")
|
||||
&& str_contains($setup, "'cloud_rescue_artifact_delete_due'")
|
||||
&& str_contains($setup, "'cloud_rescue_replica_cleanup'"),
|
||||
'CloudSetup version or rescue catalog indexes are incomplete.');
|
||||
|
||||
echo "Global rescue catalog schema contract passed.\n";
|
||||
Loading…
Reference in New Issue