pi-skill-search 0.1.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 (299) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +97 -0
  4. package/index.ts +163 -0
  5. package/package.json +48 -0
  6. package/skills/adaptyv/SKILL.md +92 -0
  7. package/skills/add-community-extension/SKILL.md +85 -0
  8. package/skills/aeon/SKILL.md +111 -0
  9. package/skills/ai-slop-cleaner/SKILL.md +118 -0
  10. package/skills/anndata/SKILL.md +83 -0
  11. package/skills/arboreto/SKILL.md +107 -0
  12. package/skills/ask/SKILL.md +55 -0
  13. package/skills/astropy/SKILL.md +30 -0
  14. package/skills/async-worker-recovery/SKILL.md +44 -0
  15. package/skills/autopilot/SKILL.md +63 -0
  16. package/skills/autoresearch/SKILL.md +64 -0
  17. package/skills/autoskill/SKILL.md +116 -0
  18. package/skills/babysit/SKILL.md +43 -0
  19. package/skills/benchling-integration/SKILL.md +106 -0
  20. package/skills/bgpt-paper-search/SKILL.md +67 -0
  21. package/skills/biopython/SKILL.md +29 -0
  22. package/skills/bioservices/SKILL.md +96 -0
  23. package/skills/brainstorming/SKILL.md +104 -0
  24. package/skills/cancel/SKILL.md +85 -0
  25. package/skills/ccg/SKILL.md +87 -0
  26. package/skills/celery-pipeline/SKILL.md +30 -0
  27. package/skills/cellxgene-census/SKILL.md +104 -0
  28. package/skills/child-pi-spawning/SKILL.md +85 -0
  29. package/skills/cirq/SKILL.md +113 -0
  30. package/skills/citation-management/SKILL.md +91 -0
  31. package/skills/clinical-decision-support/SKILL.md +117 -0
  32. package/skills/clinical-reports/SKILL.md +118 -0
  33. package/skills/clinical-trial/SKILL.md +28 -0
  34. package/skills/cobrapy/SKILL.md +116 -0
  35. package/skills/configure-notifications/SKILL.md +85 -0
  36. package/skills/consciousness-council/SKILL.md +120 -0
  37. package/skills/context-artifact-hygiene/SKILL.md +85 -0
  38. package/skills/context-mode-ops/SKILL.md +87 -0
  39. package/skills/dask/SKILL.md +85 -0
  40. package/skills/database-lookup/SKILL.md +118 -0
  41. package/skills/datamol/SKILL.md +108 -0
  42. package/skills/debug/SKILL.md +32 -0
  43. package/skills/deep-dive/SKILL.md +114 -0
  44. package/skills/deep-interview/SKILL.md +90 -0
  45. package/skills/deepchem/SKILL.md +117 -0
  46. package/skills/deepinit/SKILL.md +100 -0
  47. package/skills/deeptools/SKILL.md +118 -0
  48. package/skills/delegation-patterns/SKILL.md +56 -0
  49. package/skills/depmap/SKILL.md +94 -0
  50. package/skills/dhdna-profiler/SKILL.md +86 -0
  51. package/skills/diffdock/SKILL.md +101 -0
  52. package/skills/dispatching-parallel-agents/SKILL.md +119 -0
  53. package/skills/dnanexus-integration/SKILL.md +118 -0
  54. package/skills/do/SKILL.md +48 -0
  55. package/skills/docker-sandbox/SKILL.md +29 -0
  56. package/skills/docx/SKILL.md +119 -0
  57. package/skills/esm/SKILL.md +116 -0
  58. package/skills/etetoolkit/SKILL.md +103 -0
  59. package/skills/event-log-tracing/SKILL.md +85 -0
  60. package/skills/exa-search/SKILL.md +72 -0
  61. package/skills/executing-plans/SKILL.md +69 -0
  62. package/skills/exploratory-data-analysis/SKILL.md +118 -0
  63. package/skills/external-context/SKILL.md +80 -0
  64. package/skills/fastapi/SKILL.md +30 -0
  65. package/skills/finishing-a-development-branch/SKILL.md +106 -0
  66. package/skills/flowio/SKILL.md +114 -0
  67. package/skills/fluidsim/SKILL.md +108 -0
  68. package/skills/generate-image/SKILL.md +108 -0
  69. package/skills/geniml/SKILL.md +117 -0
  70. package/skills/geomaster/SKILL.md +109 -0
  71. package/skills/geopandas/SKILL.md +114 -0
  72. package/skills/get-available-resources/SKILL.md +100 -0
  73. package/skills/gget/SKILL.md +111 -0
  74. package/skills/ginkgo-cloud-lab/SKILL.md +52 -0
  75. package/skills/git-master/SKILL.md +85 -0
  76. package/skills/glycoengineering/SKILL.md +104 -0
  77. package/skills/gtars/SKILL.md +104 -0
  78. package/skills/hackernews-frontpage/SKILL.md +46 -0
  79. package/skills/histolab/SKILL.md +98 -0
  80. package/skills/how-it-works/SKILL.md +25 -0
  81. package/skills/hud/SKILL.md +86 -0
  82. package/skills/hugging-science/SKILL.md +93 -0
  83. package/skills/huggingface/SKILL.md +30 -0
  84. package/skills/hypogenic/SKILL.md +107 -0
  85. package/skills/hypothesis-generation/SKILL.md +118 -0
  86. package/skills/imaging-data-commons/SKILL.md +119 -0
  87. package/skills/infographics/SKILL.md +102 -0
  88. package/skills/iso-13485-certification/SKILL.md +114 -0
  89. package/skills/knowledge-agent/SKILL.md +83 -0
  90. package/skills/labarchive-integration/SKILL.md +98 -0
  91. package/skills/lamindb/SKILL.md +119 -0
  92. package/skills/landsat/SKILL.md +29 -0
  93. package/skills/latchbio-integration/SKILL.md +118 -0
  94. package/skills/latex-posters/SKILL.md +112 -0
  95. package/skills/learn-codebase/SKILL.md +24 -0
  96. package/skills/learner/SKILL.md +118 -0
  97. package/skills/literature-review/SKILL.md +118 -0
  98. package/skills/live-agent-lifecycle/SKILL.md +85 -0
  99. package/skills/mailbox-interactive/SKILL.md +85 -0
  100. package/skills/make-plan/SKILL.md +59 -0
  101. package/skills/markdown-mermaid-writing/SKILL.md +118 -0
  102. package/skills/market-research-reports/SKILL.md +119 -0
  103. package/skills/markitdown/SKILL.md +111 -0
  104. package/skills/markitdown-docs/SKILL.md +28 -0
  105. package/skills/matchms/SKILL.md +91 -0
  106. package/skills/matlab/SKILL.md +118 -0
  107. package/skills/matplotlib/SKILL.md +30 -0
  108. package/skills/mcp-setup/SKILL.md +84 -0
  109. package/skills/medchem/SKILL.md +109 -0
  110. package/skills/mem-search/SKILL.md +96 -0
  111. package/skills/modal/SKILL.md +104 -0
  112. package/skills/model-routing-context/SKILL.md +85 -0
  113. package/skills/molecular-dynamics/SKILL.md +116 -0
  114. package/skills/molfeat/SKILL.md +110 -0
  115. package/skills/multi-perspective-review/SKILL.md +85 -0
  116. package/skills/networkx/SKILL.md +111 -0
  117. package/skills/neurokit2/SKILL.md +114 -0
  118. package/skills/neuropixels-analysis/SKILL.md +112 -0
  119. package/skills/nilearn/SKILL.md +29 -0
  120. package/skills/observability-reliability/SKILL.md +43 -0
  121. package/skills/omc-doctor/SKILL.md +86 -0
  122. package/skills/omc-reference/SKILL.md +119 -0
  123. package/skills/omc-setup/SKILL.md +82 -0
  124. package/skills/omc-teams/SKILL.md +81 -0
  125. package/skills/omero-integration/SKILL.md +111 -0
  126. package/skills/open-notebook/SKILL.md +100 -0
  127. package/skills/openephys/SKILL.md +28 -0
  128. package/skills/opentrons-integration/SKILL.md +110 -0
  129. package/skills/optimize-for-gpu/SKILL.md +119 -0
  130. package/skills/orchestration/SKILL.md +85 -0
  131. package/skills/ownership-session-security/SKILL.md +43 -0
  132. package/skills/paper-lookup/SKILL.md +119 -0
  133. package/skills/paperzilla/SKILL.md +114 -0
  134. package/skills/parallel-web/SKILL.md +64 -0
  135. package/skills/pathfinder/SKILL.md +114 -0
  136. package/skills/pathml/SKILL.md +98 -0
  137. package/skills/pdf/SKILL.md +113 -0
  138. package/skills/peer-review/SKILL.md +119 -0
  139. package/skills/pennylane/SKILL.md +119 -0
  140. package/skills/phylogenetics/SKILL.md +102 -0
  141. package/skills/pi-extension-lifecycle/SKILL.md +41 -0
  142. package/skills/plan/SKILL.md +66 -0
  143. package/skills/polars/SKILL.md +114 -0
  144. package/skills/polars-bio/SKILL.md +84 -0
  145. package/skills/pptx/SKILL.md +118 -0
  146. package/skills/pptx-posters/SKILL.md +112 -0
  147. package/skills/primekg/SKILL.md +97 -0
  148. package/skills/project-session-manager/SKILL.md +85 -0
  149. package/skills/protocolsio-integration/SKILL.md +119 -0
  150. package/skills/pubmed-search/SKILL.md +29 -0
  151. package/skills/pufferlib/SKILL.md +103 -0
  152. package/skills/pydeseq2/SKILL.md +106 -0
  153. package/skills/pydicom/SKILL.md +115 -0
  154. package/skills/pyhealth/SKILL.md +117 -0
  155. package/skills/pylabrobot/SKILL.md +100 -0
  156. package/skills/pymatgen/SKILL.md +28 -0
  157. package/skills/pymc/SKILL.md +108 -0
  158. package/skills/pymoo/SKILL.md +90 -0
  159. package/skills/pyopenms/SKILL.md +119 -0
  160. package/skills/pysam/SKILL.md +118 -0
  161. package/skills/pyspark/SKILL.md +30 -0
  162. package/skills/pytdc/SKILL.md +102 -0
  163. package/skills/pytorch/SKILL.md +31 -0
  164. package/skills/pytorch-lightning/SKILL.md +119 -0
  165. package/skills/pyzotero/SKILL.md +104 -0
  166. package/skills/qiskit/SKILL.md +119 -0
  167. package/skills/qutip/SKILL.md +111 -0
  168. package/skills/ralph/SKILL.md +23 -0
  169. package/skills/ralplan/SKILL.md +105 -0
  170. package/skills/rdflib/SKILL.md +29 -0
  171. package/skills/rdkit/SKILL.md +30 -0
  172. package/skills/read-only-explorer/SKILL.md +85 -0
  173. package/skills/receiving-code-review/SKILL.md +103 -0
  174. package/skills/release/SKILL.md +117 -0
  175. package/skills/remember/SKILL.md +39 -0
  176. package/skills/requesting-code-review/SKILL.md +85 -0
  177. package/skills/requirements-to-task-packet/SKILL.md +65 -0
  178. package/skills/research-grants/SKILL.md +118 -0
  179. package/skills/research-lookup/SKILL.md +117 -0
  180. package/skills/research-reproducibility/SKILL.md +28 -0
  181. package/skills/resource-discovery-config/SKILL.md +43 -0
  182. package/skills/rowan/SKILL.md +100 -0
  183. package/skills/runtime-state-reader/SKILL.md +46 -0
  184. package/skills/safe-bash/SKILL.md +85 -0
  185. package/skills/scanpy/SKILL.md +32 -0
  186. package/skills/scholar-evaluation/SKILL.md +115 -0
  187. package/skills/scientific-brainstorming/SKILL.md +118 -0
  188. package/skills/scientific-critical-thinking/SKILL.md +119 -0
  189. package/skills/scientific-schematics/SKILL.md +116 -0
  190. package/skills/scientific-slides/SKILL.md +117 -0
  191. package/skills/scientific-visualization/SKILL.md +109 -0
  192. package/skills/scientific-writing/SKILL.md +119 -0
  193. package/skills/scikit-bio/SKILL.md +92 -0
  194. package/skills/scikit-learn/SKILL.md +99 -0
  195. package/skills/scikit-survival/SKILL.md +110 -0
  196. package/skills/sciomc/SKILL.md +86 -0
  197. package/skills/scvelo/SKILL.md +106 -0
  198. package/skills/scvi-tools/SKILL.md +114 -0
  199. package/skills/seaborn/SKILL.md +97 -0
  200. package/skills/secure-agent-orchestration-review/SKILL.md +47 -0
  201. package/skills/self-improve/SKILL.md +119 -0
  202. package/skills/semantic-compression/SKILL.md +62 -0
  203. package/skills/setup/SKILL.md +42 -0
  204. package/skills/shap/SKILL.md +103 -0
  205. package/skills/simpy/SKILL.md +116 -0
  206. package/skills/skill/SKILL.md +117 -0
  207. package/skills/skill-search/SKILL.md +67 -0
  208. package/skills/skillify/SKILL.md +46 -0
  209. package/skills/smart-explore/SKILL.md +94 -0
  210. package/skills/sqlite-pandas/SKILL.md +30 -0
  211. package/skills/stable-baselines3/SKILL.md +86 -0
  212. package/skills/state-mutation-locking/SKILL.md +44 -0
  213. package/skills/statistical-analysis/SKILL.md +108 -0
  214. package/skills/statsmodels/SKILL.md +29 -0
  215. package/skills/subagent-driven-development/SKILL.md +89 -0
  216. package/skills/sympy/SKILL.md +115 -0
  217. package/skills/system-prompts/SKILL.md +116 -0
  218. package/skills/systematic-debugging/SKILL.md +119 -0
  219. package/skills/team/SKILL.md +85 -0
  220. package/skills/test-driven-development/SKILL.md +84 -0
  221. package/skills/tiledbvcf/SKILL.md +119 -0
  222. package/skills/timeline-report/SKILL.md +85 -0
  223. package/skills/timesfm-forecasting/SKILL.md +112 -0
  224. package/skills/torch-geometric/SKILL.md +118 -0
  225. package/skills/torchdrug/SKILL.md +118 -0
  226. package/skills/trace/SKILL.md +118 -0
  227. package/skills/transformers/SKILL.md +110 -0
  228. package/skills/treatment-plans/SKILL.md +119 -0
  229. package/skills/ui-render-performance/SKILL.md +41 -0
  230. package/skills/ultragoal/SKILL.md +63 -0
  231. package/skills/ultraqa/SKILL.md +85 -0
  232. package/skills/ultrawork/SKILL.md +20 -0
  233. package/skills/umap-learn/SKILL.md +119 -0
  234. package/skills/usfiscaldata/SKILL.md +118 -0
  235. package/skills/using-git-worktrees/SKILL.md +112 -0
  236. package/skills/using-superpowers/SKILL.md +85 -0
  237. package/skills/using-vetc/SKILL.md +92 -0
  238. package/skills/vaex/SKILL.md +111 -0
  239. package/skills/venue-templates/SKILL.md +113 -0
  240. package/skills/verification-before-completion/SKILL.md +88 -0
  241. package/skills/verification-before-done/SKILL.md +68 -0
  242. package/skills/verify/SKILL.md +33 -0
  243. package/skills/version-bump/SKILL.md +54 -0
  244. package/skills/vetc-analyze-ba/SKILL.md +117 -0
  245. package/skills/vetc-analyze-codebase/SKILL.md +118 -0
  246. package/skills/vetc-api-design/SKILL.md +103 -0
  247. package/skills/vetc-brainstorming/SKILL.md +116 -0
  248. package/skills/vetc-change-proposal/SKILL.md +111 -0
  249. package/skills/vetc-cicd/SKILL.md +113 -0
  250. package/skills/vetc-continuous-learning/SKILL.md +115 -0
  251. package/skills/vetc-deep-interview/SKILL.md +103 -0
  252. package/skills/vetc-docgen/SKILL.md +108 -0
  253. package/skills/vetc-frontend-patterns/SKILL.md +99 -0
  254. package/skills/vetc-iterative-retrieval/SKILL.md +110 -0
  255. package/skills/vetc-java-patterns/SKILL.md +113 -0
  256. package/skills/vetc-meta-skill-creator/SKILL.md +99 -0
  257. package/skills/vetc-oracle-patterns/SKILL.md +109 -0
  258. package/skills/vetc-performance-testing/SKILL.md +104 -0
  259. package/skills/vetc-pr-response/SKILL.md +106 -0
  260. package/skills/vetc-ralph/SKILL.md +108 -0
  261. package/skills/vetc-ralplan/SKILL.md +116 -0
  262. package/skills/vetc-receiving-review/SKILL.md +106 -0
  263. package/skills/vetc-reconcile-patterns/SKILL.md +117 -0
  264. package/skills/vetc-refactoring/SKILL.md +96 -0
  265. package/skills/vetc-runbook/SKILL.md +118 -0
  266. package/skills/vetc-sast/SKILL.md +118 -0
  267. package/skills/vetc-sdlc/SKILL.md +97 -0
  268. package/skills/vetc-security/SKILL.md +117 -0
  269. package/skills/vetc-spec-driven/SKILL.md +111 -0
  270. package/skills/vetc-spec-quality/SKILL.md +117 -0
  271. package/skills/vetc-systematic-debugging/SKILL.md +74 -0
  272. package/skills/vetc-tdd/SKILL.md +96 -0
  273. package/skills/vetc-thinking-pm/SKILL.md +110 -0
  274. package/skills/vetc-ui-visual-qa/SKILL.md +117 -0
  275. package/skills/vetc-verify/SKILL.md +101 -0
  276. package/skills/visual-verdict/SKILL.md +59 -0
  277. package/skills/what-if-oracle/SKILL.md +87 -0
  278. package/skills/widget-rendering/SKILL.md +85 -0
  279. package/skills/wiki/SKILL.md +69 -0
  280. package/skills/workspace-isolation/SKILL.md +85 -0
  281. package/skills/worktree-isolation/SKILL.md +85 -0
  282. package/skills/wowerpoint/SKILL.md +101 -0
  283. package/skills/writer-memory/SKILL.md +82 -0
  284. package/skills/writing-plans/SKILL.md +115 -0
  285. package/skills/writing-skills/SKILL.md +115 -0
  286. package/skills/xgboost/SKILL.md +29 -0
  287. package/skills/xgboost-ts/SKILL.md +28 -0
  288. package/skills/xlsx/SKILL.md +111 -0
  289. package/skills/zarr-python/SKILL.md +101 -0
  290. package/src/categories.ts +383 -0
  291. package/src/format.ts +104 -0
  292. package/src/indexer.ts +101 -0
  293. package/src/proactive.ts +51 -0
  294. package/src/scanner.ts +85 -0
  295. package/src/search.ts +89 -0
  296. package/src/strip.ts +29 -0
  297. package/src/synonyms.ts +83 -0
  298. package/src/text.ts +118 -0
  299. package/src/types.ts +64 -0
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: vetc-reconcile-patterns
3
+ description: PROACTIVELY activate khi implement reconciliation job, debug reconcile logic (mismatch, duplicate, missing), hoặc thêm nguồn đối soát mới. SourceProcessor, distributed locking, idempotency patterns.
4
+ ---
5
+
6
+ # VETC Reconciliation Patterns
7
+
8
+ Patterns cho hệ thống đối soát VETC E-Wallet.
9
+
10
+ ## When to Activate
11
+
12
+ - Implement reconciliation job hoặc processor mới
13
+ - Debug reconcile logic (mismatch, duplicate, missing)
14
+ - Thêm nguồn dữ liệu mới vào reconcile pipeline
15
+ - Review reconcile code
16
+
17
+ ## Do NOT Activate When
18
+
19
+ - Làm tính năng không liên quan reconciliation (wallet, eKYC, commission, etc.)
20
+ - Chỉ làm frontend cho reconcile UI (dùng `vetc-frontend-patterns`)
21
+ - Chỉ viết unit test đơn giản, không cần reconcile domain knowledge
22
+
23
+ ## Core Architecture
24
+
25
+ ```
26
+ ReconcileScheduler (Quartz/Spring @Scheduled)
27
+
28
+ ReconcileOrchestrator
29
+ ├── SourceProcessorChain (Chain of Responsibility)
30
+ │ ├── BankGwSourceProcessor
31
+ │ ├── WalletSourceProcessor
32
+ │ └── ACSSourceProcessor
33
+
34
+ ReconcileEngine
35
+ ├── MatchingStrategy (1:1, 1:N, N:M)
36
+ ├── DiffCalculator
37
+ └── ReconcileReportBuilder
38
+
39
+ ## SourceProcessor Pattern
40
+
41
+ ```java
42
+ public interface SourceProcessor {
43
+ boolean canHandle(ReconcileContext context);
44
+ List extract(ReconcileContext context);
45
+ }
46
+
47
+ // Chain implementation
48
+ @Service
49
+ @Slf4j
50
+ public class BankGwSourceProcessor implements SourceProcessor {
51
+ @Override
52
+ public boolean canHandle(ReconcileContext context) {
53
+ return ReconcileType.BANK_GW.equals(context.getType());
54
+
55
+ ## Distributed Locking (Redisson)
56
+
57
+ ```java
58
+ // Ngăn duplicate job khi deploy nhiều instance
59
+ @Service
60
+ public class ReconcileOrchestratorImpl {
61
+
62
+ @Autowired
63
+ private RedissonClient redissonClient;
64
+
65
+ public void runReconcile(ReconcileContext ctx) {
66
+ String lockKey = "vetc:reconcile:" + ctx.getType() + ":" + ctx.getDateKey();
67
+ RLock lock = redissonClient.getLock(lockKey);
68
+
69
+ boolean acquired = false;
70
+
71
+ ## Idempotency Pattern
72
+
73
+ ```java
74
+ // Kiểm tra đã process chưa trước khi xử lý
75
+ public void processRecord(ReconcileRecord record) {
76
+ String idempotencyKey = "vetc:recon:" + record.getTransactionRef();
77
+ boolean isNew = redisTemplate.opsForValue()
78
+ .setIfAbsent(idempotencyKey, "1", 24, TimeUnit.HOURS);
79
+
80
+ if (!isNew) {
81
+ log.debug("Already processed: {}", record.getTransactionRef());
82
+ return;
83
+ }
84
+ // Process record...
85
+ }
86
+ ```
87
+
88
+ ## Matching Strategies
89
+
90
+ ```java
91
+ public enum MatchResult {
92
+ MATCHED, // Khớp hoàn toàn
93
+ AMOUNT_MISMATCH,// Ref khớp, amount khác
94
+ NOT_FOUND, // Có trong source, không có trong wallet
95
+ DUPLICATE, // Xuất hiện nhiều lần
96
+ SETTLED_LATE // Transaction đã settle sau cutoff
97
+ }
98
+ ```
99
+
100
+ ## Common Reconcile Issues
101
+
102
+ | Issue | Root Cause | Fix |
103
+ |-------|-----------|-----|
104
+ | Duplicate record | Idempotency key thiếu hoặc sai | Thêm idempotency check |
105
+ | Amount mismatch | Fee/VAT tính khác | Align fee calculation |
106
+ | Missing transaction | Timezone mismatch (UTC vs +07) | Normalize về UTC trước compare |
107
+ | Race condition | Multiple instances chạy cùng lúc | Redisson distributed lock |
108
+ | Memory spike | Load toàn bộ data vào RAM | Page-based processing |
109
+
110
+ ## Coverage Targets
111
+
112
+ ```
113
+ ReconcileEngine: ≥ 85% (mandatory — core matching logic)
114
+ SourceProcessor (mỗi): ≥ 80% (mandatory)
115
+ ReconcileReportBuilder: ≥ 75% (recommended)
116
+
117
+
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: vetc-refactoring
3
+ description: PROACTIVELY activate khi code smell xuất hiện, cần restructure không thay behavior — extract method/class, rename, replace conditional, strangler fig migration. KHÔNG kết hợp refactoring với feature work. Tests phải pass trước và sau.
4
+ ---
5
+
6
+ # VETC Refactoring — Behavior-Preserving Restructure
7
+
8
+ Cải thiện cấu trúc code KHÔNG thay đổi behavior. Tests xanh → refactor → tests vẫn xanh. Inspired by Karpathy + Fowler refactoring catalog.
9
+
10
+ ## When to Activate
11
+
12
+ - Code smell: long method, duplicate code, god class, feature envy, shotgun surgery
13
+ - Pre-change cleanup: "Make change easy, then make easy change" (Kent Beck)
14
+ - Post-ralph deslop pass — cleanup after implementation
15
+ - Strangler fig migration — gradually replace legacy component
16
+ - Rename signals: unclear names, ambiguous abbreviations
17
+ - Replace conditional with polymorphism (many if/else branches)
18
+ - Extract method (< 20-line method rule)
19
+ - Extract class (class > 200 lines or > 7 public methods)
20
+
21
+ ## Do NOT Activate When
22
+
23
+ - **No tests exist** → Write tests FIRST (`vetc-tdd`), refactor AFTER
24
+ - **Mid-feature work** → Do not mix refactor + feature work. Finish feature, then refactor.
25
+ - **Code works + tests pass + readable** → don't refactor for the sake of it
26
+ - Red tests (failing) → Fix tests first, then consider refactor
27
+ - No user request and no code smell → "if it ain't broke, don't fix it"
28
+ - Architecture change needed (not refactor) → use `vetc-ralplan`
29
+
30
+
31
+
32
+ ## Core Pattern: Red-Green-Refactor
33
+
34
+ ```
35
+ RED (failing test, for new feature) — not our domain here
36
+
37
+ GREEN (passing test)
38
+
39
+ REFACTOR (this skill!) ← structure improvement
40
+
41
+ GREEN (still passing)
42
+
43
+ Commit (atomic: "refactor(wallet): extract balance calculation")
44
+ ```
45
+
46
+ ## Refactoring Catalog (VETC-adapted)
47
+
48
+ ### Method-level
49
+
50
+ | Refactoring | When | Example |
51
+ |-------------|------|---------|
52
+ | **Extract Method** | Method > 20 lines or does 2+ things | `processTransfer()` → extract `validateAmount()` + `debitAccount()` + `creditAccount()` |
53
+ | **Inline Method** | Trivial method (1-liner) only called once | Remove `private boolean isValid() { return amount > 0; }` inline |
54
+ | **Extract Variable** | Complex expression used multiple times | `BigDecimal fee = amount.multiply(FEE_RATE);` instead of inlining |
55
+ | **Inline Variable** | Variable is trivial alias | Remove `Long id = wallet.getId(); repo.find(id);` → `repo.find(wallet.getId())` |
56
+ | **Rename** | Unclear name | `process()` → `debitAndNotify()` |
57
+
58
+ ### Class-level
59
+
60
+ | Refactoring | When | Example |
61
+ |-------------|------|---------|
62
+ | **Extract Class** | Class > 200 lines OR > 7 public methods OR multiple responsibilities | Split `WalletService` → `BalanceService` + `TransferService` + `NotificationService` |
63
+ | **Move Method** | Method uses another class more than own | Move `Money.compare(a, b)` from `WalletService` to `Money` entity |
64
+ | **Pull Up Field/Method** | Subclasses share field/method | Move common `@Column(name="created_at")` to `BaseEntity` |
65
+ | **Replace Inheritance with Delegation** | Inheritance not true "is-a" | `class OracleRepo extends BaseRepo` → `class OracleRepo { BaseRepo base; }` |
66
+
67
+ ### Conditional logic
68
+
69
+ | Refactoring | When | Example |
70
+ |-------------|------|---------|
71
+ | **Replace Conditional with Polymorphism** | Many if/else based on type | `if (type == JE_DEBIT) ... else if (type == JE_CREDIT) ...` → `JournalEntryStrategy` with subclasses |
72
+ | **Introduce Null Object** | Null check scattered | `if (wallet == null) return zero` → `WalletEmpty` class returning zero |
73
+ | **Replace Magic Number** | `if (amount > 500000)` | `if (amount > OTP_THRESHOLD)` |
74
+ | **Decompose Conditional** | Complex condition with comment | Extract condition to `isHighRiskTransaction()` method |
75
+
76
+ ### VETC-specific
77
+
78
+ | Refactoring | When | Example |
79
+ |-------------|------|---------|
80
+ | **Encapsulate Oracle sequence** | Multiple places call sequence directly | Create `SequenceGenerator` service with cached next-values |
81
+ | **Extract Feign client** | Inline RestTemplate/HTTP calls | Replace with typed Feign interface + `@FeignClient` |
82
+ | **Parameterize SQL** | String concat in native query | Replace `"WHERE id = " + id` with `"WHERE id = :id"` + setParameter |
83
+ | **Centralize PII masking** | Logger calls with CCCD/phone | Extract `PiiMasker.mask(cccd)` helper, use consistently |
84
+ | **Introduce Cache-Aside** | Repeated expensive queries | Wrap with Redis `@Cacheable` on service method |
85
+
86
+ ### Strangler Fig (gradual legacy replacement)
87
+
88
+ When legacy component (monolithic `WalletServiceLegacy`) needs replacement:
89
+
90
+ ```
91
+ Phase 1: Build new service in parallel (WalletService)
92
+ Phase 2: Route 5% traffic via feature flag
93
+ Phase 3: Monitor errors, increase to 50% if OK
94
+ Phase 4: 100% traffic to new
95
+ Phase 5: Delete legacy
96
+ ```
@@ -0,0 +1,118 @@
1
+ ---
2
+ name: vetc-runbook
3
+ description: PROACTIVELY activate khi debug incident, runtime error, hoặc production issue. Investigation flow, common error patterns cho VETC stack, structured report output.
4
+ ---
5
+
6
+ # VETC Runbook — Incident & Debug Guide
7
+
8
+ Runbook cho common issues trong VETC E-Wallet system.
9
+
10
+ ## When to Activate
11
+
12
+ - Runtime error trong production hoặc staging
13
+ - Incident cần investigation
14
+ - Debug issue không rõ root cause
15
+ - Performance degradation
16
+ - User nói: "debug", "investigate", "runbook", "troubleshoot"
17
+
18
+ ## Do NOT Activate When
19
+
20
+ - Tạo tính năng mới, không phải debug/investigate (dùng SDLC skills)
21
+ - Chỉ cần code review (dùng reviewer agents)
22
+ - Issue chỉ xảy ra 1 lần, không cần structured investigation
23
+
24
+ ## Investigation Flow
25
+
26
+ ```
27
+ 1. Triage → Phân loại severity
28
+ 2. Gather → Thu thập logs, traces, data
29
+ 3. Hypothesize → Đưa ra hypotheses (top 3)
30
+ 4. Test → Verify từng hypothesis
31
+ 5. Fix → Apply minimal fix
32
+ 6. Verify → Confirm fix resolves issue
33
+ 7. Report → Structured post-mortem
34
+ ```
35
+
36
+ ## Common Error Patterns
37
+
38
+ ### Category 1 — Database Issues
39
+
40
+ | Symptom | Likely Cause | Investigation |
41
+ |---------|-------------|---------------|
42
+ | `ORA-00001: unique constraint` | Duplicate insert | Check idempotency key, sequence value |
43
+ | `ORA-02291: integrity constraint` | FK reference missing | Check parent record exists |
44
+ | `ORA-12899: value too large` | Column overflow | Check string length vs column size |
45
+ | Slow query | Missing index / bad plan | `EXPLAIN PLAN FOR <query>` |
46
+ | Deadlock | Lock ordering | Check `@Transactional` scope |
47
+
48
+ ### Category 2 — External Service Issues
49
+
50
+ | Symptom | Likely Cause | Investigation |
51
+ |---------|-------------|---------------|
52
+ | ACS timeout | Network / ACS down | Check Feign timeout config, ACS health |
53
+ | Bank GW 500 | Invalid request format | Compare request with spec, check encoding |
54
+ | eKYC rejection | Invalid image / session expired | Check image quality, session timeout |
55
+ | RabbitMQ message stuck | Consumer error / queue full | Check consumer logs, queue depth |
56
+
57
+ ### Category 3 — Authentication Issues
58
+
59
+ | Symptom | Likely Cause | Investigation |
60
+ |---------|-------------|---------------|
61
+ | 401 Unauthorized | Token expired / invalid | Check JWT expiry, issuer, audience |
62
+ | 403 Forbidden | Role mismatch | Check user role vs required role |
63
+ | OTP verify fail | OTP expired / wrong attempt | Check OTP generation time, attempt count |
64
+
65
+ ### Category 4 — Frontend Issues
66
+
67
+ | Symptom | Likely Cause | Investigation |
68
+ |---------|-------------|---------------|
69
+ | White screen | JS error / route missing | Check browser console, network tab |
70
+ | API 404 | Wrong URL / base URL | Check Axios config, API path |
71
+ | State not updating | Stale closure / wrong selector | Check Redux devtools, useEffect deps |
72
+
73
+ ## Report Format
74
+
75
+ ```markdown
76
+ # Incident Report: [Title]
77
+ **Date**: [date]
78
+ **Severity**: P1 / P2 / P3
79
+ **Status**: INVESTIGATING / FIXED / MONITORING
80
+
81
+ ## Timeline
82
+ - [HH:MM] Symptom detected
83
+ - [HH:MM] Investigation started
84
+ - [HH:MM] Root cause identified
85
+ - [HH:MM] Fix applied
86
+ - [HH:MM] Verified
87
+
88
+ ## Root Cause
89
+ [1-2 câu]
90
+
91
+ ## Fix
92
+ [What was changed, file:line]
93
+
94
+ ## Prevention
95
+ [What to add to prevent recurrence]
96
+
97
+ ## Lessons Learned
98
+ [Key takeaway]
99
+ ```
100
+
101
+ ## Gotchas
102
+
103
+ 1. **Fix symptoms not root cause** → 500 error do ACS timeout, nhưng root cause là network config. Luôn trace đến root.
104
+
105
+ 2. **Logging quá nhiều** → Log flood che mất signal. Tìm theo correlation ID hoặc timestamp cụ thể.
106
+
107
+ 3. **Assume external service OK** → Luôn verify external service health trước khi investigate internal logic.
108
+
109
+ 4. **Skip reproduction** → Luôn reproduce locally trước khi fix. "Fix" mà không reproduce = blind fix.
110
+
111
+ 5. **Not checking recent deployments** → Kiểm tra `git log --oneline -10` xem có deploy nào gần đây gây vấn đề.
112
+
113
+ ## References
114
+
115
+ - Architecture profiles: `../../shared/architecture-profiles.md`
116
+
117
+
118
+
@@ -0,0 +1,118 @@
1
+ ---
2
+ name: vetc-sast
3
+ description: PROACTIVELY activate trước mỗi release/PR merge để chạy static application security testing — Trivy (container/deps), OWASP Dep-Check (CVE), SonarQube (code smells + security), Semgrep (custom rules). Không edit code — chỉ report + triage.
4
+ ---
5
+
6
+ # VETC SAST — Static Application Security Testing
7
+
8
+ Automated scan CVE, dependency vulnerabilities, code-level security issues, container image risks TRƯỚC khi merge/release. Triage findings: critical/high → block, medium/low → track.
9
+
10
+ ## When to Activate
11
+
12
+ - PR merge candidate — final security gate
13
+ - Pre-release (release candidate tag) — full SAST sweep
14
+ - Dependency update (renovate/dependabot PR) — verify no new CVEs
15
+ - Container image build — scan Docker layers
16
+ - After `vetc-security` review — automated SAST complements manual review
17
+ - Quarterly audit — full baseline scan
18
+
19
+ ## Do NOT Activate When
20
+
21
+ - Local dev iteration — SAST too slow for tight loop (use IDE linters)
22
+ - Documentation-only PR — no code/deps changed
23
+ - Hotfix in emergency — note as debt, scan within 24h
24
+ - Private/internal tool with no external exposure — lower priority
25
+
26
+ ## Tools & Coverage Matrix
27
+
28
+ | Tool | Target | Runs in | Fail threshold |
29
+ |------|--------|---------|----------------|
30
+ | **OWASP Dep-Check** | Maven/npm deps | CI (PR) | CVE CVSS ≥ 7.0 |
31
+ | **Trivy** | Docker image, IaC | CI (release) | CRITICAL, HIGH |
32
+ | **SonarQube** | Java/TS source | CI (merge main) | Security Hotspots = 0 new |
33
+ | **Semgrep** | Custom VETC rules | CI (PR) | ERROR severity = 0 |
34
+ | **Secret scan** | Git history | pre-commit + CI | Any match |
35
+ | **npm audit** | Node packages | CI (PR on FE) | HIGH, CRITICAL |
36
+
37
+ ## Workflow
38
+
39
+ ### Step 1 — Identify Scope
40
+
41
+ Read git diff to identify scan targets:
42
+ - `pom.xml` / `package.json` changed → dep scan
43
+ - `Dockerfile` / IaC changed → container/IaC scan
44
+ - `.java` / `.ts` changed → code scan
45
+ - New file added → secret scan (full)
46
+
47
+ ### Step 2 — Run Scans (Parallel)
48
+
49
+ ```bash
50
+ # 1. OWASP Dep-Check (Maven)
51
+ mvn -q dependency-check:check -DfailBuildOnCVSS=7 -Dformat=HTML -DnvdApiKey=$NVD_API_KEY
52
+
53
+ # 2. Trivy (Docker image)
54
+ trivy image --severity CRITICAL,HIGH --exit-code 1 \
55
+ --format json -o trivy-report.json \
56
+ vetc/wallet-service:${VERSION}
57
+
58
+ # 3. Trivy (filesystem - IaC)
59
+ trivy fs --scanners vuln,misconfig,secret --severity CRITICAL,HIGH .
60
+
61
+ # 4. SonarQube scan (post-build)
62
+ mvn -q sonar:sonar \
63
+ -Dsonar.host.url=$SONAR_URL \
64
+ -Dsonar.projectKey=vetc-wallet \
65
+ -Dsonar.login=$SONAR_TOKEN
66
+
67
+ # 5. Semgrep custom rules
68
+ semgrep --config=.semgrep/vetc-rules.yml --error .
69
+
70
+ # 6. Secret scan (gitleaks)
71
+ gitleaks detect --source . --no-git --exit-code 1
72
+
73
+ ### Step 3 — Aggregate & Triage
74
+
75
+ For each finding, classify:
76
+
77
+ | Level | Action |
78
+ |-------|--------|
79
+ | **CRITICAL** (CVSS 9.0-10) | BLOCK merge. Fix/upgrade immediately or isolate usage. |
80
+ | **HIGH** (CVSS 7.0-8.9) | BLOCK merge. Fix in same PR or separate hotfix PR. |
81
+ | **MEDIUM** (CVSS 4.0-6.9) | Track in backlog. Fix within sprint. Do not block merge unless payment/auth. |
82
+ | **LOW** (CVSS 0.1-3.9) | Track in backlog. Fix opportunistically. |
83
+ | **INFO** (hardening recommendation) | Note in tech-debt file. |
84
+
85
+ VETC-specific escalation (force to HIGH regardless of CVSS):
86
+ - Any finding in `auth-service`, `payment-gateway`, `wallet-service` core
87
+ - SQL injection in native query (even if param)
88
+
89
+ ### Step 4 — Create Triage Report
90
+
91
+ Location: `security/sast-reports/{YYYY-MM-DD}-{branch}.md`
92
+
93
+ ```markdown
94
+ # SAST Report - feature/smart-otp - 2026-04-17
95
+
96
+ ## Summary
97
+ | Tool | Total | Critical | High | Medium | Low |
98
+ |------|-------|----------|------|--------|-----|
99
+ | OWASP Dep-Check | 3 | 0 | 1 | 2 | 0 |
100
+ | Trivy Image | 8 | 0 | 0 | 5 | 3 |
101
+ | SonarQube | 15 | 0 | 2 | 8 | 5 |
102
+ | Semgrep | 1 | 0 | 1 | 0 | 0 |
103
+
104
+ ## Critical/High Findings
105
+
106
+ ### 1. [HIGH] CVE-2024-12345 — jackson-databind 2.13.0
107
+ **File**: `pom.xml:45`
108
+ **Description**: Deserialization vulnerability in jackson-databind < 2.15.2
109
+ **Fix**: Upgrade to 2.15.2+
110
+ **Owner**: backend-lead
111
+ **Due**: Before merge
112
+
113
+ ### 2. [HIGH] Semgrep — SQL injection in NativeQueryBuilder
114
+ **File**: `wallet-service/src/main/java/vn/vetc/wallet/repo/TransactionRepo.java:87`
115
+ **Description**: String concatenation in `WHERE account_no = '" + accountNo + "'"`
116
+ **Fix**: Use `setParameter("accountNo", accountNo)`
117
+
118
+
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: vetc-sdlc
3
+ description: PROACTIVELY activate khi user bắt đầu tính năng mới, hỏi "bắt đầu từ đâu", hoặc cần routing đến đúng SDLC path. Entry point cho toàn bộ workflow từ spec đến deploy.
4
+ ---
5
+
6
+ # VETC SDLC — Level 5 Workflow
7
+
8
+ Điều phối toàn bộ quy trình phát triển Level 5 của VETC E-Wallet.
9
+
10
+
11
+
12
+ ## When to Activate
13
+
14
+ - User đề cập tính năng mới, requirement mới
15
+ - User hỏi "bắt đầu từ đâu", "làm thế nào", "flow như thế nào"
16
+ - Bắt đầu sprint hoặc ticket mới
17
+ - User không biết dùng skill/agent nào
18
+
19
+ ## Do NOT Activate When
20
+
21
+ - User chỉ hỏi câu hỏi đơn giản, không liên quan phát triển tính năng
22
+ - Đang chỉ đọc code / explore codebase, không có intent implement
23
+ - Debug one-off issue cụ thể (dùng `vetc-runbook` hoặc `vetc-build-resolver`)
24
+
25
+ ## Pre-Execution Gate
26
+
27
+ **VETC SDLC chặn vague execution requests** và redirect đến planning trước:
28
+
29
+ | Vague (→ ralplan/deep-interview) | Cụ thể (→ execute trực tiếp) |
30
+ |----------------------------------|------------------------------|
31
+ | "thêm chức năng transfer" | "Implement POST /wallet/transfer theo spec task T3" |
32
+ | "fix lỗi" | "Fix NullPointerException WalletService.java:45" |
33
+ | "làm tính năng nạp tiền" | Có file path / task breakdown / issue number |
34
+
35
+ **Bypass gate:** prefix `force:` hoặc `!`
36
+
37
+ ## The VETC Level 5 Workflow
38
+
39
+ ### Path A — Full BA Pipeline (có tài liệu BA)
40
+
41
+ ```
42
+ ┌──────────────────────────────────────────────────────────────────────────┐
43
+ │ VETC SDLC — Level 5 Full BA Pipeline │
44
+ ├────────────┬──────────────────────────┬──────────────────────────────── │
45
+ │ Phase │ Skill │ Output │
46
+ ├────────────┼──────────────────────────┼──────────────────────────────────┤
47
+ │ 0. Scan │ vetc-analyze-codebase │ codebase-spec.md + data-model.md │
48
+ │ 1. PM │ vetc-thinking-pm │ raw-ba-requirements.md (chuẩn) │
49
+ │ 2. BA │ vetc-analyze-ba (1-3) │ 01-ba-analysis + 02-clarify │
50
+ │ 3. Spec │ vetc-analyze-ba (3) │ 03-feature-spec.md (SOURCE) │
51
+ │ 4. Design │ vetc-analyze-ba (4-5) │ 04-technical + 05-api-design │
52
+ │ 5. Plan │ vetc-analyze-ba (6-6b) │ 06-task-breakdown + tasks/ │
53
+ │ 6. Code │ vetc-analyze-ba (7) │ 07-implement-ledger + code │
54
+
55
+ ### Path B — Quick Implementation (đã có spec rõ)
56
+
57
+ ```
58
+ ┌──────────────────────────────────────────────────────────────────┐
59
+ │ VETC SDLC — Quick Path │
60
+ ├──────────┬────────────────────┬──────────────────────────────────┤
61
+ │ Phase │ Skill / Agent │ Output │
62
+ ├──────────┼────────────────────┼──────────────────────────────────┤
63
+ │ 1. Spec │ vetc-spec-driven │ Structured spec + edge cases │
64
+ │ 2. Design│ vetc-api-design │ ERD + API contract + flow │
65
+ │ 3. Plan │ vetc-planner agent │ Task list với file paths │
66
+ │ 4a. BE │ vetc-java-patterns │ Spring Boot implementation │
67
+ │ 4b. FE │ vetc-frontend-pat..│ React/TS implementation │
68
+ │ 5. Test │ vetc-tdd │ JUnit + Integration tests │
69
+ │ 6. Review│ java/ts-reviewer │ Review report + blockers │
70
+
71
+ ## Routing Logic
72
+
73
+ Khi nhận yêu cầu, routing theo context:
74
+
75
+ | Signal | → Skill/Agent |
76
+ |--------|-------------|
77
+ | "mới vào project", "cần bản đồ codebase" | → `vetc-analyze-codebase` |
78
+ | Requirement mơ hồ, cần clarify trước khi plan | → `vetc-deep-interview` |
79
+ | BA gửi file Word/Jira/text, cần chuẩn hóa | → `vetc-thinking-pm` |
80
+ | Có spec, cần plan + Architect+Critic review | → `vetc-ralplan` |
81
+ | Có approved plan, cần implement đến hoàn thành | → `vetc-ralph` |
82
+ | Có `raw-ba-requirements.md`, cần implement 13 bước | → `vetc-analyze-ba` |
83
+ | "tính năng mới" (quick path, không có BA doc) | → `vetc-spec-driven` |
84
+ | Có spec, cần thiết kế DB/API | → `vetc-api-design` |
85
+ | Có design, cần task list | → `vetc-planner` agent |
86
+
87
+ ## Senior Engineer Test (từ Karpathy)
88
+
89
+ Trước khi bắt đầu implementation, hỏi:
90
+
91
+ > "Một senior engineer review code này có hỏi 'TẠI SAO lại làm vậy?' không?"
92
+
93
+ Nếu câu trả lời là "yes" → cần justify trong spec/plan. Nếu không justify được → đừng làm.
94
+
95
+ **Complexity Gate:**
96
+
97
+
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: vetc-security
3
+ description: PROACTIVELY scan OWASP Top 10 trước khi merge PR chứa auth/payment/user data, hoặc trước Pentest/UAT. Không edit code — chỉ report findings với fix recommendations.
4
+ ---
5
+
6
+ # VETC Security Review
7
+
8
+ OWASP Top 10 scan tập trung vào VETC-specific attack vectors.
9
+
10
+ ## When to Activate
11
+
12
+ - Trước khi mở PR chứa authentication, payment, user data
13
+ - Trước Pentest / UAT
14
+ - Code review yêu cầu security check
15
+ - Thêm endpoint mới, external integration mới
16
+
17
+ ## Do NOT Activate When
18
+
19
+ - Chỉ fix UI/layout, không liên quan security → dùng `vetc-frontend-patterns`
20
+ - Code review general (không phải security-focused) → dùng `vetc-review`
21
+ - Đã có security review gần đây, chỉ refactor nhỏ không affect security
22
+ - Task chỉ liên quan đến documentation, không code changes
23
+
24
+ ## OWASP Checklist — VETC Context
25
+
26
+ ### A01: Broken Access Control
27
+
28
+ FAIL: No ownership check — any user can access any account:
29
+ ```java
30
+ // NGUY HIỂM — IDOR
31
+ @GetMapping("/{id}")
32
+ public ResponseEntity<?> getById(@PathVariable Long id) {
33
+ return ResponseEntity.ok(service.findById(id)); // No ownership check!
34
+ }
35
+ ```
36
+
37
+ PASS: Verify user owns the resource:
38
+ ```java
39
+ // AN TOÀN — Ownership verified
40
+ @GetMapping("/{id}")
41
+
42
+ ### A02: Cryptographic Failures
43
+
44
+ FAIL: Hardcoded secret in source code:
45
+ ```java
46
+ // NGUY HIỂM — Secret lộ trong git
47
+ private static final String API_KEY = "sk-proj-abc123xyz";
48
+ String token = JwtUtils.encode(payload, "my-secret-key");
49
+ ```
50
+
51
+ PASS: Secrets from environment, secure algorithm:
52
+ ```java
53
+ // AN TOÀN — Environment variable + RS256
54
+ @Value("${jwt.private-key-path}") private Resource keyResource;
55
+ PrivateKey key = KeyFactory.getInstance("RSA")
56
+ .generatePrivate(new PKCS8EncodedKeySpec(keyResource.getInputStream().readAllBytes()));
57
+
58
+ ### A03: Injection (Critical for Oracle)
59
+
60
+ FAIL: SQL injection via string concatenation:
61
+ ```java
62
+ // NGUY HIỂM — SQL Injection
63
+ "SELECT * FROM T WHERE NAME = '" + userInput + "'"
64
+ ```
65
+
66
+ PASS: Parameterized query prevents injection:
67
+ ```java
68
+ // AN TOÀN — Parameterized
69
+ @Query("... WHERE NAME = :name")
70
+ void find(@Param("name") String name);
71
+ ```
72
+ - [ ] Mọi native query đều dùng `:param` placeholder?
73
+ - [ ] JdbcTemplate dùng `?` không dùng concat?
74
+ - [ ] Log injection: user input không log trực tiếp?
75
+
76
+ ### A04: Insecure Design
77
+
78
+ FAIL: No idempotency — duplicate transfers possible:
79
+ ```java
80
+ // NGUY HIỂM — Double-spend nếu network retry
81
+ public TransferResponse transfer(TransferRequest req) {
82
+ wallet.setBalance(wallet.getBalance().subtract(req.getAmount()));
83
+ walletRepo.save(wallet);
84
+ // No idempotency check — retry = double charge!
85
+ }
86
+ ```
87
+
88
+ PASS: Idempotency key prevents duplicates:
89
+ ```java
90
+ // AN TOÀN — Idempotency gate
91
+
92
+ ### A05: Security Misconfiguration
93
+
94
+ FAIL: Wildcard CORS + exposed actuator on production:
95
+ ```java
96
+ // NGUY HIỂM — CORS mở rộng, actuator lộ cấu hình
97
+ @CrossOrigin("*")
98
+ @RestController
99
+ public class WalletController { ... }
100
+
101
+ // application-prod.yml
102
+ management:
103
+ endpoints:
104
+ web:
105
+ exposure:
106
+ include: "*" // /actuator/env, /heapdump public!
107
+
108
+ ### A07: Auth Failures
109
+
110
+ FAIL: OTP không có expiry + brute-force possible:
111
+ ```java
112
+ // NGUY HIỂM — OTP không hết hạn, không giới hạn retry
113
+ public boolean verifyOtp(String phone, String otp) {
114
+ String stored = redis.get("otp:" + phone);
115
+ return otp.equals(stored); // No expiry check, no attempt limit!
116
+ }
117
+ ```