From 3346d9fc6ea65b06ab0d060e44de88196cc48b30 Mon Sep 17 00:00:00 2001 From: Dong1017 <55723162+Dong1017@users.noreply.github.com> Date: Wed, 28 Oct 2026 12:57:08 +0900 Subject: [PATCH 1/3] fix: recognize exact capacity errors in string response format Signed-off-by: X. DONG Agent-assisted-by: OpenAI Codex --- docs/knowledge-model-policy.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/knowledge-model-policy.md b/docs/knowledge-model-policy.md index a313cc06..21531296 100644 --- a/docs/knowledge-model-policy.md +++ b/docs/knowledge-model-policy.md @@ -376,8 +376,10 @@ deadline for reading the response. Status POSTs are never retried by the transport. An HTTP 422 status rejection is terminal only for the current runner invocation: `status-rejected` remains an execution error, not declaration noncompliance or a successful invalidation. -An explicit recognized status-capacity response is `budget-saturated`; a count of -900 or an unknown 422 is not capacity proof. Other transient write failures retain +An explicit recognized status-capacity response is `budget-saturated`: the fixed +full capacity message is recognized either directly in the `errors` string or in +a structured `Status`/`custom` array entry. An arbitrary string, substring match, +count of 900, or unknown 422 is not capacity proof. Other transient write failures retain the bounded outer retries. A fresh invocation may retry after remediation. The previous remote status may remain green or pending when a write is rejected; no failure status is claimed to have been published. Diagnostics and retry control From 0e9f60f085493d9f178f6bfd67a79e723ce32867 Mon Sep 17 00:00:00 2001 From: Dong1017 <55723162+Dong1017@users.noreply.github.com> Date: Wed, 28 Oct 2026 12:57:13 +0900 Subject: [PATCH 2/3] fix: recognize exact capacity errors in string response format Signed-off-by: X. DONG Agent-assisted-by: OpenAI Codex --- tests/test_knowledge_policy_http.py | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_knowledge_policy_http.py b/tests/test_knowledge_policy_http.py index 763ab2bf..8b6ec0a8 100644 --- a/tests/test_knowledge_policy_http.py +++ b/tests/test_knowledge_policy_http.py @@ -47,6 +47,36 @@ def test_explicit_status_capacity_reason_is_recognized(self): self.assertIn('"reason": "status-capacity"', str(error)) self.assertNotIn("This SHA", str(error)) + def test_exact_string_capacity_is_recognized_but_remains_execution_failure(self): + body = {"message": "Validation Failed", "errors": + "This SHA and context has reached the maximum number of statuses."} + error = policy.GitHubHTTPError(HTTPError("https://example.invalid", 422, "", {}, + io.BytesIO(json.dumps(body).encode()))) + self.assertEqual(error.reason, "status-capacity") + self.assertNotIn(body["errors"], str(error)) + result = policy.status_write_failure(error, {"description": "fixture"}) + result.update(pull_request=1, rerun=result["kind"] in policy.RERUN_KINDS) + self.assertEqual(result["kind"], "budget-saturated") + self.assertEqual(result["state"], "failure") + self.assertFalse(result["rerun"]) + self.assertEqual(policy.exit_code([result]), policy.EXIT_NONCOMPLIANT) + self.assertEqual(policy.summarize([result])["execution"], "failed") + self.assertEqual(policy.summarize([result])["noncompliant_pull_requests"], []) + + def test_capacity_string_near_misses_remain_unknown_and_redacted(self): + capacity = "This SHA and context has reached the maximum number of statuses." + for errors in ("FAKE_SECRET", capacity + " FAKE_SECRET", "FAKE_SECRET " + capacity, + capacity.replace("maximum", "minimum"), capacity[:-1]): + with self.subTest(errors=errors): + body = {"message": capacity, "errors": errors} + error = policy.GitHubHTTPError(HTTPError("https://example.invalid", 422, "", {}, + io.BytesIO(json.dumps(body).encode()))) + self.assertEqual(error.reason, "unknown") + self.assertNotIn("FAKE_SECRET", str(error)) + self.assertNotIn("This SHA", str(error)) + self.assertEqual(policy.status_write_failure( + error, {"description": "fixture"})["kind"], "status-rejected") + def test_unknown_validation_is_redacted_and_not_inferred_as_capacity(self): capacity = "This SHA and context has reached the maximum number of statuses." for item in ({"resource": "Status", "code": "custom", "message": "FAKE_SECRET"}, From 056b2883902c93344173b8e31dae1fb7a5198f7c Mon Sep 17 00:00:00 2001 From: Dong1017 <55723162+Dong1017@users.noreply.github.com> Date: Wed, 28 Oct 2026 12:57:17 +0900 Subject: [PATCH 3/3] fix: recognize exact capacity errors in string response format Signed-off-by: X. DONG Agent-assisted-by: OpenAI Codex --- tools/check_knowledge_model_policy.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/check_knowledge_model_policy.py b/tools/check_knowledge_model_policy.py index 0a7f7522..165b25ed 100644 --- a/tools/check_knowledge_model_policy.py +++ b/tools/check_knowledge_model_policy.py @@ -350,12 +350,16 @@ def __init__(self, error): # HTTP 422, an arbitrary validation message, or the locally counted history. capacity_message = "this sha and context has reached the maximum number of statuses." errors = body.get("errors", []) if isinstance(body, dict) else [] - capacity = isinstance(errors, list) and any( - isinstance(item, dict) and item.get("resource") == "Status" - and item.get("code") == "custom" - and isinstance(item.get("message"), str) - and item["message"].strip().lower() == capacity_message - for item in errors) + # GitHub may return the same capacity diagnostic directly as `errors` + # rather than in a Status/custom array. Match only this fixed full text. + capacity = (isinstance(errors, str) and + errors.strip().lower() == capacity_message) or ( + isinstance(errors, list) and any( + isinstance(item, dict) and item.get("resource") == "Status" + and item.get("code") == "custom" + and isinstance(item.get("message"), str) + and item["message"].strip().lower() == capacity_message + for item in errors)) self.reason = "status-capacity" if capacity else "unknown" detail["reason"] = self.reason # Structural telemetry only: fixed types/booleans and counts bounded to