feat(i18n): add user copy publication ledger

go
codex 2 weeks ago
parent 5258310c2b
commit 884a606c2e

@ -8,7 +8,12 @@ use App\Services\Config;
/** Initializes only the clean-break PHP business and Agent log schemas. */
final class CloudSetup
{
private const SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation';
private const SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog';
/** Tables installed by ss.sql before cloudInit and owned by this schema. */
private const PREINSTALLED_MAIN_TABLES = [
'ui_copy_locales', 'ui_copy_entries', 'ui_copy_drafts',
'ui_copy_publications', 'ui_copy_revision_items',
];
private const MAIN_TABLES = [
'cloud_regions', 'cloud_traffic_pool_groups',
'cloud_network_lines', 'cloud_resource_pools',
@ -75,6 +80,41 @@ final class CloudSetup
'engine_vm_traffic_checkpoints', 'engine_vm_traffic_totals',
];
private const REQUIRED_MAIN_COLUMNS = [
'ui_copy_locales' => [
'id', 'locale', 'display_name', 'enabled', 'source_claim',
'created_by', 'updated_by', 'created_at', 'updated_at',
],
'ui_copy_entries' => [
'id', 'copy_key', 'scope', 'page_key', 'location', 'kind',
'format', 'criticality', 'required', 'allow_hide', 'max_length',
'source_text_zh', 'source_hash_zh',
'placeholder_contract_json', 'placeholder_hash',
'manifest_revision', 'state', 'first_seen_at', 'last_seen_at',
'created_by', 'updated_by', 'created_at', 'updated_at',
],
'ui_copy_drafts' => [
'id', 'entry_id', 'locale_id', 'draft_text', 'draft_hash',
'visibility', 'translated_source_hash_zh',
'translated_placeholder_hash', 'draft_version',
'validation_state', 'validation_errors_json', 'created_by',
'updated_by', 'created_at', 'updated_at',
],
'ui_copy_publications' => [
'id', 'publication_key', 'locale_id', 'revision',
'catalog_generation',
'previous_publication_id', 'manifest_revision',
'manifest_hash', 'catalog_hash', 'artifact_path', 'entry_count',
'state', 'request_idempotency_key', 'request_fingerprint',
'requested_by', 'published_by', 'prepared_at', 'published_at',
'error_code', 'created_at', 'updated_at',
],
'ui_copy_revision_items' => [
'id', 'publication_id', 'entry_id', 'copy_key',
'source_text_zh', 'published_text', 'visibility',
'source_hash_zh', 'placeholder_contract_json',
'placeholder_hash', 'published_hash', 'manifest_revision',
'draft_version', 'created_at',
],
'cloud_storage_backend_catalog_mutex' => [
'id', 'updated_at',
],
@ -569,6 +609,22 @@ final class CloudSetup
],
];
private const REQUIRED_CHECKS = [
'ui_copy_locales' => [
'chk_ui_copy_locale_shape',
],
'ui_copy_entries' => [
'chk_ui_copy_entry_shape',
],
'ui_copy_drafts' => [
'chk_ui_copy_draft_shape',
],
'ui_copy_publications' => [
'chk_ui_copy_publication_identity',
'chk_ui_copy_publication_terminal',
],
'ui_copy_revision_items' => [
'chk_ui_copy_revision_item_shape',
],
'cloud_storage_backend_catalog_mutex' => [
'chk_cloud_storage_backend_catalog_mutex',
],
@ -803,6 +859,28 @@ final class CloudSetup
],
];
private const REQUIRED_INDEXES = [
'ui_copy_locales' => [
'PRIMARY', 'ui_copy_locale_name', 'ui_copy_locale_source',
'ui_copy_locale_enabled',
],
'ui_copy_entries' => [
'PRIMARY', 'ui_copy_entry_key', 'ui_copy_entry_page',
'ui_copy_entry_scope', 'ui_copy_entry_manifest',
],
'ui_copy_drafts' => [
'PRIMARY', 'ui_copy_draft_entry_locale',
'ui_copy_draft_locale', 'ui_copy_draft_editor',
],
'ui_copy_publications' => [
'PRIMARY', 'ui_copy_publication_key',
'ui_copy_publication_revision',
'ui_copy_publication_generation', 'ui_copy_publication_request',
'ui_copy_publication_history', 'ui_copy_publication_previous',
],
'ui_copy_revision_items' => [
'PRIMARY', 'ui_copy_revision_item_entry',
'ui_copy_revision_item_key', 'ui_copy_revision_entry_history',
],
'cloud_storage_backend_catalog_mutex' => [
'PRIMARY',
],
@ -1172,6 +1250,56 @@ final class CloudSetup
* non-unique. Column order is part of the ownership/fencing semantics.
*/
private const REQUIRED_INDEX_SHAPES = [
'ui_copy_locales' => [
'ui_copy_locale_name' => [
'non_unique' => 0,
'columns' => ['locale'],
],
'ui_copy_locale_source' => [
'non_unique' => 0,
'columns' => ['source_claim'],
],
],
'ui_copy_entries' => [
'ui_copy_entry_key' => [
'non_unique' => 0,
'columns' => ['copy_key'],
],
],
'ui_copy_drafts' => [
'ui_copy_draft_entry_locale' => [
'non_unique' => 0,
'columns' => ['entry_id', 'locale_id'],
],
],
'ui_copy_publications' => [
'ui_copy_publication_key' => [
'non_unique' => 0,
'columns' => ['publication_key'],
],
'ui_copy_publication_revision' => [
'non_unique' => 0,
'columns' => ['locale_id', 'revision'],
],
'ui_copy_publication_generation' => [
'non_unique' => 0,
'columns' => ['locale_id', 'catalog_generation'],
],
'ui_copy_publication_request' => [
'non_unique' => 0,
'columns' => ['requested_by', 'request_idempotency_key'],
],
],
'ui_copy_revision_items' => [
'ui_copy_revision_item_entry' => [
'non_unique' => 0,
'columns' => ['publication_id', 'entry_id'],
],
'ui_copy_revision_item_key' => [
'non_unique' => 0,
'columns' => ['publication_id', 'copy_key'],
],
],
'cloud_instance_backups' => [
'cloud_instance_backup_create_request' => [
'non_unique' => 0,
@ -1623,7 +1751,7 @@ final class CloudSetup
$logConnection): void
{
$schema = $connection->getSchemaBuilder();
foreach (self::MAIN_TABLES as $table) {
foreach (self::managedMainTables() as $table) {
if (!$schema->hasTable($table)) {
throw new \RuntimeException(
'云数据库结构不完整,请使用全新数据库:' . $table
@ -1748,7 +1876,8 @@ final class CloudSetup
private static function schemaMarker(): string
{
return self::SCHEMA_VERSION . ':' . hash('sha256',
self::schema('cloud.sql') . "\0" . self::schema('cloud_log.sql')
self::schema('ss.sql') . "\0" . self::schema('cloud.sql')
. "\0" . self::schema('cloud_log.sql')
);
}
@ -1757,12 +1886,19 @@ final class CloudSetup
$logConnection): string
{
return hash('sha256', json_encode([
'main' => self::schemaObjects($connection, self::MAIN_TABLES),
'main' => self::schemaObjects(
$connection, self::managedMainTables()
),
'log' => self::schemaObjects($logConnection, self::LOG_TABLES),
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES
| JSON_UNESCAPED_UNICODE));
}
private static function managedMainTables(): array
{
return array_merge(self::PREINSTALLED_MAIN_TABLES, self::MAIN_TABLES);
}
private static function schemaObjects($connection, array $tables): array
{
$database = (string) $connection->getDatabaseName();

@ -0,0 +1,21 @@
<?php
namespace App\Models;
/** Optimistically-versioned administrator draft for one entry and locale. */
final class UiCopyDraft extends Model
{
protected $connection = 'default';
protected $table = 'ui_copy_drafts';
protected $casts = [
'id' => 'int',
'entry_id' => 'int',
'locale_id' => 'int',
'draft_version' => 'int',
'validation_errors_json' => 'array',
'created_by' => 'int',
'updated_by' => 'int',
'created_at' => 'int',
'updated_at' => 'int',
];
}

@ -0,0 +1,24 @@
<?php
namespace App\Models;
/** Source-owned Chinese copy slot discovered from the executable manifest. */
final class UiCopyEntry extends Model
{
protected $connection = 'default';
protected $table = 'ui_copy_entries';
protected $casts = [
'id' => 'int',
'required' => 'bool',
'allow_hide' => 'bool',
'max_length' => 'int',
'placeholder_contract_json' => 'array',
'manifest_revision' => 'int',
'first_seen_at' => 'int',
'last_seen_at' => 'int',
'created_by' => 'int',
'updated_by' => 'int',
'created_at' => 'int',
'updated_at' => 'int',
];
}

@ -0,0 +1,19 @@
<?php
namespace App\Models;
/** Locale registry; the compiled current.json remains the runtime pointer. */
final class UiCopyLocale extends Model
{
protected $connection = 'default';
protected $table = 'ui_copy_locales';
protected $casts = [
'id' => 'int',
'enabled' => 'bool',
'source_claim' => 'int',
'created_by' => 'int',
'updated_by' => 'int',
'created_at' => 'int',
'updated_at' => 'int',
];
}

@ -0,0 +1,24 @@
<?php
namespace App\Models;
/** Immutable locale catalog generation prepared and published atomically. */
final class UiCopyPublication extends Model
{
protected $connection = 'default';
protected $table = 'ui_copy_publications';
protected $casts = [
'id' => 'int',
'locale_id' => 'int',
'revision' => 'int',
'previous_publication_id' => 'int',
'manifest_revision' => 'int',
'entry_count' => 'int',
'requested_by' => 'int',
'published_by' => 'int',
'prepared_at' => 'int',
'published_at' => 'int',
'created_at' => 'int',
'updated_at' => 'int',
];
}

@ -0,0 +1,19 @@
<?php
namespace App\Models;
/** Immutable published value and Chinese baseline evidence for one copy key. */
final class UiCopyRevisionItem extends Model
{
protected $connection = 'default';
protected $table = 'ui_copy_revision_items';
protected $casts = [
'id' => 'int',
'publication_id' => 'int',
'entry_id' => 'int',
'placeholder_contract_json' => 'array',
'manifest_revision' => 'int',
'draft_version' => 'int',
'created_at' => 'int',
];
}

@ -66,6 +66,161 @@ CREATE TABLE `legal_document_revisions` (
`published_by` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `ui_copy_locales` (
`id` bigint(20) UNSIGNED NOT NULL,
`locale` varchar(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`display_name` varchar(128) NOT NULL,
`enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
`source_claim` tinyint(1) UNSIGNED DEFAULT NULL,
`created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
CONSTRAINT `chk_ui_copy_locale_shape` CHECK (
`locale` REGEXP '^[A-Za-z0-9]{2,16}(-[A-Za-z0-9]{2,16})*$'
AND `enabled` IN (0,1)
AND (`source_claim` IS NULL OR `source_claim` = 1)
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `ui_copy_entries` (
`id` bigint(20) UNSIGNED NOT NULL,
`copy_key` varchar(191) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`scope` varchar(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`page_key` varchar(96) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`location` varchar(191) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`kind` varchar(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`format` varchar(24) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'plain_text',
`criticality` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'normal',
`required` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
`allow_hide` tinyint(1) UNSIGNED NOT NULL DEFAULT 1,
`max_length` int(10) UNSIGNED NOT NULL DEFAULT 4096,
`source_text_zh` longtext NOT NULL,
`source_hash_zh` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`placeholder_contract_json` mediumtext NOT NULL,
`placeholder_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`manifest_revision` bigint(20) UNSIGNED NOT NULL DEFAULT 1,
`state` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'active',
`first_seen_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`last_seen_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
CONSTRAINT `chk_ui_copy_entry_shape` CHECK (
`copy_key` <> '' AND `scope` <> '' AND `page_key` <> ''
AND `location` <> '' AND `kind` <> ''
AND `format` IN ('plain_text','icu')
AND `criticality` IN ('normal','required','critical')
AND `required` IN (0,1) AND `allow_hide` IN (0,1)
AND (`required` = 0 OR `allow_hide` = 0)
AND (`criticality` = 'normal' OR `allow_hide` = 0)
AND `max_length` BETWEEN 1 AND 20000
AND `source_hash_zh` REGEXP '^[a-f0-9]{64}$'
AND `placeholder_hash` REGEXP '^[a-f0-9]{64}$'
AND `manifest_revision` > 0
AND `state` IN ('active','orphaned')
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `ui_copy_drafts` (
`id` bigint(20) UNSIGNED NOT NULL,
`entry_id` bigint(20) UNSIGNED NOT NULL,
`locale_id` bigint(20) UNSIGNED NOT NULL,
`draft_text` longtext NOT NULL,
`draft_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`visibility` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'visible',
`translated_source_hash_zh` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`translated_placeholder_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`draft_version` bigint(20) UNSIGNED NOT NULL DEFAULT 1,
`validation_state` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'pending',
`validation_errors_json` mediumtext NOT NULL,
`created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
CONSTRAINT `chk_ui_copy_draft_shape` CHECK (
`draft_hash` REGEXP '^[a-f0-9]{64}$'
AND `translated_source_hash_zh` REGEXP '^[a-f0-9]{64}$'
AND `translated_placeholder_hash` REGEXP '^[a-f0-9]{64}$'
AND `visibility` IN ('visible','hidden')
AND `draft_version` > 0
AND `validation_state` IN ('pending','valid','invalid','stale')
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `ui_copy_publications` (
`id` bigint(20) UNSIGNED NOT NULL,
`publication_key` char(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`locale_id` bigint(20) UNSIGNED NOT NULL,
`revision` bigint(20) UNSIGNED NOT NULL,
`catalog_generation` char(66) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`previous_publication_id` bigint(20) UNSIGNED DEFAULT NULL,
`manifest_revision` bigint(20) UNSIGNED NOT NULL,
`manifest_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`catalog_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
`artifact_path` varchar(512) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
`entry_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
`state` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'preparing',
`request_idempotency_key` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`request_fingerprint` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`requested_by` bigint(20) UNSIGNED NOT NULL,
`published_by` bigint(20) UNSIGNED DEFAULT NULL,
`prepared_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`published_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`error_code` varchar(128) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
CONSTRAINT `chk_ui_copy_publication_identity` CHECK (
`publication_key` REGEXP '^[a-f0-9]{32}$'
AND `revision` > 0
AND `catalog_generation` REGEXP '^g-[a-f0-9]{64}$'
AND `manifest_revision` > 0
AND `manifest_hash` REGEXP '^[a-f0-9]{64}$'
AND `request_idempotency_key` REGEXP '^[a-f0-9]{64}$'
AND `request_fingerprint` REGEXP '^[a-f0-9]{64}$'
),
CONSTRAINT `chk_ui_copy_publication_terminal` CHECK (
(`state` = 'preparing' AND `catalog_hash` = ''
AND `artifact_path` = '' AND `published_by` IS NULL
AND `published_at` = 0
AND `error_code` = '')
OR (`state` = 'ready'
AND `catalog_hash` REGEXP '^[a-f0-9]{64}$'
AND `artifact_path` <> '' AND `published_by` IS NOT NULL
AND `prepared_at` > 0 AND `published_at` > 0
AND `error_code` = '')
OR (`state` = 'failed' AND `published_by` IS NULL
AND `published_at` = 0 AND `error_code` <> '')
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `ui_copy_revision_items` (
`id` bigint(20) UNSIGNED NOT NULL,
`publication_id` bigint(20) UNSIGNED NOT NULL,
`entry_id` bigint(20) UNSIGNED NOT NULL,
`copy_key` varchar(191) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`source_text_zh` longtext NOT NULL,
`published_text` longtext NOT NULL,
`visibility` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`source_hash_zh` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`placeholder_contract_json` mediumtext NOT NULL,
`placeholder_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`published_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`manifest_revision` bigint(20) UNSIGNED NOT NULL,
`draft_version` bigint(20) UNSIGNED DEFAULT NULL,
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
CONSTRAINT `chk_ui_copy_revision_item_shape` CHECK (
`copy_key` <> ''
AND `visibility` IN ('visible','hidden')
AND `source_hash_zh` REGEXP '^[a-f0-9]{64}$'
AND `placeholder_hash` REGEXP '^[a-f0-9]{64}$'
AND `published_hash` REGEXP '^[a-f0-9]{64}$'
AND `manifest_revision` > 0
AND (`draft_version` IS NULL OR `draft_version` > 0)
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `coupon` (
`id` bigint(20) NOT NULL,
`code` text NOT NULL,
@ -518,6 +673,40 @@ ALTER TABLE `legal_document_revisions`
ADD UNIQUE KEY `uniq_legal_document_revision` (`document_id`,`version`),
ADD KEY `idx_legal_revision_published` (`document_id`,`published_at`);
ALTER TABLE `ui_copy_locales`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `ui_copy_locale_name` (`locale`),
ADD UNIQUE KEY `ui_copy_locale_source` (`source_claim`),
ADD KEY `ui_copy_locale_enabled` (`enabled`,`locale`);
ALTER TABLE `ui_copy_entries`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `ui_copy_entry_key` (`copy_key`),
ADD KEY `ui_copy_entry_page` (`page_key`,`state`,`id`),
ADD KEY `ui_copy_entry_scope` (`scope`,`state`,`id`),
ADD KEY `ui_copy_entry_manifest` (`manifest_revision`,`state`,`id`);
ALTER TABLE `ui_copy_drafts`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `ui_copy_draft_entry_locale` (`entry_id`,`locale_id`),
ADD KEY `ui_copy_draft_locale` (`locale_id`,`validation_state`,`updated_at`,`id`),
ADD KEY `ui_copy_draft_editor` (`updated_by`,`updated_at`,`id`);
ALTER TABLE `ui_copy_publications`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `ui_copy_publication_key` (`publication_key`),
ADD UNIQUE KEY `ui_copy_publication_revision` (`locale_id`,`revision`),
ADD UNIQUE KEY `ui_copy_publication_generation` (`locale_id`,`catalog_generation`),
ADD UNIQUE KEY `ui_copy_publication_request` (`requested_by`,`request_idempotency_key`),
ADD KEY `ui_copy_publication_history` (`locale_id`,`state`,`revision`),
ADD KEY `ui_copy_publication_previous` (`previous_publication_id`);
ALTER TABLE `ui_copy_revision_items`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `ui_copy_revision_item_entry` (`publication_id`,`entry_id`),
ADD UNIQUE KEY `ui_copy_revision_item_key` (`publication_id`,`copy_key`),
ADD KEY `ui_copy_revision_entry_history` (`entry_id`,`publication_id`);
ALTER TABLE `coupon`
ADD PRIMARY KEY (`id`);
@ -674,6 +863,21 @@ ALTER TABLE `legal_documents`
ALTER TABLE `legal_document_revisions`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `ui_copy_locales`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `ui_copy_entries`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `ui_copy_drafts`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `ui_copy_publications`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `ui_copy_revision_items`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `coupon`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

@ -52,7 +52,7 @@ foreach ([
'CloudSetup omits backup preparation contract: ' . $required);
}
$assert(str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'")
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'")
&& str_contains($setup,
"'columns' => [\n 'create_request_actor_id',\n 'create_request_idempotency_key',")
&& str_contains($setup, "'non_unique' => 0"),

@ -22,7 +22,7 @@ $assert(stripos($schema, 'compatibility import') === false
$assert(!preg_match('/\bengine_[A-Za-z0-9_]*\b/', $schema),
'cloud.sql retained an engine-prefixed identifier.');
$assert(str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'")
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'")
&& !str_contains($setup, "SCHEMA_VERSION = 'go-v1'"),
'Outbound Agent schema must reject the incompatible earlier Go database.');
$assert(str_contains($schema,

@ -56,7 +56,7 @@ foreach ([
}
$assert(str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'"),
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'"),
'CloudSetup schema version was not advanced for maintenance notices.');
echo "Maintenance notice schema contracts passed.\n";

@ -53,7 +53,7 @@ $assert(is_string($schema)
'Public-pool replacement lacks durable batch, child, or claim schema.');
$assert(is_string($setup)
&& str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'")
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'")
&& str_contains($setup,
"'cloud_public_ip_pool_replacement_batches'")
&& str_contains($setup,

@ -170,7 +170,7 @@ $assert(str_contains($setup,
'CloudSetup does not verify index uniqueness and ordered columns.');
$assert(str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'")
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'")
&& str_contains($setup, "'cloud_public_network_transitions'")
&& str_contains($setup, "'cloud_public_network_transition_ips'")
&& str_contains($setup, "'reservation_ip_claim_id'")

@ -57,7 +57,7 @@ $assert($replica !== ''
&& 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-v38-backup-publication-preparation'")
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'")
&& str_contains($setup, "'cloud_rescue_artifact_delete_due'")
&& str_contains($setup, "'cloud_rescue_replica_cleanup'"),
'CloudSetup version or rescue catalog indexes are incomplete.');

@ -218,7 +218,7 @@ foreach ([
'CloudSetup omits restore/migration ledger contract: ' . $required);
}
$assert(str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'")
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'")
&& str_contains($attemptModel,
"protected \$table = 'cloud_backup_restore_attempts';")
&& str_contains($attemptModel, "'active_attempt' => 'int'")

@ -105,7 +105,7 @@ $assert(str_contains($setup,
'CloudSetup lost the open-compensation fence index contract.');
$assert(str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'"),
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'"),
'CloudSetup schema version was not advanced for service compensation.');
$appliedShape = preg_match(

@ -137,7 +137,7 @@ $assert(is_string($publicationModel)
&& str_contains($artifactModel, "'maximum_size_bytes' => 'int'"),
'Storage publication/artifact model contracts are incomplete.');
$assert(str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'"),
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'"),
'CloudSetup schema version was not advanced for durable publications.');
echo "Storage publication schema contracts passed.\n";

@ -63,7 +63,7 @@ $assert(str_contains($schema,
&& str_contains($schema,
'CONSTRAINT chk_cloud_template_import_completion CHECK (')
&& str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'"),
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'"),
'Template imports are missing durable identity or terminal-state constraints.');
$assert(str_contains($routes, "'/admin/cloud-template-imports'")
&& str_contains($routes, "'/admin/cloud-template-imports/{id}'")

@ -71,7 +71,7 @@ $assert(str_contains($schema,
'Service-period traffic-pool identity is not frozen or indexed.');
$assert(str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'")
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'")
&& str_contains($setup, "'chk_cloud_traffic_entitlement_balance'")
&& str_contains($setup, "'cloud_traffic_ledger_sequence'"),
'CloudSetup schema version or named-object validation is incomplete.');

@ -101,7 +101,7 @@ $assert(str_contains($jobs, 'vpc_id BIGINT UNSIGNED DEFAULT NULL')
'Cloud jobs cannot be correlated to VPC or VPC-port work.');
$assert(str_contains($setup,
"private const SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'")
"private const SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'")
&& str_contains($setup, "'name' => 'cloud_vpc_enabled'")
&& str_contains($setup, "'value' => 'false'")
&& str_contains($setup,

@ -0,0 +1,114 @@
<?php
$root = dirname(__DIR__);
$schema = file_get_contents($root . '/sql/ss.sql');
$setup = file_get_contents($root . '/app/Command/CloudSetup.php');
$assert = static function (bool $condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$table = static function (string $name) use ($schema, $assert): string {
$matched = preg_match(
'/CREATE TABLE `' . preg_quote($name, '/')
. '` \(([\s\S]*?)\n\) ENGINE=InnoDB/',
$schema,
$match
) === 1;
$assert($matched, 'Missing UI copy table: ' . $name);
return $match[1];
};
$tables = [
'ui_copy_locales', 'ui_copy_entries', 'ui_copy_drafts',
'ui_copy_publications', 'ui_copy_revision_items',
];
foreach ($tables as $name) {
$table($name);
$assert(str_contains($setup, "'" . $name . "'"),
'CloudSetup does not own UI copy table: ' . $name);
}
$locale = $table('ui_copy_locales');
$entry = $table('ui_copy_entries');
$draft = $table('ui_copy_drafts');
$publication = $table('ui_copy_publications');
$revision = $table('ui_copy_revision_items');
$assert(!str_contains($locale, 'current_publication_id')
&& !str_contains($publication, 'active_claim')
&& !str_contains($locale, 'published_generation'),
'The database must not duplicate the runtime current.json pointer.');
$assert(str_contains($entry, '`source_text_zh` longtext NOT NULL')
&& str_contains($entry, '`source_hash_zh` char(64)')
&& str_contains($entry, '`placeholder_contract_json` mediumtext NOT NULL')
&& str_contains($entry, '`placeholder_hash` char(64)')
&& !preg_match('/(?:source|baseline|default)_(?:text_)?en\b/i', $entry),
'UI copy entries must contain only the Chinese source baseline.');
$assert(str_contains($draft, '`draft_version` bigint(20) UNSIGNED')
&& str_contains($draft, '`created_by` bigint(20) UNSIGNED')
&& str_contains($draft, '`updated_by` bigint(20) UNSIGNED')
&& str_contains($draft, '`validation_state` varchar(16)'),
'UI copy drafts lack optimistic versioning, validation or audit fields.');
$assert(str_contains($publication, '`revision` bigint(20) UNSIGNED')
&& str_contains($publication, '`catalog_generation` char(66)')
&& str_contains($publication, '`manifest_hash` char(64)')
&& str_contains($publication, '`catalog_hash` char(64)')
&& str_contains($publication, '`artifact_path` varchar(512)')
&& str_contains($publication, '`request_idempotency_key` char(64)')
&& str_contains($publication, '`request_fingerprint` char(64)')
&& str_contains($publication, '`published_by` bigint(20) UNSIGNED')
&& str_contains($publication, '`published_at` bigint(20) UNSIGNED'),
'UI copy publications lack durable generation or audit evidence.');
$assert(str_contains($revision, '`source_text_zh` longtext NOT NULL')
&& str_contains($revision, '`published_text` longtext NOT NULL')
&& str_contains($revision, '`placeholder_contract_json` mediumtext NOT NULL')
&& str_contains($revision, '`published_hash` char(64)'),
'UI copy revision items do not freeze publication evidence.');
foreach ([
'ui_copy_locale_name', 'ui_copy_locale_source',
'ui_copy_entry_key', 'ui_copy_draft_entry_locale',
'ui_copy_publication_key',
'ui_copy_publication_revision', 'ui_copy_publication_generation',
'ui_copy_publication_request',
'ui_copy_revision_item_entry', 'ui_copy_revision_item_key',
] as $index) {
$assert(str_contains($schema, 'UNIQUE KEY `' . $index . '`')
&& str_contains($setup, "'" . $index . "'"),
'UI copy unique-index contract is missing: ' . $index);
}
foreach ([
'chk_ui_copy_locale_shape', 'chk_ui_copy_entry_shape',
'chk_ui_copy_draft_shape', 'chk_ui_copy_publication_identity',
'chk_ui_copy_publication_terminal',
'chk_ui_copy_revision_item_shape',
] as $check) {
$assert(str_contains($schema, 'CONSTRAINT `' . $check . '`')
&& str_contains($setup, "'" . $check . "'"),
'UI copy CHECK contract is missing: ' . $check);
}
$models = [
'UiCopyLocale' => 'ui_copy_locales',
'UiCopyEntry' => 'ui_copy_entries',
'UiCopyDraft' => 'ui_copy_drafts',
'UiCopyPublication' => 'ui_copy_publications',
'UiCopyRevisionItem' => 'ui_copy_revision_items',
];
foreach ($models as $class => $modelTable) {
$model = file_get_contents($root . '/app/Models/' . $class . '.php');
$assert(is_string($model)
&& str_contains($model, "protected \$table = '" . $modelTable . "'"),
'UI copy model contract is missing: ' . $class);
}
$assert(str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'")
&& str_contains($setup,
"self::schema('ss.sql') . \"\\0\" . self::schema('cloud.sql')")
&& str_contains($setup,
'self::managedMainTables()'),
'Clean-break marker/fingerprint does not cover the UI copy schema.');
echo "UI copy catalog schema contracts passed.\n";
Loading…
Cancel
Save