oh-my-agent-commandcode 0.0.0-stage → 20.38.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/filter-test-output.sh +52 -0
- package/mods/oma.ts +347 -0
- package/package.json +30 -4
- package/skills/_shared/conditional/experiment-ledger.md +28 -0
- package/skills/_shared/conditional/exploration-loop.md +22 -0
- package/skills/_shared/conditional/quality-score.md +33 -0
- package/skills/_shared/core/anti-ai-prose.md +191 -0
- package/skills/_shared/core/api-contracts/README.md +28 -0
- package/skills/_shared/core/api-contracts/template.md +90 -0
- package/skills/_shared/core/clarification-protocol.md +23 -0
- package/skills/_shared/core/code-intelligence.md +46 -0
- package/skills/_shared/core/collaboration-policy.md +28 -0
- package/skills/_shared/core/common-checklist.md +28 -0
- package/skills/_shared/core/context-budget.md +22 -0
- package/skills/_shared/core/context-loading.md +34 -0
- package/skills/_shared/core/difficulty-guide.md +26 -0
- package/skills/_shared/core/execution-policy.md +31 -0
- package/skills/_shared/core/lessons-learned.md +33 -0
- package/skills/_shared/core/prompt-structure.md +18 -0
- package/skills/_shared/core/quality-principles.md +11 -0
- package/skills/_shared/core/session-metrics.md +35 -0
- package/skills/_shared/core/skill-routing.md +39 -0
- package/skills/_shared/core/test-approach.md +54 -0
- package/skills/_shared/core/vendor-detection.md +52 -0
- package/skills/_shared/runtime/memory-protocol.md +118 -0
- package/skills/_shared/runtime/result-contract.md +64 -0
- package/skills/_shared/ui-interaction-quality.md +133 -0
- package/skills/oma-academic-writing/SKILL.md +181 -0
- package/skills/oma-academic-writing/resources/abstract-guide.md +51 -0
- package/skills/oma-academic-writing/resources/academic-verb-tiers.md +42 -0
- package/skills/oma-academic-writing/resources/anti-ai-checklist.md +52 -0
- package/skills/oma-academic-writing/resources/hedging-guide.md +132 -0
- package/skills/oma-academic-writing/resources/sentence-structure-reference.md +151 -0
- package/skills/oma-architecture/SKILL.md +203 -0
- package/skills/oma-architecture/resources/api-evolution.md +41 -0
- package/skills/oma-architecture/resources/checklist.md +42 -0
- package/skills/oma-architecture/resources/execution-protocol.md +115 -0
- package/skills/oma-architecture/resources/methodology-selection.md +92 -0
- package/skills/oma-architecture/resources/migration-patterns.md +28 -0
- package/skills/oma-architecture/resources/output-templates.md +111 -0
- package/skills/oma-architecture/resources/stakeholder-synthesis.md +80 -0
- package/skills/oma-backend/SKILL.md +202 -0
- package/skills/oma-backend/resources/checklist.md +45 -0
- package/skills/oma-backend/resources/error-playbook.md +97 -0
- package/skills/oma-backend/resources/execution-protocol.md +39 -0
- package/skills/oma-backend/resources/orm-reference.md +61 -0
- package/skills/oma-backend/variants/node/api-template.ts +315 -0
- package/skills/oma-backend/variants/node/snippets.md +475 -0
- package/skills/oma-backend/variants/node/stack.yaml +21 -0
- package/skills/oma-backend/variants/node/tech-stack.md +33 -0
- package/skills/oma-backend/variants/python/api-template.py +378 -0
- package/skills/oma-backend/variants/python/snippets.md +199 -0
- package/skills/oma-backend/variants/python/stack.yaml +18 -0
- package/skills/oma-backend/variants/python/tech-stack.md +45 -0
- package/skills/oma-backend/variants/rust/api-template.rs +635 -0
- package/skills/oma-backend/variants/rust/snippets.md +471 -0
- package/skills/oma-backend/variants/rust/stack.yaml +20 -0
- package/skills/oma-backend/variants/rust/tech-stack.md +36 -0
- package/skills/oma-backend/variants/stack.schema.json +73 -0
- package/skills/oma-brainstorm/SKILL.md +166 -0
- package/skills/oma-brainstorm/resources/triz-lite.md +117 -0
- package/skills/oma-coordination/SKILL.md +171 -0
- package/skills/oma-db/SKILL.md +201 -0
- package/skills/oma-db/resources/anti-patterns.md +177 -0
- package/skills/oma-db/resources/checklist.md +67 -0
- package/skills/oma-db/resources/document-templates.md +107 -0
- package/skills/oma-db/resources/error-playbook.md +50 -0
- package/skills/oma-db/resources/examples.md +170 -0
- package/skills/oma-db/resources/execution-protocol.md +127 -0
- package/skills/oma-db/resources/iso-controls.md +98 -0
- package/skills/oma-db/resources/migration-playbook.md +93 -0
- package/skills/oma-db/resources/query-tuning.md +57 -0
- package/skills/oma-db/resources/vector-db.md +159 -0
- package/skills/oma-debug/SKILL.md +146 -0
- package/skills/oma-debug/resources/bug-report-template.md +327 -0
- package/skills/oma-debug/resources/checklist.md +31 -0
- package/skills/oma-debug/resources/common-patterns.md +734 -0
- package/skills/oma-debug/resources/debugging-checklist.md +364 -0
- package/skills/oma-debug/resources/error-playbook.md +94 -0
- package/skills/oma-debug/resources/execution-protocol.md +40 -0
- package/skills/oma-design/SKILL.md +135 -0
- package/skills/oma-design/resources/asset-strategy.md +34 -0
- package/skills/oma-design/resources/checklist.md +63 -0
- package/skills/oma-design/resources/data-grid.md +48 -0
- package/skills/oma-design/resources/design-md-spec.md +107 -0
- package/skills/oma-design/resources/design-tokens.md +53 -0
- package/skills/oma-design/resources/error-playbook.md +18 -0
- package/skills/oma-design/resources/execution-protocol.md +95 -0
- package/skills/oma-design/resources/external-design-skills.md +130 -0
- package/skills/oma-design/resources/getdesign-fetcher.md +104 -0
- package/skills/oma-design/resources/product-interface-review.md +59 -0
- package/skills/oma-design/resources/redesign-protocol.md +52 -0
- package/skills/oma-design/resources/stitch-integration.md +244 -0
- package/skills/oma-dev-workflow/SKILL.md +375 -0
- package/skills/oma-dev-workflow/resources/affected-checks.py +58 -0
- package/skills/oma-dev-workflow/resources/api-workflows.md +58 -0
- package/skills/oma-dev-workflow/resources/database-patterns.md +107 -0
- package/skills/oma-dev-workflow/resources/i18n-patterns.md +63 -0
- package/skills/oma-dev-workflow/resources/release-coordination.md +240 -0
- package/skills/oma-dev-workflow/resources/tooling-profiles.md +217 -0
- package/skills/oma-dev-workflow/resources/troubleshooting.md +78 -0
- package/skills/oma-dev-workflow/resources/validation-pipeline.md +246 -0
- package/skills/oma-docs/SKILL.md +77 -0
- package/skills/oma-docs/resources/commands.md +76 -0
- package/skills/oma-explanation/SKILL.md +212 -0
- package/skills/oma-explanation/resources/document-structure.md +115 -0
- package/skills/oma-explanation/resources/draft-format.md +199 -0
- package/skills/oma-explanation/resources/html-contract.md +102 -0
- package/skills/oma-frontend/SKILL.md +227 -0
- package/skills/oma-frontend/resources/angular-rules.md +110 -0
- package/skills/oma-frontend/resources/checklist.md +76 -0
- package/skills/oma-frontend/resources/error-playbook.md +125 -0
- package/skills/oma-frontend/resources/execution-protocol.md +46 -0
- package/skills/oma-frontend/resources/snippets.md +354 -0
- package/skills/oma-frontend/resources/specialized-visual-implementation.md +193 -0
- package/skills/oma-frontend/resources/tailwind-rules.md +83 -0
- package/skills/oma-frontend/resources/tech-stack.md +156 -0
- package/skills/oma-hwp/SKILL.md +166 -0
- package/skills/oma-hwp/config/hwp-config.yaml +35 -0
- package/skills/oma-hwp/resources/balanced-tables.ts +39 -0
- package/skills/oma-hwp/resources/execution-protocol.md +145 -0
- package/skills/oma-hwp/resources/flatten-tables.ts +101 -0
- package/skills/oma-hwp/resources/package.json +13 -0
- package/skills/oma-hwp/resources/troubleshooting.md +70 -0
- package/skills/oma-hwp/resources/tsconfig.json +10 -0
- package/skills/oma-hwp/resources/turndown-plugin-gfm.d.ts +9 -0
- package/skills/oma-image/SKILL.md +142 -0
- package/skills/oma-image/config/image-config.yaml +70 -0
- package/skills/oma-image/resources/checklist.md +18 -0
- package/skills/oma-image/resources/execution-protocol.md +117 -0
- package/skills/oma-image/resources/invocation.md +105 -0
- package/skills/oma-image/resources/prompt-tips.md +71 -0
- package/skills/oma-image/resources/vendor-matrix.md +90 -0
- package/skills/oma-market/SKILL.md +142 -0
- package/skills/oma-market/resources/checklist.md +12 -0
- package/skills/oma-market/resources/error-playbook.md +12 -0
- package/skills/oma-market/resources/execution-protocol.md +60 -0
- package/skills/oma-market/resources/frameworks/pestel.md +101 -0
- package/skills/oma-market/resources/frameworks/porters-5f.md +90 -0
- package/skills/oma-market/resources/frameworks/swot.md +61 -0
- package/skills/oma-market/resources/intent-rules.md +35 -0
- package/skills/oma-market/resources/output-laws.md +53 -0
- package/skills/oma-mobile/SKILL.md +168 -0
- package/skills/oma-mobile/resources/checklist.md +77 -0
- package/skills/oma-mobile/resources/error-playbook.md +198 -0
- package/skills/oma-mobile/resources/execution-protocol.md +47 -0
- package/skills/oma-mobile/resources/screen-template.dart +331 -0
- package/skills/oma-mobile/resources/screen-template.swift +239 -0
- package/skills/oma-mobile/resources/screen-template.tsx +179 -0
- package/skills/oma-mobile/resources/tech-stack.md +69 -0
- package/skills/oma-mobile/variants/README.md +45 -0
- package/skills/oma-mobile/variants/flutter/api-template.dart +461 -0
- package/skills/oma-mobile/variants/flutter/snippets.md +1353 -0
- package/skills/oma-mobile/variants/flutter/stack.yaml +21 -0
- package/skills/oma-mobile/variants/flutter/tech-stack.md +201 -0
- package/skills/oma-mobile/variants/kotlin-android/api-template.kt +182 -0
- package/skills/oma-mobile/variants/kotlin-android/snippets.md +871 -0
- package/skills/oma-mobile/variants/kotlin-android/stack.yaml +32 -0
- package/skills/oma-mobile/variants/kotlin-android/tech-stack.md +159 -0
- package/skills/oma-mobile/variants/react-native/api-template.ts +531 -0
- package/skills/oma-mobile/variants/react-native/snippets.md +1014 -0
- package/skills/oma-mobile/variants/react-native/stack.yaml +22 -0
- package/skills/oma-mobile/variants/react-native/tech-stack.md +192 -0
- package/skills/oma-mobile/variants/stack.schema.json +68 -0
- package/skills/oma-mobile/variants/swift-ios/api-template.swift +165 -0
- package/skills/oma-mobile/variants/swift-ios/snippets.md +1028 -0
- package/skills/oma-mobile/variants/swift-ios/stack.yaml +25 -0
- package/skills/oma-mobile/variants/swift-ios/tech-stack.md +174 -0
- package/skills/oma-observability/SKILL.md +225 -0
- package/skills/oma-observability/resources/anti-patterns.md +555 -0
- package/skills/oma-observability/resources/boundaries/cross-application.md +348 -0
- package/skills/oma-observability/resources/boundaries/multi-tenant.md +290 -0
- package/skills/oma-observability/resources/boundaries/release.md +372 -0
- package/skills/oma-observability/resources/boundaries/slo.md +225 -0
- package/skills/oma-observability/resources/checklist.md +123 -0
- package/skills/oma-observability/resources/examples.md +448 -0
- package/skills/oma-observability/resources/execution-protocol.md +166 -0
- package/skills/oma-observability/resources/incident-forensics.md +348 -0
- package/skills/oma-observability/resources/intent-rules.md +307 -0
- package/skills/oma-observability/resources/layers/L3-network.md +281 -0
- package/skills/oma-observability/resources/layers/L4-transport.md +299 -0
- package/skills/oma-observability/resources/layers/L7-application/crash-analytics.md +359 -0
- package/skills/oma-observability/resources/layers/L7-application/mobile-rum.md +278 -0
- package/skills/oma-observability/resources/layers/L7-application/waf.md +246 -0
- package/skills/oma-observability/resources/layers/L7-application/web-rum.md +350 -0
- package/skills/oma-observability/resources/layers/mesh.md +368 -0
- package/skills/oma-observability/resources/matrix.md +177 -0
- package/skills/oma-observability/resources/meta-observability.md +605 -0
- package/skills/oma-observability/resources/observability-as-code.md +666 -0
- package/skills/oma-observability/resources/signals/audit.md +310 -0
- package/skills/oma-observability/resources/signals/cost.md +303 -0
- package/skills/oma-observability/resources/signals/logs.md +263 -0
- package/skills/oma-observability/resources/signals/metrics.md +478 -0
- package/skills/oma-observability/resources/signals/privacy.md +351 -0
- package/skills/oma-observability/resources/signals/profiles.md +245 -0
- package/skills/oma-observability/resources/signals/traces.md +360 -0
- package/skills/oma-observability/resources/standards.md +214 -0
- package/skills/oma-observability/resources/transport/collector-topology.md +308 -0
- package/skills/oma-observability/resources/transport/otlp-grpc-vs-http.md +256 -0
- package/skills/oma-observability/resources/transport/sampling-recipes.md +297 -0
- package/skills/oma-observability/resources/transport/udp-statsd-mtu.md +167 -0
- package/skills/oma-observability/resources/vendor-categories.md +352 -0
- package/skills/oma-orchestration/SKILL.md +302 -0
- package/skills/oma-orchestration/config/cli-config.yaml +92 -0
- package/skills/oma-orchestration/resources/memory-schema.md +232 -0
- package/skills/oma-orchestration/resources/subagent-prompt-template.md +30 -0
- package/skills/oma-orchestration/scripts/parallel-run.sh +6 -0
- package/skills/oma-orchestration/scripts/spawn-agent.sh +5 -0
- package/skills/oma-orchestration/scripts/verify.sh +20 -0
- package/skills/oma-orchestration/templates/backend-task.md +19 -0
- package/skills/oma-orchestration/templates/debug-task.md +16 -0
- package/skills/oma-orchestration/templates/frontend-task.md +18 -0
- package/skills/oma-orchestration/templates/mobile-task.md +18 -0
- package/skills/oma-orchestration/templates/qa-task.md +16 -0
- package/skills/oma-orchestration/templates/tasks-example.yaml +15 -0
- package/skills/oma-pdf/SKILL.md +162 -0
- package/skills/oma-pdf/config/pdf-config.yaml +27 -0
- package/skills/oma-pdf/resources/execution-protocol.md +127 -0
- package/skills/oma-pm/SKILL.md +157 -0
- package/skills/oma-pm/resources/error-playbook.md +75 -0
- package/skills/oma-pm/resources/examples.md +439 -0
- package/skills/oma-pm/resources/execution-protocol.md +62 -0
- package/skills/oma-pm/resources/iso-planning.md +110 -0
- package/skills/oma-pm/resources/plan-phase-protocol.md +66 -0
- package/skills/oma-pm/resources/task-template.json +86 -0
- package/skills/oma-qa/SKILL.md +141 -0
- package/skills/oma-qa/resources/checklist.md +339 -0
- package/skills/oma-qa/resources/error-playbook.md +98 -0
- package/skills/oma-qa/resources/execution-protocol.md +169 -0
- package/skills/oma-qa/resources/iso-quality.md +82 -0
- package/skills/oma-qa/resources/verify-ship-protocol.md +116 -0
- package/skills/oma-recap/SKILL.md +245 -0
- package/skills/oma-recap/resources/output-formats.md +83 -0
- package/skills/oma-refactor/SKILL.md +184 -0
- package/skills/oma-refactor/resources/definition.md +108 -0
- package/skills/oma-refactor/resources/governance.md +33 -0
- package/skills/oma-refactor/resources/hotspots.py +44 -0
- package/skills/oma-refactor/resources/measurement.md +93 -0
- package/skills/oma-scholar/SKILL.md +276 -0
- package/skills/oma-scholar/config/scholar-config.yaml +79 -0
- package/skills/oma-scholar/resources/api-endpoints.md +174 -0
- package/skills/oma-scholar/resources/checklist.md +92 -0
- package/skills/oma-scholar/resources/execution-protocol.md +224 -0
- package/skills/oma-scholar/resources/fallback-providers.md +143 -0
- package/skills/oma-scholar/resources/setup-openalex.md +85 -0
- package/skills/oma-scholar/resources/sidecar-spec.md +341 -0
- package/skills/oma-scholar/resources/upstream-spec-cache.md +972 -0
- package/skills/oma-scm/SKILL.md +103 -0
- package/skills/oma-scm/resources/cm-operations.md +56 -0
- package/skills/oma-scm/resources/codeowners-playbook.md +45 -0
- package/skills/oma-scm/resources/conventional-commits.md +108 -0
- package/skills/oma-scm/resources/merge-risk.md +76 -0
- package/skills/oma-scm/resources/onboarding-risk-signals.md +71 -0
- package/skills/oma-search/SKILL.md +125 -0
- package/skills/oma-search/resources/checklist.md +36 -0
- package/skills/oma-search/resources/error-playbook.md +66 -0
- package/skills/oma-search/resources/examples.md +80 -0
- package/skills/oma-search/resources/execution-protocol.md +86 -0
- package/skills/oma-search/resources/intent-rules.md +47 -0
- package/skills/oma-search/resources/trust-registry.md +53 -0
- package/skills/oma-security/SKILL.md +172 -0
- package/skills/oma-security/resources/artex.md +108 -0
- package/skills/oma-security/resources/ci.md +134 -0
- package/skills/oma-security/resources/cisco-source.md +108 -0
- package/skills/oma-security/resources/deepsec-config.md +45 -0
- package/skills/oma-security/resources/deepsec-matchers.md +35 -0
- package/skills/oma-security/resources/deepsec-scanning.md +45 -0
- package/skills/oma-security/resources/deepsec-setup.md +41 -0
- package/skills/oma-security/resources/findings-contract.md +408 -0
- package/skills/oma-security/resources/mcp-scanning.md +122 -0
- package/skills/oma-security/resources/skill-scanning.md +106 -0
- package/skills/oma-security/resources/validation.md +71 -0
- package/skills/oma-skill-creation/SKILL.md +84 -0
- package/skills/oma-skill-creation/resources/prompt-evaluation.md +36 -0
- package/skills/oma-skill-creation/resources/ssl-lite-template.md +108 -0
- package/skills/oma-skill-creation/resources/validation-checklist.md +101 -0
- package/skills/oma-slide/SKILL.md +277 -0
- package/skills/oma-slide/resources/animation-patterns.md +245 -0
- package/skills/oma-slide/resources/assets/deck-stage.js +514 -0
- package/skills/oma-slide/resources/assets/viewport-base.css +257 -0
- package/skills/oma-slide/resources/canva-integration.md +203 -0
- package/skills/oma-slide/resources/checklist.md +46 -0
- package/skills/oma-slide/resources/design-doctrine.md +260 -0
- package/skills/oma-slide/resources/fixed-stage.md +232 -0
- package/skills/oma-slide/resources/generation-protocol.md +393 -0
- package/skills/oma-slide/resources/native-pptx.md +84 -0
- package/skills/oma-slide/resources/selection-index.json +461 -0
- package/skills/oma-slide/resources/style-presets.LICENSE +10 -0
- package/skills/oma-slide/resources/style-presets.md +520 -0
- package/skills/oma-tf-infra/SKILL.md +201 -0
- package/skills/oma-tf-infra/resources/checklist.md +53 -0
- package/skills/oma-tf-infra/resources/cost-optimization.md +574 -0
- package/skills/oma-tf-infra/resources/error-playbook.md +68 -0
- package/skills/oma-tf-infra/resources/examples.md +38 -0
- package/skills/oma-tf-infra/resources/execution-protocol.md +129 -0
- package/skills/oma-tf-infra/resources/iso-42001-infra.md +229 -0
- package/skills/oma-tf-infra/resources/multi-cloud-examples.md +241 -0
- package/skills/oma-tf-infra/resources/policy-testing-examples.md +332 -0
- package/skills/oma-translation/SKILL.md +229 -0
- package/skills/oma-translation/resources/anti-ai-patterns.md +104 -0
- package/skills/oma-translation/resources/lang/_template.md +73 -0
- package/skills/oma-translation/resources/lang/en.md +123 -0
- package/skills/oma-translation/resources/lang/ja.md +274 -0
- package/skills/oma-translation/resources/lang/ko.md +228 -0
- package/skills/oma-translation/resources/lang/zh.md +285 -0
- package/skills/oma-translation/resources/style-skills.md +104 -0
- package/skills/oma-translation/resources/translation-rubric.md +126 -0
- package/skills/oma-video/SKILL.md +229 -0
- package/skills/oma-video/config/video-config.yaml +60 -0
- package/skills/oma-video/resources/checklist.md +26 -0
- package/skills/oma-video/resources/execution-protocol.md +122 -0
- package/skills/oma-video/resources/existing-media.md +185 -0
- package/skills/oma-video/resources/hyperframes-authoring/README.md +44 -0
- package/skills/oma-video/resources/hyperframes-authoring/demo.md +31 -0
- package/skills/oma-video/resources/hyperframes-authoring/explainer.md +10 -0
- package/skills/oma-video/resources/hyperframes-authoring/shorts.md +10 -0
- package/skills/oma-video/resources/motion-principles.md +81 -0
- package/skills/oma-video/resources/mpt/driver.py +301 -0
- package/skills/oma-video/resources/prompt-tips.md +75 -0
- package/skills/oma-video/resources/script-schema.md +81 -0
- package/skills/oma-video/resources/sound-design.md +127 -0
- package/skills/oma-video/resources/strudel/package.json +11 -0
- package/skills/oma-video/resources/strudel/page.html +87 -0
- package/skills/oma-video/resources/strudel/render.mjs +295 -0
- package/skills/oma-video/resources/vendor-matrix.md +124 -0
- package/skills/oma-voice/SKILL.md +249 -0
- package/skills/oma-voice/config/voice-config.yaml +30 -0
- package/skills/oma-voice/resources/audio-processing.md +119 -0
- package/skills/oma-voice/resources/checklist.md +47 -0
- package/skills/oma-voice/resources/execution-protocol.md +215 -0
- package/skills/oma-voice/resources/prompt-tips.md +43 -0
- package/skills/oma-voice/resources/voice-matrix.md +51 -0
- package/skills/oma-voice/resources/voicestudio.md +87 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# DB Agent - Anti-Pattern Review Guide
|
|
2
|
+
|
|
3
|
+
Use this file for DB review, schema/query critique, remediation, or changes involving business logic in DB objects or ORM hooks. Review the affected scope; a query/index task does not require a database-wide inventory or rewrite.
|
|
4
|
+
|
|
5
|
+
## 1. ISO 27001 / 27002 / 22301-Oriented Suggestions
|
|
6
|
+
|
|
7
|
+
When any of the following are weak or absent, recommend improvements explicitly:
|
|
8
|
+
|
|
9
|
+
- access control and least privilege
|
|
10
|
+
- encryption in transit and at rest
|
|
11
|
+
- audit logging for privileged or sensitive data changes
|
|
12
|
+
- backup, restore drill, and retention evidence
|
|
13
|
+
- data classification and PII handling
|
|
14
|
+
- schema change management and migration traceability
|
|
15
|
+
- secure credential handling
|
|
16
|
+
- deletion and archive controls for cold data
|
|
17
|
+
- privileged access review and segregation of duties
|
|
18
|
+
- secure configuration baselines and hardening guidance
|
|
19
|
+
- business continuity planning assumptions for critical databases
|
|
20
|
+
- recovery objectives such as RTO / RPO and restore evidence
|
|
21
|
+
- failover, redundancy, and backup dependency visibility
|
|
22
|
+
|
|
23
|
+
## 2. Logical Design
|
|
24
|
+
|
|
25
|
+
- **CSV in one column**
|
|
26
|
+
- Smell: comma-separated IDs/tags/statuses stored in `VARCHAR`
|
|
27
|
+
- Fix: separate dependent table or junction table for many-to-many
|
|
28
|
+
- **Naive tree**
|
|
29
|
+
- Smell: `parent_id` only, but complex subtree queries and moves are required
|
|
30
|
+
- Fix: choose the tree model that matches the workload and relationship semantics
|
|
31
|
+
- **Surrogate-key obsession**
|
|
32
|
+
- Smell: every table gets generic `id` without regard to natural/composite identity
|
|
33
|
+
- Fix: use natural key or composite key when it models the domain better; prefer descriptive PK names like `bug_id`
|
|
34
|
+
- **Missing foreign keys**
|
|
35
|
+
- Smell: referential integrity delegated to application code
|
|
36
|
+
- Fix: add FK constraints and let the DB reject invalid references
|
|
37
|
+
- **EAV**
|
|
38
|
+
- Smell: generic `entity_id`, `attr_name`, `attr_value`
|
|
39
|
+
- Fix: use subtype modeling, JSON only when true schema flexibility is required
|
|
40
|
+
- **Polymorphic association**
|
|
41
|
+
- Smell: one FK-like column can point to multiple parent tables
|
|
42
|
+
- Fix: simplify relationships, use junction tables, or introduce a shared supertype
|
|
43
|
+
- **Repeated columns for multi-value attributes**
|
|
44
|
+
- Smell: `tag1`, `tag2`, `tag3`
|
|
45
|
+
- Fix: store one value per row in a dependent table
|
|
46
|
+
- **Metadata as schema**
|
|
47
|
+
- Smell: table names or column names encode data values such as year or tenant
|
|
48
|
+
- Fix: use partitioning, proper normalization, or vertical split
|
|
49
|
+
|
|
50
|
+
## 3. Physical Design
|
|
51
|
+
|
|
52
|
+
- **Floating-point money**
|
|
53
|
+
- Smell: `FLOAT/REAL/DOUBLE` for currency or exact quantities
|
|
54
|
+
- Fix: use `NUMERIC/DECIMAL`
|
|
55
|
+
- **Hard-coded enum in schema without governance**
|
|
56
|
+
- Smell: volatile code sets trapped inside enum/check definitions
|
|
57
|
+
- Fix: use reference tables when values are expected to evolve
|
|
58
|
+
- **Ghost file**
|
|
59
|
+
- Smell: DB stores only file path while lifecycle, backup, authorization, and restore are unmanaged
|
|
60
|
+
- Fix: use BLOB/object storage only with clear lifecycle, permissions, and backup/restore design
|
|
61
|
+
- **Index shotgun**
|
|
62
|
+
- Smell: indexes created by guesswork or duplicated heavily
|
|
63
|
+
- Fix: MENTOR the indexes:
|
|
64
|
+
- Measure
|
|
65
|
+
- Explain
|
|
66
|
+
- Nominate
|
|
67
|
+
- Test
|
|
68
|
+
- Optimize
|
|
69
|
+
- Rebuild
|
|
70
|
+
|
|
71
|
+
## 4. Query Design
|
|
72
|
+
|
|
73
|
+
- **NULL misuse**
|
|
74
|
+
- Smell: NULL treated like a normal value or fake defaults used instead of NULL
|
|
75
|
+
- Fix: use `IS NULL`, `IS NOT NULL`, `COALESCE`, and proper nullability semantics
|
|
76
|
+
- **Ambiguous grouping**
|
|
77
|
+
- Smell: non-grouped columns selected beside aggregates
|
|
78
|
+
- Fix: obey the single-value rule or rewrite with proper subqueries/window logic
|
|
79
|
+
- **Random sort**
|
|
80
|
+
- Smell: `ORDER BY RAND()` on large tables
|
|
81
|
+
- Fix: choose a sampling strategy that avoids full random sort
|
|
82
|
+
- **Poor-man's search engine**
|
|
83
|
+
- Smell: broad `%keyword%` or regex search on large text
|
|
84
|
+
- Fix: use full-text indexing or a dedicated search engine
|
|
85
|
+
- **Spaghetti query**
|
|
86
|
+
- Smell: forcing every rule into one giant SQL statement
|
|
87
|
+
- Fix: split into stages or multiple queries when it improves correctness and maintainability
|
|
88
|
+
- **Implicit columns**
|
|
89
|
+
- Smell: `SELECT *` in production paths
|
|
90
|
+
- Fix: list required columns explicitly
|
|
91
|
+
|
|
92
|
+
## 5. Application Integration
|
|
93
|
+
|
|
94
|
+
### Application Ownership Policy
|
|
95
|
+
|
|
96
|
+
Strongly recommend managing business decisions, workflow orchestration, and external side effects explicitly in application domain/services and jobs. Apply this recommendation to **new and existing** implementations, including triggers, stored procedures, stored functions, views, DB events/schedulers, and ORM hooks/entity listeners. This is a design default, not a blanket ban on those mechanisms.
|
|
97
|
+
|
|
98
|
+
For each affected existing implementation, identify its callers and writers, explain the risk, recommend a concrete replacement, and state the transition priority. Existing usage or convention alone is not a reason to retain it. If retention is justified, record the application alternative, the technical reason (such as atomicity across writers, measured performance, or audit requirements), and the relevant tests, privileges, deployment, and recovery approach. Recommend a staged transition when replacement is appropriate; implementation remains within the authorized scope.
|
|
99
|
+
|
|
100
|
+
### Patterns to Improve
|
|
101
|
+
|
|
102
|
+
| Pattern and failure mechanism | Strongly recommended alternative |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| Business policy in triggers, procedures, functions, views, or large `CASE` expressions: pricing, fees, eligibility, visibility, and approval rules become duplicated or tied to DB deployments | Give the policy an application owner and tests; version changing policies with effective dates and record the version/inputs used for decisions that must be reproduced |
|
|
105
|
+
| Implicit workflow: setting a status or saving an entity silently triggers payment, approval, shipment, or chained writes | Use explicit commands, validated state transitions, and service orchestration; moving the same hidden behavior into ORM hooks is not an improvement |
|
|
106
|
+
| External I/O inside DB execution, or a DB commit followed by an independent broker/API write: failures leave partial effects that rollback cannot undo | Record the integration event in an outbox in the same transaction as business data; publish through a worker with idempotency and bounded retry, and define compensation for partial external success |
|
|
107
|
+
| Business scheduling in DB events/jobs without execution ownership: settlement, expiry, and notifications lack retry limits, checkpoints, or failure visibility | Manage execution in an application job/workflow with observable runs and recovery; validate deadlines at action time rather than trusting a delayed expiry batch |
|
|
108
|
+
| Trigger-driven cache/search synchronization or cross-system projections without replay/reconciliation | Use explicit events or CDC with consumer deduplication, ordering requirements, lag monitoring, replay, and reconciliation |
|
|
109
|
+
| Policy bypass through multiple writers or procedures that modify another service's tables | Identify API, batch, admin, import, and direct SQL writers; align write permissions and policy enforcement, and use the owning service's API/events across service boundaries |
|
|
110
|
+
| Cascading deletion of independently owned objects or trigger-driven soft delete without retention/restore rules | Manage deletion intent, authorization, retention, and restoration in the application; define explicit coordination across ownership boundaries |
|
|
111
|
+
| Business authorization and audit context hidden in DB session state or routines | Give business authorization and action intent an application owner; propagate verified actor/tenant context and record decision reasons, while preserving DB enforcement and DB change/access audit |
|
|
112
|
+
|
|
113
|
+
### Database Responsibilities to Preserve
|
|
114
|
+
|
|
115
|
+
- Keep declarative integrity (`PK`, `FK`, `UNIQUE`, `CHECK`, `NOT NULL`, and exclusion constraints where supported), atomic conditional updates, transaction boundaries, isolation, and locking. Application prechecks alone cannot enforce invariants under concurrent or independent writes.
|
|
116
|
+
- Preserve RLS and DB privileges where they enforce access restrictions; RLS can be the primary enforcement point. Verify the connection roles, bypass privileges, and actor/tenant context rather than replacing RLS with application filtering.
|
|
117
|
+
- Keep DB access/change audit where required. Application business audit does not cover every direct SQL, administrator, or batch change. Audit triggers can be justified, but their coverage and privileged bypass limits must be explicit.
|
|
118
|
+
- `ON DELETE CASCADE` can be appropriate for dependent components with the same lifecycle. Flag cascades across independent ownership or retention boundaries, rather than treating every cascade as an anti-pattern.
|
|
119
|
+
- Keep efficient joins, aggregates, pure SQL functions/views, generated values, and set-based bulk operations in the DB where appropriate. Application ownership of a job does not require fetching all rows into an application loop. DB-local summaries or routines may be retained with correctness and performance evidence.
|
|
120
|
+
- Backup, replication, vacuum/statistics, partition maintenance, and storage TTL remain database operations. Separate physical cleanup from business expiry and retention decisions.
|
|
121
|
+
- CDC transports committed changes; it does not automatically supply the business intent of a domain event. An application can write an outbox and use CDC to publish it. Neither approach removes the need to handle duplicates, ordering, or consumer recovery.
|
|
122
|
+
|
|
123
|
+
For an accepted transition, use `resources/migration-playbook.md` §Moving Business Logic into the Application. Preserve all writers and invariants, and prevent the old and new paths from executing the same external effect twice.
|
|
124
|
+
|
|
125
|
+
### Other Integration Anti-Patterns
|
|
126
|
+
|
|
127
|
+
- **Readable passwords**
|
|
128
|
+
- Smell: plaintext or reversibly encrypted passwords
|
|
129
|
+
- Fix: salted one-way hash, secure transport, no password recovery by disclosure
|
|
130
|
+
- **SQL injection**
|
|
131
|
+
- Smell: unchecked input concatenated into SQL
|
|
132
|
+
- Fix: parameterized queries, allowlists for dynamic clauses, code review
|
|
133
|
+
- **Surrogate-key gap paranoia**
|
|
134
|
+
- Smell: trying to fill deleted ID gaps
|
|
135
|
+
- Fix: treat surrogate keys as identifiers, not row numbers
|
|
136
|
+
- **Ignoring DB return values and executed SQL**
|
|
137
|
+
- Smell: no error handling or no visibility into actual SQL
|
|
138
|
+
- Fix: inspect execution results, logs, and emitted SQL
|
|
139
|
+
- **SQL exempt from engineering discipline**
|
|
140
|
+
- Smell: no version control, no tests, no review, no documentation
|
|
141
|
+
- Fix: treat DB artifacts like code
|
|
142
|
+
- **Active Record leakage**
|
|
143
|
+
- Smell: controllers calling persistence methods directly
|
|
144
|
+
- Fix: keep service/repository boundaries and avoid mixing UI flow with DB access
|
|
145
|
+
|
|
146
|
+
## 6. Vector Retrieval / RAG
|
|
147
|
+
|
|
148
|
+
- **Treating vector DB as a drop-in search replacement**
|
|
149
|
+
- Smell: lexical search removed entirely after adding embeddings
|
|
150
|
+
- Fix: default to hybrid retrieval; combine keyword/BM25, metadata filters, ANN, and reranking
|
|
151
|
+
- **Embedding everything without a versioning strategy**
|
|
152
|
+
- Smell: multiple models/dimensions/chunk rules with no metadata or migration plan
|
|
153
|
+
- Fix: version embeddings like schema, store model/config metadata, and support rolling re-embedding
|
|
154
|
+
- **Ignoring chunking strategy**
|
|
155
|
+
- Smell: fixed-size chunks and naive splitting regardless of document structure
|
|
156
|
+
- Fix: use document-aware chunking, overlap, and hierarchical structure where needed
|
|
157
|
+
- **Blind ANN defaults**
|
|
158
|
+
- Smell: HNSW/IVF/PQ defaults used without recall-latency benchmarking
|
|
159
|
+
- Fix: benchmark real workloads and tune ANN parameters deliberately
|
|
160
|
+
- **Assuming metadata filtering scales for free**
|
|
161
|
+
- Smell: high-cardinality filters piled onto vector search with no partition strategy
|
|
162
|
+
- Fix: design pre-segmentation, partitioned indexes, or tenant-specific collections where justified
|
|
163
|
+
- **Unplanned real-time writes**
|
|
164
|
+
- Smell: continuous inserts degrade recall and latency over time
|
|
165
|
+
- Fix: design buffers, compaction, tiered indexing, and ingestion/search separation
|
|
166
|
+
- **Storing raw documents in vector DB**
|
|
167
|
+
- Smell: vector DB becomes source of truth for full documents
|
|
168
|
+
- Fix: keep canonical docs in object store or primary DB and store references in vector DB
|
|
169
|
+
- **No retrieval observability**
|
|
170
|
+
- Smell: only infra metrics exist; no recall or semantic drift monitoring
|
|
171
|
+
- Fix: add golden queries, offline evaluation, drift tracking, and token-waste monitoring
|
|
172
|
+
- **Over-trusting similarity scores**
|
|
173
|
+
- Smell: one cosine threshold is treated as universally meaningful
|
|
174
|
+
- Fix: calibrate per domain/model and use reranking for precision-sensitive cases
|
|
175
|
+
- **Believing vector DB equals RAG architecture**
|
|
176
|
+
- Smell: only index layer is optimized while chunking, orchestration, and feedback loop are ignored
|
|
177
|
+
- Fix: treat retrieval as a pipeline, not a single database decision
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# DB Agent - Self-Verification Checklist
|
|
2
|
+
|
|
3
|
+
Run through every item before submitting your work.
|
|
4
|
+
|
|
5
|
+
## Modeling
|
|
6
|
+
- [ ] DB type selection justified from workload, not preference
|
|
7
|
+
- [ ] Relational models normalized to at least 3NF, or denormalization explicitly justified
|
|
8
|
+
- [ ] NoSQL models aligned to concrete access patterns and aggregate boundaries
|
|
9
|
+
- [ ] Graph model used only where variable-depth traversal or relationship-pattern queries dominate; relational adjacency preferred for shallow fixed-depth cases
|
|
10
|
+
- [ ] Vector retrieval is used only where semantic similarity is actually required
|
|
11
|
+
- [ ] Keys, cardinality, and ownership clearly defined
|
|
12
|
+
- [ ] No obvious anti-patterns remain: CSV-in-column, repeated columns, EAV, polymorphic FK, missing FK
|
|
13
|
+
|
|
14
|
+
## Schema Documentation
|
|
15
|
+
- [ ] External schema documented
|
|
16
|
+
- [ ] Conceptual schema documented
|
|
17
|
+
- [ ] Internal schema documented
|
|
18
|
+
- [ ] Naming standards and field definitions documented
|
|
19
|
+
- [ ] Glossary / terminology dictionary updated
|
|
20
|
+
|
|
21
|
+
## Integrity & Concurrency
|
|
22
|
+
- [ ] Entity, domain, referential, and business-rule integrity addressed
|
|
23
|
+
- [ ] Transaction boundaries documented
|
|
24
|
+
- [ ] Isolation level selected for critical flows
|
|
25
|
+
- [ ] Locking / optimistic concurrency strategy documented
|
|
26
|
+
- [ ] Transparency assumptions called out when using distributed systems
|
|
27
|
+
|
|
28
|
+
## Application Ownership (Affected Scope)
|
|
29
|
+
- [ ] Affected triggers, stored procedures/functions, views, DB jobs, and ORM hooks reviewed for business policy, implicit workflows, and external side effects
|
|
30
|
+
- [ ] New and existing findings receive a strong application ownership recommendation with a concrete alternative and transition priority; retained implementations have technical evidence beyond existing convention
|
|
31
|
+
- [ ] Proposed design preserves DB integrity, concurrency, RLS/privileges, audit coverage, justified dependent cascades, and efficient set-based processing
|
|
32
|
+
- [ ] Where relevant, policy versions/decision context, action-time expiry checks, and all API/batch/admin/import/direct SQL writers are addressed
|
|
33
|
+
- [ ] Integration events are committed atomically with business data when needed; CDC intent/coverage, idempotency, ordering, bounded retry, replay, and compensation are explicit
|
|
34
|
+
- [ ] Planned transitions verify policy behavior and writer coverage, use one owner per side effect, and define rollback without lost or duplicate effects
|
|
35
|
+
|
|
36
|
+
## Performance & Operations
|
|
37
|
+
- [ ] Indexes match hot queries and join/filter patterns
|
|
38
|
+
- [ ] Partitioning / sharding strategy justified if introduced
|
|
39
|
+
- [ ] Hot vs cold data separation considered
|
|
40
|
+
- [ ] Full and incremental backup strategy documented
|
|
41
|
+
- [ ] Restore test or recovery validation approach documented
|
|
42
|
+
- [ ] Query anti-patterns reviewed: `SELECT *`, random sort, ambiguous grouping, full wildcard search without proper tooling
|
|
43
|
+
- [ ] Slow-query fixes verified with before/after execution plans on production-like data (estimate vs actual rows checked)
|
|
44
|
+
- [ ] Schema changes on live tables follow expand-contract with lock-aware DDL, lock timeouts, and batched, resumable backfill
|
|
45
|
+
- [ ] Destructive (contract) steps deferred to a separate deploy after a soak window, with a final backup taken first
|
|
46
|
+
|
|
47
|
+
## Vector Retrieval
|
|
48
|
+
- [ ] Vector DB is not being used as the canonical document store
|
|
49
|
+
- [ ] Hybrid retrieval considered where exact match, explainability, or compliance filtering matter
|
|
50
|
+
- [ ] Embedding model, dimension, normalization, chunking, and version metadata documented
|
|
51
|
+
- [ ] Re-embedding / re-index migration plan exists for model or chunking changes
|
|
52
|
+
- [ ] ANN index choice and tuning parameters benchmarked on production-like data
|
|
53
|
+
- [ ] Metadata filtering behavior and high-cardinality filter impact understood
|
|
54
|
+
- [ ] Similarity score thresholds calibrated per domain or reranking added for precision-critical paths
|
|
55
|
+
- [ ] Retrieval observability defined: golden queries, recall drift, semantic drift, token waste
|
|
56
|
+
|
|
57
|
+
## Capacity
|
|
58
|
+
- [ ] Capacity sheet updated by object
|
|
59
|
+
- [ ] Tablespace/storage estimate updated
|
|
60
|
+
- [ ] Disk estimate includes online, batch, backup, and growth assumptions
|
|
61
|
+
- [ ] Data type choices reviewed for storage efficiency
|
|
62
|
+
|
|
63
|
+
## Delivery
|
|
64
|
+
- [ ] Assumptions, tradeoffs, and risks are explicit
|
|
65
|
+
- [ ] Migration impact or rollout steps included when schema changes are proposed
|
|
66
|
+
- [ ] ISO 27001 / 27002-friendly suggestions included where design affects access control, logging, encryption, backup, recovery, or change management
|
|
67
|
+
- [ ] ISO 22301-friendly suggestions included where design affects resilience, failover, restore testing, RTO, or RPO
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# DB Agent - Deliverable Templates
|
|
2
|
+
|
|
3
|
+
Use this structure when the user asks for modeling or DB architecture outputs.
|
|
4
|
+
|
|
5
|
+
## 1. Decision Summary
|
|
6
|
+
|
|
7
|
+
```md
|
|
8
|
+
## Database Decision Summary
|
|
9
|
+
- Workload type:
|
|
10
|
+
- Recommended engine/model:
|
|
11
|
+
- Reason:
|
|
12
|
+
- Consistency target:
|
|
13
|
+
- Availability target:
|
|
14
|
+
- Retention target:
|
|
15
|
+
- RPO / RTO:
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 2. Schema Documentation
|
|
19
|
+
|
|
20
|
+
```md
|
|
21
|
+
## External Schema
|
|
22
|
+
- Consumer / view:
|
|
23
|
+
- Required fields:
|
|
24
|
+
- Access pattern:
|
|
25
|
+
|
|
26
|
+
## Conceptual Schema
|
|
27
|
+
- Entity / aggregate:
|
|
28
|
+
- Description:
|
|
29
|
+
- Relationships:
|
|
30
|
+
- Cardinality:
|
|
31
|
+
|
|
32
|
+
## Internal Schema
|
|
33
|
+
- Object name:
|
|
34
|
+
- Type: table / collection / index / partition
|
|
35
|
+
- Primary key / shard key:
|
|
36
|
+
- Constraints:
|
|
37
|
+
- Access path:
|
|
38
|
+
- Storage / tablespace:
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 3. Data Standards
|
|
42
|
+
|
|
43
|
+
```md
|
|
44
|
+
| Standard Item | Value |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| Naming convention | |
|
|
47
|
+
| Definition rule | |
|
|
48
|
+
| Data type / format rule | |
|
|
49
|
+
| Allowed value rule | |
|
|
50
|
+
| Nullability rule | |
|
|
51
|
+
| Default value rule | |
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 4. Glossary
|
|
55
|
+
|
|
56
|
+
```md
|
|
57
|
+
| Term | Definition | Synonym / Forbidden Term | Owner |
|
|
58
|
+
| --- | --- | --- | --- |
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 5. Capacity Estimation
|
|
62
|
+
|
|
63
|
+
```md
|
|
64
|
+
| Object | Daily Txn | Online Workload | Batch Workload | Row / Doc Size | Growth | Retention | Primary Storage | Backup Storage |
|
|
65
|
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Add these summary sections after the table:
|
|
69
|
+
- tablespace/storage allocation
|
|
70
|
+
- disk total with growth buffer
|
|
71
|
+
- hot vs cold data split
|
|
72
|
+
- backup type and cadence
|
|
73
|
+
|
|
74
|
+
## 6. Concurrency & Integrity
|
|
75
|
+
|
|
76
|
+
```md
|
|
77
|
+
## Integrity
|
|
78
|
+
- Entity integrity:
|
|
79
|
+
- Domain integrity:
|
|
80
|
+
- Referential integrity:
|
|
81
|
+
- Business-rule integrity:
|
|
82
|
+
|
|
83
|
+
## Concurrency
|
|
84
|
+
- Critical transaction:
|
|
85
|
+
- Isolation level:
|
|
86
|
+
- Locking method:
|
|
87
|
+
- Retry / idempotency strategy:
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 7. Vector Retrieval Design
|
|
91
|
+
|
|
92
|
+
```md
|
|
93
|
+
## Vector Retrieval Design
|
|
94
|
+
- Use case:
|
|
95
|
+
- Why vector retrieval is needed:
|
|
96
|
+
- Why lexical search alone is insufficient:
|
|
97
|
+
- Hybrid retrieval approach:
|
|
98
|
+
- Canonical document store:
|
|
99
|
+
- Vector store contents:
|
|
100
|
+
- Embedding model / dimension / normalization:
|
|
101
|
+
- Chunking policy / overlap:
|
|
102
|
+
- ANN index type / key tuning params:
|
|
103
|
+
- Metadata filtering strategy:
|
|
104
|
+
- Reranking strategy:
|
|
105
|
+
- Re-embedding migration plan:
|
|
106
|
+
- Retrieval evaluation metrics:
|
|
107
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# DB Agent - Error Playbook
|
|
2
|
+
|
|
3
|
+
## Symptom: Relational model is breaking 3NF everywhere
|
|
4
|
+
- Re-check whether reporting columns, derived values, and snapshots are being mixed into OLTP tables
|
|
5
|
+
- Split transactional source-of-truth from read models or marts
|
|
6
|
+
- Keep denormalization only where query cost justifies it
|
|
7
|
+
|
|
8
|
+
## Symptom: NoSQL model keeps requiring cross-document joins
|
|
9
|
+
- Re-evaluate aggregate boundaries and access patterns
|
|
10
|
+
- If strong cross-entity consistency dominates, switch recommendation toward relational storage
|
|
11
|
+
|
|
12
|
+
## Symptom: Isolation level is unclear
|
|
13
|
+
- Start from anomaly prevention required by the business flow
|
|
14
|
+
- Document what must be prevented: dirty read, non-repeatable read, phantom, lost update
|
|
15
|
+
- Choose the lowest level that still blocks unacceptable anomalies
|
|
16
|
+
|
|
17
|
+
## Symptom: Capacity estimate is unreliable
|
|
18
|
+
- Separate online traffic, batch traffic, retention, and backup retention
|
|
19
|
+
- Estimate by object first, then aggregate to tablespace and disk totals
|
|
20
|
+
- Add growth and reindex/maintenance headroom
|
|
21
|
+
|
|
22
|
+
## Symptom: Backup plan exists but restore confidence is low
|
|
23
|
+
- Add restore drill frequency
|
|
24
|
+
- Define sample recovery scenarios and max tolerable data loss
|
|
25
|
+
- Distinguish snapshot/full backup from incremental/log-based recovery
|
|
26
|
+
|
|
27
|
+
## Symptom: Deadlocks in production
|
|
28
|
+
- Read the engine's deadlock log to identify the two lock cycles, not just the victim
|
|
29
|
+
- Enforce consistent lock ordering: all transactions touch shared tables/rows in the same order
|
|
30
|
+
- Shorten transactions: move reads, external calls, and computation outside the transaction boundary
|
|
31
|
+
- Index foreign keys involved in the cycle; unindexed FK checks escalate to scans and widen lock footprints
|
|
32
|
+
- Add bounded retry with backoff at the application layer for the surviving unavoidable cases
|
|
33
|
+
|
|
34
|
+
## Symptom: Replication lag growing
|
|
35
|
+
- Look for long-running transactions on the primary holding back apply/vacuum
|
|
36
|
+
- Check for unbatched bulk writes (backfills, cascading deletes) and throttle them per `resources/migration-playbook.md`
|
|
37
|
+
- Verify large-table DML has supporting indexes on the replica side
|
|
38
|
+
- If reads require read-your-writes, route those sessions to the primary or gate on replica LSN/GTID instead of hoping lag stays low
|
|
39
|
+
|
|
40
|
+
## Symptom: Connection pool exhausted
|
|
41
|
+
- Compare app pool size x instance count against the DB's max connections; oversubscription starves everyone
|
|
42
|
+
- Hunt leaked connections: sessions idle-in-transaction, missing release on error paths
|
|
43
|
+
- Scope sessions to the request/transaction, never to long-lived objects (see backend rule: no shared mutable ORM sessions)
|
|
44
|
+
- Front high-instance-count deployments with a server-side pooler (e.g. pgbouncer) instead of raising max connections
|
|
45
|
+
|
|
46
|
+
## Symptom: Migration failed midway
|
|
47
|
+
- Determine what actually applied: transactional DDL engines roll back cleanly; others leave partial state to inspect object-by-object
|
|
48
|
+
- Make migration steps idempotent (`IF NOT EXISTS`, guarded DML) so re-running is safe
|
|
49
|
+
- Resume batched backfills from their checkpoint rather than restarting from zero
|
|
50
|
+
- If the failure was a lock timeout, that is the playbook working: retry at a quieter window per `resources/migration-playbook.md`
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# DB Agent - Examples
|
|
2
|
+
|
|
3
|
+
## Example 1: Relational Order Management
|
|
4
|
+
|
|
5
|
+
**Input**: "Design the database for ordering, payment, shipment, and refund flows."
|
|
6
|
+
|
|
7
|
+
**Output**:
|
|
8
|
+
```md
|
|
9
|
+
## Model Choice
|
|
10
|
+
- PostgreSQL chosen for strong integrity, cross-entity transactions, and reporting joins
|
|
11
|
+
|
|
12
|
+
## Conceptual Schema
|
|
13
|
+
- Customer 1:N Order
|
|
14
|
+
- Order 1:N OrderItem
|
|
15
|
+
- Order 1:N Payment
|
|
16
|
+
- Order 1:N Shipment
|
|
17
|
+
- Order 1:N Refund
|
|
18
|
+
|
|
19
|
+
## Internal Schema
|
|
20
|
+
- orders(id PK, customer_id FK, status, ordered_at, total_amount, currency_code)
|
|
21
|
+
- order_items(id PK, order_id FK, product_id FK, qty, unit_price, line_amount)
|
|
22
|
+
- payments(id PK, order_id FK, payment_method_code, status, approved_at, amount)
|
|
23
|
+
- shipments(id PK, order_id FK, warehouse_id FK, status, shipped_at)
|
|
24
|
+
- refunds(id PK, payment_id FK, reason_code, refunded_at, amount)
|
|
25
|
+
|
|
26
|
+
## Integrity / Concurrency
|
|
27
|
+
- 3NF satisfied
|
|
28
|
+
- FKs enforce referential integrity
|
|
29
|
+
- Unique(order_id, product_id) for line uniqueness
|
|
30
|
+
- Payment capture uses READ COMMITTED with idempotency key
|
|
31
|
+
- Inventory reservation uses SELECT ... FOR UPDATE
|
|
32
|
+
|
|
33
|
+
## Operations
|
|
34
|
+
- Hot data: last 12 months in primary partition
|
|
35
|
+
- Cold data: monthly archive partitions after 12 months
|
|
36
|
+
- Daily full backup + 15-minute incremental/WAL archiving
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Example 2: NoSQL Activity Feed
|
|
40
|
+
|
|
41
|
+
**Input**: "Model a high-write social feed with fan-out reads."
|
|
42
|
+
|
|
43
|
+
**Output**:
|
|
44
|
+
```md
|
|
45
|
+
## Model Choice
|
|
46
|
+
- NoSQL chosen because feed reads follow aggregate access by user timeline and tolerate eventual consistency
|
|
47
|
+
|
|
48
|
+
## Conceptual Schema
|
|
49
|
+
- User aggregate
|
|
50
|
+
- Post aggregate
|
|
51
|
+
- TimelineEntry aggregate
|
|
52
|
+
|
|
53
|
+
## Internal Schema
|
|
54
|
+
- users collection keyed by user_id
|
|
55
|
+
- posts collection keyed by post_id
|
|
56
|
+
- timelines collection keyed by owner_user_id + created_at
|
|
57
|
+
|
|
58
|
+
## Consistency / BASE
|
|
59
|
+
- Timeline fan-out is eventually consistent
|
|
60
|
+
- Post delete creates compensating cleanup event
|
|
61
|
+
- Source-of-truth post document retained separately from denormalized timeline entry
|
|
62
|
+
|
|
63
|
+
## Optimization
|
|
64
|
+
- Partition key: owner_user_id
|
|
65
|
+
- TTL on ephemeral recommendation cache
|
|
66
|
+
- Cold feed archive after 180 days
|
|
67
|
+
- Nightly full snapshot + hourly incremental backup
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Example 3: Data Standards & Capacity Update
|
|
71
|
+
|
|
72
|
+
**Input**: "Add subscription billing and keep the glossary and sizing docs current."
|
|
73
|
+
|
|
74
|
+
**Output**:
|
|
75
|
+
```md
|
|
76
|
+
## Data Standards
|
|
77
|
+
| Name | Definition | Format | Rule |
|
|
78
|
+
| --- | --- | --- | --- |
|
|
79
|
+
| subscription_status_code | Subscription lifecycle state | VARCHAR(20) | ACTIVE, PAUSED, CANCELED only |
|
|
80
|
+
| billing_cycle_day | Day of month for billing | SMALLINT | 1-28 only |
|
|
81
|
+
|
|
82
|
+
## Glossary Additions
|
|
83
|
+
- Subscription: recurring billing agreement between customer and service
|
|
84
|
+
- Invoice: billable statement generated for a subscription cycle
|
|
85
|
+
|
|
86
|
+
## Capacity Update
|
|
87
|
+
- subscriptions: 1.2M rows / year
|
|
88
|
+
- invoices: 14.4M rows / year
|
|
89
|
+
- payments: 16M rows / year
|
|
90
|
+
- Estimated primary storage: 180 GB / year
|
|
91
|
+
- Backup storage multiplier: 2.5x including retention
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Example 4: Enterprise RAG Retrieval
|
|
95
|
+
|
|
96
|
+
**Input**: "Design a policy search platform using a vector DB for enterprise RAG."
|
|
97
|
+
|
|
98
|
+
**Output**:
|
|
99
|
+
```md
|
|
100
|
+
## Model Choice
|
|
101
|
+
- PostgreSQL remains source of truth for document metadata and lifecycle
|
|
102
|
+
- Object storage holds canonical documents
|
|
103
|
+
- Vector DB is used only as semantic retrieval index
|
|
104
|
+
|
|
105
|
+
## Retrieval Architecture
|
|
106
|
+
- Hybrid retrieval = BM25 + ANN + metadata filter + cross-encoder rerank
|
|
107
|
+
- Filters applied for tenant_id, region, policy_type, effective_date
|
|
108
|
+
- Exact compliance terms still supported by lexical search
|
|
109
|
+
|
|
110
|
+
## Embedding Governance
|
|
111
|
+
- embedding_model: text-embedding-3-large
|
|
112
|
+
- embedding_version: v2026_03_policy_chunks_v2
|
|
113
|
+
- chunking: heading-aware, 350-600 tokens, 80-token overlap
|
|
114
|
+
- Shadow index used during re-embedding migration
|
|
115
|
+
|
|
116
|
+
## ANN / Operations
|
|
117
|
+
- HNSW selected after recall-latency benchmark
|
|
118
|
+
- search cluster separated from ingestion cluster
|
|
119
|
+
- Hot vectors: last 90 days of updated policies
|
|
120
|
+
- Cold vectors: older embeddings compacted to lower-cost tier
|
|
121
|
+
|
|
122
|
+
## Observability
|
|
123
|
+
- Golden query set maintained for recall regression
|
|
124
|
+
- Similarity score distribution monitored by policy domain
|
|
125
|
+
- Prompt token waste tracked for bad retrieval
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Example 5: Anti-Pattern Remediation on a Live Table
|
|
129
|
+
|
|
130
|
+
**Input**: "Our `products` table stores tags as a comma-separated column, prices as FLOAT, and category lookups are slow. Fix it without downtime."
|
|
131
|
+
|
|
132
|
+
**Output**:
|
|
133
|
+
```md
|
|
134
|
+
## Findings (anti-pattern review)
|
|
135
|
+
- CSV-in-column: `products.tags VARCHAR` holds comma-separated tags -> junction table
|
|
136
|
+
- Floating-point money: `products.price FLOAT` -> NUMERIC(12,2)
|
|
137
|
+
- Slow category lookup: Seq Scan confirmed via EXPLAIN (ANALYZE); estimated 200 rows vs actual 1.8M -> stale stats + missing composite index
|
|
138
|
+
|
|
139
|
+
## Remediation Plan (expand-contract, four deploys)
|
|
140
|
+
1. Expand (additive only)
|
|
141
|
+
- CREATE TABLE product_tags(product_id FK, tag_id FK, PRIMARY KEY(product_id, tag_id))
|
|
142
|
+
- ALTER TABLE products ADD COLUMN price_amount NUMERIC(12,2) (nullable)
|
|
143
|
+
- CREATE INDEX CONCURRENTLY idx_products_category_active ON products(category_id, is_active)
|
|
144
|
+
2. Migrate (dual-write + backfill)
|
|
145
|
+
- App writes tags to both column and junction table; price to both columns
|
|
146
|
+
- Backfill in 10k-row PK batches with checkpointing; replication lag watched, throttled at threshold
|
|
147
|
+
- Parity: row-count + sampled checksum comparison recorded
|
|
148
|
+
3. Switch (reads behind flag)
|
|
149
|
+
- Reads flip to product_tags / price_amount; old paths kept for rollback; 1-week soak
|
|
150
|
+
4. Contract (separate deploy, after soak + final backup)
|
|
151
|
+
- Drop products.tags and products.price; VALIDATE NOT NULL on price_amount via CHECK NOT VALID first
|
|
152
|
+
|
|
153
|
+
## Verification
|
|
154
|
+
- ANALYZE products; EXPLAIN (ANALYZE, BUFFERS) before/after recorded: Seq Scan -> Index Scan, p95 420ms -> 6ms
|
|
155
|
+
- lock_timeout = '2s' + retry on every DDL; no COPY-algorithm DDL on the hot table
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Example 6: New Order Approval Flow
|
|
159
|
+
|
|
160
|
+
**Input**: "Add a trigger that approves orders, charges the card, and sends email when status becomes READY."
|
|
161
|
+
|
|
162
|
+
**Recommendation**: Strongly recommend an explicit application command for approval and a versioned eligibility policy. Persist the validated transition and an outbox event in one transaction; use a worker for payment/email with idempotency, bounded retry, and a defined recovery path for partial success. Keep FK/UNIQUE/CHECK constraints and concurrency protection in the DB. A status update or ORM save hook must not silently become the workflow entry point.
|
|
163
|
+
|
|
164
|
+
## Example 7: Existing Procedure and Expiry Job
|
|
165
|
+
|
|
166
|
+
**Input**: "The existing settlement procedure calculates fees, and a DB job marks subscriptions expired. Keep using them because that is our convention."
|
|
167
|
+
|
|
168
|
+
**Recommendation**: Strongly recommend application ownership of fee policy and business job execution; existing convention alone is not retention evidence. First inspect API, batch, admin, and direct SQL writers. Version fee policies and record which version produced a settlement; validate `expires_at` when an action occurs rather than relying on the expiry job having run.
|
|
169
|
+
|
|
170
|
+
**Transition**: Compare old/new decisions without charging or notifying twice, coordinate one execution owner across old app instances and DB routines, and preserve a tested rollback path during the soak window. Keep DB constraints, atomic updates, RLS, change audit, and efficient SQL aggregation. An audit trigger that records every affected writer may remain with documented coverage and bypass limits. Retain a DB calculation routine only with a concrete reason, such as measured data-local processing cost, plus correctness/concurrency tests and deployment/recovery evidence.
|