Skip to content

KrinosAI — Coding Standards

Template ID: TPL-05-02 | Stage: 05-Development-Setup | Version: 0.3
Record: KAI-VORAL-CSTD-001 — retrospective draft for Visionary Oral. Not approved.

Purpose: Define enforceable coding rules for the project's languages, with emphasis on security, errors, logging and tests.

Required inputs: Language/framework choices from the HLD; organization secure-coding policy.

Document control

Field Required entry
Document ID KAI-VORAL-CSTD-001
Template used TPL-05-02 Coding Standards v0.3
Product / project / software version or commit SHA VORAL (Visionary Oral) / PRJ-001 / a6b4429e3165 (branch app_dev of AI-Dental-Project/Visionary_Oral)
Record status and version Draft v0.1
Author / technical reviewer / quality reviewer Claude Code (drafted with Claude Code for KrinosAI) / Tech Lead (name to be assigned) / Security & Privacy Officer (name to be assigned)
Created / updated / approved dates 2026-10-27 / 2026-10-27 / Pending
Applicable SOP and revision SOP-LC-05 v0.3
Related issue, commit, requirement and evidence links dentalapp/eslint.config.mjs; mobile/tsconfig.json
Approver and decision record Pending

Applicability and evidence baseline

Product / system boundary: Web app and API (dentalapp/), doctor/admin mobile app (mobile/), PDF Lambda (dentalapp/pdf-lambda/) at a6b4429e3165, and the external services they call. Related approved requirements, risks and change records: None approved. Related drafts are listed in document control. Retrospective record? Yes — follows the Retrospective Documentation Protocol (KrinosAI lifecycle pack, 05-References/). Items are labelled Observed (code or Git at a6b4429), Measured (dated run), Stated (named person, dated) or Not recorded. Observed from the repository, Git and build configuration at a6b4429; GitHub settings (branch protection, access lists) are not visible in the repository and are Not recorded unless stated. Acceptable evidence: an implementation reference (file:line at a commit SHA), a dated test record, a signed decision, a vendor agreement, or another independently verifiable artifact. Never invent approvals, clinical results, measurements or performance data.

1. Language framework and formatting rules

Language Version Formatter / linter Config
JavaScript (web) Node via Next.js 16.0.7 ESLint (npm run lint) dentalapp/eslint.config.mjs
TypeScript (mobile) Expo SDK 57 tsc --noEmit (npm run typecheck) mobile/tsconfig.json
Python (ML export) Python 3 Not recorded mobile/ml/requirements.txt

2. Secure coding and input sanitization

Rule Enforced by
Validate inputs in every route Code review only — partly done (e.g. offline-limit route); not enforced
Authenticate every non-public route Not enforced — OPEN-026
No secrets in code Not enforced — OPEN-007, OPEN-017

3. Authentication error and logging patterns

Pattern Rule
Authentication Use auth-helpers.js checks (getEffectiveDoctorClerkId, checkAdminAuth)
Errors JSON { error } with HTTP status
Logging console.*; must not log patient data — not enforced (OPEN-043)

4. Testing and coverage expectations

Item Rule
Mobile Jest; all tests pass before build (201 passed, 2026-10-25)
Web No tests — OPEN-027
Coverage target Proposed (Claude Code, for confirmation): 70 % line coverage for new and changed code

5. Code review and static analysis

Tool Gate
ESLint / tsc Run locally; not in CI (OPEN-039)
SAST None — OPEN-039

6. Compatibility and documentation requirements

Item Rule
Mobile ↔ API compatibility Route shapes are a contract (OPEN-036)
Docs Update lifecycle records in the same PR (pack rule)

Open issues and decisions

ID Specific gap or decision Responsible owner Due date Blocks gate? Evidence required Status
OPEN-001 Tracker project ID, named requester and sponsor, and named reviewers are not recorded Product Owner 2026-11-10 (proposed) Yes Tracker entry; names with roles Open
OPEN-007 Credential files committed to Git: dentalapp/google-credentials.json, dentalapp/mongoDb_usernamePassword (contents not opened) Security & Privacy Officer 2026-10-31 (proposed) Yes Credentials rotated; files removed and purged from history; confirmation Open
OPEN-017 Admin session signing uses a hard-coded fallback secret when JWT_SECRET is unset (dentalapp/src/lib/admin/session.js:4) Backend Lead 2026-11-10 (proposed) Yes Code fix; secret confirmed set Open
OPEN-026 Critical: 20 API routes have no authentication check, incl. /api/admin/patient-sample (patient emails) and /api/admin/api-usage (doctor names and emails), support tickets/messages, and paid AI routes (/api/detect-gemini, /api/speech-to-text, /api/validate-scan) — see docs/lifecycle/_evidence/api-inventory-a6b4429.md Backend Lead 2026-10-31 (proposed) Yes Auth added to each route; re-run of the inventory shows none unprotected Open
OPEN-027 The web app (dentalapp/) has no automated tests and no test script Tech Lead 2026-12-15 (proposed) Yes Test suite and CI run for the web app Open
OPEN-036 No OpenAPI specification and no contract tests for the 75 API route files Backend Lead 2026-12-15 (proposed) No OpenAPI file and contract tests in CI Open
OPEN-039 No CI pipeline builds, lints, tests or scans the code; the only workflow is the ML keep-awake job Tech Lead 2026-11-30 (proposed) Yes CI workflow running build, lint, tests, audit and secret scan on every PR Open
OPEN-043 No structured logging, metrics, uptime monitoring or alerting; logs are console.* only Tech Lead 2026-11-30 (proposed) Yes Monitoring and alerting in place with an on-call contact Open

Review and approval

Review role Named individual Decision Date Signed / controlled record
Author Claude Code (drafted with Claude Code) Draft 2026-10-27 This file at the commit that adds it
Technical reviewer Tech Lead (name to be assigned) Pending Pending Pending
Quality / regulatory reviewer (if applicable) Qualified regulatory reviewer (name to be assigned) Pending Pending Pending
Authorized approver Tech Lead (name to be assigned) Pending Pending Pending