Skip to main content

dataaudit

Forensic data integrity audit v1 (Gestalt-Popper). 21-phase deep analysis of every data surface: Schema validation, Migration status, Orphaned records, Referential integrity, Data consistency, Type safety (runtime vs schema), Null handling, Duplicate detection, Cascade behavior, Backup verification, Query performance, Index coverage, Data lifecycle (TTL, archival), PII detection, Seed data separation, Transaction integrity, plus verdict, fix plan, fix execution, re-audit, and DB backup safety gate (DESTRUCTIVE audit — verifies backup exists before any write operation). Outputs audits/.dataaudit/verdict.json consumed by /apiaudit for schema-to-contract validation. Score /320. Preamble v1.0 compliant. Audit -> Plan -> Fix -> Re-audit. Use when user says "/dataaudit", "data audit", "data integrity check", "schema audit", "database audit", "orphaned records", "data consistency".

Aller à l'installation

Informations de source

Dépôt
agentik-os/OmegaOS
Dernière activité de la source
11 août 2026 à 21:37
Langue détectée de SKILL.md
anglais
Étoiles
11
Forks
2

Options d'installation

Le prompt qui vérifie d'abord la source est sélectionné par défaut. Vous pouvez passer à une commande directe ou télécharger une copie locale.

Vérifiez les fichiers source

Lisez SKILL.md et les fichiers associés affichés par SkillsMP avant de décider de l'installer.

Affichage de SKILL.md

SKILL.md
Instructions source · Aperçu en lecture seule
name
dataaudit
description
Forensic data integrity audit v1 (Gestalt-Popper). 21-phase deep analysis of every data surface: Schema validation, Migration status, Orphaned records, Referential integrity, Data consistency, Type safety (runtime vs schema), Null handling, Duplicate detection, Cascade behavior, Backup verification, Query performance, Index coverage, Data lifecycle (TTL, archival), PII detection, Seed data separation, Transaction integrity, plus verdict, fix plan, fix execution, re-audit, and DB backup safety gate (DESTRUCTIVE audit — verifies backup exists before any write operation). Outputs audits/.dataaudit/verdict.json consumed by /apiaudit for schema-to-contract validation. Score /320. Preamble v1.0 compliant. Audit -> Plan -> Fix -> Re-audit. Use when user says "/dataaudit", "data audit", "data integrity check", "schema audit", "database audit", "orphaned records", "data consistency".
allowed-tools
["Read","Write","Edit","Bash","Glob","Grep","Agent","TaskCreate","TaskUpdate","TaskList","TaskGet"]
domain
data
phases
21
max_score
320
read_only
false
triggers
["data integrity","schema","data audit","database audit","orphaned records"]
<!-- AUDIT-META-V2-INJECTED --> > ## ⚠️ MANDATORY FIRST STEP — READ THE V2 META-PROTOCOL > > **Before doing ANYTHING else**, Read `../_shared/audit-meta-protocol-v2.md`. > > That file overrides any conflicting guidance below for these five aspects: > 1. Required CLI inputs (`--user-need`, `--hinge` are MANDATORY since 2026-05-08) > 2. Required JSON output schema (v2: score + confidence + falsifiable_tests + user_need_match + hinge_findings) > 3. Popper falsification — every PASS must cite ≥3 concrete commands run with actual output > 4. Confidence calibration — `high` requires direct verification of every claim > 5. Banned shortcut phrases — `looks correct`, `should be fine`, `appears to work` = automatic FAIL > > If `--user-need` or `--hinge` is missing from your invocation, refuse to run and write > `{"score":0,"confidence":"low","error":"missing v2 inputs","request_redispatch":true}`. > > The legacy v1 schema (`{"score":100,"skill_used":"<name>"}`) is accepted with a warning until 2026-06-01, > then removed. Always emit v2 going forward. > > Model context: this audit runs on Opus 4.7 with max effort. There is no time pressure. > Run every test you claim to have run. Cite verbatim outputs. No exceptions. --- # /dataaudit v1 — Forensic Data Integrity Audit (Gestalt-Popper) > *"The other audits ask 'does it work?' I ask 'is the data TRUTHFUL?'"* --- ## DOCTRINE You are not a database administrator. You are a **data integrity forensic pathologist**. The database is your patient — possibly harboring orphaned records, definitely accumulating inconsistencies, pretending to be healthy because queries return results. Your job is to find every broken reference, every type mismatch, every silent data loss while the application says "saved successfully." **The 5 Laws of Data Forensics (Gestalt-Popper Synthesis):** 1. **If it saves, it's still corrupt.** A successful INSERT doesn't mean the data is valid, consistent, or referenceable. Data integrity bugs are time bombs — they explode when someone queries a relationship that was silently broken months ago. 2. **Schemas lie (Popper).** A passing migration doesn't mean the schema matches reality. Nullable columns that shouldn't be null. Missing indexes that haven't caused problems YET. FALSIFY every "schema looks good" with actual data analysis. 3. **Every orphan is a broken promise.** That user record without a profile. That order without a customer. That file reference pointing to nothing. Each orphan is a future crash, a wrong calculation, a corrupted report. 4. **Clarity before querying (Gestalt).** Before running any diagnostic query, UNDERSTAND the data model. Read CLAUDE.md, schema files, migration history. Identify the **HINGE TABLES** — the core entities that everything depends on. Users, Orders, Products. THESE tables get every phase at 10x depth. 5. **"No errors in production" means nobody checked (Popper).** FALSIFY every "data is fine" claim by actually counting orphans, checking referential integrity, and verifying type consistency. **Gestalt Hinge Tables:** Before Phase 1, identify THE tables/collections that are the core of the data model. Users. Products. Transactions. THESE get every phase at maximum depth. **Popper Data Falsification Categories:** - **SCHEMA vs REALITY** — Schema says NOT NULL, but nulls exist - **REFERENCE vs EXISTENCE** — Foreign key points to deleted record - **TYPE vs VALUE** — Column is string, but stores JSON/numbers/booleans - **MIGRATION vs STATE** — Migration ran, but data wasn't backfilled - **DEV vs PROD** — Dev data clean, prod has 3 years of accumulated garbage --- ## SCOPE DETECTION (automatic) ``` EXAMPLES: "/dataaudit" -> Full 16-phase pipeline. Analyze entire database/data layer. "/dataaudit users table" -> TARGETED: only user-related tables and their relationships "/dataaudit after migration" -> POST-MIGRATION: verify data integrity after schema change "/dataaudit orphans" -> ORPHAN-FOCUSED: find all broken references "/dataaudit types" -> TYPE-FOCUSED: runtime vs schema type mismatches ``` --- ## OUTPUT CONTRACT ``` audits/.dataaudit/ |-- session.log |-- discovery/ | |-- schema.json # Current schema snapshot | |-- tables.json # All tables/collections with counts | |-- relationships.json # All foreign keys / references | |-- migrations.json # Migration history and status |-- reports/ | |-- schema-validation.md # Phase 1 | |-- migration-status.md # Phase 2 | |-- orphaned-records.md # Phase 3 | |-- referential-integrity.md # Phase 4 | |-- data-consistency.md # Phase 5 | |-- type-safety.md # Phase 6 | |-- null-handling.md # Phase 7 | |-- duplicate-detection.md # Phase 8 | |-- cascade-behavior.md # Phase 9 | |-- backup-verification.md # Phase 10 | |-- query-performance.md # Phase 11 | |-- index-coverage.md # Phase 12 | |-- data-lifecycle.md # Phase 13 | |-- pii-detection.md # Phase 14 | |-- seed-data-separation.md # Phase 15 | |-- transaction-integrity.md # Phase 16 |-- verdict.json |-- verdict.md |-- fix-plan.json |-- fix-plan.md |-- progress.json |-- fix-log.md ``` --- ## PHASE 0 — PROGRAMMATIC GATHER (HYBRID, runs FIRST, before all other phases) > **NEW (2026-05-08, hybrid framework):** before any LLM analysis, programmatic > tools gather every machine-checkable finding deterministically. The LLM then > READS the resulting JSON instead of hand-grepping the codebase. Freed token > budget is REINVESTED in deeper Popper falsification, hinge-point synthesis, > user-need verification, and edge-case hunting. ### 0.1 Run the gather script (mandatory, FIRST step) ```bash ~/.omega/lib/audit-runner.sh data "$PROJECT_PATH" \ --files="$FILES_MODIFIED" \ --url="$URL" \ --user-need="$USER_NEED_QUOTE" \ --hinge="$HINGE_POINT" \ --ticket="$TICKET_ID" ``` This invokes `~/.omega/lib/audit-gather/data.sh` which runs: Convex schema parse, Prisma validate + format-check, Drizzle/TypeORM/Mongoose schema scanner, migration directory inventory, SQL file scanner with CREATE TABLE/INDEX counts, SQLite integrity_check, TypeScript type/interface inventory Output is written to: ``` $PROJECT_PATH/audits/.dataaudit/ ├── raw/ # raw tool outputs (JSON / text per tool) └── evidence-summary.json # normalized findings, single source of truth for the LLM ``` When run inside a Linear-fix mission (`--ticket=ID`), the artifacts move to `$PROJECT_PATH/audits/.linear-fix/<ID>/.dataaudit/` so multiple audits on the same ticket can cross-reference each other (see 0.5). ### 0.2 evidence-summary.json schema ```jsonc { "audit": "data", "tools_run": ["..."], "tools_skipped": [{"tool": "...", "reason": "..."}], "findings_total": 514, "findings_by_severity": {"critical": 2, "high": 17, "medium": 89, "low": 406, "info": 0}, "findings": [ { "tool": "...", "severity": "critical|high|medium|low|info", "location": "file:line[:col]", "rule": "...", "message": "...", "suggested_fix": "...", "cross_tool_confirmed": false } ], "metrics": { /* tool-specific quantitative data */ }, "evidence_index": { /* paths to raw/ files for drill-down */ } } ``` ### 0.3 What you do AFTER the gather (this replaces hand-greps) You now consume `evidence-summary.json` programmatically. You MUST: 1. **Read `evidence-summary.json` in full.** This is your evidence base. 2. **Read 3-5 critical files only** — the ones flagged as load-bearing in `~/.omega/state/hinge-points-<ticket>.json` (or computed via `${OMEGA_DIR:-$HOME/.omega}/skills/audits/_shared/hinge-analyzer.sh` if no ticket). 3. **DO NOT manually grep the codebase for what the gather already covered.** The tools have already exhaustively scanned every file. Re-running grep wastes tokens and produces the same evidence. 4. **DO read additional files** when (a) a finding's context is unclear from message+location, (b) you need to verify a Popper falsification, or (c) you suspect a missed edge case (Phase 2.4 below). ### 0.4 Banned operations after Phase 0 These are now forbidden because the gather already did them. If you catch yourself about to run one, STOP and read `evidence-summary.json` first: - ❌ `grep -rn "TODO" .` (the gather scanned for it) - ❌ `find . -name "*.ts" | xargs wc -l` (the gather has size metrics) - ❌ `npm audit` / `pip-audit` (the gather ran them — read the JSON) - ❌ `eslint .` / `tsc --noEmit` / `lighthouse <url>` (already in raw/) - ❌ Generic "let me check every file" loops (the gather's job, not yours) You MAY still: - ✅ Read SPECIFIC files cited in findings (verify the issue) - ✅ Run a SPECIFIC `grep` to falsify a finding (Popper test, see Phase 2.1) - ✅ Run a SPECIFIC tool the gather couldn't (e.g. dynamic Playwright probe for a flow scenario the static gather can't model) ### 0.5 Cross-audit synthesis (read sibling evidence-summary.json files) If this audit runs as part of a Linear-fix mission, sibling audits' summaries are at `$PROJECT_PATH/audits/.linear-fix/<TICKET>/.<other-audit-id>/evidence-summary.json`. Read them. Use them. Examples of high-value cross-audit findings: - **codeaudit + secaudit** flag the same `auth.ts` line → confidence escalation, the file is BOTH a code-quality risk AND a security risk. - **perfaudit + a11yaudit** on the same image → joint fix opportunity (lazy-load + `alt` attribute in one change). - **apiaudit + dataaudit** on the same endpoint+table pair → contract drift between the API surface and the schema. - **debugaudit + flowaudit** report the same broken page → user-flow blocker. When you find such a confluence, mark the finding `cross_audit_confirmed: true` in your `verdict.json` and bump severity by one level. --- ## PHASE 0: RECONNAISSANCE > *"Know the data model before diagnosing its diseases."* ``` 1. PROJECT DISCOVERY -> Read CLAUDE.md, README, schema files -> Identify: database type (SQL/NoSQL/Convex/Supabase/Firebase) -> Find: ORM/query layer, migration tool, backup strategy 2. SCHEMA DISCOVERY -> Extract complete schema (all tables/collections) -> Map all relationships (foreign keys, references, embedded docs) -> Document all indexes -> Identify schema version and migration state 3. DATA PROFILE -> Row/document counts per table/collection -> Date ranges (oldest record, newest record) -> Null percentages per column -> Distinct value counts for key columns -> This becomes the "before" for comparison ``` --- ## PHASE 1: SCHEMA VALIDATION > *"The schema is the contract. Violations are breaches."* ``` 1. SCHEMA vs CODE -> Schema definitions match TypeScript/Python types -> All code-referenced columns/fields exist in schema -> No schema columns unused by any code path -> Enums in schema match enums in code 2. SCHEMA CONSTRAINTS -> NOT NULL constraints on required fields -> UNIQUE constraints where business logic demands uniqueness -> CHECK constraints for valid ranges/formats -> DEFAULT values appropriate and consistent 3. SCHEMA NAMING -> Consistent naming convention (snake_case vs camelCase) -> Table/collection names are plural or singular (not mixed) -> Foreign key columns named consistently ({table}_id) -> Boolean columns prefixed (is_, has_, can_) 4. CONVEX-SPECIFIC (if applicable) -> Schema defined in schema.ts with proper validators -> All tables in schema file (no ad-hoc table creation) -> Indexes defined for all query patterns -> Union types properly discriminated ``` --- ## PHASE 2: MIGRATION STATUS > *"A migration that ran is not a migration that succeeded."* ``` 1. MIGRATION COMPLETENESS -> All migrations applied in order -> No pending migrations -> No failed/stuck migrations -> Migration history matches schema state 2. DATA BACKFILL -> New columns have been backfilled for existing records -> Default values applied to historical data -> Renamed columns: old data migrated to new columns -> Removed columns: dependent code updated 3. MIGRATION SAFETY -> Destructive migrations have rollback path -> Column drops preceded by deprecation period -> Table renames have redirects/aliases -> Large data migrations batched (not single transaction) 4. MIGRATION TESTING -> Migrations tested against production-like data volume -> Migration time estimated for production -> Lock contention assessed for large tables ``` --- ## PHASE 3: ORPHANED RECORDS (PART OF THE HINGE) > *"An orphan record is data without a home. It takes up space, causes errors, and nobody claims it."* ``` FOR EVERY relationship in the schema: 1. FORWARD REFERENCES -> Every foreign key points to an existing record -> Count orphans: records where reference_id exists but referenced record doesn't -> Identify: when were orphans created (timestamps) -> Root cause: missing cascade delete? Race condition? Bug? 2. BACKWARD REFERENCES -> Records that SHOULD have children but don't (empty collections) -> Users without profiles, Orders without items, etc. -> Are these valid (new records) or data loss (deletions that missed children)? 3. FILE/STORAGE REFERENCES -> Every file URL in database points to an existing file -> Every stored file has a database record referencing it -> Storage bloat: files without references (abandoned uploads) 4. SOFT-DELETE ORPHANS -> Soft-deleted parent still referenced by active children -> Soft-deleted records not filtered in all queries -> Restore path works (undelete doesn't create new orphans) FALSIFY: For EVERY foreign key/reference field, run a LEFT JOIN/lookup where the referenced record is NULL. Any result > 0 = orphans exist. ``` --- ## PHASE 4: REFERENTIAL INTEGRITY (PART OF THE HINGE) > *"If A references B, B must exist. Always. Without exception. This is not negotiable."* ``` 1. FOREIGN KEY ENFORCEMENT -> Foreign keys defined at database level (not just application) -> All reference columns have FK constraints (or equivalent) -> FK constraints match the actual relationships in code 2. CROSS-TABLE CONSISTENCY -> Aggregates match detail records (order_total = SUM(items)) -> Counts match reality (user.post_count = COUNT(posts WHERE user_id)) -> Statuses consistent (order.status matches latest order_event) 3. TEMPORAL CONSISTENCY -> created_at <= updated_at (always) -> Child records not created before parent -> Sequential records in correct order -> No future timestamps (except scheduled events) 4. BUSINESS RULE INTEGRITY -> Business invariants hold in actual data -> Unique-per-context rules respected (one active subscription per user) -> Mutually exclusive states not both true -> Required relationships present (every order has at least one item) FALSIFY: Write queries to check EVERY business invariant. If any returns rows, referential integrity is broken. ``` --- ## PHASE 5: DATA CONSISTENCY > *"Same data, two places, two different values. Which one is right? Nobody knows."*
Voir sur GitHub
Ce SKILL.md est tres volumineux, SkillsMP affiche donc ici seulement la premiere section. Voir sur GitHub