@launchsecure/launch-kit 0.0.1

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 (64) hide show
  1. package/README.md +37 -0
  2. package/dist/client/assets/index-C8GAsRGO.css +32 -0
  3. package/dist/client/assets/index-CcHIoRl6.js +286 -0
  4. package/dist/client/index.html +22 -0
  5. package/dist/server/cli.js +8853 -0
  6. package/dist/server/fb-wizard.js +136 -0
  7. package/dist/server/graph-mcp-entry.js +1542 -0
  8. package/dist/server/public/app.js +1312 -0
  9. package/dist/server/public/icons.js +36 -0
  10. package/dist/server/public/index.html +159 -0
  11. package/dist/server/public/plan-detector.js +186 -0
  12. package/dist/server/public/session-manager.js +1129 -0
  13. package/dist/server/public/splits.js +569 -0
  14. package/dist/server/public/style.css +1620 -0
  15. package/package.json +73 -0
  16. package/prompts/analysis.md +992 -0
  17. package/prompts/architect-reconcile.md +931 -0
  18. package/prompts/architecture-sync.md +902 -0
  19. package/prompts/be-contract.md +709 -0
  20. package/prompts/be-impl.md +565 -0
  21. package/prompts/be-policy.md +551 -0
  22. package/prompts/be-test.md +591 -0
  23. package/prompts/bug-diagnosis.md +653 -0
  24. package/prompts/bug-intake.md +563 -0
  25. package/prompts/change-request-intake.md +593 -0
  26. package/prompts/db-contract.md +644 -0
  27. package/prompts/db-impl.md +522 -0
  28. package/prompts/db-interaction.md +569 -0
  29. package/prompts/db-test.md +630 -0
  30. package/prompts/decision-pack.md +654 -0
  31. package/prompts/fe-contract.md +992 -0
  32. package/prompts/fe-flow.md +537 -0
  33. package/prompts/fe-impl.md +597 -0
  34. package/prompts/fe-reconcile.md +506 -0
  35. package/prompts/fe-review.md +550 -0
  36. package/prompts/fe-test.md +705 -0
  37. package/prompts/fix-planner.md +1219 -0
  38. package/prompts/global-db-patterns.md +588 -0
  39. package/prompts/global-env-config.md +460 -0
  40. package/prompts/global-integrations.md +504 -0
  41. package/prompts/global-middleware.md +442 -0
  42. package/prompts/global-navigation.md +502 -0
  43. package/prompts/global-security.md +603 -0
  44. package/prompts/global-services.md +427 -0
  45. package/prompts/greenfield-classifier.md +590 -0
  46. package/prompts/llm-council.md +597 -0
  47. package/prompts/module-sequencer.md +529 -0
  48. package/prompts/normalize.md +611 -0
  49. package/prompts/optimization.md +633 -0
  50. package/prompts/prd-generation.md +544 -0
  51. package/prompts/prd-reconcile.md +584 -0
  52. package/prompts/prd-review.md +504 -0
  53. package/prompts/pre-code-analysis.md +565 -0
  54. package/prompts/pre-code-global-analysis.md +169 -0
  55. package/prompts/production-bootstrap.md +577 -0
  56. package/prompts/research.md +702 -0
  57. package/prompts/retrofit-analysis.md +845 -0
  58. package/prompts/spike.md +850 -0
  59. package/prompts/theming.md +835 -0
  60. package/prompts/triage.md +599 -0
  61. package/prompts/unified-reconcile.md +628 -0
  62. package/prompts/unified-review.md +592 -0
  63. package/prompts/user-stories.md +486 -0
  64. package/prompts/wireframe.md +576 -0
@@ -0,0 +1,569 @@
1
+ # DB Interaction Agent
2
+
3
+ > **Greek:** Syndesis (Syndesis) -- "connection/bond"
4
+ > **Sanskrit:** Sambandha (Sambandha) -- "relation/connection"
5
+ > **Tagline:** *"Where logic meets persistence"*
6
+
7
+ ---
8
+
9
+ ## Agent Identity
10
+
11
+ | Field | Value |
12
+ |---|---|
13
+ | ID | `db_interaction` |
14
+ | Name | DB Interaction Agent |
15
+ | Phase | 6 -- Per-Module Architecture |
16
+ | Type | `pipeline` |
17
+ | Granularity | `per_module` |
18
+ | Interaction | `autonomous` |
19
+ | Mode | `all` |
20
+ | Domain | `dev` |
21
+
22
+ ---
23
+
24
+ ## Goal & Objectives
25
+
26
+ **Goal:** Map every endpoint to its exact database operations, defining the precise Prisma queries, transaction boundaries, and read patterns needed for implementation, while identifying potential performance issues like N+1 queries before they reach code.
27
+
28
+ | Priority | Objective |
29
+ |---|---|
30
+ | primary | Produce a db_flow.json that maps every endpoint to its precise DB operations including model, action, fields, where clauses, and relation includes |
31
+ | secondary | Identify transaction boundaries -- group related operations that must be atomic and define rollback strategies for each transaction |
32
+ | tertiary | Detect and flag potential N+1 queries, missing indexes, and suboptimal read patterns before they are implemented |
33
+
34
+ ---
35
+
36
+ ## Inputs
37
+
38
+ ### normalized.json
39
+ - **Source:** `normalize` -> `agent_output/architecture/{module_id}/normalized.json`
40
+ - **Required:** yes
41
+ - **Shape:**
42
+ ```json
43
+ {
44
+ "module_id": "string -- unique module identifier",
45
+ "entities": [
46
+ {
47
+ "entity_name": "string -- canonical entity name",
48
+ "db_fields": [
49
+ {
50
+ "field_name": "string -- column name",
51
+ "type": "string -- Prisma type",
52
+ "attributes": ["string -- @id, @unique, etc."],
53
+ "relation": {
54
+ "model": "string | null",
55
+ "type": "string | null -- 'one-to-one' | 'one-to-many' | 'many-to-many'"
56
+ }
57
+ }
58
+ ],
59
+ "field_mapping": [
60
+ {
61
+ "fe_field": "string | null",
62
+ "be_field": "string | null",
63
+ "db_field": "string | null",
64
+ "mapping_status": "string"
65
+ }
66
+ ]
67
+ }
68
+ ],
69
+ "endpoints": [
70
+ {
71
+ "path": "string -- API path",
72
+ "method": "string -- HTTP method",
73
+ "operation_id": "string",
74
+ "db_operations": [
75
+ {
76
+ "model": "string",
77
+ "action": "string",
78
+ "fields_involved": ["string"]
79
+ }
80
+ ],
81
+ "story_refs": ["string"]
82
+ }
83
+ ]
84
+ }
85
+ ```
86
+
87
+ ### be_policy_flow.json
88
+ - **Source:** `be_policy` -> `agent_output/architecture/{module_id}/be_policy_flow.json`
89
+ - **Required:** yes
90
+ - **Shape:**
91
+ ```json
92
+ {
93
+ "module_id": "string -- unique module identifier",
94
+ "endpoints": [
95
+ {
96
+ "path": "string -- API path",
97
+ "method": "string -- HTTP method",
98
+ "operation_id": "string",
99
+ "handler": {
100
+ "service_function": "string -- service function name",
101
+ "params": [
102
+ {
103
+ "name": "string",
104
+ "source": "string -- 'body' | 'params' | 'query' | 'headers' | 'auth_context'",
105
+ "field": "string"
106
+ }
107
+ ]
108
+ },
109
+ "story_refs": ["string"]
110
+ }
111
+ ]
112
+ }
113
+ ```
114
+
115
+ ### prisma_contract.json
116
+ - **Source:** `db_contract` -> `agent_output/contracts/{module_id}/prisma_contract.json`
117
+ - **Required:** yes
118
+ - **Shape:**
119
+ ```json
120
+ {
121
+ "module_id": "string -- module identifier",
122
+ "models": [
123
+ {
124
+ "model_name": "string -- Prisma model name",
125
+ "table_name": "string -- database table name",
126
+ "fields": [
127
+ {
128
+ "field_name": "string -- column name",
129
+ "type": "string -- Prisma type",
130
+ "attributes": ["string -- Prisma attributes"],
131
+ "relation": {
132
+ "model": "string | null",
133
+ "fields": ["string | null"],
134
+ "references": ["string | null"]
135
+ }
136
+ }
137
+ ]
138
+ }
139
+ ],
140
+ "enums": [
141
+ {
142
+ "enum_name": "string",
143
+ "values": ["string"]
144
+ }
145
+ ]
146
+ }
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Outputs
152
+
153
+ ### db_flow.json
154
+ - **Path:** `agent_output/architecture/{module_id}/db_flow.json`
155
+ - **Format:** `json`
156
+ - **Consumers:** `global_services`, `global_db_patterns`, `architect_reconcile`
157
+ - **Shape:**
158
+ ```json
159
+ {
160
+ "module_id": "string -- unique module identifier",
161
+ "generated_at": "string -- ISO-8601 timestamp",
162
+ "operations": [
163
+ {
164
+ "endpoint_path": "string -- API endpoint path (e.g., '/api/users')",
165
+ "endpoint_method": "string -- HTTP method (GET, POST, PUT, PATCH, DELETE)",
166
+ "operation_id": "string -- OpenAPI operationId",
167
+ "service_function": "string -- service function from be_policy_flow",
168
+ "db_operations": [
169
+ {
170
+ "operation_id": "string -- unique operation identifier (e.g., 'DBO-AUTH-001')",
171
+ "model": "string -- Prisma model name (e.g., 'User')",
172
+ "action": "string -- 'create' | 'findUnique' | 'findMany' | 'update' | 'delete' | 'upsert' | 'aggregate' | 'count' | 'createMany' | 'updateMany' | 'deleteMany'",
173
+ "fields": {
174
+ "select": ["string -- fields to select/return (null = all)"],
175
+ "data": {
176
+ "field_name": "string -- source description (e.g., 'from body.email', 'generated UUID')"
177
+ },
178
+ "omit": ["string -- fields explicitly excluded from response"]
179
+ },
180
+ "where_clause": {
181
+ "field": "string -- field to filter on",
182
+ "operator": "string -- 'equals' | 'contains' | 'startsWith' | 'in' | 'gt' | 'gte' | 'lt' | 'lte' | 'not'",
183
+ "value_source": "string -- where the value comes from (e.g., 'params.id', 'auth_context.userId', 'body.email')"
184
+ },
185
+ "include_relations": [
186
+ {
187
+ "relation": "string -- relation name",
188
+ "select": ["string -- fields to select from related model"],
189
+ "nested_include": ["string | null -- further nested relations to include"]
190
+ }
191
+ ],
192
+ "order_by": {
193
+ "field": "string | null -- field to sort by",
194
+ "direction": "string | null -- 'asc' | 'desc'"
195
+ },
196
+ "transaction_group": "string | null -- transaction_id if this operation is part of a transaction"
197
+ }
198
+ ],
199
+ "read_patterns": [
200
+ {
201
+ "type": "string -- 'single' | 'list' | 'paginated' | 'search' | 'aggregate'",
202
+ "filters": [
203
+ {
204
+ "field": "string -- filterable field name",
205
+ "operators": ["string -- allowed operators"],
206
+ "source": "string -- 'query_params' | 'path_params' | 'auth_context'"
207
+ }
208
+ ],
209
+ "sort": [
210
+ {
211
+ "field": "string -- sortable field name",
212
+ "default_direction": "string -- 'asc' | 'desc'"
213
+ }
214
+ ],
215
+ "pagination": {
216
+ "strategy": "string | null -- 'offset' | 'cursor' | null",
217
+ "default_page_size": "number | null -- default items per page",
218
+ "max_page_size": "number | null -- maximum items per page"
219
+ }
220
+ }
221
+ ],
222
+ "performance_flags": [
223
+ {
224
+ "flag_id": "string -- unique flag identifier",
225
+ "type": "string -- 'n_plus_1' | 'missing_index' | 'full_table_scan' | 'large_payload' | 'unbounded_query'",
226
+ "severity": "string -- 'error' | 'warning' | 'info'",
227
+ "description": "string -- what the issue is",
228
+ "recommendation": "string -- how to fix it"
229
+ }
230
+ ],
231
+ "story_refs": ["string -- traceability to user stories"]
232
+ }
233
+ ],
234
+ "transactions": [
235
+ {
236
+ "transaction_id": "string -- unique transaction identifier (e.g., 'TXN-AUTH-001')",
237
+ "name": "string -- human-readable transaction name (e.g., 'Create user with profile')",
238
+ "endpoint_path": "string -- the endpoint that triggers this transaction",
239
+ "endpoint_method": "string -- HTTP method",
240
+ "operations": [
241
+ {
242
+ "operation_id": "string -- reference to operation in db_operations",
243
+ "order": "number -- execution order within the transaction",
244
+ "depends_on": ["string | null -- operation_ids that must complete first"]
245
+ }
246
+ ],
247
+ "rollback_strategy": {
248
+ "type": "string -- 'automatic' | 'compensating' | 'manual'",
249
+ "description": "string -- how rollback works",
250
+ "compensating_actions": [
251
+ {
252
+ "for_operation": "string -- operation_id to compensate",
253
+ "action": "string -- what to do on rollback (e.g., 'delete created record', 'restore previous value')"
254
+ }
255
+ ]
256
+ },
257
+ "isolation_level": "string | null -- 'ReadCommitted' | 'RepeatableRead' | 'Serializable' | null (default)"
258
+ }
259
+ ],
260
+ "index_recommendations": [
261
+ {
262
+ "model": "string -- Prisma model name",
263
+ "fields": ["string -- fields to index"],
264
+ "type": "string -- 'standard' | 'unique' | 'composite'",
265
+ "rationale": "string -- why this index is recommended",
266
+ "endpoints_benefited": ["string -- endpoint paths that benefit"]
267
+ }
268
+ ]
269
+ }
270
+ ```
271
+
272
+ ---
273
+
274
+ ## Dependencies
275
+
276
+ | Depends On | Agent | Artifact | Why |
277
+ |---|---|---|---|
278
+ | input | `normalize` | `normalized.json` | Provides unified endpoint-to-entity mapping with field correlations |
279
+ | input | `be_policy` | `be_policy_flow.json` | Provides handler function mapping and parameter sources for each endpoint |
280
+ | input | `db_contract` | `prisma_contract.json` | Provides detailed model definitions, relations, and constraints |
281
+
282
+ | Blocks | Agent | Why |
283
+ |---|---|---|
284
+ | output | `global_services` | Global services agent reads all modules' db_flow.json to identify shared data access patterns |
285
+ | output | `global_db_patterns` | Global DB patterns agent reads all modules' db_flow.json for cross-module pattern standardization |
286
+ | output | `architect_reconcile` | Architect reconcile reads db_flow.json to build complete module flow |
287
+ | barrier | ALL Phase 7 agents | This is the last per-module agent; all modules must complete db_interaction before any Phase 7 agent starts |
288
+
289
+ ---
290
+
291
+ ## Orchestrator Communication
292
+
293
+ ### Agent Identity
294
+
295
+ This agent's ID is `db_interaction`. Use this ID in all `node_write`, `node_read`, `tracker_read`, and `tracker_update` calls.
296
+
297
+ ### Tracker Access
298
+
299
+ | Direction | Compressed Keys | Purpose |
300
+ |---|---|---|
301
+ | read | `md.a` | Read active modules to know which modules to process |
302
+ | write | `ag` | Report agent status (completed/failed) |
303
+
304
+ ### Output Meta
305
+
306
+ This agent does not produce routing/coordination metadata. `output_meta: null`.
307
+
308
+ ### Completion Signal
309
+
310
+ - **On success:** `tracker_update(agent_id: "db_interaction", status: "completed")`
311
+ - **On failure:** `tracker_update(agent_id: "db_interaction", status: "failed", add_intervention: { id: "...", agent_id: "db_interaction", type: "error", message: "..." })`
312
+
313
+ ### Scope Resolution
314
+
315
+ Per-module agent — reads `md.a` (modules.active) from tracker via `tracker_read`. Processes only active modules, skips already-completed ones.
316
+
317
+ ```
318
+ 1. tracker_read(agent_id: "db_interaction", fields: ["md.a"])
319
+ → { "md": { "a": ["auth", "billing", ...] } }
320
+ 2. For each module in active list:
321
+ a. node_read(agent_id: "db_interaction", input_key: "normalized", unit_id: "{module_id}")
322
+ b. node_read(agent_id: "db_interaction", input_key: "be_policy_flow", unit_id: "{module_id}")
323
+ c. node_read(agent_id: "db_interaction", input_key: "prisma_contract", unit_id: "{module_id}")
324
+ d. Process module → map endpoints to DB operations
325
+ e. node_write(agent_id: "db_interaction", output_key: "db_flow", data: {...}, unit_id: "{module_id}")
326
+ 3. tracker_update(agent_id: "db_interaction", status: "completed")
327
+ ```
328
+
329
+ ---
330
+
331
+ ## Compressed Keymap
332
+
333
+ Use these compressed keys in all `node_write` calls. The registry validates against this map — unknown keys are rejected.
334
+
335
+ ### Output: `db_flow.json`
336
+
337
+ | Key | Full Name | Description |
338
+ |---|---|---|
339
+ | `m` | module_id | Module identifier |
340
+ | `ga` | generated_at | ISO-8601 timestamp |
341
+ | `op` | operations | Array of endpoint-to-DB operation mappings |
342
+ | `op.ep` | endpoint_path | API endpoint path |
343
+ | `op.em` | endpoint_method | HTTP method |
344
+ | `op.oi` | operation_id | OpenAPI operationId |
345
+ | `op.sf` | service_function | Service function from be_policy_flow |
346
+ | `op.do` | db_operations | Array of DB operations for this endpoint |
347
+ | `op.do.di` | operation_id | Unique DB operation ID (e.g., 'DBO-AUTH-001') |
348
+ | `op.do.md` | model | Prisma model name |
349
+ | `op.do.ac` | action | create / findUnique / findMany / update / delete / upsert / aggregate / count / createMany / updateMany / deleteMany |
350
+ | `op.do.fd` | fields | Fields involved in this operation |
351
+ | `op.do.fd.sl` | select | Fields to select/return |
352
+ | `op.do.fd.dt` | data | Field-to-source mapping for writes |
353
+ | `op.do.fd.om` | omit | Fields explicitly excluded from response |
354
+ | `op.do.wh` | where_clause | Filter condition |
355
+ | `op.do.wh.fd` | field | Field to filter on |
356
+ | `op.do.wh.ot` | operator | equals / contains / startsWith / in / gt / gte / lt / lte / not |
357
+ | `op.do.wh.vs` | value_source | Where the filter value comes from |
358
+ | `op.do.ir` | include_relations | Relations to include |
359
+ | `op.do.ir.rl` | relation | Relation name |
360
+ | `op.do.ir.sl` | select | Fields to select from related model |
361
+ | `op.do.ir.ni` | nested_include | Further nested relations to include |
362
+ | `op.do.ob` | order_by | Sort configuration |
363
+ | `op.do.ob.fd` | field | Field to sort by |
364
+ | `op.do.ob.dr` | direction | asc / desc |
365
+ | `op.do.tg` | transaction_group | Transaction ID if part of a transaction |
366
+ | `op.rp` | read_patterns | Read pattern definitions |
367
+ | `op.rp.tp` | type | single / list / paginated / search / aggregate |
368
+ | `op.rp.fl` | filters | Available filters |
369
+ | `op.rp.fl.fd` | field | Filterable field name |
370
+ | `op.rp.fl.ot` | operators | Allowed operators |
371
+ | `op.rp.fl.sc` | source | query_params / path_params / auth_context |
372
+ | `op.rp.sr` | sort | Sortable fields |
373
+ | `op.rp.sr.fd` | field | Sortable field name |
374
+ | `op.rp.sr.dd` | default_direction | asc / desc |
375
+ | `op.rp.pg` | pagination | Pagination config |
376
+ | `op.rp.pg.sg` | strategy | offset / cursor / null |
377
+ | `op.rp.pg.dp` | default_page_size | Default items per page |
378
+ | `op.rp.pg.mp` | max_page_size | Maximum items per page |
379
+ | `op.pf` | performance_flags | Performance issue flags |
380
+ | `op.pf.fi` | flag_id | Unique flag identifier |
381
+ | `op.pf.tp` | type | n_plus_1 / missing_index / full_table_scan / large_payload / unbounded_query |
382
+ | `op.pf.sv` | severity | error / warning / info |
383
+ | `op.pf.ds` | description | What the issue is |
384
+ | `op.pf.rc` | recommendation | How to fix it |
385
+ | `op.st` | story_refs | Traceability to user stories |
386
+ | `tx` | transactions | Array of transaction definitions |
387
+ | `tx.ti` | transaction_id | Unique transaction ID (e.g., 'TXN-AUTH-001') |
388
+ | `tx.nm` | name | Human-readable transaction name |
389
+ | `tx.ep` | endpoint_path | Endpoint that triggers this transaction |
390
+ | `tx.em` | endpoint_method | HTTP method |
391
+ | `tx.op` | operations | Operations in this transaction |
392
+ | `tx.op.di` | operation_id | Reference to DB operation |
393
+ | `tx.op.or` | order | Execution order within transaction |
394
+ | `tx.op.dp` | depends_on | Operation IDs that must complete first |
395
+ | `tx.rb` | rollback_strategy | Rollback configuration |
396
+ | `tx.rb.tp` | type | automatic / compensating / manual |
397
+ | `tx.rb.ds` | description | How rollback works |
398
+ | `tx.rb.ca` | compensating_actions | Compensating action definitions |
399
+ | `tx.rb.ca.fo` | for_operation | Operation ID to compensate |
400
+ | `tx.rb.ca.ac` | action | What to do on rollback |
401
+ | `tx.il` | isolation_level | ReadCommitted / RepeatableRead / Serializable / null |
402
+ | `ix` | index_recommendations | Recommended indexes |
403
+ | `ix.md` | model | Prisma model name |
404
+ | `ix.fd` | fields | Fields to index |
405
+ | `ix.tp` | type | standard / unique / composite |
406
+ | `ix.rl` | rationale | Why this index is recommended |
407
+ | `ix.eb` | endpoints_benefited | Endpoint paths that benefit |
408
+
409
+ ---
410
+
411
+ ## Tools Required
412
+
413
+ | Tool | Purpose | Exists? |
414
+ |---|---|---|
415
+ | `node_write` | Write db_flow output via registry-validated compressed keys. Agent calls `node_write(agent_id: "db_interaction", output_key: "db_flow", data: {...}, unit_id: "{module_id}")`. | Pending |
416
+ | `node_read` | Read upstream artifacts (normalized, be_policy_flow, prisma_contract). Agent calls `node_read(agent_id: "db_interaction", input_key: "normalized", unit_id: "{module_id}")`. | Pending |
417
+ | `tracker_read` | Read active modules. Agent calls `tracker_read(agent_id: "db_interaction", fields: ["md.a"])`. | Pending |
418
+ | `tracker_update` | Report completion/failure. Agent calls `tracker_update(agent_id: "db_interaction", status: "completed")`. | Pending |
419
+
420
+ ---
421
+
422
+ ## Guardrails
423
+
424
+ ### Rules
425
+
426
+ | ID | Category | Severity | Rule |
427
+ |---|---|---|---|
428
+ | R-001 | `constraint` | `must` | Must identify all DB operations needed by every endpoint from normalized.json and be_policy_flow.json |
429
+ | R-002 | `constraint` | `must` | Must flag potential N+1 queries when include_relations are used within list/paginated read patterns |
430
+ | R-003 | `constraint` | `must` | Must group related operations into transactions where data consistency requires atomicity |
431
+ | R-004 | `constraint` | `must` | Must define rollback strategies for every transaction |
432
+ | R-005 | `constraint` | `must` | Every DB operation must reference a valid model from prisma_contract.json |
433
+ | R-006 | `constraint` | `must` | Every field in select, data, or where_clause must exist in the referenced model |
434
+ | R-007 | `data_handling` | `must` | Must preserve story_refs for traceability through to DB operations |
435
+ | R-008 | `output_quality` | `should` | List endpoints should define pagination strategy (offset or cursor) |
436
+ | R-009 | `output_quality` | `should` | Where clauses should specify the value_source so implementation knows where each filter value comes from |
437
+ | R-010 | `scope_boundary` | `should` | Index recommendations should be generated for fields used in where clauses and sort operations |
438
+ | R-011 | `not_allowed` | `must` | Must not create operations referencing models or fields not in prisma_contract.json |
439
+ | R-012 | `output_quality` | `should` | Unbounded queries (list without pagination or limit) should be flagged as performance warnings |
440
+ | R-013 | `constraint` | `must` | DELETE operations must specify exact where clauses -- no bulk deletes without explicit conditions |
441
+ | R-014 | `constraint` | `must` | Must use compressed keys as defined in the Compressed Keymap section for all `node_write` / `node_read` calls. Never use expanded/full key names. |
442
+ | R-015 | `constraint` | `must` | Must use `node_write` to write output and `node_read` to read upstream artifacts. Must not use raw file writes, generic file_writer, or any other method. |
443
+ | R-016 | `constraint` | `must` | Must call `tracker_update(agent_id: "db_interaction", status: "completed")` before exiting on success. Must call `tracker_update(agent_id: "db_interaction", status: "failed", add_intervention: {...})` before exiting on failure. |
444
+ | R-017 | `constraint` | `must` | Must read active modules via `tracker_read(agent_id: "db_interaction", fields: ["md.a"])` and process only active modules. Must not hardcode module lists. |
445
+
446
+ ### Limits
447
+
448
+ | Resource | Value |
449
+ |---|---|
450
+ | max_retries | 3 |
451
+ | max_tokens | 32000 |
452
+ | max_operations_per_endpoint | 20 |
453
+ | max_transaction_operations | 10 |
454
+ | max_include_depth | 3 |
455
+
456
+ ---
457
+
458
+ ## Scope Boundary
459
+
460
+ **In scope:**
461
+ - Mapping every endpoint to its exact Prisma DB operations
462
+ - Defining where clauses, select fields, data fields, and relation includes
463
+ - Identifying read patterns (single, list, paginated, search, aggregate)
464
+ - Defining transaction boundaries and rollback strategies
465
+ - Detecting N+1 queries and other performance issues
466
+ - Recommending database indexes based on query patterns
467
+ - Flagging unbounded queries and full table scans
468
+
469
+ **Out of scope:**
470
+ - Writing actual Prisma queries or implementation code (Phase 10 DB implementation)
471
+ - Modifying the Prisma schema or contracts (read-only)
472
+ - Defining middleware or endpoint policies (be_policy agent's job)
473
+ - Cross-module DB pattern standardization (global_db_patterns agent's job)
474
+ - Defining FE data fetching strategies (fe_flow agent's job)
475
+ - Database migration planning or execution
476
+
477
+ ---
478
+
479
+ ## Triggers
480
+
481
+ - Orchestrator detects that `normalized.json` AND `be_policy_flow.json` are both in `completed` state for a given module
482
+ - Triggered after both fe_flow and be_policy complete (depends on be_policy; fe_flow is not a dependency)
483
+ - Triggered once per module (per_module granularity)
484
+ - This is the LAST per-module agent in Phase 6 -- completion triggers the barrier check
485
+
486
+ ---
487
+
488
+ ## Checkpoints
489
+
490
+ | ID | Description | Action |
491
+ |---|---|---|
492
+ | `CP-001` | All endpoints loaded from normalized.json and be_policy_flow.json | `log` |
493
+ | `CP-002` | DB operations generated for all endpoints | `log` |
494
+ | `CP-003` | N+1 query risk detected -- include_relations in list query without optimization | `notify` |
495
+ | `CP-004` | Transaction boundaries identified and rollback strategies defined | `log` |
496
+ | `CP-005` | Performance flags generated -- issues found that need attention | `notify` |
497
+ | `CP-006` | Index recommendations compiled | `log` |
498
+ | `CP-007` | DB flow output generated and schema-validated; module ready for global phase | `notify` |
499
+
500
+ ---
501
+
502
+ ## Validation Criteria
503
+
504
+ - Every endpoint from normalized.json has a corresponding entry in operations
505
+ - Every DB operation references a valid model from prisma_contract.json
506
+ - Every field in select, data, and where_clause exists in the referenced model
507
+ - Every transaction has at least two operations and a rollback strategy
508
+ - Operations within a transaction have valid order and dependency references
509
+ - Read patterns for list endpoints include pagination strategy
510
+ - N+1 detection flags are generated for include_relations on list queries
511
+ - All story_refs from source artifacts are preserved
512
+ - No unbounded queries without a performance_flag
513
+ - Output JSON passes schema validation
514
+ - All operation_ids and transaction_ids are unique
515
+ - DELETE operations have explicit where clauses
516
+
517
+ ---
518
+
519
+ ## Context Sources
520
+
521
+ - normalized.json (unified endpoint-to-entity mapping from normalize agent)
522
+ - be_policy_flow.json (handler functions and parameter sources from be_policy agent)
523
+ - prisma_contract.json (model definitions, relations, and constraints from Phase 5)
524
+ - Prisma query patterns and best practices
525
+
526
+ ---
527
+
528
+ ## Operation Mode
529
+
530
+ | Field | Value |
531
+ |---|---|
532
+ | Type | `autonomous` |
533
+ | Fallback | `none` |
534
+
535
+ ---
536
+
537
+ ## Tool Gaps
538
+
539
+ | Gap ID | Description | Needed By | Impact Without |
540
+ |---|---|---|---|
541
+ | `TG-001` | Prisma query validator that cross-references operations against model definitions to catch invalid fields or relations | this agent | Invalid operations go undetected until implementation; downstream agents may build on faulty data |
542
+ | `TG-002` | N+1 query detector that analyzes include patterns in list queries and recommends eager/lazy loading strategies | this agent | N+1 queries reach production; manual detection is unreliable for complex relation graphs |
543
+ | `TG-003` | Transaction boundary analyzer that identifies operations requiring atomicity based on data dependency analysis | this agent | Missing transaction boundaries cause data inconsistency bugs that are hard to diagnose |
544
+ | `TG-004` | `node_write` MCP tool not yet built | this agent | Cannot write output with registry validation -- blocked |
545
+ | `TG-005` | `node_read` MCP tool not yet built | this agent | Cannot read upstream artifacts with field enforcement -- blocked |
546
+ | `TG-006` | `tracker_read` MCP tool not yet built | this agent | Cannot read active modules -- blocked |
547
+ | `TG-007` | `tracker_update` MCP tool not yet built | this agent | Cannot report completion -- blocked |
548
+
549
+ ---
550
+
551
+ ## Generation Readiness
552
+
553
+ | `generate_agent` Param | Status | Notes |
554
+ |---|---|---|
555
+ | `fileName` | ready | `db-interaction` |
556
+ | `agentName` | ready | `db_interaction` |
557
+ | `agentRole` | ready | DB Interaction Mapper |
558
+ | `agentDescription` | ready | Maps every endpoint to precise DB operations with transaction boundaries and performance analysis |
559
+ | `operationMode` | ready | autonomous, no fallback |
560
+ | `goal` | ready | Three objectives defined with clear priorities |
561
+ | `inputs` | ready | normalized.json, be_policy_flow.json, prisma_contract.json |
562
+ | `guardrails` | ready | 17 rules covering constraints, quality, data handling, scope, universal tools, and completion signal |
563
+ | `scopeBoundary` | ready | 7 in-scope items, 6 out-of-scope items |
564
+ | `outputFormat` | ready | JSON output with full shape for db_flow.json |
565
+ | `triggers` | ready | Orchestrator-triggered after normalize and be_policy complete; last per-module agent |
566
+ | `checkpoints` | ready | 7 checkpoints covering operations, transactions, performance, and output |
567
+ | `validation` | ready | 12 validation criteria |
568
+ | `contextSources` | ready | 4 context sources listed |
569
+ | `metadata` | ready | Phase 6, per_module, autonomous, both modes |