Development guide
Run
# Start frontend with API mocking
# inside /mucgpt-frontend
npm run dev
# Start frontend using container stack for API
# inside /mucgpt-frontend
npm run dev-no-mock
# Start stack with local running services
# inside /stack
podman compose -f docker-compose.yml -f docker-compose.dev.yml upWorking with UV
Synchronize / Update Packages
In existing projects, the collected dependencies can be synchronized or updated with a single command.
# Synchronize packages
uv sync --all-extras
# Update packages
uv lock -UInstall pre-commit hooks
uv run pre-commit installAdd Packages
Packages can be added using the following command
# Add package
uv add pydantic
### Remove Packages
Packages can also be removed.
```bash
# Remove package
uv remove pydanticRunning tests
uv run pytestReal PostgreSQL in tests via Testcontainers
The core-service opt-in lifecycle tests (tests/integration/test_*_postgres.py) and the assistant-service database tests (tests/database/, parameterized postgres runs) can use Testcontainers with a throwaway postgres:17.4 container. Their behavior differs:
- Core: when
MUCGPT_LIFECYCLE_POSTGRES_HOSTis set (as in CI), tests use that server and do so even whenMUCGPT_TEST_POSTGRES=off. Otherwise,MUCGPT_TEST_POSTGRES=offprevents container startup and the affected tests skip. - Assistant: the database fixture ignores
MUCGPT_LIFECYCLE_POSTGRES_HOST; it starts a container when available, or omits PostgreSQL parameterized runs when container tests are disabled or no runtime is detected. Assistant tests may not use the configured lifecycle PostgreSQL server. - otherwise: a container starts automatically when a container runtime is reachable. Docker is tried first, then the Podman API socket (rootless before rootful) — Podman is the preferred local runtime; the socket service must be enabled (
systemctl --user enable --now podman.socket). On Windows, the running Podman machine is managed through thepodmanCLI instead, avoiding the unreliable Docker SDK named-pipe transport. MUCGPT_TEST_CONTAINER_RUNTIME=docker|podmanforces one runtime.- No container runtime reachable: the affected tests skip gracefully; nothing fails.
Windows and Podman
On Windows, start a Podman machine before running the core lifecycle tests:
podman machine start
podman machine listThe test harness starts and removes a disposable PostgreSQL container through the Podman CLI automatically; no lifecycle database environment variables are required. You can force the Podman path when troubleshooting:
$env:MUCGPT_TEST_CONTAINER_RUNTIME = "podman"
uv run pytest tests/integration/test_document_catalog_postgres.pyWindows uses a selector event loop because psycopg's asynchronous driver does not work with the default Proactor event loop. Ryuk is disabled for Podman named pipes; the pytest process owns the container and explicitly stops it during normal teardown, atexit, Ctrl+C, and termination handling. If a run is killed before cleanup can execute, inspect only Testcontainers-labeled containers before removing them—do not remove unrelated Compose containers.
For CI or an externally managed PostgreSQL instance, set MUCGPT_LIFECYCLE_POSTGRES_HOST, MUCGPT_LIFECYCLE_POSTGRES_PORT, MUCGPT_LIFECYCLE_POSTGRES_USER, and MUCGPT_LIFECYCLE_POSTGRES_PASSWORD. When the host is set, no Testcontainers container is started.
Core PostgreSQL lifecycle tests share the isolated database context in mucgpt-core-service/tests/postgres.py; new lifecycle tests should reuse it instead of creating their own containers, databases, or migration setup.
Coverage gates are enforced on full-suite runs (--cov-fail-under in each service's pyproject.toml addopts and thresholds in the frontend's vitest.config.ts; partial runs like pytest tests/unit skip the gate). If you add code, raise the floor instead of lowering it.
# Frontend (inside mucgpt-frontend/) — runs tests with coverage and thresholds
npm run testAnalyze a Langfuse trace
The core service includes a diagnostic script for investigating a single trace. It prints a chronological observation timeline, including model, finish reason, tool calls, and an explicit CONTENT_FILTERED marker when the provider stops a generation with content_filter or content_policy_violation.
Run it from mucgpt-core-service/:
uv run python app/scripts/analyze_langfuse_trace.py <trace-id>The script uses the legacy Langfuse v3 trace API by default. For Langfuse v4, select the supported Observations API v2 explicitly:
uv run python app/scripts/analyze_langfuse_trace.py <trace-id> --api-version v4The v4 path retrieves observations for the trace in a bounded seven-day window and follows cursor pagination. Set --from-start-time and --to-start-time with timezone-aware ISO-8601 timestamps when the trace is outside that window.
Credentials are read from LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, and LANGFUSE_HOST. When those variables are not already in the shell, the script loads stack/.env by default. Use --env-file <path> to select a different dotenv file.
The default report excludes observation inputs and outputs, which can contain user data. Inspect bounded content only in an approved environment:
uv run python app/scripts/analyze_langfuse_trace.py <trace-id> --show-contentUse --max-content-chars <n> to change the default 500-character content limit. The v3 option is retained for self-hosted v3 compatibility; v4 deployments must use --api-version v4.
Linting
uv run ruff check
# and fixing
uv run ruff check --fixType checking
Each Python service is type-checked with ty (dev dependency, pinned in the service's pyproject.toml). CI and pre-commit run uv run ty check as separate required checks per service. The checks cover application, test, and migration code. Keep the checked code clean — if a library stub is looser than runtime reality, prefer narrowing or a cast and use a targeted # ty: ignore[<rule>] comment (with a short explanation) only as a last resort.
uv run ty checkBuild new images
First create a tag (decide which one is needed)
git tag mucgpt-frontend-<version>
git tag mucgpt-core-<version>
git tag mucgpt-core-migrations-<version>
git tag mucgpt-assistant-<version>
git tag mucgpt-assistant-migrations-<version>Then push to origin, one of the release workflows is then triggered
git push origin mucgpt-frontend-<version>
git push origin mucgpt-core-<version>
git push origin mucgpt-core-migrations-<version>
git push origin mucgpt-assistant-<version>
git push origin mucgpt-assistant-migrations-<version>You can find the available versions under:
- Frontend: https://github.com/it-at-m/mucgpt/pkgs/container/mucgpt%2Fmucgpt-frontend
- Core: https://github.com/it-at-m/mucgpt/pkgs/container/mucgpt%2Fmucgpt-core
- Core migrations: https://github.com/it-at-m/mucgpt/pkgs/container/mucgpt%2Fmucgpt-core-migrations
- Assistant: https://github.com/it-at-m/mucgpt/pkgs/container/mucgpt%2Fmucgpt-assistant
- Migrations: https://github.com/it-at-m/mucgpt/pkgs/container/mucgpt%2Fmucgpt-assistant-migrations
Every release image is also mirrored to the openCode container registry (GitLab registry of gitlab.opencode.de):
- Frontend:
registry.opencode.de/landeshauptstadt-muenchen/mucgpt/mucgpt-frontend - Core:
registry.opencode.de/landeshauptstadt-muenchen/mucgpt/mucgpt-core - Core migrations:
registry.opencode.de/landeshauptstadt-muenchen/mucgpt/mucgpt-core-migrations - Assistant:
registry.opencode.de/landeshauptstadt-muenchen/mucgpt/mucgpt-assistant - Migrations:
registry.opencode.de/landeshauptstadt-muenchen/mucgpt/mucgpt-assistant-migrations
Both registries carry the same tags (<version> and latest) and the same runnable platform images. The openCode mirror omits GHCR-only BuildKit attestations because its registry does not accept them. If the openCode push fails, the GitHub release still succeeds (the mirror step tolerates errors); re-running the release workflow for the same tag retries the mirror.
Third-party licenses
Policy lives in the root pyproject.toml under [tool.licensecheck]: a minimal allowed list, accepted warn licenses and per-package exceptions (license, version, reason). New licenses must be reviewed before being added.
.github/workflows/license-check.yaml runs the check on every pull request: shipped dependencies fail on unapproved/unknown licenses, dev-only dependencies only warn.
# Check all targets (or --targets mucgpt-core-service)
uv run python scripts/licenses/check_licenses.py
# Generate the third-party notices (THIRD_PARTY_LICENSES/ per target)
uv run python scripts/licenses/collect_licenses.pyPython service images generate the same THIRD_PARTY_LICENSES/ layout at build time using scripts/licenses/image_notices.py (core, assistant and both migration images), which is shared with the collector. Image builds use the repository root as their context so the license tooling is available to the classic Podman builder. A direct build can be run with podman build -f mucgpt-core-service/Dockerfile .. The frontend image generates the notices of its bundled (production) npm dependencies in the builder stage and ships them under /usr/share/licenses/mucgpt-frontend/THIRD_PARTY_LICENSES/ (not web-served). Vendored frontend components under public/vendor/*/ are inventoried by convention: each directory carries a license file and a SOURCE.txt with Version / Source / License metadata lines.
MCP credential handling security note
MCP source credentials and auth overrides are modeled as secret types in configuration to reduce accidental plaintext exposure in config representation and normal app logging.
However, for outbound MCP calls the credentials are materialized into HTTP headers at runtime. This means the implementation does not guarantee secrecy against host/runtime inspection (e.g., process memory inspection, crash dumps, verbose HTTP client logging, reverse-proxy/request logging, or packet capture at TLS termination boundaries).
Treat this mechanism as log/config leak reduction, not full runtime confidentiality. For production, keep HTTP client logs non-verbose, avoid logging request objects, and restrict access to host-level observability and diagnostics.