Development¶
Setup¶
uv sync --extra dev # Python 3.11+ environment in .venv with test and lint tools
cp .env.example .env # LLM endpoint and local settings
dotnet restore ui/MiddlewareForge.slnx
Run everything locally with uv run python serve.py (API on 8000, UI on 5180), or without an LLM:
uv run python scripts/dev_mock_backend.py --port 8000
ForgeApi__BaseUrl=http://127.0.0.1:8000 dotnet run --project ui/src/MiddlewareForge.Web
VS Code users get a debug configuration for the API in .vscode/launch.json.
Repository layout¶
src/middleware_forge/ backend and CLI (see Architecture → Modules)
tests/ pytest suite; tests/_support has mock LLMs and helpers, tests/fixtures the test documents
ui/ Blazor web UI (src/) and its bUnit tests (tests/)
template/ OSB templates, CommonSchema.xsd and the ICD template (template/docs/)
example/ sample specifications and the reference OSB project (example/OSB/TravelService)
scripts/ mock backend, stub LLM, fixture capture, end-to-end smoke test
deploy/ container env example, IIS web.config, smoke-test overlay
docs/ this documentation (MkDocs)
Tests and checks¶
| Check | Command |
|---|---|
| Backend tests | uv run --extra dev pytest |
| Coverage (gate: 80%) | uv run --extra dev pytest --cov |
| Lint | uv run --extra dev ruff check src tests scripts serve.py |
| Deprecated APIs | uv run --extra dev basedpyright (deprecation check only, including APIs deprecated in type stubs) |
| UI build and tests | dotnet test ui/MiddlewareForge.slnx |
| End-to-end | scripts/e2e_smoke.py against a running backend (Operations) |
| Documentation | uv run --only-group docs mkdocs build --strict |
How the tests are isolated:
tests/conftest.pygives every test its own data folder, settings, database, broker, graphs and job pools.- The LLM is replaced by
MockLLMClient, whose handler returns canned plans and runs the deterministic builders for XML calls. tests/_support/scripted_llm.ScriptedLLMqueues replies per call type for conversation tests.tests/_support/runs.run_planruns a plan through the same path as a session, without a session.- Repository tests use a local bare repository (
tests/_support/gitrepo.py) and mocked HTTP for pull requests. - A
DeprecationWarningfails the suite (filterwarningsinpyproject.toml). Move to the replacement API; only an unavoidable third-party warning gets a narrowignoreentry there.
UI contract fixtures¶
The web UI's C# contracts (Services/Contracts.cs) are written by hand and checked against JSON captured from the real API (ui/tests/MiddlewareForge.Web.Tests/Fixtures). After changing an API response, re-capture them and run the UI tests:
Conventions¶
- Plan changes go through plan operations. Add a new kind of edit as a
PlanPatchOpinmodels/plan.pyand handle it inplan_ops._apply; describe it inllm/prompts.PLAN_OPERATIONS_GUIDEif the chat should use it. - Validation is deterministic. New blockers belong in
plan_ops.validate_planorsessions.session_issues, with a stablecode. - Generators are deterministic first. A new artifact needs a builder or a template, a validation rule, and a generation unit with a fingerprint covering everything that shapes its output. Bump
GENERATOR_VERSION(generators/layout.py) orDOCS_VERSION(generators/docs/__init__.py) when output changes for identical input. - Paths are server-controlled. Use
naming.ensure_withinfor every path built from data. - Every LLM call is replaceable. Go through
get_container().llmand give it a distinctrun_name, so tests can script it. - Schema changes need a migration. Add an Alembic revision under
persistence/migrations/versions/. Migrations run at startup and must be forward-only. - Style. ruff is configured in
pyproject.toml(line length 120, no enforced formatter). FastAPI parameters and Typer options use theAnnotated[...]form (ruffFAST).
Changing the OSB templates¶
Templates live in template/{project_name}/ and use {placeholder} tokens (wsdl_ref, binding_name, namespace, pipeline_ref, endpoint, business_service_ref, …); TemplateRenderer fails on unknown placeholders. Template changes alter the template digest, so the next run regenerates the template-based units. Run the generator tests (tests/generators) and import a generated project into JDeveloper or the OSB console to check it.
Documentation¶
The site is built with MkDocs and Material for MkDocs from docs/ and mkdocs.yml; diagrams are Mermaid code blocks. MkDocs is pinned below 2.0 (pyproject.toml, group docs), because MkDocs 2.0 drops the plugin and theme system Material depends on.
uv run --only-group docs mkdocs serve # live preview on http://127.0.0.1:8000
uv run --only-group docs mkdocs build --strict
Publishing to GitHub Pages¶
.github/workflows/docs.yml builds the site with --strict on every pull request that touches the documentation, and publishes it to GitHub Pages on pushes to main (or when run manually).
One-time setup in the GitHub repository:
- Settings → Pages → Build and deployment → Source: GitHub Actions.
- GitHub Pages on a private repository requires a GitHub plan that includes Pages for private repositories (Pro, Team or Enterprise). On a free plan, make the repository public or publish the
site/folder elsewhere.
The site is published at https://mkamiasim.github.io/middleware-forge/ (adjust site_url in mkdocs.yml if the repository moves).