feat: expose Function worker stack inspection (#5043)

Adds `Job::stack(worker_id)` in Rust and `Job.stack(worker_id)` /
`AsyncJob.stack(worker_id)` in Python for server-side Function jobs. The
response preserves capture availability, timestamps, truncation, and
session details; unsupported local or query handles retain their
existing unsupported-operation behavior. Refresh wrappers forward the
request to their tracked server job.

```python
evidence = job.stack("worker-id")
for session in evidence["stacks"]:
    print(session["status"], session["stack"])
```

Requires a server implementing `/v1/jobs/stack` and system operate
privilege. The API propagates authorization and transport errors without
waiting for job completion. Existing progress snapshots already preserve
server warning fields.

Includes mocked request/response and synchronous/asynchronous Python
coverage. Local builds and tests were intentionally skipped as
requested.
This commit is contained in:
Jack Ye
2026-11-17 02:54:18 -08:00
committed by GitHub
parent 57b20fb11d
commit ba4e3ef3f9
8 changed files with 257 additions and 0 deletions
+7
View File
@@ -159,6 +159,13 @@ impl Job {
})
}
pub fn stack(self_: PyRef<'_, Self>, worker_id: String) -> PyResult<Bound<'_, PyAny>> {
let inner = self_.inner.clone();
future_into_py(self_.py(), async move {
Ok(inner.stack(worker_id).await.infer_error()?.to_string())
})
}
pub fn stats(self_: PyRef<'_, Self>) -> PyResult<Bound<'_, PyAny>> {
let inner = self_.inner.clone();
future_into_py(self_.py(), async move { inner.stats().await.infer_error() })