Skip to content

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.py gives 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.ScriptedLLM queues replies per call type for conversation tests.
  • tests/_support/runs.run_plan runs 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 DeprecationWarning fails the suite (filterwarnings in pyproject.toml). Move to the replacement API; only an unavoidable third-party warning gets a narrow ignore entry 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:

uv run --extra dev python scripts/capture_ui_fixtures.py
dotnet test ui/MiddlewareForge.slnx

Conventions

  • Plan changes go through plan operations. Add a new kind of edit as a PlanPatchOp in models/plan.py and handle it in plan_ops._apply; describe it in llm/prompts.PLAN_OPERATIONS_GUIDE if the chat should use it.
  • Validation is deterministic. New blockers belong in plan_ops.validate_plan or sessions.session_issues, with a stable code.
  • 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) or DOCS_VERSION (generators/docs/__init__.py) when output changes for identical input.
  • Paths are server-controlled. Use naming.ensure_within for every path built from data.
  • Every LLM call is replaceable. Go through get_container().llm and give it a distinct run_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 the Annotated[...] form (ruff FAST).

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:

  1. Settings → Pages → Build and deployment → Source: GitHub Actions.
  2. 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).