Skip to content

feat(roadmap): Seam the serve start and the roadmap table - #6150

Merged
dan-petty merged 6 commits into
mainfrom
test/3885-add-the-seams-the-serve-and
Nov 18, 2026
Merged

dan-petty merged 6 commits into
mainfrom
test/3885-add-the-seams-the-serve-and

Conversation

@devops-cli-service

@devops-cli-service devops-cli-service Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The serve and roadmap tests patched uvicorn.run and run_due_jobs, because no seam showed a test the ASGI app that devops serve starts or the lane table that a Service lane runs (#3885). This change adds the server start seam (ServerStarter, with FakeServerStarter and a contract test on a loopback port) and LaneSpec on the app state. It moves the body of roadmap run into run_roadmap_command, and adds the two devops ci cache cases over the git fake. The patch ceiling falls from 377 to 375.

Closes #3885

Change: openspec/changes/archive/2026-11-18-3885-add-the-seams-the-serve-and/

@devops-cli-service devops-cli-service Bot added type/feature Type feature: a new function scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 17, 2026
@devops-cli-service
devops-cli-service Bot force-pushed the test/3885-add-the-seams-the-serve-and branch from 0973ce3 to b2c6a4c Compare November 17, 2026 10:01
@devops-cli-service

Copy link
Copy Markdown
Contributor Author

The steps of the job:

Stopped at group 2.

Failure class: provider.
Action taken: none.
Action left: retry: run the item again.

Step Status Attempts Tokens in/out Last failing command
group 1 done 1 3979533/24080 pytest on base: tests/server/test_server_start_seam.py
group 2 stopped 1 2831187/19092 -

Reason:

ModelRateLimitError: HTTP 429, model openrouter/deepseek/deepseek-v4.1-flash-1017, body: No deployments available for selected model, Try again in 120 seconds. Passed model
Refused commands: 0. Other retries: 1.

Last message of the agent (a claim that no check verified): Now the source change in serve.py:

The job discarded this work. Read it before you retry:

diff --git a/src/devops_cli/commands/serve.py b/src/devops_cli/commands/serve.py
index 1c96e39e2..12e9f5a83 100644
--- a/src/devops_cli/commands/serve.py
+++ b/src/devops_cli/commands/serve.py
@@ -23,6 +23,7 @@ from devops_cli.output import (
     print_info,
     print_success,
 )
+from devops_cli.server.start import get_server_starter
 
 if TYPE_CHECKING:
     pass
@@ -41,8 +42,8 @@ app = new_typer(
 def uvicorn_options(
     *, host: str, port: int, reload: bool, workers: int, log_level: str, service: bool
 ) -> dict[str, Any]:
-    """The options that `devops serve` passes to `uvicorn.run`, besides the app. The start and
-    its dry run both use them."""
+    """The options that `devops serve` passes to the server start, besides the app. The start
+    and its dry run both use them."""
     if service:
         return {"host": host, "port": port}
     if reload:
@@ -123,8 +124,6 @@ def serve(
         )
         return
 
-    import uvicorn
-
     if service:
         from devops_cli.config.constants import CONST_SERVICE_FAILURES_FILENAME
         from devops_cli.config.settings import load_settings
@@ -179,7 +178,7 @@ def serve(
                 read_row_state=read_row_state,
             )
 
-        uvicorn.run(
+        get_server_starter().start(
             service_app,
             factory=True,
             log_config=service_log_config(log_level),
@@ -228,6 +227,6 @@ def serve(
 
     if reload:
         # In reload mode, pass module string
-        uvicorn.run("devops_cli.server.app:create_app", factory=True, **options)
+        get_server_starter().start("devops_cli.server.app:create_app", factory=True, **options)
     else:
-        uvicorn.run(fastapi_app, **options)
+        get_server_starter().start(fastapi_app, **options)
diff --git a/tests/roadmap/test_roadmap_run_service.py b/tests/roadmap/test_roadmap_run_service.py
index 9dade1e45..cfbea0e67 100644
--- a/tests/roadmap/test_roadmap_run_service.py
+++ b/tests/roadmap/test_roadmap_run_service.py
@@ -23,11 +23,26 @@ from devops_cli.roadmap.run import (
 )
 from devops_cli.server.service import TriggerBatch, no_round_pause
 from tests.support.fakes.roadmap_store import InMemoryRoadmapStore
+from tests.support.fakes.server import FakeServerStarter
 from tests.support.roadmap_run import NOW, OPENED, PLACED, REPO
 
 pytestmark = pytest.mark.usefixtures("keyring_store")
 
 
+def install_fake_starter() -> FakeServerStarter:
+    """Install a `FakeServerStarter` for this case, and give it to the case.
+
+    `devops serve --service` starts the server through `devops_cli.server.start`, so the fake
+    records the start call and builds the app from the factory, as uvicorn does. The reset of the
+    test floor removes it after the case (`tests/conftest.py`).
+    """
+    from devops_cli.server.start import install_server_starter
+
+    fake = FakeServerStarter()
+    install_server_starter(fake)
+    return fake
+
+
 @pytest.fixture
 def service_settings(monkeypatch: pytest.MonkeyPatch) -> None:
     """The settings `devops serve --service` needs to manage REPO as a GitHub App."""
@@ -51,9 +66,9 @@ def test_service_wiring(
     (#1532, #5553). The start removes the clone of an earlier lane."""
     retired = service_state_dir() / REPO / "model-clone"
     retired.mkdir(parents=True)
-    with patch("uvicorn.run") as mock_uvicorn:
-        res = cli(["serve", "--service"])
-        fastapi_app = mock_uvicorn.call_args[0][0]()
+    fake = install_fake_starter()
+    res = cli(["serve", "--service"])
+    fastapi_app = fake.apps[0]
 
     batch = TriggerBatch(repo=REPO, counts={OPENED: 1}, first_at=NOW, last_at=NOW)
     with patch("devops_cli.roadmap.run.run_due_jobs") as mock_run:
@@ -110,9 +125,9 @@ def test_the_service_that_serve_starts_reads_its_halt_and_budget_from_the_volume
     window = [[(datetime.now(UTC) - timedelta(minutes=5)).isoformat(), 60]]
     (volume / CONST_SERVICE_BUDGET_FILENAME).write_text(json.dumps(window), encoding="utf-8")
 
-    with patch("uvicorn.run") as mock_uvicorn:
-        res = cli(["serve", "--service"])
-        manager = mock_uvicorn.call_args[0][0]().state.service_manager
+    fake = install_fake_starter()
+    res = cli(["serve", "--service"])
+    manager = fake.apps[0].state.service_manager
 
     assert (res.exit_code, manager.pause.halted(), manager.budget.spent()) == (0, True, 60)
 
@@ -133,9 +148,9 @@ def test_in_a_pod_the_service_reads_its_volume_only_when_it_holds_the_lease_of_t
     halt = {"identity": "devops-roadmap[bot]", "repo": REPO, "kind": "GitHubUnauthenticatedError"}
     (volume / CONST_SERVICE_HALT_FILENAME).write_text(json.dumps(halt), encoding="utf-8")
 
-    with patch("uvicorn.run") as mock_uvicorn:
-        res = cli(["serve", "--service"])
-        manager = mock_uvicorn.call_args[0][0]().state.service_manager
+    fake = install_fake_starter()
+    res = cli(["serve", "--service"])
+    manager = fake.apps[0].state.service_manager
 
     lease = manager.rows_lease
     assert (
diff --git a/tests/server/test_server.py b/tests/server/test_server.py
index a14d12483..d42248944 100644
--- a/tests/server/test_server.py
+++ b/tests/server/test_server.py
@@ -3,7 +3,6 @@
 from __future__ import annotations
 
 import logging
-from collections.abc import Callable
 from pathlib import Path
 from typing import Any
 from unittest.mock import patch
@@ -17,6 +16,7 @@ from devops_cli.commands.serve import app as serve_app
 from devops_cli.config.constants import CONST_GITHUB_APP_PRIVATE_KEY_ENV
 from devops_cli.server.app import create_app
 from devops_cli.server.json_logs import service_log_config
+from tests.support.fakes.server import FakeServerStarter
 
 pytestmark = pytest.mark.usefixtures("keyring_store")
 
@@ -26,6 +26,27 @@ def runner() -> CliRunner:
     return CliRunner()
 
 
+class NoStartStarter(FakeServerStarter):
+    """A starter that fails the case: a run that starts no server reaches it never."""
+
+    def start(self, target: Any, /, **options: Any) -> None:
+        raise AssertionError("no server")
+
+
+def install_fake_starter(starter: FakeServerStarter | None = None) -> FakeServerStarter:
+    """Install a `FakeServerStarter` for this case, and give it to the case.
+
+    The start of `devops serve` goes through `devops_cli.server.start`, so the fake records the
+    call that the command made and builds the app from a factory as uvicorn does. The reset of
+    the test floor removes it after the case (`tests/conftest.py`).
+    """
+    from devops_cli.server.start import install_server_starter
+
+    fake = starter if starter is not None else FakeServerStarter()
+    install_server_starter(fake)
+    return fake
+
+
 @pytest.fixture
 def client() -> TestClient:
     """Fixture providing TestClient for FastAPI app."""
@@ -299,14 +320,14 @@ def test_serve_cli_help(runner: CliRunner) -> None:
 
 def test_serve_cli_invocation_mocked(runner: CliRunner) -> None:
     """Test devops serve starts uvicorn server."""
-    with patch("uvicorn.run") as mock_uvicorn:
-        result = runner.invoke(serve_app, ["--host", "::1", "--port", "9000"])
-        assert result.exit_code == 0
-        assert mock_uvicorn.called
-        assert (mock_uvicorn.call_args.kwargs["host"], mock_uvicorn.call_args.kwargs["port"]) == (
-            "::1",
-            9000,
-        )
+    fake = install_fake_starter()
+
+    result = runner.invoke(serve_app, ["--host", "::1", "--port", "9000"])
+
+    assert (result.exit_code, [(call.host, call.port) for call in fake.calls]) == (
+        0,
+        [("::1", 9000)],
+    )
 
 
 def test_serve_service_mode_flags_rejected(runner: CliRunner) -> None:
@@ -380,16 +401,15 @@ def test_serve_service_mode_success(runner: CliRunner, monkeypatch: pytest.Monke
     monkeypatch.setenv("DEVOPS_CLI_SERVICE_REPOS", '["example-org/repo1"]')
     _set_github_app(monkeypatch)
     monkeypatch.setenv("DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS", '{"example-org/repo1":"secret-1"}')
+    fake = install_fake_starter()
+
+    result = runner.invoke(serve_app, ["--service", "--host", "::1", "--port", "8787"])
 
-    with patch("uvicorn.run") as mock_uvicorn:
-        result = runner.invoke(serve_app, ["--service", "--host", "::1", "--port", "8787"])
-        assert (
-            result.exit_code,
-            mock_uvicorn.called,
-            mock_uvicorn.call_args.kwargs["host"],
-            mock_uvicorn.call_args.kwargs["port"],
-            mock_uvicorn.call_args.kwargs["log_config"],
-        ) == (0, True, "::1", 8787, service_log_config("info"))
+    calls = [
+        (call.host, call.port, call.factory, call.log_config == service_log_config("info"))
+        for call in fake.calls
+    ]
+    assert (result.exit_code, calls) == (0, [("::1", 8787, True, True)])
 
 
 def test_serve_service_mode_leaves_logging_to_the_server(
@@ -405,25 +425,29 @@ def test_serve_service_mode_leaves_logging_to_the_server(
     monkeypatch.setenv("DEVOPS_CLI_SERVICE_REPOS", '["example-org/repo1"]')
     _set_github_app(monkeypatch)
     monkeypatch.setenv("DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS", '{"example-org/repo1":"secret-1"}')
+    install_fake_starter()
 
-    with patch("uvicorn.run"):
-        result = runner.invoke(serve_app, ["--service"])
+    result = runner.invoke(serve_app, ["--service"])
     logging.getLogger("devops_cli.server").warning("a record after the service command")
 
     assert (result.exit_code, "a record after the service command" in caplog.text) == (0, True)
 
 
-def test_serve_service_mode_builds_the_app_after_the_server_applies_its_logging(
+def test_serve_service_mode_hands_the_starter_an_app_factory_and_the_json_log_config(
     runner: CliRunner, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
 ) -> None:
-    """uvicorn builds the service app from a factory after it applies the JSON `log_config`.
+    """The service start names a factory and the JSON `log_config`, and the fake builds the app.
 
-    Building the app warns about each managed repository with no webhook secret. Built before the
-    command called uvicorn, that warning had no handler yet and came out as plain text on stderr.
+    uvicorn applies `log_config` and then builds the app from the factory, so building the app
+    warns about each managed repository with no webhook secret after the JSON logging is on. A
+    command that built the app itself would pass the app, set no factory, and leave `apps` empty.
     """
     monkeypatch.setenv("DEVOPS_CLI_SERVICE_REPOS", '["example-org/repo1", "example-org/repo2"]')
     _set_github_app(monkeypatch)
     monkeypatch.setenv("DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS", '{"example-org/repo1":"secret-1"}')
+    fake = install_fake_starter()
+
+    result = runner.invoke(serve_app, ["--service"])
 
     def missing_secret_warnings() -> list[str]:
         return [
@@ -432,24 +456,17 @@ def test_serve_service_mode_builds_the_app_after_the_server_applies_its_logging(
             if record.getMessage().startswith("No webhook secret configured")
         ]
 
-    warnings_when_run: list[list[str]] = []
-
-    def run(app_factory: Callable[[], object], **_: object) -> None:
-        warnings_when_run.append(missing_secret_warnings())
-        app_factory()
-
-    with patch("uvicorn.run", side_effect=run) as mock_uvicorn:
-        result = runner.invoke(serve_app, ["--service"])
-
     assert (
         result.exit_code,
-        mock_uvicorn.call_args.kwargs.get("factory"),
-        warnings_when_run,
+        [call.factory for call in fake.calls],
+        [call.log_config == service_log_config("info") for call in fake.calls],
+        len(fake.apps),
         missing_secret_warnings(),
     ) == (
         0,
-        True,
-        [[]],
+        [True],
+        [True],
+        1,
         ["No webhook secret configured for managed repository: example-org/repo2"],
     )
 
@@ -470,13 +487,12 @@ def _plan_lines(output: str) -> list[str]:
 def test_serve_dry_run_lists_the_bind_and_the_start(cli: Any, flag_first: bool) -> None:
     """A dry run builds no app, starts no server, and lists the bind and the start."""
     argv = ["serve", "--host", "127.0.0.1", "--port", "9000", "--workers", "2"]
-    with (
-        patch("uvicorn.run", side_effect=AssertionError("no server")),
-        patch("devops_cli.server.app.create_app", side_effect=AssertionError("no app")),
-    ):
+    fake = install_fake_starter(NoStartStarter())
+    with patch("devops_cli.server.app.create_app", side_effect=AssertionError("no app")):
         result = cli(["--dry-run", *argv] if flag_first else [*argv, "--dry-run"])
 
     assert result.exit_code == 0, result.output
+    assert fake.calls == []
     assert _plan_lines(result.output) == [
         "BIND tcp 127.0.0.1:9000",
         "START uvicorn rest app (host=127.0.0.1 port=9000 workers=2 log_level=info)",
@@ -485,8 +501,8 @@ def test_serve_dry_run_lists_the_bind_and_the_start(cli: Any, flag_first: bool)
 
 def test_serve_service_dry_run_reads_no_settings(cli: Any) -> None:
     """`serve --service --dry-run` loads no settings and reads no credential."""
+    fake = install_fake_starter(NoStartStarter())
     with (
-        patch("uvicorn.run", side_effect=AssertionError("no server")),
         patch(
             "devops_cli.config.settings.load_settings", side_effect=AssertionError("no settings")
         ),
@@ -495,6 +511,7 @@ def test_serve_service_dry_run_reads_no_settings(cli: Any) -> None:
         result = cli(["serve", "--service", "--port", "9000", "--dry-run"])
 
     assert result.exit_code == 0, result.output
+    assert fake.calls == []
     assert _plan_lines(result.output) == [
         "BIND tcp 127.0.0.1:9000",
         "START uvicorn service app (host=127.0.0.1 port=9000)",
@@ -505,9 +522,10 @@ def test_serve_starts_what_its_plan_lists(cli: Any) -> None:
     """The start passes uvicorn the options of the plan."""
     argv = ["serve", "--host", "::1", "--port", "9000", "--workers", "2"]
     planned = _plan_lines(cli([*argv, "--dry-run"]).output)
-    with patch("uvicorn.run") as start:
-        result = cli(argv)
+    fake = install_fake_starter()
+
+    result = cli(argv)
 
     assert result.exit_code == 0, result.output
-    options = " ".join(f"{name}={value}" for name, value in start.call_args.kwargs.items())
+    options = " ".join(f"{name}={value}" for name, value in fake.calls[0].options.items())
     assert planned == ["BIND tcp ::1:9000", f"START uvicorn rest app ({options})"]

The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item allow it.

Step Status Attempts Tokens in/out Last failing command
group 1 done 1 3979533/24080 pytest on base: tests/server/test_server_start_seam.py
group 2 stopped 1 2831187/19092 -
  • fail-to-pass of group 1: fails on the base commit. Tests that fail on the base commit: tests.server.test_server_start_seam::test_the_real_starter_serves_a_request_on_a_loopback_port_and_stops.

@devops-cli-service
devops-cli-service Bot force-pushed the test/3885-add-the-seams-the-serve-and branch from b2c6a4c to 4a25abe Compare November 17, 2026 16:06
@devops-cli-service

Copy link
Copy Markdown
Contributor Author

The steps of the job:

Stopped at group 2.

Failure class: provider.
Action taken: none.
Action left: retry: run the item again.

Step Status Attempts Tokens in/out Last failing command
group 2 stopped 1 232931/1213 -

Reason:

ModelRateLimitError: HTTP 429, model openrouter/deepseek/deepseek-v4.1-flash-1017, body: No deployments available for selected model, Try again in 120 seconds. Passed model

Last message of the agent (a claim that no check verified): Now let me read tests/roadmap/test_roadmap_run_service.py.

The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item allow it.

Step Status Attempts Tokens in/out Last failing command
group 2 stopped 1 232931/1213 -

@devops-cli-service

Copy link
Copy Markdown
Contributor Author

The steps of the job:

Stopped at group 2.

Failure class: provider.
Action taken: none.
Action left: retry: run the item again.

Step Status Attempts Tokens in/out Last failing command
group 2 stopped 1 211018/487 -

Reason:

ModelServerError: HTTP 500, model openrouter/deepseek/deepseek-v4.1-flash-1017, body: litellm.APIConnectionError: APIConnectionError: OpenrouterException - Response payload is not completed: <TransferEncodingError: 400, message

Last message of the agent (a claim that no check verified): none.

The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item allow it.

Step Status Attempts Tokens in/out Last failing command
group 2 stopped 1 211018/487 -

@dan-petty
dan-petty force-pushed the test/3885-add-the-seams-the-serve-and branch from b32bb32 to 36d080a Compare November 18, 2026 04:29
@dan-petty
dan-petty marked this pull request as ready for review November 18, 2026 04:36
@dan-petty
dan-petty self-requested a review as a code owner November 18, 2026 04:36
@dan-petty
dan-petty merged commit de55e8b into main Nov 18, 2026
25 checks passed
@dan-petty
dan-petty deleted the test/3885-add-the-seams-the-serve-and branch November 18, 2026 04:37
dan-petty-release Bot added a commit that referenced this pull request Nov 18, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.175.0](v0.174.7...v0.175.0)
(2026-11-18)


### Features

* **roadmap:** Add a loopback gateway broker to a step
([#6157](#6157))
([d15dfcf](d15dfcf))
* **roadmap:** Add RAG index rows to repository onboarding
([#6041](#6041))
([59b424a](59b424a))
* **roadmap:** Seam the serve start and the roadmap table
([#6150](#6150))
([de55e8b](de55e8b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/feature Type feature: a new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(roadmap): add the seams the serve and ci tests still lack

1 participant