nene2-python 1.8.4__tar.gz → 1.8.6__tar.gz
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.
- {nene2_python-1.8.4 → nene2_python-1.8.6}/CHANGELOG.md +23 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/PKG-INFO +1 -1
- nene2_python-1.8.6/docs/field-trials/2026-05-field-trial-37.md +77 -0
- nene2_python-1.8.6/docs/field-trials/2026-05-field-trial-38.md +85 -0
- nene2_python-1.8.6/docs/field-trials/2026-05-field-trial-39.md +95 -0
- nene2_python-1.8.6/docs/field-trials/2026-05-field-trial-40.md +87 -0
- nene2_python-1.8.6/docs/field-trials/2026-05-field-trial-41.md +126 -0
- nene2_python-1.8.6/docs/field-trials/2026-05-field-trial-42.md +137 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/how-to/run-tests.md +21 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/pyproject.toml +1 -1
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/http/__init__.py +6 -1
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/http/problem_details.py +21 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/middleware/request_size_limit.py +25 -9
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/http/test_problem_details.py +17 -4
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/middleware/test_request_size_limit.py +39 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/uv.lock +1 -1
- {nene2_python-1.8.4 → nene2_python-1.8.6}/.env.example +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/.github/workflows/ci.yml +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/.github/workflows/docs.yml +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/.github/workflows/publish.yml +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/.gitignore +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/.vitepress/config.mts +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/.vitepress/theme/custom.css +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/.vitepress/theme/index.ts +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/AGENTS.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/CLAUDE.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/Dockerfile +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/LICENSE +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/README.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/alembic/README +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/alembic/env.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/alembic/script.py.mako +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/alembic/versions/001_create_notes_and_tags_tables.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/alembic.ini +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/compose.yaml +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/adr/0001-toolchain.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/adr/0002-clean-architecture.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/adr/0003-security-first.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/adr/0004-ai-first-design.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/adr/0005-logging.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/adr/0006-rate-limiting.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/adr/0009-mcp-design.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/adr/0010-async-use-case.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/adr/0011-mcp-as-core-dependency.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/de/index.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/de/tutorials/getting-started.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/explanation/architecture.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/explanation/design-philosophy.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-1.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-10.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-11.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-12.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-13.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-14.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-15.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-16.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-17.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-18.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-19.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-2.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-20.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-21.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-22.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-23.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-24.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-25.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-26.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-27.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-28.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-29.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-3.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-30.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-31.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-32.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-33.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-34.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-35.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-36.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-4.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-5.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-6.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-7.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-8.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/field-trials/2026-05-field-trial-9.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/fr/index.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/fr/tutorials/getting-started.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/how-to/add-new-domain.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/how-to/async-use-case.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/how-to/configure-auth.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/how-to/new-project.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/how-to/problem-details.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/how-to/sqlalchemy-repository.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/how-to/validation.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/howto/mcp-setup.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/index.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/explanation/architecture.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/explanation/design-philosophy.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/how-to/add-new-domain.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/how-to/configure-auth.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/how-to/new-project.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/how-to/run-tests.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/how-to/sqlalchemy-repository.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/howto/mcp-setup.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/index.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/reference/api.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/reference/configuration.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/reference/framework-modules.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/tutorials/first-domain.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/ja/tutorials/getting-started.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/pt-br/index.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/pt-br/tutorials/getting-started.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/reference/api.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/reference/configuration.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/reference/framework-modules.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/roadmap.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/todo/current.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/tutorials/first-domain.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/tutorials/getting-started.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/zh/index.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/docs/zh/tutorials/getting-started.md +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/package-lock.json +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/package.json +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/__main__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/app.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/comment/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/comment/entity.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/comment/exceptions.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/comment/handler.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/comment/repository.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/comment/sqlalchemy_repository.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/comment/use_case.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/mcp.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/note/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/note/async_use_case.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/note/entity.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/note/exceptions.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/note/handler.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/note/repository.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/note/sqlalchemy_repository.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/note/use_case.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/schema.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/tag/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/tag/entity.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/tag/exceptions.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/tag/handler.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/tag/repository.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/tag/sqlalchemy_repository.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/example/tag/use_case.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/auth/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/auth/api_key.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/auth/bearer_token.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/auth/exceptions.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/auth/interfaces.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/auth/local_verifier.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/config/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/config/settings.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/database/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/database/exceptions.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/database/health.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/database/interfaces.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/database/sqlalchemy_executor.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/database/utils.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/http/health.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/http/pagination.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/log/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/log/setup.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/mcp/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/mcp/http_client.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/mcp/server.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/middleware/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/middleware/domain_exception.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/middleware/error_handler.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/middleware/request_id.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/middleware/request_logging.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/middleware/security_headers.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/middleware/throttle.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/py.typed +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/use_case/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/use_case/protocols.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/validation/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/nene2/validation/exceptions.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/scripts/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/src/scripts/export_openapi.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/comment/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/comment/test_comment_http.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/comment/test_comment_repository.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/comment/test_comment_use_case.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/conftest.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/note/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/note/test_async_note_use_case.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/note/test_list_notes.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/note/test_note_repository.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/tag/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/tag/test_tag_repository.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/tag/test_tags.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/test_cors.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/example/test_mcp.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/auth/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/auth/test_api_key.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/auth/test_bearer_token.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/auth/test_token_issuer.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/config/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/config/test_settings.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/database/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/database/test_transaction.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/database/test_utils.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/http/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/http/test_health.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/http/test_pagination.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/log/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/log/test_setup.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/mcp/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/mcp/test_http_client.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/middleware/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/middleware/test_error_handler.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/middleware/test_request_id.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/middleware/test_request_logging.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/middleware/test_security_headers.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/middleware/test_simple_domain_handler.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/middleware/test_throttle.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/use_case/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/use_case/test_protocols.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/validation/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/nene2/validation/test_exceptions.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/scripts/__init__.py +0 -0
- {nene2_python-1.8.4 → nene2_python-1.8.6}/tests/scripts/test_export_openapi.py +0 -0
|
@@ -5,6 +5,29 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [1.8.6] — 2026-05-20
|
|
9
|
+
|
|
10
|
+
FT41〜FT42 フィールドトライアル — structlog テスト統合ドキュメント・configure_problem_details リセット関数。
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `nene2.http.reset_problem_details()` — `configure_problem_details()` で設定したグローバル状態をテスト間でリセットするヘルパー関数 (FT42)
|
|
14
|
+
- Field trial reports: `docs/field-trials/2026-05-field-trial-41.md`、`docs/field-trials/2026-05-field-trial-42.md`
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- `docs/how-to/run-tests.md` — `configure_for_testing()` + `caplog` による structlog ログキャプチャパターンを追記 (FT41)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## [1.8.5] — 2026-05-20
|
|
22
|
+
|
|
23
|
+
FT37〜FT40 フィールドトライアル — RequestSizeLimitMiddleware パスごとサイズ制限とドキュメント改善。
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- `RequestSizeLimitMiddleware` に `path_limits: dict[str, int] | None = None` パラメータを追加 — パスごとに異なるリクエストボディサイズ制限を設定可能に (FT39)
|
|
27
|
+
- Field trial reports: `docs/field-trials/2026-05-field-trial-37.md` 〜 `docs/field-trials/2026-05-field-trial-40.md`
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
8
31
|
## [1.8.4] — 2026-05-20
|
|
9
32
|
|
|
10
33
|
FT33〜FT36 フィールドトライアル — バリデーション・DB整合性・混合認証・非同期ヘルスチェック改善。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nene2-python
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.6
|
|
4
4
|
Summary: NENE2 Python — minimal API framework following NENE2's design philosophy
|
|
5
5
|
Project-URL: Homepage, https://github.com/hideyukiMORI/nene2-python
|
|
6
6
|
Project-URL: Repository, https://github.com/hideyukiMORI/nene2-python
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Field Trial 37: PaginationResponse + PaginationQueryParser 実運用検証
|
|
2
|
+
|
|
3
|
+
**日付**: 2026-05-20
|
|
4
|
+
**バージョン**: v1.8.4 時点
|
|
5
|
+
**テーマ**: `PaginationQueryParser` の `Depends()` パターンと `PaginationResponse.to_dict()` を使ったページネーションパイプラインの実運用確認
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 概要
|
|
10
|
+
|
|
11
|
+
50 件の `Product` データを `PaginationQueryParser` で limit/offset 制御し、
|
|
12
|
+
`PaginationResponse.to_dict()` で slotted dataclass を自動シリアライズして `JSONResponse` に変換するパイプラインを検証した。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 実装内容
|
|
17
|
+
|
|
18
|
+
`/home/xi/docker/nene2-python-FT/ft37-pagination/` に以下を作成:
|
|
19
|
+
|
|
20
|
+
- **`app.py`** — `Annotated[PaginationQueryParser, Depends()]` パターンの `/api/products` エンドポイント
|
|
21
|
+
- **`test_app.py`** — デフォルト・カスタム・最終ページ・無効値・Depends 動作確認 (9 件)
|
|
22
|
+
- **`test_friction.py`** — 摩擦点の確認テスト (4 件)
|
|
23
|
+
|
|
24
|
+
**テスト結果**: 13 件全通過 ✅
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 摩擦点
|
|
29
|
+
|
|
30
|
+
### FP37-1: `Annotated[PaginationQueryParser, Depends()]` と書く必要がある
|
|
31
|
+
|
|
32
|
+
**分類**: 軽微な摩擦(FastAPI 標準パターン)
|
|
33
|
+
|
|
34
|
+
`def list(pagination: PaginationQueryParser = Depends())` ではなく
|
|
35
|
+
`def list(pagination: Annotated[PaginationQueryParser, Depends()])` が推奨パターン。
|
|
36
|
+
FastAPI の仕様に従っているが、初見では迷いやすい。
|
|
37
|
+
|
|
38
|
+
**判断**: `docs/how-to/validation.md` および新規作成する how-to への記載で対応。
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### FP37-2: `to_dict()` は dataclass のみ自動シリアライズ
|
|
43
|
+
|
|
44
|
+
**分類**: 既知の制約(軽微)
|
|
45
|
+
|
|
46
|
+
`PaginationResponse.to_dict()` は `dataclasses.is_dataclass()` で判定する。
|
|
47
|
+
Pydantic モデルの items は `.model_dump()` を個別に呼ぶ必要がある。
|
|
48
|
+
通常の dict はそのまま通過する。
|
|
49
|
+
|
|
50
|
+
**判断**: dataclass 向け最適化という設計意図通り。
|
|
51
|
+
Pydantic モデルとの混在ユースケースは how-to ドキュメントに記載する。
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### FP37-3: `total` 省略時に `"total"` キーが消える(設計通り)
|
|
56
|
+
|
|
57
|
+
**分類**: 設計通り(摩擦なし)
|
|
58
|
+
|
|
59
|
+
`PaginationResponse(items=[], limit=10, offset=0)` のように `total` を渡さないと
|
|
60
|
+
`to_dict()` の結果に `"total"` キーが含まれない。
|
|
61
|
+
`total=None` を明示しても同じ結果。
|
|
62
|
+
|
|
63
|
+
**判断**: 全件数を取得しない効率的なページネーションをサポートする意図通り。
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## フレームワーク変更
|
|
68
|
+
|
|
69
|
+
なし(全て設計通りの挙動)
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 関連
|
|
74
|
+
|
|
75
|
+
- `nene2.http.PaginationQueryParser`
|
|
76
|
+
- `nene2.http.PaginationResponse`
|
|
77
|
+
- FT10 (PaginationResponse.to_dict() スロット対応, v1.3.0)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Field Trial 38: SqlAlchemyTransactionManager.transactional() 実運用検証
|
|
2
|
+
|
|
3
|
+
**日付**: 2026-05-20
|
|
4
|
+
**バージョン**: v1.8.4 時点
|
|
5
|
+
**テーマ**: 注文作成(在庫更新 + 注文レコード作成)をトランザクションで包み、途中での例外発生時のロールバック動作を確認する
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 概要
|
|
10
|
+
|
|
11
|
+
`SqlAlchemyTransactionManager.transactional(callback)` を使って複数の DB 書き込みを一つのトランザクションに包み、途中で例外が発生した場合のロールバック動作を検証した。
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 実装内容
|
|
16
|
+
|
|
17
|
+
`/home/xi/docker/nene2-python-FT/ft38-transactions/` に以下を作成:
|
|
18
|
+
|
|
19
|
+
- **`app.py`** — 在庫チェック + 在庫減少 + 注文作成を `transactional()` で包んだ注文 API
|
|
20
|
+
- **`test_app.py`** — 正常注文・在庫不足・ロールバック確認・連続注文 (6 件)
|
|
21
|
+
- **`test_friction.py`** — 摩擦点の確認テスト (3 件)
|
|
22
|
+
|
|
23
|
+
**テスト結果**: 9 件全通過 ✅
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 摩擦点
|
|
28
|
+
|
|
29
|
+
### FP38-1: コールバック内で型アノテーションに `DatabaseQueryExecutorInterface` が必要
|
|
30
|
+
|
|
31
|
+
**分類**: 軽微な摩擦(mypy --strict 使用時)
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
def _do_create(db: object) -> int:
|
|
35
|
+
...
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`db` を `object` 型にするとメソッド呼び出しに mypy エラーが出る。
|
|
39
|
+
`DatabaseQueryExecutorInterface` をインポートして型アノテーションする必要がある。
|
|
40
|
+
|
|
41
|
+
**判断**: mypy --strict の設計上当然の制約。インポートはやや冗長だが許容範囲。
|
|
42
|
+
`db: DatabaseQueryExecutorInterface` が推奨パターンとしてドキュメントに記載されている。
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### FP38-2: savepoint(ネストトランザクション)はサポートしない
|
|
47
|
+
|
|
48
|
+
**分類**: 既知の制約(設計通り)
|
|
49
|
+
|
|
50
|
+
`DatabaseQueryExecutorInterface` が持つのは `fetch_all` / `fetch_one` / `write` のみ。
|
|
51
|
+
SQLAlchemy の savepoint 機能(`SAVEPOINT` / `ROLLBACK TO SAVEPOINT`)は使えない。
|
|
52
|
+
|
|
53
|
+
**判断**: フレームワークの抽象化レイヤーが Pure SQL テキストベースの設計を採用しているため、
|
|
54
|
+
ORM/Connection 固有の高度な機能は意図的に除外されている。
|
|
55
|
+
savepoint が必要な場合は SQLAlchemy を直接使う Repository を実装するのが正しいパターン。
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### FP38-3: トランザクション途中の例外はすべてロールバックされる(設計通り)
|
|
60
|
+
|
|
61
|
+
**分類**: 設計通り(摩擦なし)
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
def _callback(db: DatabaseQueryExecutorInterface) -> None:
|
|
65
|
+
db.write("INSERT ...") # ← この変更も
|
|
66
|
+
raise ValueError("oops") # ← ここで例外 → 全部ロールバック
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
例外の種類に関わらず(`DatabaseIntegrityException` 以外でも)全変更がロールバックされる。
|
|
70
|
+
これは `SqlAlchemyTransactionManager.transactional()` の期待される動作。
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## フレームワーク変更
|
|
75
|
+
|
|
76
|
+
なし(全て設計通りの挙動)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 関連
|
|
81
|
+
|
|
82
|
+
- `nene2.database.SqlAlchemyTransactionManager`
|
|
83
|
+
- `nene2.database.DatabaseQueryExecutorInterface`
|
|
84
|
+
- FT16 (DatabaseIntegrityException, v1.7.0)
|
|
85
|
+
- FT34 (DatabaseIntegrityException 実運用, v1.8.3)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Field Trial 39: RequestSizeLimitMiddleware 実運用検証
|
|
2
|
+
|
|
3
|
+
**日付**: 2026-05-20
|
|
4
|
+
**バージョン**: v1.8.4 時点
|
|
5
|
+
**テーマ**: `RequestSizeLimitMiddleware` で JSON ボディとバイナリアップロードのサイズを制限するパターンと、パスごとに異なる制限を設定したいユースケースの確認
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 概要
|
|
10
|
+
|
|
11
|
+
小さな `max_bytes` 制限(200 bytes)を設定したアプリで、正常なリクエスト・超過リクエスト・除外パス・境界値を検証した。
|
|
12
|
+
主な発見: パスごとに異なる制限(例: 通常 API は 1 MiB、アップロードエンドポイントは 10 MiB)が設定できない摩擦を発見。`path_limits` パラメータを追加して対応。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 実装内容
|
|
17
|
+
|
|
18
|
+
`/home/xi/docker/nene2-python-FT/ft39-request-size/` に以下を作成:
|
|
19
|
+
|
|
20
|
+
- **`app.py`** — `RequestSizeLimitMiddleware(max_bytes=200, exclude_paths=[...])` の動作確認アプリ
|
|
21
|
+
- **`test_app.py`** — 正常・超過・除外パス・境界値の動作確認 (8 件)
|
|
22
|
+
- **`test_friction.py`** — 摩擦点の確認テスト (3 件)
|
|
23
|
+
|
|
24
|
+
**テスト結果**: 11 件全通過 ✅
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 摩擦点
|
|
29
|
+
|
|
30
|
+
### FP39-1: パスごとに異なる max_bytes を設定できない
|
|
31
|
+
|
|
32
|
+
**分類**: 摩擦あり → **実装で対応**
|
|
33
|
+
|
|
34
|
+
`RequestSizeLimitMiddleware` は全体で一つの `max_bytes` のみ設定できる。
|
|
35
|
+
アップロードエンドポイント(例: 10 MiB)と通常 API(例: 1 MiB)で異なる制限を設定したい場合、
|
|
36
|
+
`exclude_paths` でアップロードを除外してハンドラー内で手動チェックするしかなかった。
|
|
37
|
+
|
|
38
|
+
**対応**: `ThrottleMiddleware.path_limits` と同様のパターンで `path_limits: dict[str, int] | None` を追加 (#259)。
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
app.add_middleware(
|
|
42
|
+
RequestSizeLimitMiddleware,
|
|
43
|
+
max_bytes=1_048_576, # デフォルト: 1 MiB
|
|
44
|
+
path_limits={
|
|
45
|
+
"/upload/file": 10_485_760, # /upload/file: 10 MiB
|
|
46
|
+
"/api/import": 5_242_880, # /api/import: 5 MiB
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
413 レスポンスの `max_bytes` フィールドはパス固有の制限値を返す。
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### FP39-2: max_bytes 構造化フィールドが 413 レスポンスに含まれる(FT23 改善の確認)
|
|
56
|
+
|
|
57
|
+
**分類**: 良い設計の確認
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"status": 413,
|
|
62
|
+
"type": ".../payload-too-large",
|
|
63
|
+
"title": "Payload Too Large",
|
|
64
|
+
"max_bytes": 200
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`max_bytes` フィールドがあることでクライアントがプログラムで制限値を知れる。
|
|
69
|
+
FT23 で追加された改善が実際に役立つことを確認。
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### FP39-3: Content-Length ヘッダーによる早期拒否が機能する
|
|
74
|
+
|
|
75
|
+
**分類**: 設計通り(摩擦なし)
|
|
76
|
+
|
|
77
|
+
Content-Length ヘッダーが `max_bytes` を超える場合、ボディを読む前に 413 を返す。
|
|
78
|
+
メモリ効率が良い設計。
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## フレームワーク変更
|
|
83
|
+
|
|
84
|
+
- `RequestSizeLimitMiddleware` に `path_limits: dict[str, int] | None = None` を追加 (FP39-1)
|
|
85
|
+
- テスト 2 件追加
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 関連
|
|
90
|
+
|
|
91
|
+
- `nene2.middleware.RequestSizeLimitMiddleware`
|
|
92
|
+
- FT12 (RequestSizeLimitMiddleware exclude_paths, v1.5.0)
|
|
93
|
+
- FT23 (413 レスポンスに max_bytes 追加, v1.8.0)
|
|
94
|
+
- FT28 (ThrottleMiddleware path_limits, v1.8.1)
|
|
95
|
+
- Issue #259
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Field Trial 40: 多ドメイン連携(Article + Tag 紐付け)実運用検証
|
|
2
|
+
|
|
3
|
+
**日付**: 2026-05-20
|
|
4
|
+
**バージョン**: v1.8.4 時点
|
|
5
|
+
**テーマ**: 1 つの UseCase が 2 つのリポジトリ(Article + Tag)を横断するパターンの実運用確認
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 概要
|
|
10
|
+
|
|
11
|
+
`TagArticleUseCase` が `InMemoryArticleRepository` と `InMemoryTagRepository` を
|
|
12
|
+
コンストラクタインジェクションで受け取り、記事へのタグ付けを管理するパターンを実装した。
|
|
13
|
+
複数の無効 TagId がある場合に `ValidationException` で全エラーを一度に収集するパターンも確認。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 実装内容
|
|
18
|
+
|
|
19
|
+
`/home/xi/docker/nene2-python-FT/ft40-multi-domain/` に以下を作成:
|
|
20
|
+
|
|
21
|
+
- **`app.py`** — Article + Tag の 2 ドメインを跨ぐ `TagArticleUseCase` と FastAPI エンドポイント
|
|
22
|
+
- **`test_app.py`** — 正常タグ付け・不正タグ・404・複数バリデーションエラー (7 件)
|
|
23
|
+
- **`test_friction.py`** — 摩擦点の確認テスト (4 件)
|
|
24
|
+
|
|
25
|
+
**テスト結果**: 11 件全通過 ✅
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 摩擦点
|
|
30
|
+
|
|
31
|
+
### FP40-1: 複数リポジトリを受け取る UseCase は自然に書ける(良い設計)
|
|
32
|
+
|
|
33
|
+
**分類**: 摩擦なし(設計の確認)
|
|
34
|
+
|
|
35
|
+
フレームワークは UseCase 構造に制約を課さないため、
|
|
36
|
+
複数のリポジトリを `__init__` で受け取るパターンが素直に実装できる。
|
|
37
|
+
CLAUDE.md の「UseCase は他の UseCase を呼ばない」ルールに従い、
|
|
38
|
+
各リポジトリを直接呼ぶことで依存関係がシンプルに保たれる。
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### FP40-2: カスタムドメイン例外は SimpleDomainHandler 登録が必要
|
|
43
|
+
|
|
44
|
+
**分類**: 軽微な摩擦(設計通り・注意喚起)
|
|
45
|
+
|
|
46
|
+
`ValidationException` は `ErrorHandlerMiddleware` が自動で 422 に変換するが、
|
|
47
|
+
`ArticleNotFoundException` のようなカスタムドメイン例外は
|
|
48
|
+
`SimpleDomainHandler` を明示的に登録しないと 500 になる。
|
|
49
|
+
登録を忘れると意図しない 500 レスポンスになるため注意が必要。
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
# 忘れると 500 になる
|
|
53
|
+
handlers = [
|
|
54
|
+
SimpleDomainHandler(ArticleNotFoundException, "article-not-found", "Not Found", 404),
|
|
55
|
+
]
|
|
56
|
+
app.add_middleware(ErrorHandlerMiddleware, domain_handlers=handlers)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**判断**: ドメイン例外の HTTP マッピングを明示的にする設計は正しい。
|
|
60
|
+
`configure-auth.md` と同様に how-to ドキュメントでパターンを示す価値がある。
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### FP40-3: 複数ドメイン横断バリデーションエラーを一括収集できる
|
|
65
|
+
|
|
66
|
+
**分類**: 良い設計の確認
|
|
67
|
+
|
|
68
|
+
`ValidationException` リストにエラーを積み上げてから raise するパターンで、
|
|
69
|
+
複数の無効 TagId を一度のリクエストでまとめてクライアントに通知できる。
|
|
70
|
+
FT33 で確認した `ValidationCode(StrEnum)` パターンと組み合わせると更に型安全になる。
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## フレームワーク変更
|
|
75
|
+
|
|
76
|
+
なし(全て設計通りの挙動)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 関連
|
|
81
|
+
|
|
82
|
+
- `nene2.use_case.UseCaseProtocol`
|
|
83
|
+
- `nene2.validation.ValidationException`
|
|
84
|
+
- `nene2.middleware.SimpleDomainHandler`
|
|
85
|
+
- FT13 (ValidationException 実運用, v1.6.0)
|
|
86
|
+
- FT21 (SimpleDomainHandler 実装, v1.8.0)
|
|
87
|
+
- FT33 (ValidationCode StrEnum パターン, v1.8.3)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Field Trial 41: structlog テスト統合 — configure_for_testing() + caplog ログ相関
|
|
2
|
+
|
|
3
|
+
**日付**: 2026-05-20
|
|
4
|
+
**バージョン**: v1.8.5 時点
|
|
5
|
+
**テーマ**: `configure_for_testing()` + pytest `caplog` でリクエスト ID をログで追跡するパターンの実運用確認
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 概要
|
|
10
|
+
|
|
11
|
+
`nene2.log.configure_for_testing()` を `conftest.py` のモジュールレベルで呼び出し、
|
|
12
|
+
`RequestIdMiddleware` + `RequestLoggingMiddleware` を組み合わせたアプリのログを
|
|
13
|
+
pytest の `caplog` でキャプチャ・検証するパターンを実装した。
|
|
14
|
+
structlog と stdlib logging の橋渡し構造における制約も確認した。
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 実装内容
|
|
19
|
+
|
|
20
|
+
`/home/xi/docker/nene2-python-FT/ft41-log-testing/` に以下を作成:
|
|
21
|
+
|
|
22
|
+
- **`conftest.py`** — モジュールレベルで `configure_for_testing()` を呼び出し
|
|
23
|
+
- **`app.py`** — `RequestIdMiddleware` / `RequestLoggingMiddleware` / `ErrorHandlerMiddleware` を積んだ FastAPI アプリ。`extra_context` パラメータで静的フィールドを全ログに付加
|
|
24
|
+
- **`test_app.py`** — 正常系・ヘッダー確認・caplog キャプチャ・ミドルウェアログ確認 (5 件)
|
|
25
|
+
- **`test_friction.py`** — 摩擦点の確認テスト (4 件)
|
|
26
|
+
|
|
27
|
+
**テスト結果**: 9 件全通過 ✅
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 摩擦点
|
|
32
|
+
|
|
33
|
+
### FP41-1: configure_for_testing() は conftest.py のモジュールレベルで呼ぶ必要がある
|
|
34
|
+
|
|
35
|
+
**分類**: 軽微な摩擦(設計通り・注意喚起)
|
|
36
|
+
|
|
37
|
+
`configure_for_testing()` は structlog のグローバル設定を変更するため、
|
|
38
|
+
テスト関数内で呼んでも機能するが、全テストに適用するには
|
|
39
|
+
`conftest.py` のモジュールレベルで呼ぶことが重要。
|
|
40
|
+
テスト関数内で呼ぶと、その関数のみに限定されず他のテストに副作用を与える可能性がある。
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
# conftest.py — 正しいパターン
|
|
44
|
+
from nene2.log import configure_for_testing
|
|
45
|
+
configure_for_testing()
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**判断**: ドキュメントに記載されたパターン通り。現行の `docs/how-to/run-tests.md` に
|
|
49
|
+
明示的に記載することで摩擦を減らせる。
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
### FP41-2: caplog.records の LogRecord に request_id フィールドが直接ない
|
|
54
|
+
|
|
55
|
+
**分類**: 設計上の制約(許容範囲)
|
|
56
|
+
|
|
57
|
+
`RequestIdMiddleware` が `structlog.contextvars.bind_contextvars(request_id=...)` で
|
|
58
|
+
バインドした値は、pytest の `caplog` が返す stdlib `LogRecord` に直接属性として
|
|
59
|
+
アクセスできない(`record.request_id` が存在しない)。
|
|
60
|
+
|
|
61
|
+
`ProcessorFormatter` を通すとメッセージ文字列に request_id が含まれるが、
|
|
62
|
+
構造化フィールドとして直接取り出すことはできない。
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
# NG — LogRecord に直接属性はない
|
|
66
|
+
for record in caplog.records:
|
|
67
|
+
print(record.request_id) # AttributeError
|
|
68
|
+
|
|
69
|
+
# OK — メッセージ文字列に含まれる
|
|
70
|
+
assert "request-id-test" not in " ".join(r.message for r in caplog.records)
|
|
71
|
+
# (request_id の値は UUID であり、テスト側から事前に知ることはできない)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**判断**: structlog と stdlib logging の橋渡し構造による設計上の制約。
|
|
75
|
+
`caplog` でのログ検証はメッセージ文字列ベースで行うのが現実的なアプローチ。
|
|
76
|
+
`ProcessorFormatter` に対するテストを書きたい場合は structlog の `capture_logs()` を使う方法もある。
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### FP41-3: caplog のキャプチャには configure_for_testing() が必須
|
|
81
|
+
|
|
82
|
+
**分類**: 注意喚起(ドキュメントで対応済み)
|
|
83
|
+
|
|
84
|
+
`configure_for_testing()` を呼ばない状態では、structlog のログは
|
|
85
|
+
pytest の `caplog` にキャプチャされない。
|
|
86
|
+
JSON レンダラーのまま stdout に出力されるため、
|
|
87
|
+
テストで structlog ログを検証するには必ず `configure_for_testing()` を呼ぶ必要がある。
|
|
88
|
+
|
|
89
|
+
**判断**: FT18 で実装した機能の使い方確認。`run-tests.md` に caplog との統合手順を追記する価値がある。
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### FP41-4: structlog.contextvars でバインドした値はメッセージ文字列に含まれる
|
|
94
|
+
|
|
95
|
+
**分類**: 摩擦なし(設計の確認)
|
|
96
|
+
|
|
97
|
+
`structlog.contextvars.bind_contextvars(key="value")` でバインドした値は、
|
|
98
|
+
`configure_for_testing()` の設定下では `record.message` にキー=値形式で含まれる。
|
|
99
|
+
テストで構造化フィールドを検証する場合はメッセージ文字列の部分一致で確認できる。
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
structlog.contextvars.bind_contextvars(request_id="test-123")
|
|
103
|
+
log.info("hello")
|
|
104
|
+
# caplog.records[0].message → "hello request_id=test-123" (または類似形式)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**判断**: structlog + caplog の統合パターンとして文字列検索が現実的。
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## フレームワーク変更
|
|
112
|
+
|
|
113
|
+
なし(全て設計通りの挙動)
|
|
114
|
+
|
|
115
|
+
ドキュメント追記のみ検討:
|
|
116
|
+
- `docs/how-to/run-tests.md` に `configure_for_testing()` + caplog パターンを追記
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 関連
|
|
121
|
+
|
|
122
|
+
- `nene2.log.configure_for_testing` (FT18, v1.8.0)
|
|
123
|
+
- `nene2.middleware.RequestIdMiddleware`
|
|
124
|
+
- `nene2.middleware.RequestLoggingMiddleware`
|
|
125
|
+
- FT18 (configure_for_testing 実装, v1.8.0)
|
|
126
|
+
- FT30 (RequestLoggingMiddleware extra_context, v1.8.2)
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Field Trial 42: get_request_id() Depends + configure_problem_details() 実運用検証
|
|
2
|
+
|
|
3
|
+
**日付**: 2026-05-20
|
|
4
|
+
**バージョン**: v1.8.5 時点
|
|
5
|
+
**テーマ**: `get_request_id()` を FastAPI `Depends` で注入しレスポンスに含めるパターン、および `configure_problem_details()` のプロジェクト全体設定
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 概要
|
|
10
|
+
|
|
11
|
+
`nene2.middleware.get_request_id()` を `Annotated[str, Depends(get_request_id)]` 構文で
|
|
12
|
+
ハンドラーに注入し、レスポンスボディに `request_id` を含めるパターンを実装した。
|
|
13
|
+
`configure_problem_details()` でプロジェクト全体の Problem Details base_url を設定し、
|
|
14
|
+
カスタム例外を `SimpleDomainHandler` でマッピングする構成も確認した。
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 実装内容
|
|
19
|
+
|
|
20
|
+
`/home/xi/docker/nene2-python-FT/ft42-request-id-depends/` に以下を作成:
|
|
21
|
+
|
|
22
|
+
- **`app.py`** — `get_request_id()` Depends 注入・`configure_problem_details()` 設定・`SimpleDomainHandler` でカスタム例外マッピング
|
|
23
|
+
- **`test_app.py`** — 正常系・404・Problem Details base_url・request_id 相関 (9 件)
|
|
24
|
+
- **`test_friction.py`** — 摩擦点の確認テスト (4 件)
|
|
25
|
+
|
|
26
|
+
**テスト結果**: 13 件全通過 ✅
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 摩擦点
|
|
31
|
+
|
|
32
|
+
### FP42-1: RequestIdMiddleware なしで get_request_id() を呼ぶと空文字が返る
|
|
33
|
+
|
|
34
|
+
**分類**: 注意喚起(ドキュメントに記載済み)
|
|
35
|
+
|
|
36
|
+
`get_request_id()` は `contextvars` を参照する。
|
|
37
|
+
テスト関数から直接呼ぶ場合や `RequestIdMiddleware` を経由しない場合は `""` を返す。
|
|
38
|
+
`TestClient` 経由でリクエストを送れば正しく UUID が返る。
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
# RequestIdMiddleware なしで直接呼ぶ → ""
|
|
42
|
+
from nene2.middleware import get_request_id
|
|
43
|
+
assert get_request_id() == ""
|
|
44
|
+
|
|
45
|
+
# TestClient 経由で呼ぶ → UUID v4
|
|
46
|
+
r = client.get("/debug/request-id")
|
|
47
|
+
assert len(r.json()["request_id"]) == 36
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**判断**: ドキュメントに記載済みの動作。TestClient 経由で使うことを徹底すれば問題ない。
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### FP42-2: configure_problem_details() のグローバル状態がテスト間で共有される
|
|
55
|
+
|
|
56
|
+
**分類**: 軽微な摩擦(設計上の制約・テスト時の注意点)
|
|
57
|
+
|
|
58
|
+
`configure_problem_details()` はモジュールレベルのグローバル変数 `_configured_base_url` を変更する。
|
|
59
|
+
異なる `base_url` で複数の `create_app()` を呼ぶと最後の設定が残り、
|
|
60
|
+
テスト間で state が漏れる。
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
create_app(base_url="https://first.example.com/problems/")
|
|
64
|
+
# _configured_base_url == "https://first.example.com/problems/"
|
|
65
|
+
|
|
66
|
+
create_app(base_url="https://second.example.com/problems/")
|
|
67
|
+
# _configured_base_url == "https://second.example.com/problems/"
|
|
68
|
+
# ← first の設定は上書きされている
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**対処**: テスト間で隔離が必要な場合、`nene2.http.problem_details._configured_base_url = None`
|
|
72
|
+
で手動リセットするか、全テストで同一の base_url を使う。
|
|
73
|
+
運用環境では起動時に一度だけ呼ぶ設計なので実害はない。
|
|
74
|
+
|
|
75
|
+
**判断**: アプリ起動時一度だけ呼ぶ設計であり仕様通り。テスト向けに `reset_problem_details()` 関数を追加する価値があるかもしれない。
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### FP42-3: SimpleDomainHandler のエラーレスポンスに request_id が自動付与されない
|
|
80
|
+
|
|
81
|
+
**分類**: 設計上の制約(許容範囲・パターン提示)
|
|
82
|
+
|
|
83
|
+
`ErrorHandlerMiddleware` + `SimpleDomainHandler` が生成する 404 レスポンスには
|
|
84
|
+
`request_id` フィールドが自動追加されない。
|
|
85
|
+
`X-Request-Id` ヘッダーは `RequestIdMiddleware` が付与するが、
|
|
86
|
+
レスポンスボディへの `request_id` 付与はアプリ側で明示的に行う必要がある。
|
|
87
|
+
|
|
88
|
+
エラーレスポンスに `request_id` を含めたい場合は、`problem_details_response()` を
|
|
89
|
+
直接呼ぶ exception handler を登録するか、`SimpleDomainHandler` を継承して
|
|
90
|
+
`request_id` を `extra` に追加するカスタム実装が必要。
|
|
91
|
+
|
|
92
|
+
**判断**: `ErrorHandlerMiddleware` はドメインレイヤーに依存しない設計のため、
|
|
93
|
+
`request_id` のような HTTP 横断概念を自動付与しないのは正しい。
|
|
94
|
+
クライアントが `X-Request-Id` ヘッダーを参照すれば相関できる。
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### FP42-4: Annotated[str, Depends(get_request_id)] 構文は問題なく動作する
|
|
99
|
+
|
|
100
|
+
**分類**: 摩擦なし(良い設計の確認)
|
|
101
|
+
|
|
102
|
+
Python 3.12+ 推奨の `Annotated` 構文で `get_request_id()` を注入できる。
|
|
103
|
+
FastAPI の型推論も正しく動作し、`str` 型として扱われる。
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from typing import Annotated
|
|
107
|
+
from fastapi import Depends
|
|
108
|
+
from nene2.middleware import get_request_id
|
|
109
|
+
|
|
110
|
+
async def handler(
|
|
111
|
+
request_id: Annotated[str, Depends(get_request_id)],
|
|
112
|
+
) -> JSONResponse:
|
|
113
|
+
return JSONResponse({"request_id": request_id})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**判断**: FT25 で実装した `get_request_id()` は `Annotated` + `Depends` パターンと完全に互換。
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## フレームワーク変更
|
|
121
|
+
|
|
122
|
+
なし(全て設計通りの挙動)
|
|
123
|
+
|
|
124
|
+
以下のドキュメント追記を検討:
|
|
125
|
+
- `docs/how-to/` に `get_request_id()` Depends パターンの how-to ガイドを追加
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 関連
|
|
130
|
+
|
|
131
|
+
- `nene2.middleware.get_request_id` (FT25, v1.8.1)
|
|
132
|
+
- `nene2.middleware.RequestIdMiddleware`
|
|
133
|
+
- `nene2.http.configure_problem_details` (FT19, v1.8.0)
|
|
134
|
+
- `nene2.middleware.SimpleDomainHandler` (FT21, v1.8.0)
|
|
135
|
+
- FT19 (configure_problem_details 実装, v1.8.0)
|
|
136
|
+
- FT21 (SimpleDomainHandler 実装, v1.8.0)
|
|
137
|
+
- FT25 (get_request_id 実装, v1.8.1)
|
|
@@ -103,6 +103,27 @@ engine = create_engine(
|
|
|
103
103
|
|
|
104
104
|
`StaticPool` guarantees all logical connections share the same underlying SQLite connection, so tables created in one operation are visible to the next.
|
|
105
105
|
|
|
106
|
+
## Capturing structlog output with caplog
|
|
107
|
+
|
|
108
|
+
Call `configure_for_testing()` at module level in `conftest.py` to route structlog through stdlib logging so pytest's `caplog` fixture can capture it.
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
# conftest.py
|
|
112
|
+
from nene2.log import configure_for_testing
|
|
113
|
+
configure_for_testing()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Then assert on message strings in tests:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
def test_handler_logs(caplog: pytest.LogCaptureFixture) -> None:
|
|
120
|
+
client = TestClient(create_app())
|
|
121
|
+
client.post("/api/echo", json={"message": "hello"})
|
|
122
|
+
assert any("processing echo" in r.message for r in caplog.records)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Note**: `caplog.records` returns stdlib `LogRecord` objects. Fields bound with `structlog.contextvars.bind_contextvars()` (such as `request_id`) are not directly accessible as `record.request_id` — they appear as part of the formatted message string instead.
|
|
126
|
+
|
|
106
127
|
## Coverage requirements
|
|
107
128
|
|
|
108
129
|
| Scope | Target |
|