feat(epic3): deliver the accepted Epic 3 scope through Story 3.17
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
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.
This commit is contained in:
1 parent
1b6db09bd1
commit
54ce770682
357 files changed
+117394
-5115
No files matched your search
@@ -2,6 +2,7 @@ use super::*;
|
||||
use sqlx::Row;
|
||||
use std::collections::HashMap;
|
||||
|
||||
mod dependent_source_fks;
|
||||
mod exhaustive_v12;
|
||||
|
||||
#[tokio::test]
|
||||
@@ -31,7 +32,7 @@ async fn healthy_v11_upgrades_to_v13_without_rewriting_prior_ledger() {
|
||||
MigrationAuthority::preflight(&pool).await.unwrap(),
|
||||
MigrationPreflight::MigrationRequired {
|
||||
current: 11,
|
||||
target: 15,
|
||||
target: 23,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -130,8 +131,22 @@ async fn v12_guard_still_rejects_column_constraint_index_and_relation_drift() {
|
||||
drop function unrelated_trigger_fn();",
|
||||
),
|
||||
(
|
||||
"alter table artifact_sources set unlogged;",
|
||||
"alter table artifact_sources set logged;",
|
||||
// V16 добавил `resource_versions_source_fkey`, а V17 —
|
||||
// `resource_publications_source_fkey`: обе logged-таблицы ссылаются на
|
||||
// `artifact_sources`, поэтому PostgreSQL больше не переводит её в unlogged
|
||||
// (`42P16`). Тот же класс дрейфа (persistence отношения, его проверяет
|
||||
// `schema_guard_v12`) снимает блокирующие ссылки на время дрейфа и
|
||||
// возвращает их при восстановлении.
|
||||
"alter table resource_versions drop constraint resource_versions_source_fkey;
|
||||
alter table resource_publications drop constraint resource_publications_source_fkey;
|
||||
alter table artifact_sources set unlogged;",
|
||||
"alter table artifact_sources set logged;
|
||||
alter table resource_versions add constraint resource_versions_source_fkey
|
||||
foreign key (workspace_id, artifact_source_id)
|
||||
references artifact_sources(workspace_id, source_id);
|
||||
alter table resource_publications add constraint resource_publications_source_fkey
|
||||
foreign key (workspace_id, artifact_source_id)
|
||||
references artifact_sources(workspace_id, source_id);",
|
||||
),
|
||||
(
|
||||
"alter table artifact_sources drop constraint artifact_sources_id_check;
|
||||
@@ -162,7 +177,7 @@ async fn v12_guard_still_rejects_column_constraint_index_and_relation_drift() {
|
||||
sqlx::raw_sql(restore).execute(&pool).await.unwrap();
|
||||
assert_eq!(
|
||||
MigrationAuthority::preflight(&pool).await.unwrap(),
|
||||
MigrationPreflight::Current { version: 15 },
|
||||
MigrationPreflight::Current { version: 23 },
|
||||
"restore: {restore}"
|
||||
);
|
||||
}
|
||||
@@ -215,7 +230,7 @@ async fn v13_guard_rejects_wrong_cleanup_index_order_and_predicate() {
|
||||
sqlx::raw_sql(restore).execute(&pool).await.unwrap();
|
||||
assert_eq!(
|
||||
MigrationAuthority::preflight(&pool).await.unwrap(),
|
||||
MigrationPreflight::Current { version: 15 },
|
||||
MigrationPreflight::Current { version: 23 },
|
||||
"restore: {restore}"
|
||||
);
|
||||
}
|
||||
@@ -451,6 +466,33 @@ async fn catalog_constraint_definitions(pool: &sqlx::PgPool) -> HashMap<String,
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Определение constraint **указанного отношения** текущей схемы; `None`, если его нет.
|
||||
///
|
||||
/// Отношение обязательно параметром: без него одноимённый объект другой таблицы
|
||||
/// (или другой схемы) мог бы молча подменить результат, а «однозначность» —
|
||||
/// это проверяемое свойство (R-C), а не предположение вызывающего.
|
||||
async fn constraint_definition(pool: &sqlx::PgPool, relation: &str, name: &str) -> Option<String> {
|
||||
let definitions = sqlx::query_scalar::<_, String>(
|
||||
"select pg_get_constraintdef(c.oid, true)
|
||||
from pg_catalog.pg_constraint c
|
||||
join pg_catalog.pg_class t on t.oid = c.conrelid
|
||||
join pg_catalog.pg_namespace n on n.oid = t.relnamespace
|
||||
where n.nspname = current_schema() and t.relname = $1 and c.conname = $2",
|
||||
)
|
||||
.bind(relation)
|
||||
.bind(name)
|
||||
.fetch_all(pool)
|
||||
.await
|
||||
.expect("a constraint definition must be queryable");
|
||||
assert!(
|
||||
definitions.len() <= 1,
|
||||
"constraint `{name}` on `{relation}` must resolve to exactly one definition, \
|
||||
observed {}",
|
||||
definitions.len()
|
||||
);
|
||||
definitions.into_iter().next()
|
||||
}
|
||||
|
||||
async fn assert_v12_drift(pool: &sqlx::PgPool, drift: &str, restore: &str) {
|
||||
sqlx::raw_sql(sqlx::AssertSqlSafe(drift.to_owned()))
|
||||
.execute(pool)
|
||||
@@ -465,7 +507,7 @@ async fn assert_v12_drift(pool: &sqlx::PgPool, drift: &str, restore: &str) {
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
MigrationAuthority::preflight(pool).await.unwrap(),
|
||||
MigrationPreflight::Current { version: 15 },
|
||||
MigrationPreflight::Current { version: 23 },
|
||||
"restore: {restore}"
|
||||
);
|
||||
}
|
||||
@@ -656,6 +698,50 @@ async fn v12_guard_rejects_exhaustive_catalog_drift_for_both_tables() {
|
||||
alter table artifact_sources add constraint artifact_sources_blob_digest_fkey {fk};"
|
||||
);
|
||||
assert_v12_drift(&pool, drift, &restore).await;
|
||||
} else if constraint == "artifact_sources_pkey" {
|
||||
// V16/V17 добавили `resource_versions_source_fkey` и
|
||||
// `resource_publications_source_fkey`, которые физически опираются на
|
||||
// pkey-индекс `artifact_sources_pkey`. Чтобы дрейф «constraint отсутствует»
|
||||
// был исполнимым, блокирующие ссылки снимаются на время дрейфа и
|
||||
// возвращаются при восстановлении — тот же приём, что для `artifact_blobs_pkey`.
|
||||
let draft_dependent =
|
||||
constraint_definition(&pool, "resource_versions", "resource_versions_source_fkey")
|
||||
.await;
|
||||
let publication_dependent = constraint_definition(
|
||||
&pool,
|
||||
"resource_publications",
|
||||
"resource_publications_source_fkey",
|
||||
)
|
||||
.await;
|
||||
let mut drift = String::new();
|
||||
if draft_dependent.is_some() {
|
||||
drift.push_str(
|
||||
"alter table resource_versions drop constraint resource_versions_source_fkey;\n",
|
||||
);
|
||||
}
|
||||
if publication_dependent.is_some() {
|
||||
drift.push_str(
|
||||
"alter table resource_publications drop constraint \
|
||||
resource_publications_source_fkey;\n",
|
||||
);
|
||||
}
|
||||
drift.push_str("alter table artifact_sources drop constraint artifact_sources_pkey;");
|
||||
let mut restore = format!(
|
||||
"alter table artifact_sources add constraint artifact_sources_pkey {definition};\n"
|
||||
);
|
||||
if let Some(definition_of_fk) = draft_dependent {
|
||||
restore.push_str(&format!(
|
||||
"alter table resource_versions add constraint resource_versions_source_fkey \
|
||||
{definition_of_fk};\n"
|
||||
));
|
||||
}
|
||||
if let Some(definition_of_fk) = publication_dependent {
|
||||
restore.push_str(&format!(
|
||||
"alter table resource_publications add constraint \
|
||||
resource_publications_source_fkey {definition_of_fk};"
|
||||
));
|
||||
}
|
||||
assert_v12_drift(&pool, &drift, &restore).await;
|
||||
} else {
|
||||
let drift = format!("alter table {table} drop constraint {constraint};");
|
||||
let restore = format!("alter table {table} add constraint {constraint} {definition};");
|
||||
@@ -740,3 +826,61 @@ async fn v12_guard_rejects_exhaustive_catalog_drift_for_both_tables() {
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// P4 (V16 guard): шесть однофакторных мутаций определения и проверка выбора
|
||||
// зависимого FK/created index по текущей схеме перенесены в подмодуль
|
||||
// `artifact_metadata/exhaustive_v12.rs` — там же живёт разрешённый helper
|
||||
// `dependent_source_fk_definition`, и health-правило ограничивает файл 1000 строками.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// V17 guard (Story 3.7): минимальные однофакторные мутации схемы публикаций.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[tokio::test]
|
||||
async fn v17_guard_rejects_publication_schema_drift() {
|
||||
let database_url = crank_test_support::postgres_schema_url("test_v17_guard_drift").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 }
|
||||
);
|
||||
|
||||
for (drift, restore) in [
|
||||
(
|
||||
"alter table resource_publications add column raw_upload_filename text;",
|
||||
"alter table resource_publications drop column raw_upload_filename;",
|
||||
),
|
||||
(
|
||||
"alter table resource_publications drop constraint resource_publications_sensitivity_check;\n\
|
||||
alter table resource_publications add constraint resource_publications_sensitivity_check \
|
||||
check (true);",
|
||||
"alter table resource_publications drop constraint resource_publications_sensitivity_check;\n\
|
||||
alter table resource_publications add constraint resource_publications_sensitivity_check \
|
||||
check (sensitivity in ('public', 'internal', 'secret'));",
|
||||
),
|
||||
(
|
||||
"alter table resource_publications drop constraint resource_publications_source_fkey;\n\
|
||||
alter table resource_publications add constraint resource_publications_source_fkey \
|
||||
foreign key (workspace_id, artifact_source_id) \
|
||||
references artifact_sources(workspace_id, source_id) on delete cascade;",
|
||||
"alter table resource_publications drop constraint resource_publications_source_fkey;\n\
|
||||
alter table resource_publications add constraint resource_publications_source_fkey \
|
||||
foreign key (workspace_id, artifact_source_id) \
|
||||
references artifact_sources(workspace_id, source_id);",
|
||||
),
|
||||
] {
|
||||
sqlx::raw_sql(drift).execute(&pool).await.unwrap();
|
||||
let error = MigrationAuthority::preflight(&pool).await.unwrap_err();
|
||||
assert_eq!(error.code(), "partial_sequence", "drift: {drift}");
|
||||
assert_eq!(error.version(), Some(17), "drift: {drift}");
|
||||
sqlx::raw_sql(restore).execute(&pool).await.unwrap();
|
||||
assert_eq!(
|
||||
MigrationAuthority::preflight(&pool).await.unwrap(),
|
||||
MigrationPreflight::Current { version: 23 },
|
||||
"restore: {restore}"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user