Skip to content

Commit c3c0478

Browse files
committed
feat: update database path to pabawi.db across configuration files, Dockerfiles, and scripts; enhance setup script for Puppet SSL configuration
1 parent d37f7f0 commit c3c0478

24 files changed

+285
-85
lines changed

.github/copilot-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ SQLite schema defined in `backend/src/database/schema.sql`, migrations in `migra
143143
BOLT_PROJECT_PATH=. # Path to Bolt project (inventory.yaml, modules/)
144144
PORT=3000 # Server port
145145
LOG_LEVEL=info # error | warn | info | debug
146-
DATABASE_PATH=./data/executions.db
146+
DATABASE_PATH=./data/pabawi.db
147147
BOLT_EXECUTION_TIMEOUT=300000 # 5 minutes default
148148
COMMAND_WHITELIST_ALLOW_ALL=false
149149
COMMAND_WHITELIST=["ls","pwd"] # CSV in env, JSON in code
@@ -223,7 +223,7 @@ PuppetDB, Puppetserver, Hiera enabled via `INTEGRATION_PUPPETDB_ENABLED`, `INTEG
223223
- Use correlation IDs to trace frontend actions → backend processing → responses
224224
- Inspect `backend/src/errors/ErrorHandlingService.ts` for error context details
225225
- Check `ExpertModeDebugPanel` component for timeline view of frontend + backend logs
226-
- Verify execution results in SQLite database (`data/executions.db`)—check composite indexes for query performance
226+
- Verify execution results in SQLite database (`data/pabawi.db`)—check composite indexes for query performance
227227
- Test Bolt commands manually: `bolt command run 'whoami' --targets inventory.yaml`
228228
- Check `ExecutionQueue` status via `GET /api/executions/queue/status`—verify queue isn't full
229229
- For task failures, check both `_output` (command output) and `_error.msg` (error details)

.kiro/hooks/repository-cleanup-check.kiro.hook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
},
99
"then": {
1010
"type": "askAgent",
11-
"prompt": "Analyze the repository for:\n1. Stale files (not modified in a long time, potentially obsolete)\n2. Duplicate files (same or very similar content, files with suffixes like _backup, _old, _fixed, etc.)\n3. Inconsistent files (conflicting versions, outdated patterns)\n4. Obsolete dependencies or configurations\n5. Unused code or imports\n6. Redundant documentation files\n\nFor each issue found:\n- If the cleanup action is clear and safe, implement the specific changes needed\n- If there's any doubt or user clarification is needed, create or append to a todo file at .kiro/cleanup-todo.md with:\n * Description of the issue\n * Location of the files/code\n * Questions for the user\n * Potential impact of changes\n\nFocus on:\n- Multiple Dockerfile variants (Dockerfile, Dockerfile.alpine, Dockerfile.ubuntu)\n- Duplicate .env files in different locations\n- Multiple database files (backend/data/executions.db, bolt-project/data/executions.db, data/executions.db)\n- Test result artifacts that should be in .gitignore\n- Backup or temporary files\n- Unused dependencies in package.json files\n- Duplicate documentation\n\nDo NOT make changes directly in case of doubt, document findings and recommendations."
11+
"prompt": "Analyze the repository for:\n1. Stale files (not modified in a long time, potentially obsolete)\n2. Duplicate files (same or very similar content, files with suffixes like _backup, _old, _fixed, etc.)\n3. Inconsistent files (conflicting versions, outdated patterns)\n4. Obsolete dependencies or configurations\n5. Unused code or imports\n6. Redundant documentation files\n\nFor each issue found:\n- If the cleanup action is clear and safe, implement the specific changes needed\n- If there's any doubt or user clarification is needed, create or append to a todo file at .kiro/cleanup-todo.md with:\n * Description of the issue\n * Location of the files/code\n * Questions for the user\n * Potential impact of changes\n\nFocus on:\n- Multiple Dockerfile variants (Dockerfile, Dockerfile.alpine, Dockerfile.ubuntu)\n- Duplicate .env files in different locations\n- Multiple database files (backend/data/pabawi.db, bolt-project/data/pabawi.db, data/pabawi.db)\n- Test result artifacts that should be in .gitignore\n- Backup or temporary files\n- Unused dependencies in package.json files\n- Duplicate documentation\n\nDo NOT make changes directly in case of doubt, document findings and recommendations."
1212
}
1313
}

.kiro/specs/070/pabawi/design.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ interface AppConfig {
455455
commandWhitelist: WhitelistConfig
456456
executionTimeout: number // Default: 300000 (5 min)
457457
logLevel: string // Default: 'info'
458-
databasePath: string // Default: './data/executions.db'
458+
databasePath: string // Default: './data/pabawi.db'
459459
expertModeEnabled: boolean // Default: false (new)
460460
}
461461
```
@@ -970,7 +970,7 @@ COMMAND_WHITELIST_ALLOW_ALL=false
970970
COMMAND_WHITELIST='["ls","pwd","whoami"]'
971971
BOLT_EXECUTION_TIMEOUT=300000
972972
LOG_LEVEL=info
973-
DATABASE_PATH=/data/executions.db
973+
DATABASE_PATH=/data/pabawi.db
974974
```
975975

976976
### Volume Mounts

.kiro/specs/070/puppetserver-integration/manual-testing-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Create or update `backend/.env`:
4343
PORT=3000
4444
HOST=localhost
4545
LOG_LEVEL=debug
46-
DATABASE_PATH=./data/executions.db
46+
DATABASE_PATH=./data/pabawi.db
4747
4848
# Bolt Configuration
4949
BOLT_PROJECT_PATH=./bolt-project

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,14 +794,14 @@
794794
"filename": "frontend/src/pages/LoginPage.svelte",
795795
"hashed_secret": "6c56a9249cba324d029f725f1f7c0e47184e2dcf",
796796
"is_verified": false,
797-
"line_number": 29
797+
"line_number": 46
798798
},
799799
{
800800
"type": "Secret Keyword",
801801
"filename": "frontend/src/pages/LoginPage.svelte",
802802
"hashed_secret": "3e7d56a95804ff3c322b97a7e7cdba25dc920957",
803803
"is_verified": false,
804-
"line_number": 31
804+
"line_number": 48
805805
}
806806
],
807807
"frontend/src/pages/RegisterPage.svelte": [
@@ -828,5 +828,5 @@
828828
}
829829
]
830830
},
831-
"generated_at": "2026-02-21T14:55:18Z"
831+
"generated_at": "2026-03-04T07:57:54Z"
832832
}

CLAUDE.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
```bash
8+
# Install all dependencies (root + workspaces)
9+
npm run install:all
10+
11+
# Development
12+
npm run dev:backend # Backend on port 3000 (tsx watch)
13+
npm run dev:frontend # Frontend dev server on port 5173
14+
npm run dev:fullstack # Build frontend + serve everything from backend
15+
16+
# Build
17+
npm run build # Build both frontend and backend
18+
19+
# Testing
20+
npm run test # Run all tests (backend + frontend, no-watch)
21+
npm run test --workspace=backend # Backend tests only
22+
npm run test --workspace=frontend # Frontend tests only
23+
npm run test:watch --workspace=backend # Backend watch mode
24+
npm run test:e2e # Playwright E2E tests
25+
npm run test:e2e:ui # Playwright with UI mode
26+
27+
# Run a single test file
28+
cd backend && npx vitest run test/unit/SomeService.test.ts
29+
30+
# Linting
31+
npm run lint # Lint both workspaces (0 warnings allowed)
32+
npm run lint:fix # Auto-fix lint issues
33+
```
34+
35+
Backend uses `tsx watch` for hot-reload during development. The frontend dev server proxies API calls to the backend.
36+
37+
## Architecture Overview
38+
39+
Pabawi is an infrastructure management web UI — a monorepo with a **Node.js/Express/TypeScript backend** and a **Svelte 5 SPA frontend**.
40+
41+
### Plugin-based integration system
42+
43+
All infrastructure integrations (Bolt, PuppetDB, Puppetserver, Hiera, Ansible, SSH) are plugins registered in `backend/src/integrations/`. Every plugin:
44+
45+
- Extends `BasePlugin` (`integrations/BasePlugin.ts`) and implements `isEnabled()`, `initialize()`, `healthCheck()`
46+
- Optionally implements `ExecutionToolPlugin` (can run commands) or `InformationSourcePlugin` (provides inventory/facts)
47+
- Is registered with `IntegrationManager` (`integrations/IntegrationManager.ts`), which handles lifecycle, health aggregation, and routes data requests to the correct plugin
48+
49+
`IntegrationManager` is the central registry. When inventory or facts are requested, it fans out to all enabled `InformationSourcePlugin`s and merges results using a priority system (SSH: 50, Bolt/PuppetDB: 10, Puppetserver: 20, Ansible: 8, Hiera: 6). When executing commands, it dispatches to the correct `ExecutionToolPlugin`.
50+
51+
### Backend (`backend/src/`)
52+
53+
- **`server.ts`** — Express app init, plugin registration, middleware wiring, route mounting
54+
- **`config/`**`ConfigService` wraps all env vars with Zod validation; always use this, never `process.env` directly
55+
- **`integrations/<name>/`** — One directory per integration: `<Name>Plugin.ts` (lifecycle + routing) and `<Name>Service.ts` (business logic, CLI spawning, API calls)
56+
- **`services/`** — Cross-cutting services: `ExecutionQueue` (concurrent limiting, FIFO), `StreamingExecutionManager` (SSE real-time output), `CommandWhitelistService` (security), `DatabaseService`, `AuthenticationService`, `BatchExecutionService`, and RBAC services (`UserService`, `RoleService`, `PermissionService`, `GroupService`)
57+
- **`routes/`** — Express route handlers. All async handlers must be wrapped with `asyncHandler()` from `utils/`
58+
- **`middleware/`** — Auth (JWT), RBAC, error handler, rate limiting, security headers
59+
- **`database/`**`DatabaseService.ts` (SQLite, schema/migration on startup), `ExecutionRepository.ts` (CRUD for execution history). Schema in `database/schema.sql`, migrations in `database/migrations.sql`
60+
- **`errors/`** — Typed error classes extending base classes; use these instead of generic `Error`
61+
- **`validation/`** — Zod schemas for request body validation
62+
63+
Bolt command output is parsed from JSON; both `_output` and `_error` fields must be extracted from failed task results. Inventory and facts are cached (30 s and 5 min TTL respectively) inside each plugin's service.
64+
65+
### Frontend (`frontend/src/`)
66+
67+
- **`App.svelte`** — Root: initializes router, auth guard, and setup check
68+
- **`pages/`** — One Svelte component per page route
69+
- **`components/`** — Shared UI components
70+
- **`lib/`** — Core utilities and reactive state:
71+
- `router.svelte.ts` — Client-side router using Svelte 5 runes (`$state`)
72+
- `auth.svelte.ts` — JWT auth state
73+
- `api.ts` — Centralized HTTP client with error handling
74+
- `executionStream.svelte.ts` — SSE client for real-time command output
75+
- `expertMode.svelte.ts` — Debug info toggle
76+
- `integrationColors.svelte.ts` — Per-integration color constants
77+
- `toast.svelte.ts` — Notification system
78+
79+
The frontend uses **Svelte 5 runes** throughout (`$state()`, `$effect()`, `$derived()`). State that needs to persist across components lives in the `lib/*.svelte.ts` files as module-level rune state.
80+
81+
### Configuration
82+
83+
All configuration is via `backend/.env`. Run `scripts/setup.sh` for interactive setup. Key variable groups: `PORT/HOST/LOG_LEVEL`, `JWT_SECRET/AUTH_ENABLED`, `BOLT_*`, `PUPPETDB_*`, `PUPPETSERVER_*`, `HIERA_*`, `ANSIBLE_*`, `SSH_*`, `COMMAND_WHITELIST*`, `CACHE_*`, `CONCURRENT_EXECUTION_LIMIT`.
84+
85+
See `docs/configuration.md` for the full reference.
86+
87+
### Testing conventions
88+
89+
- Backend tests live in `backend/test/` (unit, integration, security, middleware, properties with fast-check)
90+
- Frontend tests co-located with source in `frontend/src/**/*.test.ts`
91+
- E2E tests in `e2e/` using Playwright
92+
- Database tests use in-memory SQLite
93+
- Use `supertest` for HTTP route testing in backend
94+
95+
### Logging
96+
97+
Use `LoggerService` everywhere — never `console.log`. Pass structured metadata: `{ component, integration, operation }`.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ EXPOSE 3000
133133
ENV NODE_ENV=production \
134134
PORT=3000 \
135135
HOST=0.0.0.0 \
136-
DATABASE_PATH=/data/executions.db \
136+
DATABASE_PATH=/data/pabawi.db \
137137
BOLT_PROJECT_PATH=/bolt-project \
138138
# Integration settings (disabled by default)
139139
PUPPETDB_ENABLED=false \

Dockerfile.alpine

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ if [ ! -w /data ]; then
115115
fi
116116

117117
# Create database file if it doesn't exist
118-
if [ ! -f /data/executions.db ]; then
119-
touch /data/executions.db
118+
if [ ! -f /data/pabawi.db ]; then
119+
touch /data/pabawi.db
120120
fi
121121

122122
# Set Puppet/Bolt environment variables to work around Alpine detection issues
@@ -145,7 +145,7 @@ EXPOSE 3000
145145
ENV NODE_ENV=production \
146146
PORT=3000 \
147147
HOST=0.0.0.0 \
148-
DATABASE_PATH=/data/executions.db \
148+
DATABASE_PATH=/data/pabawi.db \
149149
BOLT_PROJECT_PATH=/bolt-project \
150150
FACTER_operatingsystem=Alpine \
151151
FACTER_osfamily=Linux \

Dockerfile.ubuntu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ if [ ! -w /data ]; then
121121
fi
122122

123123
# Create database file if it doesn't exist
124-
if [ ! -f /data/executions.db ]; then
125-
touch /data/executions.db
124+
if [ ! -f /data/pabawi.db ]; then
125+
touch /data/pabawi.db
126126
fi
127127

128128
# Execute the main command
@@ -143,7 +143,7 @@ EXPOSE 3000
143143
ENV NODE_ENV=production \
144144
PORT=3000 \
145145
HOST=0.0.0.0 \
146-
DATABASE_PATH=/data/executions.db \
146+
DATABASE_PATH=/data/pabawi.db \
147147
BOLT_PROJECT_PATH=/bolt-project \
148148
# Integration settings (disabled by default)
149149
PUPPETDB_ENABLED=false \

backend/src/config/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export const AppConfigSchema = z.object({
291291
commandWhitelist: WhitelistConfigSchema,
292292
executionTimeout: z.number().int().positive().default(300000), // 5 minutes
293293
logLevel: z.enum(["error", "warn", "info", "debug"]).default("info"),
294-
databasePath: z.string().default("./data/executions.db"),
294+
databasePath: z.string().default("./data/pabawi.db"),
295295
corsAllowedOrigins: z.array(z.string()).default(["http://localhost:5173", "http://localhost:3000"]),
296296
packageTasks: z.array(PackageTaskConfigSchema).default([
297297
{

0 commit comments

Comments
 (0)