diff --git a/README.md b/README.md index 192e980..91479c0 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,9 @@ model call, and the run never falls back to CodeBoarding's model. The action independently calls `POST /v1/review-guide` and `POST /v1/architecture` on the same `review_guide_url` base URL. There is no discovery request. Both receive the same required analysis inputs. The guide endpoint returns `{guide, usage, timingsMs}`; the action -saves the bare guide as `review_guide.json`. Architecture returns `{envelope, usage}`; its +saves the bare guide as `review_guide.json`. When the service has no model for the run, or the +model step fails or runs out of time, the guide still carries its structure and says what is +missing in `words` (`{"status": "missing" | "partial", "reason": ...}`). Architecture returns `{envelope, usage}`; its envelope is saved unchanged as `closed/architecture.json`, including partial, skipped and failed results. Failure of either request does not prevent the other or fail the review. The guide's request body, the same xz-compressed bytes the service receives, is saved as @@ -213,7 +215,7 @@ Symlinks are not read. Individual files are capped at 300 KB and source at 16 MB source exceeds the 4.3 MB compressed request limit, it is omitted with a reason; architecture still runs with the required inputs. `closed_features_source: false` also omits source, and merge risk then sends its file list without patches. -An unsupported provider skips the guide, but architecture can still return measured findings. +An unsupported provider still gets the guide's structure and architecture's measured findings. ### Providers diff --git a/scripts/remote_features.py b/scripts/remote_features.py index eaa7e95..2a8a6fe 100644 --- a/scripts/remote_features.py +++ b/scripts/remote_features.py @@ -719,9 +719,9 @@ def keep_bundle(artifact: Path, data: bytes | None) -> None: def run_review_guide(service_url: str, data: bytes, headers: dict, artifact: Path) -> None: + """The guide as the service returned it. A run the service has no model for, or whose model step + failed, still gets the guide's structure, marked by `words` with what is missing and why.""" try: - if "x-llm-provider" in headers and "x-llm-api-key" not in headers: - raise Skip("the service cannot call this run's provider") keep_bundle(artifact, data) answer = _post(f"{service_url.rstrip('/')}/v1/review-guide", data, headers) guide = answer.get("guide") diff --git a/tests/test_remote_features.py b/tests/test_remote_features.py index ef8f3f9..233553e 100644 --- a/tests/test_remote_features.py +++ b/tests/test_remote_features.py @@ -505,14 +505,22 @@ def test_all_architecture_statuses_preserved(self): self.run_service(lambda p, b: (200, {"guide": GUIDE, "envelope": envelope})) self.assertEqual(_read(self.env, "closed/architecture.json"), envelope) - def test_unsupported_provider_still_gets_measured_architecture(self): + def test_unsupported_provider_gets_the_guide_structure_and_measured_architecture(self): self.env.update(LLM="litellm", LITELLM_API_KEY="secret") - service = self.run_service() - self.assertEqual([r["path"] for r in service.requests], ["/v1/architecture"]) - headers = {k.lower(): v for k, v in service.requests[0]["headers"].items()} - self.assertEqual(headers["x-llm-provider"], "litellm") - self.assertNotIn("x-llm-api-key", headers) - self.assertFalse((Path(self.env["ARTIFACT_DIR"]) / "review_guide.json").exists()) + structure = {**GUIDE, "words": {"status": "missing", "reason": "no_model"}} + service = self.run_service(lambda p, b: (200, {"guide": structure, "envelope": ENVELOPE})) + self.assertEqual(sorted(r["path"] for r in service.requests), ["/v1/architecture", "/v1/review-guide"]) + for request in service.requests: + headers = {name.lower(): value for name, value in request["headers"].items()} + self.assertEqual(headers["x-llm-provider"], "litellm") + self.assertNotIn("x-llm-api-key", headers) + self.assertEqual(_read(self.env, "review_guide.json"), structure) + + def test_a_guide_without_the_models_words_is_stored_as_returned(self): + for status, reason in (("missing", "model_error"), ("missing", "timeout"), ("partial", "timeout")): + structure = {**GUIDE, "words": {"status": status, "reason": reason}} + self.run_service(lambda p, b: (200, {"guide": structure, "envelope": ENVELOPE})) + self.assertEqual(_read(self.env, "review_guide.json"), structure) def test_missing_shared_input_records_failure_without_requests(self): (Path(self.env["HEAD_ANALYSIS_PATH"]).parent / "static_analysis.pkl").unlink() @@ -860,10 +868,11 @@ def test_not_written_when_inputs_are_missing(self): self.assertEqual(self.run_service().requests, []) self.assert_not_kept() - def test_not_written_when_the_guide_cannot_call_the_provider(self): + def test_kept_when_the_service_cannot_call_the_provider(self): self.env.update(LLM="litellm", LITELLM_API_KEY="secret") - self.assertEqual([request["path"] for request in self.run_service().requests], ["/v1/architecture"]) - self.assert_not_kept() + service = self.run_service() + sent = next(request["body"] for request in service.requests if request["path"] == "/v1/review-guide") + self.assertEqual(self.bundle().read_bytes(), sent) def test_not_written_over_the_service_limit(self): with mock.patch.object(remote_features, "MAX_COMPRESSED_BYTES", 1):