qualia-framework 2.6.0 → 3.2.0

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 (321) hide show
  1. package/CLAUDE.md +64 -0
  2. package/README.md +103 -30
  3. package/agents/builder.md +110 -0
  4. package/agents/planner.md +134 -0
  5. package/agents/qa-browser.md +186 -0
  6. package/agents/verifier.md +221 -0
  7. package/bin/cli.js +336 -531
  8. package/bin/install.js +570 -0
  9. package/bin/qualia-ui.js +299 -0
  10. package/bin/state.js +630 -0
  11. package/bin/statusline.js +252 -0
  12. package/guide.md +63 -0
  13. package/hooks/auto-update.js +139 -0
  14. package/hooks/branch-guard.js +47 -0
  15. package/hooks/migration-guard.js +60 -0
  16. package/hooks/pre-compact.js +32 -0
  17. package/hooks/pre-deploy-gate.js +110 -0
  18. package/hooks/pre-push.js +33 -0
  19. package/hooks/session-start.js +170 -0
  20. package/package.json +29 -20
  21. package/rules/design-reference.md +179 -0
  22. package/rules/frontend.md +126 -0
  23. package/skills/qualia/SKILL.md +87 -0
  24. package/skills/qualia-build/SKILL.md +97 -0
  25. package/skills/qualia-debug/SKILL.md +87 -0
  26. package/skills/qualia-design/SKILL.md +93 -0
  27. package/skills/qualia-handoff/SKILL.md +66 -0
  28. package/skills/qualia-idk/SKILL.md +8 -0
  29. package/skills/qualia-learn/SKILL.md +88 -0
  30. package/skills/qualia-new/SKILL.md +323 -0
  31. package/{framework/skills → skills}/qualia-optimize/SKILL.md +1 -1
  32. package/skills/qualia-pause/SKILL.md +63 -0
  33. package/skills/qualia-plan/SKILL.md +101 -0
  34. package/skills/qualia-polish/SKILL.md +157 -0
  35. package/skills/qualia-quick/SKILL.md +37 -0
  36. package/skills/qualia-report/SKILL.md +105 -0
  37. package/skills/qualia-resume/SKILL.md +49 -0
  38. package/skills/qualia-review/SKILL.md +76 -0
  39. package/skills/qualia-ship/SKILL.md +90 -0
  40. package/skills/qualia-skill-new/SKILL.md +167 -0
  41. package/skills/qualia-task/SKILL.md +91 -0
  42. package/skills/qualia-verify/SKILL.md +113 -0
  43. package/templates/DESIGN.md +137 -0
  44. package/templates/plan.md +28 -0
  45. package/templates/project.md +22 -0
  46. package/templates/state.md +27 -0
  47. package/templates/tracking.json +20 -0
  48. package/tests/bin.test.sh +673 -0
  49. package/tests/hooks.test.sh +315 -0
  50. package/tests/state.test.sh +535 -0
  51. package/tests/statusline.test.sh +243 -0
  52. package/bin/collect-metrics.sh +0 -62
  53. package/framework/.claudeignore +0 -51
  54. package/framework/CLAUDE.md +0 -51
  55. package/framework/MCP_SETUP.md +0 -229
  56. package/framework/agents/architecture-strategist.md +0 -53
  57. package/framework/agents/backend-agent.md +0 -150
  58. package/framework/agents/code-simplicity-reviewer.md +0 -86
  59. package/framework/agents/frontend-agent.md +0 -111
  60. package/framework/agents/kieran-typescript-reviewer.md +0 -96
  61. package/framework/agents/performance-oracle.md +0 -111
  62. package/framework/agents/qualia-codebase-mapper.md +0 -761
  63. package/framework/agents/qualia-debugger.md +0 -1204
  64. package/framework/agents/qualia-executor.md +0 -882
  65. package/framework/agents/qualia-integration-checker.md +0 -424
  66. package/framework/agents/qualia-phase-researcher.md +0 -457
  67. package/framework/agents/qualia-plan-checker.md +0 -700
  68. package/framework/agents/qualia-planner.md +0 -1245
  69. package/framework/agents/qualia-project-researcher.md +0 -603
  70. package/framework/agents/qualia-research-synthesizer.md +0 -200
  71. package/framework/agents/qualia-roadmapper.md +0 -606
  72. package/framework/agents/qualia-verifier.md +0 -686
  73. package/framework/agents/red-team-qa.md +0 -130
  74. package/framework/agents/security-auditor.md +0 -72
  75. package/framework/agents/team-orchestrator.md +0 -229
  76. package/framework/agents/teams/framework-audit-team.md +0 -66
  77. package/framework/agents/teams/full-stack-team.md +0 -48
  78. package/framework/agents/teams/optimize-team.md +0 -53
  79. package/framework/agents/teams/review-team.md +0 -70
  80. package/framework/agents/teams/ship-team.md +0 -86
  81. package/framework/agents/test-agent.md +0 -182
  82. package/framework/hooks/auto-format.sh +0 -54
  83. package/framework/hooks/block-env-edit.sh +0 -42
  84. package/framework/hooks/branch-guard.sh +0 -43
  85. package/framework/hooks/confirm-delete.sh +0 -59
  86. package/framework/hooks/migration-validate.sh +0 -77
  87. package/framework/hooks/notification-speak.sh +0 -16
  88. package/framework/hooks/pre-commit.sh +0 -100
  89. package/framework/hooks/pre-compact.sh +0 -56
  90. package/framework/hooks/pre-deploy-gate.sh +0 -160
  91. package/framework/hooks/qualia-colors.sh +0 -32
  92. package/framework/hooks/retention-cleanup.sh +0 -62
  93. package/framework/hooks/save-session-state.sh +0 -185
  94. package/framework/hooks/session-context-loader.sh +0 -96
  95. package/framework/hooks/session-learn.sh +0 -32
  96. package/framework/hooks/skill-announce.sh +0 -123
  97. package/framework/hooks/tool-error-announce.sh +0 -27
  98. package/framework/install.ps1 +0 -323
  99. package/framework/install.sh +0 -313
  100. package/framework/qualia-framework/VERSION +0 -1
  101. package/framework/qualia-framework/assets/qualia-logo.png +0 -0
  102. package/framework/qualia-framework/bin/collect-metrics.sh +0 -67
  103. package/framework/qualia-framework/bin/generate-report-docx.py +0 -429
  104. package/framework/qualia-framework/bin/qualia-tools.js +0 -2201
  105. package/framework/qualia-framework/bin/qualia-tools.test.js +0 -1054
  106. package/framework/qualia-framework/references/checkpoints.md +0 -775
  107. package/framework/qualia-framework/references/completion-checklists.md +0 -359
  108. package/framework/qualia-framework/references/continuation-format.md +0 -249
  109. package/framework/qualia-framework/references/continuation-prompt.md +0 -97
  110. package/framework/qualia-framework/references/decimal-phase-calculation.md +0 -65
  111. package/framework/qualia-framework/references/design-quality.md +0 -56
  112. package/framework/qualia-framework/references/employee-guide.md +0 -167
  113. package/framework/qualia-framework/references/git-integration.md +0 -254
  114. package/framework/qualia-framework/references/git-planning-commit.md +0 -50
  115. package/framework/qualia-framework/references/model-profile-resolution.md +0 -32
  116. package/framework/qualia-framework/references/model-profiles.md +0 -73
  117. package/framework/qualia-framework/references/phase-argument-parsing.md +0 -61
  118. package/framework/qualia-framework/references/planning-config.md +0 -195
  119. package/framework/qualia-framework/references/questioning.md +0 -141
  120. package/framework/qualia-framework/references/tdd.md +0 -263
  121. package/framework/qualia-framework/references/ui-brand.md +0 -160
  122. package/framework/qualia-framework/references/verification-patterns.md +0 -612
  123. package/framework/qualia-framework/templates/DEBUG.md +0 -159
  124. package/framework/qualia-framework/templates/DESIGN.md +0 -81
  125. package/framework/qualia-framework/templates/UAT.md +0 -247
  126. package/framework/qualia-framework/templates/codebase/architecture.md +0 -255
  127. package/framework/qualia-framework/templates/codebase/concerns.md +0 -310
  128. package/framework/qualia-framework/templates/codebase/conventions.md +0 -307
  129. package/framework/qualia-framework/templates/codebase/integrations.md +0 -280
  130. package/framework/qualia-framework/templates/codebase/stack.md +0 -186
  131. package/framework/qualia-framework/templates/codebase/structure.md +0 -285
  132. package/framework/qualia-framework/templates/codebase/testing.md +0 -480
  133. package/framework/qualia-framework/templates/config.json +0 -35
  134. package/framework/qualia-framework/templates/context.md +0 -283
  135. package/framework/qualia-framework/templates/continue-here.md +0 -78
  136. package/framework/qualia-framework/templates/debug-subagent-prompt.md +0 -91
  137. package/framework/qualia-framework/templates/discovery.md +0 -146
  138. package/framework/qualia-framework/templates/lab-notes.md +0 -16
  139. package/framework/qualia-framework/templates/milestone-archive.md +0 -123
  140. package/framework/qualia-framework/templates/milestone.md +0 -115
  141. package/framework/qualia-framework/templates/phase-prompt.md +0 -567
  142. package/framework/qualia-framework/templates/planner-subagent-prompt.md +0 -117
  143. package/framework/qualia-framework/templates/project.md +0 -184
  144. package/framework/qualia-framework/templates/projects/ai-agent.md +0 -156
  145. package/framework/qualia-framework/templates/projects/mobile-app.md +0 -181
  146. package/framework/qualia-framework/templates/projects/voice-agent.md +0 -134
  147. package/framework/qualia-framework/templates/projects/website.md +0 -137
  148. package/framework/qualia-framework/templates/requirements.md +0 -231
  149. package/framework/qualia-framework/templates/research-project/ARCHITECTURE.md +0 -204
  150. package/framework/qualia-framework/templates/research-project/FEATURES.md +0 -147
  151. package/framework/qualia-framework/templates/research-project/PITFALLS.md +0 -200
  152. package/framework/qualia-framework/templates/research-project/STACK.md +0 -120
  153. package/framework/qualia-framework/templates/research-project/SUMMARY.md +0 -170
  154. package/framework/qualia-framework/templates/research.md +0 -552
  155. package/framework/qualia-framework/templates/roadmap.md +0 -206
  156. package/framework/qualia-framework/templates/state.md +0 -179
  157. package/framework/qualia-framework/templates/summary-complex.md +0 -59
  158. package/framework/qualia-framework/templates/summary-minimal.md +0 -41
  159. package/framework/qualia-framework/templates/summary-standard.md +0 -48
  160. package/framework/qualia-framework/templates/summary.md +0 -246
  161. package/framework/qualia-framework/templates/user-setup.md +0 -311
  162. package/framework/qualia-framework/templates/verification-report.md +0 -322
  163. package/framework/qualia-framework/workflows/add-phase.md +0 -179
  164. package/framework/qualia-framework/workflows/add-todo.md +0 -157
  165. package/framework/qualia-framework/workflows/audit-milestone.md +0 -241
  166. package/framework/qualia-framework/workflows/check-todos.md +0 -176
  167. package/framework/qualia-framework/workflows/complete-milestone.md +0 -858
  168. package/framework/qualia-framework/workflows/diagnose-issues.md +0 -219
  169. package/framework/qualia-framework/workflows/discovery-phase.md +0 -289
  170. package/framework/qualia-framework/workflows/discuss-phase.md +0 -534
  171. package/framework/qualia-framework/workflows/execute-phase.md +0 -559
  172. package/framework/qualia-framework/workflows/execute-plan.md +0 -438
  173. package/framework/qualia-framework/workflows/help.md +0 -470
  174. package/framework/qualia-framework/workflows/insert-phase.md +0 -220
  175. package/framework/qualia-framework/workflows/list-phase-assumptions.md +0 -178
  176. package/framework/qualia-framework/workflows/map-codebase.md +0 -327
  177. package/framework/qualia-framework/workflows/new-milestone.md +0 -363
  178. package/framework/qualia-framework/workflows/new-project.md +0 -982
  179. package/framework/qualia-framework/workflows/pause-work.md +0 -122
  180. package/framework/qualia-framework/workflows/plan-milestone-gaps.md +0 -256
  181. package/framework/qualia-framework/workflows/plan-phase.md +0 -422
  182. package/framework/qualia-framework/workflows/progress.md +0 -389
  183. package/framework/qualia-framework/workflows/quick.md +0 -252
  184. package/framework/qualia-framework/workflows/remove-phase.md +0 -326
  185. package/framework/qualia-framework/workflows/research-phase.md +0 -74
  186. package/framework/qualia-framework/workflows/resume-project.md +0 -306
  187. package/framework/qualia-framework/workflows/set-profile.md +0 -80
  188. package/framework/qualia-framework/workflows/settings.md +0 -145
  189. package/framework/qualia-framework/workflows/transition.md +0 -556
  190. package/framework/qualia-framework/workflows/update.md +0 -197
  191. package/framework/qualia-framework/workflows/verify-phase.md +0 -195
  192. package/framework/qualia-framework/workflows/verify-work.md +0 -625
  193. package/framework/rules/context7.md +0 -14
  194. package/framework/rules/frontend.md +0 -33
  195. package/framework/rules/speed.md +0 -23
  196. package/framework/scripts/__pycache__/say.cpython-314.pyc +0 -0
  197. package/framework/scripts/apply-retention.sh +0 -120
  198. package/framework/scripts/bootstrap-pop-os.sh +0 -354
  199. package/framework/scripts/claude-voice +0 -13
  200. package/framework/scripts/cleanup.sh +0 -131
  201. package/framework/scripts/cowork-mode.sh +0 -141
  202. package/framework/scripts/generate-project-claude-md.sh +0 -153
  203. package/framework/scripts/load-test-webhook.js +0 -172
  204. package/framework/scripts/say.py +0 -236
  205. package/framework/scripts/showcase-video-recorder/ffmpeg-builder.js +0 -167
  206. package/framework/scripts/showcase-video-recorder/playwright-helpers.js +0 -216
  207. package/framework/scripts/speak.py +0 -55
  208. package/framework/scripts/speak.sh +0 -18
  209. package/framework/scripts/status.sh +0 -138
  210. package/framework/scripts/sync-to-framework.sh +0 -65
  211. package/framework/scripts/voice-hotkey.py +0 -227
  212. package/framework/scripts/voice-input.sh +0 -51
  213. package/framework/skills/animate/SKILL.md +0 -202
  214. package/framework/skills/bolder/SKILL.md +0 -144
  215. package/framework/skills/browser-qa/SKILL.md +0 -536
  216. package/framework/skills/clarify/SKILL.md +0 -179
  217. package/framework/skills/client-handoff/SKILL.md +0 -135
  218. package/framework/skills/collab-onboard/SKILL.md +0 -111
  219. package/framework/skills/colorize/SKILL.md +0 -170
  220. package/framework/skills/critique/SKILL.md +0 -126
  221. package/framework/skills/deep-research/SKILL.md +0 -240
  222. package/framework/skills/delight/SKILL.md +0 -329
  223. package/framework/skills/deploy/SKILL.md +0 -261
  224. package/framework/skills/deploy-verify/SKILL.md +0 -377
  225. package/framework/skills/deploy-verify/scripts/canary-check.sh +0 -206
  226. package/framework/skills/deploy-verify/scripts/check-console-errors.js +0 -147
  227. package/framework/skills/deploy-verify/scripts/check-cwv.js +0 -139
  228. package/framework/skills/deploy-verify/scripts/project-detect.sh +0 -84
  229. package/framework/skills/deploy-verify/scripts/verify.sh +0 -548
  230. package/framework/skills/design-quieter/SKILL.md +0 -130
  231. package/framework/skills/distill/SKILL.md +0 -149
  232. package/framework/skills/docs-lookup/SKILL.md +0 -79
  233. package/framework/skills/fcm-notifications/SKILL.md +0 -125
  234. package/framework/skills/financial-ledger/SKILL.md +0 -1039
  235. package/framework/skills/frontend-master/NOTICE.md +0 -4
  236. package/framework/skills/frontend-master/SKILL.md +0 -127
  237. package/framework/skills/frontend-master/reference/color-and-contrast.md +0 -132
  238. package/framework/skills/frontend-master/reference/interaction-design.md +0 -123
  239. package/framework/skills/frontend-master/reference/motion-design.md +0 -99
  240. package/framework/skills/frontend-master/reference/responsive-design.md +0 -114
  241. package/framework/skills/frontend-master/reference/spatial-design.md +0 -100
  242. package/framework/skills/frontend-master/reference/typography.md +0 -131
  243. package/framework/skills/frontend-master/reference/ux-writing.md +0 -107
  244. package/framework/skills/harden/SKILL.md +0 -357
  245. package/framework/skills/i18n-rtl/SKILL.md +0 -752
  246. package/framework/skills/learn/SKILL.md +0 -95
  247. package/framework/skills/memory/SKILL.md +0 -50
  248. package/framework/skills/mobile-expo/SKILL.md +0 -977
  249. package/framework/skills/mobile-expo/references/store-checklist.md +0 -550
  250. package/framework/skills/nestjs-backend/README.md +0 -73
  251. package/framework/skills/nestjs-backend/SKILL.md +0 -446
  252. package/framework/skills/nestjs-backend/references/templates.md +0 -1173
  253. package/framework/skills/normalize/SKILL.md +0 -79
  254. package/framework/skills/onboard/SKILL.md +0 -242
  255. package/framework/skills/openrouter-agent/SKILL.md +0 -922
  256. package/framework/skills/polish/SKILL.md +0 -209
  257. package/framework/skills/pr/SKILL.md +0 -66
  258. package/framework/skills/qualia/SKILL.md +0 -199
  259. package/framework/skills/qualia-add-todo/SKILL.md +0 -68
  260. package/framework/skills/qualia-audit-milestone/SKILL.md +0 -95
  261. package/framework/skills/qualia-check-todos/SKILL.md +0 -55
  262. package/framework/skills/qualia-complete-milestone/SKILL.md +0 -134
  263. package/framework/skills/qualia-debug/SKILL.md +0 -149
  264. package/framework/skills/qualia-design/SKILL.md +0 -203
  265. package/framework/skills/qualia-discuss-phase/SKILL.md +0 -72
  266. package/framework/skills/qualia-evolve/SKILL.md +0 -200
  267. package/framework/skills/qualia-execute-phase/SKILL.md +0 -89
  268. package/framework/skills/qualia-framework-audit/SKILL.md +0 -604
  269. package/framework/skills/qualia-guide/SKILL.md +0 -32
  270. package/framework/skills/qualia-help/SKILL.md +0 -114
  271. package/framework/skills/qualia-idk/SKILL.md +0 -352
  272. package/framework/skills/qualia-list-phase-assumptions/SKILL.md +0 -67
  273. package/framework/skills/qualia-new-milestone/SKILL.md +0 -72
  274. package/framework/skills/qualia-new-project/SKILL.md +0 -232
  275. package/framework/skills/qualia-pause-work/SKILL.md +0 -96
  276. package/framework/skills/qualia-plan-milestone-gaps/SKILL.md +0 -57
  277. package/framework/skills/qualia-plan-phase/SKILL.md +0 -104
  278. package/framework/skills/qualia-production-check/SKILL.md +0 -0
  279. package/framework/skills/qualia-progress/SKILL.md +0 -53
  280. package/framework/skills/qualia-quick/SKILL.md +0 -89
  281. package/framework/skills/qualia-report/SKILL.md +0 -166
  282. package/framework/skills/qualia-research-phase/SKILL.md +0 -88
  283. package/framework/skills/qualia-resume-work/SKILL.md +0 -62
  284. package/framework/skills/qualia-review/SKILL.md +0 -263
  285. package/framework/skills/qualia-start/SKILL.md +0 -161
  286. package/framework/skills/qualia-verify-work/SKILL.md +0 -132
  287. package/framework/skills/rag/SKILL.md +0 -750
  288. package/framework/skills/responsive/SKILL.md +0 -231
  289. package/framework/skills/retro/SKILL.md +0 -284
  290. package/framework/skills/sakani-conventions/SKILL.md +0 -136
  291. package/framework/skills/sakani-conventions/evals/evals.json +0 -23
  292. package/framework/skills/sakani-conventions/references/entities.md +0 -365
  293. package/framework/skills/sakani-conventions/references/error-codes.md +0 -95
  294. package/framework/skills/seo-master/SKILL.md +0 -490
  295. package/framework/skills/seo-master/references/checklist.md +0 -199
  296. package/framework/skills/seo-master/references/structured-data.md +0 -609
  297. package/framework/skills/ship/SKILL.md +0 -239
  298. package/framework/skills/stack-researcher/SKILL.md +0 -215
  299. package/framework/skills/status/SKILL.md +0 -154
  300. package/framework/skills/status/scripts/health-check.sh +0 -562
  301. package/framework/skills/subscription-payments/SKILL.md +0 -250
  302. package/framework/skills/supabase/SKILL.md +0 -973
  303. package/framework/skills/supabase/references/templates.md +0 -159
  304. package/framework/skills/team/SKILL.md +0 -67
  305. package/framework/skills/test-runner/SKILL.md +0 -202
  306. package/framework/skills/voice-agent/SKILL.md +0 -1312
  307. package/framework/skills/zoho-workflow/SKILL.md +0 -51
  308. package/framework/statusline-command.sh +0 -117
  309. package/framework/teams/default/inboxes/plan-04.json +0 -9
  310. package/framework/teams/review-team.md +0 -75
  311. package/framework/teams/ship-team.md +0 -86
  312. package/profiles/fawzi.json +0 -16
  313. package/profiles/hasan.json +0 -16
  314. package/profiles/moayad.json +0 -16
  315. package/templates/CLAUDE-owner.md +0 -52
  316. package/templates/CLAUDE.md.hbs +0 -58
  317. package/templates/env.claude.template +0 -12
  318. package/templates/settings.json +0 -172
  319. package/uninstall.sh +0 -90
  320. /package/{framework/rules → rules}/deployment.md +0 -0
  321. /package/{framework/rules → rules}/security.md +0 -0
@@ -1,365 +0,0 @@
1
- # Sakani Entity Reference
2
-
3
- Complete entity definitions from SRS V1.14. This is the source of truth for schema design, API contracts, and type generation.
4
-
5
- ## Conventions
6
-
7
- - All IDs are UUIDs
8
- - All tables have `id`, `created_at` (timestamptz, UTC), `updated_at` (timestamptz, UTC)
9
- - Monetary fields: `{ amount: numeric, currency: text }` (ISO 4217)
10
- - All timestamps stored UTC, presented Asia/Amman
11
- - `request_id` correlation on every write operation
12
-
13
- ---
14
-
15
- ## Identity Domain
16
-
17
- ### building
18
- | Field | Type | Notes |
19
- |-------|------|-------|
20
- | id | uuid | PK |
21
- | building_key_v1 | text | Canonical key for deterministic matching. UNIQUE. Never expose. |
22
- | name_ar | text | Arabic building name |
23
- | name_en | text | English building name |
24
- | building_type | enum | RESIDENTIAL, COMMERCIAL, MIXED |
25
- | address | jsonb | Structured address object |
26
- | unit_count | integer | Number of units |
27
- | subscription_status | enum | TRIAL, ACTIVE, INACTIVE |
28
- | trial_expires_at | timestamptz | 30-day trial expiry |
29
-
30
- ### building_contact
31
- | Field | Type | Notes |
32
- |-------|------|-------|
33
- | building_id | uuid | FK → building |
34
- | contact_type | enum | PHONE, EMAIL, ADDRESS |
35
- | value | text | |
36
-
37
- ### building_setup_request
38
- | Field | Type | Notes |
39
- |-------|------|-------|
40
- | id | uuid | PK |
41
- | requested_by | uuid | FK → auth.users |
42
- | status | enum | PENDING, APPROVED, REJECTED, RETURNED_FOR_FIX |
43
- | building_data | jsonb | Submitted building details |
44
- | occupation_permit_document_id | uuid | FK → document |
45
- | reviewed_by | uuid | FK → auth.users (staff) |
46
- | review_notes | text | |
47
- | rejection_reason_code | text | Stable identifier |
48
-
49
- ### unit
50
- | Field | Type | Notes |
51
- |-------|------|-------|
52
- | id | uuid | PK |
53
- | building_id | uuid | FK → building |
54
- | unit_key_v1 | text | Canonical key. UNIQUE per building. Never expose. |
55
- | unit_number | text | Display number |
56
- | floor | integer | |
57
- | unit_type | enum | APARTMENT, OFFICE, SHOP, OTHER |
58
- | status | enum | DRAFT, ACTIVE |
59
-
60
- ### unit_claim_request
61
- | Field | Type | Notes |
62
- |-------|------|-------|
63
- | id | uuid | PK |
64
- | unit_id | uuid | FK → unit |
65
- | claimed_by | uuid | FK → auth.users |
66
- | status | enum | PENDING, APPROVED, REJECTED, RETURNED_FOR_FIX |
67
- | goshan_document_id | uuid | FK → document |
68
- | match_outcome | enum | ZERO_MATCH, ONE_MATCH, MULTI_MATCH |
69
- | reviewed_by | uuid | FK → auth.users (staff) |
70
-
71
- ### unit_membership
72
- | Field | Type | Notes |
73
- |-------|------|-------|
74
- | id | uuid | PK |
75
- | unit_id | uuid | FK → unit |
76
- | user_id | uuid | FK → auth.users |
77
- | role | enum | OWNER_VERIFIED, TENANT |
78
- | status | enum | ACTIVE, INACTIVE |
79
- | invited_by | uuid | FK → auth.users |
80
-
81
- One OWNER_VERIFIED per unit (no co-ownership in Phase 1).
82
-
83
- ### building_role_assignment
84
- | Field | Type | Notes |
85
- |-------|------|-------|
86
- | id | uuid | PK |
87
- | building_id | uuid | FK → building |
88
- | user_id | uuid | FK → auth.users |
89
- | role | enum | BM_CANDIDATE, BM_VERIFIED, GUARD, DEV_ADMIN |
90
- | status | enum | ACTIVE, INACTIVE |
91
- | assigned_by | uuid | FK → auth.users |
92
-
93
- ### document
94
- | Field | Type | Notes |
95
- |-------|------|-------|
96
- | id | uuid | PK |
97
- | owner_entity_type | enum | BUILDING, UNIT, USER, TICKET, CREDIT_TOPUP_REQUEST, CONTRACT, NOTICE, TASK_TEMPLATE, TASK_INSTANCE |
98
- | owner_entity_id | uuid | Polymorphic FK |
99
- | document_type | text | Classification |
100
- | storage_path | text | Object storage path |
101
- | signed_url_ttl | integer | Seconds |
102
- | uploaded_by | uuid | FK → auth.users |
103
- | approval_status | enum | PENDING, APPROVED, REJECTED |
104
- | visibility | enum | PUBLIC, BUILDING_MEMBERS, UNIT_MEMBERS, PRIVATE |
105
-
106
- ---
107
-
108
- ## Finance Domain
109
-
110
- ### dues_config
111
- | Field | Type | Notes |
112
- |-------|------|-------|
113
- | id | uuid | PK |
114
- | building_id | uuid | FK → building |
115
- | amount | numeric | Monthly amount |
116
- | currency | text | ISO 4217 (JOD) |
117
- | collection_day | integer | Day of month (1-28 recommended) |
118
- | effective_from | date | |
119
-
120
- ### dues_cycle
121
- | Field | Type | Notes |
122
- |-------|------|-------|
123
- | id | uuid | PK |
124
- | building_id | uuid | FK → building |
125
- | cycle_ym | text | Format: YYYY-MM |
126
- | status | enum | OPEN, CLOSED |
127
-
128
- ### dues_obligation
129
- | Field | Type | Notes |
130
- |-------|------|-------|
131
- | id | uuid | PK |
132
- | cycle_id | uuid | FK → dues_cycle |
133
- | unit_id | uuid | FK → unit |
134
- | amount | numeric | |
135
- | currency | text | JOD |
136
- | status | enum | UNPAID, PAID, LATE |
137
- | due_date | date | |
138
-
139
- UNPAID → LATE at cycle boundary. UNPAID/LATE → PAID via settlement.
140
-
141
- ### ledger_entry
142
- | Field | Type | Notes |
143
- |-------|------|-------|
144
- | id | uuid | PK |
145
- | building_id | uuid | FK → building |
146
- | unit_id | uuid | FK → unit (nullable for building-level) |
147
- | entry_type | enum | CREDIT_TOPUP, MANUAL_UNIT_INCOME, OPENING_BALANCE, EXPENSE, SUBSCRIPTION_FEE, AUTOSETTLEMENT_APPLIED, REVERSAL |
148
- | amount | numeric | Positive = credit, negative = debit |
149
- | currency | text | JOD |
150
- | reference_id | uuid | FK to source entity |
151
- | reference_type | text | Source entity type |
152
- | idempotency_key | text | UNIQUE. Prevents duplicate writes. |
153
- | request_id | uuid | Audit correlation |
154
- | created_by | uuid | FK → auth.users |
155
-
156
- **APPEND-ONLY.** Never UPDATE or DELETE. Corrections via REVERSAL entries only.
157
-
158
- ### credit_topup_request
159
- | Field | Type | Notes |
160
- |-------|------|-------|
161
- | id | uuid | PK |
162
- | unit_id | uuid | FK → unit |
163
- | requested_by | uuid | FK → auth.users (owner only) |
164
- | amount | numeric | |
165
- | currency | text | JOD |
166
- | evidence_document_id | uuid | FK → document (CliQ/bank screenshot) |
167
- | status | enum | PENDING, APPROVED, REJECTED |
168
- | reviewed_by | uuid | FK → auth.users (BM) |
169
- | idempotency_key | text | UNIQUE |
170
-
171
- ### settlement_entry
172
- | Field | Type | Notes |
173
- |-------|------|-------|
174
- | id | uuid | PK |
175
- | obligation_id | uuid | FK → dues_obligation |
176
- | ledger_entry_id | uuid | FK → ledger_entry |
177
- | amount | numeric | |
178
- | settled_at | timestamptz | |
179
-
180
- FIFO: oldest obligation settled first. No partial settlement.
181
-
182
- ### expense
183
- | Field | Type | Notes |
184
- |-------|------|-------|
185
- | id | uuid | PK |
186
- | building_id | uuid | FK → building |
187
- | amount | numeric | |
188
- | currency | text | JOD |
189
- | description | text | |
190
- | category | text | |
191
- | evidence_document_id | uuid | FK → document |
192
- | recorded_by | uuid | FK → auth.users (BM) |
193
- | approval_status | enum | PENDING, APPROVED |
194
-
195
- ---
196
-
197
- ## Subscription Domain
198
-
199
- ### subscription_entitlement
200
- | Field | Type | Notes |
201
- |-------|------|-------|
202
- | id | uuid | PK |
203
- | building_id | uuid | FK → building. ONE per building. |
204
- | status | enum | TRIAL, ACTIVE, INACTIVE |
205
- | current_period_start | timestamptz | |
206
- | current_period_end | timestamptz | |
207
- | provider | text | stripe, hyperpay |
208
- | provider_subscription_id | text | External ID |
209
-
210
- ### subscription_plan
211
- | Field | Type | Notes |
212
- |-------|------|-------|
213
- | id | uuid | PK |
214
- | name | text | |
215
- | building_type | enum | RESIDENTIAL, COMMERCIAL, MIXED |
216
- | unit_count_min | integer | |
217
- | unit_count_max | integer | |
218
- | price | numeric | |
219
- | currency | text | JOD |
220
- | billing_interval | text | monthly, yearly |
221
-
222
- ### subscription_price_quote
223
- | Field | Type | Notes |
224
- |-------|------|-------|
225
- | id | uuid | PK |
226
- | building_id | uuid | FK → building |
227
- | plan_id | uuid | FK → subscription_plan |
228
- | quoted_price | numeric | Snapshot at quote time |
229
- | inputs_snapshot | jsonb | building_type, unit_count at quote time |
230
- | expires_at | timestamptz | Quote expiry |
231
- | status | enum | ACTIVE, EXPIRED, CONSUMED |
232
-
233
- ### subscription_checkout_session
234
- | Field | Type | Notes |
235
- |-------|------|-------|
236
- | id | uuid | PK |
237
- | quote_id | uuid | FK → subscription_price_quote |
238
- | provider | text | stripe, hyperpay |
239
- | provider_session_id | text | |
240
- | status | enum | PENDING, COMPLETED, FAILED |
241
- | promo_redemption_id | uuid | FK → promo_redemption (nullable) |
242
-
243
- ### subscription_event
244
- | Field | Type | Notes |
245
- |-------|------|-------|
246
- | id | uuid | PK |
247
- | provider | text | |
248
- | provider_event_id | text | UNIQUE (idempotency) |
249
- | canonical_event_type | text | Normalized event type |
250
- | raw_payload | jsonb | |
251
- | processed_at | timestamptz | |
252
- | signature_valid | boolean | |
253
-
254
- ### promo_code
255
- | Field | Type | Notes |
256
- |-------|------|-------|
257
- | id | uuid | PK |
258
- | code | text | UNIQUE |
259
- | discount_type | enum | PERCENTAGE, FIXED |
260
- | discount_value | numeric | |
261
- | max_redemptions | integer | |
262
- | current_redemptions | integer | |
263
- | valid_from | timestamptz | |
264
- | valid_until | timestamptz | |
265
- | status | enum | ACTIVE, EXHAUSTED, EXPIRED |
266
-
267
- ### promo_redemption
268
- | Field | Type | Notes |
269
- |-------|------|-------|
270
- | id | uuid | PK |
271
- | promo_code_id | uuid | FK → promo_code |
272
- | building_id | uuid | FK → building |
273
- | status | enum | RESERVED, CONSUMED |
274
-
275
- RESERVED on checkout start, CONSUMED on payment success. Atomic.
276
-
277
- ### reimbursement_obligation
278
- | Field | Type | Notes |
279
- |-------|------|-------|
280
- | id | uuid | PK |
281
- | building_id | uuid | FK → building |
282
- | checkout_session_id | uuid | FK → subscription_checkout_session |
283
- | amount | numeric | |
284
- | currency | text | JOD |
285
- | settlement_method | enum | DUES_OFFSET, MANUAL |
286
- | status | enum | PENDING, SETTLED |
287
- | idempotency_key | text | UNIQUE |
288
-
289
- ---
290
-
291
- ## Operations Domain
292
-
293
- ### guard_invite
294
- | Field | Type | Notes |
295
- |-------|------|-------|
296
- | id | uuid | PK |
297
- | building_id | uuid | FK → building |
298
- | invited_by | uuid | FK → auth.users (BM) |
299
- | phone_number | text | |
300
- | status | enum | PENDING, ACCEPTED, EXPIRED, REVOKED |
301
- | expires_at | timestamptz | 7-day expiry |
302
- | token | text | Single-use invite token |
303
-
304
- One ACTIVE guard per building.
305
-
306
- ### guard_task
307
- | Field | Type | Notes |
308
- |-------|------|-------|
309
- | id | uuid | PK |
310
- | building_id | uuid | FK → building |
311
- | template_id | uuid | FK → task_template (nullable) |
312
- | assigned_to | uuid | FK → auth.users (guard) |
313
- | title | text | |
314
- | description | text | |
315
- | scheduled_at | timestamptz | |
316
- | reminder_at | timestamptz | T-15m before scheduled_at |
317
- | status | enum | PENDING, IN_PROGRESS, COMPLETED, MISSED |
318
- | visibility | enum | BUILDING_PUBLIC, UNIT_PRIVATE |
319
-
320
- BUILDING_PUBLIC: all building members see details. UNIT_PRIVATE: others see "Busy/Private" only.
321
-
322
- ### ticket
323
- | Field | Type | Notes |
324
- |-------|------|-------|
325
- | id | uuid | PK |
326
- | building_id | uuid | FK → building |
327
- | unit_id | uuid | FK → unit (nullable) |
328
- | reported_by | uuid | FK → auth.users |
329
- | assigned_to | uuid | FK → auth.users (guard, nullable) |
330
- | title | text | |
331
- | description | text | |
332
- | category | text | Optional |
333
- | status | enum | NEW, IN_PROGRESS, DONE, CLOSED, CANCELLED |
334
- | priority | enum | LOW, MEDIUM, HIGH |
335
-
336
- Status flow: NEW → IN_PROGRESS → DONE → CLOSED. Optional CANCELLED from any state.
337
-
338
- ---
339
-
340
- ## Audit Domain
341
-
342
- ### audit_log
343
- | Field | Type | Notes |
344
- |-------|------|-------|
345
- | id | uuid | PK |
346
- | event_type | text | e.g., permit_submitted, credit_topup_approved |
347
- | actor_user_id | uuid | FK → auth.users |
348
- | building_id | uuid | Nullable |
349
- | unit_id | uuid | Nullable |
350
- | request_id | uuid | Correlation |
351
- | payload | jsonb | Event-specific data (no PII) |
352
- | created_at | timestamptz | |
353
-
354
- **IMMUTABLE.** 7-year retention. Filterable by building_id, unit_id, actor_user_id, event_type, date range.
355
-
356
- ### statement_version
357
- | Field | Type | Notes |
358
- |-------|------|-------|
359
- | id | uuid | PK |
360
- | building_id | uuid | FK → building |
361
- | cycle_ym | text | |
362
- | version_token | text | UNIQUE |
363
- | pdf_storage_path | text | |
364
- | hash | text | Immutable content hash |
365
- | generated_at | timestamptz | |
@@ -1,95 +0,0 @@
1
- # Sakani Error Codes
2
-
3
- All 44 error codes from SRS V1.14 (EH-6.02 through EH-6.44). Every API endpoint must use these exact codes.
4
-
5
- ## Error Response Shape
6
-
7
- ```typescript
8
- interface ApiError {
9
- http_status: number;
10
- error_code: string;
11
- message_key: string; // i18n lookup key
12
- request_id: string; // UUID, always present
13
- details?: Record<string, unknown>; // safe details only
14
- }
15
- ```
16
-
17
- ## Safe-Details Rule
18
-
19
- NEVER include in `details` or error messages:
20
- - `building_key_v1` or `unit_key_v1` values
21
- - National ID numbers or extracted document text
22
- - Internal entity IDs that enable enumeration
23
- - Stack traces or internal paths
24
-
25
- ## Error Code Table
26
-
27
- | Code | error_code | HTTP | message_key | Context |
28
- |------|-----------|------|-------------|---------|
29
- | EH-6.02 | UNAUTHENTICATED | 401 | error.auth.unauthenticated | No valid token |
30
- | EH-6.03 | TOKEN_EXPIRED | 401 | error.auth.token_expired | Access token expired |
31
- | EH-6.04 | INSUFFICIENT_PERMISSIONS | 403 | error.auth.insufficient_permissions | Role/scope insufficient |
32
- | EH-6.05 | BUILDING_NOT_FOUND | 404 | error.building.not_found | Building lookup 0-match |
33
- | EH-6.06 | BUILDING_AMBIGUOUS | 409 | error.building.ambiguous | Building lookup >1-match |
34
- | EH-6.07 | UNIT_NOT_FOUND | 404 | error.unit.not_found | Unit lookup 0-match |
35
- | EH-6.08 | UNIT_AMBIGUOUS | 409 | error.unit.ambiguous | Unit lookup >1-match |
36
- | EH-6.09 | UNIT_ALREADY_CLAIMED | 409 | error.unit.already_claimed | OWNER_VERIFIED exists |
37
- | EH-6.10 | CLAIM_ALREADY_PENDING | 409 | error.claim.already_pending | Duplicate claim request |
38
- | EH-6.11 | PERMIT_ALREADY_SUBMITTED | 409 | error.permit.already_submitted | Duplicate permit submission |
39
- | EH-6.12 | SETUP_REQUEST_ALREADY_PENDING | 409 | error.setup.already_pending | Duplicate setup request |
40
- | EH-6.13 | DOCUMENT_NOT_FOUND | 404 | error.document.not_found | Document ID invalid |
41
- | EH-6.14 | DOCUMENT_ACCESS_DENIED | 403 | error.document.access_denied | Visibility check failed |
42
- | EH-6.15 | INVALID_DOCUMENT_TYPE | 422 | error.document.invalid_type | Wrong document classification |
43
- | EH-6.16 | DUES_CONFIG_NOT_FOUND | 404 | error.dues.config_not_found | No dues config for building |
44
- | EH-6.17 | DUES_CYCLE_NOT_FOUND | 404 | error.dues.cycle_not_found | Invalid cycle_ym |
45
- | EH-6.18 | OBLIGATION_NOT_FOUND | 404 | error.dues.obligation_not_found | Invalid obligation |
46
- | EH-6.19 | INSUFFICIENT_CREDIT | 422 | error.credit.insufficient | Credit doesn't cover obligation |
47
- | EH-6.20 | DUPLICATE_TOPUP_REQUEST | 409 | error.credit.duplicate_topup | Idempotency key collision |
48
- | EH-6.21 | TOPUP_ALREADY_REVIEWED | 409 | error.credit.already_reviewed | Re-reviewing decided request |
49
- | EH-6.22 | OPENING_BALANCE_EXISTS | 409 | error.ledger.opening_balance_exists | One per unit |
50
- | EH-6.23 | OPENING_BALANCE_WINDOW_CLOSED | 422 | error.ledger.opening_balance_window | Past controlled window |
51
- | EH-6.24 | LEDGER_IDEMPOTENCY_CONFLICT | 409 | error.ledger.idempotency_conflict | Duplicate financial write |
52
- | EH-6.25 | SUBSCRIPTION_NOT_FOUND | 404 | error.subscription.not_found | No entitlement for building |
53
- | EH-6.26 | SUBSCRIPTION_INACTIVE | 403 | error.subscription.inactive | Paywall gate |
54
- | EH-6.27 | TRIAL_EXPIRED | 403 | error.subscription.trial_expired | 30-day trial over |
55
- | EH-6.28 | QUOTE_EXPIRED | 422 | error.subscription.quote_expired | Price quote past expiry |
56
- | EH-6.29 | QUOTE_ALREADY_CONSUMED | 409 | error.subscription.quote_consumed | Quote used in checkout |
57
- | EH-6.30 | PROMO_CODE_INVALID | 422 | error.promo.invalid | Code not found or inactive |
58
- | EH-6.31 | PROMO_CODE_EXHAUSTED | 422 | error.promo.exhausted | Max redemptions reached |
59
- | EH-6.32 | PROMO_ALREADY_RESERVED | 409 | error.promo.already_reserved | Duplicate reservation |
60
- | EH-6.33 | CHECKOUT_SESSION_INVALID | 422 | error.checkout.invalid | Bad session state |
61
- | EH-6.34 | WEBHOOK_SIGNATURE_INVALID | 401 | error.webhook.signature_invalid | Provider signature failed |
62
- | EH-6.35 | GUARD_INVITE_EXPIRED | 422 | error.guard.invite_expired | Past 7-day window |
63
- | EH-6.36 | GUARD_INVITE_REVOKED | 422 | error.guard.invite_revoked | Invite was revoked |
64
- | EH-6.37 | GUARD_ALREADY_ACTIVE | 409 | error.guard.already_active | One active guard per building |
65
- | EH-6.38 | TICKET_NOT_FOUND | 404 | error.ticket.not_found | Invalid ticket |
66
- | EH-6.39 | TICKET_INVALID_TRANSITION | 422 | error.ticket.invalid_transition | Status flow violated |
67
- | EH-6.40 | TASK_NOT_FOUND | 404 | error.task.not_found | Invalid task |
68
- | EH-6.41 | VALIDATION_ERROR | 422 | error.validation.failed | Zod/input validation |
69
- | EH-6.42 | RATE_LIMITED | 429 | error.rate_limit.exceeded | Too many requests |
70
- | EH-6.43 | INTERNAL_ERROR | 500 | error.internal | Unexpected server error |
71
- | EH-6.44 | SERVICE_UNAVAILABLE | 503 | error.service.unavailable | Downstream service down |
72
-
73
- ## Usage in NestJS
74
-
75
- ```typescript
76
- // In @sakani/shared/src/constants/errors.ts
77
- export const SAKANI_ERRORS = {
78
- UNAUTHENTICATED: { code: 'UNAUTHENTICATED', status: 401, messageKey: 'error.auth.unauthenticated' },
79
- BUILDING_NOT_FOUND: { code: 'BUILDING_NOT_FOUND', status: 404, messageKey: 'error.building.not_found' },
80
- // ... all 44
81
- } as const;
82
-
83
- // In NestJS exception filter
84
- throw new SakaniException(SAKANI_ERRORS.BUILDING_NOT_FOUND, { requestId });
85
- ```
86
-
87
- ## Deterministic Lookup Semantics
88
-
89
- These error codes have precise semantic meanings for building/unit lookup:
90
- - `BUILDING_NOT_FOUND` = exactly 0-match (not "maybe not found")
91
- - `BUILDING_AMBIGUOUS` = exactly >1-match
92
- - `UNIT_NOT_FOUND` = exactly 0-match
93
- - `UNIT_AMBIGUOUS` = exactly >1-match
94
-
95
- The lookup algorithm must be deterministic: same input always produces the same match outcome.