prizmkit 1.1.154 → 1.1.155

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.
Files changed (157) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/codex/skill-adapter.js +1 -1
  3. package/bundled/adapters/pi/skill-adapter.js +2 -1
  4. package/bundled/dev-pipeline/.env.example +2 -6
  5. package/bundled/dev-pipeline/README.md +21 -27
  6. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +341 -15
  7. package/bundled/dev-pipeline/prizmkit_runtime/cli.py +0 -3
  8. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +1 -15
  9. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +48 -14
  10. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +50 -2
  11. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +0 -9
  12. package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +3 -3
  13. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +120 -22
  14. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +482 -0
  15. package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +64 -11
  16. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +145 -367
  17. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +91 -62
  18. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +105 -69
  19. package/bundled/dev-pipeline/scripts/prompt_framework.py +36 -41
  20. package/bundled/dev-pipeline/scripts/update-bug-status.py +1 -4
  21. package/bundled/dev-pipeline/scripts/update-checkpoint.py +61 -13
  22. package/bundled/dev-pipeline/scripts/update-feature-status.py +1 -4
  23. package/bundled/dev-pipeline/scripts/update-refactor-status.py +1 -4
  24. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +22 -27
  25. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +71 -104
  26. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +59 -111
  27. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +37 -72
  28. package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +39 -0
  29. package/bundled/dev-pipeline/templates/sections/bugfix-critical-paths.md +3 -1
  30. package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +8 -25
  31. package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +3 -3
  32. package/bundled/dev-pipeline/templates/sections/bugfix-phase-implement.md +2 -2
  33. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +3 -3
  34. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -2
  35. package/bundled/dev-pipeline/templates/sections/bugfix-reminders.md +4 -4
  36. package/bundled/dev-pipeline/templates/sections/bugfix-session-context.md +0 -1
  37. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +7 -4
  38. package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +14 -27
  39. package/bundled/dev-pipeline/templates/sections/feature-completion-summary.md +20 -0
  40. package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +8 -71
  41. package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +7 -7
  42. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +3 -3
  43. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +4 -4
  44. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +5 -17
  45. package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +3 -1
  46. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +10 -23
  47. package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +2 -2
  48. package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +2 -2
  49. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +3 -3
  50. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +2 -2
  51. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +7 -7
  52. package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -1
  53. package/bundled/dev-pipeline/templates/sections/retrospective.md +12 -0
  54. package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +35 -0
  55. package/bundled/dev-pipeline/templates/session-status-schema.json +45 -62
  56. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +469 -18
  57. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +262 -175
  58. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +62 -23
  59. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +76 -28
  60. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +168 -18
  61. package/bundled/dev-pipeline/tests/test_recovery_workflow.py +111 -0
  62. package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -2
  63. package/bundled/dev-pipeline/tests/test_runtime_commit.py +608 -0
  64. package/bundled/dev-pipeline/tests/test_unified_cli.py +167 -25
  65. package/bundled/skills/_metadata.json +9 -9
  66. package/bundled/skills/app-planner/SKILL.md +3 -3
  67. package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
  68. package/bundled/skills/app-planner/references/rules/backend/derivation-rules.md +56 -64
  69. package/bundled/skills/app-planner/references/rules/backend/fixed-rules.md +85 -240
  70. package/bundled/skills/app-planner/references/rules/backend/question-bank.md +25 -25
  71. package/bundled/skills/app-planner/references/rules/backend/question-manifest.json +16 -7
  72. package/bundled/skills/app-planner/references/rules/backend/template.md +74 -92
  73. package/bundled/skills/app-planner/references/rules/database/derivation-rules.md +93 -93
  74. package/bundled/skills/app-planner/references/rules/database/fixed-rules.md +66 -173
  75. package/bundled/skills/app-planner/references/rules/database/question-bank.md +31 -26
  76. package/bundled/skills/app-planner/references/rules/database/question-manifest.json +13 -4
  77. package/bundled/skills/app-planner/references/rules/database/template.md +76 -98
  78. package/bundled/skills/app-planner/references/rules/frontend/derivation-rules.md +68 -95
  79. package/bundled/skills/app-planner/references/rules/frontend/fixed-rules.md +93 -166
  80. package/bundled/skills/app-planner/references/rules/frontend/question-bank.md +46 -36
  81. package/bundled/skills/app-planner/references/rules/frontend/question-manifest.json +11 -2
  82. package/bundled/skills/app-planner/references/rules/frontend/template.md +79 -257
  83. package/bundled/skills/app-planner/references/rules/mobile/derivation-rules.md +91 -99
  84. package/bundled/skills/app-planner/references/rules/mobile/fixed-rules.md +73 -246
  85. package/bundled/skills/app-planner/references/rules/mobile/question-bank.md +17 -17
  86. package/bundled/skills/app-planner/references/rules/mobile/question-manifest.json +17 -2
  87. package/bundled/skills/app-planner/references/rules/mobile/template.md +73 -85
  88. package/bundled/skills/app-planner/references/rules-configuration.md +133 -65
  89. package/bundled/skills/app-planner/scripts/validate-rules-configuration.py +291 -0
  90. package/bundled/skills/prizmkit/SKILL.md +17 -18
  91. package/bundled/skills/prizmkit/references/workflow-state-protocol.md +22 -18
  92. package/bundled/skills/prizmkit-code-review/SKILL.md +22 -58
  93. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +6 -6
  94. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +2 -2
  95. package/bundled/skills/prizmkit-committer/SKILL.md +82 -132
  96. package/bundled/skills/prizmkit-deploy/SKILL.md +27 -11
  97. package/bundled/skills/prizmkit-deploy/assets/deploy-document-template.md +89 -0
  98. package/bundled/skills/prizmkit-deploy/references/ci-cd-workflows.md +44 -14
  99. package/bundled/skills/prizmkit-deploy/references/cloud-platform-deploy.md +19 -3
  100. package/bundled/skills/prizmkit-deploy/references/database-setup.md +22 -12
  101. package/bundled/skills/prizmkit-deploy/references/deploy-config-schema.md +3 -1
  102. package/bundled/skills/prizmkit-deploy/references/deploy-history-schema.md +22 -6
  103. package/bundled/skills/prizmkit-deploy/references/deploy-metadata-schema.json +49 -0
  104. package/bundled/skills/prizmkit-deploy/references/live-validation-notes.md +1 -1
  105. package/bundled/skills/prizmkit-deploy/references/pending-input-schema.json +164 -0
  106. package/bundled/skills/prizmkit-deploy/references/ssh-adapter-flow.md +9 -8
  107. package/bundled/skills/prizmkit-deploy/references/ssh-execution-flow.md +6 -6
  108. package/bundled/skills/prizmkit-implement/SKILL.md +30 -66
  109. package/bundled/skills/prizmkit-implement/references/implementation-subagent-procedure.md +4 -4
  110. package/bundled/skills/prizmkit-init/SKILL.md +4 -0
  111. package/bundled/skills/prizmkit-plan/SKILL.md +21 -64
  112. package/bundled/skills/prizmkit-plan/references/artifact-identity.md +38 -0
  113. package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +4 -4
  114. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +5 -5
  115. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +11 -1
  116. package/bundled/skills/prizmkit-retrospective/SKILL.md +63 -77
  117. package/bundled/skills/prizmkit-retrospective/references/knowledge-injection-steps.md +3 -3
  118. package/bundled/skills/prizmkit-retrospective/references/retrospective-result-schema.json +138 -0
  119. package/bundled/skills/prizmkit-retrospective/references/structural-sync-steps.md +17 -23
  120. package/bundled/skills/prizmkit-test/SKILL.md +64 -51
  121. package/bundled/skills/prizmkit-test/references/boundary-contract-and-test-double-guidance.md +206 -0
  122. package/bundled/skills/prizmkit-test/references/independent-test-review.md +17 -9
  123. package/bundled/skills/prizmkit-test/references/test-coverage-model.md +45 -21
  124. package/bundled/skills/prizmkit-test/references/test-report-template.md +20 -13
  125. package/bundled/skills/prizmkit-workflow/SKILL.md +35 -37
  126. package/bundled/skills/prizmkit-workflow/references/artifact-identity.md +34 -0
  127. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +22 -18
  128. package/bundled/skills/recovery-workflow/SKILL.md +2 -1
  129. package/bundled/skills/recovery-workflow/references/detection.md +4 -3
  130. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +15 -5
  131. package/package.json +1 -1
  132. package/src/scaffold.js +33 -22
  133. package/bundled/dev-pipeline/templates/sections/bugfix-artifacts.md +0 -16
  134. package/bundled/dev-pipeline/templates/sections/bugfix-session-status.md +0 -31
  135. package/bundled/dev-pipeline/templates/sections/critical-paths-agent.md +0 -7
  136. package/bundled/dev-pipeline/templates/sections/critical-paths-lite.md +0 -7
  137. package/bundled/dev-pipeline/templates/sections/directory-convention-agent.md +0 -9
  138. package/bundled/dev-pipeline/templates/sections/directory-convention-lite.md +0 -6
  139. package/bundled/dev-pipeline/templates/sections/headless-commit-authorization.md +0 -15
  140. package/bundled/dev-pipeline/templates/sections/phase-commit.md +0 -61
  141. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +0 -24
  142. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-lite-suffix.md +0 -12
  143. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +0 -44
  144. package/bundled/dev-pipeline/templates/sections/phase-implement-lite.md +0 -25
  145. package/bundled/dev-pipeline/templates/sections/phase-plan-agent.md +0 -20
  146. package/bundled/dev-pipeline/templates/sections/phase-plan-lite.md +0 -20
  147. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +0 -20
  148. package/bundled/dev-pipeline/templates/sections/refactor-artifacts.md +0 -17
  149. package/bundled/dev-pipeline/templates/sections/refactor-session-status.md +0 -28
  150. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-agent.md +0 -52
  151. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-lite.md +0 -52
  152. package/bundled/skills/prizmkit-code-review/references/workflow-state-protocol.md +0 -174
  153. package/bundled/skills/prizmkit-committer/references/workflow-state-protocol.md +0 -174
  154. package/bundled/skills/prizmkit-implement/references/workflow-state-protocol.md +0 -174
  155. package/bundled/skills/prizmkit-plan/references/workflow-state-protocol.md +0 -174
  156. package/bundled/skills/prizmkit-retrospective/references/workflow-state-protocol.md +0 -174
  157. package/bundled/skills/prizmkit-test/references/external-contract-mock-guidance.md +0 -119
@@ -1,211 +1,104 @@
1
- # Fixed Rules — Complete Database Fixed Rules
1
+ # Database Invariant Rules
2
2
 
3
- > This file is read by the `database-rules` skill in Phase 1 and injected directly into `database-rules.md`.
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
- ## F1. Schema Design
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
- ### F1.1 Naming Conventions (Mandatory)
9
+ ## I1. Schema and Model Integrity
12
10
 
13
- - **Table names**: snake_case plural (`users`, `order_items`), not camelCase. Junction tables use alphabetical concatenation (`user_roles`).
14
- - **Column names**: snake_case (`created_at`, `user_id`), not camelCase.
15
- - **Primary keys**: use `id` for single tables, or concatenated names for junction tables (`user_id`, `role_id`).
16
- - **Foreign keys**: `<referenced_table>_id` (`user_id`, `order_id`).
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
- ### F1.2 Required Fields
16
+ Inject into `{{ FIXED_RULES_SCHEMA }}`.
23
17
 
24
- - **Rule**: Every business table must have:
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
- ### F1.3 Primary Key Strategy
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
- - **Rule**: Prefer UUID v4/v7 or ULID as the business primary key exposed to APIs.
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
- ### F1.4 Normalization vs. Denormalization
27
+ ## I3. Access-Path Integrity
41
28
 
42
- - **Rule**: Default to 3NF (Third Normal Form) to reduce data redundancy.
43
- - **Denormalization exception**: Only allowed when query performance is a proven bottleneck AND index optimization has been exhausted. Must be documented with rationale in schema comments.
44
- - **Forbidden**: Denormalizing without load testing.
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
- ### F1.5 Enum Values
33
+ Inject into `{{ FIXED_RULES_INDEX }}`.
48
34
 
49
- - **Rule**: Status columns must list all possible values in schema comments.
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
- ## F2. Column Types
41
+ Inject into `{{ FIXED_RULES_TRANSACTION }}`.
57
42
 
58
- - **Rule**: Monetary amounts always use `DECIMAL(19,4)` or `NUMERIC`. Forbid `FLOAT`/`DOUBLE`.
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
- ## F3. Index Strategy
49
+ Inject into `{{ FIXED_RULES_MIGRATION }}`.
69
50
 
70
- - **Rule**: Primary keys are auto-indexed. Foreign keys must be manually indexed.
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
- ## F3b. Transaction Isolation
58
+ Inject into `{{ FIXED_RULES_QUERY }}`.
82
59
 
83
- ### F3b.1 Transaction Isolation
60
+ ## I7. Data Security
84
61
 
85
- - **Rule**: Explicitly set transaction isolation level for each transaction. Do not rely on database defaults.
86
- - **Rule**: Default isolation for OLTP: READ COMMITTED (balances consistency and performance). For financial operations: REPEATABLE READ or SERIALIZABLE.
87
- - **Rule**: Document the chosen isolation level per business operation in code comments.
88
- - **Forbidden**: Using SERIALIZABLE for high-throughput read operations (causes unnecessary contention).
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
- ## F4. Migration Management
69
+ ## I8. Recovery Integrity
94
70
 
95
- - **Rule**: All database structure changes must go through versioned migration files. Forbid executing SQL directly against production databases.
96
- - **Rule**: Migration file naming: `V<number>__<description>.sql` (Flyway format) or `<timestamp>_<description>.sql` (custom format).
97
- - **Rule**: Each migration file must include both `up` (forward) and corresponding `down` (rollback).
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
- ## F5. Query Standards
77
+ ## I9. Performance Integrity
108
78
 
109
- - **Rule**: All SQL must be parameterized. Forbid string concatenation with user input.
110
- - **Rule**: SELECT must explicitly list column names. Forbid `SELECT *`.
111
- - **Rule**: Queries must have LIMIT (unless the business explicitly requires full results and data volume is controllable).
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
- ## F6. Security & Permissions
85
+ ## I10. Connection and Client Lifecycle
121
86
 
122
- - **Rule**: Application accounts get minimum privileges separate read and write accounts. Read accounts only get SELECT.
123
- - **Rule**: Forbid using root/superuser accounts for application connections.
124
- - **Rule**: Connections must enforce TLS/SSL.
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
- ## F7. Backup & Recovery
93
+ ## I11. AI Data-Change Safety
132
94
 
133
- - **Rule**: Automated backup strategy daily full + continuous incremental/archiving (WAL archiving / binlog).
134
- - **Rule**: Backup files must be stored offsite and encrypted.
135
- - **Rule**: Regular recovery drills are mandatory (at least quarterly) to verify backup usability.
136
- - **Rule**: PITR (Point-in-Time Recovery) must be available — recovering only to the last full backup is not sufficient.
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
- ## F8. Performance
102
+ ## Injection Contract
142
103
 
143
- - **Rule**: Connection pool limit 80% of database `max_connections`, leaving headroom for admin connections.
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` → skip all remaining groups, adopt all recommended options
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
- - **Note**: Choosing D injects the rule "forbid exposing auto-increment IDs to the frontend."
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 whether audit fields and unique indexes with `deleted_at` rules are needed.
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
- - **Options**:
84
- - A) Strict 3NF; denormalization requires comments explaining why **【Recommended】**
85
- - B) Allow partial denormalization (OLAP/reporting scenarios)
86
- - **Note**: Determines the threshold for data redundancy.
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. Query Complexity
110
+ ### Q7. Workload Type
106
111
  - **Options**:
107
- - A) OLTP (high-frequency small queries, 10ms each) **【Recommended: web apps】**
108
- - B) OLAP (low-frequency large queries, 100ms each)
109
- - C) Mixed (has reporting/analytics needs)
110
- - **Note**: Determines slow query thresholds, index strategy strictness, and partitioning rules.
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 rows (large scale, partitioning strategy is mandatory)
118
- - **Note**: Determines the urgency of partitioning and archival rules.
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 PII (Personally Identifiable Information), encryption at rest required **【Recommended: privacy-first, safest default】**
128
- - B) Business data only, no special encryption needed
129
- - **Note**: Choosing A auto-injects "encrypt sensitive fields", "log desensitization", and other strict rules.
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**: **Multi-select allowed** audit tables (A) and CDC (B) serve different purposes and can be used together. Determines audit table structure and trigger rules.
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) Primary-replica replication / read-write split **【Recommended: production environments】**
164
- - B) Single instance is sufficient
165
- - C) Multi-master cluster
166
- - **Note**: Determines connection pool configuration and failover strategy.
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 operate freely (development environment)
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-v1",
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": "Query Complexity", "maps_to": ["workload_type", "performance_rules"], "required": true },
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 },