{item.title??item.id}
- {Object.entries(item).filter(([k])=>k!=='id'&&k!=='title').map(([k,v])=>
- {k}
- {String(v??'Unknown')}
diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts
index b25f5f20..8f8bf7f7 100644
--- a/backend/src/app.module.ts
+++ b/backend/src/app.module.ts
@@ -1,3 +1,5 @@
+import { RouterUsageModule } from './router-usage/router-usage.module';
+import { HermesManagementModule } from './hermes-management/hermes-management.module';
import { TasksModule } from './common/services/tasks.module';
import { Module, NestModule, MiddlewareConsumer } from "@nestjs/common";
import { PrismaModule } from "./prisma/prisma.module";
@@ -43,6 +45,9 @@ import { Request, Response, NextFunction } from "express";
@Module({
imports: [
+ RouterUsageModule,
+ // Deny-all registration: no request identity or runtime credentials are accepted yet.
+ HermesManagementModule.register({origin:'http://canina-hermes:9119',token:async()=>''}),
OrchestrationModule,
SupportChatModule,
RevalidationModule,
diff --git a/backend/src/orchestration/orchestration-read.http.spec.ts b/backend/src/orchestration/orchestration-read.http.spec.ts
new file mode 100644
index 00000000..9d1537b6
--- /dev/null
+++ b/backend/src/orchestration/orchestration-read.http.spec.ts
@@ -0,0 +1,151 @@
+import { Test } from '@nestjs/testing';
+import { INestApplication } from '@nestjs/common';
+import request from 'supertest';
+import { OrchestrationController } from './orchestration.controller';
+import { OrchestrationService } from './orchestration.service';
+import { JwtAuthGuard } from '../auth/jwt-auth.guard';
+import { RolesGuard } from '../common/guards/roles.guard';
+
+describe('integration read boundary', () => {
+ let app: INestApplication;
+ const task = {
+ id: 't1',
+ key: 'k',
+ title: 'Review',
+ department: 'SEO',
+ state: 'GATE2_APPROVED',
+ version: 1,
+ operationMode: 'PREPARE',
+ budgetLimitCents: 0,
+ metadata: { token: 'secret' },
+ runs: [
+ {
+ id: 'r',
+ status: 'VERIFIED',
+ commitSha: 'abc',
+ environment: 'stage',
+ artifacts: [
+ {
+ id: 'a',
+ sha256: 'f'.repeat(64),
+ sizeBytes: 1n,
+ uri: 'secret-uri',
+ metadata: { token: 'secret' },
+ },
+ ],
+ },
+ ],
+ events: [
+ {
+ id: 'e',
+ eventType: 'CREATED',
+ sequence: 1,
+ payload: { token: 'secret' },
+ },
+ ],
+ };
+ const service = {
+ findAll: jest.fn(() => Promise.resolve([task])),
+ findOne: jest.fn(() => Promise.resolve(task)),
+ createTask: jest.fn(),
+ transition: jest.fn(),
+ decideGate: jest.fn(),
+ recordBudget: jest.fn(),
+ setKillSwitch: jest.fn(),
+ };
+ beforeAll(async () => {
+ const m = await Test.createTestingModule({
+ controllers: [OrchestrationController],
+ providers: [
+ { provide: OrchestrationService, useValue: service },
+ RolesGuard,
+ ],
+ })
+ .overrideGuard(JwtAuthGuard)
+ .useValue({
+ canActivate(c: any) {
+ const req = c.switchToHttp().getRequest();
+ if (!req.headers.authorization) return false;
+ req.user = { id: 'verified-user', role: req.headers.authorization };
+ return true;
+ },
+ })
+ .compile();
+ app = m.createNestApplication();
+ await app.init();
+ });
+ afterAll(async () => app.close());
+ it('denies every mutation before legacy core is invoked', async () => {
+ for (const [method, path] of [
+ ['post', 'tasks'],
+ ['put', 'tasks/t1/transition'],
+ ['post', 'tasks/t1/gates/2/decide'],
+ ['post', 'tasks/t1/budget'],
+ ['put', 'kill-switch'],
+ ['post', 'chat/messages'],
+ ] as const) {
+ await request(app.getHttpServer())
+ [method]('/admin/orchestration/' + path)
+ .set('Authorization', 'Admin')
+ .send({})
+ .expect(403);
+ }
+ for (const name of [
+ 'createTask',
+ 'transition',
+ 'decideGate',
+ 'recordBudget',
+ 'setKillSwitch',
+ ] as const)
+ expect(service[name]).not.toHaveBeenCalled();
+ });
+ it('projects list and detail with no actions, arbitrary secrets or BigInt transport failures', async () => {
+ for (const path of ['tasks', 'tasks/t1']) {
+ const r = await request(app.getHttpServer())
+ .get('/admin/orchestration/' + path)
+ .set('Authorization', 'Admin')
+ .expect(200);
+ const t = Array.isArray(r.body) ? r.body[0] : r.body;
+ expect(t.availableActions).toEqual([]);
+ expect(t.budgetLimitCents).toBe(0);
+ expect(JSON.stringify(t)).not.toMatch(/secret|sizeBytes|payload|token/);
+ }
+ });
+ it('returns actual inventory overview and explicit unavailable runtime resources', async () => {
+ const r = await request(app.getHttpServer())
+ .get('/admin/orchestration/overview')
+ .set('Authorization', 'Admin')
+ .expect(200);
+ expect(r.body.items).toEqual([
+ expect.objectContaining({ id: 'tasks', count: 1 }),
+ ]);
+ expect(r.body.capabilities).toMatchObject({
+ mutations: false,
+ chat: false,
+ runtime: false,
+ });
+ for (const path of ['agents', 'schedules', 'model-policy'])
+ await request(app.getHttpServer())
+ .get('/admin/orchestration/' + path)
+ .set('Authorization', 'Admin')
+ .expect(503);
+ const releases = await request(app.getHttpServer())
+ .get('/admin/orchestration/releases')
+ .set('Authorization', 'Admin')
+ .expect(200);
+ expect(releases.body.items[0]).toMatchObject({
+ id: 'r',
+ commitSha: 'abc',
+ environment: 'stage',
+ });
+ });
+ it('protects read surfaces from anonymous and customer access', async () => {
+ await request(app.getHttpServer())
+ .get('/admin/orchestration/overview')
+ .expect(403);
+ await request(app.getHttpServer())
+ .get('/admin/orchestration/tasks')
+ .set('Authorization', 'CUSTOMER')
+ .expect(403);
+ });
+});
diff --git a/backend/src/orchestration/orchestration.controller.ts b/backend/src/orchestration/orchestration.controller.ts
index b4fc03f3..223c756a 100644
--- a/backend/src/orchestration/orchestration.controller.ts
+++ b/backend/src/orchestration/orchestration.controller.ts
@@ -1,13 +1,147 @@
-import { Body, Controller, Get, Param, Post, Put, Req, UseGuards } from "@nestjs/common";
-import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";
-import { JwtAuthGuard } from "../auth/jwt-auth.guard"; import { RolesGuard } from "../common/guards/roles.guard"; import { Roles } from "../common/decorators/roles.decorator";
-import { CreateOrchestrationTaskDto, GateDecisionDto, RecordBudgetDto, SetKillSwitchDto, TransitionTaskDto } from "./dto/orchestration.dto"; import { OrchestrationService } from "./orchestration.service";
-@ApiTags("Admin - Orchestration v4") @ApiBearerAuth() @UseGuards(JwtAuthGuard,RolesGuard) @Roles("Admin","SUPER_ADMIN") @Controller("admin/orchestration")
-export class OrchestrationController { constructor(private readonly service:OrchestrationService){} private actor(req:any){return String(req.user?.id??req.user?.sub??"SYSTEM")}
- @Get("tasks") all(){return this.service.findAll()} @Get("tasks/:id") one(@Param("id")id:string){return this.service.findOne(id)}
- @Post("tasks") create(@Body()dto:CreateOrchestrationTaskDto,@Req()req:any){return this.service.createTask(dto,this.actor(req))}
- @Put("tasks/:id/transition") transition(@Param("id")id:string,@Body()dto:TransitionTaskDto,@Req()req:any){return this.service.transition(id,dto,this.actor(req))}
- @Post("tasks/:id/gates/:gate/decide") decide(@Param("id")id:string,@Param("gate")gate:string,@Body()dto:GateDecisionDto,@Req()req:any){if(gate!=="1"&&gate!=="2")throw new Error("gate must be 1 or 2");return this.service.decideGate(id,Number(gate) as 1|2,dto,this.actor(req))}
- @Post("tasks/:id/budget") budget(@Param("id")id:string,@Body()dto:RecordBudgetDto,@Req()req:any){return this.service.recordBudget(id,dto,this.actor(req))}
- @Put("kill-switch") kill(@Body()dto:SetKillSwitchDto,@Req()req:any){return this.service.setKillSwitch(dto.level,dto.reason,this.actor(req))}
+import {
+ Controller,
+ Get,
+ Param,
+ Post,
+ Put,
+ UseGuards,
+ ForbiddenException,
+ ServiceUnavailableException,
+} from '@nestjs/common';
+import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
+import { JwtAuthGuard } from '../auth/jwt-auth.guard';
+import { RolesGuard } from '../common/guards/roles.guard';
+import { Roles } from '../common/decorators/roles.decorator';
+import { OrchestrationService } from './orchestration.service';
+
+// Explicit response allowlists: never serialize arbitrary JSON, signatures, URIs or BigInt.
+function pick(row: any, keys: string[]) {
+ return Object.fromEntries(
+ keys.filter((k) => row[k] !== undefined).map((k) => [k, row[k]]),
+ );
+}
+function project(row: any) {
+ return {
+ ...pick(row, [
+ 'id',
+ 'key',
+ 'title',
+ 'department',
+ 'state',
+ 'version',
+ 'operationMode',
+ 'budgetLimitCents',
+ ]),
+ availableActions: [],
+ runs: (row.runs ?? []).map((run: any) => ({
+ ...pick(run, ['id', 'commitSha', 'environment', 'status']),
+ artifacts: (run.artifacts ?? []).map((a: any) =>
+ pick(a, ['id', 'kind', 'sha256']),
+ ),
+ })),
+ decisions: (row.decisions ?? []).map((d: any) =>
+ pick(d, [
+ 'id',
+ 'gate',
+ 'decision',
+ 'expiresAt',
+ 'runId',
+ 'artifactHash',
+ 'commitSha',
+ 'environment',
+ 'createdAt',
+ ]),
+ ),
+ events: (row.events ?? []).map((e: any) =>
+ pick(e, [
+ 'id',
+ 'eventType',
+ 'fromState',
+ 'toState',
+ 'sequence',
+ 'createdAt',
+ ]),
+ ),
+ budgetLedger: (row.budgetLedger ?? []).map((b: any) =>
+ pick(b, ['id', 'amountCents', 'kind', 'createdAt']),
+ ),
+ };
+}
+@ApiTags('Admin - Orchestration v4')
+@ApiBearerAuth()
+@UseGuards(JwtAuthGuard, RolesGuard)
+@Roles('Admin', 'SUPER_ADMIN')
+@Controller('admin/orchestration')
+export class OrchestrationController {
+ constructor(private readonly service: OrchestrationService) {}
+ @Get('tasks') async all() {
+ return (await this.service.findAll()).map(project);
+ }
+ @Get('tasks/:id') async one(@Param('id') id: string) {
+ return project(await this.service.findOne(id));
+ }
+ @Get('overview') async overview() {
+ const tasks = await this.service.findAll();
+ return {
+ items: [
+ { id: 'tasks', title: 'Persisted task inventory', count: tasks.length },
+ ],
+ measuredAt: new Date().toISOString(),
+ capabilities: { mutations: false, chat: false, runtime: false },
+ reason: 'security_hardening_pending',
+ };
+ }
+ @Get('releases') async releases() {
+ const tasks = await this.service.findAll();
+ const details = await Promise.all(
+ tasks.map((t: any) => this.service.findOne(t.id)),
+ );
+ return {
+ items: details.flatMap((t: any) =>
+ (t.runs ?? []).map((run: any) =>
+ pick(run, ['id', 'status', 'commitSha', 'environment']),
+ ),
+ ),
+ measuredAt: new Date().toISOString(),
+ };
+ }
+ @Get('agents') agents() {
+ throw new ServiceUnavailableException(
+ 'Hermes runtime unavailable: trusted identity and runtime authentication not configured',
+ );
+ }
+ @Get('schedules') schedules() {
+ throw new ServiceUnavailableException(
+ 'Hermes schedules unavailable; runtime remains disabled',
+ );
+ }
+ @Get('model-policy') models() {
+ throw new ServiceUnavailableException(
+ 'No persisted model policy read contract available',
+ );
+ }
+ // The committed legacy core is not safe to expose. No env switch or role may bypass this boundary.
+ @Post('tasks') create() {
+ return this.deny();
+ }
+ @Put('tasks/:id/transition') transition() {
+ return this.deny();
+ }
+ @Post('tasks/:id/gates/:gate/decide') decide() {
+ return this.deny();
+ }
+ @Post('tasks/:id/budget') budget() {
+ return this.deny();
+ }
+ @Put('kill-switch') kill() {
+ return this.deny();
+ }
+ @Post('chat/messages') chat() {
+ return this.deny();
+ }
+ private deny(): never {
+ throw new ForbiddenException(
+ 'Orchestration mutations and chat disabled pending hardened core and trusted runtime integration',
+ );
+ }
}
diff --git a/docs/orchestration-v4-integration-verification.md b/docs/orchestration-v4-integration-verification.md
new file mode 100644
index 00000000..b0c4a31c
--- /dev/null
+++ b/docs/orchestration-v4-integration-verification.md
@@ -0,0 +1,22 @@
+# Orchestration v4 read-only integration verification
+
+Base e5c83e87fe2d52d06eb36532fa9e354570678c43 plus cherry-picks admin a34c2a9, runtime bd58cc4, router b0f4636. Separate remote worktree; no dirty core edits, pushes, deploys, DB access or runtime changes.
+
+## RED → GREEN proof
+- New backend HTTP boundary suite initially failed 4/4: mutation returned 201, BigInt serialization returned 500, overview missing (404). After integration: 4/4 pass, covering all mutation routes, anonymous/customer rejection, secret projection, actual overview and unavailable resources.
+- New UI fail-closed capability test initially failed because Create bounded work was visible without authorization. After capability gating: 7/7 command-center tests pass. Existing explicit action/binding/retry tests retained.
+
+## Disposable remote validation
+Node 22 bookworm, network none, userns host (host Docker remapping prevents normal bind mounts), worktree source mounts, read-only sibling dependency cache. Vite cache directories are ephemeral tmpfs; no existing dependency trees changed.
+- Backend focused aggregate: **13 suites, 65 tests pass** (orchestration, Hermes, router usage).
+- Backend `tsc --noEmit`: exit 0. `npm run build`: exit 0.
+- Backend changed controller/HTTP spec ESLint: exit 0, 8 unsafe-argument warnings (7 test harness, 1 existing any-typed Prisma result). Baseline subsystem lint had 256 errors/8 warnings largely inherited formatting; no full lint pass claimed.
+- Admin focused aggregate: **5 files, 19 tests pass** (command center, orchestration/router adapters, creation, navigation).
+- Admin `npm run build`: exit 0, existing unresolved font warning remains.
+- Admin `tsc --noEmit -p tsconfig.app.json`: exit 2 with **33 inherited diagnostics** outside this change: legacy Approvals/Audit/HQ/Dashboard/ManagerActions/Tasks unused imports, Orders requiresRx missing, Symptoms ConfirmModal props/unused setter. No changed-file diagnostics. Full admin typecheck is NOT green.
+
+## Security/release blockers
+The committed legacy core permits gate-state bypass through generic transitions and lacks hardened replay/authorization/budget/kill-switch boundaries. It is retained unchanged for parent integration; every exposed v4 mutation is unconditionally denied by controller. Do not restore controller calls or enable execution until hardened core is merged and reverified.
+Runtime dashboard not listening per parent investigation; no fabricated health or live availability claim. No trusted runtime identity/profile policy or runtime auth configured. Chat, cron mutations, execution/event dispatch, release execution stay disabled. Read-only inventory still requires orchestration schema migration through approved CI/CD, never manual DB changes. Backend read queries are currently full inventory and release evidence uses per-task reads; pagination/scaling remains future work.
+
+Parent must inspect this commit and reconcile hardened core before any mutation milestone. No Stage promotion performed by this worker; admin typecheck failures remain explicit verification blockers for parent decision.
diff --git a/frontend/admin-panel/ORCHESTRATION_API_CONTRACT.md b/frontend/admin-panel/ORCHESTRATION_API_CONTRACT.md
index 87420bdd..f66d3746 100644
--- a/frontend/admin-panel/ORCHESTRATION_API_CONTRACT.md
+++ b/frontend/admin-panel/ORCHESTRATION_API_CONTRACT.md
@@ -1,3 +1,15 @@
+# Integration milestone: read-only v4
+
+This integration supersedes mutation/chat expectations below. All orchestration POST/PUT routes return 403 **before calling legacy services**, including task creation, transitions, gate decisions, budget writes, kill-switch and chat. No feature flag can enable them. `availableActions` is always `[]`. Do not enable mutation controls until hardened core is merged and independently verified.
+
+GET `/admin/orchestration/overview` returns `{items:[{id:"tasks",title:"Persisted task inventory",count:number}], measuredAt, capabilities:{mutations:false,chat:false,runtime:false},reason:"security_hardening_pending"}`. The timestamp describes this DB inventory observation, not runtime health. Frontend capability fetch defaults to all false on failure or missing fields.
+
+GET tasks and detail use explicit allowlists: task identity/state/version/mode/budget; run identity/status/commit/environment; artifact identity/kind/hash; decision identity/gate/decision/expiry/bindings; event identity/type/states/sequence/time; ledger identity/amount/kind/time. Arbitrary metadata, notes, event payloads, artifact URI/signature and BigInt size are not exposed. Scope/acceptance metadata remains withheld pending a reviewed structured schema.
+
+GET `/releases` is persisted run evidence only, not a claim of release authorization or deployment. GET `/agents`, `/schedules`, `/model-policy` return 503 with explicit unavailable reasons: there are no trusted runtime identity/auth or persisted model policy read contracts. HermesManagementModule is registered deny-all with an empty token and no HTTP controllers; no runtime calls or cron changes occur. RouterUsageModule is registered with its admin-protected read-only endpoint and returns unavailable when credentials are absent. No new secrets are configured.
+
+## Historical component contract (mutation proposals disabled)
+
# Admin orchestration v4 adapter contract
All client traffic uses existing authenticated Axios client (`src/services/api.ts`). Relative `/admin/...` paths are served below `/api`. No runtime secrets, Hermes tokens, PTY, terminal websocket or direct gateway credentials may enter these DTOs. Backend must project/redact task metadata, artifacts, audit payloads and chat text before returning them. Browser does not enforce authorization.
diff --git a/frontend/admin-panel/src/pages/OrchestrationCommandCenter.test.tsx b/frontend/admin-panel/src/pages/OrchestrationCommandCenter.test.tsx
index 741af75f..01f196a4 100644
--- a/frontend/admin-panel/src/pages/OrchestrationCommandCenter.test.tsx
+++ b/frontend/admin-panel/src/pages/OrchestrationCommandCenter.test.tsx
@@ -6,6 +6,7 @@ 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,chat:true,runtime:false}}};
if(url.endsWith('/tasks')) return {data:[task]};
if(url.endsWith('/tasks/t1')) return {data:task};
throw new Error('Unavailable: '+url);
@@ -92,4 +93,16 @@ describe('command center', () => {
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(
{JSON.stringify(value,null,2)}}
export default function OrchestrationCommandCenter() {
const [section,setSection]=useStateLoading measured backend state…
} {error&&Unknown / unavailable: {error}. No fallback data.
} {success&&{success}
} - {section==='Tasks & approvals'&&{tasks.length} tasks returned by backend. This is inventory, not agent health or runtime telemetry.
No tasks returned by backend.
} @@ -65,9 +66,11 @@ export default function OrchestrationCommandCenter() {Measured at: {snapshot.measuredAt}
{!snapshot.items.length&&No records returned by backend.
}Configuration mutations require backend-advertised commands; none are inferred by this client.
Applies globally, not only to selected task. No implicit resume. Current active level: unknown until backend returns state.
Freeze new work → stop agents → disable mutations → emergency halt.
Mutation controls unavailable: backend security hardening pending.
} + {section==='Kill switch'&&capabilities.mutations&&Applies globally, not only to selected task. No implicit resume. Current active level: unknown until backend returns state.
Freeze new work → stop agents → disable mutations → emergency halt.
Advisory text only. No terminal, PTY, runtime token, or direct Hermes connection. Decisions use explicit approval controls.
{m.role}: {m.content}
)}Chat unsupported: trusted runtime bridge unavailable.
} + {section==='Chat'&&capabilities.chat&&Advisory text only. No terminal, PTY, runtime token, or direct Hermes connection. Decisions use explicit approval controls.
{m.role}: {m.content}
)}