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.
159 lines
6.7 KiB
Rust
159 lines
6.7 KiB
Rust
//! P3 (AT-3.6-03/04): preview отдаёт metadata и bytes **одного** разрешения версии.
|
|
//!
|
|
//! Источник: CORRECTION-PACKAGE P3 (TL F05), SPEC v4 §3 D-6/D-19. Проверка
|
|
//! детерминированная: приватная точка `interleave` внутри `load_content` исполняет
|
|
//! настоящий concurrent update того же Resource в той же PG-схеме, поэтому окно
|
|
//! «между источником metadata и физическим чтением bytes» наблюдаемо без гонки.
|
|
//!
|
|
//! Ожидание одного снимка: версия/размер/MIME/digest/text в ответе относятся к
|
|
//! одной и той же версии, а не к metadata версии N и bytes версии N+1 (TL F05).
|
|
|
|
use super::super::{DraftMetadata, NewDraft, UpdateDraft, interleave};
|
|
use crate::app::resource_test_support::ResourceServiceHarness;
|
|
use crank_core::WorkspaceId;
|
|
use serde_json::Value;
|
|
use serial_test::serial;
|
|
use sha2::{Digest, Sha256};
|
|
|
|
const LIMIT: usize = 256 * 1024;
|
|
const WORKSPACE_ID: &str = "ws_default";
|
|
const FIRST: &[u8] = b"{\"snapshot\":\"first\"}";
|
|
const SECOND: &[u8] = b"{\"snapshot\":\"second\",\"n\":2}";
|
|
|
|
fn sha256_hex(bytes: &[u8]) -> String {
|
|
format!("{:x}", Sha256::digest(bytes))
|
|
}
|
|
|
|
fn text_draft(bytes: &[u8]) -> NewDraft {
|
|
NewDraft {
|
|
workspace_id: WorkspaceId::new(WORKSPACE_ID),
|
|
metadata: DraftMetadata {
|
|
uri: "crank://snapshot/draft".to_owned(),
|
|
name: "snapshot_draft".to_owned(),
|
|
description: String::new(),
|
|
kind: "text".to_owned(),
|
|
mime_type: "text/plain".to_owned(),
|
|
sensitivity: "internal".to_owned(),
|
|
},
|
|
bytes: bytes.to_vec(),
|
|
}
|
|
}
|
|
|
|
#[tokio::test]
|
|
#[serial]
|
|
async fn story36_at04_preview_serves_one_pinned_resolution_snapshot() {
|
|
let harness = ResourceServiceHarness::spawn("snapshot", LIMIT).await;
|
|
let service = harness.service.clone();
|
|
let workspace = WorkspaceId::new(WORKSPACE_ID);
|
|
|
|
let created = service
|
|
.create_draft(text_draft(FIRST))
|
|
.await
|
|
.expect("the seed draft must be created");
|
|
let resource_id = created.resource_id;
|
|
|
|
let card = service
|
|
.card(&workspace, &resource_id)
|
|
.await
|
|
.expect("the seed card must be readable");
|
|
let precondition = card.resource.updated_at.clone();
|
|
|
|
// Controlled concurrent update того же Resource и той же схемы: шаг исполняется
|
|
// ровно один раз на приватной точке чередования.
|
|
let updating = service.clone();
|
|
let updated_id = resource_id.clone();
|
|
let updated_workspace = workspace.clone();
|
|
let (sender, receiver) = tokio::sync::oneshot::channel::<Result<u32, String>>();
|
|
interleave::install(Box::new(move || {
|
|
Box::pin(async move {
|
|
let outcome = updating
|
|
.update_draft(UpdateDraft {
|
|
workspace_id: updated_workspace,
|
|
resource_id: updated_id,
|
|
description: "updated during interleave".to_owned(),
|
|
mime_type: "text/plain".to_owned(),
|
|
sensitivity: "internal".to_owned(),
|
|
expected_updated_at: Some(precondition),
|
|
immutable_fields: Vec::new(),
|
|
bytes: SECOND.to_vec(),
|
|
})
|
|
.await
|
|
.map(|card| card.version.version)
|
|
.map_err(|error| error.to_string());
|
|
let _ = sender.send(outcome);
|
|
})
|
|
}));
|
|
|
|
let preview = service
|
|
.preview(&workspace, &resource_id)
|
|
.await
|
|
.expect("preview must succeed");
|
|
let concurrent = receiver
|
|
.await
|
|
.expect("the interleave step must report its outcome");
|
|
|
|
// Положительный контроль чередования: одновременный update действительно принят,
|
|
// поэтому «один снимок» ниже — наблюдение, а не следствие того, что ничего не менялось.
|
|
assert_eq!(
|
|
concurrent,
|
|
Ok(2),
|
|
"the interleaved update must be accepted before the bytes of this response are read"
|
|
);
|
|
|
|
let digest_first = sha256_hex(FIRST);
|
|
let digest_second = sha256_hex(SECOND);
|
|
let expected_text = std::str::from_utf8(SECOND)
|
|
.expect("the fixture content must be UTF-8")
|
|
.to_owned();
|
|
let observed = format!(
|
|
"version={} digest={} size={} mime={} text={:?}",
|
|
preview.version.version,
|
|
preview.version.digest,
|
|
preview.version.size_bytes,
|
|
preview.version.mime_type,
|
|
preview.preview.text
|
|
);
|
|
|
|
// Все поля относятся к одному снимку: той версии, которую разрешил этот ответ.
|
|
assert_eq!(preview.version.version, 2, "single snapshot: {observed}");
|
|
assert_eq!(
|
|
preview.version.digest, digest_second,
|
|
"single snapshot: {observed}"
|
|
);
|
|
assert_eq!(
|
|
preview.version.size_bytes,
|
|
i64::try_from(SECOND.len()).expect("fixture size must fit i64"),
|
|
"single snapshot: {observed}"
|
|
);
|
|
assert_eq!(
|
|
preview.version.mime_type, "text/plain",
|
|
"single snapshot: {observed}"
|
|
);
|
|
assert_eq!(
|
|
preview.preview.text.as_deref(),
|
|
Some(expected_text.as_str()),
|
|
"single snapshot: the preview text must be the bytes of the same version: {observed}"
|
|
);
|
|
// Расхождение с metadata предыдущей версии — то, что было дефектом (материализация).
|
|
assert_ne!(
|
|
preview.version.digest, digest_first,
|
|
"the snapshot must not fall back to the pre-interleave version: {observed}"
|
|
);
|
|
assert!(
|
|
!preview.version.digest.is_empty() && preview.version.digest.len() == 64,
|
|
"the digest must be the pinned version digest, not a placeholder: {observed}"
|
|
);
|
|
assert_eq!(preview.resource.name, "snapshot_draft");
|
|
assert_eq!(preview.resource.uri, "crank://snapshot/draft");
|
|
assert_eq!(preview.resource.current_draft_version, 2);
|
|
let _: Value = serde_json::to_value(&preview).expect("the preview must serialize");
|
|
|
|
// Тот же Resource после ответа отдаёт содержимое новой версии: update настоящий,
|
|
// а не «виртуальный» только внутри тестового шага.
|
|
let served = service
|
|
.read_content(&workspace, &resource_id)
|
|
.await
|
|
.expect("content must be readable after the interleave");
|
|
assert_eq!(served, SECOND.to_vec());
|
|
}
|