fix template, remove okr, use casan.*

This commit is contained in:
thanhnv
2026-07-18 16:45:31 +07:00
parent 0dfd1742d3
commit 13fae3e6c3
249 changed files with 4881 additions and 5702 deletions
+7 -94
View File
@@ -1,94 +1,7 @@
# Step 13: Launch
> Boss MUST read this file before executing Step 13.
> Protocols referenced: `protocols/report-gate-protocol.md`
---
## STEP 13 — Build, Connect DB & Launch Screen
> ✅ Step 12 verdict = ALL TESTS PASS → launch with confidence.
> ⚠ Step 12 verdict = FAIL (after 3 cycles) → still launch, but notify user of known defects.
> ⚠ All code errors MUST have been resolved in Steps 10–12. STEP 13 does NOT fix code.
| Key | Value |
|-----|-------|
| Agent | Boss (self — direct execution) |
| Report | `reports/13-launch-report.md` |
| Gate | REPORT HARD GATE (+ "Launch Status" section required) |
| Max retries | 5 |
### ⛔ PRE-LAUNCH: Environment Detection (MANDATORY — run FIRST)
Before ANY build/start command, Boss MUST detect the runtime environment:
```
1. Check Docker availability:
- Run: `docker --version` (or `docker info`)
- If SUCCEEDS → Docker mode (use docker-compose)
- If FAILS → Local mode (fallback to SQLite + local Node)
2. Check database availability (Local mode only):
- If MySQL/PostgreSQL configured in docker-compose.yml but Docker unavailable:
→ Switch Prisma schema to SQLite provider
→ Create .env with DATABASE_URL="file:./dev.db"
→ Remove enum definitions (SQLite does not support enums)
→ Create local TypeScript type definitions to replace Prisma enums
→ Run: npx prisma migrate dev --name init && npx prisma db seed
3. Check port availability:
- Run: `netstat -ano | findstr :<PORT>` (Windows) or `lsof -i :<PORT>` (Unix)
- If port in use → kill existing process BEFORE starting new one
- Log [ISSUE] entry with killed PID
4. Verify .env file exists:
- backend/.env MUST exist with at minimum: DATABASE_URL, JWT_SECRET
- If missing → CREATE it with sensible defaults for local dev
- JWT_SECRET MUST be read from env, NEVER hardcoded in source
```
### Execution — Boss builds & launches directly (no delegation)
Boss MUST directly:
1. **Build Backend:**
- `cd backend && npm install && npm run build`
- If build fails, log `[ISSUE]` and retry (do NOT fix code — code must be clean from Steps 10–12)
2. **Connect DB (if the chosen stack uses a database):**
- **Docker mode:** Start Docker infrastructure: `docker-compose up -d` (or `docker compose -f docker/docker-compose.dev.yml up -d`)
- **Local mode (Docker unavailable):**
- Verify `backend/.env` has `DATABASE_URL` pointing to SQLite file
- Run `cd backend && npx prisma migrate dev --name init` if no migrations exist
- Run `cd backend && npx prisma db seed` to populate data
- Verify the application can connect to the configured database
3. **Build Frontend:**
- `cd frontend && npm install && npm run build`
- (Output is bundled to `backend/src/static/`)
4. **Start Backend (background):**
- **FIRST:** Kill any existing process on the backend port (default 3000):
- Windows: `Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess -ErrorAction SilentlyContinue | Stop-Process -Force`
- Unix: `lsof -ti:3000 | xargs kill -9`
- `cd backend && node dist/main.js &`
- Wait for startup confirmation in logs
5. **Start Frontend dev server (background, for screen verification only):**
- **FIRST:** Kill any existing process on port 5173 (same pattern as above)
- `cd frontend && npm run dev`
- Confirm dev server is listening on `http://localhost:5173`
6. **Verify screens:**
- Read `specs/<feature-id>/spec.md` → find first screen route (`SCR-MOD[XX]-01` URL path)
- Confirm screens are accessible and data is visible from DB (not mock)
7. **Open browser:**
- **Call `open_browser_page`** with URL: `http://localhost:5173/<first-screen-route>`
- This is the **final mandatory deliverable** of the pipeline
- The user MUST see the running UI without manual action
8. **Write `[END]`** entry in boss log with the exact URL
### Auto-Retry Gate
- All screens accessible + data visible → write `[END]` pipeline complete
- Startup errors → Auto-Retry Loop (max 5 retries):
1. Write `[ISSUE]` in boss log
2. Retry startup sequence
3. If retry > 5: `[ESCALATION]`, mark PARTIAL COMPLETE
> ⛔ **[REPORT GATE]** per `protocols/report-gate-protocol.md`
# Step 13 — Release Candidate and Deployment Adapter
Package only artifacts produced by a passing manifest build/test and bind them to commit, manifest,
quality profile, evidence hashes, and provenance. Do not call a package “deployed” unless an approved
environment adapter defines target identity, workload credentials, preflight, migration, health
checks, smoke tests, rollback command, and post-deploy evidence. Deployment requires separation of
duties and the protected environment approval configured by the repository owner.
+2 -2
View File
@@ -37,7 +37,7 @@ Run: Get-ChildItem specs/ -Directory | Select-Object -ExpandProperty Name
| Key | Value |
|-----|-------|
| Agent | `okr.srs` |
| Agent | `casan.srs` |
| Model | `gpt-5.4` |
| Input | Module keyword from `$ARGUMENTS` |
| Output | `docs/output/ipa-docs/srs/srs-<MOD-ID>-<short-name>.md` |
@@ -63,7 +63,7 @@ pipeline-context: docs/output/output_logs/<feature-id>/pipeline-context.yaml
| Key | Value |
|-----|-------|
| Agent | `okr.bd` |
| Agent | `casan.bd` |
| Model | `gpt-5.4` |
| Input | `docs/output/ipa-docs/srs/srs-<MOD-ID>-<short-name>.md`, `docs/output/srs-systems/srs-overview-system.md`, `docs/technical_architecture.md` |
| Output | `docs/output/ipa-docs/bd/bd-<MOD-ID>-<short-name>.md` |
+4 -4
View File
@@ -9,7 +9,7 @@
| Key | Value |
|-----|-------|
| Agent | `okr.reviewspec` |
| Agent | `casan.reviewspec` |
| Model | `claude-sonnet-4-6` |
| Input | `spec.md`, `docs/output/ipa-docs/srs/srs-<MOD-ID>-<short-name>.md`, `constitution.md` |
| Report | `reports/05-review-spec-report.md` |
@@ -19,7 +19,7 @@
**Gate logic:**
- ✅/⚠️ → proceed to Step 6
- ❌ REJECTED → invoke `speckit.specify` to fix CRITICAL issues → re-invoke `okr.reviewspec` → repeat until pass or retry > 5
- ❌ REJECTED → invoke `speckit.specify` to fix CRITICAL issues → re-invoke `casan.reviewspec` → repeat until the bounded retry limit
- Escalation after 5 retries → continue to Step 6
> ⛔ **[REPORT GATE]** per `protocols/report-gate-protocol.md`
@@ -54,7 +54,7 @@ pipeline-context: docs/output/output_logs/<feature-id>/pipeline-context.yaml
| Key | Value |
|-----|-------|
| Agent | `okr.reviewplan` |
| Agent | `casan.reviewplan` |
| Model | `claude-sonnet-4-6` |
| Input | `plan.md`, `spec.md`, `data-model.md`, `docs/technical_architecture.md` |
| Report | `reports/07-review-plan-report.md` |
@@ -64,7 +64,7 @@ pipeline-context: docs/output/output_logs/<feature-id>/pipeline-context.yaml
**Gate logic:**
- ✅/⚠️ → proceed to Step 8
- ❌ REJECTED → invoke `speckit.plan` to fix → re-invoke `okr.reviewplan` → repeat
- ❌ REJECTED → invoke `speckit.plan` to fix → re-invoke `casan.reviewplan` within the bounded retry limit
- Escalation after 5 retries → continue to Step 8
> ⛔ **[REPORT GATE]** per `protocols/report-gate-protocol.md`
+2 -2
View File
@@ -17,7 +17,7 @@
| Key | Value |
|-----|-------|
| Agent | `okr.dd` |
| Agent | `casan.dd` |
| Model | `gpt-5-3-codex` |
| Input | BD, SRS, spec, plan, technical architecture |
| Output | `docs/output/ipa-docs/dd/dd-<MOD-ID>-<short-name>.md` |
@@ -77,7 +77,7 @@ pipeline-context: docs/output/output_logs/<feature-id>/pipeline-context.yaml
| Key | Value |
|-----|-------|
| Agent | `okr.testkit` |
| Agent | `casan.testkit` |
| Model | `claude-sonnet-4-6` |
| Mode | `gen-testcases` |
| Input | `docs/output/ipa-docs/srs/srs-<MOD-ID>-<short-name>.md`, `docs/output/ipa-docs/bd/bd-<MOD-ID>-<short-name>.md`, `docs/output/ipa-docs/dd/dd-<MOD-ID>-<short-name>.md`, `spec.md`, `plan.md` |
+10 -139
View File
@@ -1,139 +1,10 @@
# Steps 10–12: Implementation & QA Phase
> Boss MUST read this file before executing Steps 10–12.
> Protocols referenced: `protocols/gate-retry-protocol.md`, `protocols/report-gate-protocol.md`, `protocols/implement-delegation.md`
---
## STEP 10 — Implementation + Build & Fix (Auto-Retry)
| Key | Value |
|-----|-------|
| Agent | `speckit.implement` |
| Model | `gpt-5-3-codex` |
| Input | `tasks.md`, `plan.md`, `data-model.md`, `contracts/`, `docs/output/ipa-docs/testcase/testcase-<mod-id>-<short-name>.md` |
| Report | `reports/10-implement-report.md` (NN=10, phase=implement) |
| Gate | BUILD GATE (Auto-Retry) + REPORT HARD GATE (+ "Test Results" + "Screen Verification" sections required) |
| Max retries | 5 |
**Delegation:** Per `protocols/implement-delegation.md` § STEP 10.
**Additional context:**
```yaml
feature-id: <feature-id>
module-id: <mod-id>
report-nn: 10
report-phase: implement
pipeline-context: docs/output/output_logs/<feature-id>/pipeline-context.yaml
```
**Phase 1 — Gen test:**
- Every source file under `src/` must have a dedicated test file under `test/` or co-located (following standard TypeScript/Jest testing conventions)
- All checklist items in `specs/<feature-id>/checklists/` must be resolved before proceeding
- Auto-resolve any checklist ambiguities per `protocols/auto-resolve-protocol.md`
**⛔ Test Quality Mandate (Post-Mortem P-08):**
- Integration tests MUST use real database (SQLite for local, Docker DB for CI) — **in-memory mocks are PROHIBITED**
- Every endpoint test MUST verify: HTTP status, response shape, actual DB state change (read-back after write)
- Authorization tests MUST verify: unauthenticated → 401, wrong role → 403, ownership violation → 403
- Pseudo-tests (tests that always pass, mock everything, or have no assertions) are treated as CRITICAL review failure
**Phase 2 — Implement:**
- Execute all tasks in `specs/<feature-id>/tasks.md` phase by phase
- All checklist items in `specs/<feature-id>/checklists/` must be resolved before proceeding
- Auto-resolve any checklist ambiguities per `protocols/auto-resolve-protocol.md`
**Phase 3 — Build & Fix:**
1. Fix all compile/lint errors (`get_errors` → fix → repeat until zero)
2. Build frontend: `cd frontend && npm install && npm run build`
3. Start Docker (if `docker-compose.dev.yml` exists): `docker compose -f docker/docker-compose.dev.yml up -d`
4. Build backend: `cd backend && npm install && npm run build`
5. Verify startup (if Docker available): `cd backend && npm run start:dev`
**Gate logic:**
- ✅ Build succeeds + app starts → proceed to Step 11
- ❌ Build/startup fails → **Auto-Retry Loop:**
1. Capture error log
2. Write `[ISSUE]` in boss log
3. Invoke `speckit.implement`: *"Fix build/startup errors: <error log>. Minimal fix."*
4. Retry build sequence
5. If retry > 5: `[ESCALATION]`, mark PARTIAL COMPLETE
> ⛔ **[REPORT GATE]** per `protocols/report-gate-protocol.md`
---
## STEP 11 — Code Review (Auto-Retry)
| Key | Value |
|-----|-------|
| Agent | `okr.reviewcode` |
| Model | `claude-sonnet-4-6` |
| Input | Implemented source code, spec, tasks, constitution |
| Report | `reports/11-review-code-report.md` |
| Gate | REVIEW GATE (Auto-Retry) + REPORT HARD GATE |
| Fix agent | `speckit.implement` |
| Max retries | 5 |
**Gate logic:**
- ✅/⚠️ → proceed to Step 12
- ❌ REJECTED → invoke `speckit.implement` to fix CRITICAL issues → re-invoke `okr.reviewcode`
- Escalation after 5 retries → continue to Step 12
**Additional DB Data Check:**
Code review MUST also verify:
- All screen data is fetched from the database (via Prisma Client / API endpoints), NOT from mock/hardcoded data
- Prisma seed script (`backend/prisma/seed.ts`) includes necessary seed data for the screens to display real content
- Frontend components call real API endpoints (not mock adapters or static JSON)
- If mock data is detected, mark as ❌ CRITICAL and instruct fix agent to replace with DB-backed data
> ⛔ **[REPORT GATE]** per `protocols/report-gate-protocol.md`
---
## STEP 12 — Final QA Audit: Test Execution (Independent QA)
| Key | Value |
|-----|-------|
| Agent | `okr.testkit` |
| Model | `claude-sonnet-4-6` |
| Mode | `run-tests` |
| Prerequisite | Step 10 PASSED |
| Report (Phase C) | `reports/12-testkit-report.md` |
| Report (Phase D) | `docs/output/ipa-docs/testreport/testreport-<MOD-ID>-<short-name>.md` |
| Gate | TEST GATE (BACK-TO-PLAN on FAIL) |
> ⚠ This is the **FINAL quality gate** before launch. No screen shown until ALL tests pass.
**Delegation `$ARGUMENTS`:**
```
run-tests <feature-id>
```
**Additional delegation context (mandatory):**
Pipeline report (Phase C) MUST include:
1. `## Test Execution Summary` — Category | Total | Passed | Failed | Skipped | Pass Rate
2. `## Failed Test Details` — every failed test with TC-ID, failure reason, design reference
3. `## Retry Log` — Retry Count | Target | Fix Applied | Result
4. `## Screen Verification Results (E2E)` — per-screen accessibility
5. `## Coverage` — Istanbul/c8 metrics
6. `## Overall Verdict` — PASS / FAIL
IPA detail report (Phase D) generation rules:
- Take `docs/output/ipa-docs/testcase/testcase-<MOD-ID>-<short-name>.md` as BASE
- Rename title to `Test Execution Result Report`
- Keep ALL test case rows intact — fill `Execution Result`, `Verdict`, `Notes` columns only
- Add `## Test Execution Summary`, `## Coverage Results` at top
- Append `## Screen Verification Results`, `## SRS/BD/DD Compliance Check`, `## Overall Verdict` at bottom
**GATE — FAIL ← BACK TO PLAN (Full Fix Cycle):**
Per `protocols/gate-retry-protocol.md` § BACK-TO-PLAN Fix Cycle:
- ✅ ALL tests PASS + coverage ≥ 80% → proceed to Step 13
- ❌ Tests FAIL → re-invoke pipeline from STEP 6 (max 3 full cycles)
- If 3 cycles exhausted → `[ESCALATION]`, proceed to Step 13 with failure report
> ⛔ **[REPORT GATE]** — **Both files required:**
> 1. `reports/12-testkit-report.md` (Phase C)
> 2. `docs/output/ipa-docs/testreport/testreport-<MOD-ID>-<short-name>.md` (Phase D)
# Steps 10–12 — Manifest-Bound Implementation and Acceptance
1. Implement approved tasks only inside manifest `source_roots`.
2. Confirm every changed behavior and test maps to a requirement ID.
3. Review architecture boundaries, validation, authorization, data integrity, safe logging/errors,
dependency policy, test depth, and golden drift.
4. Run all matching manifest verification rules.
5. Run manifest build commands, then test commands, as argv without shell interpolation.
6. On failure, roll back the approved patch and return to plan/implementation with evidence.
7. Write implementation acceptance only after every deterministic gate passes.