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.
142 lines
5.5 KiB
Rust
142 lines
5.5 KiB
Rust
//! Story 3.6 · AT-3.6-08 · фаза B — v2 snapshot и CLI.
|
|
//!
|
|
//! `TD-C1` default output CLI равен закоммиченному v2-снимку byte-for-byte.
|
|
//! `TD-C2` `--check` не зависит от cwd и печатает точную строку версии.
|
|
//! `TD-C3` ошибки CLI точны, без JSON в выводе.
|
|
//! `TD-C4` сериализация компактна и не несёт динамического текста.
|
|
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
const FROZEN_V2: &str = include_str!("../../../docs/schemas/metrics-registry-v2.json");
|
|
|
|
fn binary() -> Command {
|
|
Command::new(env!("CARGO_BIN_EXE_crank-metrics-contract"))
|
|
}
|
|
|
|
/// TD-C1 — default output CLI = versioned snapshot (byte-for-byte, детерминированно).
|
|
#[test]
|
|
fn default_output_is_the_versioned_snapshot() {
|
|
let first = binary().output().expect("contract CLI runs");
|
|
assert!(
|
|
first.status.success(),
|
|
"{}",
|
|
String::from_utf8_lossy(&first.stderr)
|
|
);
|
|
let stdout = String::from_utf8(first.stdout).expect("utf-8 snapshot");
|
|
assert_eq!(
|
|
stdout, FROZEN_V2,
|
|
"default CLI обязан печатать ровно закоммиченный v2-снимок"
|
|
);
|
|
let second = binary().output().expect("contract CLI reruns");
|
|
assert_eq!(
|
|
String::from_utf8(second.stdout).expect("utf-8 snapshot"),
|
|
stdout,
|
|
"рендер обязан быть детерминированным"
|
|
);
|
|
let rendered = crank_metrics::render_metric_schema_json().expect("renderer");
|
|
assert_eq!(
|
|
rendered, FROZEN_V2,
|
|
"Rust renderer обязан совпасть с закоммиченным снимком"
|
|
);
|
|
}
|
|
|
|
/// TD-C2 — `--check` независим от cwd и печатает точную строку версии.
|
|
#[test]
|
|
fn check_is_cwd_independent_and_exact() {
|
|
let directory = std::env::temp_dir().join(format!(
|
|
"crank-metrics-contract-v2-{}-{}",
|
|
std::process::id(),
|
|
std::thread::current().name().unwrap_or("main").len()
|
|
));
|
|
std::fs::create_dir_all(&directory).expect("temp cwd");
|
|
let output = binary()
|
|
.arg("--check")
|
|
.current_dir(&directory)
|
|
.output()
|
|
.expect("contract CLI runs");
|
|
std::fs::remove_dir_all(&directory).ok();
|
|
assert!(
|
|
output.status.success(),
|
|
"{}",
|
|
String::from_utf8_lossy(&output.stderr)
|
|
);
|
|
assert_eq!(
|
|
String::from_utf8(output.stdout).expect("utf-8"),
|
|
"metrics_contract_ok schema_version=2\n",
|
|
"--check обязан печатать ровно эту строку"
|
|
);
|
|
assert!(output.stderr.is_empty(), "--check не пишет stderr");
|
|
}
|
|
|
|
/// TD-C3 — ошибочные команды: точный stderr, ненулевой exit, никакого JSON.
|
|
#[test]
|
|
fn error_paths_are_exact_and_json_free() {
|
|
for args in [vec!["--unknown"], vec!["--check", "extra"], vec!["render"]] {
|
|
let output = binary().args(&args).output().expect("contract CLI runs");
|
|
assert!(
|
|
!output.status.success(),
|
|
"команда {args:?} обязана падать, output: {:?}",
|
|
output
|
|
);
|
|
assert_eq!(
|
|
String::from_utf8(output.stderr).expect("utf-8"),
|
|
"metrics_contract_invalid_command\n",
|
|
"точный static error text для {args:?}"
|
|
);
|
|
let stdout = String::from_utf8(output.stdout).expect("utf-8");
|
|
assert!(
|
|
!stdout.contains('{') && !stdout.contains('"'),
|
|
"ошибочный вывод не может содержать JSON: {stdout:?}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// TD-C4 — компактная сериализация без динамического текста и < 65536 bytes.
|
|
#[test]
|
|
fn serialization_is_compact_and_free_of_dynamic_text() {
|
|
assert!(
|
|
FROZEN_V2.len() < 65_536,
|
|
"v2-снимок обязан остаться < 65536 bytes, observed {}",
|
|
FROZEN_V2.len()
|
|
);
|
|
assert!(FROZEN_V2.ends_with("}\n"), "ровно одна завершающая LF");
|
|
assert_eq!(
|
|
FROZEN_V2.matches('\n').count(),
|
|
1,
|
|
"компактный JSON без переводов строк внутри документа"
|
|
);
|
|
assert!(
|
|
!FROZEN_V2.contains(" "),
|
|
"вне строк не может быть пробелов"
|
|
);
|
|
assert!(FROZEN_V2.starts_with("{\"schema_version\":2,"));
|
|
assert!(FROZEN_V2.contains("\"unmatched\""));
|
|
for forbidden in [
|
|
"trace_id",
|
|
"request_id",
|
|
"correlation_id",
|
|
"workspace-",
|
|
"/home/",
|
|
"/tmp/",
|
|
"http://",
|
|
"https://",
|
|
] {
|
|
assert!(
|
|
!FROZEN_V2.contains(forbidden),
|
|
"v2-снимок не может нести динамический текст `{forbidden}`"
|
|
);
|
|
}
|
|
assert!(
|
|
FROZEN_V2
|
|
.contains("\"buckets_seconds\":[0.005,0.01,0.025,0.05,0.1,0.25,0.5,1,2.5,5,10,30,60]"),
|
|
"bucket'ы обязаны быть точными числами (1, а не 1.0)"
|
|
);
|
|
let snapshot_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../docs/schemas/metrics-registry-v2.json");
|
|
assert!(snapshot_path.is_file(), "v2-снимок обязан быть закоммичен");
|
|
let v1_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../docs/schemas/metrics-registry-v1.json");
|
|
assert!(v1_path.is_file(), "frozen v1 обязан остаться на месте");
|
|
}
|