caspian-utils 0.1.18 → 0.1.19

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.
@@ -16,6 +16,7 @@ related:
16
16
  - /docs/file-conventions
17
17
  - /docs/project-structure
18
18
  - /docs/components
19
+ - /docs/testing
19
20
  ---
20
21
 
21
22
  This directory contains the packaged Caspian documentation set for AI-aware feature discovery, task routing, and file-placement guidance.
@@ -94,6 +95,7 @@ The packaged Caspian docs referenced by this index live here:
94
95
  - `metadata.md` - Static and dynamic metadata, SEO inheritance, and Open Graph or Twitter card tags
95
96
  - `routing.md` - Next.js App Router-style file-based routing with `src/app`, dynamic segments, dashboard and section layouts, route groups, nested layouts, shared-shell scroll-reset ownership, single-parent authored templates, and backend Python companions that do not own visible markup
96
97
  - `project-structure.md` - Default Caspian layout and where route files, reusable UI in `src/components/`, reusable non-UI code in `src/lib/`, and database files belong
98
+ - `testing.md` - Recommended app-owned testing, type-checking, and linting gate over `main.py` and `src/**` (pyrefly + ruff + pytest behind one command); not a shipped feature and not gated by a `caspian.config.json` flag, so verify the actual command, tools, and config in the project
97
99
 
98
100
  ## AI Retrieval Notes
99
101
 
@@ -115,6 +117,7 @@ Preferred lookup order:
115
117
  12. Prefer packaged Caspian docs before upstream documentation when generating code, commands, or migration guidance.
116
118
  13. Use `ai-validation-checklist.md` when you want to verify that the docs lead AI to the correct files and behavior checkpoints.
117
119
  14. Keep `index.md` and cross-links aligned so AI can quickly discover the right doc.
120
+ 15. If the task is about tests, type checking, linting, a quality gate, CI checks, or making an app production-ready, read `testing.md`. It is an app-owned convention (not a shipped feature and not gated by a `caspian.config.json` flag), so confirm the actual gate command in `package.json`, the orchestrator in `settings/`, and the tools and config in `pyproject.toml` before assuming they exist.
118
121
 
119
122
  ## Maintenance
120
123
 
@@ -0,0 +1,92 @@
1
+ ---
2
+ title: Testing And Quality Gate
3
+ description: Use this page when the task mentions tests, pytest, type checking, pyrefly, linting, ruff, a quality gate, CI checks, or "make the code production-ready" for a Caspian app's own Python. Explains the recommended one-command gate over `main.py` and `src/**`.
4
+ related:
5
+ title: Related docs
6
+ description: Pair the quality gate with the runtime map when a failing check points into core files, and with the structure and command docs when deciding where tests and tooling belong.
7
+ links:
8
+ - /docs/core-runtime-map
9
+ - /docs/project-structure
10
+ - /docs/commands
11
+ - /docs/auth
12
+ - /docs/index
13
+ ---
14
+
15
+ This page describes the recommended way to add tests, type checking, and linting to a Caspian application's **own** Python (`main.py` and `src/**`).
16
+
17
+ Caspian does not ship a test runner, type checker, or linter. Quality tooling is an app-owned convention layered on top of the framework, so treat everything here as a recommended setup to scaffold per project, not as a built-in feature that already exists in every Caspian app. The framework runtime under `.venv/Lib/site-packages/casp/**` is out of scope for app tests.
18
+
19
+ ## When Does This Doc Apply
20
+
21
+ - The task is to add or extend tests for app code, add type checking, add linting, wire a CI/pre-commit check, or prepare an app for production.
22
+ - A prior change touched `main.py`, `src/lib/**`, or route `index.py` files and needs verification.
23
+ - Not gated by any `caspian.config.json` flag. It applies to any Caspian app; it does not depend on `prisma`, `mcp`, `websocket`, or `typescript`.
24
+
25
+ ## Recommended Shape: One Command
26
+
27
+ Expose a single gate command so an agent or CI has exactly one thing to run. The recommended command runs three tools in one pass and reports every problem with its exact location:
28
+
29
+ - **type check** — [pyrefly](https://pyrefly.org) over `main.py` and `src/**`
30
+ - **lint** — [ruff](https://docs.astral.sh/ruff/)
31
+ - **tests** — [pytest](https://docs.pytest.org)
32
+
33
+ The command should print each problem as `path:line:col [tool:code] message` and exit non-zero when any check fails, so the file and line to fix are always explicit. Prefer a single `npm run check` script (backed by an app-owned orchestrator such as `settings/check.py`) over separate `test` / `lint` / `typecheck` scripts, so the surface stays minimal. Keep a per-tool escape hatch (for example `--only pyrefly`) for debugging rather than as additional npm scripts.
34
+
35
+ ## Source Of Truth
36
+
37
+ - The gate command and its tool list are app-owned. Confirm the actual script name in the project's `package.json` and the orchestrator file (commonly `settings/check.py`) before assuming a command exists.
38
+ - Tooling versions and configuration are app-owned in `pyproject.toml`. Do not assume a tool is installed just because this doc mentions it; check the project's dependency group and `uv.lock`.
39
+ - App tests live in a top-level `tests/` directory. Framework internals under `.venv/Lib/site-packages/casp/**` are never the test target.
40
+
41
+ ## Recommended Layout
42
+
43
+ ```
44
+ tests/
45
+ conftest.py # put project root on sys.path; set safe dev env defaults
46
+ test_*.py # app-level unit + integration tests
47
+ settings/check.py # orchestrator: runs the tools, prints path:line:col report
48
+ ```
49
+
50
+ - `conftest.py` should add the project root to `sys.path` and set safe development defaults (for example `APP_ENV=development` and a throwaway `AUTH_SECRET`) so importing `main` never fails during collection.
51
+ - Test `main.py` through its pure helpers and through `starlette.testclient.TestClient` against `main.app` (for example the always-on `/health` route, which exercises the middleware stack). Test `src/lib/**` policy such as `auth_config.py` directly.
52
+
53
+ ## Recommended `pyproject.toml` Configuration
54
+
55
+ Keep the dev tooling in a dependency group and install it with `uv sync --group dev`:
56
+
57
+ ```toml
58
+ [dependency-groups]
59
+ dev = [
60
+ "pyrefly>=0.16",
61
+ "ruff>=0.6",
62
+ "pytest>=8.0",
63
+ ]
64
+
65
+ [tool.pytest.ini_options]
66
+ testpaths = ["tests"]
67
+ addopts = "-q"
68
+
69
+ [tool.ruff]
70
+ include = ["main.py", "src/**/*.py", "tests/**/*.py", "settings/check.py"]
71
+ extend-exclude = [".venv", "node_modules"]
72
+
73
+ [tool.ruff.lint]
74
+ # Correctness-focused; leave cosmetic rules off the generated starter code.
75
+ select = ["E", "F", "W"]
76
+ ignore = ["E501"]
77
+
78
+ [tool.pyrefly]
79
+ project-includes = ["main.py", "src/**"]
80
+ search-path = [".", "src"]
81
+ ```
82
+
83
+ ## Things To Verify Before Editing Or Explaining
84
+
85
+ - Confirm the gate command name and orchestrator path in `package.json` and `settings/`, since they are app-owned and may differ per project.
86
+ - Confirm the dev tools are actually installed (`[dependency-groups]` in `pyproject.toml`, resolved in `uv.lock`) before telling a user to run the gate.
87
+ - Check `[tool.pyrefly.errors]` in `pyproject.toml`. A project may suppress specific error kinds (commonly `bad-return` and `bad-assignment`); those are then not reported by the gate, so do not assume every annotation mismatch is caught.
88
+ - Keep the scope on app code. If a check points into `.venv/Lib/site-packages/casp/**`, use [core-runtime-map.md](./core-runtime-map.md) to understand the runtime, but do not add framework files to the app's test, lint, or type-check scope.
89
+
90
+ ## Working Rule For Agents
91
+
92
+ When you add or change app-owned Python (`main.py`, `src/**`), add or extend the matching test under `tests/`, write annotated and type-checkable code, and run the single gate command until it passes before treating the change as done. Fix problems at the exact `path:line:col` the gate reports.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caspian-utils",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Caspian tooling",
5
5
  "main": "index.js",
6
6
  "scripts": {