4 Commits

Author SHA1 Message Date
Hartmut 5d6ca3d8cc ci: retrigger — unit-tests flake on run 159 (setup-node .gitignore issue)
CI / Architecture Guardrails (pull_request) Successful in 3m4s
CI / Lint (pull_request) Successful in 3m40s
CI / Typecheck (pull_request) Successful in 3m45s
CI / Assistant Split Regression (pull_request) Successful in 4m3s
CI / Unit Tests (pull_request) Successful in 6m31s
CI / Build (pull_request) Successful in 5m58s
CI / E2E Tests (pull_request) Successful in 4m48s
CI / Fresh-Linux Docker Deploy (pull_request) Successful in 5m4s
CI / Release Images (pull_request) Has been skipped
2026-05-21 19:51:47 +02:00
Hartmut db7948d279 fix(ci): add --profile full to teardown so app container on port 3100 is stopped
CI / Architecture Guardrails (pull_request) Successful in 2m46s
CI / Lint (pull_request) Successful in 3m14s
CI / Typecheck (pull_request) Successful in 3m28s
CI / Assistant Split Regression (pull_request) Successful in 3m56s
CI / Unit Tests (pull_request) Failing after 1m36s
CI / Build (pull_request) Successful in 4m8s
CI / E2E Tests (pull_request) Successful in 4m30s
CI / Fresh-Linux Docker Deploy (pull_request) Successful in 5m25s
CI / Release Images (pull_request) Has been skipped
The app service is declared under the 'full' profile. Without --profile full,
docker compose down skips it — leaving nexus-app-1 (or capakraken-app-1)
running and holding port 3100, which causes the next run to fail with
"Bind for 0.0.0.0:3100 failed: port is already allocated".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 19:38:03 +02:00
Hartmut 7cee3b3a97 fix(ci): tear down legacy capakraken compose project before Docker Deploy
CI / Architecture Guardrails (pull_request) Successful in 2m54s
CI / Lint (pull_request) Successful in 3m17s
CI / Typecheck (pull_request) Successful in 3m29s
CI / Assistant Split Regression (pull_request) Successful in 3m48s
CI / Unit Tests (pull_request) Successful in 6m0s
CI / Build (pull_request) Successful in 5m31s
CI / Fresh-Linux Docker Deploy (pull_request) Failing after 4m5s
CI / E2E Tests (pull_request) Successful in 5m23s
CI / Release Images (pull_request) Has been skipped
After the Phase 3 rename the project name flipped from 'capakraken' to 'nexus'.
The QNAP runner may still have capakraken-redis-1 running (holding port 6380).
The down step only cleaned up the 'nexus' project, leaving the old container
alive and causing "Bind for 0.0.0.0:6380 failed: port is already allocated".

Add an explicit `docker compose -p capakraken ... down` before the normal
cleanup so stale pre-rename containers are always removed first.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 17:23:34 +02:00
Hartmut 01f8974314 rename(phase 3): compose/DB/infra names + stray code refs capakraken → nexus
CI / Architecture Guardrails (pull_request) Successful in 2m59s
CI / Typecheck (pull_request) Successful in 6m41s
CI / Lint (pull_request) Successful in 4m18s
CI / Assistant Split Regression (pull_request) Successful in 5m6s
CI / Unit Tests (pull_request) Successful in 7m21s
CI / Build (pull_request) Successful in 5m21s
CI / Fresh-Linux Docker Deploy (pull_request) Failing after 38s
CI / E2E Tests (pull_request) Successful in 3m28s
CI / Release Images (pull_request) Has been skipped
- docker-compose.yml / .prod.yml / .ci.yml: project names, POSTGRES_DB/USER,
  pg_isready, DATABASE_URL, volume names (nexus_pgdata, nexus_prod_*)
- .github/workflows/ci.yml: POSTGRES_PASSWORD, pg_isready, psql credentials,
  GRANT statements, POSTGRES_PASSWORD=nexus_dev for Docker Deploy job
- scripts/db-target-guard.mjs: expectedDatabase default, NEXUS_EXPECTED_DB_NAME
- scripts/prisma-with-env.mjs, e2e/test-server.mjs: env-var rename
- packages/db/src/safe-destructive-env.ts + reset-dispo-import.ts: DB name set
- packages/db/src/destructive-db-guard.ts: PROTECTED_DATABASE_NAMES → "nexus"
- packages/db/src/destructive-db-guard.test.ts: all fixture DB names + comments
- .env.example, tooling/deploy/deploy.env.example: DATABASE_URL, image refs
- packages/api: Redis channel/key prefixes (rbac-invalidate, sse, ratelimit),
  logger service name, app-base-url log prefix
- E2E: DB container names, localStorage/sessionStorage keys, email domains
- scripts: architecture-guardrails filter, export/import-dev-seed defaults,
  harden-postgres defaults, start.sh pg_isready, worktree-hygiene fixture
- tooling/migrate/rename-to-nexus.sh: new maintenance-window cutover script

Only intentional capakraken survivor: anonymization.ts DEFAULT_ANONYMIZATION_SEED
(functional cryptographic constant — changing it would invalidate stored aliases).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 16:35:39 +02:00
14 changed files with 61 additions and 206 deletions
+1 -61
View File
@@ -43,14 +43,6 @@ jobs:
with: with:
node-version: ${{ env.NODE_VERSION }} node-version: ${{ env.NODE_VERSION }}
- name: Cache pnpm store
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
@@ -85,14 +77,6 @@ jobs:
with: with:
node-version: ${{ env.NODE_VERSION }} node-version: ${{ env.NODE_VERSION }}
- name: Cache pnpm store
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
@@ -123,14 +107,6 @@ jobs:
with: with:
node-version: ${{ env.NODE_VERSION }} node-version: ${{ env.NODE_VERSION }}
- name: Cache pnpm store
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
@@ -156,14 +132,6 @@ jobs:
with: with:
node-version: ${{ env.NODE_VERSION }} node-version: ${{ env.NODE_VERSION }}
- name: Cache pnpm store
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
@@ -228,14 +196,6 @@ jobs:
with: with:
node-version: ${{ env.NODE_VERSION }} node-version: ${{ env.NODE_VERSION }}
- name: Cache pnpm store
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
@@ -291,14 +251,6 @@ jobs:
with: with:
node-version: ${{ env.NODE_VERSION }} node-version: ${{ env.NODE_VERSION }}
- name: Cache pnpm store
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
@@ -395,14 +347,6 @@ jobs:
with: with:
node-version: ${{ env.NODE_VERSION }} node-version: ${{ env.NODE_VERSION }}
- name: Cache pnpm store
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
@@ -549,10 +493,6 @@ jobs:
sleep 3 sleep 3
done done
- name: Pre-pull Docker base image
run: docker pull node:20-bookworm-slim
continue-on-error: true
- name: Build and start app (full profile) - name: Build and start app (full profile)
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml --profile full up -d --build app run: docker compose -f docker-compose.yml -f docker-compose.ci.yml --profile full up -d --build app
@@ -569,7 +509,7 @@ jobs:
# the act_runner job can reach). No DNS, no guessing. # the act_runner job can reach). No DNS, no guessing.
run: | run: |
set -e set -e
for i in $(seq 1 60); do for i in $(seq 1 36); do
CID=$(docker compose -f docker-compose.yml -f docker-compose.ci.yml ps -q app || true) CID=$(docker compose -f docker-compose.yml -f docker-compose.ci.yml ps -q app || true)
if [ -n "$CID" ]; then if [ -n "$CID" ]; then
APP_IP=$(docker inspect -f '{{range $k,$v := .NetworkSettings.Networks}}{{if eq $k "gitea_gitea"}}{{$v.IPAddress}}{{end}}{{end}}' "$CID") APP_IP=$(docker inspect -f '{{range $k,$v := .NetworkSettings.Networks}}{{if eq $k "gitea_gitea"}}{{$v.IPAddress}}{{end}}{{end}}' "$CID")
+1 -1
View File
@@ -24,6 +24,6 @@ export default defineConfig({
command: "node ./e2e/test-server.mjs", command: "node ./e2e/test-server.mjs",
url: e2eBaseUrl, url: e2eBaseUrl,
reuseExistingServer: false, reuseExistingServer: false,
timeout: 300000, timeout: 180000,
}, },
}); });
@@ -82,7 +82,7 @@ describe("GET /api/cron/auth-anomaly-check — cron secret enforcement", () => {
const { GET } = await importRoute(); const { GET } = await importRoute();
const res = await GET(makeRequest()); const res = await GET(makeRequest());
expect(res.status).toBe(401); expect(res.status).toBe(401);
}, 15_000); // next/server cold-import can take >5s on the act runner });
it("proceeds when verifyCronSecret returns null (allowed)", async () => { it("proceeds when verifyCronSecret returns null (allowed)", async () => {
verifyCronSecretMock.mockReturnValue(null); verifyCronSecretMock.mockReturnValue(null);
+2 -2
View File
@@ -450,7 +450,7 @@ function SidebarContent({
{!sidebarCollapsed && ( {!sidebarCollapsed && (
<div className="overflow-hidden"> <div className="overflow-hidden">
<h1 className="font-display text-xl font-semibold text-gray-900 dark:text-gray-50"> <h1 className="font-display text-xl font-semibold text-gray-900 dark:text-gray-50">
Nex<span className="text-brand-600">us</span> Capa<span className="text-brand-600">Kraken</span>
</h1> </h1>
<p className="text-xs uppercase tracking-[0.18em] text-gray-500 dark:text-gray-400"> <p className="text-xs uppercase tracking-[0.18em] text-gray-500 dark:text-gray-400">
Resource & Capacity Planning Resource & Capacity Planning
@@ -984,7 +984,7 @@ export function AppShell({
<HamburgerIcon /> <HamburgerIcon />
</button> </button>
<span className="ml-3 font-display text-sm font-semibold text-gray-900 dark:text-gray-50"> <span className="ml-3 font-display text-sm font-semibold text-gray-900 dark:text-gray-50">
Nex<span className="text-brand-600">us</span> Capa<span className="text-brand-600">Kraken</span>
</span> </span>
</div> </div>
<PageTransition>{children}</PageTransition> <PageTransition>{children}</PageTransition>
@@ -284,7 +284,7 @@ export function TimelineProvider({
const d = new Date(sp); const d = new Date(sp);
if (!isNaN(d.getTime())) return d; if (!isNaN(d.getTime())) return d;
} }
return addDays(today, -90); return addDays(today, -30);
}); });
const [viewDays, setViewDays] = useState(() => { const [viewDays, setViewDays] = useState(() => {
const sp = searchParams.get("days"); const sp = searchParams.get("days");
@@ -310,7 +310,7 @@ export function TimelineProvider({
const d = new Date(spStart); const d = new Date(spStart);
if (!isNaN(d.getTime())) return d; if (!isNaN(d.getTime())) return d;
} }
return addDays(today, -90); return addDays(today, -30);
}); });
const spDays = searchParams.get("days"); const spDays = searchParams.get("days");
@@ -2,7 +2,7 @@
import { clsx } from "clsx"; import { clsx } from "clsx";
import { useSession } from "next-auth/react"; import { useSession } from "next-auth/react";
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useAllocationHistory } from "~/hooks/useAllocationHistory.js"; import { useAllocationHistory } from "~/hooks/useAllocationHistory.js";
import { useProjectDragContext } from "~/hooks/useProjectDragContext.js"; import { useProjectDragContext } from "~/hooks/useProjectDragContext.js";
import { useTimelineDrag } from "~/hooks/useTimelineDrag.js"; import { useTimelineDrag } from "~/hooks/useTimelineDrag.js";
@@ -685,70 +685,15 @@ function TimelineViewContent({
const scrollRafRef = useRef<number | null>(null); const scrollRafRef = useRef<number | null>(null);
const [scrollLeft, setScrollLeft] = useState(0); const [scrollLeft, setScrollLeft] = useState(0);
// Pixels to add to scrollLeft after a left-extension re-render (prevents jump).
const pendingLeftCompensationPx = useRef(0);
// Flag: scroll viewport to today after the next viewStart-driven re-layout.
const pendingScrollToTodayRef = useRef(false);
// Guard reset on every real unmount (including Strict Mode fake-unmount) so the
// scroll-to-today fires correctly on remount.
const hasScrolledToTodayOnLoad = useRef(false);
useLayoutEffect(() => {
return () => {
hasScrolledToTodayOnLoad.current = false;
};
}, []);
// Scroll to today the first time the canvas is in the DOM (isInitialLoading → false).
// totalCanvasWidth is non-zero before data loads, so it can't be used as the trigger.
useLayoutEffect(() => {
if (isInitialLoading) return;
if (hasScrolledToTodayOnLoad.current) return;
const el = scrollContainerRef.current;
if (!el) return;
el.scrollLeft = toLeft(today);
hasScrolledToTodayOnLoad.current = true;
}, [isInitialLoading, toLeft, today]);
// Apply scroll compensation synchronously after the canvas grows (left-extend or Today button).
useLayoutEffect(() => {
const el = scrollContainerRef.current;
if (!el) return;
const px = pendingLeftCompensationPx.current;
if (px !== 0) {
el.scrollLeft += px;
pendingLeftCompensationPx.current = 0;
} else if (pendingScrollToTodayRef.current) {
el.scrollLeft = toLeft(today);
pendingScrollToTodayRef.current = false;
}
}, [viewStart, toLeft, today]);
// 5-year floor — no practical data exists further back; prevents runaway growth.
const minDate = useMemo(() => addDays(today, -(365 * 5)), [today]);
// ─── Navigation callbacks for TimelineToolbar ──────────────────────────── // ─── Navigation callbacks for TimelineToolbar ────────────────────────────
const handleNavigateBack = useCallback( const handleNavigateBack = useCallback(
() => () => setViewStart((v) => addDays(v, -28)),
setViewStart((v) => { [setViewStart],
const candidate = addDays(v, -28); );
return candidate < minDate ? minDate : candidate; const handleNavigateToday = useCallback(
}), () => setViewStart(addDays(today, -30)),
[setViewStart, minDate], [setViewStart, today],
); );
const handleNavigateToday = useCallback(() => {
const el = scrollContainerRef.current;
const todayMs = new Date(today).setHours(0, 0, 0, 0);
const vsMs = new Date(viewStart).setHours(0, 0, 0, 0);
const veMs = new Date(addDays(viewStart, viewDays)).setHours(0, 0, 0, 0);
if (todayMs >= vsMs && todayMs < veMs && el) {
// Today is in range — just scroll without touching state.
el.scrollLeft = toLeft(today);
} else {
// Today is out of range — reset the window and schedule a scroll.
pendingScrollToTodayRef.current = true;
setViewStart(addDays(today, -90));
}
}, [today, viewStart, viewDays, toLeft, setViewStart]);
const handleNavigateForward = useCallback( const handleNavigateForward = useCallback(
() => setViewStart((v) => addDays(v, 28)), () => setViewStart((v) => addDays(v, 28)),
[setViewStart], [setViewStart],
@@ -764,31 +709,10 @@ function TimelineViewContent({
const handleContainerScroll = useCallback(() => { const handleContainerScroll = useCallback(() => {
const el = scrollContainerRef.current; const el = scrollContainerRef.current;
if (!el) return; if (!el) return;
// Right-edge: extend future range
const distanceFromRight = el.scrollWidth - el.scrollLeft - el.clientWidth; const distanceFromRight = el.scrollWidth - el.scrollLeft - el.clientWidth;
if (distanceFromRight < CELL_WIDTH * 40) { if (distanceFromRight < CELL_WIDTH * 40) {
setViewDays((d) => d + 120); setViewDays((d) => d + 120);
} }
// Left-edge: prepend past range and compensate scroll position so viewport doesn't jump
if (el.scrollLeft < CELL_WIDTH * 40 && viewStart > minDate) {
const daysToPrepend = 120;
// Count the exact visible days (respecting showWeekends) being prepended
let prependedVisible = 0;
for (let i = 1; i <= daysToPrepend; i++) {
const d = addDays(viewStart, -i);
const dow = d.getDay();
if (filters.showWeekends || (dow !== 0 && dow !== 6)) prependedVisible++;
}
pendingLeftCompensationPx.current = prependedVisible * CELL_WIDTH;
setViewStart((v) => {
const candidate = addDays(v, -daysToPrepend);
return candidate < minDate ? minDate : candidate;
});
setViewDays((d) => d + daysToPrepend);
}
scrollLeftRef.current = el.scrollLeft; scrollLeftRef.current = el.scrollLeft;
if (scrollRafRef.current === null) { if (scrollRafRef.current === null) {
scrollRafRef.current = requestAnimationFrame(() => { scrollRafRef.current = requestAnimationFrame(() => {
@@ -796,7 +720,7 @@ function TimelineViewContent({
setScrollLeft(scrollLeftRef.current); setScrollLeft(scrollLeftRef.current);
}); });
} }
}, [CELL_WIDTH, setViewDays, viewStart, minDate, setViewStart, filters.showWeekends]); }, [CELL_WIDTH, setViewDays]);
// ─── Canvas mousemove — only forwards event when drag overlay is active ─── // ─── Canvas mousemove — only forwards event when drag overlay is active ───
const handleMouseMove = useCallback( const handleMouseMove = useCallback(
+4 -4
View File
@@ -1,5 +1,5 @@
# Nexus nginx Security Hardening # CapaKraken nginx Security Hardening
# Apply to the server block for nexus.hartmut-noerenberg.com # Apply to the server block for capakraken.hartmut-noerenberg.com
# #
# References: # References:
# - EAPPS 3.3.1.3.04 (Server Header entfernen) # - EAPPS 3.3.1.3.04 (Server Header entfernen)
@@ -113,5 +113,5 @@ log_format security '$remote_addr - $remote_user [$time_local] '
'"$http_referer" "$http_user_agent" ' '"$http_referer" "$http_user_agent" '
'$request_time $upstream_response_time'; '$request_time $upstream_response_time';
access_log /var/log/nginx/nexus_access.log security; access_log /var/log/nginx/capakraken_access.log security;
error_log /var/log/nginx/nexus_error.log warn; error_log /var/log/nginx/capakraken_error.log warn;
@@ -7,14 +7,12 @@ vi.mock("../lib/audit.js", () => ({
vi.mock("../router/assistant-approvals.js", () => ({ vi.mock("../router/assistant-approvals.js", () => ({
clearPendingAssistantApproval: vi.fn().mockResolvedValue(undefined), clearPendingAssistantApproval: vi.fn().mockResolvedValue(undefined),
consumePendingAssistantApproval: vi.fn(), consumePendingAssistantApproval: vi.fn(),
toApprovalPayload: vi.fn( toApprovalPayload: vi.fn((approval: { id: string; toolName: string; summary: string }, status: string) => ({
(approval: { id: string; toolName: string; summary: string }, status: string) => ({ id: approval.id,
id: approval.id, toolName: approval.toolName,
toolName: approval.toolName, summary: approval.summary,
summary: approval.summary, status,
status, })),
}),
),
})); }));
vi.mock("../router/assistant-confirmation.js", () => ({ vi.mock("../router/assistant-confirmation.js", () => ({
@@ -41,10 +39,16 @@ import {
clearPendingAssistantApproval, clearPendingAssistantApproval,
consumePendingAssistantApproval, consumePendingAssistantApproval,
} from "../router/assistant-approvals.js"; } from "../router/assistant-approvals.js";
import { canExecuteMutationTool, isCancellationReply } from "../router/assistant-confirmation.js"; import {
canExecuteMutationTool,
isCancellationReply,
} from "../router/assistant-confirmation.js";
import { buildAssistantInsight } from "../router/assistant-insights.js"; import { buildAssistantInsight } from "../router/assistant-insights.js";
import { handlePendingAssistantApproval } from "../router/assistant-chat-response.js"; import { handlePendingAssistantApproval } from "../router/assistant-chat-response.js";
import { readToolError, readToolSuccessMessage } from "../router/assistant-tool-results.js"; import {
readToolError,
readToolSuccessMessage,
} from "../router/assistant-tool-results.js";
import { executeTool } from "../router/assistant-tools.js"; import { executeTool } from "../router/assistant-tools.js";
function createPendingApproval() { function createPendingApproval() {
@@ -53,16 +57,14 @@ function createPendingApproval() {
userId: "user_1", userId: "user_1",
conversationId: "conv_1", conversationId: "conv_1",
toolName: "create_project", toolName: "create_project",
toolArguments: '{"name":"Apollo"}', toolArguments: "{\"name\":\"Apollo\"}",
summary: "create project (name=Apollo)", summary: "create project (name=Apollo)",
createdAt: Date.now(), createdAt: Date.now(),
expiresAt: Date.now() + 60_000, expiresAt: Date.now() + 60_000,
}; };
} }
function createHandleInput( function createHandleInput(overrides: Partial<Parameters<typeof handlePendingAssistantApproval>[0]> = {}) {
overrides: Partial<Parameters<typeof handlePendingAssistantApproval>[0]> = {},
) {
return { return {
db: {} as never, db: {} as never,
dbUserId: "user_1", dbUserId: "user_1",
@@ -79,10 +81,7 @@ function createHandleInput(
pendingApproval: createPendingApproval(), pendingApproval: createPendingApproval(),
lastUserMessage: { role: "user" as const, content: "ja" }, lastUserMessage: { role: "user" as const, content: "ja" },
messages: [ messages: [
{ { role: "assistant" as const, content: "__CAPAKRAKEN_CONFIRM__ create project (name=Apollo). Bitte bestätigen." },
role: "assistant" as const,
content: "__NEXUS_CONFIRM__ create project (name=Apollo). Bitte bestätigen.",
},
{ role: "user" as const, content: "ja" }, { role: "user" as const, content: "ja" },
], ],
collectedActions: [], collectedActions: [],
@@ -104,11 +103,9 @@ describe("assistant pending approval handling", () => {
it("cancels pending approvals when the user aborts", async () => { it("cancels pending approvals when the user aborts", async () => {
vi.mocked(isCancellationReply).mockReturnValue(true); vi.mocked(isCancellationReply).mockReturnValue(true);
const result = await handlePendingAssistantApproval( const result = await handlePendingAssistantApproval(createHandleInput({
createHandleInput({ lastUserMessage: { role: "user", content: "nein, abbrechen" },
lastUserMessage: { role: "user", content: "nein, abbrechen" }, }));
}),
);
expect(result).toMatchObject({ expect(result).toMatchObject({
response: { response: {
@@ -130,7 +127,7 @@ describe("assistant pending approval handling", () => {
summary: "create project (name=Apollo, status=DRAFT)", summary: "create project (name=Apollo, status=DRAFT)",
} as never); } as never);
vi.mocked(executeTool).mockResolvedValue({ vi.mocked(executeTool).mockResolvedValue({
content: '{"message":"Projekt Apollo angelegt"}', content: "{\"message\":\"Projekt Apollo angelegt\"}",
data: { message: "Projekt Apollo angelegt" }, data: { message: "Projekt Apollo angelegt" },
action: { type: "refresh" }, action: { type: "refresh" },
} as never); } as never);
@@ -151,35 +148,29 @@ describe("assistant pending approval handling", () => {
status: "approved", status: "approved",
}, },
actions: [{ type: "refresh" }], actions: [{ type: "refresh" }],
insights: [ insights: [{
{ kind: "holiday_region",
kind: "holiday_region", title: "Berlin",
title: "Berlin", }],
},
],
}, },
}); });
expect(executeTool).toHaveBeenCalledWith( expect(executeTool).toHaveBeenCalledWith(
"create_project", "create_project",
'{"name":"Apollo"}', "{\"name\":\"Apollo\"}",
expect.objectContaining({ userId: "user_1" }), expect.objectContaining({ userId: "user_1" }),
); );
expect(createAuditEntry).toHaveBeenCalledWith( expect(createAuditEntry).toHaveBeenCalledWith(expect.objectContaining({
expect.objectContaining({ entityName: "create_project",
entityName: "create_project", summary: "AI executed previously approved tool: create_project",
summary: "AI executed previously approved tool: create_project", }));
}),
);
}); });
it("does nothing when the user reply is not a valid confirmation", async () => { it("does nothing when the user reply is not a valid confirmation", async () => {
vi.mocked(canExecuteMutationTool).mockReturnValue(false); vi.mocked(canExecuteMutationTool).mockReturnValue(false);
const result = await handlePendingAssistantApproval( const result = await handlePendingAssistantApproval(createHandleInput({
createHandleInput({ lastUserMessage: { role: "user", content: "vielleicht" },
lastUserMessage: { role: "user", content: "vielleicht" }, }));
}),
);
expect(result).toBeNull(); expect(result).toBeNull();
expect(consumePendingAssistantApproval).not.toHaveBeenCalled(); expect(consumePendingAssistantApproval).not.toHaveBeenCalled();
+1 -1
View File
@@ -1,4 +1,4 @@
// Nexus — Prisma Schema // CapaKraken — Prisma Schema
// All monetary values stored as integer cents to avoid float precision issues. // All monetary values stored as integer cents to avoid float precision issues.
generator client { generator client {
+1 -1
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# restart.sh — Rebuild the Nexus app container from scratch. # restart.sh — Rebuild the CapaKraken app container from scratch.
# #
# When to use: # When to use:
# - After changing pnpm-lock.yaml (new/removed dependencies) # - After changing pnpm-lock.yaml (new/removed dependencies)
+1 -1
View File
@@ -2,7 +2,7 @@
set -euo pipefail set -euo pipefail
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
echo "Restarting Nexus..." echo "Restarting CapaKraken..."
echo "" echo ""
# Stop # Stop
+2 -2
View File
@@ -5,7 +5,7 @@ cd "$(dirname "$0")/.."
APP_PORT="${APP_PORT:-3100}" APP_PORT="${APP_PORT:-3100}"
APP_CONTAINER="${APP_CONTAINER:-$(docker compose --profile full ps -q app 2>/dev/null | head -1)}" APP_CONTAINER="${APP_CONTAINER:-$(docker compose --profile full ps -q app 2>/dev/null | head -1)}"
echo "Starting Nexus..." echo "Starting CapaKraken..."
# 1. Start Docker services # 1. Start Docker services
echo " Starting PostgreSQL + Redis..." echo " Starting PostgreSQL + Redis..."
@@ -34,7 +34,7 @@ echo " Waiting for server (up to 90s)..."
for i in {1..90}; do for i in {1..90}; do
if curl -sf "http://localhost:${APP_PORT}/api/health" > /dev/null 2>&1; then if curl -sf "http://localhost:${APP_PORT}/api/health" > /dev/null 2>&1; then
echo "" echo ""
echo "Nexus is running!" echo "CapaKraken is running!"
curl -s "http://localhost:${APP_PORT}/api/ready" | python3 -m json.tool 2>/dev/null || curl -s "http://localhost:${APP_PORT}/api/ready" curl -s "http://localhost:${APP_PORT}/api/ready" | python3 -m json.tool 2>/dev/null || curl -s "http://localhost:${APP_PORT}/api/ready"
echo "" echo ""
echo " URL: http://localhost:${APP_PORT}" echo " URL: http://localhost:${APP_PORT}"
+2 -2
View File
@@ -2,7 +2,7 @@
set -euo pipefail set -euo pipefail
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
echo "Stopping Nexus..." echo "Stopping CapaKraken..."
# 1. Stop any legacy local dev server # 1. Stop any legacy local dev server
if [ -f /tmp/nexus-dev.pid ]; then if [ -f /tmp/nexus-dev.pid ]; then
@@ -28,4 +28,4 @@ echo " Stopping app, PostgreSQL and Redis..."
docker compose --profile full stop app postgres redis 2>/dev/null || true docker compose --profile full stop app postgres redis 2>/dev/null || true
echo "" echo ""
echo "Nexus stopped." echo "CapaKraken stopped."
+2 -2
View File
@@ -63,7 +63,7 @@ docker compose -p "$OLD_PROJECT" -f "$COMPOSE_FILE" stop app 2>/dev/null || true
echo "[2/7] Capturing pre-rename row counts..." echo "[2/7] Capturing pre-rename row counts..."
PRE_COUNTS=$(docker compose -p "$OLD_PROJECT" -f "$COMPOSE_FILE" exec -T postgres \ PRE_COUNTS=$(docker compose -p "$OLD_PROJECT" -f "$COMPOSE_FILE" exec -T postgres \
psql -U capakraken -d capakraken -t -c \ psql -U capakraken -d capakraken -t -c \
"SELECT relname, n_live_tup FROM pg_stat_user_tables ORDER BY relname;") "SELECT table_name, n_live_tup FROM pg_stat_user_tables ORDER BY table_name;")
echo "$PRE_COUNTS" | head -20 echo "$PRE_COUNTS" | head -20
echo "..." echo "..."
@@ -149,7 +149,7 @@ sleep 15
echo "=== Verification ===" echo "=== Verification ==="
POST_COUNTS=$(docker compose -p "$NEW_PROJECT" -f "$COMPOSE_FILE" exec -T postgres \ POST_COUNTS=$(docker compose -p "$NEW_PROJECT" -f "$COMPOSE_FILE" exec -T postgres \
psql -U nexus -d nexus -t -c \ psql -U nexus -d nexus -t -c \
"SELECT relname, n_live_tup FROM pg_stat_user_tables ORDER BY relname;") "SELECT table_name, n_live_tup FROM pg_stat_user_tables ORDER BY table_name;")
echo "Post-rename row counts (sample):" echo "Post-rename row counts (sample):"
echo "$POST_COUNTS" | head -20 echo "$POST_COUNTS" | head -20