From e765c06ae3842b4cae06e48addef845b436fe40b Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Fri, 6 Nov 2026 01:36:49 +0100 Subject: [PATCH] STRA-338 S7: last_activity at the start and end of a request reads the request's clock run_backend_worker (twice per request) and the stdio worker's run_session (once per request) stamp last_activity with ObsHandle::now(). The stamps at attach or READY and the per-engine-line stamp keep Instant::now(). The instant-now ratchet of strata-control falls from 26 to 23. Docs: gateway-ports.md lists what is and is not behind the Clock. --- architecture-baseline.json | 2 +- control-plane/src/backend_worker/run_backend_worker.rs | 4 ++-- control-plane/src/worker/run_session.rs | 2 +- docs/architecture/gateway-ports.md | 7 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/architecture-baseline.json b/architecture-baseline.json index dca43084..4a57f9d9 100644 --- a/architecture-baseline.json +++ b/architecture-baseline.json @@ -180,7 +180,7 @@ "instant-now:leleka-npu-service": 5, "instant-now:leleka-obs": 3, "instant-now:leleka-runtime": 17, - "instant-now:strata-control": 26, + "instant-now:strata-control": 23, "instant-now:strata-desktop-core": 15, "path-include:leleka-cuda-driver": 115, "path-include:leleka-model-format": 12, diff --git a/control-plane/src/backend_worker/run_backend_worker.rs b/control-plane/src/backend_worker/run_backend_worker.rs index dfb0b788..2844498f 100644 --- a/control-plane/src/backend_worker/run_backend_worker.rs +++ b/control-plane/src/backend_worker/run_backend_worker.rs @@ -166,13 +166,13 @@ pub async fn run_backend_worker( { continue; } - status.write().await.last_activity = Some(Instant::now()); + status.write().await.last_activity = Some(command.request.obs.now()); let _activity = command.activity.take(); match serve_one(&engine, &config, &status, &mut shutdown, &mut command, &loaded) .await { Served::Done => { - status.write().await.last_activity = Some(Instant::now()); + status.write().await.last_activity = Some(command.request.obs.now()); refresh_prefix_view(&engine, &config).await; } Served::Shutdown => { diff --git a/control-plane/src/worker/run_session.rs b/control-plane/src/worker/run_session.rs index 9f6a8908..2cd1e638 100644 --- a/control-plane/src/worker/run_session.rs +++ b/control-plane/src/worker/run_session.rs @@ -180,7 +180,7 @@ pub(super) async fn run_session( if command.result.is_closed() || command.queue.take().is_some_and(|ticket| !ticket.claim()) { continue; } - status.write().await.last_activity = Some(tokio::time::Instant::now()); + status.write().await.last_activity = Some(command.request.obs.now()); // Retain the command activity until protocol cleanup, // including STOP/QUIT and failed-process termination. let _activity = command.activity.take(); diff --git a/docs/architecture/gateway-ports.md b/docs/architecture/gateway-ports.md index 284df8fd..96fa6379 100644 --- a/docs/architecture/gateway-ports.md +++ b/docs/architecture/gateway-ports.md @@ -62,10 +62,11 @@ Completions translation) is the crate `leleka-gateway-domain` (layer L2); `strat * The request's own stamps read the `Clock`: `Observe.clock` (the router builds it from `services.clock`) goes into the request record `ReqCtx`, which stamps `admitted`, `engine_start`, `first_token` and the line written at the end with it. The backend worker's `serve_one` and `conclude` and the stdio worker's `combine_done` take the start and end of a - request from `ObsHandle::now()` (the clock of the request's record; the system's when the request has none). Those are a few - stamps per request and none per streamed token or event. + request, and the `last_activity` stamps at the start and the end of a request, from `ObsHandle::now()` (the clock of the + request's record; the system's when the request has none). Those are a few stamps per request and none per streamed token + or event. * Still direct `Instant::now()`, tracked with the `instant-now` ratchet in `architecture-baseline.json`: the activity - stamps of the worker supervisors (`last_activity`), the per-event progress stamps and the cancel and stop-drain deadlines + stamps of the worker supervisors at attach or `READY` and per engine line, the per-event progress stamps and the cancel and stop-drain deadlines inside the streaming loops, the metrics counters, the MCP hub and server, the model fetch, the memory, prefix and hardware views, the request monitor and the stage trace.