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

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:
bsodfather committed 2026-10-25 09:08:22 +00:00
1 parent 1b6db09bd1
commit 54ce770682
357 files changed
+117394 -5115

No files matched your search

@@ -0,0 +1,241 @@
//! AC02 positive/negative controls для publication policy (Story 3.7).
//!
//! TL decision 4: explicit `include: crank://...` — это директива, а не обычное
//! упоминание. Она разрешается только workspace-local по уже опубликованной metadata;
//! понижение sensitivity запрещено. Обычные ссылки, проза и сами слова категорий
//! публикуются. Все контроля используют синтетические значения, без реальных секретов.
use super::super::helpers::{
create_draft, created_resource_id, draft_metadata, error_signature, get_card, spawn_authorized,
};
use super::{create_and_publish, create_fixture, publish, published_metadata};
use reqwest::StatusCode;
use serde_json::json;
use serial_test::serial;
/// Локальная опубликованная цель + обычная ссылка в том же Draft: обе ситуации
/// разрешены и дают immutable Published Version.
#[tokio::test(flavor = "multi_thread")]
#[serial]
async fn story37_at02_ordinary_link_and_local_published_include_are_publishable() {
let (_registry, server, client) = spawn_authorized("story37_policy_positive").await;
// Цель — exact Published Version в этом же workspace со sensitivity internal.
let target = create_and_publish(
&client,
&server,
&draft_metadata(
"crank://story37/policy-target",
"policy_target",
"text",
"text/plain",
"internal",
),
b"target reference body\n",
"story37-policy-target.txt",
"text/plain",
)
.await;
assert_eq!(target.published_version["version"], json!(1));
// Обычная ссылка + упоминания категорий: не директива и не секрет.
let ordinary = "См. https://example.com/spec; private keys и tokens описаны в prose.\n";
let ordinary_fixture = create_fixture(
&client,
&server,
&draft_metadata(
"crank://story37/policy-ordinary",
"policy_ordinary",
"text",
"text/plain",
"internal",
),
ordinary.as_bytes(),
"story37-policy-ordinary.txt",
"text/plain",
)
.await;
let (status, text, body) = publish(
&client,
&server,
&ordinary_fixture.resource_id,
&ordinary_fixture.updated_at,
)
.await;
assert_eq!(
status,
StatusCode::OK,
"an ordinary link must stay publishable; observed {} body={text}",
error_signature(status, &body)
);
assert_eq!(published_metadata(&body)["version"], json!(1));
// Explicit include на exact published version того же workspace с совместимой
// sensitivity публикуется; текст остаётся статическим (без expansion).
let include = "include: crank://story37/policy-target\n";
let include_fixture = create_fixture(
&client,
&server,
&draft_metadata(
"crank://story37/policy-include",
"policy_include",
"text",
"text/plain",
"internal",
),
include.as_bytes(),
"story37-policy-include.txt",
"text/plain",
)
.await;
let (status, text, body) = publish(
&client,
&server,
&include_fixture.resource_id,
&include_fixture.updated_at,
)
.await;
assert_eq!(
status,
StatusCode::OK,
"an explicit include of a published local Resource must publish; observed {} body={text}",
error_signature(status, &body)
);
let published = published_metadata(&body);
assert_eq!(published["version"], json!(1));
assert_eq!(published["kind"], json!("text"));
assert!(
!published.to_string().contains("target reference body"),
"publication must not expand the included content: {published}"
);
}
/// Include на published Resource с более высокой sensitivity — access-bypassing
/// reference: тот же generic 422, без раскрытия цели и без side effects.
#[tokio::test(flavor = "multi_thread")]
#[serial]
async fn story37_at02_include_must_not_lower_published_sensitivity() {
let (_registry, server, client) = spawn_authorized("story37_policy_lowering").await;
// Публикуем секретную цель (sensitivity=secret сама по себе публикуема).
let secret_target = create_and_publish(
&client,
&server,
&draft_metadata(
"crank://story37/policy-secret-target",
"policy_secret_target",
"text",
"text/plain",
"secret",
),
b"synthetic secret target body\n",
"story37-policy-secret-target.txt",
"text/plain",
)
.await;
assert_eq!(secret_target.published_version["version"], json!(1));
// Внутренний Draft включает секретную цель -> понижение sensitivity, отказ.
let fixture = create_fixture(
&client,
&server,
&draft_metadata(
"crank://story37/policy-lowering",
"policy_lowering",
"text",
"text/plain",
"internal",
),
b"include: crank://story37/policy-secret-target\n",
"story37-policy-lowering.txt",
"text/plain",
)
.await;
let (status, text, body) =
publish(&client, &server, &fixture.resource_id, &fixture.updated_at).await;
assert_eq!(
status,
StatusCode::UNPROCESSABLE_ENTITY,
"a sensitivity-lowering include must be refused with 422; observed {} body={text}",
error_signature(status, &body)
);
assert_eq!(body["error"]["code"], json!("resource_secret_findings"));
assert_eq!(body["error"]["context"]["field"], json!("content"));
assert!(
!text.contains("policy-secret-target") && !text.contains("policy_secret_target"),
"the refusal must not disclose the referenced target: {text}"
);
// Отказ не опубликовал включающий Draft и не изменил цель.
let card = get_card(&client, &server, &fixture.resource_id).await;
assert_eq!(card["resource"]["status"], json!("draft"));
let (status, _, _) = super::read_version(&client, &server, &fixture.resource_id, 1).await;
assert_eq!(
status,
StatusCode::NOT_FOUND,
"a refused publication must not expose a Published Version"
);
}
/// `include:` на неопубликованную (но существующую) сущность того же workspace —
/// тот же generic отказ; существование/метаданные цели не раскрываются.
#[tokio::test(flavor = "multi_thread")]
#[serial]
async fn story37_at02_include_requires_published_target_without_disclosure() {
let (_registry, server, client) = spawn_authorized("story37_policy_unpublished").await;
let unpublished_meta = draft_metadata(
"crank://story37/policy-draft-target",
"policy_draft_target",
"text",
"text/plain",
"internal",
);
let unpublished = create_draft(
&client,
&server,
&unpublished_meta,
b"draft-only target body\n",
"story37-policy-draft-target.txt",
"text/plain",
)
.await;
let unpublished_id = created_resource_id(&unpublished);
assert!(!unpublished_id.is_empty());
let fixture = create_fixture(
&client,
&server,
&draft_metadata(
"crank://story37/policy-unpublished",
"policy_unpublished",
"text",
"text/plain",
"internal",
),
b"include: crank://story37/policy-draft-target\n",
"story37-policy-unpublished.txt",
"text/plain",
)
.await;
let (status, text, body) =
publish(&client, &server, &fixture.resource_id, &fixture.updated_at).await;
assert_eq!(
status,
StatusCode::UNPROCESSABLE_ENTITY,
"an include of an unpublished target must be refused; observed {} body={text}",
error_signature(status, &body)
);
assert_eq!(body["error"]["code"], json!("resource_secret_findings"));
assert!(
!text.contains("policy-draft-target") && !text.contains("draft-only target body"),
"the refusal must not disclose the unpublished target: {text}"
);
// Цель остаётся Draft и не получила Published Version.
let target_card = get_card(&client, &server, &unpublished_id).await;
assert_eq!(target_card["resource"]["status"], json!("draft"));
let (target_version_status, _, _) =
super::read_version(&client, &server, &unpublished_id, 1).await;
assert_eq!(target_version_status, StatusCode::NOT_FOUND);
}