@code-sentinel-cli/code-sentinel-cli 3.0.10 → 3.0.12

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 (103) hide show
  1. package/dist/bin.js +10044 -6056
  2. package/dist/builtin-rules/ai/angular/api-service-contract-risk.prompt.md +2 -2
  3. package/dist/builtin-rules/ai/angular/api-service-contract-risk.rule.yaml +3 -3
  4. package/dist/builtin-rules/ai/angular/component-state-flow.prompt.md +2 -2
  5. package/dist/builtin-rules/ai/angular/component-state-flow.rule.yaml +3 -3
  6. package/dist/builtin-rules/ai/angular/cross-feature-api-drift.prompt.md +2 -3
  7. package/dist/builtin-rules/ai/angular/cross-feature-api-drift.rule.yaml +3 -6
  8. package/dist/builtin-rules/ai/angular/cross-feature-route-permission-drift.prompt.md +2 -3
  9. package/dist/builtin-rules/ai/angular/cross-feature-route-permission-drift.rule.yaml +4 -8
  10. package/dist/builtin-rules/ai/angular/reactive-form-flow.prompt.md +2 -2
  11. package/dist/builtin-rules/ai/angular/reactive-form-flow.rule.yaml +3 -3
  12. package/dist/builtin-rules/ai/angular/route-permission-flow.prompt.md +2 -2
  13. package/dist/builtin-rules/ai/angular/route-permission-flow.rule.yaml +3 -3
  14. package/dist/builtin-rules/ai/angular/rxjs-flow-risk.prompt.md +2 -2
  15. package/dist/builtin-rules/ai/angular/rxjs-flow-risk.rule.yaml +3 -3
  16. package/dist/builtin-rules/ai/angular/template-contract-risk.prompt.md +2 -2
  17. package/dist/builtin-rules/ai/angular/template-contract-risk.rule.yaml +3 -3
  18. package/dist/builtin-rules/ai/flutter/dynamic-content-risk.prompt.md +2 -2
  19. package/dist/builtin-rules/ai/flutter/dynamic-content-risk.rule.yaml +1 -2
  20. package/dist/builtin-rules/ai/flutter/feature-state-flow-risk.prompt.md +2 -2
  21. package/dist/builtin-rules/ai/flutter/feature-state-flow-risk.rule.yaml +1 -2
  22. package/dist/builtin-rules/ai/flutter/native-platform-consistency-risk.prompt.md +2 -3
  23. package/dist/builtin-rules/ai/flutter/native-platform-consistency-risk.rule.yaml +1 -2
  24. package/dist/builtin-rules/ai/flutter/network-auth-flow-risk.prompt.md +2 -2
  25. package/dist/builtin-rules/ai/flutter/network-auth-flow-risk.rule.yaml +1 -2
  26. package/dist/builtin-rules/ai/flutter/ui-responsive-accessibility-risk.prompt.md +2 -2
  27. package/dist/builtin-rules/ai/flutter/ui-responsive-accessibility-risk.rule.yaml +0 -2
  28. package/dist/builtin-rules/ai/general/code-clarity.prompt.md +21 -4
  29. package/dist/builtin-rules/ai/general/code-clarity.rule.yaml +8 -3
  30. package/dist/builtin-rules/ai/spring-boot/business-invariant-risk.prompt.md +5 -5
  31. package/dist/builtin-rules/ai/spring-boot/business-invariant-risk.rule.yaml +1 -2
  32. package/dist/builtin-rules/ai/spring-boot/cache-consistency-risk.prompt.md +2 -2
  33. package/dist/builtin-rules/ai/spring-boot/cache-consistency-risk.rule.yaml +1 -2
  34. package/dist/builtin-rules/ai/spring-boot/cross-feature-error-handling-drift.prompt.md +2 -3
  35. package/dist/builtin-rules/ai/spring-boot/cross-feature-error-handling-drift.rule.yaml +4 -10
  36. package/dist/builtin-rules/ai/spring-boot/cross-feature-transaction-boundary-drift.prompt.md +2 -3
  37. package/dist/builtin-rules/ai/spring-boot/cross-feature-transaction-boundary-drift.rule.yaml +2 -9
  38. package/dist/builtin-rules/ai/spring-boot/error-handling-completeness.prompt.md +6 -6
  39. package/dist/builtin-rules/ai/spring-boot/error-handling-completeness.rule.yaml +1 -2
  40. package/dist/builtin-rules/ai/spring-boot/event-publishing-risk.prompt.md +2 -2
  41. package/dist/builtin-rules/ai/spring-boot/event-publishing-risk.rule.yaml +1 -2
  42. package/dist/builtin-rules/ai/spring-boot/import-template-contract-risk.prompt.md +74 -0
  43. package/dist/builtin-rules/ai/spring-boot/import-template-contract-risk.rule.yaml +24 -0
  44. package/dist/builtin-rules/ai/spring-boot/io-boundary-risk.prompt.md +2 -2
  45. package/dist/builtin-rules/ai/spring-boot/io-boundary-risk.rule.yaml +1 -2
  46. package/dist/builtin-rules/ai/spring-boot/native-dml-consistency-risk.prompt.md +75 -0
  47. package/dist/builtin-rules/ai/spring-boot/native-dml-consistency-risk.rule.yaml +24 -0
  48. package/dist/builtin-rules/ai/spring-boot/native-query-performance-risk.prompt.md +73 -0
  49. package/dist/builtin-rules/ai/spring-boot/native-query-performance-risk.rule.yaml +24 -0
  50. package/dist/builtin-rules/ai/spring-boot/ownership-scope-risk.prompt.md +5 -5
  51. package/dist/builtin-rules/ai/spring-boot/ownership-scope-risk.rule.yaml +1 -2
  52. package/dist/builtin-rules/ai/spring-boot/pagination-query-consistency-risk.prompt.md +75 -0
  53. package/dist/builtin-rules/ai/spring-boot/pagination-query-consistency-risk.rule.yaml +25 -0
  54. package/dist/builtin-rules/ai/spring-boot/pagination-risk.prompt.md +2 -2
  55. package/dist/builtin-rules/ai/spring-boot/pagination-risk.rule.yaml +1 -2
  56. package/dist/builtin-rules/ai/spring-boot/partial-update-mapper-risk.prompt.md +73 -0
  57. package/dist/builtin-rules/ai/spring-boot/partial-update-mapper-risk.rule.yaml +24 -0
  58. package/dist/builtin-rules/ai/spring-boot/query-contract-risk.prompt.md +80 -0
  59. package/dist/builtin-rules/ai/spring-boot/query-contract-risk.rule.yaml +25 -0
  60. package/dist/builtin-rules/ai/spring-boot/query-date-boundary-risk.prompt.md +74 -0
  61. package/dist/builtin-rules/ai/spring-boot/query-date-boundary-risk.rule.yaml +24 -0
  62. package/dist/builtin-rules/ai/spring-boot/security-authorization-risk.prompt.md +2 -2
  63. package/dist/builtin-rules/ai/spring-boot/security-authorization-risk.rule.yaml +3 -3
  64. package/dist/builtin-rules/ai/spring-boot/security-mass-assignment-risk.prompt.md +2 -2
  65. package/dist/builtin-rules/ai/spring-boot/security-mass-assignment-risk.rule.yaml +3 -3
  66. package/dist/builtin-rules/ai/spring-boot/security-redirect-risk.prompt.md +2 -2
  67. package/dist/builtin-rules/ai/spring-boot/security-redirect-risk.rule.yaml +1 -2
  68. package/dist/builtin-rules/ai/spring-boot/security-sensitive-data-risk.prompt.md +9 -4
  69. package/dist/builtin-rules/ai/spring-boot/security-sensitive-data-risk.rule.yaml +6 -6
  70. package/dist/builtin-rules/ai/spring-boot/soft-delete-publication-consistency-risk.prompt.md +74 -0
  71. package/dist/builtin-rules/ai/spring-boot/soft-delete-publication-consistency-risk.rule.yaml +24 -0
  72. package/dist/builtin-rules/ai/spring-boot/transaction-loop-risk.prompt.md +2 -2
  73. package/dist/builtin-rules/ai/spring-boot/transaction-loop-risk.rule.yaml +1 -2
  74. package/dist/builtin-rules/ai/spring-boot/versioned-entity-concurrency-risk.prompt.md +73 -0
  75. package/dist/builtin-rules/ai/spring-boot/versioned-entity-concurrency-risk.rule.yaml +24 -0
  76. package/dist/builtin-rules/static/angular/button-accessible-name.rule.js +143 -0
  77. package/dist/builtin-rules/static/angular/component-prefix.rule.js +6 -2
  78. package/dist/builtin-rules/static/angular/img-alt-required.rule.js +3 -2
  79. package/dist/builtin-rules/static/angular/inject-pattern.rule.js +3 -2
  80. package/dist/builtin-rules/static/angular/lifecycle-method-required.rule.js +3 -2
  81. package/dist/builtin-rules/static/angular/no-leaky-subscription.rule.js +14 -5
  82. package/dist/builtin-rules/static/angular/onpush-required.rule.js +3 -2
  83. package/dist/builtin-rules/static/angular/template-dom-xss.rule.js +3 -2
  84. package/dist/builtin-rules/static/angular/trackby-required.rule.js +3 -2
  85. package/dist/builtin-rules/static/flutter/no-undisposed-resource.rule.js +143 -0
  86. package/dist/builtin-rules/static/general/file-too-long.rule.js +5 -4
  87. package/dist/builtin-rules/static/general/function-too-long.rule.js +46 -27
  88. package/dist/builtin-rules/static/general/no-code-injection.rule.js +8 -1
  89. package/dist/builtin-rules/static/general/no-console-log.rule.js +3 -2
  90. package/dist/builtin-rules/static/general/no-empty-catch.rule.yaml +14 -8
  91. package/dist/builtin-rules/static/general/no-hardcoded-vietnamese.rule.js +58 -0
  92. package/dist/builtin-rules/static/general/no-magic-number.rule.js +151 -8
  93. package/dist/builtin-rules/static/general/no-todo-comment.rule.js +88 -0
  94. package/dist/builtin-rules/static/general/no-unused-export.rule.js +53 -6
  95. package/dist/builtin-rules/static/spring-boot/no-command-injection.rule.js +8 -1
  96. package/dist/builtin-rules/static/spring-boot/no-spel-injection.rule.js +8 -1
  97. package/dist/builtin-rules/static/spring-boot/no-sql-string-concat.rule.js +6 -1
  98. package/dist/builtin-rules/static/spring-boot/no-unzoned-datetime.rule.js +96 -0
  99. package/dist/builtin-rules/static/spring-boot/repository-naming.rule.yaml +4 -2
  100. package/dist/index.d.ts +348 -382
  101. package/dist/index.js +10045 -6057
  102. package/package.json +1 -1
  103. package/dist/builtin-rules/static/general/no-todo-comment.rule.yaml +0 -30
@@ -8,7 +8,6 @@ Bạn là senior Spring Boot reviewer. Đánh giá **một module Spring Boot**
8
8
  3. **`line` BẮT BUỘC là số nguyên dương** (≥ 1), trỏ vào một dòng cụ thể trong file đã chọn nơi pattern lộ rõ nhất (vd. dòng khai báo method mutation thiếu `@Transactional`, dòng `@Transactional(readOnly = true)` lệch chuẩn, dòng controller gọi thẳng repository.save). Nếu không chắc dòng nào → dùng `line: 1`. KHÔNG để trống, KHÔNG dùng `null`, KHÔNG dùng `0`.
9
9
  4. **`file` phải là posix path** xuất hiện trong `Module summary` bên dưới — KHÔNG fabricate path mới.
10
10
  5. **Transaction programmatic cũng là transaction hợp lệ.** `TransactionTemplate.execute(...)`, `executeWithoutResult(...)` và `TransactionOperations.execute(...)` bao phủ method/callback được ghi trong boundary facts; KHÔNG được coi write path đó là thiếu transaction chỉ vì không có annotation.
11
- 6. **Confidence `<50` → KHÔNG emit.** Ngưỡng noise thấp (`numMaxFindings: 5`).
12
11
 
13
12
  ## Chỉ flag khi có pattern lặp lại ≥ 2 feature (cùng resource)
14
13
 
@@ -61,8 +60,8 @@ Trả về **JSON HỢP LỆ DUY NHẤT** (không markdown fence, không text kh
61
60
  "file": "<posix path trong members[]>",
62
61
  "line": <số nguyên dương, 1-based>,
63
62
  "endLine": <số nguyên dương | null>,
64
- "message": "<≤200 ký tự, tiếng Việt, mô tả pattern drift + tên ≥ 2 feature liên quan>",
65
- "suggestion": "<gợi ý refactor (vd. đặt @Transactional ở tầng service thống nhất, chuẩn hóa readOnly cho read path, gộp chuỗi mutation vào một transaction) | null>",
63
+ "message": "<≤200 ký tự, tiếng Việt có dấu, mô tả sai lệch mẫu hình + tên ≥ 2 tính năng liên quan>",
64
+ "suggestion": "<gợi ý tái cấu trúc bằng tiếng Việt có dấu (ví dụ: đặt @Transactional ở tầng service thống nhất, chuẩn hóa readOnly cho luồng đọc, gộp chuỗi mutation vào một transaction) | null>",
66
65
  "confidence": <số nguyên 0-100>
67
66
  }
68
67
  ]
@@ -2,13 +2,10 @@ id: spring-boot/cross-feature-transaction-boundary-drift
2
2
  # v1 (Phase 15.5.3): fourth rule in the per-module family (ADR-0016), second
3
3
  # Spring Boot per-module rule. Mirrors the validated cross-feature-api-drift /
4
4
  # cross-feature-route-permission-drift / cross-feature-error-handling-drift
5
- # shape byte-for-byte (same contextScope, numMaxFindings, sandwich prompt,
6
- # one-finding-per-pattern + line >= 1 + file in members[] requirements).
5
+ # shape: one-finding-per-pattern, line >= 1, and file-in-members requirements.
7
6
  # Detects INCONSISTENT transaction boundaries (@Transactional placement /
8
7
  # readOnly / propagation / rollbackFor) across >= 2 services/controllers
9
- # (features) of one module mutating the same resource. POC gate
10
- # (>= 80% precision on a small Viettel Spring module) still pending — keep
11
- # numMaxFindings small until it passes per ADR-0016 §"Implementation phase".
8
+ # (features) of one module mutating the same resource.
12
9
  # Unlike rule #3 (error-handling), transaction boundaries live on
13
10
  # service-layer methods that DO share import/domain-token edges with the
14
11
  # controllers, so the cluster assembler already sees them — no global-advice
@@ -65,9 +62,5 @@ scope: spring-boot
65
62
  baseConfidence: 55
66
63
  prompt: ./cross-feature-transaction-boundary-drift.prompt.md
67
64
  contextScope: per-module
68
- maxTokens: 1800
69
65
  aiConfig:
70
66
  tier: regular
71
- # Cap findings để v1 ngưỡng noise thấp; nâng lên sau khi POC gate đạt
72
- # ≥ 80% precision theo ADR-0016 §"Implementation phase".
73
- numMaxFindings: 5
@@ -12,7 +12,7 @@ Bạn là **senior Spring Boot reviewer**. Đánh giá **error handling flow** c
12
12
  6. **High-signal only** — rule này KHÔNG phải catch-all cho mọi uncaught service exception. Chỉ emit các pattern trong mục "Tiêu chí flag" bên dưới.
13
13
  7. **Không overlap với security/backend-flow** — nếu symptom chính là thiếu authorization, IDOR, unsafe outbound/file flow, transaction multi-write, hoặc invariant nghiệp vụ, để rule tương ứng xử lý. Error-handling chỉ flag cách lỗi bị catch/leak/swallow/map sai.
14
14
  8. **Không duplicate raw-error security leak trừ khi có error-handling bug riêng** — `e.getMessage()` / `e.toString()` chỉ là finding rule này khi catch cũng map sai lỗi nghiệp vụ/user-correctable, swallow failure, hoặc làm client hiểu sai kết quả.
15
- 9. **Benchmark negative controls** — KHÔNG report `SafeOperationsController`, `SafeOperationsService`, DTO safe flow, hoặc `ApiExceptionAdvice` support-only file nếu không có evidence trực tiếp trong PRIMARY. `ApiExceptionAdvice` chỉ là evidence xử lý lỗi khi annotation/assignable target áp dụng cho PRIMARY.
15
+ 9. **File chỉ đóng vai chứng cứ** — KHÔNG report một `@ControllerAdvice` / global exception handler, DTO, hay luồng mà cluster cho thấy là đường an toàn, nếu không có evidence trực tiếp trong PRIMARY. Một global handler chỉ là evidence xử lý lỗi khi annotation/assignable target của nó áp dụng cho PRIMARY.
16
16
  10. **Scan đủ cluster trước khi emit** — đọc PRIMARY, service support, repository support, và advice/handler support. Nếu service/advice body cần thiết không có trong cluster thì skip thay vì đoán.
17
17
  11. **Global `@ControllerAdvice` / `@RestControllerAdvice` được TIÊM vào MỌI cluster** (kể cả khi nó ở package khác như `exception/`, `web/rest/errors/`). Nếu support files có một advice class với `@ExceptionHandler` cho một exception type (vd. `NotFoundException` → 404, `Exception` → 500), thì exception đó ĐÃ được handle app-wide cho PRIMARY (trừ khi advice khai báo `assignableTypes`/`basePackages` loại trừ PRIMARY). KHÔNG flag "missing handler" cho exception mà advice trong cluster đã cover.
18
18
  12. **Confidence `<50` → KHÔNG emit**.
@@ -42,8 +42,8 @@ Nếu cùng một catch block vừa `catch (Exception)` vừa trả `e.getMessag
42
42
  ## KHÔNG flag
43
43
 
44
44
  - Controller `throws Exception` được handle ở `@ControllerAdvice` HIỆN diện trong cluster (kể cả file `*ExceptionHandler.java` / `*Advice.java`).
45
- - `ApiExceptionAdvice` neu no chi apply cho controller khac (`assignableTypes`, package/path mismatch) va khong phai handler cua PRIMARY; dung no de skip false-positive cho safe flow, khong report chinh advice file.
46
- - `SafeOperationsController`, `SafeOperationsService`, DTO safe flow, hoac negative-control support files tru khi PRIMARY co catch/leak/swallow/missing-handler evidence truc tiep.
45
+ - Mot `@ControllerAdvice` neu no chi apply cho controller khac (`assignableTypes`, package/path mismatch) va khong phai handler cua PRIMARY; dung no de skip false-positive cho safe flow, khong report chinh file advice do.
46
+ - File support-only (global exception handler, DTO, luong an toan) tru khi PRIMARY co catch/leak/swallow/missing-handler evidence truc tiep.
47
47
  - Service throw nhưng controller method gọi nó được wrap trong helper với try/catch xử lý đúng.
48
48
  - Test files, generated files, DTO/Entity thuần.
49
49
  - Intentional crash / demo / test endpoints (xem CRITICAL RULE 4).
@@ -81,8 +81,8 @@ Trả về **JSON HỢP LỆ DUY NHẤT** (không markdown fence, không text kh
81
81
  {
82
82
  "line": <số nguyên 1-based, ÁNH XẠ VỀ FILE PRIMARY>,
83
83
  "endLine": <số nguyên | null>,
84
- "message": "<≤200 ký tự, tiếng Việt, nêu rõ FILE + behavior + tác động>",
85
- "suggestion": "<gợi ý fix | null>",
84
+ "message": "<≤2000 ký tự, tiếng Việt có dấu, nêu rõ FILE + hành vi + tác động>",
85
+ "suggestion": "<gợi ý sửa lỗi bằng tiếng Việt có dấu | null>",
86
86
  "confidence": <số nguyên 0-100>
87
87
  }
88
88
  ]
@@ -101,7 +101,7 @@ Trả về **JSON HỢP LỆ DUY NHẤT** (không markdown fence, không text kh
101
101
  - **High-signal only** — không flag normal read/not-found flow hoặc Optional `.get()` chỉ vì thiếu handler.
102
102
  - **Scan đủ cluster** — trước khi emit missing-handler, xác nhận service method được PRIMARY gọi throw explicit domain/runtime exception và không có applicable `@ExceptionHandler`/`@ControllerAdvice`/`@RestControllerAdvice` trong support files. Global advice giờ được TIÊM vào mọi cluster → nếu thấy advice cover exception đó (kể cả ở package khác), KHÔNG flag missing-handler.
103
103
  - Không hard-code theo tên controller/method; quyết định dựa trên flow lỗi thực tế trong cluster và ranh giới rule ở trên.
104
- - Không report `SafeOperationsController`, `SafeOperationsService`, DTO safe flow, hoac `ApiExceptionAdvice` support-only file neu khong co direct evidence trong PRIMARY.
104
+ - Không report file support-only (global exception handler, DTO, luong an toan) neu khong co direct evidence trong PRIMARY.
105
105
  - Raw `e.getMessage()`/`e.toString()` chỉ vào rule này khi có map sai lỗi nghiệp vụ/user-correctable, swallow failure, hoặc wrong success semantics; nếu chỉ là security leak, để security rule.
106
106
  - Nếu một catch block vừa generic catch vừa trả raw exception string, gộp thành 1 finding.
107
107
  - **Mỗi finding distinct** — không duplicate message cho nhiều dòng.
@@ -33,7 +33,7 @@ id: spring-boot/error-handling-completeness
33
33
  # CRITICAL RULE: don't flag missing-handler for an exception a
34
34
  # cluster-visible advice already covers. Version bump invalidates the
35
35
  # stale findings cached against the pre-injection (smaller) clusters.
36
- version: 10
36
+ version: 11
37
37
  kind: ai
38
38
  title: "Error handling có đầy đủ và đúng pattern không?"
39
39
  description: |
@@ -73,7 +73,6 @@ scope: spring-boot
73
73
  baseConfidence: 65
74
74
  prompt: ./error-handling-completeness.prompt.md
75
75
  contextScope: per-cluster
76
- maxTokens: 1400
77
76
  aiConfig:
78
77
  tier: regular
79
78
  prRouting:
@@ -60,8 +60,8 @@ Tra ve **JSON HOP LE DUY NHAT** (khong markdown fence, khong text khac) theo sch
60
60
  {
61
61
  "line": <so nguyen duong, 1-based, trong PRIMARY>,
62
62
  "endLine": <so nguyen duong | null>,
63
- "message": "<<=200 ky tu, tieng Viet, neu event/outbox consistency gap>",
64
- "suggestion": "<goi y fix | null>",
63
+ "message": "<≤200 ký tự, tiếng Việt có dấu, nêu lỗ hổng nhất quán event/outbox>",
64
+ "suggestion": "<gợi ý sửa lỗi bằng tiếng Việt có dấu | null>",
65
65
  "confidence": <so nguyen 0-100>
66
66
  }
67
67
  ]
@@ -1,5 +1,5 @@
1
1
  id: spring-boot/event-publishing-risk
2
- version: 1
2
+ version: 2
3
3
  kind: ai
4
4
  title: "Event Publishing Risk"
5
5
  description: |
@@ -14,7 +14,6 @@ scope: spring-boot
14
14
  baseConfidence: 60
15
15
  prompt: ./event-publishing-risk.prompt.md
16
16
  contextScope: per-cluster
17
- maxTokens: 1800
18
17
  aiConfig:
19
18
  tier: regular
20
19
  prRouting:
@@ -0,0 +1,74 @@
1
+ Bạn là senior Spring Boot reviewer. Chỉ đánh giá **contract xuyên suốt import parser → validator → DTO → mapper → persistence**.
2
+
3
+ ## CRITICAL RULES
4
+
5
+ - CHỈ report mismatch có bằng chứng từ ít nhất hai stage trong cluster; không đoán nội dung file Excel/template binary không được cung cấp.
6
+ - `line` BẮT BUỘC trỏ về PRIMARY controller/import endpoint gọi pipeline.
7
+ - Không report generic missing validation, arbitrary remote URL/SSRF, transaction length, memory limit hoặc MIME hardening ở rule này.
8
+ - Không report style/refactor hay field optional hợp lệ.
9
+ - Một root cause lặp trên nhiều field/row phải gộp thành một finding, liệt kê field đại diện.
10
+ - Confidence `<50` thì KHÔNG emit.
11
+
12
+ ## CHỈ REPORT KHI có import-contract bug cụ thể
13
+
14
+ - Parser đọc column/index/header khác validator hoặc constants/template contract nhìn thấy; start row/header row lệch làm header bị parse hoặc data row bị bỏ.
15
+ - Validator chấp nhận format/date/enum/value mà mapper parser không parse được, hoặc parser fallback sang một valid business value khác khi input invalid/blank.
16
+ - DTO có required field và persistence tạo entity/child dựa trên field đó nhưng parser không map, khiến null/default sai được persist.
17
+ - Parser bỏ blank row nhưng không giữ physical row number, trong khi error workbook ghép kết quả theo list index và có thể gắn lỗi sai row.
18
+ - Numeric/formula/date cell conversion làm mất precision, đổi identifier, hoặc đọc formula source thay vì evaluated/formatted value với evidence downstream type cần giá trị khác.
19
+ - Import path bypasses validation/defaults used by normal save and persists null/deleted/identity/workflow state trái contract hiện rõ.
20
+
21
+ ## KHÔNG flag
22
+
23
+ - Chỉ thấy một parser/mapper riêng lẻ mà không có stage contract để so sánh.
24
+ - Header text/template thực tế không nằm trong context và code không có constant/schema tương ứng.
25
+ - File URL/HTTP/SSRF, zip bomb, workbook size, stream closing hoặc transaction/MinIO orphan.
26
+ - Pure mapper partial-update API flow; để `partial-update-mapper-risk`.
27
+ - Pure duplicate race; để `versioned-entity-concurrency-risk`.
28
+
29
+ ## Primary file
30
+
31
+ File: `{{file}}`
32
+ Language: `{{language}}`
33
+
34
+ ```{{language}}
35
+ {{code}}
36
+ ```
37
+
38
+ ## Support files cùng cluster
39
+
40
+ ```
41
+ {{cluster_files}}
42
+ ```
43
+
44
+ {{cluster_summary}}
45
+
46
+ ## Output yêu cầu
47
+
48
+ Trả về JSON hợp lệ duy nhất:
49
+
50
+ ```
51
+ {
52
+ "violations": [
53
+ {
54
+ "line": <số nguyên dương, 1-based, trong PRIMARY>,
55
+ "endLine": <số nguyên dương | null>,
56
+ "message": "<≤200 ký tự, tiếng Việt có dấu, nêu hai stage không khớp và dữ liệu bị mất/sai>",
57
+ "suggestion": "<gợi ý đồng bộ contract bằng tiếng Việt có dấu | null>",
58
+ "confidence": <số nguyên 0-100>
59
+ }
60
+ ]
61
+ }
62
+ ```
63
+
64
+ Không có lỗi rõ ràng: `{"violations": []}`.
65
+
66
+ ## REPEAT CRITICAL RULES
67
+
68
+ - Cần evidence từ ít nhất hai stage; không suy đoán template binary.
69
+ - `line` phải thuộc PRIMARY controller/import endpoint.
70
+ - Gộp cùng root cause; không tách mỗi field/row.
71
+ - Không duplicate SSRF, resource, transaction, mapper PATCH hoặc concurrency rules.
72
+ - Confidence `<50` thì KHÔNG emit.
73
+
74
+ Không giải thích. JSON thuần.
@@ -0,0 +1,24 @@
1
+ id: spring-boot/import-template-contract-risk
2
+ version: 1
3
+ kind: ai
4
+ title: "Spring import/parser/validator/mapper contract có lệch nhau không?"
5
+ description: |
6
+ Per-cluster AI rule for concrete import-pipeline contract drift across parser,
7
+ validator, DTO, mapper, and persistence code: mismatched columns or row
8
+ indexes, incompatible date/enum formats, fields validated but not parsed (or
9
+ persisted without parsing), and silent fallback that corrupts domain data.
10
+ severity: warning
11
+ category: backend-import-correctness
12
+ languages: [java]
13
+ scope: spring-boot
14
+ baseConfidence: 58
15
+ prompt: ./import-template-contract-risk.prompt.md
16
+ contextScope: per-cluster
17
+ aiConfig:
18
+ tier: regular
19
+ prRouting:
20
+ group: spring-boundary-reliability-group
21
+ targetLayers: [controller, service, parser, validator, mapper, dto, entity]
22
+ triggers: ["import", "Excel", "Workbook", "Row", "Cell", "parseDate", "validateHeader", "ImportDTO", "AfterMapping"]
23
+ riskWeight: 4
24
+ requiresContext: [diff, primaryFile, relatedController, relatedService, relatedParser, relatedValidator, relatedMapper, relatedDto]
@@ -58,8 +58,8 @@ Tra ve **JSON HOP LE DUY NHAT** (khong markdown fence, khong text khac) theo sch
58
58
  {
59
59
  "line": <so nguyen duong, 1-based, trong PRIMARY>,
60
60
  "endLine": <so nguyen duong | null>,
61
- "message": "<<=200 ky tu, tieng Viet, neu source -> sink + missing guard>",
62
- "suggestion": "<goi y fix | null>",
61
+ "message": "<≤200 ký tự, tiếng Việt có dấu, nêu luồng source → sink và guard còn thiếu>",
62
+ "suggestion": "<gợi ý sửa lỗi bằng tiếng Việt có dấu | null>",
63
63
  "confidence": <so nguyen 0-100>
64
64
  }
65
65
  ]
@@ -1,5 +1,5 @@
1
1
  id: spring-boot/io-boundary-risk
2
- version: 1
2
+ version: 2
3
3
  kind: ai
4
4
  title: "Spring Boot filesystem/HTTP/queue boundary co rui ro khong?"
5
5
  description: |
@@ -14,7 +14,6 @@ scope: spring-boot
14
14
  baseConfidence: 60
15
15
  prompt: ./io-boundary-risk.prompt.md
16
16
  contextScope: per-cluster
17
- maxTokens: 1800
18
17
  aiConfig:
19
18
  tier: regular
20
19
  prRouting:
@@ -0,0 +1,75 @@
1
+ Bạn là senior Spring Boot reviewer. Chỉ đánh giá **native/bulk UPDATE hoặc DELETE và persistence-context contract**.
2
+
3
+ ## CRITICAL RULES
4
+
5
+ - CHỈ report khi PRIMARY hoặc support files cho thấy câu DML cụ thể và flow thực sự gọi nó.
6
+ - `line` BẮT BUỘC trỏ vào PRIMARY file. Nếu lỗi nằm trong support repository, dùng dòng PRIMARY gọi method đó; nếu PRIMARY chính là repository, dùng dòng khai báo method/query.
7
+ - Không report SQL injection/string concatenation; `spring-boot/no-sql-string-concat` sở hữu lỗi đó.
8
+ - Không report generic `@Transactional` placement/style hoặc pure multi-write atomicity; để transaction rules.
9
+ - Không duplicate lost-update/check-then-write; để `versioned-entity-concurrency-risk` trừ khi lỗi riêng là bulk DML bỏ qua version contract.
10
+ - Không duplicate missing tenant/owner hoặc deleted/public eligibility predicates; để `ownership-scope-risk` và `soft-delete-publication-consistency-risk`.
11
+ - Confidence `<50` thì KHÔNG emit.
12
+
13
+ ## CHỈ REPORT KHI có native-DML bug cụ thể
14
+
15
+ - Spring Data `@Query` chứa `UPDATE`/`DELETE` được gọi nhưng thiếu `@Modifying`, khiến method không có execution contract cho DML.
16
+ - DML cần transaction nhưng visible caller/repository contract không có transaction boundary và có bằng chứng sẽ lỗi runtime hoặc commit không đúng; không báo chỉ vì thích đặt annotation ở chỗ khác.
17
+ - `UPDATE`/`DELETE` thiếu `WHERE`, có predicate hằng đúng, hoặc bỏ target business key/id mà method parameters và sibling safe flow chứng minh là intended row selector, nên sửa/xóa tập row rộng hơn request.
18
+ - Bulk DML sửa entity có `@Version`, lifecycle callback, audit hoặc soft-delete convention nhưng query bypass version/audit/lifecycle và caller tiếp tục giả định invariant đó đã được giữ.
19
+ - Sau bulk DML, cùng transaction đọc/save lại các entity có thể còn nằm trong persistence context mà không clear/refresh hoặc dùng `clearAutomatically`; flow có thể trả hay ghi đè dữ liệu stale.
20
+ - DML dùng `clearAutomatically` nhưng pending managed changes chưa flush và visible flow có thể làm mất chúng; cần `flushAutomatically`/explicit flush hoặc tách boundary.
21
+
22
+ ## KHÔNG flag
23
+
24
+ - Derived `deleteBy...`, `JpaRepository.delete...`, entity-by-entity mutation hoặc read-only native query.
25
+ - DML có predicate chặt, transaction rõ ràng và caller không tái dùng managed state bị stale.
26
+ - Thiếu `@Version` đơn lẻ, hypothetical concurrent update hoặc preference dùng entity mutation thay bulk query.
27
+ - Soft-delete/publication predicate sai trên SELECT; để `soft-delete-publication-consistency-risk`.
28
+ - Dynamic SQL/identifier từ request; để `no-sql-string-concat` và security rules.
29
+
30
+ ## Primary file
31
+
32
+ File: `{{file}}`
33
+ Language: `{{language}}`
34
+
35
+ ```{{language}}
36
+ {{code}}
37
+ ```
38
+
39
+ ## Support files cùng cluster
40
+
41
+ ```
42
+ {{cluster_files}}
43
+ ```
44
+
45
+ {{cluster_summary}}
46
+
47
+ ## Output yêu cầu
48
+
49
+ Trả về JSON hợp lệ duy nhất:
50
+
51
+ ```
52
+ {
53
+ "violations": [
54
+ {
55
+ "line": <số nguyên dương, 1-based, trong PRIMARY>,
56
+ "endLine": <số nguyên dương | null>,
57
+ "message": "<≤200 ký tự, tiếng Việt có dấu, nêu DML contract và dữ liệu bị ảnh hưởng>",
58
+ "suggestion": "<gợi ý @Modifying/transaction/predicate/version/clear-flush bằng tiếng Việt có dấu | null>",
59
+ "confidence": <số nguyên 0-100>
60
+ }
61
+ ]
62
+ }
63
+ ```
64
+
65
+ Không có lỗi rõ ràng: `{"violations": []}`.
66
+
67
+ ## REPEAT CRITICAL RULES
68
+
69
+ - Cần câu DML và caller evidence cụ thể; không suy đoán.
70
+ - `line` phải thuộc PRIMARY dù PRIMARY là controller, service hoặc repository.
71
+ - Chỉ report execution, predicate, lifecycle/version hoặc persistence-context bug của bulk DML.
72
+ - Không duplicate SQL injection, generic transaction style hoặc concurrency rule.
73
+ - Confidence `<50` thì KHÔNG emit.
74
+
75
+ Không giải thích. JSON thuần.
@@ -0,0 +1,24 @@
1
+ id: spring-boot/native-dml-consistency-risk
2
+ version: 1
3
+ kind: ai
4
+ title: "Spring native UPDATE/DELETE có giữ đúng persistence contract không?"
5
+ description: |
6
+ Per-cluster AI rule for native/bulk UPDATE and DELETE correctness: missing
7
+ @Modifying or transaction execution contract, dangerously broad predicates,
8
+ optimistic-version or lifecycle bypass, and stale persistence-context reads
9
+ after bulk DML. It does not own SQL injection or generic transaction style.
10
+ severity: warning
11
+ category: backend-data-integrity
12
+ languages: [java]
13
+ scope: spring-boot
14
+ baseConfidence: 60
15
+ prompt: ./native-dml-consistency-risk.prompt.md
16
+ contextScope: per-cluster
17
+ aiConfig:
18
+ tier: regular
19
+ prRouting:
20
+ group: spring-data-consistency-group
21
+ targetLayers: [controller, service, repository, entity]
22
+ triggers: ["@Modifying", "UPDATE ", "DELETE ", "executeUpdate", "clearAutomatically", "flushAutomatically", "@Version", "nativeQuery"]
23
+ riskWeight: 5
24
+ requiresContext: [diff, primaryFile, relatedController, relatedService, relatedRepository, relatedEntity, relatedMigration]
@@ -0,0 +1,73 @@
1
+ Bạn là senior Spring Boot reviewer. Chỉ đánh giá **native-query performance/amplification có bằng chứng cụ thể**.
2
+
3
+ ## CRITICAL RULES
4
+
5
+ - KHÔNG report generic “nên thêm index”, “dùng CTE”, “tránh SELECT *” hoặc micro-optimization khi không chứng minh được scale/cost path.
6
+ - `line` BẮT BUỘC trỏ vào PRIMARY file. Nếu query nằm trong support repository, dùng dòng PRIMARY gọi query; nếu PRIMARY là repository, dùng dòng query/method.
7
+ - Không report unbounded result/page-size clamp; `pagination-risk` sở hữu result-window contract.
8
+ - Không report query-per-loop N+1; `no-nplus1-query-in-loop`/`transaction-loop-risk` sở hữu caller amplification đó.
9
+ - Không report correctness của count/order/date; để query/date/pagination consistency rules.
10
+ - Confidence `<50` thì KHÔNG emit.
11
+
12
+ ## CHỈ REPORT KHI có performance bug cụ thể
13
+
14
+ - Query bọc indexed column bằng `DATE`/`LOWER`/`CAST`/calculation trong predicate và cluster cho thấy index thường trên chính column đó cùng unbounded/large lookup path; range/functional index là fix cụ thể.
15
+ - Page size đã bounded và `OFFSET` hợp lệ, nhưng API cho phép page number rất sâu trên ordered large dataset nên DB phải scan/discard lượng row tăng tuyến tính; keyset/cursor là fix cụ thể. Missing clamp/negative/overflow đơn thuần vẫn thuộc `pagination-risk`.
16
+ - Correlated subquery/aggregate thực hiện theo từng outer row trên result set không giới hạn hoặc lớn theo evidence, với correlation/predicate không thể dùng visible key/index; không báo nếu DB có thể decorrelate rõ ràng.
17
+ - Query materialize `SELECT *`/LOB/blob/large JSON columns rồi mapper/response chỉ dùng tập field nhỏ, trên list/export/page path có nhiều row; phải nhìn thấy wide field và downstream subset.
18
+ - Leading-wildcard/case-fold search chạy trên visible large/unbounded path trong khi schema/config cho thấy không có full-text/trigram/functional-index mechanism và caller có thể gọi thường xuyên.
19
+ - Sort/group trên tập lớn được lặp hoặc materialize trước filter/limit do query shape cụ thể, không chỉ vì thiếu index suy đoán.
20
+
21
+ ## KHÔNG flag
22
+
23
+ - Thiếu index được suy ra chỉ từ việc không thấy migration; absence of evidence không phải evidence of absence.
24
+ - Bảng/config/reference data nhỏ, bounded endpoint, offline report/job có batch/throttle, hoặc query đã có suitable functional/full-text index.
25
+ - Correctness bug, SQL injection, tenant scope, N+1 caller loop hoặc generic pagination gap.
26
+ - DB-specific syntax/portability preference không có measured/runtime impact.
27
+
28
+ ## Primary file
29
+
30
+ File: `{{file}}`
31
+ Language: `{{language}}`
32
+
33
+ ```{{language}}
34
+ {{code}}
35
+ ```
36
+
37
+ ## Support files cùng cluster
38
+
39
+ ```
40
+ {{cluster_files}}
41
+ ```
42
+
43
+ {{cluster_summary}}
44
+
45
+ ## Output yêu cầu
46
+
47
+ Trả về JSON hợp lệ duy nhất:
48
+
49
+ ```
50
+ {
51
+ "violations": [
52
+ {
53
+ "line": <số nguyên dương, 1-based, trong PRIMARY>,
54
+ "endLine": <số nguyên dương | null>,
55
+ "message": "<≤200 ký tự, tiếng Việt có dấu, nêu query shape, scale evidence và amplification>",
56
+ "suggestion": "<gợi ý sargable/keyset/projection/index phù hợp bằng tiếng Việt có dấu | null>",
57
+ "confidence": <số nguyên 0-100>
58
+ }
59
+ ]
60
+ }
61
+ ```
62
+
63
+ Không có lỗi rõ ràng: `{"violations": []}`.
64
+
65
+ ## REPEAT CRITICAL RULES
66
+
67
+ - Không có scale/schema/caller evidence thì không emit.
68
+ - `line` phải thuộc PRIMARY dù PRIMARY là controller, service hoặc repository.
69
+ - Không duplicate pagination, N+1, correctness hoặc SQL injection rules.
70
+ - Missing index đơn thuần không phải finding.
71
+ - Confidence `<50` thì KHÔNG emit.
72
+
73
+ Không giải thích. JSON thuần.
@@ -0,0 +1,24 @@
1
+ id: spring-boot/native-query-performance-risk
2
+ version: 1
3
+ kind: ai
4
+ title: "Spring native query có amplification/performance risk có bằng chứng không?"
5
+ description: |
6
+ Per-cluster AI rule for evidence-backed native-query amplification:
7
+ non-sargable predicates over visibly indexed columns, deep request-driven
8
+ OFFSET, repeated correlated work, and unnecessarily wide row materialization.
9
+ It rejects generic missing-index or rewrite preferences.
10
+ severity: warning
11
+ category: performance
12
+ languages: [java]
13
+ scope: spring-boot
14
+ baseConfidence: 58
15
+ prompt: ./native-query-performance-risk.prompt.md
16
+ contextScope: per-cluster
17
+ aiConfig:
18
+ tier: regular
19
+ prRouting:
20
+ group: spring-data-consistency-group
21
+ targetLayers: [controller, service, repository, entity, config]
22
+ triggers: ["nativeQuery", "SELECT *", "OFFSET", "LIKE", "LOWER(", "DATE(", "CAST(", "EXISTS", "GROUP BY", "ORDER BY"]
23
+ riskWeight: 4
24
+ requiresContext: [diff, primaryFile, relatedController, relatedService, relatedRepository, relatedEntity, relatedMigration, databaseConfig]
@@ -7,7 +7,7 @@ CRITICAL NON-VIOLATIONS:
7
7
  - NEVER report generic missing login/auth annotation. `spring-boot/security-authorization-risk` owns endpoint-level missing authorization.
8
8
  - NEVER report a scope gap when repository/service query already includes principal/user/account/tenant/owner/deleted scope.
9
9
  - NEVER report a DTO validation issue, SQL concat, transaction placement, raw exception response, SSRF, or filesystem issue.
10
- - NEVER report benchmark negative controls (`SafeOperationsController`, `SafeOperationsService`, `ApiExceptionAdvice`, DTOs under `com.benchmark.badmvc.dto`) unless PRIMARY shows direct, unscoped data access evidence in the unsafe method itself.
10
+ - NEVER report a file that only plays a supporting/evidence role (a global exception handler, a DTO, a class the cluster shows as the safe path) unless PRIMARY shows direct, unscoped data access evidence in the unsafe method itself.
11
11
  - NEVER report pure list/pagination/findAll/unbounded-result problems here. `spring-boot/pagination-risk` owns pagination/result-window gaps, even when entities have tenant/account fields.
12
12
 
13
13
  1. **CHI report loi co bang chung cu the** trong PRIMARY hoac support files. Khong doan convention ngoai cluster.
@@ -27,7 +27,7 @@ CRITICAL NON-VIOLATIONS:
27
27
  - `list()`, `findAll()`, fallback list, pagination/limit gaps, hoac endpoint tra ve collection ma khong nhan object id cu the tu request. De `pagination-risk` xu ly.
28
28
  - Entity/service khong co bang chung ownership/tenant/account boundary.
29
29
  - Flow co `Principal`, `Authentication`, current user/tenant, scoped query (`findByIdAndOwnerId`, `findByTenantIdAndId`, `deleted=false`), ownership validator, policy service, hoac method security voi object-scope ro rang.
30
- - Safe DTO flow, `SafeOperations*`, hoac `ApiExceptionAdvice` support-only file neu khong co direct unsafe scoped data access trong PRIMARY.
30
+ - Luong DTO an toan, hoac file support-only (global exception handler, mapper, config) neu khong co direct unsafe scoped data access trong PRIMARY.
31
31
  - Endpoint public-safe/doc lookup khong co sensitive domain boundary trong cluster.
32
32
  - Thieu auth chung chung; chi flag neu co data ownership/scope gap rieng.
33
33
  - Style/naming/refactor suggestion.
@@ -61,8 +61,8 @@ Tra ve **JSON HOP LE DUY NHAT** (khong markdown fence, khong text khac) theo sch
61
61
  {
62
62
  "line": <so nguyen duong, 1-based, trong PRIMARY>,
63
63
  "endLine": <so nguyen duong | null>,
64
- "message": "<<=200 ky tu, tieng Viet, neu controller/service flow + scope bi thieu>",
65
- "suggestion": "<goi y fix | null>",
64
+ "message": "<≤200 ký tự, tiếng Việt có dấu, nêu luồng controller/service và phạm vi sở hữu còn thiếu>",
65
+ "suggestion": "<gợi ý sửa lỗi bằng tiếng Việt có dấu | null>",
66
66
  "confidence": <so nguyen 0-100>
67
67
  }
68
68
  ]
@@ -76,7 +76,7 @@ Neu khong co ownership/scope bug ro rang: `{"violations": []}`.
76
76
  - `line` phai tro ve PRIMARY controller, khong dung line tu service/repository.
77
77
  - Khong flag generic missing auth; chi flag owner/tenant/account/deleted scope gap co evidence.
78
78
  - Khong flag list/findAll/pagination/unbounded collection; rule nay chi bat object-level owner/tenant/account scope gap.
79
- - Khong flag benchmark negative controls: `SafeOperationsController`, `SafeOperationsService`, `ApiExceptionAdvice`, DTO safe flow, tru khi PRIMARY co direct unsafe data access evidence.
79
+ - Khong flag file support-only (global exception handler, DTO, luong an toan) tru khi PRIMARY co direct unsafe data access evidence.
80
80
  - Khong duplicate static rules hoac cac rule `io-boundary-risk`, `transaction-loop-risk`, `pagination-risk`, `business-invariant-risk`, `error-handling-completeness`.
81
81
  - Confidence `<50` -> KHONG emit.
82
82
 
@@ -1,5 +1,5 @@
1
1
  id: spring-boot/ownership-scope-risk
2
- version: 3
2
+ version: 4
3
3
  kind: ai
4
4
  title: "Spring Boot ownership/tenant scope flow co rui ro khong?"
5
5
  description: |
@@ -14,7 +14,6 @@ scope: spring-boot
14
14
  baseConfidence: 60
15
15
  prompt: ./ownership-scope-risk.prompt.md
16
16
  contextScope: per-cluster
17
- maxTokens: 1800
18
17
  aiConfig:
19
18
  tier: regular
20
19
  prRouting:
@@ -0,0 +1,75 @@
1
+ Bạn là senior Spring Boot reviewer. Chỉ đánh giá **tính đúng của paged/single-row result window**: ordering, value/count parity và page membership.
2
+
3
+ ## CRITICAL RULES
4
+
5
+ - Rule này KHÔNG yêu cầu thêm pagination. `spring-boot/pagination-risk` sở hữu unbounded/findAll/unpaged/page-size bugs.
6
+ - `line` BẮT BUỘC trỏ vào PRIMARY file. Nếu query nằm trong support repository, dùng dòng PRIMARY gọi flow; nếu PRIMARY là repository, dùng dòng query/method.
7
+ - CHỈ report khi cluster cho thấy query/page implementation cụ thể và tác động đến page content/total/order.
8
+ - Không report generic index/full-scan/CTE cost hoặc sở thích sort.
9
+ - Không duplicate `query-contract-risk` cho scalar/list bind, column, join-key hoặc projection alias mismatch không liên quan paging.
10
+ - Confidence `<50` thì KHÔNG emit.
11
+
12
+ ## CHỈ REPORT KHI có paged-query correctness bug cụ thể
13
+
14
+ - `ORDER BY` không có unique/stable tie-breaker khi primary sort field có thể trùng theo evidence (timestamp/status/name/version), khiến row duplicate/missing giữa page.
15
+ - Query có `Pageable` nhưng không có default ordering và caller có thể gửi unsorted page, nên DB order bất định.
16
+ - `LIMIT 1`, `TOP 1`, `setMaxResults(1)`, `findFirst...` hoặc `findTop...` chọn một row nhưng thiếu explicit/derived unique ordering, nên cùng input có thể trả record khác nhau.
17
+ - `value` query và `countQuery` áp filter/join/date boundary khác nhau, làm content và `totalElements` mô tả hai tập record khác nhau.
18
+ - One-to-many JOIN nhân row trong value/count query; `DISTINCT`/grouping áp chỉ một phía hoặc không giữ entity uniqueness.
19
+ - Service load hard-limited page rồi mới filter requested ids/permission/status trong memory, gây valid row ngoài first window bị mất hoặc page metadata sai.
20
+ - Service thêm ancestor/root/synthetic rows vào page content nhưng không điều chỉnh page size/total/order contract.
21
+
22
+ ## KHÔNG flag
23
+
24
+ - Unbounded list/export, missing page-size clamp, fake pagination do load full table: để `pagination-risk` nếu lỗi chỉ là result-window.
25
+ - Ordering có unique id/code tie-breaker hoặc DB query dùng deterministic keyset pagination.
26
+ - Count query bỏ fetch-only JOIN nhưng giữ cùng filter semantics.
27
+ - Pure query performance/index advice.
28
+ - Filter scope/auth thiếu nhưng page mechanics đúng; để ownership/authorization rules.
29
+
30
+ ## Primary file
31
+
32
+ File: `{{file}}`
33
+ Language: `{{language}}`
34
+
35
+ ```{{language}}
36
+ {{code}}
37
+ ```
38
+
39
+ ## Support files cùng cluster
40
+
41
+ ```
42
+ {{cluster_files}}
43
+ ```
44
+
45
+ {{cluster_summary}}
46
+
47
+ ## Output yêu cầu
48
+
49
+ Trả về JSON hợp lệ duy nhất:
50
+
51
+ ```
52
+ {
53
+ "violations": [
54
+ {
55
+ "line": <số nguyên dương, 1-based, trong PRIMARY>,
56
+ "endLine": <số nguyên dương | null>,
57
+ "message": "<≤200 ký tự, tiếng Việt có dấu, nêu page ordering/count/membership bị sai>",
58
+ "suggestion": "<gợi ý stable ordering/parity bằng tiếng Việt có dấu | null>",
59
+ "confidence": <số nguyên 0-100>
60
+ }
61
+ ]
62
+ }
63
+ ```
64
+
65
+ Không có lỗi rõ ràng: `{"violations": []}`.
66
+
67
+ ## REPEAT CRITICAL RULES
68
+
69
+ - Chỉ xét paged hoặc single-row result window; unbounded result thuộc `pagination-risk`.
70
+ - `line` phải thuộc PRIMARY dù PRIMARY là controller, service hoặc repository.
71
+ - Cần user-visible page content/total/order impact, không báo performance/style.
72
+ - Không duplicate query-contract hoặc ownership/auth rules.
73
+ - Confidence `<50` thì KHÔNG emit.
74
+
75
+ Không giải thích. JSON thuần.
@@ -0,0 +1,25 @@
1
+ id: spring-boot/pagination-query-consistency-risk
2
+ version: 2
3
+ kind: ai
4
+ title: "Spring paged query có ordering/count/filter nhất quán không?"
5
+ description: |
6
+ Per-cluster AI rule for correctness defects in paginated or single-row-window queries:
7
+ non-deterministic ordering without a unique tie-breaker, value/count query
8
+ predicate drift, joins that multiply page rows, and filtering requested ids
9
+ only after a hard-limited page has been loaded, and LIMIT/TOP/findFirst
10
+ selection without deterministic ordering.
11
+ severity: warning
12
+ category: backend-pagination-correctness
13
+ languages: [java]
14
+ scope: spring-boot
15
+ baseConfidence: 58
16
+ prompt: ./pagination-query-consistency-risk.prompt.md
17
+ contextScope: per-cluster
18
+ aiConfig:
19
+ tier: regular
20
+ prRouting:
21
+ group: spring-data-consistency-group
22
+ targetLayers: [controller, service, repository]
23
+ triggers: ["Pageable", "PageRequest", "countQuery", "ORDER BY", "PageImpl", "DISTINCT", "ROW_NUMBER", "totalElements", "LIMIT 1", "TOP 1", "findFirst", "findTop", "ids"]
24
+ riskWeight: 4
25
+ requiresContext: [diff, primaryFile, relatedController, relatedService, relatedRepository]
@@ -61,8 +61,8 @@ Tra ve **JSON HOP LE DUY NHAT** (khong markdown fence, khong text khac) theo sch
61
61
  {
62
62
  "line": <so nguyen duong, 1-based, trong PRIMARY>,
63
63
  "endLine": <so nguyen duong | null>,
64
- "message": "<<=200 ky tu, tieng Viet, neu list/search/export flow unbounded>",
65
- "suggestion": "<goi y fix | null>",
64
+ "message": "<≤200 ký tự, tiếng Việt có dấu, nêu luồng list/search/export không giới hạn>",
65
+ "suggestion": "<gợi ý sửa lỗi bằng tiếng Việt có dấu | null>",
66
66
  "confidence": <so nguyen 0-100>
67
67
  }
68
68
  ]