@code-sentinel-cli/code-sentinel-cli 3.0.11 → 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.
- package/dist/bin.js +4793 -4228
- package/dist/builtin-rules/ai/angular/api-service-contract-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/angular/component-state-flow.prompt.md +2 -2
- package/dist/builtin-rules/ai/angular/cross-feature-api-drift.prompt.md +2 -2
- package/dist/builtin-rules/ai/angular/cross-feature-route-permission-drift.prompt.md +2 -2
- package/dist/builtin-rules/ai/angular/reactive-form-flow.prompt.md +2 -2
- package/dist/builtin-rules/ai/angular/route-permission-flow.prompt.md +2 -2
- package/dist/builtin-rules/ai/angular/rxjs-flow-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/angular/template-contract-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/flutter/dynamic-content-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/flutter/feature-state-flow-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/flutter/native-platform-consistency-risk.prompt.md +2 -3
- package/dist/builtin-rules/ai/flutter/network-auth-flow-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/flutter/ui-responsive-accessibility-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/general/code-clarity.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/business-invariant-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/cache-consistency-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/cross-feature-error-handling-drift.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/cross-feature-transaction-boundary-drift.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/error-handling-completeness.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/event-publishing-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/import-template-contract-risk.prompt.md +74 -0
- package/dist/builtin-rules/ai/spring-boot/import-template-contract-risk.rule.yaml +24 -0
- package/dist/builtin-rules/ai/spring-boot/io-boundary-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/native-dml-consistency-risk.prompt.md +75 -0
- package/dist/builtin-rules/ai/spring-boot/native-dml-consistency-risk.rule.yaml +24 -0
- package/dist/builtin-rules/ai/spring-boot/native-query-performance-risk.prompt.md +73 -0
- package/dist/builtin-rules/ai/spring-boot/native-query-performance-risk.rule.yaml +24 -0
- package/dist/builtin-rules/ai/spring-boot/ownership-scope-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/pagination-query-consistency-risk.prompt.md +75 -0
- package/dist/builtin-rules/ai/spring-boot/pagination-query-consistency-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/spring-boot/pagination-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/partial-update-mapper-risk.prompt.md +73 -0
- package/dist/builtin-rules/ai/spring-boot/partial-update-mapper-risk.rule.yaml +24 -0
- package/dist/builtin-rules/ai/spring-boot/query-contract-risk.prompt.md +80 -0
- package/dist/builtin-rules/ai/spring-boot/query-contract-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/spring-boot/query-date-boundary-risk.prompt.md +74 -0
- package/dist/builtin-rules/ai/spring-boot/query-date-boundary-risk.rule.yaml +24 -0
- package/dist/builtin-rules/ai/spring-boot/security-authorization-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/security-mass-assignment-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/security-redirect-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/security-sensitive-data-risk.prompt.md +9 -4
- package/dist/builtin-rules/ai/spring-boot/security-sensitive-data-risk.rule.yaml +6 -5
- package/dist/builtin-rules/ai/spring-boot/soft-delete-publication-consistency-risk.prompt.md +74 -0
- package/dist/builtin-rules/ai/spring-boot/soft-delete-publication-consistency-risk.rule.yaml +24 -0
- package/dist/builtin-rules/ai/spring-boot/transaction-loop-risk.prompt.md +2 -2
- package/dist/builtin-rules/ai/spring-boot/versioned-entity-concurrency-risk.prompt.md +73 -0
- package/dist/builtin-rules/ai/spring-boot/versioned-entity-concurrency-risk.rule.yaml +24 -0
- package/dist/index.d.ts +275 -241
- package/dist/index.js +4793 -4228
- package/package.json +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Bạn là senior Spring Boot reviewer. Chỉ đánh giá **race condition trên versioned entity, uniqueness invariant và workflow read-check-write**.
|
|
2
|
+
|
|
3
|
+
## CRITICAL RULES
|
|
4
|
+
|
|
5
|
+
- Không report chỉ vì entity thiếu `@Version`. Phải có concurrent read-compute/check-write path và invariant có thể bị phá.
|
|
6
|
+
- `line` BẮT BUỘC trỏ vào PRIMARY file. Nếu race nằm trong support repository/service, dùng dòng PRIMARY gọi flow; nếu PRIMARY là repository/service, dùng dòng mutation/query.
|
|
7
|
+
- `@Transactional` một mình KHÔNG chứng minh chống race; đồng thời thiếu `@Transactional` một mình thuộc transaction rules.
|
|
8
|
+
- Không report performance, generic retry preference, hoặc hypothetical concurrency không có persisted effect.
|
|
9
|
+
- Không duplicate request-controlled status/mass assignment; tập trung vào interleaving của hai request hợp lệ.
|
|
10
|
+
- Confidence `<50` thì KHÔNG emit.
|
|
11
|
+
|
|
12
|
+
## CHỈ REPORT KHI có concurrency bug cụ thể
|
|
13
|
+
|
|
14
|
+
- Flow đọc latest/MAX(version), tính `+1`, rồi insert/save mà không có pessimistic/advisory lock, atomic DB sequence, unique `(lineage, version)` constraint kèm retry, hoặc equivalent serialization.
|
|
15
|
+
- Flow check-then-insert (`existsBy...`/duplicate check trước insert/update) nhưng DB không có visible unique invariant/lock; hai request có thể cùng pass.
|
|
16
|
+
- Approve/reject/publish/delete flow đọc current status rồi save mà entity không có optimistic version/conditional update/lock, cho phép lost update hoặc hai terminal side effect cùng xảy ra.
|
|
17
|
+
- Batch có thể chứa nhiều row cùng lineage/business key và publish/approve nhiều active versions vì không dedupe/lock/enforce one-active invariant.
|
|
18
|
+
- Mutation load method thiếu lock trong khi sibling mutation path hoặc repository cung cấp explicit `ForUpdate` method nhưng flow không dùng, chứng minh lock contract bị bỏ qua.
|
|
19
|
+
|
|
20
|
+
## KHÔNG flag
|
|
21
|
+
|
|
22
|
+
- Entity có `@Version`, conditional `UPDATE ... WHERE status/version`, pessimistic lock, DB unique constraint + conflict handling, hoặc serialized queue/lock rõ ràng.
|
|
23
|
+
- Pure multi-write atomicity/rollback/orphan external object; để `transaction-loop-risk`.
|
|
24
|
+
- Read-only query chọn latest sai predicate; để `soft-delete-publication-consistency-risk` hoặc `query-contract-risk`.
|
|
25
|
+
- ID generation có collision probability nhỏ nhưng không có deterministic check-then-act evidence.
|
|
26
|
+
- Code test/import offline được single-thread guarantee rõ ràng.
|
|
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, mô tả hai request có thể interleave và invariant bị phá>",
|
|
56
|
+
"suggestion": "<gợi ý lock/version/unique/conditional update 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
|
+
- Thiếu `@Version` đơn lẻ không phải finding.
|
|
68
|
+
- Phải có read-check/compute-write race và persisted invariant cụ thể.
|
|
69
|
+
- `line` phải thuộc PRIMARY dù PRIMARY là controller, service hoặc repository.
|
|
70
|
+
- `@Transactional` không tự chống lost update.
|
|
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/versioned-entity-concurrency-risk
|
|
2
|
+
version: 2
|
|
3
|
+
kind: ai
|
|
4
|
+
title: "Spring versioned entity/workflow có race condition không?"
|
|
5
|
+
description: |
|
|
6
|
+
Per-cluster AI rule for concrete read-compute-write races in versioned domain
|
|
7
|
+
entities and workflow transitions: MAX/latest version plus one without a lock
|
|
8
|
+
or uniqueness invariant, unlocked status transitions, and check-then-insert
|
|
9
|
+
uniqueness paths that concurrent requests can violate.
|
|
10
|
+
severity: warning
|
|
11
|
+
category: backend-concurrency
|
|
12
|
+
languages: [java]
|
|
13
|
+
scope: spring-boot
|
|
14
|
+
baseConfidence: 60
|
|
15
|
+
prompt: ./versioned-entity-concurrency-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: ["MAX(version)", "version + 1", "findFirstBy", "@Version", "@Lock", "PESSIMISTIC_WRITE", "existsBy", "approve", "reject"]
|
|
23
|
+
riskWeight: 5
|
|
24
|
+
requiresContext: [diff, primaryFile, relatedController, relatedService, relatedRepository, relatedEntity]
|