urun-cli 0.8.0__tar.gz → 0.8.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. {urun_cli-0.8.0 → urun_cli-0.8.1}/CHANGELOG.md +20 -0
  2. {urun_cli-0.8.0 → urun_cli-0.8.1}/PKG-INFO +2 -7
  3. {urun_cli-0.8.0 → urun_cli-0.8.1}/README.md +1 -3
  4. {urun_cli-0.8.0 → urun_cli-0.8.1}/SECURITY.md +0 -5
  5. {urun_cli-0.8.0 → urun_cli-0.8.1}/hatch_build.py +5 -45
  6. {urun_cli-0.8.0 → urun_cli-0.8.1}/pyproject.toml +14 -19
  7. urun_cli-0.8.1/src/urun/_bin/README.md +4 -0
  8. {urun_cli-0.8.0 → urun_cli-0.8.1}/src/urun/api.py +50 -45
  9. urun_cli-0.8.1/src/urun/cli.py +1090 -0
  10. {urun_cli-0.8.0 → urun_cli-0.8.1}/src/urun/config.py +0 -9
  11. {urun_cli-0.8.0 → urun_cli-0.8.1}/src/urun/errors.py +2 -2
  12. urun_cli-0.8.1/src/urun/feature_flags.py +121 -0
  13. {urun_cli-0.8.0 → urun_cli-0.8.1}/src/urun/retry.py +0 -6
  14. urun_cli-0.8.1/src/urun/term.py +46 -0
  15. urun_cli-0.8.0/.gitignore +0 -26
  16. urun_cli-0.8.0/src/urun/_bin/README.md +0 -41
  17. urun_cli-0.8.0/src/urun/buildlogs.py +0 -689
  18. urun_cli-0.8.0/src/urun/catalog.py +0 -1462
  19. urun_cli-0.8.0/src/urun/cli.py +0 -6851
  20. urun_cli-0.8.0/src/urun/client_tokens.py +0 -657
  21. urun_cli-0.8.0/src/urun/deps.py +0 -2111
  22. urun_cli-0.8.0/src/urun/dev.py +0 -2144
  23. urun_cli-0.8.0/src/urun/devconsole.py +0 -269
  24. urun_cli-0.8.0/src/urun/devstream.py +0 -652
  25. urun_cli-0.8.0/src/urun/discovery.py +0 -1585
  26. urun_cli-0.8.0/src/urun/feature_flags.py +0 -252
  27. urun_cli-0.8.0/src/urun/fleet.py +0 -709
  28. urun_cli-0.8.0/src/urun/frontend_launch.py +0 -1634
  29. urun_cli-0.8.0/src/urun/hub_builds.py +0 -328
  30. urun_cli-0.8.0/src/urun/kubectl_plugin.py +0 -705
  31. urun_cli-0.8.0/src/urun/launch_auth.py +0 -470
  32. urun_cli-0.8.0/src/urun/nodes.py +0 -121
  33. urun_cli-0.8.0/src/urun/openai_proxy_bin.py +0 -179
  34. urun_cli-0.8.0/src/urun/repo_deps.py +0 -696
  35. urun_cli-0.8.0/src/urun/reserve.py +0 -156
  36. urun_cli-0.8.0/src/urun/rust.py +0 -1501
  37. urun_cli-0.8.0/src/urun/scratch.py +0 -108
  38. urun_cli-0.8.0/src/urun/serve.py +0 -1142
  39. {urun_cli-0.8.0 → urun_cli-0.8.1}/LICENSE +0 -0
  40. {urun_cli-0.8.0 → urun_cli-0.8.1}/src/urun/__init__.py +0 -0
  41. {urun_cli-0.8.0 → urun_cli-0.8.1}/src/urun/manifest.py +0 -0
  42. {urun_cli-0.8.0 → urun_cli-0.8.1}/src/urun/runtime_health.py +0 -0
@@ -1,3 +1,23 @@
1
+ ## 0.8.1
2
+
3
+ Release-engineering release (ENG-662); the CLI surface is unchanged from
4
+ 0.8.0 — the flag-gated MVP launch surface. What changed is how release
5
+ artifacts are built and published:
6
+
7
+ - Published artifacts are generated from the launch export, not the raw
8
+ working tree: `scripts/gen_launch_export.py` derives the strip config
9
+ from the `ff-strip` markers and the flag registry, and copybarista
10
+ produces the release source tree. Code gated off at launch is now
11
+ stripped from the sdist and the wheel PyPI serves, not merely
12
+ unregistered (the 0.8.0 wheel still carried it).
13
+ - `release.yaml` publishes from the same lane CI validates on every push
14
+ (generate, export, leak-check, `uv build`, then `verify_wheel.py
15
+ --expect-pure --expect-launch`), so a release can no longer ship an
16
+ artifact the CI lane has not proven. The platform-wheel legs run
17
+ exactly when the flag registry says the release ships the
18
+ vendored-binary loader; at this launch state the release publishes the
19
+ sdist and the pure wheel only.
20
+
1
21
  ## 0.8.0
2
22
 
3
23
  MVP launch release (URU-673). The CLI ships only its launch surface, gated by
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: urun-cli
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: CLI for the urun platform — login, billing & usage. More capabilities coming soon.
5
5
  Project-URL: Homepage, https://urun.sh
6
6
  Project-URL: Repository, https://github.com/urun-sh/urun-cli
@@ -17,9 +17,6 @@ Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Requires-Python: >=3.11
20
- Provides-Extra: rust
21
- Requires-Dist: tree-sitter-rust==0.24.0; extra == 'rust'
22
- Requires-Dist: tree-sitter==0.25.2; extra == 'rust'
23
20
  Description-Content-Type: text/markdown
24
21
 
25
22
  # urun CLI
@@ -136,9 +133,7 @@ terminal.
136
133
  ## What's next
137
134
 
138
135
  This release focuses on account access: login, billing, usage, and cost
139
- information. Additional capabilities — deploy tooling, app management, and
140
- more — are in development and will arrive in upcoming releases.
141
-
136
+ information.
142
137
  ## Development
143
138
 
144
139
  Contributing and test instructions are in [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -112,9 +112,7 @@ terminal.
112
112
  ## What's next
113
113
 
114
114
  This release focuses on account access: login, billing, usage, and cost
115
- information. Additional capabilities — deploy tooling, app management, and
116
- more — are in development and will arrive in upcoming releases.
117
-
115
+ information.
118
116
  ## Development
119
117
 
120
118
  Contributing and test instructions are in [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -10,8 +10,3 @@ Please report suspected vulnerabilities privately to the urun maintainers. Do no
10
10
  - Do not commit real API keys or `.env` files.
11
11
  - The CLI validates the `urun_<32 lowercase hex>` shape locally, but the server remains authoritative for auth and revocation.
12
12
 
13
- ## Source upload behavior
14
-
15
- `urun deploy` uploads selected source files and dependency declaration files to urun via presigned object-store URLs. Review `.urunignore` before deploying sensitive repositories.
16
-
17
- The CLI enforces project-root containment for entrypoints and dependency files. Symlinks are resolved before that containment check.
@@ -1,50 +1,10 @@
1
- """Hatch build hook: platform-tag wheels that carry the vendored urun-openai binary.
1
+ """Hatch build hook: platform-tag wheels that carry a vendored native binary.
2
2
 
3
- The `urun compat` proxy binary (see ``src/urun/_bin/README.md``) is a native
4
- executable, so a wheel that ships it must NOT claim ``py3-none-any`` — pip
3
+ A wheel that ships a native executable must NOT claim ``py3-none-any`` — pip
5
4
  would happily install a mac binary on linux. This hook makes the wheel tag
6
- tell the truth, both ways:
7
-
8
- - binary PRESENT at ``src/urun/_bin/urun-openai`` → ``pure_python = False``
9
- and an explicit ``py3-none-<platform>`` tag. NOT ``infer_tag`` — that would
10
- stamp ``cp3XX-cp3XX-<platform>`` and needlessly bind the (pure-Python) code
11
- to the building interpreter's minor version; the only platform-specific
12
- content is the data binary. A present-but-non-executable binary fails the
13
- build loudly — shipping it would only fail later on user machines.
14
- - binary ABSENT → nothing changes: the wheel stays pure ``py3-none-any`` and
15
- ships without the binary (`urun compat` then resolves via its override/PATH
16
- lanes or fails loud at runtime).
17
-
18
- The platform component is derived explicitly, never a bare ``linux_<arch>``:
19
-
20
- - Linux → ``manylinux_<major>_<minor>_<arch>`` from the GLIBC symbol versions
21
- the VENDORED BINARY ITSELF actually references (``objdump -T``), never from
22
- ``platform.libc_ver()`` (the build machine's installed glibc). PyPI rejects
23
- bare ``linux_*`` uploads outright, and in the isolated build env
24
- ``packaging.tags.platform_tags()`` can yield bare ``linux_x86_64`` first —
25
- so the tag is constructed, not inferred.
26
-
27
- INCIDENT (2026-08-25): tagging by the build machine's installed glibc
28
- (``platform.libc_ver()`` on the ``ubuntu-24.04`` release runner → glibc
29
- 2.39) produced wheels tagged ``manylinux_2_39_x86_64`` even though the
30
- actual bun-compiled binary's highest referenced symbol is ``GLIBC_2.17``
31
- (confirmed via ``objdump -T``) — a decade-wide, entirely incidental gap
32
- between "what the build runner happened to have installed" and "what the
33
- binary actually needs". ``manylinux_2_39`` is only installable on glibc
34
- ≥2.39 (Ubuntu 24.04+, roughly 2024 onward), so pip/uv silently rejected the
35
- platform wheel on every older-but-still-current distro (Ubuntu 20.04/22.04,
36
- Debian 11/12, RHEL 8/9, ...) and fell back to the binary-less
37
- ``py3-none-any`` wheel with ZERO signal at install time — `uv tool install
38
- urun-cli` "succeeded" and `urun compat` failed at runtime claiming the
39
- binary "is not installed". Reading the binary's OWN symbol requirements is
40
- the only floor that isn't a lie in either direction.
41
- - everything else (macOS) → the most specific ``packaging.tags`` platform tag
42
- (e.g. ``macosx_15_0_arm64``).
43
-
44
- The release workflow builds one wheel per platform with the binary vendored
45
- (``scripts/vendor_openai_proxy.py --from-npm``) plus one pure wheel + sdist
46
- without it, and verifies each with ``scripts/verify_wheel.py`` — a
47
- ``py3-none-any`` wheel containing the binary fails the release.
5
+ tell the truth, both ways (the ABSENT arm is the no-op path this release's
6
+ build takes — nothing is vendored):
7
+
48
8
  """
49
9
 
50
10
  from __future__ import annotations
@@ -20,7 +20,7 @@ name = "urun-cli"
20
20
  # so every merge remains on the already-published version until this value is
21
21
  # advanced. Wiring semantic-release into CI remains separate work; this patch
22
22
  # bump is the minimal release unblock (post-v0.6.3 fixes + the Rust feature minor).
23
- version = "0.8.0"
23
+ version = "0.8.1"
24
24
  description = "CLI for the urun platform — login, billing & usage. More capabilities coming soon."
25
25
  readme = "README.md"
26
26
  requires-python = ">=3.11"
@@ -47,30 +47,26 @@ Issues = "https://github.com/urun-sh/urun-cli/issues"
47
47
  [project.scripts]
48
48
  urun = "urun.cli:main"
49
49
  urun-cli = "urun.cli:main"
50
- # No kubectl-urun entry point at launch (URU-673): the GPUWorker surface is
51
- # flag-hidden (feat-byo-nodes, FLAGS.md) and the wheel must not install an
52
- # operator binary whose every verb errors. The module stays, gated; the entry
53
- # point returns when the flag flips on in a future release.
54
-
55
- [project.optional-dependencies]
56
- # Rust app discovery (urun/rust.py) parses with the pinned native
57
- # tree-sitter wheels; lazy-imported only for Rust deploys, so the ordinary
58
- # wheel stays dependency-free. Pin advance = contract native_crate_baselines
59
- # (tree-sitter 0.25.2 / tree-sitter-rust 0.24.0).
60
- rust = [
61
- "tree-sitter==0.25.2",
62
- "tree-sitter-rust==0.24.0",
63
- ]
64
-
65
50
  [dependency-groups]
66
51
  dev = [
52
+ # The launch-export pipeline (ENG-662, FLAGS.md "Launch export"): the export
53
+ # tests and CI's launch-export lane run a REAL `copybarista export` /
54
+ # `check-leaks` against the config scripts/gen_launch_export.py generates.
55
+ # Marker required by the universal lock: copybarista itself needs >=3.12
56
+ # while the CLI supports >=3.11; the export tests fail loudly on a 3.11
57
+ # dev env (missing binary), which is the sanctioned fail-hard behavior.
58
+ "copybarista==0.1.8; python_version >= \"3.12\"",
67
59
  # The build backend, present in the dev env so tests can import hatch_build.py
68
60
  # (the wheel-tagging hook) directly.
69
61
  "hatchling",
70
62
  "minio>=7.2.0",
71
63
  "pytest>=8.0",
72
64
  "pytest-cov>=7.1.0",
73
- "python-semantic-release==10.5.2",
65
+ # Bumped from 10.5.2 (ENG-662): that line capped tomlkit<0.14, which cannot
66
+ # share the dev lock with copybarista (tomlkit>=0.15.1). 10.7.0 is the first
67
+ # release on tomlkit~=0.15. Nothing invokes semantic-release yet — CI only
68
+ # reads project.version — so the bump changes no behavior.
69
+ "python-semantic-release==10.7.0",
74
70
  "ruff>=0.15.14",
75
71
  ]
76
72
  # The LIVE quickstart gate (tests/test_quickstart_live.py) drives a real
@@ -132,8 +128,6 @@ include = [
132
128
 
133
129
  [tool.hatch.build.targets.wheel]
134
130
  packages = ["src/urun"]
135
- artifacts = ["src/urun/_bin/urun-openai"]
136
-
137
131
  # Platform-tags any wheel that carries the vendored binary (and keeps the
138
132
  # no-binary wheel honestly pure). See hatch_build.py.
139
133
  [tool.hatch.build.targets.wheel.hooks.custom]
@@ -145,6 +139,7 @@ testpaths = ["tests"]
145
139
  markers = [
146
140
  "minio: requires a running local MinIO server configured with URUN_TEST_MINIO_* env vars",
147
141
  "quickstart_live: LIVE quickstart gate — deploys rolling-sink to the real platform with URUN_API_KEY and requires a browser-decoded first frame within the documented budget (run by .github/workflows/quickstart-e2e.yml)",
142
+ "slow: the full 26-state launch-export matrix — a real copybarista export of every flag state (tests/test_launch_export.py); CI's launch-export lane runs it, the default suite selects it out",
148
143
  ]
149
144
 
150
145
  [tool.coverage.run]
@@ -0,0 +1,4 @@
1
+ # Vendored platform binaries
2
+
3
+ Release-vendored platform binaries live in this directory; the binary itself
4
+ is gitignored — only this README is committed.
@@ -87,14 +87,7 @@ class ApiClient:
87
87
  environment: str | None = None,
88
88
  deploy_kind: str | None = None,
89
89
  ) -> dict[str, Any]:
90
- """Finalize a registered manifest into a (re)deployed release.
91
-
92
- ``deploy_kind="dev"`` marks the deployment EPHEMERAL on the control
93
- plane (`urun dev` only): it carries a keep-alive lease and is reaped
94
- when the lease lapses or the dev loop exits. Omitted (every plain
95
- `urun deploy`) the deployment is persistent — and a finalize WITHOUT
96
- the marker resets a previously-dev app back to persistent.
97
- """
90
+ """Finalize a registered manifest into a (re)deployed release."""
98
91
  body: dict[str, Any] = {}
99
92
  if environment:
100
93
  body["environment"] = environment
@@ -203,9 +196,8 @@ class ApiClient:
203
196
  header; ``body`` is the snake_case constraint set
204
197
  (``expires_in`` ≤3600, ``allowed_functions`` ≤20 ``app/function``
205
198
  entries, ``allowed_origins`` ≤20 bare http(s) origins,
206
- ``max_session_s``, ``subject``, ``metadata``) — see
207
- :func:`urun.client_tokens.build_client_token_request`. The server
208
- answers ``{token, expires_in, expires_at, org_id}``.
199
+ ``max_session_s``, ``subject``, ``metadata``).
200
+ The server answers ``{token, expires_in, expires_at, org_id}``.
209
201
 
210
202
  Constraints are enforced server-side at session admission; token
211
203
  expiry gates STARTING sessions only (live sessions ride their lease).
@@ -224,8 +216,7 @@ class ApiClient:
224
216
 
225
217
  The server filters out slices with no provisioned GPU units, so the
226
218
  listing reflects what is actively running for the org rather than
227
- the full deployment catalogue (which is ``urun app list``).
228
-
219
+ the full deployment catalogue.
229
220
  ``limit`` is passed through as a query param; this method does not
230
221
  impose a client-side maximum.
231
222
 
@@ -245,8 +236,8 @@ class ApiClient:
245
236
 
246
237
  Wire contract (urun-infra ``nodes`` edge function): the org API key
247
238
  authenticates via the standard ``Authorization: Bearer`` header; the
248
- body is ``{"name", "gpu_type", "tags"}`` (``gpu_type`` one of
249
- :data:`urun.nodes.NODE_GPU_TYPES`; validation is authoritative
239
+ body is ``{"name", "gpu_type", "tags"}`` (``gpu_type`` one of the
240
+ org's supported node GPU types; validation is authoritative
250
241
  server-side in ``urun_create_custom_node`` and surfaces as 422). The
251
242
  server answers 201 ``{id, name, gpu_type, tags, status,
252
243
  token_prefix, created_at, registration_token, script_url,
@@ -464,9 +455,9 @@ class ApiClient:
464
455
  def promote_release(self, release_id: str, environment: str) -> dict[str, Any]:
465
456
  """Make an EXISTING release current for ``environment`` (rollback).
466
457
 
467
- ``POST /cli/releases/<id>/promote`` re-fires the release's deploy event —
468
- the same path a same-content ``urun deploy`` takes — so the control plane
469
- re-registers it and republishes the release pointer.
458
+ ``POST /cli/releases/<id>/promote`` re-fires the release's deploy event,
459
+ so the control plane re-registers it and republishes the release
460
+ pointer.
470
461
  """
471
462
  return self._post(
472
463
  f"/cli/releases/{urllib.parse.quote(release_id, safe='')}/promote",
@@ -619,10 +610,8 @@ class ApiClient:
619
610
  def renew_dev_lease(self, app: str, environment: str | None = None) -> dict[str, Any]:
620
611
  """Renew the keep-alive lease on a DEV deploy.
621
612
 
622
- Hits ``POST /app/<slug>/dev-lease``. Dev deploys (``urun dev``) are
623
- ephemeral: the control plane reaps a dev deployment whose lease
624
- lapsed (the CLI process died without a clean exit). The running dev
625
- loop renews on a fixed beat; only deployments finalized with
613
+ Hits ``POST /app/<slug>/dev-lease``.
614
+ Only deployments finalized with
626
615
  ``deploy_kind="dev"`` carry a lease — the server rejects renewal for
627
616
  anything else. The org is derived from the API key. Returns
628
617
  ``{"app": {...}}``.
@@ -670,8 +659,7 @@ class ApiClient:
670
659
  return self._json("POST", f"/app/{urllib.parse.quote(app, safe='')}/pause", body)
671
660
 
672
661
  def retire_app(self, app: str, environment: str | None = None) -> dict[str, Any]:
673
- """Retire an app through the CLI edge route (backs ``urun app delete``).
674
-
662
+ """Retire an app through the CLI edge route.
675
663
  Hits ``DELETE /cli/apps/<slug>`` which calls the org-scoped
676
664
  ``urun_stage2_retire_app`` lifecycle RPC: the deployment is driven to
677
665
  ``status='paused'`` / ``lifecycle='superseded'`` so the control-plane
@@ -696,20 +684,10 @@ class ApiClient:
696
684
  return self._json("GET", "/org-config", None)
697
685
 
698
686
  # --- Scratch occupants ------------------------------------------------- #
699
- # `urun scratch` rides the same pull-dispatch path as serving: the
700
- # session API enqueues a BullMQ scratch demand job, the node scheduler
701
- # admits it and spawns the resident. Org scoping comes from the same
702
- # org-API-key authz the deploy/client-token routes use. GET
703
- # /api/scratch/:id/logs and POST /api/scratch/:id/exec are Slice A
704
- # (urun-infra) endpoints — this client is coded against the shared
705
- # contract ({cmd} -> streamed output / polled log text).
706
-
707
687
  def post_scratch_run(self, body: dict[str, Any]) -> dict[str, Any]:
708
688
  """Request a scratch occupant (``POST /api/scratch/run``).
709
689
 
710
- ``body`` is :func:`urun.scratch.scratch_run_body`'s payload: app,
711
- optional function/gpu/release_id/cmd/name, and ``ttl_s``. The server
712
- resolves the app's current promoted release when ``release_id`` is
690
+ The server resolves the app's current promoted release when ``release_id`` is
713
691
  omitted and answers ``{scratch_id, queue, expires_at}``.
714
692
  """
715
693
  return self._post("/api/scratch/run", body)
@@ -928,7 +906,7 @@ class ApiClient:
928
906
  raise UrunError(
929
907
  f"network error: {reason} ({method} {url}); this request mints a "
930
908
  "one-time credential so it is NOT retried automatically — the server "
931
- "may or may not have applied it. Check `urun node list` before retrying."
909
+ "may or may not have applied it."
932
910
  ) from exc
933
911
  return self._parse_json(payload, method, url)
934
912
 
@@ -1068,9 +1046,6 @@ def require_safe_url(raw_url: str, label: str) -> None:
1068
1046
  # Terminal build states reported by the control plane's deployment-status document.
1069
1047
  # The build worker transitions a deployment queued -> building -> ready|failed and
1070
1048
  # records the actual build stderr/reason in the `error` field on failure.
1071
- # "cancelled" is terminal by user intent (`urun cancel`): the poll loop must stop
1072
- # — the control plane will never progress a cancelled deploy (only a fresh
1073
- # `urun deploy` re-queues it).
1074
1049
  TERMINAL_STATES = {"ready", "failed", "cancelled"}
1075
1050
 
1076
1051
  # Human-readable progress lines for non-terminal states, so the CLI streams what the
@@ -1141,10 +1116,7 @@ def poll_until_done(
1141
1116
  ``UrunError`` on timeout.
1142
1117
 
1143
1118
  ``on_status`` (when given) receives the FULL status document of every
1144
- successful poll read, terminal one included — the hook the build-log
1145
- streamer rides (``urun.buildlogs.BuildLogTailer``) so log lines interleave
1146
- with the state narrative on the poll cadence.
1147
-
1119
+ successful poll read, terminal one included.
1148
1120
  A transient failure on a single status read (read/connect timeout,
1149
1121
  connection reset, 5xx/429) does NOT abort the deploy — the build continues
1150
1122
  server-side, so the poll backs off and re-reads, bounded by ``timeout``.
@@ -1230,7 +1202,6 @@ def poll_until_done(
1230
1202
  "The control plane kept answering, so this is not a poll failure: it "
1231
1203
  f"reported '{last_state}' for the whole {timeout:.0f}s budget. If the app "
1232
1204
  "is in fact already serving, the build-status document is wedged "
1233
- "server-side — check `urun build logs` for the real build outcome."
1234
1205
  )
1235
1206
  time.sleep(_poll_sleep_interval(time.time() - poll_started, interval))
1236
1207
 
@@ -1267,7 +1238,6 @@ def _poll_streak_error(
1267
1238
  f"GET /deployment-status/{manifest_hash}: {describe_error(exc)}. "
1268
1239
  f"Failing now rather than re-polling a broken endpoint for the rest of the "
1269
1240
  f"wait budget; {staleness}. The build itself may still be running "
1270
- f"server-side — check `urun build logs` for the real outcome."
1271
1241
  )
1272
1242
 
1273
1243
 
@@ -1323,3 +1293,38 @@ def _absorb_transient_poll_failure(
1323
1293
  def progress_line(state: str) -> str:
1324
1294
  """Render a human-readable progress line for a build state."""
1325
1295
  return _STATE_PROGRESS.get(state, state)
1296
+
1297
+
1298
+ def resolve_app_functions(client: Any, app_slug: str, *, environment: str | None) -> list[str]:
1299
+ """EVERY function the deployed app serves, from the platform's own rows.
1300
+
1301
+ The launch token is APP-WIDE (owner ruling 2026-08-19): a multi-function
1302
+ app must be able to start sessions on any of its functions, and the
1303
+ platform expresses scope only as an explicit app/function list — so the
1304
+ CLI enumerates. ONE canonical source: the capacity rows (written at build
1305
+ registration, so they exist the moment a deploy promotes — before any
1306
+ runtime materializes). Empty is a loud error, never a silent
1307
+ single-function fallback.
1308
+ """
1309
+ try:
1310
+ response = client.list_capacity({"app": app_slug, "environment": environment})
1311
+ except UrunError:
1312
+ raise
1313
+ except Exception as exc: # noqa: BLE001 - surfaced verbatim below
1314
+ raise UrunError(
1315
+ f"could not enumerate app {app_slug!r} functions for the launch token: {exc}"
1316
+ ) from exc
1317
+ rows = response.get("capacity") if isinstance(response, dict) else None
1318
+ names: list[str] = []
1319
+ for row in rows if isinstance(rows, list) else []:
1320
+ if not isinstance(row, dict):
1321
+ continue
1322
+ name = row.get("function_name")
1323
+ if isinstance(name, str) and name and name not in names:
1324
+ names.append(name)
1325
+ if not names:
1326
+ raise UrunError(
1327
+ f"app {app_slug!r} reports no deployed functions; deploy it first "
1328
+ "(the launch token is scoped to the app's real function list)"
1329
+ )
1330
+ return names