[skip ci] wip: preserve Hermes crank development checkpoint
Owner-authorized recovery of accumulated source changes.
Includes accepted work and in-progress changes; NOT a release or acceptance.
Parent baseline 1b6db09bd1. Runtime data, build caches and local credentials excluded.
This commit is contained in:
1 parent
1b6db09bd1
commit
75fe5a123c
357 files changed
+118831
-5113
No files matched your search
@@ -2,269 +2,10 @@ use sqlx::{PgConnection, Row, query};
|
||||
|
||||
use super::authority::MigrationError;
|
||||
|
||||
pub(super) const OWNED_RELATIONS: &[&str] = &[
|
||||
"__crank_core_migrations",
|
||||
"__crank_migrations",
|
||||
"__crank_migration_legacy_audit",
|
||||
"__crank_mcp_migrations",
|
||||
"__crank_ext_migrations",
|
||||
"mcp_transport_sessions",
|
||||
"workspaces",
|
||||
"users",
|
||||
"memberships",
|
||||
"user_sessions",
|
||||
"invitation_tokens",
|
||||
"platform_api_keys",
|
||||
"operations",
|
||||
"operation_versions",
|
||||
"published_operations",
|
||||
"operation_samples",
|
||||
"descriptors",
|
||||
"agents",
|
||||
"agent_versions",
|
||||
"published_agents",
|
||||
"agent_operation_bindings",
|
||||
"secrets",
|
||||
"secret_versions",
|
||||
"master_key_identities",
|
||||
"master_key_rotations",
|
||||
"auth_profiles",
|
||||
"workspace_upstreams",
|
||||
"yaml_import_jobs",
|
||||
"import_jobs",
|
||||
"approval_requests",
|
||||
"invocation_logs",
|
||||
"usage_rollups",
|
||||
"artifact_blobs",
|
||||
"artifact_sources",
|
||||
"import_plans",
|
||||
"import_plan_applications",
|
||||
"onboarding_import_selections",
|
||||
];
|
||||
mod required_tables;
|
||||
|
||||
const REQUIRED_COLUMNS: &[(&str, &[&str])] = &[
|
||||
(
|
||||
"__crank_core_migrations",
|
||||
&["version", "description", "checksum", "applied_at"],
|
||||
),
|
||||
(
|
||||
"__crank_migrations",
|
||||
&[
|
||||
"version",
|
||||
"name",
|
||||
"checksum",
|
||||
"phase",
|
||||
"compatibility",
|
||||
"applied_at",
|
||||
],
|
||||
),
|
||||
(
|
||||
"__crank_migration_legacy_audit",
|
||||
&["source", "source_version", "source_checksum", "imported_at"],
|
||||
),
|
||||
(
|
||||
"__crank_mcp_migrations",
|
||||
&["version", "checksum", "applied_at"],
|
||||
),
|
||||
(
|
||||
"__crank_ext_migrations",
|
||||
&["extension_name", "version", "checksum", "applied_at"],
|
||||
),
|
||||
(
|
||||
"mcp_transport_sessions",
|
||||
&[
|
||||
"id",
|
||||
"protocol_version",
|
||||
"initialized",
|
||||
"supports_elicitation",
|
||||
"workspace_slug",
|
||||
"agent_slug",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"expires_at",
|
||||
],
|
||||
),
|
||||
(
|
||||
"master_key_identities",
|
||||
&[
|
||||
"epoch",
|
||||
"fingerprint",
|
||||
"cipher_contract",
|
||||
"status",
|
||||
"backup_ref",
|
||||
"created_at",
|
||||
"activated_at",
|
||||
"retired_at",
|
||||
],
|
||||
),
|
||||
(
|
||||
"master_key_rotations",
|
||||
&[
|
||||
"id",
|
||||
"source_epoch",
|
||||
"target_epoch",
|
||||
"target_fingerprint",
|
||||
"state",
|
||||
"backup_ref",
|
||||
"checkpoint_secret_id",
|
||||
"total_secret_versions",
|
||||
"processed_secret_versions",
|
||||
"verified_secret_versions",
|
||||
"failure_code",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
const REQUIRED_COLUMN_TYPES: &[(&str, &str, &str, bool)] = &[
|
||||
("__crank_core_migrations", "version", "integer", false),
|
||||
("__crank_core_migrations", "description", "text", false),
|
||||
("__crank_core_migrations", "checksum", "text", false),
|
||||
(
|
||||
"__crank_core_migrations",
|
||||
"applied_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
("__crank_migrations", "version", "bigint", false),
|
||||
("__crank_migrations", "name", "text", false),
|
||||
("__crank_migrations", "checksum", "text", false),
|
||||
("__crank_migrations", "phase", "text", false),
|
||||
("__crank_migrations", "compatibility", "text", false),
|
||||
(
|
||||
"__crank_migrations",
|
||||
"applied_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
("__crank_migration_legacy_audit", "source", "text", false),
|
||||
(
|
||||
"__crank_migration_legacy_audit",
|
||||
"source_version",
|
||||
"bigint",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"__crank_migration_legacy_audit",
|
||||
"source_checksum",
|
||||
"text",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"__crank_migration_legacy_audit",
|
||||
"imported_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
("__crank_mcp_migrations", "version", "integer", false),
|
||||
("__crank_mcp_migrations", "checksum", "text", false),
|
||||
(
|
||||
"__crank_mcp_migrations",
|
||||
"applied_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
("__crank_ext_migrations", "extension_name", "text", false),
|
||||
("__crank_ext_migrations", "version", "integer", false),
|
||||
("__crank_ext_migrations", "checksum", "text", true),
|
||||
(
|
||||
"__crank_ext_migrations",
|
||||
"applied_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
("mcp_transport_sessions", "id", "text", false),
|
||||
("mcp_transport_sessions", "protocol_version", "text", false),
|
||||
("mcp_transport_sessions", "initialized", "boolean", false),
|
||||
(
|
||||
"mcp_transport_sessions",
|
||||
"supports_elicitation",
|
||||
"boolean",
|
||||
false,
|
||||
),
|
||||
("mcp_transport_sessions", "workspace_slug", "text", false),
|
||||
("mcp_transport_sessions", "agent_slug", "text", false),
|
||||
(
|
||||
"mcp_transport_sessions",
|
||||
"created_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"mcp_transport_sessions",
|
||||
"updated_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"mcp_transport_sessions",
|
||||
"expires_at",
|
||||
"timestamp with time zone",
|
||||
true,
|
||||
),
|
||||
("master_key_identities", "epoch", "bigint", false),
|
||||
("master_key_identities", "fingerprint", "text", false),
|
||||
("master_key_identities", "cipher_contract", "text", false),
|
||||
("master_key_identities", "status", "text", false),
|
||||
("master_key_identities", "backup_ref", "text", true),
|
||||
(
|
||||
"master_key_identities",
|
||||
"created_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"master_key_identities",
|
||||
"activated_at",
|
||||
"timestamp with time zone",
|
||||
true,
|
||||
),
|
||||
(
|
||||
"master_key_identities",
|
||||
"retired_at",
|
||||
"timestamp with time zone",
|
||||
true,
|
||||
),
|
||||
("master_key_rotations", "id", "text", false),
|
||||
("master_key_rotations", "source_epoch", "bigint", false),
|
||||
("master_key_rotations", "target_epoch", "bigint", false),
|
||||
("master_key_rotations", "target_fingerprint", "text", false),
|
||||
("master_key_rotations", "state", "text", false),
|
||||
("master_key_rotations", "backup_ref", "text", true),
|
||||
("master_key_rotations", "checkpoint_secret_id", "text", true),
|
||||
(
|
||||
"master_key_rotations",
|
||||
"total_secret_versions",
|
||||
"bigint",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"master_key_rotations",
|
||||
"processed_secret_versions",
|
||||
"bigint",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"master_key_rotations",
|
||||
"verified_secret_versions",
|
||||
"bigint",
|
||||
false,
|
||||
),
|
||||
("master_key_rotations", "failure_code", "text", true),
|
||||
(
|
||||
"master_key_rotations",
|
||||
"created_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"master_key_rotations",
|
||||
"updated_at",
|
||||
"timestamp with time zone",
|
||||
false,
|
||||
),
|
||||
];
|
||||
pub(super) use required_tables::OWNED_RELATIONS;
|
||||
use required_tables::{REQUIRED_COLUMN_TYPES, REQUIRED_COLUMNS};
|
||||
|
||||
pub(super) async fn relation_exists(
|
||||
connection: &mut PgConnection,
|
||||
@@ -662,6 +403,71 @@ pub(super) async fn validate_schema_fingerprint(
|
||||
} else {
|
||||
super::schema_guard_v15::validate_v15_onboarding_import_selection(connection).await?;
|
||||
}
|
||||
if current_version < 16 {
|
||||
if !super::schema_guard_v16::validate_v16_absent(connection).await? {
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
} else {
|
||||
super::schema_guard_v16::validate_v16_resource_drafts(connection, current_version).await?;
|
||||
}
|
||||
if current_version < 17 {
|
||||
if !super::schema_guard_v17::validate_v17_absent(connection).await? {
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
} else {
|
||||
super::schema_guard_v17::validate_v17_resource_publications(connection, current_version)
|
||||
.await?;
|
||||
}
|
||||
if current_version < 18 {
|
||||
if !super::schema_guard_v18::validate_v18_absent(connection).await? {
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
} else {
|
||||
super::schema_guard_v18::validate_v18_agent_resource_bindings(connection).await?;
|
||||
}
|
||||
if current_version < 19 {
|
||||
if !super::schema_guard_v19::validate_v19_absent(connection).await? {
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
} else {
|
||||
super::schema_guard_v19::validate_v19_resource_security_revocations(connection).await?;
|
||||
}
|
||||
if current_version < 20 {
|
||||
if !super::schema_guard_v20::validate_v20_absent(connection).await? {
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
} else {
|
||||
super::schema_guard_v20::validate_v20_resource_template_sources(connection).await?;
|
||||
}
|
||||
if current_version < 21 {
|
||||
for relation in [
|
||||
"prompts",
|
||||
"prompt_versions",
|
||||
"prompt_arguments",
|
||||
"prompt_messages",
|
||||
] {
|
||||
if relation_exists(connection, relation).await? {
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
validate_required_relations(connection, super::owned_relations::PROMPTS, current_version)
|
||||
.await?;
|
||||
}
|
||||
if current_version < 22 {
|
||||
if !super::schema_guard_v22::validate_v22_absent(connection).await? {
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
} else {
|
||||
super::schema_guard_v22::validate_v22_prompt_publications(connection).await?;
|
||||
}
|
||||
if current_version < 23 {
|
||||
if !super::schema_guard_v23::validate_v23_absent(connection).await? {
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
} else {
|
||||
super::schema_guard_v23::validate_v23_prompt_dependencies(connection).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user