next-issue 6.7.0 → 6.8.0

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
@@ -853,6 +853,12 @@ affect another. The worker:
853
853
  takes it from its own flags. Only runs of the worker can switch; a
854
854
  command-line run keeps what `--hunt` gave it. The progress of each run
855
855
  carries `hunting`, `true` while hunting is on;
856
+ - asks a watching run to check for new issues now when a client sends
857
+ `{ "type": "refresh", "root": "<path>" }`. A run that waits between passes
858
+ starts a new pass at once, and its next wait starts again at 1 minute; a
859
+ waiting hunter checks the ready count again. A refresh while a pass runs,
860
+ for a run that is stopping or does not watch, or with no run going, changes
861
+ nothing and gets no answer;
856
862
  - exits, and removes its socket and lock files, when no run is going and no
857
863
  client is connected, or when no client connects in the 30 seconds after it
858
864
  starts;
@@ -24,18 +24,22 @@ export function deadline(ms, onExpire) {
24
24
  export function elapsedMs(started) {
25
25
  return Date.now() - started;
26
26
  }
27
- export function wakeableSleep(sleeper, ms, stopped) {
27
+ // Resolves false when woken, or when `refreshed` aborts.
28
+ export function wakeableSleep(sleeper, ms, stopped, refreshed) {
28
29
  return new Promise((resolve) => {
29
- if (stopped) {
30
+ if (stopped || refreshed?.aborted === true) {
30
31
  resolve(false);
31
32
  return;
32
33
  }
33
34
  const settle = (slept) => {
34
35
  clearTimeout(timer);
36
+ refreshed?.removeEventListener('abort', onRefresh);
35
37
  sleeper.wake = undefined;
36
38
  resolve(slept);
37
39
  };
40
+ const onRefresh = () => settle(false);
38
41
  const timer = setTimeout(() => settle(true), timerMs(ms));
39
42
  sleeper.wake = () => settle(false);
43
+ refreshed?.addEventListener('abort', onRefresh, { once: true });
40
44
  });
41
45
  }
@@ -33,9 +33,9 @@ export function listenForInterrupts(say) {
33
33
  return {
34
34
  afterIssue: () => presses >= 1,
35
35
  afterRound: () => presses >= 2,
36
- sleep: (ms, busy = () => false) => {
36
+ sleep: (ms, busy = () => false, refreshed) => {
37
37
  hunting = busy;
38
- return wakeableSleep(sleeper, ms, presses >= 1);
38
+ return wakeableSleep(sleeper, ms, presses >= 1, refreshed);
39
39
  },
40
40
  };
41
41
  }
@@ -0,0 +1,10 @@
1
+ export function refresher() {
2
+ let controller = new AbortController();
3
+ return {
4
+ refreshed: () => controller.signal,
5
+ refresh: () => {
6
+ controller.abort();
7
+ controller = new AbortController();
8
+ },
9
+ };
10
+ }
package/dist/run.mjs CHANGED
@@ -86,14 +86,15 @@ export function watchRun(args, loop, context, controls, print) {
86
86
  const hunt = hunter(context);
87
87
  return watchIssues(args, {
88
88
  ...loop,
89
- wait: (minutes) => {
89
+ wait: (minutes, refreshed) => {
90
90
  recorder.event('watch.wait', { minutes }, 'quiet');
91
91
  passStart = recorder.summary();
92
- return interrupts.sleep(minutesToMs(minutes), () => hunt.busy());
92
+ return interrupts.sleep(minutesToMs(minutes), () => hunt.busy(), refreshed);
93
93
  },
94
94
  passEnd: (issues) => print({ ...recorder.summary(passStart), issues }),
95
95
  hunter: hunt,
96
96
  hunting: controls.hunting ?? huntSwitch(args.hunt),
97
+ refreshed: controls.refreshed,
97
98
  });
98
99
  }
99
100
  function recordLoopEnd(recorder, stoppedAt, error) {
package/dist/serve.mjs CHANGED
@@ -14,7 +14,7 @@ import { runRepo } from './run.mjs';
14
14
  import { packageVersion } from './version.mjs';
15
15
  import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
16
16
  import { checkSocketPath, workerPaths } from './worker-paths.mjs';
17
- import { active, endStatus, huntRefusal, newRun, requestStop, runControls, runsMessage, setHunting, startRefusal, stopPoint, } from './worker-run.mjs';
17
+ import { active, endStatus, huntRefusal, newRun, requestRefresh, requestStop, runControls, runsMessage, setHunting, startRefusal, stopPoint, } from './worker-run.mjs';
18
18
  import { broadcast, closer, fileId, listen, parseMessage, removeOwned, shutdown, } from './worker-server.mjs';
19
19
  const LOCK_WAIT_MS = 5_000;
20
20
  const IDLE_MS = 30_000;
@@ -117,6 +117,9 @@ export async function startWorker(options) {
117
117
  else if (value.type === 'hunt') {
118
118
  hunt(socket, value.root, value.on);
119
119
  }
120
+ else if (value.type === 'refresh') {
121
+ requestRefresh(runs.get(value.root));
122
+ }
120
123
  else if (value.type === 'questions') {
121
124
  void sendQuestions(value.root, () => [socket], value.id);
122
125
  }
package/dist/watch.mjs CHANGED
@@ -8,7 +8,7 @@ export async function watchIssues(args, watch) {
8
8
  const claims = claimAlarm();
9
9
  const hunting = watch.hunter === undefined
10
10
  ? undefined
11
- : huntIssues(watch.hunter, watch.hunting ?? huntSwitch(true), running, failed, claims, () => ended.signal.aborted || watch.stop(), ended.signal);
11
+ : huntIssues(watch.hunter, watch.hunting ?? huntSwitch(true), running, failed, claims, watch.refreshed, () => ended.signal.aborted || watch.stop(), ended.signal);
12
12
  try {
13
13
  return await watchPasses(args, failed, {
14
14
  ...watch,
@@ -57,7 +57,7 @@ function aborted(signal) {
57
57
  }
58
58
  });
59
59
  }
60
- async function huntIssues(hunter, hunting, running, failed, claims, stopped, signal) {
60
+ async function huntIssues(hunter, hunting, running, failed, claims, refreshes, stopped, signal) {
61
61
  let step = 0;
62
62
  while (!stopped()) {
63
63
  if (!hunting.on()) {
@@ -81,8 +81,9 @@ async function huntIssues(hunter, hunting, running, failed, claims, stopped, sig
81
81
  continue;
82
82
  }
83
83
  const changed = hunting.changed();
84
- await hunter.wait(backOffMinutes(step), AbortSignal.any([signal, claims.signal(), changed]));
85
- if (changed.aborted) {
84
+ const refreshed = refreshes?.() ?? new AbortController().signal;
85
+ await hunter.wait(backOffMinutes(step), AbortSignal.any([signal, claims.signal(), changed, refreshed]));
86
+ if (changed.aborted || refreshed.aborted) {
86
87
  step = 0;
87
88
  }
88
89
  else if (!claims.take()) {
@@ -110,8 +111,12 @@ async function watchPasses(args, failed, watch) {
110
111
  }
111
112
  const minutes = backOffMinutes(step);
112
113
  step += 1;
113
- if (!(await watch.wait(minutes))) {
114
- return { reports };
114
+ const refreshed = watch.refreshed?.();
115
+ if (!(await watch.wait(minutes, refreshed))) {
116
+ if (refreshed?.aborted !== true || watch.stop()) {
117
+ return { reports };
118
+ }
119
+ step = 0;
115
120
  }
116
121
  }
117
122
  }
@@ -3,8 +3,15 @@ import { wakeableSleep } from './durations.mjs';
3
3
  import { huntSwitch } from './hunt-switch.mjs';
4
4
  import { applyEvent } from './progress.mjs';
5
5
  import { STOP_POINTS } from './protocol.mjs';
6
+ import { refresher } from './refresh.mjs';
6
7
  export function newRun(progress, watching = false) {
7
- return { progress, children: runChildren(), watching, hunting: huntSwitch(progress.hunting) };
8
+ return {
9
+ progress,
10
+ children: runChildren(),
11
+ watching,
12
+ hunting: huntSwitch(progress.hunting),
13
+ refresher: refresher(),
14
+ };
8
15
  }
9
16
  export function active(run) {
10
17
  return run?.progress.status === 'running' || run?.progress.status === 'stopping';
@@ -60,6 +67,14 @@ export function huntRefusal(run, on) {
60
67
  }
61
68
  return undefined;
62
69
  }
70
+ // Only a running watch run refreshes; a pass that is going or a stop is left alone.
71
+ export function requestRefresh(run) {
72
+ if (run?.progress.status !== 'running' || !run.watching || run.stop !== undefined) {
73
+ return false;
74
+ }
75
+ run.refresher.refresh();
76
+ return true;
77
+ }
63
78
  export function setHunting(run, on) {
64
79
  run.hunting.set(on);
65
80
  run.progress = { ...run.progress, hunting: on };
@@ -68,13 +83,14 @@ function runInterrupts(run) {
68
83
  return {
69
84
  afterIssue: () => run.stop !== undefined,
70
85
  afterRound: () => run.stop === 'round' || run.stop === 'now',
71
- sleep: (ms) => wakeableSleep(run, ms, run.stop !== undefined),
86
+ sleep: (ms, _hunting, refreshed) => wakeableSleep(run, ms, run.stop !== undefined, refreshed),
72
87
  };
73
88
  }
74
89
  export function runControls(run, update, issueEnded) {
75
90
  return {
76
91
  interrupts: runInterrupts(run),
77
92
  hunting: run.hunting,
93
+ refreshed: run.refresher.refreshed,
78
94
  onEvent: (record) => {
79
95
  update(applyEvent(run.progress, record));
80
96
  if (endsIssue(record)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.7.0",
3
+ "version": "6.8.0",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",