Add bounded source reconciliation counts and clarify receiver dependencies
Assistant: codex Assistant-Model: gpt-6.1-sol Assistant-Session: 01a1046e-fdbf-7b93-a267-5f72b9b24526
This commit is contained in:
parent
1044a5f36d
commit
24a5ecd56b
8 changed files with 231 additions and 17 deletions
|
|
@ -4,9 +4,10 @@ from __future__ import annotations
|
|||
|
||||
import json
|
||||
from typing import Any, Callable
|
||||
from urllib.parse import parse_qs
|
||||
|
||||
from .auth import Authenticator, DenyAllAuthenticator, Identity
|
||||
from .errors import ApprovalError, Forbidden
|
||||
from .errors import ApprovalError, Forbidden, Unprocessable
|
||||
from .store import Engine
|
||||
|
||||
FORBIDDEN_DECISION_KEYS = frozenset({"effect", "decision", "allow", "deny"})
|
||||
|
|
@ -105,6 +106,13 @@ class App:
|
|||
return 200, self.engine.storage_status(integrity=True)
|
||||
if path == "/v1/cadence" and method == "GET":
|
||||
self.identity(environ, "approval:observe")
|
||||
query = parse_qs(environ.get("QUERY_STRING", ""), keep_blank_values=True)
|
||||
if query:
|
||||
if set(query) != {"since", "until"} or any(
|
||||
len(values) != 1 or not values[0] for values in query.values()
|
||||
):
|
||||
raise Unprocessable("supply exactly one since and until")
|
||||
return 200, self.engine.reconciliation_counts(query["since"][0], query["until"][0])
|
||||
return 200, self.engine.transition_counts() | {"form": "heartbeat-or-reconciliation"}
|
||||
if path == "/v1/outbox/stats" and method == "GET":
|
||||
self.identity(environ, "approval:observe")
|
||||
|
|
@ -181,6 +189,7 @@ def call(
|
|||
body: dict[str, Any] | None = None,
|
||||
*,
|
||||
authorization: str | None = "Bearer test-token",
|
||||
query_string: str = "",
|
||||
) -> tuple[int, dict[str, Any]]:
|
||||
"""In-process WSGI helper for tests."""
|
||||
raw = json.dumps(body or {}).encode("utf-8") if body is not None else b""
|
||||
|
|
@ -189,7 +198,7 @@ def call(
|
|||
"PATH_INFO": path,
|
||||
"wsgi.input": _Bytes(raw),
|
||||
"CONTENT_LENGTH": str(len(raw)) if body is not None else "0",
|
||||
"QUERY_STRING": "",
|
||||
"QUERY_STRING": query_string,
|
||||
}
|
||||
if authorization is not None:
|
||||
environ["HTTP_AUTHORIZATION"] = authorization
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue