prizmkit 1.1.154 → 1.1.156
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/bundled/VERSION.json +3 -3
- package/bundled/adapters/codex/skill-adapter.js +1 -1
- package/bundled/adapters/pi/skill-adapter.js +2 -1
- package/bundled/dev-pipeline/.env.example +2 -6
- package/bundled/dev-pipeline/README.md +21 -27
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +341 -15
- package/bundled/dev-pipeline/prizmkit_runtime/cli.py +0 -3
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +1 -15
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +48 -14
- package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +50 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +0 -9
- package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +3 -3
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +120 -22
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +482 -0
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +64 -11
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +145 -367
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +91 -62
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +105 -69
- package/bundled/dev-pipeline/scripts/prompt_framework.py +36 -41
- package/bundled/dev-pipeline/scripts/update-bug-status.py +1 -4
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +61 -13
- package/bundled/dev-pipeline/scripts/update-feature-status.py +1 -4
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +1 -4
- package/bundled/dev-pipeline/templates/bootstrap-prompt.md +22 -27
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +71 -104
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +59 -111
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +37 -72
- package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +39 -0
- package/bundled/dev-pipeline/templates/sections/bugfix-critical-paths.md +3 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +8 -25
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +3 -3
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-implement.md +2 -2
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +3 -3
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -2
- package/bundled/dev-pipeline/templates/sections/bugfix-reminders.md +4 -4
- package/bundled/dev-pipeline/templates/sections/bugfix-session-context.md +0 -1
- package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +7 -4
- package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +14 -27
- package/bundled/dev-pipeline/templates/sections/feature-completion-summary.md +20 -0
- package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +8 -71
- package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +7 -7
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +3 -3
- package/bundled/dev-pipeline/templates/sections/phase-review-full.md +4 -4
- package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +5 -17
- package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +3 -1
- package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +10 -23
- package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +2 -2
- package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +2 -2
- package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +3 -3
- package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +2 -2
- package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +7 -7
- package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -1
- package/bundled/dev-pipeline/templates/sections/retrospective.md +12 -0
- package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +35 -0
- package/bundled/dev-pipeline/templates/session-status-schema.json +45 -62
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +469 -18
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +262 -175
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +62 -23
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +76 -28
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +168 -18
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +111 -0
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -2
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +608 -0
- package/bundled/dev-pipeline/tests/test_unified_cli.py +167 -25
- package/bundled/skills/_metadata.json +9 -9
- package/bundled/skills/app-planner/SKILL.md +3 -3
- package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
- package/bundled/skills/app-planner/references/rules/backend/derivation-rules.md +56 -64
- package/bundled/skills/app-planner/references/rules/backend/fixed-rules.md +85 -240
- package/bundled/skills/app-planner/references/rules/backend/question-bank.md +25 -25
- package/bundled/skills/app-planner/references/rules/backend/question-manifest.json +16 -7
- package/bundled/skills/app-planner/references/rules/backend/template.md +74 -92
- package/bundled/skills/app-planner/references/rules/database/derivation-rules.md +93 -93
- package/bundled/skills/app-planner/references/rules/database/fixed-rules.md +66 -173
- package/bundled/skills/app-planner/references/rules/database/question-bank.md +31 -26
- package/bundled/skills/app-planner/references/rules/database/question-manifest.json +13 -4
- package/bundled/skills/app-planner/references/rules/database/template.md +76 -98
- package/bundled/skills/app-planner/references/rules/frontend/derivation-rules.md +68 -95
- package/bundled/skills/app-planner/references/rules/frontend/fixed-rules.md +93 -166
- package/bundled/skills/app-planner/references/rules/frontend/question-bank.md +46 -36
- package/bundled/skills/app-planner/references/rules/frontend/question-manifest.json +11 -2
- package/bundled/skills/app-planner/references/rules/frontend/template.md +79 -257
- package/bundled/skills/app-planner/references/rules/mobile/derivation-rules.md +91 -99
- package/bundled/skills/app-planner/references/rules/mobile/fixed-rules.md +73 -246
- package/bundled/skills/app-planner/references/rules/mobile/question-bank.md +17 -17
- package/bundled/skills/app-planner/references/rules/mobile/question-manifest.json +17 -2
- package/bundled/skills/app-planner/references/rules/mobile/template.md +73 -85
- package/bundled/skills/app-planner/references/rules-configuration.md +133 -65
- package/bundled/skills/app-planner/scripts/validate-rules-configuration.py +291 -0
- package/bundled/skills/prizmkit/SKILL.md +17 -18
- package/bundled/skills/prizmkit/references/workflow-state-protocol.md +22 -18
- package/bundled/skills/prizmkit-code-review/SKILL.md +22 -58
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +6 -6
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +2 -2
- package/bundled/skills/prizmkit-committer/SKILL.md +82 -132
- package/bundled/skills/prizmkit-deploy/SKILL.md +27 -11
- package/bundled/skills/prizmkit-deploy/assets/deploy-document-template.md +89 -0
- package/bundled/skills/prizmkit-deploy/references/ci-cd-workflows.md +44 -14
- package/bundled/skills/prizmkit-deploy/references/cloud-platform-deploy.md +19 -3
- package/bundled/skills/prizmkit-deploy/references/database-setup.md +22 -12
- package/bundled/skills/prizmkit-deploy/references/deploy-config-schema.md +3 -1
- package/bundled/skills/prizmkit-deploy/references/deploy-history-schema.md +22 -6
- package/bundled/skills/prizmkit-deploy/references/deploy-metadata-schema.json +49 -0
- package/bundled/skills/prizmkit-deploy/references/live-validation-notes.md +1 -1
- package/bundled/skills/prizmkit-deploy/references/pending-input-schema.json +164 -0
- package/bundled/skills/prizmkit-deploy/references/ssh-adapter-flow.md +9 -8
- package/bundled/skills/prizmkit-deploy/references/ssh-execution-flow.md +6 -6
- package/bundled/skills/prizmkit-implement/SKILL.md +30 -66
- package/bundled/skills/prizmkit-implement/references/implementation-subagent-procedure.md +4 -4
- package/bundled/skills/prizmkit-init/SKILL.md +4 -0
- package/bundled/skills/prizmkit-plan/SKILL.md +21 -64
- package/bundled/skills/prizmkit-plan/references/artifact-identity.md +38 -0
- package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +4 -4
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +5 -5
- package/bundled/skills/prizmkit-prizm-docs/SKILL.md +75 -11
- package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +191 -56
- package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +18 -18
- package/bundled/skills/prizmkit-prizm-docs/references/op-rebuild.md +14 -8
- package/bundled/skills/prizmkit-prizm-docs/references/op-status.md +12 -5
- package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +23 -12
- package/bundled/skills/prizmkit-prizm-docs/references/op-validate.md +13 -9
- package/bundled/skills/prizmkit-retrospective/SKILL.md +94 -97
- package/bundled/skills/prizmkit-retrospective/references/knowledge-injection-steps.md +79 -37
- package/bundled/skills/prizmkit-retrospective/references/retrospective-result-schema.json +138 -0
- package/bundled/skills/prizmkit-retrospective/references/structural-sync-steps.md +111 -54
- package/bundled/skills/prizmkit-test/SKILL.md +64 -51
- package/bundled/skills/prizmkit-test/references/boundary-contract-and-test-double-guidance.md +206 -0
- package/bundled/skills/prizmkit-test/references/independent-test-review.md +17 -9
- package/bundled/skills/prizmkit-test/references/test-coverage-model.md +45 -21
- package/bundled/skills/prizmkit-test/references/test-report-template.md +20 -13
- package/bundled/skills/prizmkit-workflow/SKILL.md +35 -37
- package/bundled/skills/prizmkit-workflow/references/artifact-identity.md +34 -0
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +22 -18
- package/bundled/skills/recovery-workflow/SKILL.md +2 -1
- package/bundled/skills/recovery-workflow/references/detection.md +4 -3
- package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +15 -5
- package/bundled/templates/hooks/validate-prizm-docs.py +124 -12
- package/package.json +1 -1
- package/src/scaffold.js +33 -22
- package/bundled/dev-pipeline/templates/sections/bugfix-artifacts.md +0 -16
- package/bundled/dev-pipeline/templates/sections/bugfix-session-status.md +0 -31
- package/bundled/dev-pipeline/templates/sections/critical-paths-agent.md +0 -7
- package/bundled/dev-pipeline/templates/sections/critical-paths-lite.md +0 -7
- package/bundled/dev-pipeline/templates/sections/directory-convention-agent.md +0 -9
- package/bundled/dev-pipeline/templates/sections/directory-convention-lite.md +0 -6
- package/bundled/dev-pipeline/templates/sections/headless-commit-authorization.md +0 -15
- package/bundled/dev-pipeline/templates/sections/phase-commit.md +0 -61
- package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +0 -24
- package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-lite-suffix.md +0 -12
- package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +0 -44
- package/bundled/dev-pipeline/templates/sections/phase-implement-lite.md +0 -25
- package/bundled/dev-pipeline/templates/sections/phase-plan-agent.md +0 -20
- package/bundled/dev-pipeline/templates/sections/phase-plan-lite.md +0 -20
- package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +0 -20
- package/bundled/dev-pipeline/templates/sections/refactor-artifacts.md +0 -17
- package/bundled/dev-pipeline/templates/sections/refactor-session-status.md +0 -28
- package/bundled/dev-pipeline/templates/sections/test-failure-recovery-agent.md +0 -52
- package/bundled/dev-pipeline/templates/sections/test-failure-recovery-lite.md +0 -52
- package/bundled/skills/prizmkit-code-review/references/workflow-state-protocol.md +0 -174
- package/bundled/skills/prizmkit-committer/references/workflow-state-protocol.md +0 -174
- package/bundled/skills/prizmkit-implement/references/workflow-state-protocol.md +0 -174
- package/bundled/skills/prizmkit-plan/references/workflow-state-protocol.md +0 -174
- package/bundled/skills/prizmkit-retrospective/references/workflow-state-protocol.md +0 -174
- package/bundled/skills/prizmkit-test/references/external-contract-mock-guidance.md +0 -119
|
@@ -1,211 +1,104 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Database Invariant Rules
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
> These rules are industry consensus / best practices — **do not ask the user**.
|
|
5
|
-
> Every rule includes RATIONALE so the AI understands intent, not just constraints.
|
|
3
|
+
POLICY_CLASS: invariant
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
These blocks apply to relational, document, embedded, managed, and self-hosted data stores without imposing one model on another.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
**Selected-decision boundary:** database technology, identifier strategy, soft deletion, normalization/document modeling, migration tooling, workload, scale, sensitivity, audit/CDC, deployment, backup, availability, and AI DDL permission belong to confirmed decisions and derivation rules.
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
## I1. Schema and Model Integrity
|
|
12
10
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- **Indexes**: prefix `idx_` + table + columns (`idx_users_email`).
|
|
18
|
-
- **Unique constraints**: prefix `uq_` + table + columns (`uq_users_email`).
|
|
19
|
-
- **Forbidden**: Pinyin names, reserved keywords as table/column names (`order`, `group`, `user`).
|
|
20
|
-
- **RATIONALE**: Consistent naming makes ORM mapping accurate, SQL readable, and AI code generation precise when guessing field names.
|
|
11
|
+
- Give each persisted concept an explicit owner, stable identity strategy, and documented lifecycle.
|
|
12
|
+
- Preserve selected naming and modeling conventions consistently within the same datastore boundary.
|
|
13
|
+
- Constraints enforced by the datastore and application must agree; do not rely on undocumented coercion.
|
|
14
|
+
- Relational normalization and document embedding/reference policies come only from selected derivation rules.
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
Inject into `{{ FIXED_RULES_SCHEMA }}`.
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
- `id` — primary key
|
|
26
|
-
- `created_at` — `NOT NULL DEFAULT NOW()`
|
|
27
|
-
- `updated_at` — `NOT NULL DEFAULT NOW()` with auto-update (or trigger)
|
|
28
|
-
- **Rule**: Tables requiring soft delete must add `deleted_at` (NULL = not deleted). Unique indexes must include `deleted_at`.
|
|
29
|
-
- **Forbidden**: Using `is_deleted` boolean instead of `deleted_at` — losing the deletion timestamp loses audit information.
|
|
30
|
-
- **RATIONALE**: Consistent timestamps are the foundation of all auditing, synchronization, and CDC.
|
|
18
|
+
## I2. Type Integrity
|
|
31
19
|
|
|
32
|
-
|
|
20
|
+
- Use native datastore types or validated encodings that preserve the domain's precision, range, timezone, and nullability semantics.
|
|
21
|
+
- Monetary or exact quantities must not use an imprecise representation.
|
|
22
|
+
- Do not store structured values in an opaque string when the selected datastore has a safer queryable representation, unless compatibility requires it and the boundary is documented.
|
|
23
|
+
- Technology-specific type names come from `{{ tech_rules }}`.
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
- **Rule**: Primary key strategy is determined by Q3 (Primary Key Strategy). If UUID/ULID is chosen, UUIDs are used both internally and in the API layer. If auto-increment is chosen, BIGINT may be used internally, but the API layer must expose UUID (via an additional UUID column or ID mapping).
|
|
36
|
-
- **Forbidden**: Exposing auto-increment IDs directly to the frontend (enumerable, leaks data volume).
|
|
37
|
-
- **Forbidden**: Using business fields as primary keys (e.g., national ID, phone number) — business rules change.
|
|
38
|
-
- **RATIONALE**: UUIDs prevent enumeration, support distributed generation, and avoid merge conflicts. Exposing auto-increment IDs is information leakage.
|
|
25
|
+
Inject into `{{ FIXED_RULES_TYPES }}`.
|
|
39
26
|
|
|
40
|
-
|
|
27
|
+
## I3. Access-Path Integrity
|
|
41
28
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
- **RATIONALE**: Denormalization is a double-edged sword — queries get faster but writes and consistency maintenance costs skyrocket.
|
|
29
|
+
- Add indexes or equivalent access paths from observed query patterns, selectivity, and write cost rather than universal rules.
|
|
30
|
+
- Verify expensive access paths with the selected datastore's explain/profile capability when available.
|
|
31
|
+
- Avoid duplicate or unused indexes and document intentional full scans for bounded datasets.
|
|
46
32
|
|
|
47
|
-
|
|
33
|
+
Inject into `{{ FIXED_RULES_INDEX }}`.
|
|
48
34
|
|
|
49
|
-
|
|
50
|
-
- **Rule**: Prefer database ENUM types (PostgreSQL use CHECK constraint + string) or enum tables.
|
|
51
|
-
- **Forbidden**: Using `status TINYINT` without comments — nobody knows what 2 means.
|
|
52
|
-
- **RATIONALE**: Enum values are the easiest thing to rot — every status addition requires a full code scan to confirm compatibility.
|
|
35
|
+
## I4. Atomicity and Concurrency
|
|
53
36
|
|
|
54
|
-
|
|
37
|
+
- Define the consistency, transaction, or atomic-write boundary for operations that update related state.
|
|
38
|
+
- Keep atomic units bounded and avoid waiting on unrelated external systems while locks or equivalent write ownership are held.
|
|
39
|
+
- Select isolation, optimistic concurrency, or conflict handling according to the datastore and business invariant.
|
|
55
40
|
|
|
56
|
-
|
|
41
|
+
Inject into `{{ FIXED_RULES_TRANSACTION }}`.
|
|
57
42
|
|
|
58
|
-
|
|
59
|
-
- **Rule**: Date/time use `TIMESTAMP WITH TIME ZONE` (PostgreSQL) / `DATETIME` (MySQL). Forbid string-stored dates.
|
|
60
|
-
- **Rule**: JSON data use `JSONB` (PostgreSQL) / `JSON` (MySQL 8+). Forbid storing TEXT and parsing in application layer.
|
|
61
|
-
- **Rule**: Character set unified to `UTF8MB4` (MySQL) / `UTF8` (PostgreSQL). Collation unified.
|
|
62
|
-
- **Rule**: IP addresses use `INET` (PostgreSQL) / `VARBINARY(16)` (MySQL), not VARCHAR.
|
|
63
|
-
- **Forbidden**: Using VARCHAR to store arrays (e.g., `"a,b,c"`) — use array types or junction tables.
|
|
64
|
-
- **RATIONALE**: The right type lets the database do validation and index optimization for you. Wrong types mean you're throwing away the database's self-protection.
|
|
43
|
+
## I5. Change Management
|
|
65
44
|
|
|
66
|
-
|
|
45
|
+
- Version structural or model changes and make the applied state observable.
|
|
46
|
+
- Define rollout, compatibility, data transformation, and recovery behavior before a destructive or incompatible change.
|
|
47
|
+
- Use the selected migration mechanism; do not require SQL rollback files for technologies or tools that use another safe recovery model.
|
|
67
48
|
|
|
68
|
-
|
|
49
|
+
Inject into `{{ FIXED_RULES_MIGRATION }}`.
|
|
69
50
|
|
|
70
|
-
|
|
71
|
-
- **Rule**: Columns involved in WHERE/JOIN/ORDER BY/DISTINCT must be evaluated for index need.
|
|
72
|
-
- **Rule**: Multi-column queries use composite indexes with the leftmost prefix rule — equality columns first, range columns last.
|
|
73
|
-
- **Rule**: Adding indexes to large tables must use `CONCURRENTLY` (PostgreSQL) / `ALGORITHM=INPLACE` (MySQL) to avoid table locks.
|
|
74
|
-
- **Rule**: Regularly analyze slow query logs and remove unused indexes.
|
|
75
|
-
- **Forbidden**: Indexing low-cardinality columns alone (e.g., `gender`, `status` with < 5 values).
|
|
76
|
-
- **Forbidden**: Redundant indexes — `idx(a,b)` already covers `idx(a)` scenarios.
|
|
77
|
-
- **RATIONALE**: Indexes are the core lever of database performance, but every additional index slows writes by a bit.
|
|
51
|
+
## I6. Query and Mutation Safety
|
|
78
52
|
|
|
79
|
-
|
|
53
|
+
- Bind untrusted values through the selected driver's safe query API; never concatenate untrusted input into executable query text.
|
|
54
|
+
- Bound bulk and list operations or explicitly implement streaming/pagination.
|
|
55
|
+
- Protect dynamic field, sort, operator, and projection choices with an allowlisted contract.
|
|
56
|
+
- Apply SQL-specific syntax rules only to SQL datastores.
|
|
80
57
|
|
|
81
|
-
|
|
58
|
+
Inject into `{{ FIXED_RULES_QUERY }}`.
|
|
82
59
|
|
|
83
|
-
|
|
60
|
+
## I7. Data Security
|
|
84
61
|
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
- **RATIONALE**: PostgreSQL defaults to READ COMMITTED, MySQL to REPEATABLE READ. Different defaults cause different behaviors in the same application code.
|
|
62
|
+
- Apply least privilege to application identities and separate administrative access from runtime access.
|
|
63
|
+
- Keep credentials outside source control and secure network exposure according to the deployment boundary.
|
|
64
|
+
- Protect sensitive fields, logs, replicas, exports, and backups according to the selected sensitivity classification.
|
|
65
|
+
- Do not log secrets or unrestricted personal data.
|
|
90
66
|
|
|
91
|
-
|
|
67
|
+
Inject into `{{ FIXED_RULES_SECURITY }}`.
|
|
92
68
|
|
|
93
|
-
##
|
|
69
|
+
## I8. Recovery Integrity
|
|
94
70
|
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
- **Rule**: Schema changes must avoid table locks (choose the correct method per database):
|
|
99
|
-
- MySQL: `ALGORITHM=INPLACE, LOCK=NONE` (when conditions allow)
|
|
100
|
-
- PostgreSQL: `ALTER TABLE ... ADD COLUMN` without DEFAULT (add column first, then backfill defaults).
|
|
101
|
-
- **Forbidden**: Dropping columns in migrations — mark as deprecated first, remove in the next version after confirming zero references.
|
|
102
|
-
- **Forbidden**: Changing column types — must follow the pattern: add new column → dual-write transition → migrate data → switch reads → drop old column.
|
|
103
|
-
- **RATIONALE**: Migrations are the most dangerous production operations. It's not just "does it run" — it's about online tables, rollback windows, and data consistency.
|
|
71
|
+
- The selected backup decision must state accepted data-loss and recovery-time risk.
|
|
72
|
+
- When backups are required, protect them independently from the primary datastore and verify restoration on a schedule appropriate to the risk.
|
|
73
|
+
- Development-only `no automatic backup` is rendered explicitly and must not be contradicted by a universal production backup mandate.
|
|
104
74
|
|
|
105
|
-
|
|
75
|
+
Inject into `{{ FIXED_RULES_BACKUP }}`.
|
|
106
76
|
|
|
107
|
-
##
|
|
77
|
+
## I9. Performance Integrity
|
|
108
78
|
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
- **Rule**: Bulk write operations (UPDATE/DELETE) must be batched (≤ 1000 rows per batch) with transaction intervals.
|
|
113
|
-
- **Rule**: Transactions must be as short as possible — no external API calls, message sends, or user input waits inside transactions.
|
|
114
|
-
- **Rule**: Complex queries must first run `EXPLAIN` / `EXPLAIN ANALYZE` to verify index usage.
|
|
115
|
-
- **Forbidden**: Concatenating dynamic SQL strings in application code (use whitelist for dynamic sort fields, query builder for dynamic conditions).
|
|
116
|
-
- **RATIONALE**: Query standards aren't about "writing prettier code" — every rule here corresponds to a real production incident.
|
|
79
|
+
- Establish performance targets from the selected workload and scale.
|
|
80
|
+
- Monitor resource saturation and slow operations using capabilities available for the selected datastore.
|
|
81
|
+
- Do not require partitioning, replication, or archival solely from a generic threshold without considering access patterns and operational cost.
|
|
117
82
|
|
|
118
|
-
|
|
83
|
+
Inject into `{{ FIXED_RULES_PERFORMANCE }}`.
|
|
119
84
|
|
|
120
|
-
##
|
|
85
|
+
## I10. Connection and Client Lifecycle
|
|
121
86
|
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
- **Rule**: Sensitive fields (passwords, tokens, national IDs, phone numbers) must be encrypted at rest.
|
|
126
|
-
- **Rule**: Database ports must not be exposed to the public internet. Internal/VPC whitelist access only.
|
|
127
|
-
- **RATIONALE**: The database is the attacker's ultimate target. Enough layers of defense is what keeps you safe.
|
|
87
|
+
- Reuse datastore clients or pools according to driver guidance; close or release resources deterministically.
|
|
88
|
+
- Size concurrency against total service instances and datastore capacity rather than a per-process hardcoded formula.
|
|
89
|
+
- Embedded or connectionless stores render the applicable client-lifecycle rule instead of a server pool requirement.
|
|
128
90
|
|
|
129
|
-
|
|
91
|
+
Inject into `{{ FIXED_RULES_CONNECTION }}`.
|
|
130
92
|
|
|
131
|
-
##
|
|
93
|
+
## I11. AI Data-Change Safety
|
|
132
94
|
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
- **RATIONALE**: A database whose backups have never been verified is a database without backups.
|
|
95
|
+
- Read the current schema/model and migration history before proposing a structural change.
|
|
96
|
+
- State target datastore, environment, compatibility impact, lock/rewrite risk where applicable, and recovery plan.
|
|
97
|
+
- Never execute destructive operations against user or production data without explicit authorization from the selected permission policy.
|
|
98
|
+
- Concrete DDL generation and execution rights come only from `{{ ai_ddl_rule }}` and `{{ ai_safety_rule }}`.
|
|
138
99
|
|
|
139
|
-
|
|
100
|
+
Inject into `{{ FIXED_RULES_AI_BASE }}`.
|
|
140
101
|
|
|
141
|
-
##
|
|
102
|
+
## Injection Contract
|
|
142
103
|
|
|
143
|
-
-
|
|
144
|
-
- **Rule**: Slow query threshold set to 100ms (for OLTP workloads). Alert on exceeding.
|
|
145
|
-
- **Rule**: Large tables (>10M rows) must plan a partitioning strategy (range partition by time or business key).
|
|
146
|
-
- **Rule**: Historical data must have an archival strategy that doesn't impact online query performance.
|
|
147
|
-
- **Forbidden**: Running DDL, bulk data migrations, or creating large indexes during peak hours.
|
|
148
|
-
- **RATIONALE**: Database performance issues are "boiling the frog" — unnoticeable at first, then suddenly crashing three times a day once data volume grows.
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## F8b. Connection Pooling
|
|
153
|
-
|
|
154
|
-
### F8b.1 Connection Pooling
|
|
155
|
-
|
|
156
|
-
- **Rule**: Every application service must use connection pooling. Forbid opening a new connection per request.
|
|
157
|
-
- **Rule**: Pool size = CPU cores x 2 per service instance (for OLTP). Max pool size <= 80% of database max_connections / number of service instances.
|
|
158
|
-
- **Rule**: Connection timeout: acquire <= 30s, idle <= 10min, max lifetime <= 1hour.
|
|
159
|
-
- **Rule**: Pool must have health check (validation query on borrow).
|
|
160
|
-
- **Forbidden**: Using hardcoded pool sizes without accounting for the number of service instances.
|
|
161
|
-
- **RATIONALE**: Connection pooling misconfiguration is the #1 cause of "database is up but application can't connect" incidents.
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## F9. AI Vibecoding Baseline Constraints (project-agnostic, always active)
|
|
166
|
-
|
|
167
|
-
### F9.1 Migration Files
|
|
168
|
-
- **Rule**: AI generating a new migration must also produce the corresponding rollback migration.
|
|
169
|
-
- **Forbidden**: Dropping columns, changing column types, or renaming columns in migrations (unless a complete transition plan exists).
|
|
170
|
-
- **Rule**: New migrations must pass `EXPLAIN` review before submission.
|
|
171
|
-
|
|
172
|
-
### F9.2 SQL Safety
|
|
173
|
-
- **Rule**: All AI-written SQL in application code must be parameterized queries.
|
|
174
|
-
- **Forbidden**: AI generating string-concatenated SQL code.
|
|
175
|
-
|
|
176
|
-
### F9.3 Search First
|
|
177
|
-
- **Rule**: Before writing SQL/migrations, AI must read existing migration files and schema.
|
|
178
|
-
- **Rule**: Before adding a new column, AI must confirm that a column with the same name doesn't already exist in that table.
|
|
179
|
-
|
|
180
|
-
### F9.4 Context Honesty
|
|
181
|
-
- **Rule**: When uncertain about database version, field names, or constraint names, AI must explicitly say "I'm not sure." Forbid inventing.
|
|
182
|
-
- **Rule**: AI must understand the target database type before generating SQL (MySQL and PostgreSQL syntax differ).
|
|
183
|
-
|
|
184
|
-
### F9.5 Irreversible Operations
|
|
185
|
-
- **Rule**: AI must not execute any DROP/TRUNCATE statements (unless the user explicitly provides both the target object and the reason).
|
|
186
|
-
- **Rule**: AI-proposed DDL must include a migration strategy assessment: online execution or maintenance window? How long is the table locked? What's the rollback plan?
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## Injection Instructions (for the AI executing this skill)
|
|
191
|
-
|
|
192
|
-
Each chapter in this file corresponds to a `{{ FIXED_RULES_* }}` placeholder in the template:
|
|
193
|
-
|
|
194
|
-
| Chapter | Inject Into Placeholder | Template Section |
|
|
195
|
-
|---------|------------------------|-------------------|
|
|
196
|
-
| F1 Schema Design | `{{ FIXED_RULES_SCHEMA }}` | §1 Schema Design |
|
|
197
|
-
| F2 Column Types | `{{ FIXED_RULES_TYPES }}` | §2 Column Types |
|
|
198
|
-
| F3 Index Strategy | `{{ FIXED_RULES_INDEX }}` | §3 Index Strategy |
|
|
199
|
-
| F3b Transaction Isolation | `{{ FIXED_RULES_TRANSACTION }}` | §3b Transaction Isolation |
|
|
200
|
-
| F4 Migration Management | `{{ FIXED_RULES_MIGRATION }}` | §4 Migration Management |
|
|
201
|
-
| F5 Query Standards | `{{ FIXED_RULES_QUERY }}` | §5 Query Standards |
|
|
202
|
-
| F6 Security & Permissions | `{{ FIXED_RULES_SECURITY }}` | §6 Security & Permissions |
|
|
203
|
-
| F7 Backup & Recovery | `{{ FIXED_RULES_BACKUP }}` | §7 Backup & Recovery |
|
|
204
|
-
| F8 Performance | `{{ FIXED_RULES_PERFORMANCE }}` | §8 Performance |
|
|
205
|
-
| F8b Connection Pooling | `{{ FIXED_RULES_CONNECTION }}` | §8b Connection Pooling |
|
|
206
|
-
| F9 AI Constraints | `{{ FIXED_RULES_AI_BASE }}` | §9 AI Behavior Constraints |
|
|
207
|
-
|
|
208
|
-
**Rendering rules**:
|
|
209
|
-
1. Copy each chapter's full body (including RATIONALE) directly into the corresponding placeholder.
|
|
210
|
-
2. RATIONALE must be preserved — it lets AI understand intent rather than follow mechanically.
|
|
211
|
-
3. Keep the original markdown list structure. Do not rewrite as prose paragraphs.
|
|
104
|
+
Copy each invariant block only into its named placeholder. If a selected datastore or operational decision makes a block inapplicable, render the compatible invariant meaning or an explicit not-applicable statement; never inject relational rules into a document or embedded datastore by default.
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
1. **Group order**: G1 → G2 → G3 → G4 → G5 → G6 → G7. Do not skip.
|
|
12
12
|
2. **Shortcut commands** (respond immediately when user types these at any point):
|
|
13
13
|
- `recommended` / `default` → skip current group, adopt all recommended options
|
|
14
|
-
- `all recommended` / `one-click` →
|
|
14
|
+
- `all recommended` / `one-click` → explicit authorization to adopt each remaining applicable recommended option; ask any question whose recommendation is ambiguous for the selected datastore
|
|
15
15
|
- `strict` / `strictest` → adopt the strictest option for the current group
|
|
16
16
|
- `skip` / `don't need this` → mark current group as N/A
|
|
17
17
|
- `custom: xxx` → record user's custom content
|
|
18
18
|
3. **Abbreviation recognition**: `A` / `a` / `1` all mean option A.
|
|
19
19
|
4. **Follow-up rule**: If the user gives an answer outside the options, first confirm whether to classify as an "other" branch.
|
|
20
20
|
5. **Forbidden behaviors**:
|
|
21
|
-
- Must not make choices for the user before they explicitly answer.
|
|
21
|
+
- Must not make choices for the user before they explicitly answer, except concrete defaults covered by the user's explicit Quick/all-recommended authorization.
|
|
22
22
|
- Must not fabricate user preferences to complete the answer set.
|
|
23
23
|
- Must not output more than 3 questions in a single message.
|
|
24
24
|
|
|
@@ -64,26 +64,31 @@ Total: 15 questions.
|
|
|
64
64
|
## G2 — Data Modeling
|
|
65
65
|
|
|
66
66
|
### Q3. Primary Key Strategy
|
|
67
|
-
- **Options**:
|
|
67
|
+
- **Options for relational or embedded SQL datastores**:
|
|
68
68
|
- A) UUID v7 (time-sortable, 128-bit with dashes) **【Recommended】**
|
|
69
69
|
- B) ULID (lowercase, URL-safe, 26-char, time-sortable)
|
|
70
70
|
- C) Auto-increment BIGINT + UUID mapping for external use
|
|
71
71
|
- D) Direct auto-increment IDs
|
|
72
|
-
- **
|
|
72
|
+
- **Options for MongoDB**:
|
|
73
|
+
- A) Native ObjectId **【Recommended】**
|
|
74
|
+
- B) UUID v7
|
|
75
|
+
- C) ULID
|
|
76
|
+
- **Note**: Options vary by Q1. Direct auto-increment selection includes the explicit external-reference limitation; MongoDB never inherits relational auto-increment rules.
|
|
73
77
|
- **Maps to**: `{{ pk_strategy }}` + `{{ schema_rules }}`
|
|
74
78
|
|
|
75
79
|
### Q4. Soft Delete
|
|
76
80
|
- **Options**:
|
|
77
81
|
- A) Use `deleted_at` field **【Recommended】**
|
|
78
82
|
- B) No soft delete needed (data is irrecoverably deleted)
|
|
79
|
-
- **Note**: Determines
|
|
83
|
+
- **Note**: Determines deletion filtering, recovery, lifecycle, and active-record uniqueness rules using capabilities of the selected datastore.
|
|
80
84
|
- **Maps to**: `{{ soft_delete }}` + `{{ schema_rules }}`
|
|
81
85
|
|
|
82
|
-
### Q5. Normalization Level
|
|
83
|
-
- **
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
86
|
+
### Q5. Modeling / Normalization Level
|
|
87
|
+
- **Conditional logic**: Ask for relational and embedded SQL datastores. For MongoDB, auto-derive `Document modeling: embedding vs. references follows access patterns and consistency boundaries` and do not ask a 3NF question.
|
|
88
|
+
- **Options when asked**:
|
|
89
|
+
- A) Strict 3NF; denormalization requires evidence and documented consistency handling **【Recommended】**
|
|
90
|
+
- B) Allow partial denormalization for confirmed reporting or performance paths
|
|
91
|
+
- **Note**: Determines the selected data-redundancy policy without applying relational normalization to document storage.
|
|
87
92
|
- **Maps to**: `{{ normalization }}` + `{{ schema_rules }}`
|
|
88
93
|
|
|
89
94
|
---
|
|
@@ -102,20 +107,20 @@ Total: 15 questions.
|
|
|
102
107
|
|
|
103
108
|
## G4 — Index & Performance
|
|
104
109
|
|
|
105
|
-
### Q7.
|
|
110
|
+
### Q7. Workload Type
|
|
106
111
|
- **Options**:
|
|
107
|
-
- A) OLTP (
|
|
108
|
-
- B) OLAP (
|
|
109
|
-
- C) Mixed (
|
|
110
|
-
- **Note**:
|
|
112
|
+
- A) OLTP (frequent bounded reads/writes and short atomic operations) **【Recommended for transactional web applications】**
|
|
113
|
+
- B) OLAP (large scans, aggregations, and batch analytics)
|
|
114
|
+
- C) Mixed (transactional plus confirmed reporting/analytics paths)
|
|
115
|
+
- **Note**: Numeric service objectives and maintenance windows require project evidence; they are not hidden defaults of a workload label.
|
|
111
116
|
- **Maps to**: `{{ workload_type }}` + `{{ performance_rules }}`
|
|
112
117
|
|
|
113
118
|
### Q8. Estimated Data Volume (per table)
|
|
114
119
|
- **Options**:
|
|
115
120
|
- A) < 1M rows (small scale, no partitioning needed) **【Recommended: early-stage projects】**
|
|
116
121
|
- B) 1M-10M rows (medium scale, recommend reserving partition expansion space)
|
|
117
|
-
- C) > 10M
|
|
118
|
-
- **Note**:
|
|
122
|
+
- C) > 10M records/documents in a major collection (large scale, explicit access-path and lifecycle plan required)
|
|
123
|
+
- **Note**: Scale triggers evaluation of partitioning, sharding, archival, and index operations; it does not make time partitioning universally mandatory.
|
|
119
124
|
- **Maps to**: `{{ data_scale }}` + `{{ performance_rules }}`
|
|
120
125
|
|
|
121
126
|
---
|
|
@@ -124,9 +129,9 @@ Total: 15 questions.
|
|
|
124
129
|
|
|
125
130
|
### Q9. Data Sensitivity Level
|
|
126
131
|
- **Options**:
|
|
127
|
-
- A) Contains
|
|
128
|
-
- B) Business data only, no special
|
|
129
|
-
- **Note**: Choosing A
|
|
132
|
+
- A) Contains personal, regulated, credential, or equivalent sensitive data
|
|
133
|
+
- B) Business/public data only, with no identified special classification
|
|
134
|
+
- **Note**: Select from the product's actual data inventory; this is not a preference that Quick mode may guess. Choosing A derives encryption, redaction, retention, and access rules from the identified field classes rather than claiming every value is reversibly encrypted.
|
|
130
135
|
- **Maps to**: `{{ data_sensitivity }}` + `{{ security_rules }}`
|
|
131
136
|
|
|
132
137
|
### Q10. Audit Requirements
|
|
@@ -135,7 +140,7 @@ Total: 15 questions.
|
|
|
135
140
|
- B) Need CDC (Change Data Capture, for sync/analytics)
|
|
136
141
|
- C) Both audit tables + CDC (for comprehensive compliance + real-time sync)
|
|
137
142
|
- D) No audit needed
|
|
138
|
-
- **Note**:
|
|
143
|
+
- **Note**: Choose C when both capabilities are required; do not encode a free-form multi-select value. Audit and CDC have separate trust, retention, transport, and failure contracts.
|
|
139
144
|
- **Maps to**: `{{ audit }}` + `{{ audit_rules }}`
|
|
140
145
|
|
|
141
146
|
---
|
|
@@ -160,10 +165,10 @@ Total: 15 questions.
|
|
|
160
165
|
|
|
161
166
|
### Q13. High Availability Requirements
|
|
162
167
|
- **Options**:
|
|
163
|
-
- A)
|
|
164
|
-
- B) Single instance is sufficient
|
|
165
|
-
- C) Multi-
|
|
166
|
-
- **Note**: Determines connection
|
|
168
|
+
- A) Managed failover or primary-replica topology **【Recommended when the confirmed availability target requires it】**
|
|
169
|
+
- B) Single instance is sufficient **【Recommended for development or an accepted low-availability workload】**
|
|
170
|
+
- C) Multi-writer/multi-region topology (only with a documented consistency need)
|
|
171
|
+
- **Note**: Determines failover and connection behavior from the selected availability objective; read/write splitting is not implied unless the workload and datastore support it.
|
|
167
172
|
- **Maps to**: `{{ ha }}` + `{{ ops_rules }}`
|
|
168
173
|
|
|
169
174
|
---
|
|
@@ -174,7 +179,7 @@ Total: 15 questions.
|
|
|
174
179
|
- **Options**:
|
|
175
180
|
- A) AI may only generate migration files; human reviews before execution **【Recommended】**
|
|
176
181
|
- B) AI may not generate any DDL (fully human-managed)
|
|
177
|
-
- C) AI may
|
|
182
|
+
- C) AI may generate DDL and execute it only in an explicitly identified disposable development environment under Q15 safety confirmation
|
|
178
183
|
- **Maps to**: `{{ ai_ddl_rule }}`
|
|
179
184
|
|
|
180
185
|
### Q15. AI Safety Constraints
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schema_version": "app-planner-question-manifest-
|
|
2
|
+
"schema_version": "app-planner-question-manifest-v2",
|
|
3
3
|
"layer": "database",
|
|
4
4
|
"total_questions": 15,
|
|
5
5
|
"_doc": "Machine-readable structure for database question-bank.md. Question TEXT/options/Recommended/Notes are authoritative in question-bank.md; this file carries ONLY structure: group membership, quick-mode, question->placeholder mapping, and conditional logic. Keep Qids and group ids in sync with question-bank.md. The AI reads this as its asking checklist (Phase A) and self-check expected-set (Phase D).",
|
|
6
6
|
"_conditions": "required_if / auto_derived_when use simple expressions over recorded answers. options_vary_by names a prior answer that changes the OPTION LIST only (question is still asked; never affects required). A single answer may fill more than one placeholder (a TL;DR value + a rules-block), both listed in maps_to.",
|
|
7
|
+
"render_contract": {
|
|
8
|
+
"fixed_rules_policy": "invariants_only",
|
|
9
|
+
"selected_decision_precedence": true,
|
|
10
|
+
"quick_mode_requires_explicit_authorization": true,
|
|
11
|
+
"unmapped_option_policy": "semantic_fallback",
|
|
12
|
+
"not_applicable_policy": "explicit_statement",
|
|
13
|
+
"conflict_policy": "fail_generation",
|
|
14
|
+
"semantic_fallback_questions": ["Q1", "Q2", "Q3", "Q4", "Q5", "Q6", "Q7", "Q8", "Q9", "Q10", "Q11", "Q12", "Q13", "Q14", "Q15"]
|
|
15
|
+
},
|
|
7
16
|
"groups": [
|
|
8
17
|
{ "id": "G1", "topic": "Database Selection", "quick_mode": true },
|
|
9
18
|
{ "id": "G2", "topic": "Data Modeling", "quick_mode": true },
|
|
@@ -16,11 +25,11 @@
|
|
|
16
25
|
"questions": [
|
|
17
26
|
{ "id": "Q1", "group": "G1", "topic": "Primary Database", "maps_to": ["database", "tech_rules"], "required": true },
|
|
18
27
|
{ "id": "Q2", "group": "G1", "topic": "Cache Layer", "maps_to": ["cache", "cache_rules"], "required": true },
|
|
19
|
-
{ "id": "Q3", "group": "G2", "topic": "Primary Key Strategy", "maps_to": ["pk_strategy", "schema_rules"], "required": true },
|
|
28
|
+
{ "id": "Q3", "group": "G2", "topic": "Primary Key Strategy", "maps_to": ["pk_strategy", "schema_rules"], "required": true, "options_vary_by": "Q1" },
|
|
20
29
|
{ "id": "Q4", "group": "G2", "topic": "Soft Delete", "maps_to": ["soft_delete", "schema_rules"], "required": true },
|
|
21
|
-
{ "id": "Q5", "group": "G2", "topic": "Normalization Level", "maps_to": ["normalization", "schema_rules"], "required": true },
|
|
30
|
+
{ "id": "Q5", "group": "G2", "topic": "Modeling / Normalization Level", "maps_to": ["normalization", "schema_rules"], "required": true, "required_if": "Q1 != C", "auto_derived_when": "Q1 == C" },
|
|
22
31
|
{ "id": "Q6", "group": "G3", "topic": "Migration Tool", "maps_to": ["migration_tool", "migration_rules"], "required": true },
|
|
23
|
-
{ "id": "Q7", "group": "G4", "topic": "
|
|
32
|
+
{ "id": "Q7", "group": "G4", "topic": "Workload Type", "maps_to": ["workload_type", "performance_rules"], "required": true },
|
|
24
33
|
{ "id": "Q8", "group": "G4", "topic": "Estimated Data Volume", "maps_to": ["data_scale", "performance_rules"], "required": true },
|
|
25
34
|
{ "id": "Q9", "group": "G5", "topic": "Data Sensitivity Level", "maps_to": ["data_sensitivity", "security_rules"], "required": true },
|
|
26
35
|
{ "id": "Q10", "group": "G5", "topic": "Audit Requirements", "maps_to": ["audit", "audit_rules"], "required": true, "multi_select": true },
|