@plot-pm/board 0.16.2 → 0.16.3

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.
@@ -101,9 +101,13 @@ Started by plot-dispatch.sh inside the worker's wrapper. Reads its subject from
101
101
  the environment, exactly as the wrapper's other children do:
102
102
 
103
103
  PLOT_BRANCH the branch whose builds this monitor will report
104
- PLOT_WORKTREE the desk it reads the head sha from
104
+ PLOT_WORKTREE the desk it STARTS on; it follows the manifest's
105
+ `worktree` from then on (PLOT_MANIFEST_FILE below)
106
+ PLOT_MANIFEST_FILE the manifest this agent is named in, re-read each pass;
107
+ absent or unreadable keeps watching PLOT_WORKTREE
105
108
  PLOT_MONITOR_FILE where findings are published (default:
106
- $PLOT_WORKTREE/.plot-worker.monitor.build.jsonl)
109
+ $PLOT_WORKTREE/.plot-worker.monitor.build.jsonl). Set
110
+ explicitly, it WINS and does not follow a hop.
107
111
  PLOT_MONITOR_INTERVAL seconds between passes (default 30)
108
112
 
109
113
  --once take one sample and exit, rather than looping. A test
@@ -124,7 +128,17 @@ done
124
128
  monitor='BuildMonitor'
125
129
 
126
130
  branch="${PLOT_BRANCH:-}"
127
- worktree="${PLOT_WORKTREE:-}"
131
+ # The branch at start, kept for a detached or unreadable desk; `monitor_branch`
132
+ # re-reads the desk on every pass.
133
+ start_branch="$branch"
134
+ # THE DESK THIS MONITOR WAS LAUNCHED ON, FIXED FOR ITS WHOLE LIFE. `worktree`
135
+ # itself is no longer fixed: `monitor_pass` reassigns it every pass by asking
136
+ # `plot_watched_desk`, which follows a hop to the manifest's new `worktree`
137
+ # field. This is the launch desk `plot_watched_desk` falls back to when the
138
+ # manifest carries no override — never read directly after startup.
139
+ launched_worktree="${PLOT_WORKTREE:-}"
140
+ worktree="$launched_worktree"
141
+ manifest_file="${PLOT_MANIFEST_FILE:-}"
128
142
  # THIRTY SECONDS IS AFFORDABLE ONLY BECAUSE OF THE SILENCE RULE. This cadence
129
143
  # matches the WorkerMonitor's rather than the AgentMonitor's, and it asks a HOST
130
144
  # — which would be the rate problem the AgentMonitor's 300 s exists to avoid,
@@ -132,7 +146,11 @@ worktree="${PLOT_WORKTREE:-}"
132
146
  # is bounded by how long a build takes, not by how long a worker lives.
133
147
  interval="${PLOT_MONITOR_INTERVAL:-30}"
134
148
 
135
- findings="${PLOT_MONITOR_FILE:-${worktree:+$worktree/.plot-worker.monitor.build.jsonl}}"
149
+ # IF `PLOT_MONITOR_FILE` IS SET IT WINS AND DOES NOT FOLLOW THE DESK — the
150
+ # existing contract this usage text already states. Otherwise `findings`
151
+ # follows `worktree`, reassigned alongside it at the top of `monitor_pass`.
152
+ monitor_file_override="${PLOT_MONITOR_FILE:-}"
153
+ findings="${monitor_file_override:-${worktree:+$worktree/.plot-worker.monitor.build.jsonl}}"
136
154
 
137
155
  # THE SUBJECT, read the same way the other two monitors read it.
138
156
  pid_file="${PLOT_PID_FILE:-${worktree:+$worktree/.plot-worker.pid}}"
@@ -209,6 +227,25 @@ monitor_head_sha() { # → prints a sha, or nothing
209
227
  git -C "$worktree" rev-parse --verify --quiet HEAD 2>/dev/null || true
210
228
  }
211
229
 
230
+ # Which branch does the desk hold, right now?
231
+ #
232
+ # → prints the branch, or the branch the monitor started with when the desk is
233
+ # detached or unreadable
234
+ #
235
+ # READ ON EVERY PASS, NOT ONCE. A free agent starts with an empty `PLOT_BRANCH`
236
+ # and is handed its slices later, in the same desk; a dispatched agent hops to
237
+ # its next slice in the same desk too. A branch fixed at start made this monitor
238
+ # unaskable for every free agent (`monitor_run_for_sha` returns 2 on an empty
239
+ # branch) and wrong after every hop, so the correction path in
240
+ # `plot-worker-loop.sh` received no finding for most slices.
241
+ monitor_branch() { # → prints a branch, or nothing
242
+ local current=''
243
+ if [ -n "$worktree" ] && [ -d "$worktree" ]; then
244
+ current=$(git -C "$worktree" branch --show-current 2>/dev/null || true)
245
+ fi
246
+ printf '%s' "${current:-$start_branch}"
247
+ }
248
+
212
249
  # What does the host say about the run for ONE sha?
213
250
  #
214
251
  # → prints the run JSON, or nothing when there is no run for it
@@ -376,6 +413,14 @@ sample_finding() { # → prints "finding\tevidence", or nothing
376
413
  # One full pass: sample, publish only on a change of ANSWER-ABOUT-A-COMMIT.
377
414
  monitor_pass() {
378
415
  local row finding evidence head
416
+ # REASSIGNED ONCE, HERE, RATHER THAN THREADED THROUGH EACH READER. `worktree`
417
+ # feeds `monitor_head_sha`, `monitor_branch` and `publish()`'s own field, so a
418
+ # hop is picked up in one place rather than three. `PLOT_MONITOR_FILE`, when
419
+ # set, WINS and does not follow the desk — the existing contract the usage
420
+ # text states.
421
+ worktree=$(plot_watched_desk "$manifest_file" "$launched_worktree")
422
+ findings="${monitor_file_override:-${worktree:+$worktree/.plot-worker.monitor.build.jsonl}}"
423
+ branch=$(monitor_branch)
379
424
  head=$(monitor_head_sha)
380
425
  row=$(sample_finding)
381
426
  finding="${row%% *}"