From 11338fb8879fe03aff1f5eb02994b1748ae2b12b Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Fri, 24 Jul 2026 18:12:54 -0700 Subject: [PATCH] Fix metrics doc drift and counters.sh shell prologue Two review findings on the runtime-metrics content: - ARCHITECTURE.md described the progress model as byte-weighted, summed once up front and credited at file completion - the pre-operation-weighted behavior. The current model (operation-weighted, total grows as heavy operations are discovered, credited per operation) is what README, HISTORY, and Metrics.cs implement, so align the architecture prose to it. - Docker/counters.sh used set -euo pipefail; committed shell scripts use the full set -Eeuo pipefail per the Workflow YAML Conventions shell rule. Co-Authored-By: Claude Opus 4.8 (1M context) --- ARCHITECTURE.md | 4 ++-- Docker/counters.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index b2064da8..3ffb93e8 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -79,8 +79,8 @@ All external process execution uses [CliWrap](https://github.com/Tyrrrz/CliWrap) `Metrics.cs` owns a single `System.Diagnostics.Metrics.Meter` (`PlexCleaner.Process`) published for the whole process and read externally with `dotnet-counters` (no config flag, and instruments are inert until observed). -- Hooks: `ProcessDriver.ProcessFiles` (the choke point every command and monitor cycle funnels through) drives the file/byte/in-flight instruments and the byte-weighted `progress.ratio`. `Process.ProcessFiles` records the per-`SidecarFile.StatesType` outcomes. `MediaTool` execution paths record `tool.duration`. -- Progress is weighted by input bytes (summed once up front and credited at completion from the same map), not file count. +- Hooks: `ProcessDriver.ProcessFiles` (the choke point every command and monitor cycle funnels through) drives the file/byte/in-flight instruments and the operation-weighted `progress.ratio`. `Process.ProcessFiles` records the per-`SidecarFile.StatesType` outcomes. `MediaTool` execution paths record `tool.duration`. +- Progress is operation-weighted, not file count: each heavy full-file operation counts the file's size as work to do when it starts and as work done when it finishes, so the total grows as operations are discovered rather than being summed up front. - Run-scoped gauges (totals, in-flight, progress, ETA) reset per `ProcessFiles` call, while the counters stay cumulative for the process. All writers use `Interlocked`, so the parallel loop needs no lock, and observable-gauge callbacks only read. Tags are bounded (`state`, `tool`) - no filename tags. ### Sidecar File System diff --git a/Docker/counters.sh b/Docker/counters.sh index 56261ee2..d21ade22 100644 --- a/Docker/counters.sh +++ b/Docker/counters.sh @@ -6,7 +6,7 @@ # docker exec counters # live monitor of the PlexCleaner.Process meter # docker exec counters collect ... # any other dotnet-counters verb/args, passed through -set -euo pipefail +set -Eeuo pipefail export DOTNET_BUNDLE_EXTRACT_BASE_DIR="${DOTNET_BUNDLE_EXTRACT_BASE_DIR:-/tmp}"