Part of #1028 (phase 4), step 3 of the plan on that issue: the registry client for connections, with a fake registry in the tests.
The registry part, tenant-registry#138, has not started (open, unassigned, no PR). This client follows the API sketched in #138, so it will need adjusting if the registry builds it differently.
What it adds
Registry client (registry.rs):
active_connections(tenant) calls GET /v1/internal/tenants/{id}/connections?state=active and returns id, peer_tenant_id and peer_name. It isn't cached, so a connection ended a second ago is never offered.
connection(id) calls GET /v1/internal/connections/{id} and returns {active, tenant_ids}; a 404 means none.
ConnectionState::peer_of(tenant) gives the other side only while the connection is active and the tenant is one of exactly two distinct sides. Releases will ask this right before they write into another tenant's database (#1028: "a third tenant receives nothing", "an ended connection delivers nothing").
API:GET /api/v1/connections returns the workspace's active connections as {id, peer_name}, sorted by name, never the other tenant's id. It's for choosing whom to release a target to (the "Freigeben an" choice in the phase 4 mockup). It returns an empty list without a registry, and 503 when the registry can't be asked.
Tests
Unit:peer_of for both sides, a third tenant, an ended connection, a connection to itself, one side, and three sides.
tests/connections.rs against a fake registry:
the client lists and checks connections, including unknown (none) and a registry error;
the endpoint lists by name with id and name only, and no other tenant's id appears anywhere in the answer;
an unreachable registry gives 503.
Checks: the OpenAPI, route and registry gates pass, and clippy is clean.
Part of #1028 (phase 4), step 3 of the plan on that issue: the registry client for connections, with a fake registry in the tests.
The registry part, tenant-registry#138, has **not started** (open, unassigned, no PR). This client follows the API sketched in #138, so it will need adjusting if the registry builds it differently.
## What it adds
**Registry client** (`registry.rs`):
- `active_connections(tenant)` calls `GET /v1/internal/tenants/{id}/connections?state=active` and returns `id`, `peer_tenant_id` and `peer_name`. It isn't cached, so a connection ended a second ago is never offered.
- `connection(id)` calls `GET /v1/internal/connections/{id}` and returns `{active, tenant_ids}`; a `404` means none.
- `ConnectionState::peer_of(tenant)` gives the other side only while the connection is active and the tenant is one of exactly two distinct sides. Releases will ask this right before they write into another tenant's database (#1028: "a third tenant receives nothing", "an ended connection delivers nothing").
**API:** `GET /api/v1/connections` returns the workspace's active connections as `{id, peer_name}`, sorted by name, **never the other tenant's id**. It's for choosing whom to release a target to (the "Freigeben an" choice in the phase 4 mockup). It returns an empty list without a registry, and `503` when the registry can't be asked.
## Tests
- **Unit:** `peer_of` for both sides, a third tenant, an ended connection, a connection to itself, one side, and three sides.
- **`tests/connections.rs` against a fake registry:**
- the client lists and checks connections, including unknown (none) and a registry error;
- the endpoint lists by name with id and name only, and no other tenant's id appears anywhere in the answer;
- an unreachable registry gives `503`.
- **Checks:** the OpenAPI, route and registry gates pass, and clippy is clean.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
The Prüfwerk side of tenant-registry#138, built against its spec with a
fake registry in the tests (the registry part has not started):
- `RegistryClient::active_connections(tenant)`:
`GET /v1/internal/tenants/{id}/connections?state=active`, not cached, so
a connection just ended is never offered;
- `RegistryClient::connection(id)`: `GET /v1/internal/connections/{id}`,
404 as none;
- `ConnectionState::peer_of(tenant)`: the other side while the connection
is active and the tenant is one of exactly two distinct sides; what a
delivery asks right before it writes to another tenant's database;
- `GET /api/v1/connections`: the workspace's active connections by id and
the other workspace's display name, by name, never the other tenant's id
(for choosing whom to release to); none without a registry, 503 when it
cannot be asked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Part of #1028 (phase 4), step 3 of the plan on that issue: the registry client for connections, with a fake registry in the tests.
The registry part, tenant-registry#138, has not started (open, unassigned, no PR). This client follows the API sketched in #138, so it will need adjusting if the registry builds it differently.
What it adds
Registry client (
registry.rs):active_connections(tenant)callsGET /v1/internal/tenants/{id}/connections?state=activeand returnsid,peer_tenant_idandpeer_name. It isn't cached, so a connection ended a second ago is never offered.connection(id)callsGET /v1/internal/connections/{id}and returns{active, tenant_ids}; a404means none.ConnectionState::peer_of(tenant)gives the other side only while the connection is active and the tenant is one of exactly two distinct sides. Releases will ask this right before they write into another tenant's database (#1028: "a third tenant receives nothing", "an ended connection delivers nothing").API:
GET /api/v1/connectionsreturns the workspace's active connections as{id, peer_name}, sorted by name, never the other tenant's id. It's for choosing whom to release a target to (the "Freigeben an" choice in the phase 4 mockup). It returns an empty list without a registry, and503when the registry can't be asked.Tests
peer_offor both sides, a third tenant, an ended connection, a connection to itself, one side, and three sides.tests/connections.rsagainst a fake registry:503.🤖 Generated with Claude Code
https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
The Prüfwerk side of tenant-registry#138, built against its spec with a fake registry in the tests (the registry part has not started): - `RegistryClient::active_connections(tenant)`: `GET /v1/internal/tenants/{id}/connections?state=active`, not cached, so a connection just ended is never offered; - `RegistryClient::connection(id)`: `GET /v1/internal/connections/{id}`, 404 as none; - `ConnectionState::peer_of(tenant)`: the other side while the connection is active and the tenant is one of exactly two distinct sides; what a delivery asks right before it writes to another tenant's database; - `GET /api/v1/connections`: the workspace's active connections by id and the other workspace's display name, by name, never the other tenant's id (for choosing whom to release to); none without a registry, 503 when it cannot be asked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9