Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions arbora/webui_host/session_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,37 @@ async def tracked_send(message: Any) -> None:
await send({"type": "http.response.body", "body": body})


def _declared_read_routes() -> frozenset[str]:
"""The exact anonymous read routes the installed web UI package declares."""
try:
from overstory.auth_policy import exported_anonymous_read_routes
except ImportError:
return frozenset()
return frozenset(exported_anonymous_read_routes())


def _loopback_listener(host: str) -> bool:
from arbora.security.anonymous import loopback

return host == "localhost" or loopback(host)


def identity_factory_kwargs(
mode: str, boundary: WebUISessionBoundary | None, *, factory: Any = None
mode: str,
boundary: WebUISessionBoundary | None,
*,
factory: Any = None,
listener_host: str | None = None,
read_routes: Callable[[], frozenset[str]] = _declared_read_routes,
) -> dict[str, Any]:
"""Map explicit host configuration to the public WebUI factory contract."""
"""Map explicit host configuration to the public WebUI factory contract.

In explicit no-auth mode, when the listener is named, the read routes the
web UI package declares are passed as its anonymous read policy
(ARBORA-IDENTITY-R004.7.3). Arbora hard-codes no route list, passes no
policy in any other mode, and refuses a non-loopback listener or a package
that declares no read routes.
"""
if mode not in {"required", "none", "eg", "oidc"}:
raise IdentityUnavailable("unknown WebUI identity mode")
if mode == "none" and boundary is not None:
Expand All @@ -227,4 +254,20 @@ def identity_factory_kwargs(
kwargs: dict[str, Any] = {"auth_mode": mode} if mode != "required" else {}
if boundary is not None:
kwargs["session_boundary"] = boundary
if mode == "none" and listener_host is not None:
if not _loopback_listener(listener_host):
raise IdentityUnavailable("no-auth read routes require a loopback listener")
routes = read_routes()
if not routes:
raise IdentityUnavailable(
"installed WebUI declares no anonymous read routes"
)
if (
factory is not None
and "anonymous_read_routes" not in inspect.signature(factory).parameters
):
raise IdentityUnavailable(
"installed WebUI cannot take an anonymous read policy"
)
kwargs["anonymous_read_routes"] = routes
return kwargs
5 changes: 4 additions & 1 deletion arbora/webui_host/webui_co_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ def run_web_ui(
from arbora.webui_host.session_boundary import identity_factory_kwargs

identity_kwargs = identity_factory_kwargs(
config.webui_auth_mode, session_boundary, factory=create_agent_web_app
config.webui_auth_mode,
session_boundary,
factory=create_agent_web_app,
listener_host=bind_host,
)
app = create_agent_web_app(
agent,
Expand Down
3 changes: 3 additions & 0 deletions specs/fleet-catalog-and-tools/requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,6 @@ Live agent browser requests must carry host-bound agent/run provenance for the l
| `ARBORA-FLEET-R084` | **The fleet serves the city layout read.** Subsystem: fleet catalog. Entry: the served `ask` operation `fleet.city.layout` (effect `READ`, scope `fleet:read`). arbora serves the spatial layout of the fleet tenant from the Medulla world view: districts, buildings, rooms, streets, the relations `locatedIn`, `position` and `hasInterior`, and the active manual overrides. arbora invokes the engine's one spatial query method as the bound actor (`MEDULLA-WORLD-VIEW-R003`) and serves its stable envelope; it adds no placement logic and no second registry. A connector added to the catalog appears in the layout on the next read without a write, and a stored override for a removed connector is reported stale, never applied. Refusals: `UNAVAILABLE` when the engine world view is not bound; the engine's typed unknown-tenant and unknown-layout refusals are preserved in arbora's closed error enum. Writes: none. Caller chain: `arbora/api/http/app.py:208` -> `arbora/api/http/routes.py:122` -> `arbora/api/invoke/pipeline.py:1021` -> (planned) `arbora/api/ops/fleet_city.py::handle_city_layout` -> the engine spatial query; over MCP, `arbora/api/mcp/serving.py:29` -> `arbora/api/mcp/verbs.py` (`ask`) -> the same handler. Shape: one handler that builds the params and maps the engine envelope into the result model; no new store. Depends on: `MEDULLA-WORLD-VIEW-R003`. | Test: `tests/fleet/test_city_layout_served.py::test_city_layout_serves_the_engine_envelope_and_refuses_unbound` (L3) planned in `test-spec.md`. |
| `ARBORA-FLEET-R085` | **A sandbox fleet profile fills the catalog without external credentials (rollup).** Subsystem: fleet catalog, sandbox profile. Caller chain: `arbora-sandbox up` (`ARBORA-DEPLOY-R019`) -> `arbora-production-ops onboard-fleet` (`arbora/deployment/production_ops.py::_onboard_fleet`) -> `configured_fleet_endpoints` -> `FleetOnboarding.onboard`. Rule: a sandbox fleet profile declares a closed set of connectors. Each runs locally, needs no external credential, and serves from self-contained fixture data. The profile lives in one declarative file in the arbora package. The sandbox start reads it and nothing else decides the set. After onboarding, `fleet.catalog.list` must return those connectors and their tools, in addition to the 45 items that Arbora serves itself (29 prompts, 15 skills, 1 resource). The profile applies only when the operator selects the sandbox. A production profile ignores it. Arbora implements no fixture mode. It consumes the connector fixture-serving mode of the connector SDK. Depends: `SCION-CONNECTOR-CONTROL-R931` (the explicit fixture serving mode). This row builds on the existing fleet onboarding rollup. Shape: `arbora/deployment/sandbox_fleet.py` (planned) holds the typed profile loader; `production_ops.py::_onboard_fleet` takes the endpoint set from it when the sandbox is active. | Test: `tests/fleet/test_sandbox_fleet_served.py::test_catalog_list_returns_sandbox_connectors_and_tools` (planned, L3). It starts the sandbox, runs `onboard-fleet` and asserts `fleet.catalog.list` returns each declared connector with at least one tool. It asserts no external network call and no credential read. |
| `ARBORA-FLEET-R085.1` | **`onboard-fleet` reports each connector and exits non-zero only for the declared set.** Subsystem: fleet onboarding, operator command. Caller chain: `arbora-production-ops onboard-fleet` -> `_onboard_fleet` (`arbora/deployment/production_ops.py:416`) -> `_exit_status`. Rule: the report lists one entry per connector with its state, error type and message. Today `ok` is false when any connector fails. In sandbox mode, `ok` is false only when a connector of the declared sandbox set fails. A failure outside that set appears in the report and leaves the exit code at zero. Outside sandbox mode, behavior stays as it is. A failed connector never hides the others. Refusals: the report names the failing connector, its error type and a bounded message. It never prints a secret or an endpoint credential. Writes: none beyond onboarding. Depends: none in this repository. This row extends the existing onboarding refusal behavior. Shape: extend `report.as_dict` consumers and the `ok` computation in `_onboard_fleet`; no new command. | Test: `tests/fleet/test_onboard_fleet_report.py::test_exit_status_follows_the_declared_sandbox_set` (planned, L2). It fails one declared and one undeclared connector in turn. It asserts the exit code, the per-connector entries and that production mode keeps its current exit rule. |
| `ARBORA-FLEET-R086` | **The fleet serves graph neighbourhoods as city chunks.** Subsystem: fleet catalog. Entry: the served `ask` operation `fleet.city.chunk` (effect `READ`, scope `fleet:read`). arbora forwards the tenant, a cell range or anchor node and an opaque cursor to the engine world-view chunk read as the bound actor, and serves the bounded chunk envelope unchanged, with each element's provenance. It adds no placement logic and no second registry. Any cache is keyed by the verified principal and tenant. Refusals: `UNAVAILABLE` when the engine world view is not bound; the engine's typed unknown-tenant and unknown-range refusals are preserved in arbora's closed error enum. Writes: none. Caller chain: `arbora/api/http/app.py:208` -> `arbora/api/http/routes.py:122` -> `arbora/api/invoke/pipeline.py:1021` -> (planned) `arbora/api/ops/fleet_city.py::handle_city_chunk` -> the engine chunk read. Shape: one handler beside `handle_city_layout`. Depends on: `ARBORA-FLEET-R084`, `MEDULLA-WORLD-VIEW-R007`. | Test: `tests/fleet/test_city_chunk_served.py::test_chunk_read_serves_the_engine_envelope_and_refuses_unbound` (planned, L3). |
| `ARBORA-FLEET-R087` | **The fleet serves the city edit layer.** Subsystem: fleet catalog. Entry: the served operations `fleet.city.edit_layer.get` (effect `READ`, scope `fleet:read`) and `fleet.city.edit_layer.put` (effect `WRITE`, scope `fleet:write`). The write previews first and runs through the standard plan flow. The engine validates it (collisions, stale edits) and records the verified actor. A refusal carries the engine's typed reason. A read returns the layer version. arbora stores nothing. Refusals: `UNAVAILABLE` when the engine world view is not bound; `PIN_COLLISION` and `STALE_EDIT` as the engine reports them. Writes: one edit-layer version in the engine. Caller chain: `arbora/api/http/routes.py:122` -> `arbora/api/invoke/pipeline.py:1021` -> (planned) `arbora/api/ops/fleet_city.py::handle_edit_layer_get` and `handle_edit_layer_put`. Shape: two handlers that map the engine envelope into result models. Depends on: `ARBORA-FLEET-R084`, `MEDULLA-WORLD-VIEW-R006`. | Test: `tests/fleet/test_city_edit_layer_served.py::test_edit_layer_round_trips_with_actor_and_refuses_collisions` (planned, L3). |
| `ARBORA-FLEET-R088` | **The fleet serves the city mapping registry, growth rules and seed.** Subsystem: fleet catalog. Entry: the served `ask` operation `fleet.city.rules` (effect `READ`, scope `fleet:read`). arbora reads the tenant's class-to-archetype registry, the declared growth rules and the seed from the engine world view and serves them, so a client can evaluate the pure mapping and growth. arbora hard-codes none of them. Refusals: `UNAVAILABLE` when the engine world view is not bound. Writes: none. Caller chain: `arbora/api/invoke/pipeline.py:1021` -> (planned) `arbora/api/ops/fleet_city.py::handle_city_rules` -> the engine spatial query. Shape: one handler. Depends on: `ARBORA-FLEET-R084`, `MEDULLA-WORLD-VIEW-R004`, `MEDULLA-WORLD-VIEW-R005`. | Test: `tests/fleet/test_city_rules_served.py::test_rules_serve_registry_growth_and_seed_from_the_engine` (planned, L3). |
3 changes: 3 additions & 0 deletions specs/fleet-catalog-and-tools/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,3 +540,6 @@ The WebUI bridge is configured by the host and discovered through the existing p
- [ ] T272 [US1] ARBORA-FLEET-R084 The fleet serves the city layout read from the engine world view. Size: S, 1 PR, 2 hours.
- [ ] T273 [US1] ARBORA-FLEET-R085 A sandbox fleet profile fills the catalog without external credentials (rollup). Size: L, 2 PRs, 1 day.
- [ ] T274 [US1] ARBORA-FLEET-R085.1 The fleet onboarding command reports each connector and exits non-zero only for the declared set. Size: S, 1 PR, 2 hours.
- [ ] T275 [US1] ARBORA-FLEET-R086 The fleet serves graph neighbourhoods as city chunks. Size: S, 1 PR, 2 hours.
- [ ] T276 [US1] ARBORA-FLEET-R087 The fleet serves the city edit layer. Size: S, 1 PR, 2 hours.
- [ ] T277 [US1] ARBORA-FLEET-R088 The fleet serves the city mapping registry, growth rules and seed. Size: S, 1 PR, 2 hours.
3 changes: 3 additions & 0 deletions specs/fleet-catalog-and-tools/test-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,6 @@ Each test below is named by its requirement row, has no running implementation y
| PT-186 | ARBORA-FLEET-R084 | `tests/fleet/test_city_layout_served.py::test_city_layout_serves_the_engine_envelope_and_refuses_unbound` (planned) | The result the row states holds. | Each refusal the row states is returned. |
| PT-187 | ARBORA-FLEET-R085 | `tests/fleet/test_sandbox_fleet_served.py::test_catalog_list_returns_sandbox_connectors_and_tools` (planned) | The result the row states holds. | Each refusal the row states is returned. |
| PT-188 | ARBORA-FLEET-R085.1 | `tests/fleet/test_onboard_fleet_report.py::test_exit_status_follows_the_declared_sandbox_set` (planned) | The result the row states holds. | Each refusal the row states is returned. |
| PT-189 | ARBORA-FLEET-R086 | `tests/fleet/test_city_chunk_served.py::test_chunk_read_serves_the_engine_envelope_and_refuses_unbound` (planned) | The result the row states holds. | Each refusal the row states is returned. |
| PT-190 | ARBORA-FLEET-R087 | `tests/fleet/test_city_edit_layer_served.py::test_edit_layer_round_trips_with_actor_and_refuses_collisions` (planned) | The result the row states holds. | Each refusal the row states is returned. |
| PT-191 | ARBORA-FLEET-R088 | `tests/fleet/test_city_rules_served.py::test_rules_serve_registry_growth_and_seed_from_the_engine` (planned) | The result the row states holds. | Each refusal the row states is returned. |
Loading
Loading