@cubis/foundry 0.3.10 → 0.3.11

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 (56) hide show
  1. package/Ai Agent Workflow/powers/database-skills/POWER.md +15 -2
  2. package/Ai Agent Workflow/powers/database-skills/SKILL.md +26 -2
  3. package/Ai Agent Workflow/powers/database-skills/engines/mongodb/POWER.md +10 -0
  4. package/Ai Agent Workflow/powers/database-skills/engines/mysql/POWER.md +10 -0
  5. package/Ai Agent Workflow/powers/database-skills/engines/neki/POWER.md +10 -0
  6. package/Ai Agent Workflow/powers/database-skills/engines/postgres/POWER.md +10 -0
  7. package/Ai Agent Workflow/powers/database-skills/engines/redis/POWER.md +10 -0
  8. package/Ai Agent Workflow/powers/database-skills/engines/sqlite/POWER.md +10 -0
  9. package/Ai Agent Workflow/powers/database-skills/engines/supabase/POWER.md +10 -0
  10. package/Ai Agent Workflow/powers/database-skills/engines/vitess/POWER.md +10 -0
  11. package/Ai Agent Workflow/powers/database-skills/steering/readme.md +18 -6
  12. package/Ai Agent Workflow/skills/database-skills/LATEST_VERSIONS.md +36 -0
  13. package/Ai Agent Workflow/skills/database-skills/README.md +11 -2
  14. package/Ai Agent Workflow/skills/database-skills/SKILL.md +85 -20
  15. package/Ai Agent Workflow/skills/database-skills/skills/mongodb/SKILL.md +29 -7
  16. package/Ai Agent Workflow/skills/database-skills/skills/mongodb/references/aggregation.md +153 -0
  17. package/Ai Agent Workflow/skills/database-skills/skills/mongodb/references/modeling.md +95 -4
  18. package/Ai Agent Workflow/skills/database-skills/skills/mongodb/references/mongoose-nestjs.md +133 -4
  19. package/Ai Agent Workflow/skills/database-skills/skills/mysql/SKILL.md +33 -7
  20. package/Ai Agent Workflow/skills/database-skills/skills/mysql/references/locking-ddl.md +103 -4
  21. package/Ai Agent Workflow/skills/database-skills/skills/mysql/references/query-indexing.md +103 -4
  22. package/Ai Agent Workflow/skills/database-skills/skills/mysql/references/replication.md +142 -0
  23. package/Ai Agent Workflow/skills/database-skills/skills/neki/SKILL.md +18 -7
  24. package/Ai Agent Workflow/skills/database-skills/skills/neki/references/architecture.md +135 -4
  25. package/Ai Agent Workflow/skills/database-skills/skills/neki/references/operations.md +76 -4
  26. package/Ai Agent Workflow/skills/database-skills/skills/postgres/SKILL.md +31 -7
  27. package/Ai Agent Workflow/skills/database-skills/skills/postgres/references/connection-pooling.md +142 -0
  28. package/Ai Agent Workflow/skills/database-skills/skills/postgres/references/migrations.md +126 -0
  29. package/Ai Agent Workflow/skills/database-skills/skills/postgres/references/performance-ops.md +116 -4
  30. package/Ai Agent Workflow/skills/database-skills/skills/postgres/references/schema-indexing.md +78 -4
  31. package/Ai Agent Workflow/skills/database-skills/skills/redis/SKILL.md +28 -7
  32. package/Ai Agent Workflow/skills/database-skills/skills/redis/references/cache-patterns.md +153 -4
  33. package/Ai Agent Workflow/skills/database-skills/skills/redis/references/data-modeling.md +152 -0
  34. package/Ai Agent Workflow/skills/database-skills/skills/redis/references/operations.md +143 -4
  35. package/Ai Agent Workflow/skills/database-skills/skills/sqlite/SKILL.md +28 -7
  36. package/Ai Agent Workflow/skills/database-skills/skills/sqlite/references/local-first.md +94 -4
  37. package/Ai Agent Workflow/skills/database-skills/skills/sqlite/references/performance.md +104 -4
  38. package/Ai Agent Workflow/skills/database-skills/skills/supabase/SKILL.md +27 -7
  39. package/Ai Agent Workflow/skills/database-skills/skills/supabase/references/performance-operations.md +94 -4
  40. package/Ai Agent Workflow/skills/database-skills/skills/supabase/references/rls-auth.md +105 -4
  41. package/Ai Agent Workflow/skills/database-skills/skills/vitess/SKILL.md +27 -7
  42. package/Ai Agent Workflow/skills/database-skills/skills/vitess/references/operational-safety.md +104 -4
  43. package/Ai Agent Workflow/skills/database-skills/skills/vitess/references/sharding-routing.md +124 -4
  44. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/antigravity/agents/backend-specialist.md +1 -1
  45. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/antigravity/agents/database-architect.md +8 -1
  46. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/antigravity/agents/performance-optimizer.md +2 -0
  47. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/antigravity/workflows/database.md +11 -6
  48. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/codex/agents/backend-specialist.md +1 -1
  49. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/codex/agents/database-architect.md +8 -1
  50. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/codex/agents/performance-optimizer.md +2 -0
  51. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/codex/workflows/database.md +11 -6
  52. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/copilot/agents/backend-specialist.md +1 -1
  53. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/copilot/agents/database-architect.md +8 -1
  54. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/copilot/agents/performance-optimizer.md +2 -0
  55. package/Ai Agent Workflow/workflows/agent-environment-setup/platforms/copilot/workflows/database.md +11 -6
  56. package/package.json +1 -1
@@ -1,5 +1,125 @@
1
- # Vitess Sharding and Routing
1
+ # Vitess Sharding and VSchema Design
2
2
 
3
- - Define shard key from access patterns and growth model.
4
- - Keep hot paths shard-local when possible.
5
- - Validate query routing behavior before launch.
3
+ ## Core concept
4
+
5
+ The **VSchema** tells VTGate how to route queries. It defines which tables belong to which keyspace, which column determines shard placement (the **primary vindex**), and how tables relate across shards.
6
+
7
+ ## Shard routing types
8
+
9
+ | Routing | Condition | Performance |
10
+ | --- | --- | --- |
11
+ | **Single-shard** | `WHERE` on primary vindex with `=` | Best |
12
+ | **Multi-shard (targeted)** | `WHERE` with `IN` on primary vindex | Good |
13
+ | **Scatter** | No primary vindex filter | Expensive — hits all shards |
14
+
15
+ Always include the primary vindex column in `WHERE` clauses to avoid scatter queries.
16
+
17
+ ## Choosing a primary vindex column
18
+
19
+ Pick the column that:
20
+ 1. Appears in your highest-QPS `WHERE` clauses.
21
+ 2. Enables join co-location — tables frequently joined should shard on the same column.
22
+ 3. Keeps transactions within a single shard.
23
+ 4. Has high cardinality for even distribution.
24
+ 5. Is immutable — changing it after insert requires a data migration.
25
+
26
+ Common choices: `user_id`, `tenant_id`, `org_id`, `account_id`.
27
+
28
+ ## Vindex types
29
+
30
+ | Type | When to use |
31
+ | --- | --- |
32
+ | `xxhash` | Any column type — most common |
33
+ | `unicode_loose_xxhash` | Text columns needing case-insensitive hashing |
34
+ | `binary_md5` | MD5-based alternative for any column type |
35
+
36
+ ## VSchema structure (sharded keyspace)
37
+
38
+ ```json
39
+ {
40
+ "sharded": true,
41
+ "vindexes": {
42
+ "xxhash": { "type": "xxhash" }
43
+ },
44
+ "tables": {
45
+ "orders": {
46
+ "column_vindexes": [
47
+ { "column": "customer_id", "name": "xxhash" }
48
+ ],
49
+ "auto_increment": {
50
+ "column": "id",
51
+ "sequence": "unsharded_keyspace.orders_seq"
52
+ }
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ ## Sequences — replacing AUTO_INCREMENT
59
+
60
+ Per-shard `AUTO_INCREMENT` produces duplicate IDs across shards. Use Vitess Sequences instead.
61
+
62
+ 1. Create in an **unsharded** keyspace:
63
+ ```sql
64
+ CREATE TABLE orders_seq (id BIGINT, next_id BIGINT, cache BIGINT, PRIMARY KEY(id))
65
+ COMMENT 'vitess_sequence';
66
+ INSERT INTO orders_seq (id, next_id, cache) VALUES (0, 1, 1000);
67
+ ```
68
+ 2. Register in unsharded VSchema: `{ "orders_seq": { "type": "sequence" } }`
69
+ 3. Link to sharded table via `auto_increment` in sharded VSchema (see above).
70
+
71
+ Sequence gaps from caching/restarts are expected and harmless.
72
+
73
+ ## Lookup vindexes (secondary routing)
74
+
75
+ Lookup vindexes let you route by non-primary-vindex columns without scatter. They are backed by a separate mapping table. **They are expensive** — avoid unless scatter on the column is genuinely a problem.
76
+
77
+ ```json
78
+ "customer_email_lookup": {
79
+ "type": "consistent_lookup",
80
+ "params": {
81
+ "table": "product.customer_email_lookup",
82
+ "from": "email",
83
+ "to": "keyspace_id"
84
+ },
85
+ "owner": "customer"
86
+ }
87
+ ```
88
+
89
+ Use `consistent_lookup_unique` only when uniqueness across shards must be enforced at the DB level (this is a scalability anti-pattern — prefer app-level enforcement).
90
+
91
+ ## Discover existing VSchema
92
+
93
+ ```bash
94
+ vtctldclient GetVSchema <keyspace> # full JSON
95
+ vtctldclient GetVSchema <keyspace> | jq '.vindexes' # just vindexes
96
+ ```
97
+
98
+ ```sql
99
+ SHOW VSCHEMA TABLES; -- tables known to VTGate
100
+ SHOW VSCHEMA VINDEXES; -- vindexes and types
101
+ ```
102
+
103
+ ## Troubleshoot scatter queries
104
+
105
+ ```sql
106
+ VEXPLAIN PLAN SELECT * FROM orders WHERE customer_id = 42;
107
+ -- Look for Route variant: EqualUnique (single-shard) vs Scatter (all shards)
108
+
109
+ VEXPLAIN ALL SELECT ...; -- includes MySQL plans from each tablet
110
+ VEXPLAIN TRACE SELECT ...; -- shows row counts passed between query parts
111
+ ```
112
+
113
+ If a query scatters:
114
+ 1. Is `WHERE` filtering on the primary vindex column? If not, add it.
115
+ 2. Is a lookup vindex configured for that column? If needed, add one.
116
+ 3. Primary vindex column updates are blocked — use `MoveTables` to re-shard if needed.
117
+
118
+ ## Reference tables
119
+
120
+ Small, rarely-changing lookup data (countries, currencies, enums) can use `"type": "reference"` — they are replicated to all shards and never scatter.
121
+
122
+ ## Sources
123
+ - VSchema guide: https://vitess.io/docs/user-guides/vschema-guide/
124
+ - Vindexes reference: https://vitess.io/docs/reference/features/vschema/
125
+ - Sharding key selection: https://vitess.io/docs/faq/advanced-configuration/vschema/how-do-you-select-your-sharding-key-for-vitess/
@@ -260,4 +260,4 @@ After editing any file:
260
260
 
261
261
  ---
262
262
 
263
- > **Note:** This agent loads relevant skills for detailed guidance. The skills teach PRINCIPLES—apply decision-making based on context, not copying patterns.
263
+ > **Note:** For database-heavy backend work, route through `database-skills` plus `Ai Agent Workflow/powers/database-skills` so indexing, pagination, query-plan evidence, and rollback stay explicit.
@@ -209,6 +209,13 @@ After database changes:
209
209
 
210
210
  ---
211
211
 
212
+ ## Database Power Routing (MANDATORY)
213
+
214
+ 1. Load `database-skills` as the core package.
215
+ 2. Load power bridge: `Ai Agent Workflow/powers/database-skills/POWER.md`.
216
+ 3. Pick engine wrapper in `Ai Agent Workflow/powers/database-skills/engines/<engine>/POWER.md`.
217
+ 4. Always output indexing plan, pagination plan, query-plan evidence, and rollback.
218
+
212
219
  ## When You Should Be Used
213
220
 
214
221
  - Designing new database schemas
@@ -223,4 +230,4 @@ After database changes:
223
230
 
224
231
  ---
225
232
 
226
- > **Note:** This agent loads the unified `database-skills` skill package for detailed guidance. Apply principles to context; do not copy patterns blindly.
233
+ > **Note:** Use `database-skills` as source of truth. Use `Ai Agent Workflow/powers/database-skills` for power-mode routing, especially engine wrappers (`postgres`, `mysql`, `vitess`, `neki`, `mongodb`, `sqlite`, `supabase`, `redis`).
@@ -185,3 +185,5 @@ What's slow?
185
185
  ---
186
186
 
187
187
  > **Remember:** Users don't care about benchmarks. They care about feeling fast.
188
+
189
+ > **Database path:** For query/storage bottlenecks, route through `database-skills` and `Ai Agent Workflow/powers/database-skills` and report index/pagination/plan evidence.
@@ -5,22 +5,27 @@ triggers: ["database", "sql", "schema", "migration", "index"]
5
5
  ---
6
6
  # Database Workflow
7
7
 
8
- Use this when data modeling, query quality, or migration safety is core to the task.
8
+ Use this when data modeling, query quality, migration safety, or database performance is core to the task.
9
9
 
10
10
  ## Routing
11
11
  - Primary specialist: `@database-architect`
12
12
  - Backend integration: `@backend-specialist`
13
13
  - Verification support: `@test-engineer`
14
14
  - Core skill package: `database-skills`
15
+ - Power bridge: `Ai Agent Workflow/powers/database-skills`
16
+ - Engine wrappers: `postgres`, `mysql`, `vitess`, `neki`, `mongodb`, `sqlite`, `supabase`, `redis`
15
17
 
16
18
  ## Steps
17
- 1. Confirm data shape and access patterns.
18
- 2. Design schema/index strategy.
19
- 3. Plan migration with rollback.
20
- 4. Validate performance and integrity impacts.
19
+ 1. Confirm data shape, access patterns, and workload size.
20
+ 2. Choose engine wrapper and define index strategy.
21
+ 3. Define pagination strategy (keyset first, offset only if justified).
22
+ 4. Plan migration and rollback.
23
+ 5. Validate with query-plan evidence and production-risk notes.
21
24
 
22
25
  ## Output Contract
23
26
  - Schema/query changes
27
+ - Indexing plan
28
+ - Pagination plan
24
29
  - Migration + rollback plan
25
- - Performance expectations
30
+ - Query-plan evidence (`EXPLAIN` or equivalent)
26
31
  - Validation evidence
@@ -260,4 +260,4 @@ After editing any file:
260
260
 
261
261
  ---
262
262
 
263
- > **Note:** This agent loads relevant skills for detailed guidance. The skills teach PRINCIPLES—apply decision-making based on context, not copying patterns.
263
+ > **Note:** For database-heavy backend work, route through `database-skills` plus `Ai Agent Workflow/powers/database-skills` so indexing, pagination, query-plan evidence, and rollback stay explicit.
@@ -209,6 +209,13 @@ After database changes:
209
209
 
210
210
  ---
211
211
 
212
+ ## Database Power Routing (MANDATORY)
213
+
214
+ 1. Load `database-skills` as the core package.
215
+ 2. Load power bridge: `Ai Agent Workflow/powers/database-skills/POWER.md`.
216
+ 3. Pick engine wrapper in `Ai Agent Workflow/powers/database-skills/engines/<engine>/POWER.md`.
217
+ 4. Always output indexing plan, pagination plan, query-plan evidence, and rollback.
218
+
212
219
  ## When You Should Be Used
213
220
 
214
221
  - Designing new database schemas
@@ -223,4 +230,4 @@ After database changes:
223
230
 
224
231
  ---
225
232
 
226
- > **Note:** This agent loads the unified `database-skills` skill package for detailed guidance. Apply principles to context; do not copy patterns blindly.
233
+ > **Note:** Use `database-skills` as source of truth. Use `Ai Agent Workflow/powers/database-skills` for power-mode routing, especially engine wrappers (`postgres`, `mysql`, `vitess`, `neki`, `mongodb`, `sqlite`, `supabase`, `redis`).
@@ -185,3 +185,5 @@ What's slow?
185
185
  ---
186
186
 
187
187
  > **Remember:** Users don't care about benchmarks. They care about feeling fast.
188
+
189
+ > **Database path:** For query/storage bottlenecks, route through `database-skills` and `Ai Agent Workflow/powers/database-skills` and report index/pagination/plan evidence.
@@ -5,22 +5,27 @@ triggers: ["database", "sql", "schema", "migration", "index"]
5
5
  ---
6
6
  # Database Workflow
7
7
 
8
- Use this when data modeling, query quality, or migration safety is core to the task.
8
+ Use this when data modeling, query quality, migration safety, or database performance is core to the task.
9
9
 
10
10
  ## Routing
11
11
  - Primary specialist: `@database-architect`
12
12
  - Backend integration: `@backend-specialist`
13
13
  - Verification support: `@test-engineer`
14
14
  - Core skill package: `database-skills`
15
+ - Power bridge: `Ai Agent Workflow/powers/database-skills`
16
+ - Engine wrappers: `postgres`, `mysql`, `vitess`, `neki`, `mongodb`, `sqlite`, `supabase`, `redis`
15
17
 
16
18
  ## Steps
17
- 1. Confirm data shape and access patterns.
18
- 2. Design schema/index strategy.
19
- 3. Plan migration with rollback.
20
- 4. Validate performance and integrity impacts.
19
+ 1. Confirm data shape, access patterns, and workload size.
20
+ 2. Choose engine wrapper and define index strategy.
21
+ 3. Define pagination strategy (keyset first, offset only if justified).
22
+ 4. Plan migration and rollback.
23
+ 5. Validate with query-plan evidence and production-risk notes.
21
24
 
22
25
  ## Output Contract
23
26
  - Schema/query changes
27
+ - Indexing plan
28
+ - Pagination plan
24
29
  - Migration + rollback plan
25
- - Performance expectations
30
+ - Query-plan evidence (`EXPLAIN` or equivalent)
26
31
  - Validation evidence
@@ -257,4 +257,4 @@ After editing any file:
257
257
 
258
258
  ---
259
259
 
260
- > **Note:** This agent loads relevant skills for detailed guidance. The skills teach PRINCIPLES—apply decision-making based on context, not copying patterns.
260
+ > **Note:** For database-heavy backend work, route through `database-skills` plus `Ai Agent Workflow/powers/database-skills` so indexing, pagination, query-plan evidence, and rollback stay explicit.
@@ -206,6 +206,13 @@ After database changes:
206
206
 
207
207
  ---
208
208
 
209
+ ## Database Power Routing (MANDATORY)
210
+
211
+ 1. Load `database-skills` as the core package.
212
+ 2. Load power bridge: `Ai Agent Workflow/powers/database-skills/POWER.md`.
213
+ 3. Pick engine wrapper in `Ai Agent Workflow/powers/database-skills/engines/<engine>/POWER.md`.
214
+ 4. Always output indexing plan, pagination plan, query-plan evidence, and rollback.
215
+
209
216
  ## When You Should Be Used
210
217
 
211
218
  - Designing new database schemas
@@ -220,4 +227,4 @@ After database changes:
220
227
 
221
228
  ---
222
229
 
223
- > **Note:** This agent loads the unified `database-skills` skill package for detailed guidance. Apply principles to context; do not copy patterns blindly.
230
+ > **Note:** Use `database-skills` as source of truth. Use `Ai Agent Workflow/powers/database-skills` for power-mode routing, especially engine wrappers (`postgres`, `mysql`, `vitess`, `neki`, `mongodb`, `sqlite`, `supabase`, `redis`).
@@ -182,3 +182,5 @@ What's slow?
182
182
  ---
183
183
 
184
184
  > **Remember:** Users don't care about benchmarks. They care about feeling fast.
185
+
186
+ > **Database path:** For query/storage bottlenecks, route through `database-skills` and `Ai Agent Workflow/powers/database-skills` and report index/pagination/plan evidence.
@@ -5,22 +5,27 @@ triggers: ["database", "sql", "schema", "migration", "index"]
5
5
  ---
6
6
  # Database Workflow
7
7
 
8
- Use this when data modeling, query quality, or migration safety is core to the task.
8
+ Use this when data modeling, query quality, migration safety, or database performance is core to the task.
9
9
 
10
10
  ## Routing
11
11
  - Primary specialist: `@database-architect`
12
12
  - Backend integration: `@backend-specialist`
13
13
  - Verification support: `@test-engineer`
14
14
  - Core skill package: `database-skills`
15
+ - Power bridge: `Ai Agent Workflow/powers/database-skills`
16
+ - Engine wrappers: `postgres`, `mysql`, `vitess`, `neki`, `mongodb`, `sqlite`, `supabase`, `redis`
15
17
 
16
18
  ## Steps
17
- 1. Confirm data shape and access patterns.
18
- 2. Design schema/index strategy.
19
- 3. Plan migration with rollback.
20
- 4. Validate performance and integrity impacts.
19
+ 1. Confirm data shape, access patterns, and workload size.
20
+ 2. Choose engine wrapper and define index strategy.
21
+ 3. Define pagination strategy (keyset first, offset only if justified).
22
+ 4. Plan migration and rollback.
23
+ 5. Validate with query-plan evidence and production-risk notes.
21
24
 
22
25
  ## Output Contract
23
26
  - Schema/query changes
27
+ - Indexing plan
28
+ - Pagination plan
24
29
  - Migration + rollback plan
25
- - Performance expectations
30
+ - Query-plan evidence (`EXPLAIN` or equivalent)
26
31
  - Validation evidence
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubis/foundry",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "Cubis Foundry CLI for workflow-first AI agent environments",
5
5
  "type": "module",
6
6
  "bin": {