Files
crank/crates/crank-registry/src/migrations/resource_drafts_v16.sql
T
bsodfather 54ce770682
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
feat(epic3): deliver the accepted Epic 3 scope through Story 3.17
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.
2026-10-25 09:08:22 +00:00

77 lines
3.8 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- V16: typed static Resource drafts (Story 3.6, D-15).
--
-- Байты не хранятся здесь: содержимое версии — это content-addressed blob
-- (`artifact_blobs`) и owning-ссылка (`artifact_sources`), поэтому Resource
-- участвует в существующем учёте владения и sweep-е (AD-10).
-- Filesystem path, raw filename и mutable external reference намеренно
-- отсутствуют (D-12).
create table resources (
workspace_id text not null references workspaces(id) on delete cascade,
resource_id text not null,
uri text not null,
name text not null,
description text not null default '',
status text not null default 'draft',
kind text not null,
current_draft_version integer not null,
created_at timestamptz not null,
updated_at timestamptz not null,
constraint resources_resource_id_check check (resource_id ~ '^res_[A-Za-z0-9_-]{1,96}$'),
constraint resources_uri_len_check check (octet_length(uri) between 10 and 200),
constraint resources_name_len_check check (octet_length(name) between 1 and 64),
constraint resources_description_len check (octet_length(description) <= 1024),
constraint resources_status_check check (status in ('draft', 'published', 'archived')),
constraint resources_kind_check check (kind in ('text', 'json', 'binary')),
constraint resources_current_version_check check (current_draft_version >= 1),
constraint resources_timestamps_check check (updated_at >= created_at),
constraint resources_workspace_uri_unique unique (workspace_id, uri),
constraint resources_workspace_name_unique unique (workspace_id, name),
primary key (workspace_id, resource_id)
);
create table resource_versions (
workspace_id text not null,
resource_id text not null,
version integer not null,
kind text not null,
mime_type text not null,
size_bytes bigint not null,
digest text not null,
sensitivity text not null,
artifact_source_id text not null,
created_at timestamptz not null,
superseded_at timestamptz null,
constraint resource_versions_version_check check (version >= 1),
constraint resource_versions_kind_check check (kind in ('text', 'json', 'binary')),
constraint resource_versions_mime_type_check check (
octet_length(mime_type) between 3 and 255
and mime_type ~ '^[A-Za-z0-9!#$&^_.+-]+/[A-Za-z0-9!#$&^_.+-]+$'
),
constraint resource_versions_size_check check (size_bytes between 1 and 262144),
constraint resource_versions_digest_check check (digest ~ '^[0-9a-f]{64}$'),
constraint resource_versions_sensitivity_check check (
sensitivity in ('public', 'internal', 'secret')
),
constraint resource_versions_source_id_check check (
artifact_source_id ~ '^src_[A-Za-z0-9_-]{1,128}$'
),
constraint resource_versions_supersede_check check (
superseded_at is null or superseded_at >= created_at
),
primary key (workspace_id, resource_id, version),
constraint resource_versions_resource_fkey foreign key (workspace_id, resource_id)
references resources(workspace_id, resource_id) on delete cascade,
constraint resource_versions_source_fkey foreign key (workspace_id, artifact_source_id)
references artifact_sources(workspace_id, source_id)
);
-- Ровно одна текущая черновая версия на Resource: пометка прежней версии
-- обязана произойти до вставки новой (D-15 шаг 4), индекс не ослабляется.
create unique index resource_versions_current_draft_unique
on resource_versions (workspace_id, resource_id)
where superseded_at is null;
create index resources_workspace_created_idx
on resources (workspace_id, created_at, resource_id);