Files
CASAN/.claude/agents/steps/steps-10-12-implement.md
T
thanhnvandClaude Opus 4.8 36a4812ef3 refactor(structure): promote app to repo root + remove redundant workspace cruft
Standard production layout: the OKR app (was nested under AINative_OKR_CASAN5/) is now
the repository root. No more wrapper directory.

- Promote AINative_OKR_CASAN5/* -> repo root (backend/ frontend/ packages/ apps/
  .specify/ docs/ infra/ nginx/ scripts/ + configs). Merge tool dirs: .gitea (kept the
  active deploy ci.yml, added harness-ci.yml + runbooks), .claude (agents/commands +
  launch.json), .github moved up.
- Remove redundant: 00_SUBMISSION_PACKAGE, scattered root notes (FPT_CASAN_Full.md,
  tu-tuong-casan.md, casan-tu-sinh..., casan_harness_assessment.md, source-review...,
  README_CASAN5_REFINED.md), casan-next-plans/ and optimize-docs/ (competition/planning
  artifacts — roadmap + design history preserved in git log / commit messages).
- Update all references to the old layout:
  - .gitea/workflows/{ci,harness-ci}.yml, .github/workflows/{ci,deploy}.yml:
    working-directory .; drop AINative_OKR_CASAN5/ prefix; .specify/{tests,scripts}
    -> packages/casan-harness/... (.specify/logs state kept)
  - .claude/launch.json, .gitea/*-runbook.md: path prefixes
  - CLAUDE.md, README.md: docs/input -> apps/okr/domain/input
  - policy-bundle.yaml: 8 policy paths -> packages/casan-harness/...; manifest re-signed
- secrets-scan.sh: fixture excludes -> new package/domain paths.

Full gate from the new root: PASS=64 FAIL=0 SKIP=3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 13:26:36 +09:00

6.1 KiB
Raw Blame History

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:

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 docs/output/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 docs/output/specs/<feature-id>/tasks.md phase by phase
  • All checklist items in docs/output/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: . 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)