@bonesofspring/ai-rules 0.2.9 → 0.2.10
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/CHANGELOG.md +11 -3
- package/package.json +1 -1
- package/presets/_shared/core/meta/preset-token-budget.md +1 -1
- package/presets/claude/go/rules/api-and-data/persistence-adapters.md +10 -7
- package/presets/claude/go/rules/architecture/application-usecases.md +9 -5
- package/presets/claude/go/rules/architecture/boundaries.md +6 -1
- package/presets/claude/go/rules/architecture/composition-root.md +14 -9
- package/presets/claude/go/rules/testing/e2e.md +8 -6
- package/presets/claude/go/rules/testing/integration.md +11 -5
- package/presets/claude/go/rules/tooling-and-review/preset-token-budget.md +1 -1
- package/presets/claude/go/rules/tooling-and-review/security-go.md +17 -5
- package/presets/claude/ios-swift/README.md +1 -1
- package/presets/claude/ios-swift/agents/build-verifier.md +1 -1
- package/presets/claude/ios-swift/rules/README.md +1 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-token-budget.md +1 -1
- package/presets/claude/java/agents/build-verifier.md +1 -1
- package/presets/claude/java/rules/README.md +1 -1
- package/presets/claude/java/rules/api-and-data/messaging-adapters.md +16 -9
- package/presets/claude/java/rules/architecture/boundaries.md +6 -1
- package/presets/claude/java/rules/tooling-and-review/preset-token-budget.md +1 -1
- package/presets/claude/next/agents/build-verifier.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/preset-token-budget.md +1 -1
- package/presets/cursor/go/rules/README.md +8 -8
- package/presets/cursor/go/rules/application-usecases.mdc +9 -5
- package/presets/cursor/go/rules/architecture-boundaries.mdc +6 -0
- package/presets/cursor/go/rules/composition-root.mdc +14 -9
- package/presets/cursor/go/rules/persistence-adapters.mdc +10 -7
- package/presets/cursor/go/rules/preset-token-budget.mdc +1 -1
- package/presets/cursor/go/rules/security-go.mdc +17 -5
- package/presets/cursor/go/rules/tests-e2e.mdc +8 -6
- package/presets/cursor/go/rules/tests-integration.mdc +11 -5
- package/presets/cursor/ios-swift/agents/build-verifier.md +1 -1
- package/presets/cursor/ios-swift/rules/README.md +1 -1
- package/presets/cursor/ios-swift/rules/preset-token-budget.mdc +1 -1
- package/presets/cursor/java/README.md +1 -1
- package/presets/cursor/java/agents/build-verifier.md +1 -1
- package/presets/cursor/java/rules/README.md +4 -4
- package/presets/cursor/java/rules/architecture-boundaries.mdc +6 -0
- package/presets/cursor/java/rules/messaging-adapters.mdc +16 -10
- package/presets/cursor/java/rules/preset-token-budget.mdc +1 -1
- package/presets/cursor/next/agents/build-verifier.md +1 -1
- package/presets/cursor/next/rules/preset-token-budget.mdc +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
### Go/Java stub thicken + session-start budget raise (`go-java-rules-thicken-dogfood`)
|
|
6
|
+
|
|
7
|
+
- **Session-start body cap:** **120 → 140** (stretch **≤120**); `alwaysApply` / Claude session-start count stays **exactly 3**. Checker `BODY_CAP=140`; policy core + embed adapters + build-verifier copy updated.
|
|
8
|
+
- **Go Must thickened to full** (Cursor SoT + Claude twins): `application-usecases`, `composition-root`, `persistence-adapters`, `tests-integration`, `security-go`. `tests-e2e` kept stub with scoped-smoke banner (≥15 body).
|
|
9
|
+
- **Always-on edit-bundle index** added to Go/Java `architecture-boundaries` (uses new headroom).
|
|
10
|
+
- **Java:** `messaging-adapters` expanded to **full** (J3); `api-grpc` remains documented stub.
|
|
11
|
+
- **Dogfood hosts:** dedicated samples under `dogfood/go-hexagonal` and `dogfood/java-spring-hexagonal` (A/B runs follow-up).
|
|
12
|
+
|
|
5
13
|
### React/Next anti-hallucination (P0-B / `preset-react-next-anti-hallucination`)
|
|
6
14
|
|
|
7
15
|
- New **requestable** next-only rule `react-next-anti-hallucination` (Cursor `.mdc` + Claude twin under `anti-hallucination/`) — ≥15 ❌/✅ banlist rows for phantom Next/React/RTK imports, RSC boundaries, navigation, version drift.
|
|
@@ -13,20 +21,20 @@
|
|
|
13
21
|
- Slimmed always-on `quality/code-quality-and-refactoring` (Principles + condensed Agent discipline essentials + pointer).
|
|
14
22
|
- New requestable shared-core `quality/anti-sycophancy-discipline` (~17 procedural rules) + Cursor/Claude adapters ×4 stacks (`alwaysApply: false` / `paths:`).
|
|
15
23
|
- Wired `feature-developer` / `debugger` / `ci-investigator` (Cursor + Claude ×4) to load `anti-sycophancy-discipline` when writing/changing code.
|
|
16
|
-
- Session-start alwaysApply trio body sum target ≤120 (prefer ≤110);
|
|
24
|
+
- Session-start alwaysApply trio body sum target was ≤120 (prefer ≤110) at ship time; **superseded** by Unreleased budget raise to ≤140 (prefer ≤120).
|
|
17
25
|
|
|
18
26
|
### Review follow-ups (core sharing / structure)
|
|
19
27
|
|
|
20
28
|
- **Shared-core drift is a hard gate** in `check:preset-structure` / CI (`AI_RULES_DRIFT_FAIL=1`).
|
|
21
29
|
- **build-verifier** agents (next/ios-swift/go/java × Cursor+Claude): twin / REPO_AGENTS / react-performance gates list all four stacks.
|
|
22
30
|
- **Leakage core DRY:** merged go+java forbidden blocks in `meta/preset-no-cross-stack-leakage` (+8 embed adapters).
|
|
23
|
-
- **ios-swift session-start:** trimmed `ios-app-core` toward stretch ≤100 body sum.
|
|
31
|
+
- **ios-swift session-start:** trimmed `ios-app-core` toward stretch ≤100 body sum (at ship; stretch target now ≤120 with hard cap 140).
|
|
24
32
|
- **Docs:** leakage soft-WARN baseline + drift hardgate in `PRESET-CONTRIBUTION.md`; go/java `feature-full` fixtures drop Playwright/XCUITest skipped noise.
|
|
25
33
|
|
|
26
34
|
### Java preset
|
|
27
35
|
|
|
28
36
|
- New installable preset **`java`** (Cursor + Claude twins): Spring Boot hexagonal default, layer-first single-module layout, Context7-only MCP, Maven/Gradle detection via `java-tooling` / `post-change-test`.
|
|
29
|
-
- Full mapped rule catalog (~32 stems); always-on trio `java-app-core`, `architecture-boundaries`, `code-quality-and-refactoring` (
|
|
37
|
+
- Full mapped rule catalog (~32 stems); always-on trio `java-app-core`, `architecture-boundaries`, `code-quality-and-refactoring` (body budget now ≤140).
|
|
30
38
|
- Agent-team surface: 21 agents, 8 skills, 5 commands, hooks + team fixtures; `integration-test-*` (no Playwright/XCUITest/a11y).
|
|
31
39
|
- Structure scripts (`twin-map`, `token-budget`, `leakage`) include `java`; meta cores list four stacks (8 adapters per embed stem).
|
|
32
40
|
- Install: `npx @bonesofspring/ai-rules init cursor|claude --preset java`.
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
**Claude Option A (README exclusion):** when counting Claude rules without `paths:` / session-start, **exclude `**/README.md`** (topic indexes are not session-start rules). The intended session-start trio remains **exactly 3**; body budget sums **only those 3** rules.
|
|
13
13
|
|
|
14
|
-
Session-start body budget (где задокументировано): ≤
|
|
14
|
+
Session-start body budget (где задокументировано): ≤140 строк суммарно (stretch ≤120).
|
|
15
15
|
|
|
16
16
|
## Meta / author rules
|
|
17
17
|
|
|
@@ -5,24 +5,27 @@ paths:
|
|
|
5
5
|
- **/*repository*.go
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
# Persistence adapters
|
|
10
9
|
|
|
11
10
|
- Implement outbound repository ports from application.
|
|
12
|
-
- Use parameterized queries; map rows → domain entities inside the adapter.
|
|
11
|
+
- Use **parameterized** queries; map rows → domain entities **inside** the adapter.
|
|
13
12
|
- Transactions: expose via port (`Transactional`, `UnitOfWork`) implemented here — use cases call the port, not `*sql.Tx` directly.
|
|
14
|
-
- Migrations live with infra (separate package/dir) — not in domain.
|
|
13
|
+
- Migrations live with infra (separate package/dir) — not in domain or application.
|
|
15
14
|
|
|
16
15
|
## Mapping
|
|
17
16
|
|
|
18
17
|
- Persistence models (db tags) stay private to the adapter package when possible.
|
|
19
|
-
- Nullability and DB defaults
|
|
18
|
+
- Nullability, zero values, and DB defaults convert to domain values explicitly (no silent zero-value domain objects).
|
|
19
|
+
- Port methods return domain/application errors — never leak driver-specific types through the port.
|
|
20
20
|
|
|
21
21
|
## Forbidden
|
|
22
22
|
|
|
23
|
-
- Importing persistence from domain or leaking `*sql.DB` through port APIs.
|
|
24
|
-
- Building SQL strings in use cases.
|
|
23
|
+
- Importing persistence from domain or leaking `*sql.DB` / ORM handles through port APIs.
|
|
24
|
+
- Building SQL strings in use cases or handlers.
|
|
25
|
+
- Returning scan structs / `sql.Null*` types across the port boundary.
|
|
25
26
|
|
|
26
27
|
## Tests
|
|
27
28
|
|
|
28
|
-
- Integration
|
|
29
|
+
- Integration: repository **contract** round-trip (save → load → error/not-found) against testcontainers / repo-standard test DB.
|
|
30
|
+
- Unit-test mappers with fixtures; do **not** substitute `httptest` for a repository contract.
|
|
31
|
+
- Agents: `integration-test-{planner,generator,healer}` + skill `integration-testing`; then `post-change-test`.
|
|
@@ -5,25 +5,29 @@ paths:
|
|
|
5
5
|
- **/application/**/*
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
# Application / use cases
|
|
10
9
|
|
|
11
10
|
- One use case ≈ one application service method (command/query).
|
|
12
11
|
- Depend on **outbound ports** (interfaces), not concrete repos/clients.
|
|
13
12
|
- Orchestrate domain; transaction boundaries via ports (`UnitOfWork`) when needed — still no SQL here.
|
|
14
13
|
- Accept `context.Context` on public methods; propagate to ports.
|
|
14
|
+
- Input/output types stay in application or domain — never handler DTOs, `http.Request`, or SQL row types.
|
|
15
15
|
|
|
16
16
|
## Forbidden
|
|
17
17
|
|
|
18
|
-
- Importing `adapters/*`, SQL drivers, HTTP frameworks.
|
|
19
|
-
- Embedding `*sql.DB`, Redis clients, or handler types in use-case structs.
|
|
20
|
-
- Business rules that belong in domain entities (keep use cases thin).
|
|
18
|
+
- Importing `adapters/*`, SQL drivers, HTTP/gRPC frameworks, broker clients.
|
|
19
|
+
- Embedding `*sql.DB`, Redis/Kafka clients, or handler types in use-case structs.
|
|
20
|
+
- Business rules that belong in domain entities (keep use cases thin orchestrators).
|
|
21
|
+
- Starting DB transactions with concrete `*sql.Tx` — call a port (`UnitOfWork` / `Transactional`).
|
|
21
22
|
|
|
22
23
|
## Structure
|
|
23
24
|
|
|
24
25
|
- Prefer `application/<usecase>.go` + `ports.go` (or `ports/`) colocated.
|
|
25
26
|
- Inbound port = interface the driving adapter calls (optional if use-case struct is the API).
|
|
27
|
+
- Map transport/persistence errors at adapters; use cases return domain/application errors.
|
|
26
28
|
|
|
27
29
|
## Tests
|
|
28
30
|
|
|
29
|
-
-
|
|
31
|
+
- Fake/mock **outbound ports** only; assert domain outcomes and port interactions — no real DB.
|
|
32
|
+
- Table-driven cases for validation/branching; inject clock/ID seams when time/IDs matter.
|
|
33
|
+
- After edits: `post-change-test` (+ `go-tooling`).
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
description: Hexagonal layer boundaries for Go backends (domain, application, ports, adapters)
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
# Границы слоёв (hexagonal)
|
|
7
6
|
|
|
8
7
|
- **Domain** (`internal/domain`, `**/domain`):
|
|
@@ -23,6 +22,12 @@ description: Hexagonal layer boundaries for Go backends (domain, application, po
|
|
|
23
22
|
- Domain never imports adapters or frameworks.
|
|
24
23
|
- Cross-feature access — only via public ports / `pkg` API, not deep imports of another feature's internals.
|
|
25
24
|
|
|
25
|
+
# Edit bundles (load on matching paths)
|
|
26
|
+
|
|
27
|
+
- `**/domain/**` → `domain-layer`; `**/application/**` → `application-usecases` + `ports-interfaces`
|
|
28
|
+
- Driving HTTP/gRPC → `adapters-driving` + `api-http` / `api-grpc`; persistence/messaging → `adapters-driven` + matching `*-adapters`
|
|
29
|
+
- `cmd/**`, `internal/app/**` → `composition-root`; after `*.go` edits → `post-change-test` (+ `go-tooling`)
|
|
30
|
+
|
|
26
31
|
# Требование к агенту
|
|
27
32
|
|
|
28
33
|
- Класть файлы в правильный слой; не «коротить» слои ради скорости.
|
|
@@ -5,24 +5,29 @@ paths:
|
|
|
5
5
|
- internal/app/**/*
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
# Composition root
|
|
10
9
|
|
|
11
|
-
- Construct adapters
|
|
12
|
-
- Wire interfaces to implementations explicitly (manual DI preferred unless repo already uses a container).
|
|
13
|
-
- Load config once; fail fast on missing required settings.
|
|
14
|
-
- Lifecycle:
|
|
10
|
+
- Construct adapters → use cases → servers in `cmd/<service>` and/or `internal/app`.
|
|
11
|
+
- Wire interfaces to implementations explicitly (manual DI preferred unless the repo already uses a container).
|
|
12
|
+
- Load config once; **fail fast** on missing required settings before opening listeners or connections.
|
|
13
|
+
- Lifecycle: cancel root `context` → drain in-flight work → `Shutdown` servers → close driven adapters (DB/pool/clients) in reverse wire order.
|
|
15
14
|
|
|
16
15
|
## Allowed here
|
|
17
16
|
|
|
18
|
-
- Import all layers for wiring only
|
|
19
|
-
- Process-wide loggers/metrics providers.
|
|
17
|
+
- Import all layers **for wiring only**.
|
|
18
|
+
- Process-wide loggers/metrics providers constructed once and injected.
|
|
20
19
|
|
|
21
20
|
## Forbidden
|
|
22
21
|
|
|
23
22
|
- Business rules, SQL queries, HTTP routing tables with domain logic.
|
|
24
|
-
- Global mutable singletons for repos without clear init (prefer explicit deps).
|
|
23
|
+
- Global mutable singletons for repos without clear init (prefer explicit constructor deps).
|
|
24
|
+
- Starting background workers without tying them to the root context / shutdown path.
|
|
25
|
+
|
|
26
|
+
## Agent handoffs
|
|
27
|
+
|
|
28
|
+
- After wiring changes: `post-change-test` (+ `go-tooling`) — at least compile / construction smoke.
|
|
29
|
+
- Layer checklist: `feature-delivery-workflow` (domain → ports → adapters → wire).
|
|
25
30
|
|
|
26
31
|
## Tests
|
|
27
32
|
|
|
28
|
-
- Optional smoke that wiring builds
|
|
33
|
+
- Optional construction/smoke test that `NewApp`/`main` wiring builds; heavy logic stays in unit/integration tests.
|
|
@@ -5,14 +5,16 @@ paths:
|
|
|
5
5
|
- **/*_e2e_test.go
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
# E2E / HTTP smoke
|
|
10
9
|
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
10
|
+
> **Documented stub / scoped smoke:** Prefer `tests-integration` + `integration-test-*` for breadth. Expand this rule only when the consumer repo keeps a dedicated black-box smoke suite.
|
|
11
|
+
|
|
12
|
+
- Black-box against a running server (`httptest` with full composition root, or localhost in CI).
|
|
13
|
+
- Cover critical paths only; prefer integration + unit for most coverage.
|
|
14
|
+
- Stable test data; avoid wall-clock flakiness and shared mutable fixtures.
|
|
15
|
+
- Do **not** use browser/Playwright tooling in this preset (`preset-no-cross-stack-leakage`).
|
|
15
16
|
|
|
16
17
|
## Placement
|
|
17
18
|
|
|
18
|
-
- `e2e/` package or `*_e2e_test.go` with build tags if
|
|
19
|
+
- `e2e/` package or `*_e2e_test.go` with build tags if the repo already separates smoke CI.
|
|
20
|
+
- If smoke overlaps repository contracts, put the contract under `tests-integration` instead.
|
|
@@ -5,19 +5,25 @@ paths:
|
|
|
5
5
|
- **/*_integration_test.go
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
# Integration tests
|
|
10
9
|
|
|
11
10
|
- Exercise driven adapters against real infra doubles (testcontainers, docker compose test DB, miniredis, etc.).
|
|
12
11
|
- Or exercise HTTP adapter with `httptest` + wired use case + fake/real ports — still no full prod cluster required.
|
|
13
|
-
- Build tags (`//go:build integration`)
|
|
14
|
-
- Keep fixtures deterministic; clean up data between tests.
|
|
12
|
+
- Build tags (`//go:build integration`) when the repo separates CI jobs — discover the existing CI entrypoint; do not invent a second runner.
|
|
13
|
+
- Keep fixtures deterministic; clean up / isolate data between tests (truncate, transaction rollback, or unique prefixes).
|
|
15
14
|
|
|
16
15
|
## Scope
|
|
17
16
|
|
|
18
|
-
- Contract of a port implementation (repo save/load
|
|
19
|
-
-
|
|
17
|
+
- **Contract of a port implementation** (repo save/load/error round-trip) — assert semantics at the port, not only SQL rows.
|
|
18
|
+
- HTTP adapter contract with `httptest` is valid **adapter** integration — it is **not** a substitute for a repository contract test.
|
|
19
|
+
- Not a substitute for domain unit tests (table-driven domain logic stays in `tests-unit`).
|
|
20
|
+
|
|
21
|
+
## Forbidden shortcuts
|
|
22
|
+
|
|
23
|
+
- Fake-only “integration” that never crosses the adapter↔infra boundary for the port under test.
|
|
24
|
+
- Skipping isolation so tests pass only in isolation or only on a dirty DB.
|
|
20
25
|
|
|
21
26
|
## Agents
|
|
22
27
|
|
|
23
28
|
- Planning/generation: `integration-test-{planner,generator,healer}` + skill `integration-testing`.
|
|
29
|
+
- After green tests: `post-change-test` (+ `go-tooling`).
|
|
@@ -22,7 +22,7 @@ paths:
|
|
|
22
22
|
|
|
23
23
|
**Claude Option A (README exclusion):** when counting Claude rules without `paths:` / session-start, **exclude `**/README.md`** (topic indexes are not session-start rules). The intended session-start trio remains **exactly 3**; body budget sums **only those 3** rules.
|
|
24
24
|
|
|
25
|
-
Session-start body budget (где задокументировано): ≤
|
|
25
|
+
Session-start body budget (где задокументировано): ≤140 строк суммарно (stretch ≤120).
|
|
26
26
|
|
|
27
27
|
## Meta / author rules
|
|
28
28
|
|
|
@@ -6,17 +6,29 @@ paths:
|
|
|
6
6
|
- **/config/**/*
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
# Security (Go)
|
|
11
10
|
|
|
12
|
-
- Secrets from env/secret manager — never commit keys;
|
|
11
|
+
- Secrets from env/secret manager — never commit keys; **never log** tokens, passwords, raw `Authorization` headers, or cookie values.
|
|
13
12
|
- Validate and canonicalize untrusted input at the driving adapter edge.
|
|
14
13
|
- Prefer prepared statements / parameterized queries in persistence adapters.
|
|
15
14
|
- TLS and secure cookie/header defaults when exposing HTTP.
|
|
16
15
|
- AuthN/AuthZ in middleware or driving adapters; pass identity into use cases as domain value (user ID / claims), not raw headers.
|
|
17
|
-
- Minimize PII in logs; redact
|
|
16
|
+
- Minimize PII in structured logs; redact known sensitive fields by default.
|
|
18
17
|
|
|
19
18
|
## Config
|
|
20
19
|
|
|
21
|
-
- Distinguish public vs secret config fields in types.
|
|
22
|
-
- Fail closed when auth is misconfigured in production builds.
|
|
20
|
+
- Distinguish public vs secret config fields in types (separate structs or tagged fields).
|
|
21
|
+
- **Fail closed** when auth is misconfigured in production builds (missing issuer/JWKS/secret → refuse to start or reject requests).
|
|
22
|
+
- Sample configs and README snippets must use placeholders — never real-looking secrets.
|
|
23
|
+
|
|
24
|
+
## Forbidden
|
|
25
|
+
|
|
26
|
+
- Hardcoded API keys/tokens in source or committed `.env` examples with live values.
|
|
27
|
+
- Logging request/response bodies that may contain credentials without an explicit redact step.
|
|
28
|
+
- Fail-open auth middleware when required validators are nil/empty in prod.
|
|
29
|
+
|
|
30
|
+
## Tests
|
|
31
|
+
|
|
32
|
+
- Negative assertions: logs/metrics fixtures must not contain bearer tokens or secret config values.
|
|
33
|
+
- Missing/invalid auth config fails closed in a construction or middleware test.
|
|
34
|
+
- Agents: `security-reviewer` on auth/config/logging changes; then `post-change-test`.
|
|
@@ -29,7 +29,7 @@ npx @bonesofspring/ai-rules init claude --preset ios-swift
|
|
|
29
29
|
|
|
30
30
|
## Session-start (= Cursor alwaysApply)
|
|
31
31
|
|
|
32
|
-
Ровно **3** файла без `paths:`: `stack/ios-app-core.md`, `architecture/boundaries.md`, `tooling-and-review/code-quality.md`. Бюджет тела ≤
|
|
32
|
+
Ровно **3** файла без `paths:`: `stack/ios-app-core.md`, `architecture/boundaries.md`, `tooling-and-review/code-quality.md`. Бюджет тела ≤140 строк суммарно.
|
|
33
33
|
|
|
34
34
|
## Parity with Cursor
|
|
35
35
|
|
|
@@ -38,7 +38,7 @@ When validating **ios-swift preset** changes (or `scope: preset-structure-valida
|
|
|
38
38
|
6. **Twin presence (hard):** Cursor rule change → Claude twin same PR — **FAIL** if missing (next, ios-swift, go, and java).
|
|
39
39
|
7. **Mapping / README:** Cursor→Claude mapping table present; core→stack mapping when `_shared` consumers exist.
|
|
40
40
|
8. **shared-core consumers:** if `_shared/core/**` changed, update all `<!-- shared-core: … -->` consumers (or document intentional fork).
|
|
41
|
-
9. **Session-start body budget:** sum of the **3** intended session-start rule bodies ≤ **
|
|
41
|
+
9. **Session-start body budget:** sum of the **3** intended session-start rule bodies ≤ **140** lines (stretch ≤120); do **not** include `**/README.md` — record in report.
|
|
42
42
|
10. **Embed drift (hard in `check:preset-structure`):** `packages/ai-rules/scripts/check-shared-core-drift.sh` with `AI_RULES_DRIFT_FAIL=1`.
|
|
43
43
|
11. **Dogfood (monorepo soft):** `packages/ai-rules/scripts/sync-dogfood-cursor.sh`; mass deletion without migration doc → risk / FAIL for maintainers.
|
|
44
44
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
## Loading budget
|
|
15
15
|
|
|
16
|
-
- **Session-start (no `paths:`):** ровно **3** — `ios-app-core`, `boundaries`, `code-quality` (≤
|
|
16
|
+
- **Session-start (no `paths:`):** ровно **3** — `ios-app-core`, `boundaries`, `code-quality` (≤140 body lines total)
|
|
17
17
|
- **Все остальные** — с `paths:` (commands/team/agents и/или Feature/Swift globs)
|
|
18
18
|
- **Soft twin depth:** domain rules ≥15 body lines; thin aliases (`agent-team-intake`, `technical-retro`) могут быть короче (как next)
|
|
19
19
|
|
|
@@ -22,7 +22,7 @@ paths:
|
|
|
22
22
|
|
|
23
23
|
**Claude Option A (README exclusion):** when counting Claude rules without `paths:` / session-start, **exclude `**/README.md`** (topic indexes are not session-start rules). The intended session-start trio remains **exactly 3**; body budget sums **only those 3** rules.
|
|
24
24
|
|
|
25
|
-
Session-start body budget (где задокументировано): ≤
|
|
25
|
+
Session-start body budget (где задокументировано): ≤140 строк суммарно (stretch ≤120).
|
|
26
26
|
|
|
27
27
|
## Meta / author rules
|
|
28
28
|
|
|
@@ -30,7 +30,7 @@ Hard gates for the **java** stack:
|
|
|
30
30
|
| Gate | FAIL when |
|
|
31
31
|
|------|-----------|
|
|
32
32
|
| **twin-map** | `java` missing from `STACKS`, or Cursor↔Claude orphan/missing twins |
|
|
33
|
-
| **token-budget** | Cursor `alwaysApply` ≠ 3 or Claude session-start (excl. README) ≠ 3, or trio body sum >
|
|
33
|
+
| **token-budget** | Cursor `alwaysApply` ≠ 3 or Claude session-start (excl. README) ≠ 3, or trio body sum > 140 |
|
|
34
34
|
| **leakage** | `JAVA_FORBIDDEN_*` hits (Playwright/XCUITest/`lint:js`/`accessibility-reviewer` as required handoffs) |
|
|
35
35
|
| **chain fork** | `hooks/chain-team-phases.sh` byte-identical to **next**, **ios-swift**, or **go** (same platform) |
|
|
36
36
|
|
|
@@ -14,7 +14,7 @@ Claude topic `.md` files are **derived** from Cursor SoT `presets/cursor/java/ru
|
|
|
14
14
|
|
|
15
15
|
- **Session-start (no `paths:`):** exactly **3** — `java-app-core`, `boundaries`, `code-quality`
|
|
16
16
|
- All others — with `paths:`
|
|
17
|
-
- **Twin depth:** domain rules target ≥15 body lines; thin aliases: `agent-team-intake`, `technical-retro`; **documented
|
|
17
|
+
- **Twin depth:** domain rules target ≥15 body lines; thin aliases: `agent-team-intake`, `technical-retro`; **documented stub** (v1): `api-grpc`; `messaging-adapters` is **full** — see Cursor `presets/cursor/java/rules/README.md` Catalog (Depth column)
|
|
18
18
|
|
|
19
19
|
## Cursor → Claude mapping
|
|
20
20
|
|
|
@@ -6,19 +6,26 @@ paths:
|
|
|
6
6
|
- "**/adapters/messaging/**/*"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
# Messaging adapters
|
|
9
|
+
# Messaging adapters
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- Idempotency keys and retry/DLQ are adapter concerns; document at-least-once assumptions.
|
|
16
|
-
- Do not put broker client types (`KafkaTemplate`, JMS sessions, etc.) in domain or application signatures.
|
|
11
|
+
- **Publisher** (driven): implements an outbound port; serializes application/domain events to wire format inside the adapter.
|
|
12
|
+
- **Consumer** (driving): deserializes → maps to application/domain types → calls inbound port / use case; **ack/nack** (and commit) stays in the adapter.
|
|
13
|
+
- Idempotency keys, retry, and DLQ/parking-lot policy are adapter (or infra) concerns — document at-least-once vs exactly-once assumptions at the port.
|
|
14
|
+
- Use the broker client already present in the repo (`KafkaTemplate`, JMS, Spring Cloud Stream, etc.) — do not invent a second stack.
|
|
17
15
|
|
|
18
16
|
## Event shapes
|
|
19
17
|
|
|
20
|
-
- Prefer explicit event types in application or a small `events` package used by ports
|
|
18
|
+
- Prefer explicit event types in application or a small `events` package used by ports.
|
|
19
|
+
- Map wire DTOs ↔ application events **only** in the adapter; never pass `ConsumerRecord` / broker payloads into domain.
|
|
20
|
+
|
|
21
|
+
## Forbidden
|
|
22
|
+
|
|
23
|
+
- Broker client types (`KafkaTemplate`, JMS sessions, `MessageListener`) in domain or application signatures.
|
|
24
|
+
- Business rules inside listeners beyond mapping + calling one use case.
|
|
25
|
+
- Silent catch-and-ack that drops poison messages without DLQ/metrics policy.
|
|
21
26
|
|
|
22
27
|
## Tests
|
|
23
28
|
|
|
24
|
-
- Unit-test mapping
|
|
29
|
+
- Unit-test mapping and idempotency branches with fakes.
|
|
30
|
+
- Integration against embedded broker / Testcontainers **when the repo already has that setup**.
|
|
31
|
+
- After edits: `post-change-test` (+ `java-tooling`); agents `integration-test-*` when adding consumer contracts.
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
description: Hexagonal layer boundaries for Java backends (domain, application, ports, adapters)
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
# Границы слоёв (hexagonal)
|
|
7
6
|
|
|
8
7
|
- **Domain** (`**/domain`):
|
|
@@ -23,6 +22,12 @@ description: Hexagonal layer boundaries for Java backends (domain, application,
|
|
|
23
22
|
- Domain never imports adapters or frameworks.
|
|
24
23
|
- Cross-feature access — only via public ports / module API, not deep imports of another feature's internals.
|
|
25
24
|
|
|
25
|
+
# Edit bundles (load on matching paths)
|
|
26
|
+
|
|
27
|
+
- `**/domain/**` → `domain-layer`; `**/application/**` → `application-usecases` + `ports-interfaces`
|
|
28
|
+
- Inbound HTTP/gRPC → `adapters-driving` + `api-http` / `api-grpc`; outbound persistence/messaging → `adapters-driven` + matching `*-adapters`
|
|
29
|
+
- `**/configuration/**`, `*Application.java` → `composition-root`; after `*.java` edits → `post-change-test` (+ `java-tooling`)
|
|
30
|
+
|
|
26
31
|
# Требование к агенту
|
|
27
32
|
|
|
28
33
|
- Класть файлы в правильный слой; не «коротить» слои ради скорости.
|
|
@@ -22,7 +22,7 @@ paths:
|
|
|
22
22
|
|
|
23
23
|
**Claude Option A (README exclusion):** when counting Claude rules without `paths:` / session-start, **exclude `**/README.md`** (topic indexes are not session-start rules). The intended session-start trio remains **exactly 3**; body budget sums **only those 3** rules.
|
|
24
24
|
|
|
25
|
-
Session-start body budget (где задокументировано): ≤
|
|
25
|
+
Session-start body budget (где задокументировано): ≤140 строк суммарно (stretch ≤120).
|
|
26
26
|
|
|
27
27
|
## Meta / author rules
|
|
28
28
|
|
|
@@ -36,7 +36,7 @@ When validating **preset packaging** changes (paths under `packages/ai-rules/pre
|
|
|
36
36
|
3. **Mapping / README:** `rules/README.md` must include a Cursor→Claude mapping table; document core→stack mapping when `_shared` consumers exist.
|
|
37
37
|
4. **shared-core consumers:** if `_shared/core/**` changed, every file with matching `<!-- shared-core: … -->` in this PR must be updated (or intentional fork documented).
|
|
38
38
|
5. **Twin presence:** Cursor rule change without Claude twin same PR → **FAIL** (next, ios-swift, go, and java). Domain twin body ≥15 lines; thin aliases may be shorter.
|
|
39
|
-
6. **Session-start body budget:** sum body lines of the **3** intended session-start rules ≤ **
|
|
39
|
+
6. **Session-start body budget:** sum body lines of the **3** intended session-start rules ≤ **140** (stretch ≤120); do **not** include `**/README.md` — record in validation-report; FAIL if grossly over.
|
|
40
40
|
7. **Embed drift (hard in `check:preset-structure`):** run `packages/ai-rules/scripts/check-shared-core-drift.sh` with `AI_RULES_DRIFT_FAIL=1` (bundled by the structure orchestrator). Lineage stems excluded from body equality.
|
|
41
41
|
8. **Dogfood (monorepo soft):** prefer `packages/ai-rules/scripts/sync-dogfood-cursor.sh`; mass dogfood deletion without migration doc → risk / FAIL for maintainers.
|
|
42
42
|
|
|
@@ -22,7 +22,7 @@ paths:
|
|
|
22
22
|
|
|
23
23
|
**Claude Option A (README exclusion):** when counting Claude rules without `paths:` / session-start, **exclude `**/README.md`** (topic indexes are not session-start rules). The intended session-start trio remains **exactly 3**; body budget sums **only those 3** rules.
|
|
24
24
|
|
|
25
|
-
Session-start body budget (где задокументировано): ≤
|
|
25
|
+
Session-start body budget (где задокументировано): ≤140 строк суммарно (stretch ≤120).
|
|
26
26
|
|
|
27
27
|
## Meta / author rules
|
|
28
28
|
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
| `architecture-boundaries` | Hexagonal invariants |
|
|
9
9
|
| `code-quality-and-refactoring` | Shared quality + Go notes |
|
|
10
10
|
|
|
11
|
-
**Session-start body budget:** sum of the 3 always-on bodies ≤ **
|
|
11
|
+
**Session-start body budget:** sum of the 3 always-on bodies ≤ **140** lines (stretch ≤120).
|
|
12
12
|
|
|
13
13
|
## Twin depth (Cursor↔Claude)
|
|
14
14
|
|
|
15
15
|
- **Domain** rules: target ≥15 non-empty body lines (FAIL soft when undocumented stubs).
|
|
16
16
|
- **Thin aliases** (may be shorter): `agent-team-intake`, `technical-retro`.
|
|
17
|
-
- **Documented stubs** (checklist-style, expand in consumer Stack notes / target repo): see Catalog **Depth** column (`stub`). High-traffic stems (`domain-layer`, `ports-interfaces`, `adapters-*`, `post-change-test`, `go-tooling`) are expanded to **full** depth.
|
|
17
|
+
- **Documented stubs** (checklist-style, expand in consumer Stack notes / target repo): see Catalog **Depth** column (`stub`). High-traffic stems (`domain-layer`, `ports-interfaces`, `adapters-*`, `application-usecases`, `composition-root`, `persistence-adapters`, `tests-integration`, `security-go`, `post-change-test`, `go-tooling`) are expanded to **full** depth.
|
|
18
18
|
|
|
19
19
|
## Loading strategy
|
|
20
20
|
|
|
@@ -71,21 +71,21 @@ Claude twins + Cursor→Claude map: `presets/claude/go/rules/README.md`. Cross-s
|
|
|
71
71
|
| `technical-retro` | thin-alias | |
|
|
72
72
|
| `api-grpc` | stub | optional transport; expand when repo uses gRPC |
|
|
73
73
|
| `domain-layer` | full | high-traffic hexagonal |
|
|
74
|
-
| `application-usecases` |
|
|
74
|
+
| `application-usecases` | full | use-case ports, Forbidden, unit via fakes |
|
|
75
75
|
| `ports-interfaces` | full | high-traffic hexagonal |
|
|
76
76
|
| `adapters-driven` | full | high-traffic hexagonal |
|
|
77
77
|
| `adapters-driving` | full | high-traffic hexagonal |
|
|
78
|
-
| `composition-root` |
|
|
78
|
+
| `composition-root` | full | wire order, shutdown, construction smoke |
|
|
79
79
|
| `api-http` | full | thin handlers, resilience, idempotency/bulkhead |
|
|
80
|
-
| `persistence-adapters` |
|
|
80
|
+
| `persistence-adapters` | full | port contract, no `*sql.DB` leak |
|
|
81
81
|
| `messaging-adapters` | stub | |
|
|
82
82
|
| `module-public-api` | stub | |
|
|
83
83
|
| `go-conventions` | full | errors, interfaces at call site, anti-hallucination |
|
|
84
84
|
| `go-tooling` | full | requestable toolchain |
|
|
85
85
|
| `post-change-test` | full | requestable gate |
|
|
86
|
-
| `security-go` |
|
|
86
|
+
| `security-go` | full | redact, fail-closed auth, secret tests |
|
|
87
87
|
| `tests-unit` | stub | |
|
|
88
|
-
| `tests-integration` |
|
|
89
|
-
| `tests-e2e` | stub |
|
|
88
|
+
| `tests-integration` | full | repo contract vs httptest; isolation |
|
|
89
|
+
| `tests-e2e` | stub | scoped smoke banner; prefer integration-test-* |
|
|
90
90
|
|
|
91
91
|
**Всего topic `.mdc`:** 27 domain + 5 preset-meta (без README) = 32.
|
|
@@ -6,25 +6,29 @@ globs:
|
|
|
6
6
|
alwaysApply: false
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
# Application / use cases
|
|
11
10
|
|
|
12
11
|
- One use case ≈ one application service method (command/query).
|
|
13
12
|
- Depend on **outbound ports** (interfaces), not concrete repos/clients.
|
|
14
13
|
- Orchestrate domain; transaction boundaries via ports (`UnitOfWork`) when needed — still no SQL here.
|
|
15
14
|
- Accept `context.Context` on public methods; propagate to ports.
|
|
15
|
+
- Input/output types stay in application or domain — never handler DTOs, `http.Request`, or SQL row types.
|
|
16
16
|
|
|
17
17
|
## Forbidden
|
|
18
18
|
|
|
19
|
-
- Importing `adapters/*`, SQL drivers, HTTP frameworks.
|
|
20
|
-
- Embedding `*sql.DB`, Redis clients, or handler types in use-case structs.
|
|
21
|
-
- Business rules that belong in domain entities (keep use cases thin).
|
|
19
|
+
- Importing `adapters/*`, SQL drivers, HTTP/gRPC frameworks, broker clients.
|
|
20
|
+
- Embedding `*sql.DB`, Redis/Kafka clients, or handler types in use-case structs.
|
|
21
|
+
- Business rules that belong in domain entities (keep use cases thin orchestrators).
|
|
22
|
+
- Starting DB transactions with concrete `*sql.Tx` — call a port (`UnitOfWork` / `Transactional`).
|
|
22
23
|
|
|
23
24
|
## Structure
|
|
24
25
|
|
|
25
26
|
- Prefer `application/<usecase>.go` + `ports.go` (or `ports/`) colocated.
|
|
26
27
|
- Inbound port = interface the driving adapter calls (optional if use-case struct is the API).
|
|
28
|
+
- Map transport/persistence errors at adapters; use cases return domain/application errors.
|
|
27
29
|
|
|
28
30
|
## Tests
|
|
29
31
|
|
|
30
|
-
-
|
|
32
|
+
- Fake/mock **outbound ports** only; assert domain outcomes and port interactions — no real DB.
|
|
33
|
+
- Table-driven cases for validation/branching; inject clock/ID seams when time/IDs matter.
|
|
34
|
+
- After edits: `post-change-test` (+ `go-tooling`).
|
|
@@ -24,6 +24,12 @@ alwaysApply: true
|
|
|
24
24
|
- Domain never imports adapters or frameworks.
|
|
25
25
|
- Cross-feature access — only via public ports / `pkg` API, not deep imports of another feature's internals.
|
|
26
26
|
|
|
27
|
+
# Edit bundles (load on matching paths)
|
|
28
|
+
|
|
29
|
+
- `**/domain/**` → `domain-layer`; `**/application/**` → `application-usecases` + `ports-interfaces`
|
|
30
|
+
- Driving HTTP/gRPC → `adapters-driving` + `api-http` / `api-grpc`; persistence/messaging → `adapters-driven` + matching `*-adapters`
|
|
31
|
+
- `cmd/**`, `internal/app/**` → `composition-root`; after `*.go` edits → `post-change-test` (+ `go-tooling`)
|
|
32
|
+
|
|
27
33
|
# Требование к агенту
|
|
28
34
|
|
|
29
35
|
- Класть файлы в правильный слой; не «коротить» слои ради скорости.
|
|
@@ -6,24 +6,29 @@ globs:
|
|
|
6
6
|
alwaysApply: false
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
# Composition root
|
|
11
10
|
|
|
12
|
-
- Construct adapters
|
|
13
|
-
- Wire interfaces to implementations explicitly (manual DI preferred unless repo already uses a container).
|
|
14
|
-
- Load config once; fail fast on missing required settings.
|
|
15
|
-
- Lifecycle:
|
|
11
|
+
- Construct adapters → use cases → servers in `cmd/<service>` and/or `internal/app`.
|
|
12
|
+
- Wire interfaces to implementations explicitly (manual DI preferred unless the repo already uses a container).
|
|
13
|
+
- Load config once; **fail fast** on missing required settings before opening listeners or connections.
|
|
14
|
+
- Lifecycle: cancel root `context` → drain in-flight work → `Shutdown` servers → close driven adapters (DB/pool/clients) in reverse wire order.
|
|
16
15
|
|
|
17
16
|
## Allowed here
|
|
18
17
|
|
|
19
|
-
- Import all layers for wiring only
|
|
20
|
-
- Process-wide loggers/metrics providers.
|
|
18
|
+
- Import all layers **for wiring only**.
|
|
19
|
+
- Process-wide loggers/metrics providers constructed once and injected.
|
|
21
20
|
|
|
22
21
|
## Forbidden
|
|
23
22
|
|
|
24
23
|
- Business rules, SQL queries, HTTP routing tables with domain logic.
|
|
25
|
-
- Global mutable singletons for repos without clear init (prefer explicit deps).
|
|
24
|
+
- Global mutable singletons for repos without clear init (prefer explicit constructor deps).
|
|
25
|
+
- Starting background workers without tying them to the root context / shutdown path.
|
|
26
|
+
|
|
27
|
+
## Agent handoffs
|
|
28
|
+
|
|
29
|
+
- After wiring changes: `post-change-test` (+ `go-tooling`) — at least compile / construction smoke.
|
|
30
|
+
- Layer checklist: `feature-delivery-workflow` (domain → ports → adapters → wire).
|
|
26
31
|
|
|
27
32
|
## Tests
|
|
28
33
|
|
|
29
|
-
- Optional smoke that wiring builds
|
|
34
|
+
- Optional construction/smoke test that `NewApp`/`main` wiring builds; heavy logic stays in unit/integration tests.
|
|
@@ -6,24 +6,27 @@ globs:
|
|
|
6
6
|
alwaysApply: false
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
# Persistence adapters
|
|
11
10
|
|
|
12
11
|
- Implement outbound repository ports from application.
|
|
13
|
-
- Use parameterized queries; map rows → domain entities inside the adapter.
|
|
12
|
+
- Use **parameterized** queries; map rows → domain entities **inside** the adapter.
|
|
14
13
|
- Transactions: expose via port (`Transactional`, `UnitOfWork`) implemented here — use cases call the port, not `*sql.Tx` directly.
|
|
15
|
-
- Migrations live with infra (separate package/dir) — not in domain.
|
|
14
|
+
- Migrations live with infra (separate package/dir) — not in domain or application.
|
|
16
15
|
|
|
17
16
|
## Mapping
|
|
18
17
|
|
|
19
18
|
- Persistence models (db tags) stay private to the adapter package when possible.
|
|
20
|
-
- Nullability and DB defaults
|
|
19
|
+
- Nullability, zero values, and DB defaults convert to domain values explicitly (no silent zero-value domain objects).
|
|
20
|
+
- Port methods return domain/application errors — never leak driver-specific types through the port.
|
|
21
21
|
|
|
22
22
|
## Forbidden
|
|
23
23
|
|
|
24
|
-
- Importing persistence from domain or leaking `*sql.DB` through port APIs.
|
|
25
|
-
- Building SQL strings in use cases.
|
|
24
|
+
- Importing persistence from domain or leaking `*sql.DB` / ORM handles through port APIs.
|
|
25
|
+
- Building SQL strings in use cases or handlers.
|
|
26
|
+
- Returning scan structs / `sql.Null*` types across the port boundary.
|
|
26
27
|
|
|
27
28
|
## Tests
|
|
28
29
|
|
|
29
|
-
- Integration
|
|
30
|
+
- Integration: repository **contract** round-trip (save → load → error/not-found) against testcontainers / repo-standard test DB.
|
|
31
|
+
- Unit-test mappers with fixtures; do **not** substitute `httptest` for a repository contract.
|
|
32
|
+
- Agents: `integration-test-{planner,generator,healer}` + skill `integration-testing`; then `post-change-test`.
|
|
@@ -22,7 +22,7 @@ alwaysApply: false
|
|
|
22
22
|
|
|
23
23
|
**Claude Option A (README exclusion):** when counting Claude rules without `paths:` / session-start, **exclude `**/README.md`** (topic indexes are not session-start rules). The intended session-start trio remains **exactly 3**; body budget sums **only those 3** rules.
|
|
24
24
|
|
|
25
|
-
Session-start body budget (где задокументировано): ≤
|
|
25
|
+
Session-start body budget (где задокументировано): ≤140 строк суммарно (stretch ≤120).
|
|
26
26
|
|
|
27
27
|
## Meta / author rules
|
|
28
28
|
|
|
@@ -7,17 +7,29 @@ globs:
|
|
|
7
7
|
alwaysApply: false
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
# Security (Go)
|
|
12
11
|
|
|
13
|
-
- Secrets from env/secret manager — never commit keys;
|
|
12
|
+
- Secrets from env/secret manager — never commit keys; **never log** tokens, passwords, raw `Authorization` headers, or cookie values.
|
|
14
13
|
- Validate and canonicalize untrusted input at the driving adapter edge.
|
|
15
14
|
- Prefer prepared statements / parameterized queries in persistence adapters.
|
|
16
15
|
- TLS and secure cookie/header defaults when exposing HTTP.
|
|
17
16
|
- AuthN/AuthZ in middleware or driving adapters; pass identity into use cases as domain value (user ID / claims), not raw headers.
|
|
18
|
-
- Minimize PII in logs; redact
|
|
17
|
+
- Minimize PII in structured logs; redact known sensitive fields by default.
|
|
19
18
|
|
|
20
19
|
## Config
|
|
21
20
|
|
|
22
|
-
- Distinguish public vs secret config fields in types.
|
|
23
|
-
- Fail closed when auth is misconfigured in production builds.
|
|
21
|
+
- Distinguish public vs secret config fields in types (separate structs or tagged fields).
|
|
22
|
+
- **Fail closed** when auth is misconfigured in production builds (missing issuer/JWKS/secret → refuse to start or reject requests).
|
|
23
|
+
- Sample configs and README snippets must use placeholders — never real-looking secrets.
|
|
24
|
+
|
|
25
|
+
## Forbidden
|
|
26
|
+
|
|
27
|
+
- Hardcoded API keys/tokens in source or committed `.env` examples with live values.
|
|
28
|
+
- Logging request/response bodies that may contain credentials without an explicit redact step.
|
|
29
|
+
- Fail-open auth middleware when required validators are nil/empty in prod.
|
|
30
|
+
|
|
31
|
+
## Tests
|
|
32
|
+
|
|
33
|
+
- Negative assertions: logs/metrics fixtures must not contain bearer tokens or secret config values.
|
|
34
|
+
- Missing/invalid auth config fails closed in a construction or middleware test.
|
|
35
|
+
- Agents: `security-reviewer` on auth/config/logging changes; then `post-change-test`.
|
|
@@ -6,14 +6,16 @@ globs:
|
|
|
6
6
|
alwaysApply: false
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
# E2E / HTTP smoke
|
|
11
10
|
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
11
|
+
> **Documented stub / scoped smoke:** Prefer `tests-integration` + `integration-test-*` for breadth. Expand this rule only when the consumer repo keeps a dedicated black-box smoke suite.
|
|
12
|
+
|
|
13
|
+
- Black-box against a running server (`httptest` with full composition root, or localhost in CI).
|
|
14
|
+
- Cover critical paths only; prefer integration + unit for most coverage.
|
|
15
|
+
- Stable test data; avoid wall-clock flakiness and shared mutable fixtures.
|
|
16
|
+
- Do **not** use browser/Playwright tooling in this preset (`preset-no-cross-stack-leakage`).
|
|
16
17
|
|
|
17
18
|
## Placement
|
|
18
19
|
|
|
19
|
-
- `e2e/` package or `*_e2e_test.go` with build tags if
|
|
20
|
+
- `e2e/` package or `*_e2e_test.go` with build tags if the repo already separates smoke CI.
|
|
21
|
+
- If smoke overlaps repository contracts, put the contract under `tests-integration` instead.
|
|
@@ -6,19 +6,25 @@ globs:
|
|
|
6
6
|
alwaysApply: false
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
# Integration tests
|
|
11
10
|
|
|
12
11
|
- Exercise driven adapters against real infra doubles (testcontainers, docker compose test DB, miniredis, etc.).
|
|
13
12
|
- Or exercise HTTP adapter with `httptest` + wired use case + fake/real ports — still no full prod cluster required.
|
|
14
|
-
- Build tags (`//go:build integration`)
|
|
15
|
-
- Keep fixtures deterministic; clean up data between tests.
|
|
13
|
+
- Build tags (`//go:build integration`) when the repo separates CI jobs — discover the existing CI entrypoint; do not invent a second runner.
|
|
14
|
+
- Keep fixtures deterministic; clean up / isolate data between tests (truncate, transaction rollback, or unique prefixes).
|
|
16
15
|
|
|
17
16
|
## Scope
|
|
18
17
|
|
|
19
|
-
- Contract of a port implementation (repo save/load
|
|
20
|
-
-
|
|
18
|
+
- **Contract of a port implementation** (repo save/load/error round-trip) — assert semantics at the port, not only SQL rows.
|
|
19
|
+
- HTTP adapter contract with `httptest` is valid **adapter** integration — it is **not** a substitute for a repository contract test.
|
|
20
|
+
- Not a substitute for domain unit tests (table-driven domain logic stays in `tests-unit`).
|
|
21
|
+
|
|
22
|
+
## Forbidden shortcuts
|
|
23
|
+
|
|
24
|
+
- Fake-only “integration” that never crosses the adapter↔infra boundary for the port under test.
|
|
25
|
+
- Skipping isolation so tests pass only in isolation or only on a dirty DB.
|
|
21
26
|
|
|
22
27
|
## Agents
|
|
23
28
|
|
|
24
29
|
- Planning/generation: `integration-test-{planner,generator,healer}` + skill `integration-testing`.
|
|
30
|
+
- After green tests: `post-change-test` (+ `go-tooling`).
|
|
@@ -38,7 +38,7 @@ When validating **ios-swift preset** changes (or `scope: preset-structure-valida
|
|
|
38
38
|
6. **Twin presence (hard):** Cursor rule change → Claude twin present **same PR** — **FAIL** if missing (next, ios-swift, go, and java).
|
|
39
39
|
7. **Mapping / README:** `claude/ios-swift/rules/README.md` mapping table present; core→stack mapping documented when `_shared` consumers exist.
|
|
40
40
|
8. **shared-core consumers:** if `_shared/core/**` changed, every matching `<!-- shared-core: … -->` consumer in this PR must be updated (or intentional fork documented).
|
|
41
|
-
9. **Session-start body budget:** sum of the **3** intended always-on / session-start rule bodies ≤ **
|
|
41
|
+
9. **Session-start body budget:** sum of the **3** intended always-on / session-start rule bodies ≤ **140** lines (stretch ≤120); do **not** include `**/README.md` — record in report.
|
|
42
42
|
10. **Embed drift (hard in `check:preset-structure`):** `packages/ai-rules/scripts/check-shared-core-drift.sh` with `AI_RULES_DRIFT_FAIL=1`.
|
|
43
43
|
11. **Dogfood (monorepo soft):** `packages/ai-rules/scripts/sync-dogfood-cursor.sh`; mass deletion without migration doc → risk / FAIL for maintainers.
|
|
44
44
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
### Пресет ios-swift — карта правил
|
|
15
15
|
|
|
16
|
-
**alwaysApply budget:** **≤3** always-on правила и **≤
|
|
16
|
+
**alwaysApply budget:** **≤3** always-on правила и **≤140** строк тела (после YAML) суммарно (stretch ≤120). Новые alwaysApply только вместе с сокращением существующего бюджета.
|
|
17
17
|
|
|
18
18
|
| Файл | Скоуп | Тема |
|
|
19
19
|
|------|--------|------|
|
|
@@ -22,7 +22,7 @@ alwaysApply: false
|
|
|
22
22
|
|
|
23
23
|
**Claude Option A (README exclusion):** when counting Claude rules without `paths:` / session-start, **exclude `**/README.md`** (topic indexes are not session-start rules). The intended session-start trio remains **exactly 3**; body budget sums **only those 3** rules.
|
|
24
24
|
|
|
25
|
-
Session-start body budget (где задокументировано): ≤
|
|
25
|
+
Session-start body budget (где задокументировано): ≤140 строк суммарно (stretch ≤120).
|
|
26
26
|
|
|
27
27
|
## Meta / author rules
|
|
28
28
|
|
|
@@ -10,7 +10,7 @@ npx @bonesofspring/ai-rules init cursor --preset java
|
|
|
10
10
|
|
|
11
11
|
| Path | Role |
|
|
12
12
|
|------|------|
|
|
13
|
-
| `rules/*.mdc` | Cursor SoT (~32 stems); always-on trio ≤
|
|
13
|
+
| `rules/*.mdc` | Cursor SoT (~32 stems); always-on trio ≤140 lines |
|
|
14
14
|
| `agents/` | 21 agents + README (no a11y / Playwright / XCUITest) |
|
|
15
15
|
| `skills/` | 8 skills + README |
|
|
16
16
|
| `commands/` | 5 slash commands |
|
|
@@ -30,7 +30,7 @@ Hard gates for the **java** stack:
|
|
|
30
30
|
| Gate | FAIL when |
|
|
31
31
|
|------|-----------|
|
|
32
32
|
| **twin-map** | `java` missing from `STACKS`, or Cursor↔Claude orphan/missing twins |
|
|
33
|
-
| **token-budget** | Cursor `alwaysApply` ≠ 3 or Claude session-start (excl. README) ≠ 3, or trio body sum >
|
|
33
|
+
| **token-budget** | Cursor `alwaysApply` ≠ 3 or Claude session-start (excl. README) ≠ 3, or trio body sum > 140 |
|
|
34
34
|
| **leakage** | `JAVA_FORBIDDEN_*` hits (Playwright/XCUITest/`lint:js`/`accessibility-reviewer` as required handoffs) |
|
|
35
35
|
| **chain fork** | `hooks/chain-team-phases.sh` byte-identical to **next**, **ios-swift**, or **go** (same platform) |
|
|
36
36
|
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
| `architecture-boundaries` | Hexagonal invariants |
|
|
9
9
|
| `code-quality-and-refactoring` | Shared quality + Java notes |
|
|
10
10
|
|
|
11
|
-
**Session-start body budget:** sum of the 3 always-on bodies ≤ **
|
|
11
|
+
**Session-start body budget:** sum of the 3 always-on bodies ≤ **140** lines (stretch ≤120).
|
|
12
12
|
|
|
13
13
|
## Twin depth (Cursor↔Claude)
|
|
14
14
|
|
|
15
15
|
- **Domain** rules: target ≥15 non-empty body lines (FAIL soft when undocumented stubs).
|
|
16
16
|
- **Thin aliases** (may be shorter): `agent-team-intake`, `technical-retro`.
|
|
17
|
-
- **Documented stubs** (v1): `api-grpc
|
|
17
|
+
- **Documented stubs** (v1): `api-grpc` — catalog Depth=`stub`; body carries stub banner + when-to-use. `messaging-adapters` expanded to **full** for dogfood J3.
|
|
18
18
|
|
|
19
19
|
## Loading strategy
|
|
20
20
|
|
|
@@ -78,7 +78,7 @@ Claude twins + Cursor→Claude map: `presets/claude/java/rules/README.md`. Cross
|
|
|
78
78
|
| `composition-root` | full | Spring `@Configuration` + plain Java bootstrap |
|
|
79
79
|
| `api-http` | full | Spring MVC/Jakarta; DTO validation/mapping |
|
|
80
80
|
| `persistence-adapters` | full | JPA/JDBC; entities do not leak upward |
|
|
81
|
-
| `messaging-adapters` |
|
|
81
|
+
| `messaging-adapters` | full | publisher/consumer, idempotency, ack/DLQ |
|
|
82
82
|
| `module-public-api` | full | package/module boundaries |
|
|
83
83
|
| `java-conventions` | full | records, exceptions, naming, no invented APIs |
|
|
84
84
|
| `java-tooling` | full | requestable Maven/Gradle detect |
|
|
@@ -94,6 +94,6 @@ Claude twins + Cursor→Claude map: `presets/claude/java/rules/README.md`. Cross
|
|
|
94
94
|
|
|
95
95
|
- Spring Boot hexagonal = public default; plain Java / Quarkus / Micronaut / Jakarta = documented variants
|
|
96
96
|
- Layer-first single-module = default; multi-module = documented variant
|
|
97
|
-
- gRPC
|
|
97
|
+
- gRPC = documented stub in v1; messaging adapters = full (broker-agnostic)
|
|
98
98
|
- MCP = Context7 only
|
|
99
99
|
- Static analysis = discover from repo/CI (no mandated Checkstyle/SpotBugs/Error Prone)
|
|
@@ -24,6 +24,12 @@ alwaysApply: true
|
|
|
24
24
|
- Domain never imports adapters or frameworks.
|
|
25
25
|
- Cross-feature access — only via public ports / module API, not deep imports of another feature's internals.
|
|
26
26
|
|
|
27
|
+
# Edit bundles (load on matching paths)
|
|
28
|
+
|
|
29
|
+
- `**/domain/**` → `domain-layer`; `**/application/**` → `application-usecases` + `ports-interfaces`
|
|
30
|
+
- Inbound HTTP/gRPC → `adapters-driving` + `api-http` / `api-grpc`; outbound persistence/messaging → `adapters-driven` + matching `*-adapters`
|
|
31
|
+
- `**/configuration/**`, `*Application.java` → `composition-root`; after `*.java` edits → `post-change-test` (+ `java-tooling`)
|
|
32
|
+
|
|
27
33
|
# Требование к агенту
|
|
28
34
|
|
|
29
35
|
- Класть файлы в правильный слой; не «коротить» слои ради скорости.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Messaging driven/driving adapters for Java hexagonal services
|
|
2
|
+
description: Messaging driven/driving adapters for Java hexagonal services
|
|
3
3
|
globs:
|
|
4
4
|
- "**/adapters/outbound/messaging/**/*"
|
|
5
5
|
- "**/adapters/inbound/messaging/**/*"
|
|
@@ -7,20 +7,26 @@ globs:
|
|
|
7
7
|
alwaysApply: false
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
# Messaging adapters
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
- **Publisher** (driven): implements an outbound port; serializes application/domain events to wire format inside the adapter.
|
|
13
|
+
- **Consumer** (driving): deserializes → maps to application/domain types → calls inbound port / use case; **ack/nack** (and commit) stays in the adapter.
|
|
14
|
+
- Idempotency keys, retry, and DLQ/parking-lot policy are adapter (or infra) concerns — document at-least-once vs exactly-once assumptions at the port.
|
|
15
|
+
- Use the broker client already present in the repo (`KafkaTemplate`, JMS, Spring Cloud Stream, etc.) — do not invent a second stack.
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
## Event shapes
|
|
14
18
|
|
|
15
|
-
-
|
|
16
|
-
- **
|
|
17
|
-
- Idempotency keys and retry/DLQ are adapter concerns; document at-least-once assumptions.
|
|
18
|
-
- Do not put broker client types (`KafkaTemplate`, JMS sessions, etc.) in domain or application signatures.
|
|
19
|
+
- Prefer explicit event types in application or a small `events` package used by ports.
|
|
20
|
+
- Map wire DTOs ↔ application events **only** in the adapter; never pass `ConsumerRecord` / broker payloads into domain.
|
|
19
21
|
|
|
20
|
-
##
|
|
22
|
+
## Forbidden
|
|
21
23
|
|
|
22
|
-
-
|
|
24
|
+
- Broker client types (`KafkaTemplate`, JMS sessions, `MessageListener`) in domain or application signatures.
|
|
25
|
+
- Business rules inside listeners beyond mapping + calling one use case.
|
|
26
|
+
- Silent catch-and-ack that drops poison messages without DLQ/metrics policy.
|
|
23
27
|
|
|
24
28
|
## Tests
|
|
25
29
|
|
|
26
|
-
- Unit-test mapping
|
|
30
|
+
- Unit-test mapping and idempotency branches with fakes.
|
|
31
|
+
- Integration against embedded broker / Testcontainers **when the repo already has that setup**.
|
|
32
|
+
- After edits: `post-change-test` (+ `java-tooling`); agents `integration-test-*` when adding consumer contracts.
|
|
@@ -22,7 +22,7 @@ alwaysApply: false
|
|
|
22
22
|
|
|
23
23
|
**Claude Option A (README exclusion):** when counting Claude rules without `paths:` / session-start, **exclude `**/README.md`** (topic indexes are not session-start rules). The intended session-start trio remains **exactly 3**; body budget sums **only those 3** rules.
|
|
24
24
|
|
|
25
|
-
Session-start body budget (где задокументировано): ≤
|
|
25
|
+
Session-start body budget (где задокументировано): ≤140 строк суммарно (stretch ≤120).
|
|
26
26
|
|
|
27
27
|
## Meta / author rules
|
|
28
28
|
|
|
@@ -37,7 +37,7 @@ When validating **preset packaging** changes (paths under `packages/ai-rules/pre
|
|
|
37
37
|
3. **Mapping / README:** `claude/next/rules/README.md` must include a Cursor→Claude mapping table; stack `rules/README.md` should document core→stack mapping when `_shared` consumers exist.
|
|
38
38
|
4. **shared-core consumers:** if `_shared/core/**` changed, every file with matching `<!-- shared-core: … -->` in this PR must be updated (or intentional fork documented in validation-report).
|
|
39
39
|
5. **Twin presence:** Cursor rule change without Claude twin same PR → **FAIL** (next, ios-swift, go, and java). Domain twin body ≥15 lines; thin aliases (`agent-team-intake`, `technical-retro`) may be shorter.
|
|
40
|
-
6. **Session-start body budget (soft→document, FAIL if grossly over):** sum body lines of the **3** intended always-on / session-start rules ≤ **
|
|
40
|
+
6. **Session-start body budget (soft→document, FAIL if grossly over):** sum body lines of the **3** intended always-on / session-start rules ≤ **140** (stretch ≤120); do **not** include `**/README.md`. Record the sum in validation-report.
|
|
41
41
|
7. **Embed drift (hard in `check:preset-structure`):** run `packages/ai-rules/scripts/check-shared-core-drift.sh` with `AI_RULES_DRIFT_FAIL=1` (bundled by the structure orchestrator). Lineage stems are excluded from body equality.
|
|
42
42
|
8. **Dogfood (monorepo soft):** if root `.cursor/` is in the PR, prefer sync via `packages/ai-rules/scripts/sync-dogfood-cursor.sh`; mass deletion of tracked dogfood without migration doc → note as risk / FAIL for maintainers.
|
|
43
43
|
|
|
@@ -22,7 +22,7 @@ alwaysApply: false
|
|
|
22
22
|
|
|
23
23
|
**Claude Option A (README exclusion):** when counting Claude rules without `paths:` / session-start, **exclude `**/README.md`** (topic indexes are not session-start rules). The intended session-start trio remains **exactly 3**; body budget sums **only those 3** rules.
|
|
24
24
|
|
|
25
|
-
Session-start body budget (где задокументировано): ≤
|
|
25
|
+
Session-start body budget (где задокументировано): ≤140 строк суммарно (stretch ≤120).
|
|
26
26
|
|
|
27
27
|
## Meta / author rules
|
|
28
28
|
|