feat(worker,gateway): report record-info pin outcome in WorkerReady; drain-thread completion tests

The worker logged its MXSTATUS_PROXY record-info pin outcome only to its own
stderr, which the gateway's launcher does not capture, so operators never saw
whether the pin took.

- Contract (additive, internal IPC): WorkerReady.record_info_pin_status = 5.
  No protocol version bump; an older peer ignores it or sends it empty.
  Regenerated Contracts/Generated, the client protoset, the Rust vendored
  proto, and the Go/Python/Java worker bindings (real delta only).
- Worker: the handshake copies MxStatusProxyRecordInfoPin.Status into
  WorkerReady unless the runtime already set it.
- Gateway: WorkerClient records it (IWorkerClient.RecordInfoPinStatus, default
  null) and logs it at Information when pinned, Warning otherwise; empty is
  not logged. Shown as "Record-info pin" in the dashboard session details
  Worker table via DashboardSessionSummary.WorkerRecordInfoPinStatus.
- Tests: drain-thread cancellation (task ends Canceled; RunAsync cancels,
  runtime disposed, thread exits, no EventDrain stop-failure log) and fault
  (exception on the thread faults RunAsync with the same instance) paths;
  WorkerReady carries the pin status; gateway logging/recording and the
  dashboard projection.
- Docs: gateway.md STA thread model (drain thread, pin step in COM lifetime),
  MxAccessWorkerInstanceDesign, GatewayProcessDesign, GatewayDashboardDesign,
  WorkerFrameProtocol.
This commit is contained in:
Joseph Doherty
2026-11-21 08:11:31 -05:00
parent f6a3e13bd3
commit e811b93eb8
23 changed files with 878 additions and 145 deletions
+3 -1
View File
@@ -482,7 +482,9 @@ Shows:
- a session section: state badge, backend, client identity, client session name,
client correlation id (all redacted), open time, last activity, lease expiry,
events received, and last fault;
- a worker section: process id, worker state, and last heartbeat time;
- a worker section: process id, worker state, last heartbeat time, and the
worker's `MXSTATUS_PROXY` record-info pin outcome from `WorkerReady` (`-` for an
older worker that does not report it);
- a "Recent events" table — the newest 50 events from the in-process mirror, with
worker sequence, family, server handle, item handle, and status (no values), plus
a live/offline pill; gated by the session ACL, so a caller who may not observe the
+9
View File
@@ -507,6 +507,15 @@ and nonce, waits for `WorkerReady`, and only then exposes `Ready` state. The
read loop starts after readiness so the handshake has a single owner for its
ordered frames.
`WorkerReady.record_info_pin_status` carries the worker's `MXSTATUS_PROXY`
record-info pin outcome (see `MxAccessWorkerInstanceDesign.md`). The gateway does
not capture worker stderr, so `WorkerClient` is where operators see it: a status
starting `pinned ` is logged at Information, anything else at Warning, because an
unpinned worker pays a type-library reload on every data change. It is kept as
`IWorkerClient.RecordInfoPinStatus` and shown on the dashboard's session details
page. It never gates readiness, and an empty status (an older worker) is neither
logged nor shown.
### Read loop
The read loop:
+9 -5
View File
@@ -500,10 +500,12 @@ microsecond. Measured at ~240 events/s on the dev box, worker CPU fell from 67%
with the pin alone.
The pin only warms a cache. It changes no MXAccess behaviour, and a failure is never fatal. The
outcome is in `MxStatusProxyRecordInfoPin.Status`, and the worker logs it as `WorkerRecordInfoPin`
just before `WorkerReady`. Worker logs go to stderr, which the gateway does not redirect, so the
line lands wherever the host captures the gateway's stderr (the NSSM stderr log on deployed
boxes).
outcome is in `MxStatusProxyRecordInfoPin.Status`. During the handshake `WorkerPipeSession` logs it
as `WorkerRecordInfoPin` and copies it into `WorkerReady.record_info_pin_status`, unless the runtime
already filled that field. The copy is the one operators see: the worker's own log goes to stderr,
which the gateway's launcher does not redirect. The gateway logs the reported status (Warning when
it is not a successful pin) and shows it on the dashboard's session details page; see
`GatewayProcessDesign.md`.
If COM creation fails, the worker should send a structured fault with:
@@ -602,7 +604,9 @@ CLR thread pool:
- It blocks on the frame writer's batch write.
- `RunEventDrainLoopAsync` starts the thread and returns a task that completes,
faults or cancels exactly as the loop does, so the message loop's `Task.WhenAny`
supervision is unchanged.
supervision is unchanged. Cancelling the session ends the task Canceled, which
teardown treats as a clean stop; an exception thrown on the thread faults the task
with that same exception, which ends `RunAsync` with it as the async loop did.
The reason is .NET Framework's thread pool. As an async loop, every enqueue's
semaphore release queued a continuation to the pool, and each pool worker that ran
+6
View File
@@ -90,6 +90,12 @@ Protocol violations throw `WorkerFrameProtocolException` with a
`WorkerFrameProtocolErrorCode` so callers can distinguish malformed frames,
oversized frames, protocol version mismatches, and session mismatches.
Fields added to a body without a protocol version bump must be ones both ends can
ignore. `WorkerReady.record_info_pin_status` (field 5) is the current example: it is
diagnostic only, so a newer worker talking to an older gateway is simply not
reported, and an older worker leaves it empty, which the gateway treats as "not
reported". Neither end gates readiness on it.
## Write Scheduling And Sequencing
This section covers write scheduling (priority classes, enqueue-then-contend,