CI / Rust Checks (pull_request) Failing after 13m41s
CI / UI Checks (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Deploy (pull_request) Skipped
Community Release / release (push) Failing after 13m33s
Recovery delivery of the accumulated, TL-accepted Epic 3 work that had never been
committed to Git (stories 3.6-3.17, see the crank board). Story 3.18 is not accepted
yet and is deliberately excluded: its logging surface, its capability registration,
its oracle projections and its tests are not part of this tree.
Accepted scope
- 3.6 typed static Resource Drafts; 3.7 publication and exact binding of static
Resource Versions; 3.8 MCP discovery/read and revocation of static Resources;
- 3.9 Resource import/export in API and UI plus TLS dependency maintenance;
3.10 REST-backed Resource templates; 3.11 shared REST read runtime and the MCP
revision/capability foundation;
- 3.12 parameterised Prompt Drafts with preview; 3.13 Prompt publication and exact
version binding to Agents; 3.14 MCP prompts; 3.15 Prompt import/export;
- 3.16 composite Prompts with published Resources (dependency content scan plus
dynamic read through the accepted 3.11 runtime, admin preview and MCP prompts/get);
- 3.17 bounded MCP completion suggestions from typed published schemas and the
resources/list admission fix for bound template publications.
Accepted evidence being reused (unchanged code paths)
- 3.16 candidate: core 7, admin-api 22, registry 4, mcp-server 4, UI 6; one final
`just verify` run 1651 passed / 0 failed / 2 ignored.
- 3.17 candidate: full run 1672 passed / 0 failed / 2 ignored, QA targeted reruns and
a real MCP Inspector 2.12.0 client smoke.
Delivery engineering in this commit
- CI: one event per change (feature branches are gated by their pull request, push
runs only on main), story events run the changed packages, the full workspace suite
stays the feature/release gate; no cache/sharding without a measured runner check.
- Release: the packaged archives, checksums and SBOM are now uploaded to the Gitea
release entry of the tag instead of dying with the runner workspace.
Not included on purpose: Story 3.18 work, build caches, runtime databases, local
credentials and scratch evidence.
Refs: crank kanban t_e39d7263; baseline 1b6db09bd1.
162 lines
6.4 KiB
Rust
162 lines
6.4 KiB
Rust
//! Story 3.8: V19 immutable Resource security revocations — migration evidence.
|
||
//!
|
||
//! Fresh install, upgrade from V18 without rewriting the prior ledger, schema
|
||
//! drift detection, failed-DDL rollback and the fail-closed future-version gate
|
||
//! (the path an old binary takes when it meets a database newer than itself).
|
||
|
||
use super::*;
|
||
use crank_registry::MigrationApplyResult;
|
||
|
||
#[tokio::test]
|
||
async fn fresh_install_creates_the_empty_revocation_authority() {
|
||
let database_url = crank_test_support::postgres_schema_url("test_v19_fresh_install").await;
|
||
let pool = sqlx::PgPool::connect(&database_url).await.unwrap();
|
||
MigrationAuthority::apply(&pool).await.unwrap();
|
||
assert_eq!(
|
||
MigrationAuthority::preflight(&pool).await.unwrap(),
|
||
MigrationPreflight::Current { version: 23 }
|
||
);
|
||
let rows: i64 = sqlx::query_scalar("select count(*) from resource_security_revocations")
|
||
.fetch_one(&pool)
|
||
.await
|
||
.expect("V19 table must be queryable after a fresh install");
|
||
assert_eq!(
|
||
rows, 0,
|
||
"an empty authoritative table must preserve the previous (unrevoked) behaviour; \
|
||
no data backfill or mass migration is allowed"
|
||
);
|
||
}
|
||
|
||
#[tokio::test]
|
||
async fn v18_upgrades_to_v19_without_rewriting_the_prior_ledger() {
|
||
let database_url = crank_test_support::postgres_schema_url("test_v19_upgrade").await;
|
||
let pool = sqlx::PgPool::connect(&database_url).await.unwrap();
|
||
MigrationAuthority::apply(&pool).await.unwrap();
|
||
let before: Vec<(i64, String, String)> =
|
||
sqlx::query_as("select version, name, checksum from __crank_migrations where version < 19 order by version")
|
||
.fetch_all(&pool)
|
||
.await
|
||
.unwrap();
|
||
remove_v19_schema(&pool).await;
|
||
assert_eq!(
|
||
MigrationAuthority::preflight(&pool).await.unwrap(),
|
||
MigrationPreflight::MigrationRequired {
|
||
current: 18,
|
||
target: 23,
|
||
}
|
||
);
|
||
assert_eq!(
|
||
MigrationAuthority::apply(&pool).await.unwrap(),
|
||
MigrationApplyResult::Applied { from: 18, to: 23 }
|
||
);
|
||
let after: Vec<(i64, String, String)> =
|
||
sqlx::query_as("select version, name, checksum from __crank_migrations where version < 19 order by version")
|
||
.fetch_all(&pool)
|
||
.await
|
||
.unwrap();
|
||
assert_eq!(before, after, "V16–V18 ledger rows must not be rewritten");
|
||
assert_eq!(
|
||
MigrationAuthority::preflight(&pool).await.unwrap(),
|
||
MigrationPreflight::Current { version: 23 }
|
||
);
|
||
}
|
||
|
||
#[tokio::test]
|
||
async fn v19_guard_rejects_a_missing_revocation_trigger() {
|
||
let database_url = crank_test_support::postgres_schema_url("test_v19_trigger_drift").await;
|
||
let pool = sqlx::PgPool::connect(&database_url).await.unwrap();
|
||
MigrationAuthority::apply(&pool).await.unwrap();
|
||
sqlx::query(
|
||
"drop trigger resource_security_revocations_immutable_guard
|
||
on resource_security_revocations",
|
||
)
|
||
.execute(&pool)
|
||
.await
|
||
.expect("the V19 trigger must be droppable for the drift fixture");
|
||
let error = MigrationAuthority::preflight(&pool).await.unwrap_err();
|
||
assert_eq!(error.code(), "partial_sequence");
|
||
assert_eq!(error.version(), Some(19));
|
||
assert_eq!(error.stage(), "v19.immutable_trigger");
|
||
}
|
||
|
||
#[tokio::test]
|
||
async fn a_database_newer_than_the_binary_fails_closed_at_startup() {
|
||
let database_url = crank_test_support::postgres_schema_url("test_v19_future_version").await;
|
||
let pool = sqlx::PgPool::connect(&database_url).await.unwrap();
|
||
MigrationAuthority::apply(&pool).await.unwrap();
|
||
// The same `version > CURRENT_VERSION` branch an old V23 binary takes when it
|
||
// meets a V24 database; a synthetic V24 row exercises it without a second binary.
|
||
sqlx::query(
|
||
"insert into __crank_migrations (version, name, checksum, phase, compatibility)
|
||
values (24, 'future-v24', repeat('a', 64), 'expand', 'n-minus-one-readable')",
|
||
)
|
||
.execute(&pool)
|
||
.await
|
||
.unwrap();
|
||
let error = MigrationAuthority::preflight(&pool).await.unwrap_err();
|
||
assert_eq!(error.code(), "future_version");
|
||
assert_eq!(error.version(), Some(24));
|
||
assert_eq!(error.recovery(), "install_matching_application");
|
||
assert!(
|
||
MigrationAuthority::require_current(&pool).await.is_err(),
|
||
"startup must refuse a newer database instead of serving with unknown schema"
|
||
);
|
||
}
|
||
|
||
#[tokio::test]
|
||
async fn failed_v19_migration_rolls_back_schema_and_ledger() {
|
||
let _event_trigger_guard = EVENT_TRIGGER_TEST_LOCK.lock().await;
|
||
let database_url = crank_test_support::postgres_schema_url("test_v19_rollback").await;
|
||
let pool = sqlx::PgPool::connect(&database_url).await.unwrap();
|
||
MigrationAuthority::apply(&pool).await.unwrap();
|
||
remove_v19_schema(&pool).await;
|
||
let schema: String = sqlx::query_scalar("select current_schema()")
|
||
.fetch_one(&pool)
|
||
.await
|
||
.unwrap();
|
||
let failure_trigger = format!(
|
||
"create function reject_story38_v19() returns event_trigger language plpgsql as $$
|
||
begin
|
||
if current_schema() = '{schema}' and current_query() like '%resource_security_revocations%' then
|
||
raise exception 'injected v19 ddl failure';
|
||
end if;
|
||
end $$;
|
||
create event trigger reject_story38_v19 on ddl_command_start
|
||
execute function reject_story38_v19();"
|
||
);
|
||
sqlx::raw_sql(sqlx::AssertSqlSafe(failure_trigger))
|
||
.execute(&pool)
|
||
.await
|
||
.unwrap();
|
||
let error = MigrationAuthority::apply(&pool).await.unwrap_err();
|
||
sqlx::raw_sql(
|
||
"drop event trigger reject_story38_v19;
|
||
drop function reject_story38_v19();",
|
||
)
|
||
.execute(&pool)
|
||
.await
|
||
.unwrap();
|
||
assert_eq!(error.code(), "apply_failed");
|
||
assert_eq!(error.version(), Some(19));
|
||
let present: bool = sqlx::query_scalar(
|
||
"select to_regclass(format('%I.%I', current_schema(), 'resource_security_revocations')) is not null",
|
||
)
|
||
.fetch_one(&pool)
|
||
.await
|
||
.unwrap();
|
||
assert!(!present, "failed V19 DDL must roll the table back");
|
||
let ledger_v19: i64 =
|
||
sqlx::query_scalar("select count(*) from __crank_migrations where version = 19")
|
||
.fetch_one(&pool)
|
||
.await
|
||
.unwrap();
|
||
assert_eq!(ledger_v19, 0);
|
||
assert_eq!(
|
||
MigrationAuthority::preflight(&pool).await.unwrap(),
|
||
MigrationPreflight::MigrationRequired {
|
||
current: 18,
|
||
target: 23,
|
||
}
|
||
);
|
||
}
|