CyberStrikeAI/internal/database/schemas
Sycun b5f4ab9071 feat(assessment): fuse global security base and deep assessment governance (v1.8.2)
- Add random-nonce CSAI_DATA prompt guard envelope and typed scanner surface ingest (nmap/nuclei/httpx/ffuf) with cross-path execution deduplication
- Add deterministic 3-axis vulnerability fingerprinting and 5-dimension adversarial review shared across record/status/retest/assessment review
- Extend project scope_json with structured allow/deny constraints, scanner noise profiles, and evidence-gated project lessons (off/shadow/inject)
- Bundle offline WSTG/CWE/ATT&CK lookup_security_taxonomy tool and Pi compact skill index + prompt_cache_prefix_split support
- Add deep assessment pre-plan goal decomposition, persistent coverage ledger & acceptance gate, optimistic-concurrency plan notes, and graceful segment wrap-up
- Bump personal version to v1.8.2 and update CHANGELOG.md
2026-11-27 19:21:04 +08:00
..
README.md docs: remove internal process journals and organize public guides 2026-10-16 16:59:01 +08:00
application.sql feat(assessment): fuse global security base and deep assessment governance (v1.8.2) 2026-11-27 19:21:04 +08:00
knowledge.sql feat: reconcile SQLite tables and columns at startup 2026-10-10 20:45:39 +08:00

README.md

SQLite latest schema definitions

These SQL files are embedded into the server binary and are the authoritative source for the tables and columns managed by the application. When adding a table or column, update its definition here; do not add a separate list of ALTER TABLE ADD COLUMN migrations in startup or handlers.

Startup opens an isolated in-memory reference database with the latest SQL, compares it with the actual SQLite file, and adds missing tables and columns in one transaction before creating missing indexes and running business queries. Existing rows, extra tables and extra columns remain in place. Repeated startup is safe. The process does not change types or constraints of existing columns.

Column additions use their exact definition, including defaults. SQLite rejects some additions (for example PRIMARY KEY, UNIQUE, STORED generated columns, or a required column without a suitable default on a populated table). Such failures roll back structure repair and stop startup with the table/column and cause. Resolve the definition or explicitly plan a data migration, then restart; the repair engine does not invent required values or weaken constraints.

Historical data and foreign keys

Historical data backfills and foreign-key semantic changes are separate from missing-table/column repair. Existing data migrations remain responsible for time values, token usage, tool guards, and approvals. The historical vulnerability foreign-key migration creates the destination from the latest definition and copies existing columns dynamically, preserving extra columns, indexes, triggers, and dependent records. It is not the source of missing-column checks.

Both application and knowledge databases use the same reconciliation engine. HITL and notification-read tables are included in the embedded definitions, so request handlers do not need to create those tables at request time.

Regression coverage

Schema reconciliation tests cover missing tables and columns, complex defaults, repeated startup, rollback on failure, and preservation of existing data and extra schema objects. Keep these properties when changing definitions or historical migrations.