Skip to content

Commit 747ca1c

Browse files
committed
refactor: use HOTDATA_WORKSPACE env var
Revert to the canonical HOTDATA_WORKSPACE name for explicit workspace selection, matching the CLI and other adapters.
1 parent ba06915 commit 747ca1c

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

CONTRACT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Adapters should import from `hotdata_runtime` and treat this surface as the stab
6363
- `default_api_key()` reads `HOTDATA_API_KEY`.
6464
- `default_host()` reads `HOTDATA_API_URL` (default: `https://api.hotdata.dev`) and normalizes it.
6565
- `default_session_id()` reads `HOTDATA_SANDBOX`.
66-
- `explicit_workspace_id()` reads `HOTDATA_WORKSPACE_ID` (workspace public id).
66+
- `explicit_workspace_id()` reads `HOTDATA_WORKSPACE` (workspace public id).
6767
- `pick_workspace()` prefers explicit env workspace, then active workspace, then first workspace.
6868
- `resolve_workspace_selection()` is the canonical workspace selection algorithm. It returns `WorkspaceSelection` with selected workspace id, selection source, and discovered workspaces when auto-selected.
6969

hotdata_runtime/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def default_api_key() -> str:
2323

2424

2525
def explicit_workspace_id() -> str | None:
26-
return os.environ.get("HOTDATA_WORKSPACE_ID")
26+
return os.environ.get("HOTDATA_WORKSPACE")
2727

2828

2929
def default_host() -> str:

tests/test_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ def test_normalize_host(raw: str, expected: str):
2525
assert normalize_host(raw) == expected
2626

2727

28-
def test_pick_workspace_prefers_workspace_id_env(monkeypatch: pytest.MonkeyPatch):
29-
monkeypatch.setenv("HOTDATA_WORKSPACE_ID", "ws_explicit")
28+
def test_pick_workspace_prefers_env(monkeypatch: pytest.MonkeyPatch):
29+
monkeypatch.setenv("HOTDATA_WORKSPACE", "ws_explicit")
3030
assert pick_workspace("k", "https://api.hotdata.dev", None) == "ws_explicit"
3131

3232

3333
def test_resolve_workspace_selection_prefers_env_without_listing(
3434
monkeypatch: pytest.MonkeyPatch,
3535
):
36-
monkeypatch.setenv("HOTDATA_WORKSPACE_ID", "ws_explicit")
36+
monkeypatch.setenv("HOTDATA_WORKSPACE", "ws_explicit")
3737
with patch("hotdata_runtime.env.list_workspaces") as listing:
3838
resolved = resolve_workspace_selection(
3939
"k", "https://api.hotdata.dev", None
@@ -46,7 +46,7 @@ def test_resolve_workspace_selection_prefers_env_without_listing(
4646

4747

4848
def test_pick_workspace_chooses_first_active(monkeypatch: pytest.MonkeyPatch):
49-
monkeypatch.delenv("HOTDATA_WORKSPACE_ID", raising=False)
49+
monkeypatch.delenv("HOTDATA_WORKSPACE", raising=False)
5050

5151
items = [
5252
SimpleNamespace(public_id="ws_1", active=False),
@@ -61,7 +61,7 @@ def test_pick_workspace_chooses_first_active(monkeypatch: pytest.MonkeyPatch):
6161

6262

6363
def test_pick_workspace_falls_back_to_first(monkeypatch: pytest.MonkeyPatch):
64-
monkeypatch.delenv("HOTDATA_WORKSPACE_ID", raising=False)
64+
monkeypatch.delenv("HOTDATA_WORKSPACE", raising=False)
6565

6666
items = [
6767
SimpleNamespace(public_id="ws_1", active=False),
@@ -75,7 +75,7 @@ def test_pick_workspace_falls_back_to_first(monkeypatch: pytest.MonkeyPatch):
7575

7676

7777
def test_resolve_workspace_selection_source_first(monkeypatch: pytest.MonkeyPatch):
78-
monkeypatch.delenv("HOTDATA_WORKSPACE_ID", raising=False)
78+
monkeypatch.delenv("HOTDATA_WORKSPACE", raising=False)
7979
items = [
8080
SimpleNamespace(public_id="ws_1", active=False),
8181
SimpleNamespace(public_id="ws_2", active=False),
@@ -94,7 +94,7 @@ def test_resolve_workspace_selection_source_first(monkeypatch: pytest.MonkeyPatc
9494
def test_resolve_workspace_selection_returns_workspaces_and_source(
9595
monkeypatch: pytest.MonkeyPatch,
9696
):
97-
monkeypatch.delenv("HOTDATA_WORKSPACE_ID", raising=False)
97+
monkeypatch.delenv("HOTDATA_WORKSPACE", raising=False)
9898

9999
items = [
100100
SimpleNamespace(public_id="ws_1", active=False),

0 commit comments

Comments
 (0)