Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "archipy",
"source": ".",
"description": "Cursor and Claude Code plugin: rules, skills, agents, and hooks for building apps with ArchiPy",
"version": "0.21.0"
"version": "0.22.0"
}
]
}
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "archipy",
"version": "0.21.0",
"version": "0.22.0",
"description": "Cursor and Claude Code plugin: rules, skills, agents, and hooks for building apps with ArchiPy",
"author": {
"name": "SyntaxArc"
Expand Down
2 changes: 1 addition & 1 deletion .cursor-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "archipy",
"source": ".",
"description": "Cursor and Claude Code plugin: rules, skills, agents, and hooks for building apps with ArchiPy",
"version": "0.21.0"
"version": "0.22.0"
}
]
}
2 changes: 1 addition & 1 deletion .cursor-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "archipy",
"version": "0.21.0",
"version": "0.22.0",
"description": "Cursor and Claude Code plugin: rules, skills, agents, and hooks for building apps with ArchiPy",
"author": {
"name": "SyntaxArc"
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.22.0] - 2026-10-18

### Changed

- Rules, skills, the cheat sheet and `archipy-reviewer` follow ArchiPy 5.16: unit of work is
`postgres_sqlalchemy_atomic` (and the mysql/sqlite/starrocks/generic variants) imported from
`archipy.adapters.base.sqlalchemy.atomic`, and one name serves sync and async logics
- Decorator guidance uses the suffix-less names (`retry`, `timeout`, `timing`, `singleton`, `ttl_cache`,
`grpc_rate_limit`) and says that decorators detect `async def`
- FastAPI telemetry is installed with `archipy[otel,fastapi]`; the `otel-fastapi` extra no longer exists
- gRPC server metrics are `rpc.server.call.duration`
- Keycloak guards are `fastapi_auth` / `grpc_auth` from `archipy.adapters.keycloak.auth`; the actor is also readable
through `AuthContextManager`, not `request.state`
- `scaffold-observability` lists the OTel tuning options (sampler, B3 propagation, compression, batching, resource
detectors, standard `OTEL_*` variables)
- The cheat sheet is verified against `archipy` 5.16.x

### Added

- `archipy-reviewer` flags names deprecated in ArchiPy 5.10 to 5.16 (removed in 6.0.0), and dashboards still using the
old RPC metric names
- `scripts/check_catalog.py` rejects `otel-fastapi` and `KeycloakUtils` in the cheat sheet

## [0.21.0] - 2026-10-14

### Added
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ each workflow once.
| `scaffold-domain` | `/scaffold-domain` | Model + you | Full domain slice (models, repo, logic, service) |
| `scaffold-models` | `/scaffold-models` | Model + you | Domain/repository DTOs, errors, optional entities under `models/` |
| `scaffold-adapter` | `/scaffold-adapter` | Model + you | Domain adapter under `repositories/{domain}/adapters/` |
| `scaffold-logic` | `/scaffold-logic` | Model + you | Use-case under `logics/{domain}/` with `*_sqlalchemy_atomic_decorator` |
| `scaffold-logic` | `/scaffold-logic` | Model + you | Use-case under `logics/{domain}/` with `*_sqlalchemy_atomic` |
| `scaffold-service` | `/scaffold-service` | Model + you | Thin FastAPI/gRPC service under `services/{domain}/v{n}/` |
| `scaffold-bdd` | `/scaffold-bdd` | Model + you | Behave tests via REST/gRPC + testcontainers |
| `scaffold-utils` | `/scaffold-utils` | Model + you | Wire or create `helpers/utils` |
Expand Down Expand Up @@ -202,7 +202,7 @@ the layer-producing scaffold skills run it in their `## Verify` step. Claude Cod

### `/scaffold-decorator`

- **Purpose:** Prefer ArchiPy decorators (`ttl_cache_decorator`, `postgres_sqlalchemy_atomic_decorator`,
- **Purpose:** Prefer ArchiPy decorators (`ttl_cache`, `postgres_sqlalchemy_atomic`,
`trace_span` / `trace_root`, `measure_duration` / `count_calls`, …).
- **Asks:** Purpose; sync/async; built-in vs custom.
- **Outcome:** Usage snippet or `helpers/decorators/<name>.py` with example.
Expand Down Expand Up @@ -276,7 +276,7 @@ Pure utilities; prefer ArchiPy utils. **AppUtils** for FastAPI/gRPC factories.

Prefer ArchiPy decorators; UoW decorators belong on **logics**.

- **Do:** Preserve wrapped signatures (`functools.wraps`); use `postgres_sqlalchemy_atomic_decorator` on logics.
- **Do:** Preserve wrapped signatures (`functools.wraps`); use `postgres_sqlalchemy_atomic` on logics.
- **Don’t:** Construct adapters inside decorator modules.

### `using-archipy-interceptors`
Expand Down Expand Up @@ -311,7 +311,7 @@ Domain data access; adapters under `repositories/{domain}/adapters/`.

Business rules + unit of work; domain isolation.

- **Do:** Domain DTO in/out; `*_sqlalchemy_atomic_decorator` on public methods; call other logics for cross-domain.
- **Do:** Domain DTO in/out; `*_sqlalchemy_atomic` on public methods; call other logics for cross-domain.
- **Don’t:** Import another domain’s repository; import FastAPI/gRPC.

### `using-archipy-services`
Expand Down
15 changes: 12 additions & 3 deletions agents/archipy-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ makes it worse.

**Unit of work**

- Transactions use a real `*_sqlalchemy_atomic_decorator` on logics only: `postgres_sqlalchemy_atomic_decorator`
(or the sqlite/starrocks variant) for sync code, `async_postgres_sqlalchemy_atomic_decorator` for async. There is no
- Transactions use a real `*_sqlalchemy_atomic` on logics only: `postgres_sqlalchemy_atomic`
(or the mysql/sqlite/starrocks variant), which detects `async def` itself. There is no
decorator named `atomic`.
- A logic method that reads or writes through a SQLAlchemy-backed repository without an atomic decorator is a finding.
- Sync and async are not mixed within one class or one server.
Expand Down Expand Up @@ -126,7 +126,16 @@ makes it worse.

- On `archipy` 5.x, flag removed 4.x APIs and extras: `TracingUtils`, `PrometheusUtils`, `capture_span`,
`capture_transaction`, `FastAPIRateLimitConfig`, and the `sentry`, `elastic-apm`, `prometheus` extras. The 5.x
replacements are `OtelUtils`, `trace_span`, and the `otel`, `otel-fastapi`, `otel-grpc` extras.
replacements are `OtelUtils`, `trace_span`, and the `otel` and `otel-grpc` extras. FastAPI telemetry needs `archipy[otel,fastapi]`; there is no `otel-fastapi`
extra on 5.16+.
- On `archipy` 5.10+ flag deprecated names that warn today and are removed in 6.0.0 (**Should fix**, name the
replacement): `*_decorator` and `async_*` decorator names (`retry`, `timeout`, `timing`, `singleton`, `ttl_cache`,
`grpc_rate_limit`, `*_sqlalchemy_atomic`); on 5.16+ the atomic decorators imported from `archipy.helpers.decorators`
instead of `archipy.adapters.base.sqlalchemy.atomic`; `KeycloakUtils` and `archipy.helpers.utils.keycloak_utils`
instead of `fastapi_auth` / `grpc_auth` from `archipy.adapters.keycloak.auth`; reads of `request.state.user_info`,
`token_info`, `actor_chain` or `user_roles` instead of `AuthContextManager`.
- On `archipy` 5.16+ dashboards or alerts on `rpc.server.duration` / `rpc.server.request.duration` need
`rpc.server.call.duration` (attributes `rpc.system.name`, `rpc.response.status_code`, `error.type`).
- For any other API you are unsure exists in the pinned version, check the live docs
(https://syntaxarc.github.io/ArchiPy/) or the installed package (`.venv/lib/python*/site-packages/archipy/`) before
flagging it.
Expand Down
2 changes: 1 addition & 1 deletion evals/02-orders-postgres-domain/graders/layering.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
type: llm
focus: trace
---
- The unit of work is a real `*_sqlalchemy_atomic_decorator` (for example `postgres_sqlalchemy_atomic_decorator`) applied in `logics/`, not in services or repositories, and no decorator named plain `atomic` is used.
- The unit of work is a real `*_sqlalchemy_atomic` (for example `postgres_sqlalchemy_atomic`) applied in `logics/`, not in services or repositories, and no decorator named plain `atomic` is used.
- The service module only maps request DTOs to the logic and back; it contains no SQL or business rules.
- The logic module does not import FastAPI.
2 changes: 1 addition & 1 deletion evals/03-wallet-transfer-logic/graders/atomic-decorator.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
type: regex
target: trace
---
_sqlalchemy_atomic_decorator
_sqlalchemy_atomic
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
type: llm
focus: trace
---
- The transfer is wrapped in a single unit of work via a `*_sqlalchemy_atomic_decorator` on the logic method, so both balance updates commit or roll back together.
- The transfer is wrapped in a single unit of work via a `*_sqlalchemy_atomic` on the logic method, so both balance updates commit or roll back together.
- Insufficient balance raises a specific domain error (a subclass of an ArchiPy error), not a bare `Exception`.
- The logic calls repositories, not database sessions or adapters directly.
2 changes: 1 addition & 1 deletion evals/06-reviewer-violations/graders/catches-violations.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ focus: trace
- The review reports the untracked `adapters/payment_gateway.py` and says domain adapters belong under `repositories/payment/adapters/`, not a top-level `adapters/` package.
- The review flags the hardcoded `API_KEY` secret in `adapters/payment_gateway.py`.
- The review flags that `httpx` errors (for example from `raise_for_status`) leak raw instead of being mapped to a domain error with `raise ... from e`.
- The review flags `postgres_sqlalchemy_atomic_decorator` and the discount rule in `services/payment/v1/payment_router.py` as belonging in `logics/`.
- The review flags `postgres_sqlalchemy_atomic` and the discount rule in `services/payment/v1/payment_router.py` as belonging in `logics/`.
- The adapter, secret, and unit-of-work findings are ranked as must-fix (highest severity), not as optional suggestions.
4 changes: 2 additions & 2 deletions evals/06-reviewer-violations/scaffold.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ git -c user.name=eval -c user.email=eval@example.com commit -qm "baseline"

# Tracked, uncommitted: unit of work and business rule in the service layer.
cat > services/payment/v1/payment_router.py <<'PY'
from archipy.helpers.decorators.sqlalchemy_atomic import postgres_sqlalchemy_atomic_decorator
from archipy.adapters.base.sqlalchemy.atomic import postgres_sqlalchemy_atomic
from fastapi import APIRouter

from logics.payment.payment_logic import PaymentLogic
Expand All @@ -53,7 +53,7 @@ def create_payment_v1_router(logic: PaymentLogic) -> APIRouter:
router = APIRouter(prefix="/v1/payments")

@router.post("")
@postgres_sqlalchemy_atomic_decorator
@postgres_sqlalchemy_atomic
def charge(amount: int) -> dict[str, str]:
if amount > 10_000:
amount = int(amount * 0.95)
Expand Down
2 changes: 1 addition & 1 deletion evals/07-reviewer-clean-diff/graders/no-false-positives.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ focus: trace
---
- The review does not report any must-fix (highest severity) architecture violation for the wallet logic change.
- The review does not flag `WalletLogic` calling `NotificationLogic` as a violation; a logic calling another logic is allowed.
- The review does not flag `postgres_sqlalchemy_atomic_decorator` on `WalletLogic.withdraw` as misplaced.
- The review does not flag `postgres_sqlalchemy_atomic` on `WalletLogic.withdraw` as misplaced.
- It may note that the change has no Behave scenario, as long as that is not presented as a layer violation.
4 changes: 2 additions & 2 deletions evals/07-reviewer-clean-diff/scaffold.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class WithdrawOutputDTO(BaseDTO):
balance: int
PY
cat > logics/wallet/wallet_logic.py <<'PY'
from archipy.helpers.decorators.sqlalchemy_atomic import postgres_sqlalchemy_atomic_decorator
from archipy.adapters.base.sqlalchemy.atomic import postgres_sqlalchemy_atomic

from logics.notification.notification_logic import NotificationLogic
from models.dtos.wallet.domain.v1.wallet_dtos import WithdrawInputDTO, WithdrawOutputDTO
Expand All @@ -110,7 +110,7 @@ class WalletLogic:
self._repository = repository
self._notification_logic = notification_logic

@postgres_sqlalchemy_atomic_decorator
@postgres_sqlalchemy_atomic
def withdraw(self, input_dto: WithdrawInputDTO) -> WithdrawOutputDTO:
"""Withdraw credit, notifying when the balance runs low.

Expand Down
2 changes: 1 addition & 1 deletion evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pilot one case first (`--case 04-otel-question --runs 1`) to check cost. Results
|---|---|---|
| `01-redis-cache-adapter` | `scaffold-adapter` | adapter under `repositories/user/adapters/`, no top-level `adapters/`, wraps ArchiPy Redis, `raise ... from e` |
| `02-orders-postgres-domain` | `scaffold-domain` | logic + versioned service created, UoW only in logics |
| `03-wallet-transfer-logic` | `scaffold-logic` | `*_sqlalchemy_atomic_decorator` on the logic, domain error for insufficient funds |
| `03-wallet-transfer-logic` | `scaffold-logic` | `*_sqlalchemy_atomic` on the logic, domain error for insufficient funds |
| `04-otel-question` | `archipy-docs` | answer uses `OtelUtils` and `otel` extras, no removed 4.x APIs |
| `05-neg-unrelated-shell` | none | no plugin skill fires on an unrelated shell question |
| `06-reviewer-violations` | `archipy-reviewer` | catches untracked top-level adapter, hardcoded secret, leaked `httpx` errors, UoW in service; ranks them must-fix |
Expand Down
4 changes: 2 additions & 2 deletions rules/architecture-for-apps.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Optional app-local helpers (prefer `archipy.helpers` first): `helpers/{utils,dec
services → logics (atomic UoW) → repositories → adapters → ArchiPy
```

> Plugin shorthand `@atomic` means a real `*_sqlalchemy_atomic_decorator` — there is no decorator named `atomic`.
> Plugin shorthand `@atomic` means a real `*_sqlalchemy_atomic` — there is no decorator named `atomic`.

## Layer Rules

Expand All @@ -46,7 +46,7 @@ those files are open. This always-on rule keeps only the global map:
- **models/** — data only (no I/O, no business rules).
- **repositories/** — domain data access; adapters under `repositories/{domain}/adapters/`; no cross-domain repo calls.
Domain adapters map driver errors with `raise ... from e`; repository orchestrators consume domain-facing errors.
- **logics/** — business rules + UoW (`*_sqlalchemy_atomic_decorator`); may call other logics; never other domains'
- **logics/** — business rules + UoW (`*_sqlalchemy_atomic`); may call other logics; never other domains'
repositories; no FastAPI/gRPC.
- **services/** — thin transport; versioned `v{n}/`; no UoW / business rules.
- **helpers/** — pure only; prefer ArchiPy; no adapter construction at module level.
Expand Down
17 changes: 8 additions & 9 deletions rules/using-archipy-decorators.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ Helpers stay **pure**: no database calls, no network I/O, no constructing adapte

Before writing a custom decorator, prefer ArchiPy under `archipy.helpers.decorators`:

- `ttl_cache_decorator` — caching (`archipy.helpers.decorators.cache`)
- `ttl_cache` — caching (`archipy.helpers.decorators`)
- Unit of work (apply on **logics**, not repositories):
- `postgres_sqlalchemy_atomic_decorator`
- `async_postgres_sqlalchemy_atomic_decorator`
- also `sqlite_` / `starrocks_` / generic `sqlalchemy_atomic_decorator` twins
- `postgres_sqlalchemy_atomic` (detects `async def`), imported from `archipy.adapters.base.sqlalchemy.atomic`
- also `mysql_` / `sqlite_` / `starrocks_` / generic `sqlalchemy_atomic` variants
- Tracing: `trace_span`, `trace_root`, `async_trace_span`, `async_trace_root`, `trace_class`
- Metrics: `measure_duration`, `async_measure_duration`, `count_calls`, `async_count_calls`
- Local timing only: `timing_decorator`
- Resilience: `retry_decorator`, `timeout_decorator`
- Other: `singleton_decorator`, `grpc_rate_limit_decorator` (gRPC only)
- Local timing only: `timing`
- Resilience: `retry`, `timeout`
- Other: `singleton`, `grpc_rate_limit` (gRPC only)

## Custom Decorators

Expand All @@ -36,5 +35,5 @@ Before writing a custom decorator, prefer ArchiPy under `archipy.helpers.decorat

- Hide adapter construction inside decorator modules.
- Catch broad `Exception` without re-raising as a domain error with `raise ... from e`.
- Mix sync/async incorrectly — provide separate sync and async wrappers when needed.
- Put `@postgres_sqlalchemy_atomic_decorator` on repositories or services — UoW belongs on logics.
- Write separate sync and async copies of a decorator when one wrapper can detect `inspect.iscoroutinefunction`; ArchiPy's `retry`, `timeout`, `timing`, `ttl_cache` and `*_sqlalchemy_atomic` do.
- Put `@postgres_sqlalchemy_atomic` on repositories or services — UoW belongs on logics.
4 changes: 2 additions & 2 deletions rules/using-archipy-interceptors.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Use ArchiPy interceptors under `archipy.helpers.interceptors` (FastAPI / gRPC) b
Prefer **AppUtils** auto-registration for stock interceptors/middleware:

- FastAPI: `AppUtils.create_fastapi_app` wires middleware/exception handlers and instruments through
`archipy[otel-fastapi]` when `OTEL.IS_ENABLED`.
`archipy[otel,fastapi]` when `OTEL.IS_ENABLED`.
- gRPC: `create_grpc_app` / `create_async_grpc_app` append exception, optional OTel traces (contrib), ArchiPy
metrics (`rpc.server.duration` when `OTEL.METRICS_ENABLED`), and gRPC rate-limit interceptors. Do not hand-roll
metrics (`rpc.server.call.duration` when `OTEL.METRICS_ENABLED`), and gRPC rate-limit interceptors. Do not hand-roll
those stock hooks; metrics install is independent of traces.
- FastAPI rate limiting is not shipped by ArchiPy 5.x; use `fastapi-redis-sdk` when required.

Expand Down
8 changes: 4 additions & 4 deletions rules/using-archipy-logics.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Live: https://syntaxarc.github.io/ArchiPy/getting-started/concepts/
When using Postgres SQLAlchemy, decorate public methods:

```python
from archipy.helpers.decorators.sqlalchemy_atomic import postgres_sqlalchemy_atomic_decorator
from archipy.adapters.base.sqlalchemy.atomic import postgres_sqlalchemy_atomic

class UserRegistrationLogic:
@postgres_sqlalchemy_atomic_decorator
@postgres_sqlalchemy_atomic
def register_user(self, input_dto: UserRegistrationInputDTO) -> UserRegistrationOutputDTO:
...
```

- Async stack: `async_postgres_sqlalchemy_atomic_decorator`.
- Async logics: the same decorator detects `async def`; the `async_*` names are deprecated.
- Nested atomic-decorator calls reuse the open session — logics may call other logics.

## Domain Isolation
Expand All @@ -50,5 +50,5 @@ class UserRegistrationLogic:
## Do Not

- Put HTTP status mapping or router code here (that belongs in `services/`).
- Skip `*_sqlalchemy_atomic_decorator` on write/read paths that need a SQLAlchemy session when SQLAlchemy is in use.
- Skip `*_sqlalchemy_atomic` on write/read paths that need a SQLAlchemy session when SQLAlchemy is in use.
- Construct Redis/DB clients inside logic classes.
2 changes: 1 addition & 1 deletion rules/using-archipy-repositories.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ repositories/{domain}/

## Do Not

- Put business rules or `@postgres_sqlalchemy_atomic_decorator` here (that belongs in `logics/`).
- Put business rules or `@postgres_sqlalchemy_atomic` here (that belongs in `logics/`).
- Create a top-level app `adapters/` package — domain adapters live under repositories.
- Leak raw driver exceptions into logics/services.
6 changes: 3 additions & 3 deletions rules/using-archipy-services.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Paths are hierarchical resources: `/api/v{n}/<collection>/{<resource>_uuid}/<chi

## Actor identity and audit columns (JWT auth)

With any JWT-based auth (`KeycloakUtils` dependencies/decorators, `JWTUtils`, or another issuer) the acting principal comes
from the verified access token, never from a path parameter. With `KeycloakUtils` it is an `AuthenticatedUserDTO`; for
With any JWT-based auth (`fastapi_auth` / `grpc_auth` from `archipy.adapters.keycloak.auth`, `JWTUtils`, or another issuer) the acting principal comes
from the verified access token, never from a path parameter. With the Keycloak guards it is an `AuthenticatedUserDTO`, also readable anywhere below the endpoint through `AuthContextManager` (do not read `request.state.user_info` and friends; they warn and go away in 6.0.0); for
other JWTs read the claims the same way: actor = `act.sub` (RFC 8693 delegation/impersonation) when present, else `sub`.

- Fill `created_by*` / `updated_by*` (`created_by_admin*`, `updated_by_admin*` on `AdminEntity` /
Expand Down Expand Up @@ -110,7 +110,7 @@ CLI flags may override for local runs; defaults always come from `FASTAPI`.

## Do Not

- Put business rules or `@postgres_sqlalchemy_atomic_decorator` in services.
- Put business rules or `@postgres_sqlalchemy_atomic` in services.
- Hand-roll bare `FastAPI()` / `grpc.server()` when AppUtils extras are installed.
- Hardcode uvicorn host/port — use `FastAPIConfig`.
- Use non-kebab literal path segments, verb paths (`/get-user`), or flat routes that hide the resource hierarchy.
Expand Down
Loading
Loading