@oisin-ee/pi-dogsled 0.34.1 → 0.34.2

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.
package/README.md CHANGED
@@ -13,13 +13,13 @@ Install the binary on each Herdr host. Use the same release tag in each command.
13
13
  Binary:
14
14
 
15
15
  ```sh
16
- mise use github:oisin-ee/dogsled@v0.34.1 # x-release-please-version
16
+ mise use github:oisin-ee/dogsled@v0.34.2 # x-release-please-version
17
17
  ```
18
18
 
19
19
  Pi (extension, tools, the `todo` tool, and skill), from npm:
20
20
 
21
21
  ```sh
22
- pi install npm:@oisin-ee/pi-dogsled@0.34.1 # x-release-please-version
22
+ pi install npm:@oisin-ee/pi-dogsled@0.34.2 # x-release-please-version
23
23
  ```
24
24
 
25
25
  At session start the extension compares its version with `dogsled --version` and warns when they differ.
@@ -58,8 +58,10 @@ The bot uses `GITHUB_TOKEN`, so its release-PR updates do not start CI.
58
58
  Nothing auto-merges the release PR.
59
59
 
60
60
  When the user requests a release, merge the open release-please PR.
61
- The merge runs the full CI suite on the release commit through the reusable CI workflow.
62
- After CI passes, the publish job creates `vX.Y.Z` at that release commit and dispatches dist.
61
+ The release commit changes only version files and the changelog.
62
+ Every passing CI run records the tree it tested, so the release gate reuses the PR's proof when the release commit sits on a tree that a run already proved.
63
+ Only otherwise does the merge run the full CI suite on the release commit through the reusable CI workflow.
64
+ After that gate, the publish job creates `vX.Y.Z` at that release commit and dispatches dist.
63
65
  Dist publishes the binaries and calls the existing npm publisher.
64
66
  The publish job changes `autorelease: pending` to `autorelease: tagged` so release-please can prepare the next release.
65
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oisin-ee/pi-dogsled",
3
- "version": "0.34.1",
3
+ "version": "0.34.2",
4
4
  "description": "Pi extension for dogsled: the board, the /dogsled panel, the inbox reader, and the dogsled tools. Needs the dogsled binary of the same version.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/pi/activity.ts CHANGED
@@ -16,7 +16,13 @@ export type Payload =
16
16
  | { kind: "closed" };
17
17
  export type ActivityEvent =
18
18
  | { type: "agent_start" | "agent_end" | "settled" | "message_end" }
19
- | { type: "block"; index: number; phase: "thinking" | "responding"; ended: boolean; delta?: string }
19
+ | {
20
+ type: "block";
21
+ index: number;
22
+ phase: "thinking" | "responding";
23
+ ended: boolean;
24
+ delta?: string;
25
+ }
20
26
  | { type: "tool_start"; tool: ActiveTool }
21
27
  | { type: "tool_end"; id: string };
22
28
 
@@ -77,7 +83,10 @@ export class ActivityReducer {
77
83
  this.blocks.delete(event.index);
78
84
  if (!event.ended) this.blocks.set(event.index, event.phase);
79
85
  if (event.phase === "thinking") {
80
- this.thoughts.set(event.index, (this.thoughts.get(event.index) ?? "") + (event.delta ?? ""));
86
+ this.thoughts.set(
87
+ event.index,
88
+ (this.thoughts.get(event.index) ?? "") + (event.delta ?? ""),
89
+ );
81
90
  }
82
91
  } else if (event.type === "tool_start") {
83
92
  this.idle = false;
@@ -107,7 +116,10 @@ export class ActivityReducer {
107
116
  .join("\n\n"),
108
117
  16 * 1024,
109
118
  );
110
- return { kind: "snapshot", state: { phase, active_tools, ...(reasoning ? { reasoning } : {}) } };
119
+ return {
120
+ kind: "snapshot",
121
+ state: { phase, active_tools, ...(reasoning ? { reasoning } : {}) },
122
+ };
111
123
  }
112
124
  }
113
125
 
@@ -175,6 +187,7 @@ export class ActivityPublisher {
175
187
  private lastAttempt = -Infinity;
176
188
  private retryAt = -Infinity;
177
189
  private retryDelay = 500;
190
+ private lastBackoff: string | undefined;
178
191
  private timer: ReturnType<typeof setTimeout> | undefined;
179
192
  private heartbeat: ReturnType<typeof setInterval>;
180
193
  private controller: AbortController | undefined;
@@ -190,7 +203,8 @@ export class ActivityPublisher {
190
203
  this.path = `/api/agents/local/${encodeURIComponent(pane)}/activity`;
191
204
  this.reducer = new ActivityReducer(idle);
192
205
  this.pending = this.reducer.snapshot();
193
- this.request = { method: "GET", path: this.path };
206
+ this.request = this.registration(null, 0);
207
+ this.diagnostic("POST", 0, "start", "bootstrap");
194
208
  this.heartbeat = setInterval(() => {
195
209
  if (this.disposed || this.stopped) return;
196
210
  this.pending = this.reducer.snapshot();
@@ -242,7 +256,7 @@ export class ActivityPublisher {
242
256
  deadline = setTimeout(() => {
243
257
  controller.abort();
244
258
  reject(new Error("activity request deadline"));
245
- }, 1000);
259
+ }, 6000);
246
260
  deadline.unref();
247
261
  }),
248
262
  ]);
@@ -276,13 +290,54 @@ export class ActivityPublisher {
276
290
  const { status, body } = await this.send(request, controller);
277
291
  if (this.disposed) return;
278
292
  if (status < 200 || status >= 300) {
279
- const code = record(body) && typeof body["error"] === "string" ? body["code"] : undefined;
293
+ const receivedCode =
294
+ record(body) && typeof body["error"] === "string" ? body["code"] : undefined;
295
+ const code =
296
+ [
297
+ "invalid_request",
298
+ "unsupported_version",
299
+ "unauthorized",
300
+ "sequence_conflict",
301
+ "agent_missing",
302
+ "session_unverified",
303
+ "upstream_unavailable",
304
+ "session_changed",
305
+ "stale_generation",
306
+ "producer_closed",
307
+ "capacity",
308
+ "upstream_invalid",
309
+ ].find((known) => known === receivedCode) ?? "unknown";
280
310
  if (
281
- (request.method === "POST" &&
282
- (code === "session_changed" ||
311
+ code === "invalid_request" ||
312
+ code === "unsupported_version" ||
313
+ code === "unauthorized" ||
314
+ code === "sequence_conflict" ||
315
+ (status === 404 && code !== "agent_missing")
316
+ ) {
317
+ this.stop(request.method, status, code);
318
+ return;
319
+ }
320
+ // A 5xx may follow a committed mutation, even with a typed error body.
321
+ // Discovery failures return to POST so startup keeps cheap sampling alive.
322
+ if (
323
+ status >= 500 ||
324
+ code === "agent_missing" ||
325
+ code === "session_unverified" ||
326
+ code === "upstream_unavailable"
327
+ ) {
328
+ if (
329
+ request.method === "GET" &&
330
+ (code === "agent_missing" ||
283
331
  code === "session_unverified" ||
284
- code === "upstream_unavailable" ||
285
- code === "stale_generation")) ||
332
+ code === "upstream_unavailable")
333
+ )
334
+ this.request = this.registration(null, 0);
335
+ this.backoff(request.method, status, "retry", code);
336
+ return;
337
+ }
338
+ if (
339
+ (request.method === "POST" &&
340
+ (code === "session_changed" || code === "stale_generation")) ||
286
341
  (request.method === "PUT" &&
287
342
  (code === "stale_generation" ||
288
343
  code === "session_changed" ||
@@ -292,13 +347,10 @@ export class ActivityPublisher {
292
347
  this.sequence = 0;
293
348
  this.pending = this.reducer.snapshot();
294
349
  this.request = { method: "GET", path: this.path };
295
- this.retryAt = performance.now() + this.retryDelay;
296
- this.retryDelay = Math.min(5000, this.retryDelay * 2);
350
+ this.backoff(request.method, status, "discover", code);
297
351
  return;
298
352
  }
299
- // A server failure may follow a committed mutation. Retry this exact request.
300
- if (status >= 500) return;
301
- this.stop();
353
+ this.stop(request.method, status, code);
302
354
  return;
303
355
  }
304
356
  if (request.method === "GET") {
@@ -309,30 +361,30 @@ export class ActivityPublisher {
309
361
  !text(body["epoch"], 256) ||
310
362
  !record(body["producer"]) ||
311
363
  !counter(body["producer"]["generation"]) ||
312
- (body["producer"]["id"] !== null && body["producer"]["id"] !== undefined)
364
+ (body["producer"]["id"] !== null && !text(body["producer"]["id"], 256))
313
365
  ) {
314
- this.stop();
366
+ this.stop(request.method, status);
315
367
  return;
316
368
  }
317
- // Freeze fresh compare-and-swap evidence only while the pane is unowned.
318
- this.request = {
319
- method: "POST",
320
- path: `${this.path}/producer`,
321
- body: {
322
- version: 1,
323
- epoch: body["epoch"],
324
- expected_generation: body["producer"]["generation"],
325
- producer_id: this.producer,
326
- evidence: { ...this.evidence },
327
- },
328
- };
369
+ const detail = body["detail"];
370
+ const retired =
371
+ record(detail) &&
372
+ detail["availability"] === "unavailable" &&
373
+ (detail["reason"] === "producer_closed" || detail["reason"] === "expired");
374
+ if (body["producer"]["id"] !== null && !retired) {
375
+ // Generation-0 probes renew sampling interest by design without claiming the live generation.
376
+ this.request = this.registration(null, 0);
377
+ this.backoff(request.method, status, "wait_owner");
378
+ return;
379
+ }
380
+ this.request = this.registration(body["epoch"], body["producer"]["generation"]);
329
381
  } else {
330
382
  if (
331
383
  !acknowledgement(body, this.pane, this.producer) ||
332
384
  body.sequence !== (request.method === "POST" ? 0 : this.sequence) ||
333
385
  (request.method === "POST" &&
334
386
  record(request.body) &&
335
- (body.epoch !== request.body["epoch"] ||
387
+ ((request.body["epoch"] !== null && body.epoch !== request.body["epoch"]) ||
336
388
  !counter(request.body["expected_generation"]) ||
337
389
  body.generation <= request.body["expected_generation"])) ||
338
390
  (this.stamp &&
@@ -340,9 +392,10 @@ export class ActivityPublisher {
340
392
  body.generation !== this.stamp.generation ||
341
393
  body.session !== this.stamp.session))
342
394
  ) {
343
- this.stop();
395
+ this.stop(request.method, status);
344
396
  return;
345
397
  }
398
+ if (request.method === "POST") this.diagnostic("POST", status, "ack", "publishing");
346
399
  this.stamp = {
347
400
  epoch: body.epoch,
348
401
  generation: body.generation,
@@ -350,12 +403,14 @@ export class ActivityPublisher {
350
403
  session: body.session,
351
404
  };
352
405
  this.request = undefined;
406
+ this.lastBackoff = undefined;
353
407
  this.retryDelay = 500;
354
408
  this.retryAt = -Infinity;
355
409
  }
356
410
  } catch {
357
411
  // Offline and ambiguous outcomes are telemetry gaps, never hook failures.
358
412
  if (this.disposed) return;
413
+ this.backoff(request.method, 0, "retry_transport", "transport");
359
414
  } finally {
360
415
  if (!this.disposed) {
361
416
  this.busy = false;
@@ -365,7 +420,39 @@ export class ActivityPublisher {
365
420
  }
366
421
  }
367
422
 
368
- private stop(): void {
423
+ private registration(epoch: string | null, generation: number): Request {
424
+ return {
425
+ method: "POST",
426
+ path: `${this.path}/producer`,
427
+ body: {
428
+ version: 1,
429
+ epoch,
430
+ expected_generation: generation,
431
+ producer_id: this.producer,
432
+ evidence: { ...this.evidence },
433
+ },
434
+ };
435
+ }
436
+
437
+ private diagnostic(method: string, status: number, code: string, decision: string): void {
438
+ // Match the extension's console reporting; never log response text or native evidence.
439
+ console.error(
440
+ `[dogsled activity] pane=${encodeURIComponent(this.pane).slice(0, 384)} method=${method} status=${status} code=${code} decision=${decision}`,
441
+ );
442
+ }
443
+
444
+ private backoff(method: string, status: number, decision: string, code = "recovery"): void {
445
+ const key = `${method}:${code}:${decision}`;
446
+ if (this.lastBackoff !== key) {
447
+ this.diagnostic(method, status, code, decision);
448
+ this.lastBackoff = key;
449
+ }
450
+ this.retryAt = performance.now() + this.retryDelay;
451
+ this.retryDelay = Math.min(5000, this.retryDelay * 2);
452
+ }
453
+
454
+ private stop(method: string, status: number, code = "invalid_response"): void {
455
+ this.diagnostic(method, status, code, "stop");
369
456
  this.stopped = true;
370
457
  clearInterval(this.heartbeat);
371
458
  if (this.timer) clearTimeout(this.timer);
@@ -374,6 +461,7 @@ export class ActivityPublisher {
374
461
  dispose(): void {
375
462
  if (this.disposed) return;
376
463
  this.disposed = true;
464
+ this.diagnostic(this.request?.method ?? "PUT", 0, "dispose", "stop");
377
465
  clearInterval(this.heartbeat);
378
466
  if (this.timer) clearTimeout(this.timer);
379
467
  this.controller?.abort();
@@ -2,7 +2,7 @@
2
2
 
3
3
  1. Run the repository's heavy gate once, at the final revision. Limit it to the change if the task runner can do that. If a target fails, start a follow-up writer unit on the same branch with the failure. A finished writer is closed. When the fix arrives, run only the failed targets again.
4
4
  2. Run `gh pr ready <n>`, then merge the PR. Then confirm that its state is `MERGED`.
5
- 3. Landing never bumps versions or creates tags. Use conventional commit titles for feature PRs because release-please builds the changelog from them. Release only when the user asks: merge the open release-please PR. Its workflow runs the full CI suite on the release commit, then tags it and dispatches publication. A failed release stays outstanding: retry it by dispatching `release-please.yml` before anything else lands on main, or abandon it by reverting its release commit with a `chore(release):` subject. Never auto-merge the release-please PR.
5
+ 3. Landing never bumps versions or creates tags. Use conventional commit titles for feature PRs because release-please builds the changelog from them. Release only when the user asks: merge the open release-please PR. Its workflow reuses the passing CI proof of the tree under the release commit, or runs the full CI suite on the release commit when no run proved that tree. Then it tags the release commit and dispatches publication. A failed release stays outstanding: retry it by dispatching `release-please.yml` before anything else lands on main, or abandon it by reverting its release commit with a `chore(release):` subject. Never auto-merge the release-please PR.
6
6
  4. If GitHub Actions does not run because of billing, the local gate is the evidence. Say so once in the PR body.
7
7
  5. Bring the local `main` up to date with `origin/main`. Leave the tree clean.
8
8
  6. Report to the user what changed and what is live.