Skip to content

Commit 8942b4f

Browse files
authored
Ship autopilot dashboard hardening
Merge PR #9 after green release gate, supply-chain, Windows, stress, and acceptance checks.
1 parent e48a061 commit 8942b4f

23 files changed

Lines changed: 727 additions & 147 deletions

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ jobs:
6565
PROMPT_REFINER_PRIMARY_MODEL: ${{ matrix.model-order == 'primary' && 'gemma3:12b' || 'gemma3:1b' }}
6666
PROMPT_REFINER_FALLBACK_MODEL: ${{ matrix.model-order == 'primary' && 'gemma3:1b' || 'gemma3:12b' }}
6767
run: npm run acceptance:semantic
68+
- name: Run tracked-turn acceptance
69+
run: npm run acceptance:tracked-turn
6870

6971
stress:
7072
runs-on: ubuntu-latest
@@ -89,6 +91,10 @@ jobs:
8991
PROMPT_REFINER_STRESS_WORKERS: '4'
9092
PROMPT_REFINER_STRESS_WRITES: '100'
9193
run: npm run stress:event-store
94+
- name: Run abrupt recovery proof
95+
run: npm run recovery:event-store:abrupt
96+
- name: Run EventStore soak
97+
run: npm run stress:event-store:soak
9298

9399
windows:
94100
runs-on: windows-latest
@@ -108,7 +114,13 @@ jobs:
108114
- run: npm run build
109115
- run: npm run test:coverage
110116
- run: npm run test:acceptance
117+
- run: npm run acceptance:semantic
118+
- run: npm run acceptance:tracked-turn
111119
- run: npm run test:stress
120+
- run: npm run stress:event-store
121+
- run: npm run recovery:event-store:abrupt
122+
- run: npm run stress:event-store:soak
123+
- run: npm run acceptance:package-runtime
112124

113125
supply-chain:
114126
runs-on: ubuntu-latest
@@ -125,9 +137,11 @@ jobs:
125137
cache-dependency-path: universal-refiner/package-lock.json
126138
- run: npm ci --no-fund
127139
- run: npm run security:audit
140+
- run: npm run security:audit:all
128141
- run: npm run security:secrets
129142
- run: npm run build
130143
- run: npm run package:check
144+
- run: npm run acceptance:package-runtime
131145

132146
release-gate:
133147
if: always()

CLAUDE.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# PromptImprover
2+
3+
MCP server middleware for prompt governance. The active implementation is the Universal Refiner package, which provides prompt refinement, local memory, commit-correlated learning, dashboard review workflows, and evidence capture for agent runs.
4+
5+
## Project Hierarchy
6+
7+
This project has a `context.md` tree. Always read the nearest context file before changing files in a directory.
8+
9+
- Root: `context.md` - project-wide mandates and submodule index.
10+
- `universal-refiner/context.md` - active MCP server, refinement engine, history, learning, hooks, and dashboard.
11+
- `gemini-extension/context.md` - Gemini CLI integration.
12+
- `mcp-server/context.md` - legacy standalone MCP server.
13+
- `docs/context.md` - architecture specs, roadmaps, and release-gate documentation.
14+
- `archive/context.md` - deprecated code and historical experiments.
15+
16+
## Tech Stack
17+
18+
| Layer | Technology |
19+
|---|---|
20+
| Language | TypeScript, strict mode |
21+
| Runtime | Node.js >= 22 |
22+
| MCP transport | stdio via `@modelcontextprotocol/sdk` |
23+
| Storage | SQLite via `better-sqlite3` |
24+
| Build | `tsc` plus dashboard asset copy |
25+
| Test | Vitest |
26+
27+
## Active Entry Points
28+
29+
| Path | Purpose |
30+
|---|---|
31+
| `universal-refiner/src/` | Active source code |
32+
| `universal-refiner/dist/src/index.js` | Built MCP server used by global CLI registrations |
33+
| `universal-refiner/hooks/` | Claude/Gemini hook runtime and fragments |
34+
| `universal-refiner/scripts/operations/register-global.ps1` | Global Codex, Claude, and Gemini registration doctor |
35+
| `universal-refiner/scripts/acceptance/` | Real-process and package-runtime acceptance gates |
36+
37+
## Standard Workflow
38+
39+
1. Read the relevant `context.md`, `AGENTS.md`, `GEMINI.md`, and this file before changing behavior.
40+
2. Prefer the active `universal-refiner` package for new work. Avoid expanding legacy `mcp-server` unless the task explicitly targets it.
41+
3. Keep changes scoped and preserve unrelated user work.
42+
4. After code or package changes in `universal-refiner`, run the strongest proportionate gate. For broad hardening, use:
43+
44+
```powershell
45+
cd C:\PersonalRepo\portfolio\Promptimprover\universal-refiner
46+
npm.cmd run release:verify
47+
```
48+
49+
5. Restart the local background runtime after rebuilding:
50+
51+
```powershell
52+
$repo = 'C:\PersonalRepo\portfolio\Promptimprover\universal-refiner'
53+
$env:PROMPT_REFINER_BACKGROUND = 'true'
54+
Start-Process -WindowStyle Hidden -FilePath node -ArgumentList (Join-Path $repo 'dist\src\index.js') -WorkingDirectory $repo
55+
```
56+
57+
6. Smoke-test runtime health:
58+
59+
```powershell
60+
Invoke-RestMethod http://127.0.0.1:3000/api/health
61+
```
62+
63+
## Release Gates
64+
65+
The authoritative local gate is:
66+
67+
```powershell
68+
npm.cmd run release:verify
69+
```
70+
71+
It includes build, 100% coverage, MCP acceptance, semantic fallback, tracked-turn acceptance, stress/recovery/soak, production and full audit checks, secret scanning, package dry-run, and packaged runtime startup smoke.
72+
73+
## Global Registration
74+
75+
Use the registration doctor after changes that affect global MCP wiring:
76+
77+
```powershell
78+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\register-global.ps1 -Check
79+
```
80+
81+
Apply only when the check reports real drift:
82+
83+
```powershell
84+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\register-global.ps1 -Apply
85+
```
86+
87+
The expected global MCP registrations are:
88+
89+
- Codex: `prompt-refiner`, `obsidian`
90+
- Claude Code: `prompt-refiner`, `obsidian`, plus PromptImprover hooks
91+
- Gemini: `prompt-refiner`, `obsidian`
92+
93+
## Security
94+
95+
- Never commit secrets, tokens, credentials, private prompts, or raw sensitive payloads.
96+
- Treat `npm audit` failures as defects. Production audit is mandatory; full audit is also part of the release gate.
97+
- If a plaintext token was ever present in local configuration, remove it and rotate it externally.

docs/enterprise-release-gates.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Passing unit tests alone does not prove that PromptImprover is operationally rea
1919
6. SQLite restart, migration, backup/restore, contention, and multi-process tests pass.
2020
7. Claude and Gemini hook pre/post flows pass; Codex MCP-first flow passes.
2121
8. Dashboard API security, review mutation, health telemetry, and browser smoke flows pass.
22-
9. Dependency audit reports no known production vulnerabilities.
23-
10. Package dry-run, global installation, runtime startup, and post-restart smoke tests pass.
22+
9. Dependency audit reports no known production or development vulnerabilities at high severity or above.
23+
10. Package dry-run plus `acceptance:package-runtime` global installation, runtime startup, and health smoke tests pass.
2424
11. Secret scanning finds no committed credentials.
2525
12. Linux and Windows CI jobs pass before merge.
2626

docs/operator-testing.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Operator Testing Guide
2+
3+
Use this guide to verify PromptImprover from a clean Windows operator session.
4+
5+
## 1. Enter The Active Package
6+
7+
```powershell
8+
cd C:\PersonalRepo\portfolio\Promptimprover\universal-refiner
9+
```
10+
11+
## 2. Run The Full Release Gate
12+
13+
```powershell
14+
npm.cmd run release:verify
15+
```
16+
17+
Expected result:
18+
19+
- TypeScript build passes.
20+
- Vitest coverage reports 100% statements, branches, functions, and lines.
21+
- MCP tool acceptance passes.
22+
- Semantic fallback acceptance passes.
23+
- Tracked-turn acceptance links a `prm_...` prompt ID in SQLite.
24+
- EventStore stress, abrupt recovery, and soak pass.
25+
- Production and full dependency audits report zero high-or-higher vulnerabilities.
26+
- Secret scan passes.
27+
- Package dry-run passes.
28+
- `acceptance:package-runtime` installs the packed tarball into a temporary global prefix and serves `/api/health`.
29+
30+
## 3. Check Global MCP Registration
31+
32+
```powershell
33+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\register-global.ps1 -Check -ProfileRoot C:\Users\KimHarjamaki -CodexHome C:\codex-home
34+
```
35+
36+
Expected result:
37+
38+
```text
39+
OK Codex
40+
OK Claude Code MCP
41+
OK Claude Code hooks
42+
OK Gemini
43+
```
44+
45+
If any row reports `DRIFT`, run `-Apply` only after confirming the drift is expected:
46+
47+
```powershell
48+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\register-global.ps1 -Apply -ProfileRoot C:\Users\KimHarjamaki -CodexHome C:\codex-home
49+
```
50+
51+
## 4. List MCP Servers In Each CLI
52+
53+
```powershell
54+
codex.cmd mcp list | Select-String -Pattern 'prompt-refiner|obsidian|Connected|enabled'
55+
claude.cmd mcp list | Select-String -Pattern 'prompt-refiner|obsidian|Connected|Configured'
56+
gemini.cmd mcp list | Select-String -Pattern 'prompt-refiner|obsidian|Connected|Configured'
57+
```
58+
59+
Expected result:
60+
61+
- Codex lists `prompt-refiner` and `obsidian` as enabled.
62+
- Claude lists `prompt-refiner` and `obsidian` as connected.
63+
- Gemini lists `prompt-refiner` and `obsidian` as connected.
64+
65+
Codex may show `Unsupported` in the status column for stdio MCP entries. Treat the registration doctor as the authoritative config drift check.
66+
67+
## 5. Verify Dashboard Runtime Health
68+
69+
Start or restart the local background runtime:
70+
71+
```powershell
72+
$repo = 'C:\PersonalRepo\portfolio\Promptimprover\universal-refiner'
73+
Get-CimInstance Win32_Process |
74+
Where-Object { $_.Name -eq 'node.exe' -and ($_.CommandLine -match 'universal-refiner.*dist/src/index.js' -or $_.CommandLine -match 'universal-refiner.*dist\\src\\index.js') } |
75+
ForEach-Object { Stop-Process -Id $_.ProcessId -Force }
76+
77+
$env:PROMPT_REFINER_BACKGROUND = 'true'
78+
Start-Process -WindowStyle Hidden -FilePath node -ArgumentList (Join-Path $repo 'dist\src\index.js') -WorkingDirectory $repo
79+
```
80+
81+
Check health:
82+
83+
```powershell
84+
Invoke-RestMethod http://127.0.0.1:3000/api/health | ConvertTo-Json -Depth 6
85+
```
86+
87+
Expected result:
88+
89+
- `runtime.status` is `online`.
90+
- `semantic.local.enabled` is `true`.
91+
- `semantic.local.models` includes `gemma3:12b` and `gemma3:1b`.
92+
93+
## 6. Verify Live Gemma Integration
94+
95+
```powershell
96+
$env:PROMPT_REFINER_ACCEPTANCE_BASE_URL = 'http://localhost:9000/v1'
97+
npm.cmd run acceptance:gemma:live
98+
```
99+
100+
Expected result:
101+
102+
```text
103+
Live semantic acceptance passed for gemma3:12b and gemma3:1b at http://localhost:9000/v1.
104+
Semantic acceptance passed: gemma3:12b -> gemma3:1b and outage provider fallback.
105+
```
106+
107+
Warnings such as `HTTP 503` for `gemma3:12b` and `fetch failed` during the outage section are expected. They prove fallback and outage paths are being exercised. The command must still exit successfully.
108+
109+
## 7. Verify Packaged Runtime Directly
110+
111+
```powershell
112+
npm.cmd run acceptance:package-runtime
113+
```
114+
115+
Expected result:
116+
117+
```text
118+
Package runtime smoke passed: installed gemini-prompt-refiner-8.0.0 and served /api/health on <port>.
119+
```
120+
121+
This catches missing production dependencies that are hidden by the local workspace.
122+
123+
## 8. Confirm GitHub CI
124+
125+
After pushing a branch and opening a pull request:
126+
127+
```powershell
128+
gh pr checks <PR_NUMBER> --repo Coding-Autopilot-System/Promptimprover
129+
gh run list --repo Coding-Autopilot-System/Promptimprover --branch <BRANCH_NAME> --limit 10
130+
```
131+
132+
Expected result:
133+
134+
- `build-and-test` passes.
135+
- Both acceptance matrix jobs pass.
136+
- `stress` passes.
137+
- `windows` passes.
138+
- `supply-chain` passes.
139+
- `release-gate` passes.
140+
141+
Remote CI is the authoritative proof for Linux and Windows clean-checkout behavior.

0 commit comments

Comments
 (0)