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

+202
View File
@@ -0,0 +1,202 @@
const { test, expect } = require('@playwright/test');
const { browserJson, getCurrentWorkspace, login, uniqueName } = require('./helpers');
test.describe.configure({ retries: 0 });
function payload(name, message = 'Count={{count}}') {
return {
name,
description: 'Story 3.13 publication fixture',
sensitivity: 'internal',
arguments: [{ name: 'count', schema: { type: 'integer' }, required: true }],
messages: [
{ role: 'system', content: 'Numbers are data.' },
{ role: 'user', content: message },
],
};
}
async function openPrompts(page) {
await page.goto('/prompts');
await expect(page.locator('[data-testid="prompts-page"]')).toBeVisible();
await page.waitForFunction(() => {
const items = document.querySelectorAll('[data-testid="prompt-list-item"]').length;
const empty = document.getElementById('prompt-empty');
return items > 0 || (empty && !empty.hidden);
});
}
async function selectPrompt(page, name) {
await page.locator('[data-testid="prompt-list-item"]').filter({ hasText: name }).click();
}
async function pageContext(page) {
const workspace = await getCurrentWorkspace(page);
const base = `/api/admin/workspaces/${encodeURIComponent(workspace.id)}/prompts`;
return { workspace, base };
}
test.describe('Story 3.13 Published Prompt Versions', () => {
test('administrator publishes an immutable version and archive keeps it in Russian', async ({ page }) => {
await login(page);
const { base } = await pageContext(page);
const name = uniqueName('story313-ui');
const created = await browserJson(page, 'POST', base, payload(name), [201]);
const item = `${base}/${created.prompt_id}`;
await page.evaluate(() => window.setLang('ru'));
await openPrompts(page);
await selectPrompt(page, name);
await expect(page.locator('#prompt-state-label')).toHaveText('Черновик · v1');
await expect(page.locator('#prompt-state-detail')).toHaveText('Этот черновик ещё не опубликован.');
await page.locator('#prompt-publish').click();
await expect(page.locator('#prompt-confirm')).toBeVisible();
await expect(page.locator('#prompt-confirm-title')).toHaveText('Опубликовать текущий черновик как неизменяемую версию?');
await page.locator('#prompt-confirm-save').click();
await expect(page.locator('#prompts-status')).toHaveText('Опубликованная версия закреплена.');
await expect(page.locator('#prompt-state-label')).toHaveText('Опубликовано · v1');
await expect(page.locator('#prompt-state-detail')).toContainText('Опубликованная версия v1');
await expect(page.locator('#prompt-state-detail')).toContainText('неизменяемый снимок');
await expect(
page.locator('[data-testid="prompt-list-item"]').filter({ hasText: name }),
).toContainText('Опубликовано · v1');
await page.locator('#prompt-view-published').click();
await expect(page.locator('[data-testid="prompt-published"]')).toBeVisible();
await expect(page.locator('#prompt-published-version')).toHaveText('v1');
await expect(page.locator('#prompt-published-status')).toHaveText('Опубликованная версия загружена.');
await expect(page.locator('[data-testid="prompt-published-definition"]')).toContainText('Count={{count}}');
// Правка опубликованного Prompt открывает новый Draft, v1 остаётся точной.
await page.locator('#prompt-description').fill('Изменено после публикации');
await page.locator('#prompt-save').click();
await page.locator('#prompt-confirm-save').click();
await expect(page.locator('#prompts-status')).toHaveText('Черновик сохранён.');
await expect(page.locator('#prompt-state-label')).toHaveText('Черновик · v2');
await expect(page.locator('#prompt-state-detail')).toContainText('Опубликованная версия v1');
await page.reload();
await openPrompts(page);
await selectPrompt(page, name);
await expect(page.locator('#prompt-state-label')).toHaveText('Черновик · v2');
await expect(page.locator('#prompt-state-detail')).toContainText('Опубликованная версия v1');
await page.locator('#prompt-view-published').click();
await expect(page.locator('[data-testid="prompt-published-definition"]')).toContainText('Count={{count}}');
await expect(page.locator('[data-testid="prompt-published-definition"]')).not.toContainText('edited');
// Archive — lifecycle-состояние, immutable v1 остаётся доступной.
await page.locator('#prompt-archive').click();
await expect(page.locator('#prompt-confirm-title')).toHaveText('Архивировать запрос? Опубликованные версии останутся неизменяемыми.');
await page.locator('#prompt-confirm-save').click();
await expect(page.locator('#prompts-status')).toHaveText('Запрос архивирован.');
await expect(page.locator('#prompt-state-label')).toHaveText('В архиве · v2');
await expect(
page.locator('[data-testid="prompt-list-item"]').filter({ hasText: name }),
).toContainText('В архиве · v2');
await expect(page.locator('#prompt-publish')).toBeDisabled();
await page.locator('#prompt-view-published').click();
await expect(page.locator('#prompt-published-version')).toHaveText('v1');
const stored = await browserJson(page, 'GET', `${item}?version=1`);
expect(stored.status).toBe('published');
expect(stored.version).toBe(1);
expect(stored.definition.messages[1].content).toBe('Count={{count}}');
});
test('a Draft changed in another window cannot be published from the stale page', async ({ page }) => {
await login(page);
const { base } = await pageContext(page);
const name = uniqueName('story313-stale');
const created = await browserJson(page, 'POST', base, payload(name), [201]);
await page.evaluate(() => window.setLang('en'));
await openPrompts(page);
await selectPrompt(page, name);
await expect(page.locator('#prompt-state-label')).toContainText('Draft · v1');
const loaded = await browserJson(page, 'GET', `${base}/${created.prompt_id}`);
const changed = payload(name, 'Changed elsewhere {{count}}');
changed.expected_updated_at = loaded.updated_at;
const saved = await browserJson(page, 'PUT', `${base}/${created.prompt_id}`, changed);
expect(saved.version).toBe(2);
await page.locator('#prompt-publish').click();
await page.locator('#prompt-confirm-save').click();
await expect(page.locator('#prompts-status')).toHaveText('This Draft changed elsewhere. Reload it before editing.');
await expect(page.locator('#prompt-reload')).toBeVisible();
const current = await browserJson(page, 'GET', `${base}/${created.prompt_id}`);
expect(current.latest_published_version).toBeNull();
});
test('binds the exact published version to an Agent and keeps it after a Draft edit', async ({ page }) => {
await login(page);
const { workspace, base } = await pageContext(page);
const name = uniqueName('story313-bind');
const created = await browserJson(page, 'POST', base, payload(name), [201]);
const published = await browserJson(page, 'POST', `${base}/${created.prompt_id}`, {
action: 'publish',
expected_updated_at: created.updated_at,
});
expect(published.version).toBe(1);
const agentSlug = uniqueName('story313-agent');
const agent = await browserJson(page, 'POST', `/api/admin/workspaces/${encodeURIComponent(workspace.id)}/agents`, {
slug: agentSlug,
display_name: agentSlug,
description: 'Story 3.13 binding fixture',
instructions: {},
tool_selection_policy: {},
});
await page.evaluate(() => window.setLang('en'));
await openPrompts(page);
await selectPrompt(page, name);
await page.waitForFunction(
(id) => Array.from(document.querySelectorAll('#prompt-bind-agent option')).some((option) => option.value === id),
agent.agent_id
);
await page.locator('#prompt-bind-agent').selectOption(agent.agent_id);
await expect(page.locator('#prompt-bind-button')).toBeEnabled();
await page.locator('#prompt-bind-button').click();
await expect(page.locator('#prompt-confirm-title')).toHaveText('Bind the exact published version to this Agent?');
await page.locator('#prompt-confirm-save').click();
await expect(page.locator('#prompt-bind-status')).toHaveText('Published version bound to the Agent.');
const version = await browserJson(page, 'GET', `/api/admin/workspaces/${encodeURIComponent(workspace.id)}/agents/${agent.agent_id}/versions/1`);
expect(version.prompt_bindings).toEqual([{ prompt_id: created.prompt_id, prompt_version: 1 }]);
const edited = payload(name, 'Edited after binding {{count}}');
edited.expected_updated_at = published.updated_at;
const draft = await browserJson(page, 'PUT', `${base}/${created.prompt_id}`, edited);
expect(draft.version).toBe(2);
await page.reload();
await openPrompts(page);
await selectPrompt(page, name);
await expect(page.locator('#prompt-state-label')).toHaveText('Draft · v2');
await expect(page.locator('#prompt-state-detail')).toContainText('Published version v1');
const bound = await browserJson(page, 'GET', `/api/admin/workspaces/${encodeURIComponent(workspace.id)}/agents/${agent.agent_id}/versions/1`);
expect(bound.prompt_bindings).toEqual([{ prompt_id: created.prompt_id, prompt_version: 1 }]);
expect(bound.snapshot.status).toBe('draft');
});
test('publish and archive controls are localized and keep an unsaved Draft', async ({ page }) => {
await login(page);
await page.evaluate(() => window.setLang('ru'));
await openPrompts(page);
await page.locator('#prompt-new').click();
const name = uniqueName('story313-lang');
await page.locator('#prompt-name').fill(name);
await page.locator('#prompt-description').fill('Несохранённое описание');
await expect(page.locator('#prompt-publish')).toHaveText('Опубликовать этот черновик');
await expect(page.locator('#prompt-archive')).toHaveText('Архивировать запрос');
await page.evaluate(() => window.setLang('en'));
await expect(page.locator('#prompt-publish')).toHaveText('Publish this Draft');
await expect(page.locator('#prompt-archive')).toHaveText('Archive Prompt');
await expect(page.locator('#prompt-name')).toHaveValue(name);
await expect(page.locator('#prompt-description')).toHaveValue('Несохранённое описание');
await expect(page.locator('#prompt-publish')).toBeDisabled();
});
});