فقط اجرای منقضیشده به شکست ثبت میشود. رزرو ۲۰ سنت حفظ میشود؛ هزینه واقعی نامشخص است، نه هزینه صفر.
-
این اقدام QA یا تأیید خودکار ایجاد نمیکند؛ انتشار، اجرای دوباره، افزایش بودجه یا آزادسازی رزرو انجام نمیشود. مجوز بازبین مستقل و اتصال اجرای منقضی را سرور دوباره بررسی میکند.
-
{reason.length}/500
-
- {error&&
{error}
}
-
-
;
-}
diff --git a/frontend/admin-panel/src/components/OrchestrationNavigation.test.tsx b/frontend/admin-panel/src/components/OrchestrationNavigation.test.tsx
deleted file mode 100644
index 951bc6ae..00000000
--- a/frontend/admin-panel/src/components/OrchestrationNavigation.test.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import { render,screen } from '@testing-library/react';
-import { MemoryRouter } from 'react-router-dom';
-import { it,expect,vi } from 'vitest';
-import Sidebar from './Sidebar';
-vi.mock('../services/api',()=>({default:{get:vi.fn().mockResolvedValue({data:{success:true,data:{}}})}}));
-it('exposes command center inside existing authenticated navigation',async()=>{
- render();
- expect(await screen.findByRole('link',{name:'Orchestration command center'})).toHaveAttribute('href','/orchestration');
-});
diff --git a/frontend/admin-panel/src/components/OrchestrationPresentation.test.tsx b/frontend/admin-panel/src/components/OrchestrationPresentation.test.tsx
deleted file mode 100644
index 3f06f428..00000000
--- a/frontend/admin-panel/src/components/OrchestrationPresentation.test.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import {render,screen} from '@testing-library/react';
-import {expect,it} from 'vitest';
-import {Records} from './OrchestrationPresentation';
-it('preserves human scope, criteria and immutable identifiers while translating protocol enums',()=>{
- render();
- expect(screen.getAllByText('READY')).toHaveLength(2);
- expect(screen.getByText('SUCCEEDED')).toBeInTheDocument();
- expect(screen.getByText('آمادهسازی')).toBeInTheDocument();
- expect(screen.getByText('موفق')).toBeInTheDocument();
-});
diff --git a/frontend/admin-panel/src/components/OrchestrationPresentation.tsx b/frontend/admin-panel/src/components/OrchestrationPresentation.tsx
deleted file mode 100644
index 4f6ab567..00000000
--- a/frontend/admin-panel/src/components/OrchestrationPresentation.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import type {ServerAction} from '../services/orchestration';
-const labels:Record={GATE1_RENEWAL_REQUIRED:'مسدود — تأیید Gate1 منقضی شده؛ نیازمند تأیید مجدد مالک',DRAFT:'پیشنویس',GATE1_HELD:'تصمیم به تعویق افتاده',GATE1_PENDING:'در انتظار تأیید Gate1',GATE1_APPROVED:'تأییدشده در Gate1',READY:'آماده اجرا',RUNNING:'در حال اجرا',SUCCEEDED:'موفق',FAILED:'ناموفق',BLOCKED:'مسدود',EXPIRED:'منقضی',REJECTED:'ردشده',APPROVED:'تأییدشده',GATE2_PENDING:'در انتظار Gate2 (غیرفعال)',PREPARE:'آمادهسازی',MUTATE_PRODUCTION:'تغییر Production (غیرفعال)',SEO:'بهینهسازی جستوجو (SEO)',Content:'محتوا',Tech:'فنی',operationMode:'حالت عملیات',budgetLimitCents:'سقف بودجه (سنت)',metadata:'اطلاعات ثبتشده',scope:'محدوده',acceptanceCriteria:'معیارهای پذیرش',commitSha:'شناسه کامیت',id:'شناسه',taskId:'شناسه وظیفه',expectedVersion:'نسخه مورد انتظار',idempotencyKey:'کلید جلوگیری از اجرای تکراری',gate:'دروازه تأیید',decision:'تصمیم',expiresAt:'زمان انقضا',createdAt:'زمان ثبت',runId:'شناسه اجرا',artifactHash:'هش خروجی',environment:'محیط',sha256:'هش SHA-256',kind:'نوع',eventType:'نوع رویداد',fromState:'وضعیت پیشین',toState:'وضعیت بعدی',sequence:'ترتیب',amountCents:'مبلغ (سنت)',status:'وضعیت',reason:'دلیل',department:'دپارتمان',staging:'آزمایشی (staging)',FREEZE_NEW_WORK:'توقف کار جدید',STOP_AGENTS:'توقف عاملها',DISABLE_MUTATIONS:'منع تغییرات',EMERGENCY_HALT:'توقف اضطراری',RESERVE:'رزرو بودجه',RECONCILE:'تطبیق بودجه'};
-export const label=(value:string)=>labels[value]??value;
-export const actionLabel=(action:ServerAction)=>({HOLD_GATE1:'تعویق تصمیم Gate1',SUBMIT_GATE1:'ارسال برای Gate1',APPROVE_GATE1:'تأیید کار محدود در Gate1',REJECT_GATE1:'رد کار در Gate1',QUEUE_PREPARE:'صفبندی آمادهسازی'}[action.id]??(action.gate?`${action.decision==='APPROVED'?'تأیید':'رد'} در Gate${action.gate}`:'اقدام سرور'));
-export function Records({value,field}:{value:unknown;field?:string}){
- if(value===null||value===undefined)return نامشخص — گزارش نشده;
- if(Array.isArray(value))return value.length?
مجموع درگاه شامل همه مشتریهاست. تفکیک تأمینکننده، مدل و حساب همپوشانی دارد؛ آنها را جمع نکنید. شمارنده حافظه نهان و استدلال ممکن است با توکنها همپوشان باشد. مجموع یا سهمیه تخمینی محاسبه نمیشود.
-
سهم مصرف Hermes: نامشخص و گزارشنشده؛ با مجموع درگاه جمع نکنید.
- {loading&&
در حال دریافت مصرف درگاه…
}{error&&
دریافت مصرف ناموفق بود: {error}
}
- {data&&<>
منبع
{data.source}
زمان دریافت (نه زمان تازگی منبع)
{shown(data.freshness.retrievedAt)}
زمان بهروزرسانی منبع
{shown(data.freshness.sourceUpdatedAt)}
قدیمی بودن داده
{shown(data.freshness.stale)}
بازه گزارششده
{data.period}
مجموع درگاه (شامل Hermes)
- {(['providers','models','accounts'] as const).map(group=>
{labels[group]}
{!data.data[group].length&&
دادهای برای {labels[group]} گزارش نشده است.
}
{data.data[group].map((row,i)=>
{shown(row.provider)} · {shown(row.model)}
{row.accountId&&
{row.accountId}
}{group==='accounts'&&
سهمیه باقیمانده گزارششده تأمینکننده
{shown(row.quota?.remaining)}
زمان بازنشانی سهمیه گزارششده
{shown(row.quota?.resetAt)}
دلیل وضعیت سهمیه
{shown(row.quota?.reason)}
})}
)}
-
سهمیه نامشخص است: درخواست سهمیه به منبع، اطلاعات احراز هویت را تغییر میدهد؛ بنابراین این رابط فقطخواندنی آن را فراخوانی نمیکند.
>}
- ;
-}
diff --git a/frontend/admin-panel/src/components/RuntimeReadPanel.test.tsx b/frontend/admin-panel/src/components/RuntimeReadPanel.test.tsx
deleted file mode 100644
index 27a42c09..00000000
--- a/frontend/admin-panel/src/components/RuntimeReadPanel.test.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import {render,screen,fireEvent,waitFor} from '@testing-library/react';
-import {beforeEach,it,expect,vi} from 'vitest';
-import api from '../services/api';
-import RuntimeReadPanel from './RuntimeReadPanel';
-const provenance={source:'snapshot',capturedAt:'2020-01-01T00:00:00Z',ageSeconds:5000,freshness:'stale',liveProcess:'unknown'};
-it('labels snapshot inventory without presenting متوقف gateway, zero agents or فعال sessions as live',async()=>{
- vi.mocked(api.get).mockImplementation(async url=>({data:url.endsWith('/health')?{ok:true,version:'v1',commit:'abc',auth_required:true,provenance}:url.endsWith('/profiles')?[{name:'dev',is_default:false,gateway_running:false,liveGatewayState:'unknown',provenance}]:url.endsWith('/status')?{version:'v1',gateway_running:false,overall:'نامشخص',active_agents:0,gateway_state:null,liveGatewayState:'unknown',liveActiveAgents:null,provenance}:url.endsWith('/sessions')?{total:1,sessions:[{id:'session-1',profile:'dev',source:'cli',is_active:true}],provenance}:{period_days:30,totals:{total_input:1,total_output:2,total_sessions:1,total_estimated_cost:0},provenance}}));
- render();
- expect(await screen.findByText('سرویس فهرست ثبتشده: پاسخگو (نه سلامت زنده Hermes)')).toBeInTheDocument();
- screen.getAllByText(/زمان ثبت: 2020-01-01T00:00:00Z/).forEach(row=>expect(row).toHaveTextContent('قدیمی'));
- fireEvent.change(screen.getByLabelText('پروفایل اجرای مجاز'),{target:{value:'dev'}});
- expect(await screen.findByText(/عاملهای فعال: نامشخص/)).toBeInTheDocument();
- expect(await screen.findByText(/پرچم تاریخی نمای ثبتشده: فعال; فعالیت زنده نامشخص است/)).toBeInTheDocument();
- expect(screen.queryByText(/درگاه.*متوقف/)).not.toBeInTheDocument();
- expect(screen.queryByText(/عاملهای فعال: 0/)).not.toBeInTheDocument();
- expect(screen.queryByText(/runtime health: healthy/)).not.toBeInTheDocument();
-});
-vi.mock('../services/api',()=>({default:{get:vi.fn()}}));
-beforeEach(()=>{vi.resetAllMocks();vi.mocked(api.get).mockImplementation(async url=>{
- if(url.endsWith('/health'))return {data:{ok:true,version:'v1',commit:'abc',auth_required:true}};
- if(url.endsWith('/profiles'))return {data:[{name:'dev',is_default:false,gateway_running:false}]};
- if(url.endsWith('/status'))return {data:{version:'v1',gateway_running:false,overall:'degraded',active_agents:0,gateway_state:null}};
- if(url.endsWith('/sessions'))return {data:{total:0,sessions:[]}};
- if(url.endsWith('/usage'))return {data:{period_days:30,totals:{total_input:0,total_output:0,total_sessions:0,total_estimated_cost:0}}};
- throw new Error('Runtime unavailable');
-});});
-it('shows actual health identity, explicit متوقف gateway, zero usage and profile-bound reads',async()=>{
- render();expect(await screen.findByText('v1 · abc')).toBeInTheDocument();
- fireEvent.change(await screen.findByLabelText('پروفایل اجرای مجاز'),{target:{value:'dev'}});
- expect(await screen.findByText('degraded')).toBeInTheDocument();expect(await screen.findByText('نشستی دریافت نشد.')).toBeInTheDocument();
- expect(screen.getByText('توکن ورودی: 0')).toBeInTheDocument();expect(screen.getByText(/هزینه تخمینی منبع: 0/)).toBeInTheDocument();
- expect(api.get).toHaveBeenCalledWith('/admin/orchestration/runtime/sessions',{params:{profile:'dev',limit:20,offset:0}});
-});
-it('shows unavailable rather than healthy when runtime cannot be authenticated',async()=>{
- vi.mocked(api.get).mockRejectedValue(new Error('Runtime unavailable'));
- render();expect(await screen.findByText(/وضعیت اجرا در دسترس نیست/)).toBeInTheDocument();expect(screen.queryByText('اجرای احرازهویتشده health: healthy')).not.toBeInTheDocument();
-});
-it('rejects malformed health and never renders نامشخص secret fields',async()=>{
- vi.mocked(api.get).mockImplementation(async url=>({data:url.endsWith('/health')?{ok:true,version:'v1',commit:'abc',auth_required:false,password:'secret-value'}:[]}));
- render();expect(await screen.findByText(/وضعیت اجرا در دسترس نیست/)).toBeInTheDocument();expect(screen.queryByText(/secret-value/)).not.toBeInTheDocument();
-});
-it('refreshes the authenticated runtime reads without a browser runtime connection',async()=>{
- render();await screen.findByText('v1 · abc');fireEvent.click(screen.getByRole('button',{name:'بازخوانی اطلاعات اجرا'}));await waitFor(()=>expect(vi.mocked(api.get).mock.calls.filter(([u])=>u.endsWith('/health'))).toHaveLength(2));
-});
diff --git a/frontend/admin-panel/src/components/RuntimeReadPanel.tsx b/frontend/admin-panel/src/components/RuntimeReadPanel.tsx
deleted file mode 100644
index 3031a2c7..00000000
--- a/frontend/admin-panel/src/components/RuntimeReadPanel.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import {useEffect,useState} from 'react';
-import Button from './ui/Button';
-import {runtime} from '../services/runtime';
-import type {RuntimeProvenance,RuntimeHealth,RuntimeProfile,RuntimeStatus,RuntimeSessions,RuntimeUsage} from '../services/runtime';
-function Snapshot({value}:{value?:RuntimeProvenance}){return value?
فهرست ثبتشده · زمان ثبت: {value.capturedAt} · قدمت: {value.ageSeconds} ثانیه · {value.freshness==='fresh'?'تازه':'قدیمی'} · فرایند زنده: نامشخص. حتی نمای تازه، آمادگی زنده را اثبات نمیکند.
- امکان ارتباط با سرویس ارکستراسیون یا دریافت آمار وظایف دپارتمانها وجود ندارد. به منظور حفظ صداقت عملیاتی، هیچ وضعیت شبیهسازیشدهای رندر نمیشود.
-
قانون تفکیک حاکمیتی اقدامات مدیریتی از مجوزهای عملیاتی:
-
- طرحهای استراتژیک تامینکنندگان (B2B_SUPPLIER_STRATEGY) و همکاریهای تجاری، وظایف انسانی و راهبردی هستند که دکمه تایید فوری ندارند. تکمیل این موارد صرفاً با درج صریح نتیجه واقعی (Outcome) و مستندات قابل اعتبارسنجی (Evidence) محقق میشود.
-
- );
-}
diff --git a/frontend/admin-panel/src/pages/OrchestrationCommandCenter.test.tsx b/frontend/admin-panel/src/pages/OrchestrationCommandCenter.test.tsx
deleted file mode 100644
index 9369d7dc..00000000
--- a/frontend/admin-panel/src/pages/OrchestrationCommandCenter.test.tsx
+++ /dev/null
@@ -1,198 +0,0 @@
-import { render, screen, fireEvent, within, waitFor, act } from '@testing-library/react';
-import { beforeEach, describe, it, expect, vi } from 'vitest';
-import api from '../services/api';
-import OrchestrationCommandCenter from './OrchestrationCommandCenter';
-vi.mock('../services/api', () => ({ default: {get:vi.fn(),post:vi.fn(),put:vi.fn()} }));
-const task={id:'t1',key:'bounded-1',title:'Bounded SEO audit',department:'SEO',state:'GATE1_PENDING',version:4,operationMode:'PREPARE',budgetLimitCents:500,availableActions:[{id:'g1',label:'Approve bounded work',gate:1,decision:'APPROVED'}],runs:[],metadata:{scope:'Only staging',acceptanceCriteria:['Audit schema']}};
-describe('command center', () => {
- beforeEach(() => { vi.resetAllMocks(); vi.mocked(api.get).mockImplementation(async url => {
- if(url.endsWith('/overview'))return {data:{items:[],measuredAt:'2026-10-22T00:00:00Z',capabilities:{mutations:true,killSwitch:true,chat:true,runtime:false}}};
- if(url.endsWith('/tasks')) return {data:[task]};
- if(url.endsWith('/tasks/t1')) return {data:task};
- throw new Error('Unavailable: '+url);
- }); });
- it('loads server tasks, immutable bounds and only server actions; unavailable data is never fabricated', async () => {
- render();
- fireEvent.click(await screen.findByRole('button',{name:'Bounded SEO audit'}));
- const detail=await screen.findByRole('region',{name:'جزئیات وظیفه'});
- expect(within(detail).getByText(/Only staging/)).toBeInTheDocument();
- expect(screen.getByRole('button',{name:'تأیید در Gate1'})).toBeInTheDocument();
- expect(screen.queryByRole('button',{name:'RUNNING'})).not.toBeInTheDocument();
- fireEvent.click(screen.getByRole('button',{name:'عاملها و دپارتمانها'}));
- expect(screen.getByText(/این بخش در نسخه فعلی در دسترس نیست/)).toBeInTheDocument();
- expect(vi.mocked(api.get).mock.calls.some(([url])=>url.endsWith('/agents'))).toBe(false);
- });
- it('labels deliberately omitted scope metadata unavailable, not immutable scope',async()=>{
- const {metadata:_metadata,...safeTask}=task;
- vi.mocked(api.get).mockImplementation(async url=>({data:url.endsWith('/tasks')?[safeTask]:safeTask}));
- render();
- fireEvent.click(await screen.findByRole('button',{name:'Bounded SEO audit'}));
- expect(await screen.findByText('محدوده و معیارهای پذیرش در دسترس نیست؛ سرور این اطلاعات را در نمای امن ارسال نکرده است.')).toBeInTheDocument();
- expect(screen.queryByText('Immutable scope / acceptance criteria')).not.toBeInTheDocument();
- });
- it('approves immediately without date or reason after explicit confirmation',async()=>{
- vi.mocked(api.post).mockResolvedValue({data:{...task,state:'READY'}});
- render();
- fireEvent.click(await screen.findByRole('button',{name:'Bounded SEO audit'}));
- fireEvent.click(await screen.findByRole('button',{name:'تأیید در Gate1'}));
- const dialog=screen.getByRole('dialog');
- expect(within(dialog).getByLabelText('زمان اجرای برنامهریزیشده')).toHaveValue('');
- expect(within(dialog).queryByLabelText('زمان انقضا')).not.toBeInTheDocument();
- fireEvent.click(within(dialog).getByLabelText('محدوده و اتصال تغییرناپذیر را بررسی کردم'));
- fireEvent.click(within(dialog).getByRole('button',{name:'تأیید فرمان'}));
- await waitFor(()=>expect(api.post).toHaveBeenCalledTimes(1));
- const payload=vi.mocked(api.post).mock.calls[0][1] as Record;
- expect(payload.decision).toBe('APPROVED');
- expect(payload.expiresAt).toBeUndefined();expect(payload.notBefore).toBeUndefined();
- });
- it('requires explicit confirmation; retains idempotency across failed retry', async () => {
- vi.mocked(api.post).mockRejectedValue(new Error('network failure'));
- render();
- fireEvent.click(await screen.findByRole('button',{name:'Bounded SEO audit'}));
- fireEvent.click(await screen.findByRole('button',{name:'تأیید در Gate1'}));
- const dialog=screen.getByRole('dialog');
- expect(within(dialog).getByRole('button',{name:'تأیید فرمان'})).toBeDisabled();
- fireEvent.change(within(dialog).getByLabelText('زمان اجرای برنامهریزیشده'),{target:{value:new Date(Date.now()+3600000).toISOString().slice(0,16)}});
- fireEvent.change(within(dialog).getByLabelText('دلیل'),{target:{value:'محدوده checked'}});
- fireEvent.click(within(dialog).getByLabelText('محدوده و اتصال تغییرناپذیر را بررسی کردم'));
- fireEvent.click(within(dialog).getByRole('button',{name:'تأیید فرمان'}));
- expect(await within(dialog).findByRole('alert')).toHaveTextContent('network failure');
- expect(within(dialog).getByLabelText('دلیل')).toBeDisabled();
- expect(within(dialog).getByLabelText('زمان اجرای برنامهریزیشده')).toBeDisabled();
- fireEvent.click(within(dialog).getByRole('button',{name:'تأیید فرمان'}));
- await within(dialog).findByRole('alert');
- expect(api.post).toHaveBeenCalledTimes(2);
- const first=vi.mocked(api.post).mock.calls[0][1];
- expect(first).toEqual(expect.objectContaining({expectedVersion:4,decision:'APPROVED'}));
- expect(vi.mocked(api.post).mock.calls[1][1]).toEqual(first);
- });
- it('keeps legacy Gate2 release decisions disabled without sending a command',async()=>{
- const release={...task,state:'GATE2_PENDING',availableActions:[{id:'g2',label:'Approve release',gate:2,decision:'APPROVED'}]};
- vi.mocked(api.get).mockImplementation(async url=>({data:url.endsWith('/overview')?{items:[],measuredAt:'now',capabilities:{mutations:true}}:url.endsWith('/tasks')?[release]:release}));
- render();
- fireEvent.click(await screen.findByRole('button',{name:'Bounded SEO audit'}));
- expect(await screen.findByRole('button',{name:'تأیید در Gate2'})).toBeDisabled();
- expect(api.post).not.toHaveBeenCalled();
- });
- it('requires global impact confirmation for each kill level and reports backend rejection',async()=>{
- vi.mocked(api.put).mockRejectedValue(new Error('Forbidden: role'));
- render();await screen.findByRole('button',{name:'Bounded SEO audit'});
- fireEvent.click(screen.getByRole('button',{name:'توقف اضطراری'}));
- expect(screen.getAllByRole('option')).toHaveLength(4);
- expect(screen.getByRole('button',{name:'اعمال توقف سراسری'})).toBeDisabled();
- fireEvent.change(screen.getByLabelText('سطح توقف'),{target:{value:'EMERGENCY_HALT'}});
- fireEvent.change(screen.getByLabelText('دلیل توقف'),{target:{value:'Incident'}});
- fireEvent.click(screen.getByLabelText('پیامد عملیاتی سراسری را تأیید میکنم'));
- fireEvent.click(screen.getByRole('button',{name:'اعمال توقف سراسری'}));
- expect(await screen.findByRole('alert')).toHaveTextContent('Forbidden: role');
- expect(api.put).toHaveBeenCalledWith('/admin/orchestration/kill-switch',{level:'EMERGENCY_HALT',reason:'Incident'});
- });
- it('sends advisory chat via typed bridge and renders text, not HTML',async()=>{
- vi.mocked(api.post).mockResolvedValue({data:{id:'reply',role:'assistant',content:''}});
- render();await screen.findByRole('button',{name:'Bounded SEO audit'});
- fireEvent.click(screen.getByRole('button',{name:'گفتوگو'}));
- fireEvent.change(screen.getByLabelText('شناسه نشست'),{target:{value:'session-1'}});
- fireEvent.change(screen.getByLabelText('پیام'),{target:{value:'Explain bounded work'}});
- fireEvent.click(screen.getByRole('button',{name:'ارسال پیام مشورتی'}));
- expect(await screen.findByText('assistant: ')).toBeInTheDocument();
- expect(document.querySelector('script')).toBeNull();
- expect(api.post).toHaveBeenCalledWith('/admin/orchestration/chat/messages',expect.objectContaining({sessionId:'session-1',message:'Explain bounded work'}));
- });
- it('fails closed for creation, kill and chat when overview cannot authorize capabilities',async()=>{
- vi.mocked(api.get).mockImplementation(async url=>{if(url.endsWith('/tasks'))return {data:[task]};throw new Error('Unavailable');});
- render();await screen.findByRole('button',{name:'Bounded SEO audit'});
- fireEvent.click(screen.getByRole('button',{name:'وظیفهها و تأییدها'}));
- expect(screen.queryByText('ایجاد کار محدود')).not.toBeInTheDocument();
- fireEvent.click(screen.getByRole('button',{name:'توقف اضطراری'}));
- expect(screen.queryByRole('button',{name:'اعمال توقف سراسری'})).not.toBeInTheDocument();
- fireEvent.click(screen.getByRole('button',{name:'گفتوگو'}));
- expect(screen.queryByRole('button',{name:'ارسال پیام مشورتی'})).not.toBeInTheDocument();
- expect(api.post).not.toHaveBeenCalled();expect(api.put).not.toHaveBeenCalled();
- });
-
-});
-
-it('requires explicit kill capability rather than generic mutations',async()=>{
- vi.mocked(api.get).mockImplementation(async url=>({data:url.endsWith('/overview')?{items:[],measuredAt:'now',capabilities:{mutations:true}}:url.endsWith('/tasks')?[task]:task}));
- render();await screen.findByRole('button',{name:'Bounded SEO audit'});
- fireEvent.click(screen.getByRole('button',{name:'توقف اضطراری'}));
- expect(screen.queryByRole('button',{name:'اعمال توقف سراسری'})).not.toBeInTheDocument();expect(api.put).not.toHaveBeenCalled();
-});
-
-it.each([{}, {scope:'STAGE_PREPARE'}, {scope:'Human scope',acceptanceCriteria:[]}])('does not claim incomplete or legacy metadata is scope evidence: %j',async metadata=>{
- vi.mocked(api.get).mockImplementation(async url=>({data:url.endsWith('/tasks')?[{...task,metadata}]:{...task,metadata}}));
- render();fireEvent.click(await screen.findByRole('button',{name:'Bounded SEO audit'}));
- expect(await screen.findByText(/محدوده و معیارهای پذیرش در دسترس نیست/)).toBeInTheDocument();
- expect(screen.getByText('محدوده گردش کار سرور: در نمای امن در دسترس نیست.')).toBeInTheDocument();
-});
-it('separates human evidence from server workflow scope without inventing a marker',async()=>{
- vi.mocked(api.get).mockImplementation(async url=>({data:url.endsWith('/tasks')?[task]:task}));
- render();fireEvent.click(await screen.findByRole('button',{name:'Bounded SEO audit'}));
- expect(await screen.findByText('محدوده و معیارهای پذیرش گزارششده از سرور')).toBeInTheDocument();
- expect(screen.getByText('محدوده گردش کار سرور: در نمای امن در دسترس نیست.')).toBeInTheDocument();
-});
-
-it('shows advertised decisions directly on pending card and labels reservation not measured cost',async()=>{
- const ownerTask={...task,budgetLimitCents:20,availableActions:['APPROVE_GATE1','REJECT_GATE1','HOLD_GATE1']};
- vi.mocked(api.get).mockImplementation(async url=>({data:url.endsWith('/overview')?{items:[],measuredAt:'now',capabilities:{mutations:true}}:url.endsWith('/tasks')?[ownerTask]:ownerTask}));
- render();
- const card=await screen.findByRole('region',{name:'منتظر تصمیم شما'});
- expect(await within(card).findByRole('button',{name:'تأیید کار محدود در Gate1'})).toBeEnabled();
- expect(within(card).getByRole('button',{name:'رد کار در Gate1'})).toBeEnabled();
- expect(within(card).getByRole('button',{name:'تعویق تصمیم Gate1'})).toBeEnabled();
- expect(within(card).getByText('رزرو آزمایشی؛ هزینه واقعی نامشخص')).toBeInTheDocument();
- fireEvent.click(within(card).getByRole('button',{name:'تعویق تصمیم Gate1'}));
- const dialog=await screen.findByRole('dialog');
- expect(within(dialog).getByRole('heading',{name:'تعویق تصمیم Gate1'})).toBeInTheDocument();
- expect(api.post).not.toHaveBeenCalled(); expect(api.put).not.toHaveBeenCalled();
-});
-
-const cardActions=['APPROVE_GATE1','HOLD_GATE1','REJECT_GATE1'];
-const cardLabels=['تأیید کار محدود در Gate1','تعویق تصمیم Gate1','رد کار در Gate1'];
-it.each(cardActions)('opens fresh matching %s from the card without a preconfirm mutation',async action=>{
- vi.resetAllMocks();
- const fresh={...task,version:9,budgetLimitCents:73,availableActions:[action]};
- vi.mocked(api.get).mockImplementation(async url=>({data:url.endsWith('/overview')?{items:[],measuredAt:'now',capabilities:{mutations:true}}:url.endsWith('/tasks')?[{...task,availableActions:cardActions}]:fresh}));
- render();
- const queue=screen.getByRole('region',{name:'منتظر تصمیم شما'});
- const label=cardLabels[cardActions.indexOf(action)];
- fireEvent.click(await within(queue).findByRole('button',{name:label}));
- const dialog=await screen.findByRole('dialog');
- expect(within(dialog).getByRole('heading',{name:label})).toBeInTheDocument();
- expect(within(dialog).getByText('9')).toBeInTheDocument();
- expect(within(dialog).getByText('73')).toBeInTheDocument();
- expect(api.get).toHaveBeenCalledWith('/admin/orchestration/tasks/t1');
- expect(api.post).not.toHaveBeenCalled();expect(api.put).not.toHaveBeenCalled();
- fireEvent.click(within(dialog).getByRole('button',{name:'انصراف'}));
- expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
- expect(api.post).not.toHaveBeenCalled();expect(api.put).not.toHaveBeenCalled();
-});
-it.each(['missing','disabled','wrong-task','error'])('reports fresh card action failure: %s',async failure=>{
- vi.resetAllMocks();
- vi.mocked(api.get).mockImplementation(async url=>{
- if(url.endsWith('/overview'))return {data:{items:[],measuredAt:'now',capabilities:{mutations:true}}};
- if(url.endsWith('/tasks'))return {data:[{...task,availableActions:cardActions}]};
- if(failure==='error')throw new Error('offline detail');
- return {data:{...task,id:failure==='wrong-task'?'other':task.id,availableActions:failure==='missing'?['HOLD_GATE1']:[{id:'APPROVE_GATE1',disabledReason:'policy'}]}};
- });
- render();
- fireEvent.click(await within(screen.getByRole('region',{name:'منتظر تصمیم شما'})).findByRole('button',{name:cardLabels[0]}));
- expect(await screen.findByRole('alert')).toBeInTheDocument();
- expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
- expect(api.post).not.toHaveBeenCalled();expect(api.put).not.toHaveBeenCalled();
-});
-it('invalidates a delayed card decision on refresh',async()=>{
- vi.resetAllMocks();let resolve!:(value:{data:unknown})=>void;
- vi.mocked(api.get).mockImplementation(async url=>{
- if(url.endsWith('/overview'))return {data:{items:[],measuredAt:'now',capabilities:{mutations:true}}};
- if(url.endsWith('/tasks'))return {data:[{...task,availableActions:cardActions}]};
- return await new Promise<{data:unknown}>(r=>{resolve=r});
- });
- render();
- fireEvent.click(await within(screen.getByRole('region',{name:'منتظر تصمیم شما'})).findByRole('button',{name:cardLabels[0]}));
- expect(screen.getByRole('status')).toHaveTextContent('در حال');
- fireEvent.click(screen.getByRole('button',{name:'بازخوانی وضعیت از سرور'}));
- await act(async()=>resolve({data:{...task,availableActions:cardActions}}));
- await waitFor(()=>expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
- expect(api.post).not.toHaveBeenCalled();expect(api.put).not.toHaveBeenCalled();
-});
diff --git a/frontend/admin-panel/src/pages/OrchestrationCommandCenter.tsx b/frontend/admin-panel/src/pages/OrchestrationCommandCenter.tsx
deleted file mode 100644
index 83f19b31..00000000
--- a/frontend/admin-panel/src/pages/OrchestrationCommandCenter.tsx
+++ /dev/null
@@ -1,128 +0,0 @@
-import { useEffect, useState, useRef } from 'react';
-import Button from '../components/ui/Button';
-import EditorialRecoveryDialog from '../components/EditorialRecoveryDialog';
-import {editorialRecoveryRun} from '../services/orchestration';
-import RouterUsagePanel from '../components/RouterUsagePanel';
-import RuntimeReadPanel from '../components/RuntimeReadPanel';
-import CreateOrchestrationTask from '../components/CreateOrchestrationTask';
-import { orchestration, killLevels, actionBlockReason, commandFailure } from '../services/orchestration';
-import {label,actionLabel,Records} from '../components/OrchestrationPresentation';
-import type { Task, ServerAction, Resource, ResourceSnapshot, KillLevel, ChatMessage } from '../services/orchestration';
-const sections = ['نمای کلی','وظیفهها و تأییدها','اجراها و خروجیها','عاملها و دپارتمانها','مدلها و بودجهها','زمانبندیها','ممیزی و انتشارها','توقف اضطراری','مصرف و سهمیه 9router','اطلاعات اجرا و نشستها','گفتوگو'] as const;
-type Section = typeof sections[number];
-const resources:Partial> = {'ممیزی و انتشارها':'releases'};
-const unavailable:Partial> = {'عاملها و دپارتمانها':'فهرست عاملها به هویت و اتصال مورد اعتماد اجرا نیاز دارد. اطلاعات نمای ثبتشده را از بخش اطلاعات اجرا و نشستها ببینید؛ این اطلاعات سلامت زنده نیست.','مدلها و بودجهها':'قرارداد خواندن سیاست مدل در سرور پیادهسازی نشده است. سقف بودجه هر وظیفه در فهرست وظیفهها قابل مشاهده است.','زمانبندیها':'مسیر مدیریت زمانبندی در این نسخه پشتیبانی نمیشود؛ زمانبندی ساختگی نمایش داده نمیشود.'};
-const errorText=(e:unknown)=> {const status=(e as {response?:{status?:number}})?.response?.status;return status?`خطای سرور (HTTP ${status})`:e instanceof Error?e.message:'پاسخ سرور در دسترس نیست'};
-function Json({value}:{value:unknown}) {return ;}
-export default function OrchestrationCommandCenter() {
- const detailEpoch=useRef(0);
- const [recovery,setRecovery]=useState(null);
- const [section,setSection]=useState('نمای کلی');
- const [capabilities,setCapabilities]=useState({mutations:false,chat:false,runtime:false,killSwitch:false});
- const [tasks,setTasks]=useState([]);
- const [selected,setSelected]=useState(null);
- const [decisionLoading,setDecisionLoading]=useState(false);
- const [snapshot,setSnapshot]=useState(null);
- const [error,setError]=useState(''); const [loading,setLoading]=useState(false);
- const [search,setSearch]=useState('');
- const [decisionFilter,setDecisionFilter]=useState('ALL');
- const [pending,setPending]=useState<{task:Task;action:ServerAction;key:string}|null>(null);
- const [expires,setExpires]=useState(''); const [reason,setReason]=useState('');
- const [binding,setBinding]=useState(''); const [confirmed,setConfirmed]=useState(false);
- const [attempted,setAttempted]=useState(false); const [busy,setBusy]=useState(false); const [commandError,setCommandError]=useState('');
- const [success,setSuccess]=useState('');
- const [blocked,setBlocked]=useState(false);
- const [now,setNow]=useState(()=>Date.now());
- useEffect(()=>{const timer=setInterval(()=>setNow(Date.now()),1000);return ()=>clearInterval(timer)},[]);
- const [kill,setKill]=useState('FREEZE_NEW_WORK');
- const [session,setSession]=useState(''); const [message,setMessage]=useState('');
- const [messages,setMessages]=useState([]);
- const [chatKey,setChatKey]=useState(()=>crypto.randomUUID());
- const loadTasks=async()=> {setLoading(true);setError(''); try {setTasks(await orchestration.tasks())} catch(e){setTasks([]);setSelected(null);setError(errorText(e))} finally {setLoading(false)}};
- useEffect(()=>{void loadTasks(); orchestration.resource('overview').then(s=>setCapabilities({mutations:s.capabilities?.mutations===true,chat:s.capabilities?.chat===true,runtime:s.capabilities?.runtime===true,killSwitch:s.capabilities?.killSwitch===true})).catch(()=>setCapabilities({mutations:false,chat:false,runtime:false,killSwitch:false}));},[]);
- useEffect(()=> {
- const resource=resources[section]; setSnapshot(null);
- if(!resource)return;
- let active=true;setLoading(true);
- orchestration.resource(resource).then(data=>{if(active)setSnapshot(data)}).catch(e=>{if(active)setError(errorText(e))}).finally(()=>{if(active)setLoading(false)});
- return ()=>{active=false};
- },[section]);
- const select=async(task:Task)=>{const epoch=++detailEpoch.current;setDecisionLoading(false);setSelected(null);setError('');try {const detail=await orchestration.task(task.id);if(epoch===detailEpoch.current)setSelected(detail)}catch(e){if(epoch===detailEpoch.current)setError(errorText(e))}};
- const open=(task:Task,action:ServerAction)=>{if(!capabilities.mutations||actionBlockReason(task,action))return;setBlocked(false);setAttempted(false);setPending({task,action,key:crypto.randomUUID()});setExpires('');setReason('');setConfirmed(false);setBinding('');setCommandError('');setSuccess('')};
- const decide=async(task:Task,requested:ServerAction)=>{
- const epoch=++detailEpoch.current;
- setSelected(null);setPending(null);setError('');setSuccess('');setDecisionLoading(true);
- try {
- const detail=await orchestration.task(task.id);
- if(epoch!==detailEpoch.current)return;
- if(detail.id!==task.id)throw new Error('پاسخ جزئیات با وظیفه انتخابشده مطابقت ندارد');
- const action=detail.availableActions.find(a=>a.id===requested.id);
- if(!action)throw new Error('این اقدام دیگر توسط سرور مجاز نیست؛ وضعیت را بازخوانی کنید');
- const blockedReason=actionBlockReason(detail,action);
- if(blockedReason)throw new Error(blockedReason);
- if(!capabilities.mutations)throw new Error('تغییرات از طرف سرور مجاز نیست');
- setSelected(detail);open(detail,action);
- } catch(e) {if(epoch===detailEpoch.current)setError(errorText(e))}
- finally {if(epoch===detailEpoch.current)setDecisionLoading(false)}
- };
- const execute=async()=> {
- if(!pending||busy||!confirmed||blocked||!capabilities.mutations)return;
- setAttempted(true);setBusy(true);setCommandError('');
- try { const [runId,artifactHash]=binding.split('|');
- await orchestration.command(pending.task,pending.action,{idempotencyKey:pending.key,reason,notBefore:expires?new Date(expires).toISOString():undefined,runId,artifactHash});
- setPending(null);setSelected(null);setSuccess('فرمان توسط سرور پذیرفته شد؛ وضعیت مرجع بازخوانی شد.');await loadTasks();
- } catch(e) {const failure=commandFailure(e);setBlocked(!failure.retryable);setCommandError(failure.message)} finally {setBusy(false)}
- };
- const openRecovery=async(task:Task)=>{
- if(!capabilities.mutations||pending||recovery)return;
- const epoch=++detailEpoch.current;setDecisionLoading(true);setSelected(null);setError('');
- try{const detail=await orchestration.task(task.id);if(epoch!==detailEpoch.current)return;
- if(detail.id!==task.id||!editorialRecoveryRun(detail))throw new Error('بازیابی دیگر مجاز نیست؛ وضعیت را بازخوانی کنید');
- setRecovery(detail);
- }catch(e){if(epoch===detailEpoch.current)setError(errorText(e))}finally{if(epoch===detailEpoch.current)setDecisionLoading(false)}
- };
- const refresh=()=>{detailEpoch.current++;setDecisionLoading(false);setSelected(null);setPending(null);setRecovery(null);void loadTasks()};
- const filtered=tasks.filter(t=>(t.title+' '+t.department+' '+t.state).toLowerCase().includes(search.toLowerCase()));
- return <>
-
مرکز فرماندهی ارکستراسیون
مرجع عملیات سرور است · Gate1 برای کار محدود · Gate2 و انتشار غیرفعال هستند
-
- {unavailable[section]&&
این بخش در نسخه فعلی در دسترس نیست
{unavailable[section]}
برای این بخش درخواست ناموفق تکراری به سرور ارسال نمیشود.
}
- {(loading||decisionLoading)&&
در حال دریافت وضعیت از سرور…
}
- {error&&
دریافت اطلاعات از سرور ناموفق بود: {error}. داده جایگزین نمایش داده نمیشود.
}
- {success&&
{success}
}
- {section==='وظیفهها و تأییدها'&&capabilities.mutations&&void loadTasks()}/>}
- {section==='نمای کلی'&&
-
منتظر تصمیم شما
تصمیم Gate1 برای کار محدود؛ تأیید بهمعنای انتشار یا اجرای Production نیست. دکمهها فقط اقدامهای مجاز اعلامشده توسط سرور هستند؛ برای بررسی و تصمیم، جزئیات را باز کنید.
تأیید، وظیفه را در اولویت صف آماده قرار میدهد؛ زمان اختیاری فقط زودترین زمان شروع است و اجرای دقیق در آن لحظه تضمین نمیشود. حداکثر زمانبندی ۳۰ روز است؛ اعتبار تأیید را سرور مدیریت میکند.