@rarog/server 1.1.1 → 1.1.2-beta.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/node_modules/@rarog/shared/package.json +1 -1
- package/node_modules/@rarog/shared/src/decode.js +46 -1
- package/node_modules/@rarog/shared/src/notify-copy.js +2 -0
- package/node_modules/@rarog/shared/src/protocol/background.js +7 -0
- package/node_modules/@rarog/shared/src/protocol/context.js +57 -0
- package/node_modules/@rarog/shared/src/protocol/coordination.js +42 -0
- package/node_modules/@rarog/shared/src/protocol/dialog-live.js +117 -0
- package/node_modules/@rarog/shared/src/protocol/files.js +1 -1
- package/node_modules/@rarog/shared/src/protocol/inbox.js +6 -0
- package/node_modules/@rarog/shared/src/protocol/presence.js +47 -0
- package/node_modules/@rarog/shared/src/protocol.js +14 -146
- package/node_modules/@rarog/shared/src/rest.js +16 -1
- package/node_modules/@rarog/shared/src/sentences/dialogs.js +10 -0
- package/node_modules/@rarog/shared/src/sentences/push.js +9 -0
- package/node_modules/@rarog/shared/src/sentences/rest.js +9 -0
- package/node_modules/@rarog/shared/src/sentences/restart.js +1 -0
- package/node_modules/@rarog/shared/src/sentences/session.js +24 -0
- package/package.json +2 -2
- package/plugin/rarog/.claude-plugin/plugin.json +4 -0
- package/plugin/rarog/bin/rarog-coordinator +7 -0
- package/plugin/rarog/hooks/hooks.json +18 -0
- package/plugin/rarog/hooks/recipient.mjs +95 -0
- package/plugin/rarog/lib/coordinator.mjs +1340 -0
- package/plugin/rarog/lib/threads.mjs +350 -0
- package/plugin/rarog/skills/coordinator/SKILL.md +111 -0
- package/plugin/rarog/skills/coordinator/check-and-merge.md +46 -0
- package/plugin/rarog/skills/coordinator/close-thread.md +15 -0
- package/plugin/rarog/skills/coordinator/role.md +61 -0
- package/plugin/rarog/skills/coordinator/send-back.md +39 -0
- package/plugin/rarog/skills/coordinator/start-thread.md +43 -0
- package/server/src/bootstrap/coordination.js +49 -0
- package/server/src/bootstrap/coordinator-start.js +27 -0
- package/server/src/bootstrap/inbox.js +4 -0
- package/server/src/bootstrap/pr-status.js +15 -7
- package/server/src/bootstrap/push.js +59 -5
- package/server/src/cli/doctor-pr-status.js +10 -6
- package/server/src/companion/catalog.js +1 -1
- package/server/src/companion/index.js +2 -4
- package/server/src/config/flags.js +4 -0
- package/server/src/config-env.js +15 -0
- package/server/src/config.js +17 -3
- package/server/src/coordination/merge-events.js +86 -0
- package/server/src/coordination/merge-prompt.js +244 -0
- package/server/src/coordination/registry.js +289 -0
- package/server/src/coordination/state.js +94 -0
- package/server/src/coordination/summary.js +422 -0
- package/server/src/coordination/thread-file.js +245 -0
- package/server/src/coordination/thread-git.js +110 -0
- package/server/src/coordination/watch.js +237 -0
- package/server/src/demo/content/coordinator.js +89 -0
- package/server/src/demo/content/en.js +57 -1
- package/server/src/demo/content/pl.js +57 -1
- package/server/src/demo/control.js +4 -2
- package/server/src/demo/inbox.js +12 -0
- package/server/src/demo/mock-herdr.js +5 -4
- package/server/src/demo/review-routes.js +2 -2
- package/server/src/demo/scenarios.js +31 -17
- package/server/src/demo/seeds.js +82 -40
- package/server/src/drivers/herdr/live-dialog.js +412 -0
- package/server/src/drivers/herdr/live-step.js +261 -0
- package/server/src/drivers/herdr/pause-gate.js +60 -0
- package/server/src/drivers/herdr/pull-request-poll.js +5 -5
- package/server/src/drivers/herdr/queue-take-back.js +4 -0
- package/server/src/drivers/herdr/returned-prompt.js +4 -1
- package/server/src/drivers/herdr/screen-fallback.js +50 -0
- package/server/src/drivers/herdr/start-dialog-gate.js +136 -0
- package/server/src/drivers/herdr-driver.js +159 -77
- package/server/src/files/refusals.js +9 -2
- package/server/src/files/session-gate.js +5 -4
- package/server/src/git-branch-diff.js +194 -0
- package/server/src/herdr/argv.js +34 -3
- package/server/src/herdr/audit.js +32 -1
- package/server/src/herdr/background/cli-shapes.js +35 -15
- package/server/src/herdr/background/index.js +7 -7
- package/server/src/herdr/background/merge.js +17 -5
- package/server/src/herdr/background/notification.js +0 -4
- package/server/src/herdr/background/pull-request-files.js +53 -161
- package/server/src/herdr/background/pull-requests.js +54 -632
- package/server/src/herdr/background/queued-prompt.js +46 -0
- package/server/src/herdr/background/work.js +96 -0
- package/server/src/herdr/client.js +22 -46
- package/server/src/herdr/commands/catalog.js +11 -7
- package/server/src/herdr/commands/discover.js +33 -1
- package/server/src/herdr/commands/index.js +3 -2
- package/server/src/herdr/dialogs/copy.js +7 -0
- package/server/src/herdr/dialogs/index.js +13 -1
- package/server/src/herdr/dialogs/layer1/hook-list/hook-list.js +4 -56
- package/server/src/herdr/dialogs/live/model.js +220 -0
- package/server/src/herdr/dialogs/live/policy.js +108 -0
- package/server/src/herdr/dialogs/live/view.js +261 -0
- package/server/src/herdr/dialogs/screen/form.js +6 -4
- package/server/src/herdr/dialogs/screen/option-run.js +25 -3
- package/server/src/herdr/dialogs/screen/parse.js +3 -3
- package/server/src/herdr/dialogs/screen/signatures.js +78 -0
- package/server/src/herdr/dialogs/screen/start-dialog.js +72 -0
- package/server/src/herdr/dialogs/screen/trust-arrow.js +46 -9
- package/server/src/herdr/engines.js +96 -0
- package/server/src/herdr/history-steps.js +9 -4
- package/server/src/herdr/identity.js +20 -5
- package/server/src/herdr/jsonl-follow.js +26 -3
- package/server/src/herdr/label-code.js +104 -0
- package/server/src/herdr/label-migration.js +142 -0
- package/server/src/herdr/launcher.js +30 -5
- package/server/src/herdr/plugin-copy.js +281 -0
- package/server/src/herdr/provenance.js +80 -40
- package/server/src/herdr/session-index.js +19 -0
- package/server/src/herdr/start-dialog-wait.js +96 -0
- package/server/src/herdr/supervisor.js +49 -23
- package/server/src/herdr/types.js +1 -0
- package/server/src/herdr/workspace-resolver.js +5 -4
- package/server/src/inbox/card.js +31 -8
- package/server/src/inbox/heads.js +1 -0
- package/server/src/inbox/inbox.js +21 -4
- package/server/src/inbox/removals.js +10 -1
- package/server/src/index.js +45 -8
- package/server/src/notify/apns-payload.js +5 -3
- package/server/src/notify/content.js +64 -0
- package/server/src/notify/index.js +11 -3
- package/server/src/notify/live-activity-state.js +19 -6
- package/server/src/notify/live-activity.js +5 -2
- package/server/src/notify/policy.js +53 -13
- package/server/src/notify/ready-to-merge.js +148 -0
- package/server/src/notify/stalled-wait.js +213 -0
- package/server/src/pr-status/facts.js +87 -0
- package/server/src/pr-status/gh.js +76 -9
- package/server/src/pr-status/index.js +1 -10
- package/server/src/pr-status/source.js +20 -6
- package/server/src/pr-status/tracker.js +32 -9
- package/server/src/project-root.js +233 -0
- package/server/src/routes/sessions.js +68 -2
- package/server/src/sessions/branch-diff.js +57 -0
- package/server/src/sessions/cli-registry.js +17 -3
- package/server/src/sessions/companion-scope.js +2 -1
- package/server/src/sessions/consent-cards.js +49 -2
- package/server/src/sessions/conversation-lists.js +11 -2
- package/server/src/sessions/coordinator-start.js +172 -0
- package/server/src/sessions/demo-modules.js +1 -0
- package/server/src/sessions/demo-seeds.js +100 -0
- package/server/src/sessions/driver-events.js +68 -14
- package/server/src/sessions/herdr-lifecycle.js +11 -4
- package/server/src/sessions/interrupt-windows.js +28 -4
- package/server/src/sessions/launch-gate.js +36 -11
- package/server/src/sessions/live-dialog.js +69 -0
- package/server/src/sessions/manager.js +138 -287
- package/server/src/sessions/owner-turn.js +36 -0
- package/server/src/sessions/pr-status-link.js +64 -16
- package/server/src/sessions/seen-marks.js +31 -12
- package/server/src/sessions/session-dialog.js +82 -0
- package/server/src/sessions/session-git.js +1 -0
- package/server/src/sessions/session-scope.js +6 -5
- package/server/src/sessions/session-take-back.js +5 -0
- package/server/src/sessions/session.js +82 -10
- package/server/src/sessions/state-machine.js +13 -0
- package/server/src/sessions/state-sentences.js +87 -30
- package/server/src/sessions/test-session.js +50 -0
- package/server/src/sessions/waiting-line.js +49 -0
- package/server/src/term/herdr-backend.js +15 -12
- package/server/src/term/lifecycle.js +4 -6
- package/server/src/transcript-import.js +20 -2
- package/server/src/version.js +4 -0
- /package/server/src/{companion/asks-owner.js → asks-owner.js} +0 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge in the coordinator's transcript: which entry is the owner's Merge prompt for a thread, and how long the
|
|
3
|
+
* thread is `merging` after it. Pure: transcript entries and moments come from the caller, and it reads no file.
|
|
4
|
+
* It yields facts (a Merge request, an episode and how it ended, a message from another session); the thread state
|
|
5
|
+
* that wins over the session state is decided elsewhere.
|
|
6
|
+
*
|
|
7
|
+
* Prompt shapes measured on Claude Code 2.1.331 (a typed prompt: a `user` entry with `origin.kind` `human`; a message
|
|
8
|
+
* from another session: `isMeta` with `origin.kind` `peer`, the sender's address in `origin.from` and its process id
|
|
9
|
+
* in `origin.verifiedPeerPid`).
|
|
10
|
+
*/
|
|
11
|
+
import { CLI_SHAPES } from '../herdr/background/cli-shapes.js';
|
|
12
|
+
import { queuedHumanPrompt } from '../herdr/background/queued-prompt.js';
|
|
13
|
+
import { THREAD_SESSION_PREFIX, isThreadName } from './thread-file.js';
|
|
14
|
+
const ORIGIN = CLI_SHAPES.queuedPrompt.literals;
|
|
15
|
+
const CARRIERS = CLI_SHAPES.notificationCarriers.literals;
|
|
16
|
+
const PEER = CLI_SHAPES.crossSessionPeer.literals;
|
|
17
|
+
/**
|
|
18
|
+
* The process id in the file name of a sender's socket address: `<pid>.sock` (measured on Claude Code 2.1.331, the
|
|
19
|
+
* number matched the sender's `claude` process).
|
|
20
|
+
*/
|
|
21
|
+
const SOCKET_PID = /\/([1-9]\d*)\.sock$/;
|
|
22
|
+
/** `origin.kind` of a message another session sent with SendMessage. */
|
|
23
|
+
const PEER_KIND = 'peer';
|
|
24
|
+
const MERGE_PREFIX = 'Merge: ';
|
|
25
|
+
function asRecord(value) {
|
|
26
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
|
|
27
|
+
}
|
|
28
|
+
function timeOf(entry) {
|
|
29
|
+
const raw = entry['timestamp'];
|
|
30
|
+
if (typeof raw !== 'string')
|
|
31
|
+
return null;
|
|
32
|
+
const at = Date.parse(raw);
|
|
33
|
+
return Number.isNaN(at) ? null : at;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The thread name of a Merge prompt, or `null`: the whole prompt, apart from white space around it, is exactly
|
|
37
|
+
* `Merge: <name>` or `Merge: [A] <name>`, with a name in the thread name alphabet. A line inside a longer prompt is
|
|
38
|
+
* a quote, and another spelling (`merge:`) is no Merge.
|
|
39
|
+
*/
|
|
40
|
+
export function mergeTargetOf(text) {
|
|
41
|
+
const prompt = text.trim();
|
|
42
|
+
if (!prompt.startsWith(MERGE_PREFIX))
|
|
43
|
+
return null;
|
|
44
|
+
let name = prompt.slice(MERGE_PREFIX.length);
|
|
45
|
+
if (name.startsWith(THREAD_SESSION_PREFIX))
|
|
46
|
+
name = name.slice(THREAD_SESSION_PREFIX.length);
|
|
47
|
+
return isThreadName(name) ? name : null;
|
|
48
|
+
}
|
|
49
|
+
/** The text of a prompt's content: a string, or text blocks only (an image or a tool result makes it no prompt). */
|
|
50
|
+
function promptText(content) {
|
|
51
|
+
if (typeof content === 'string')
|
|
52
|
+
return content;
|
|
53
|
+
if (!Array.isArray(content) || content.length === 0)
|
|
54
|
+
return null;
|
|
55
|
+
const parts = [];
|
|
56
|
+
for (const block of content) {
|
|
57
|
+
const record = asRecord(block);
|
|
58
|
+
if (record?.['type'] !== 'text' || typeof record['text'] !== 'string')
|
|
59
|
+
return null;
|
|
60
|
+
parts.push(record['text']);
|
|
61
|
+
}
|
|
62
|
+
return parts.join('\n');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The owner's own prompt in the main conversation, with its moment: a `user` entry that is neither meta nor a
|
|
66
|
+
* subagent's, with `origin.kind` `human`; or such a prompt typed while the session worked and absorbed into the
|
|
67
|
+
* running turn (`queuedHumanPrompt`). A message from another session, a summary and every meta entry are not.
|
|
68
|
+
*/
|
|
69
|
+
function ownerPrompt(value) {
|
|
70
|
+
const entry = asRecord(value);
|
|
71
|
+
if (entry === null)
|
|
72
|
+
return null;
|
|
73
|
+
const at = timeOf(entry);
|
|
74
|
+
if (at === null)
|
|
75
|
+
return null;
|
|
76
|
+
const queued = queuedHumanPrompt(entry);
|
|
77
|
+
if (queued !== null) {
|
|
78
|
+
const text = promptText(queued.prompt);
|
|
79
|
+
return text === null ? null : { text, at };
|
|
80
|
+
}
|
|
81
|
+
if (entry['type'] !== 'user' || entry['isMeta'] === true || entry['isSidechain'] === true)
|
|
82
|
+
return null;
|
|
83
|
+
if (asRecord(entry[ORIGIN.origin])?.[ORIGIN.kind] !== ORIGIN.human)
|
|
84
|
+
return null;
|
|
85
|
+
const text = promptText(asRecord(entry['message'])?.['content']);
|
|
86
|
+
return text === null ? null : { text, at };
|
|
87
|
+
}
|
|
88
|
+
/** The Merge request an entry of the coordinator's transcript carries, or `null`. */
|
|
89
|
+
export function mergeRequestOf(entry) {
|
|
90
|
+
const prompt = ownerPrompt(entry);
|
|
91
|
+
if (prompt === null)
|
|
92
|
+
return null;
|
|
93
|
+
const name = mergeTargetOf(prompt.text);
|
|
94
|
+
return name === null ? null : { name, at: prompt.at };
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The process that sent a message from another session, or `undefined`: only for a socket address in `from`, the
|
|
98
|
+
* verified process id when the entry has one, else the number in the socket's file name. Both present and different
|
|
99
|
+
* is no known sender, because the address would not belong to the process that wrote to the socket.
|
|
100
|
+
*/
|
|
101
|
+
function senderPid(origin, from) {
|
|
102
|
+
if (!from.startsWith(PEER.socket))
|
|
103
|
+
return undefined;
|
|
104
|
+
const named = SOCKET_PID.exec(from)?.[1];
|
|
105
|
+
const fromName = named === undefined ? undefined : Number(named);
|
|
106
|
+
const raw = origin[PEER.verifiedPid];
|
|
107
|
+
const verified = typeof raw === 'number' && Number.isSafeInteger(raw) && raw > 0 ? raw : undefined;
|
|
108
|
+
if (verified !== undefined && fromName !== undefined && verified !== fromName)
|
|
109
|
+
return undefined;
|
|
110
|
+
const pid = verified ?? fromName;
|
|
111
|
+
return pid !== undefined && Number.isSafeInteger(pid) ? pid : undefined;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A message from another session in a transcript (a thread's, when the coordinator sends it back), with the sender's
|
|
115
|
+
* address, its process ({@link senderPid}, absent when unknown) and the moment, or `null`. Both carriers count: the
|
|
116
|
+
* meta `user` entry and the queue attachment of a message absorbed into a running turn. A subagent's entry, the
|
|
117
|
+
* owner's prompt and a message without a sender are not.
|
|
118
|
+
*/
|
|
119
|
+
export function peerMessageOf(value) {
|
|
120
|
+
const entry = asRecord(value);
|
|
121
|
+
if (entry === null || entry['isSidechain'] === true)
|
|
122
|
+
return null;
|
|
123
|
+
const at = timeOf(entry);
|
|
124
|
+
if (at === null)
|
|
125
|
+
return null;
|
|
126
|
+
let origin = null;
|
|
127
|
+
if (entry['type'] === 'user') {
|
|
128
|
+
origin = asRecord(entry[ORIGIN.origin]);
|
|
129
|
+
}
|
|
130
|
+
else if (entry['type'] === CARRIERS.attachmentType) {
|
|
131
|
+
const attachment = asRecord(entry[CARRIERS.attachmentField]);
|
|
132
|
+
if (attachment?.['type'] === CARRIERS.queuedCommand)
|
|
133
|
+
origin = asRecord(attachment[ORIGIN.origin]);
|
|
134
|
+
}
|
|
135
|
+
if (origin?.[ORIGIN.kind] !== PEER_KIND)
|
|
136
|
+
return null;
|
|
137
|
+
const from = origin['from'];
|
|
138
|
+
if (typeof from !== 'string' || from === '')
|
|
139
|
+
return null;
|
|
140
|
+
const pid = senderPid(origin, from);
|
|
141
|
+
return pid === undefined ? { from, at } : { from, pid, at };
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Merge episodes of one coordinator conversation, one per thread name, fed with the coordinator's transcript entries
|
|
145
|
+
* in file order and with the moments the coordinator stopped working.
|
|
146
|
+
*
|
|
147
|
+
* - **Live point.** An entry older than the live point is history: the conversation before this coordinator process
|
|
148
|
+
* (a resumed or forked conversation carries the old entries), so a Merge there is no request. The caller starts
|
|
149
|
+
* with the process start it knows, or the moment it began reading, and moves it with {@link processStarted}.
|
|
150
|
+
* - **Stops.** A stop at or after the Merge's moment ends the episode; a stop seen before the Merge entry was read
|
|
151
|
+
* still ends it, because the turn that carried the Merge is over. The caller reports a stop when the coordinator
|
|
152
|
+
* leaves work for idle, an interrupt or its end, never for a dialog: a coordinator waiting on a dialog still works.
|
|
153
|
+
*/
|
|
154
|
+
export class MergeEpisodes {
|
|
155
|
+
#liveFrom;
|
|
156
|
+
#lastStop = Number.NEGATIVE_INFINITY;
|
|
157
|
+
#episodes = new Map();
|
|
158
|
+
/** The last send-back per thread that matched no episode yet: its Merge entry may still be unread. */
|
|
159
|
+
#earlySendBack = new Map();
|
|
160
|
+
constructor(liveFrom) {
|
|
161
|
+
this.#liveFrom = liveFrom;
|
|
162
|
+
}
|
|
163
|
+
episodeOf(name) {
|
|
164
|
+
return this.#episodes.get(name);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* One entry of the coordinator's transcript. Returns the thread name whose episode the entry started, or `null`:
|
|
168
|
+
* no Merge request, a request from the history, or a name `isThread` does not know.
|
|
169
|
+
*/
|
|
170
|
+
note(entry, isThread) {
|
|
171
|
+
const request = mergeRequestOf(entry);
|
|
172
|
+
if (request === null || request.at < this.#liveFrom || !isThread(request.name))
|
|
173
|
+
return null;
|
|
174
|
+
const early = this.#earlySendBack.get(request.name);
|
|
175
|
+
this.#earlySendBack.delete(request.name);
|
|
176
|
+
let episode = this.#lastStop >= request.at
|
|
177
|
+
? { phase: 'ended', since: request.at, endedAt: this.#lastStop, how: 'stopped' }
|
|
178
|
+
: { phase: 'merging', since: request.at };
|
|
179
|
+
if (early !== undefined && early >= request.at) {
|
|
180
|
+
episode = { phase: 'ended', since: request.at, endedAt: episode.phase === 'ended' ? episode.endedAt : early,
|
|
181
|
+
how: 'sent-back' };
|
|
182
|
+
}
|
|
183
|
+
this.#episodes.set(request.name, episode);
|
|
184
|
+
return request.name;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The coordinator stopped working at `at`, the moment its turn ended (not the moment the caller noticed). Returns the
|
|
188
|
+
* names whose episode this ended. Comparing that moment with the Merge entry's `timestamp` holds because a prompt
|
|
189
|
+
* typed during a turn and delivered after it gets its `user` entry at delivery, after that turn's end, and one
|
|
190
|
+
* absorbed into the turn ends with the turn (measured queue transcripts of Claude Code 2.1.328,
|
|
191
|
+
* `server/test/fixtures/herdr/queue/measured/`).
|
|
192
|
+
*/
|
|
193
|
+
coordinatorStopped(at) {
|
|
194
|
+
this.#lastStop = Math.max(this.#lastStop, at);
|
|
195
|
+
return this.#endWhere((episode) => episode.since <= at, at, 'stopped');
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* A new process of the coordinator conversation started at `at`: entries before it are history from now on, and an
|
|
199
|
+
* episode it outlived is over, because the process that worked on it is gone.
|
|
200
|
+
*/
|
|
201
|
+
processStarted(at) {
|
|
202
|
+
this.#liveFrom = Math.max(this.#liveFrom, at);
|
|
203
|
+
return this.#endWhere((episode) => episode.since < at, at, 'stopped');
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The coordinator's message reached the thread `name` at `at`; true when it ended that thread's episode or marked
|
|
207
|
+
* its stopped episode as sent back. A message after the coordinator's stop still counts: the coordinator's and the
|
|
208
|
+
* thread's transcripts are read by two followers, so the turn end can be read before the message it sent, and a
|
|
209
|
+
* message held while the thread worked lands after that turn end. For the same reason the message can be read
|
|
210
|
+
* before the Merge entry: a message that matched no episode is kept and counts for a Merge entry not later than it.
|
|
211
|
+
* An episode that ended merged stays merged.
|
|
212
|
+
*/
|
|
213
|
+
sentBack(name, at) {
|
|
214
|
+
const episode = this.#episodes.get(name);
|
|
215
|
+
if (episode?.phase === 'ended' && episode.how === 'stopped' && episode.since <= at) {
|
|
216
|
+
this.#episodes.set(name, { ...episode, how: 'sent-back' });
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (this.#endWhere((one, other) => other === name && one.since <= at, at, 'sent-back').length > 0)
|
|
220
|
+
return true;
|
|
221
|
+
if (at >= this.#liveFrom)
|
|
222
|
+
this.#earlySendBack.set(name, Math.max(at, this.#earlySendBack.get(name) ?? at));
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
/** The thread file of `name` carries the merge, seen at `at`; true when it ended that thread's episode. */
|
|
226
|
+
merged(name, at) {
|
|
227
|
+
return this.#endWhere((_episode, one) => one === name, at, 'merged').length > 0;
|
|
228
|
+
}
|
|
229
|
+
/** The thread is gone (closed, its file removed). */
|
|
230
|
+
forget(name) {
|
|
231
|
+
this.#episodes.delete(name);
|
|
232
|
+
this.#earlySendBack.delete(name);
|
|
233
|
+
}
|
|
234
|
+
#endWhere(match, at, how) {
|
|
235
|
+
const ended = [];
|
|
236
|
+
for (const [name, episode] of this.#episodes) {
|
|
237
|
+
if (episode.phase !== 'merging' || !match(episode, name))
|
|
238
|
+
continue;
|
|
239
|
+
this.#episodes.set(name, { phase: 'ended', since: episode.since, endedAt: at, how });
|
|
240
|
+
ended.push(name);
|
|
241
|
+
}
|
|
242
|
+
return ended;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of project coordinators: which conversation a Launch with the coordinator switch started in a project, and
|
|
3
|
+
* which live session holds the coordinator role now. The role of a session comes from here only.
|
|
4
|
+
*
|
|
5
|
+
* `<dataDir>/coordinators.json` maps the main checkout of a project to the conversation id of its coordinator and
|
|
6
|
+
* survives a server restart. A session is the coordinator while it runs that very conversation in a process with the
|
|
7
|
+
* coordinator plugin and no other session holds the role. Any other conversation is ordinary: a fork, a new
|
|
8
|
+
* conversation in the coordinator's pane, and a session that invoked the coordinator skill without a Launch. The
|
|
9
|
+
* registry does not follow a pane from one conversation to the next; a pane that comes back to the stored
|
|
10
|
+
* conversation takes the role again. The holder and the reservation of a starting coordinator live in memory only.
|
|
11
|
+
*
|
|
12
|
+
* The module reads no thread file, git or herdr, decides no session state, and never throws.
|
|
13
|
+
*/
|
|
14
|
+
import { randomBytes } from 'node:crypto';
|
|
15
|
+
import { mkdir, rename, unlink, writeFile } from 'node:fs/promises';
|
|
16
|
+
import { isAbsolute, join } from 'node:path';
|
|
17
|
+
import { ENGINE_SESSION_ID_RE } from '@rarog/shared';
|
|
18
|
+
import { readRegularFileSync } from '../safe-read.js';
|
|
19
|
+
/** Registry file name in `dataDir`. */
|
|
20
|
+
export const COORDINATOR_REGISTRY_FILENAME = 'coordinators.json';
|
|
21
|
+
/** File format version. */
|
|
22
|
+
const FORMAT = 1;
|
|
23
|
+
/** Projects the file keeps at most; a new Launch beyond it drops the project with the oldest Launch. */
|
|
24
|
+
export const COORDINATOR_REGISTRY_MAX_ENTRIES = 200;
|
|
25
|
+
/**
|
|
26
|
+
* Read cap of the file. A write never goes over it (it drops the oldest entries until the text fits), so a file the
|
|
27
|
+
* registry wrote always reads back.
|
|
28
|
+
*/
|
|
29
|
+
const MAX_BYTES = 1024 * 1024;
|
|
30
|
+
/** Longest project path an entry may hold; macOS `PATH_MAX` is 1024, Linux 4096. */
|
|
31
|
+
const MAX_PATH_CHARS = 4096;
|
|
32
|
+
const PREFIX = 'coordinators:';
|
|
33
|
+
/** An absolute path without NUL: a relative one would resolve against the server's own cwd. */
|
|
34
|
+
function isProject(project) {
|
|
35
|
+
return typeof project === 'string' && project.length <= MAX_PATH_CHARS && isAbsolute(project)
|
|
36
|
+
&& !project.includes('\0');
|
|
37
|
+
}
|
|
38
|
+
/** The id later goes into `--resume`, so only the engine session id shape passes. */
|
|
39
|
+
function isConversation(conversation) {
|
|
40
|
+
return typeof conversation === 'string' && ENGINE_SESSION_ID_RE.test(conversation);
|
|
41
|
+
}
|
|
42
|
+
/** File text → entries; `null` = not the registry's file. */
|
|
43
|
+
function parseRegistry(text) {
|
|
44
|
+
let value;
|
|
45
|
+
try {
|
|
46
|
+
value = JSON.parse(text);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
52
|
+
return null;
|
|
53
|
+
const record = value;
|
|
54
|
+
const list = record['coordinators'];
|
|
55
|
+
if (record['format'] !== FORMAT || !Array.isArray(list) || list.length > COORDINATOR_REGISTRY_MAX_ENTRIES) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const entries = new Map();
|
|
59
|
+
for (const item of list) {
|
|
60
|
+
if (typeof item !== 'object' || item === null || Array.isArray(item))
|
|
61
|
+
return null;
|
|
62
|
+
const { project, conversation, since } = item;
|
|
63
|
+
if (!isProject(project) || !isConversation(conversation) || entries.has(project))
|
|
64
|
+
return null;
|
|
65
|
+
if (typeof since !== 'string' || !Number.isFinite(Date.parse(since)))
|
|
66
|
+
return null;
|
|
67
|
+
entries.set(project, { conversation, since });
|
|
68
|
+
}
|
|
69
|
+
return entries;
|
|
70
|
+
}
|
|
71
|
+
/** File system error code for a log line (no path, no content). */
|
|
72
|
+
function codeOf(err) {
|
|
73
|
+
const code = err?.code;
|
|
74
|
+
return typeof code === 'string' ? code : 'error';
|
|
75
|
+
}
|
|
76
|
+
class Registry {
|
|
77
|
+
#dataDir;
|
|
78
|
+
#file;
|
|
79
|
+
#log;
|
|
80
|
+
#now;
|
|
81
|
+
/** Project → its stored coordinator; what the file holds after the last write. */
|
|
82
|
+
#entries;
|
|
83
|
+
/** Project → the start in progress. */
|
|
84
|
+
#reserved = new Map();
|
|
85
|
+
/** Project → session id of the live coordinator. */
|
|
86
|
+
#holders = new Map();
|
|
87
|
+
/** Session id → the project whose role it holds. */
|
|
88
|
+
#heldBy = new Map();
|
|
89
|
+
/** One chain for every write, so a slow write cannot land after a newer one. */
|
|
90
|
+
#chain = Promise.resolve();
|
|
91
|
+
/** A write waits on the chain and has not started yet. */
|
|
92
|
+
#writeQueued = false;
|
|
93
|
+
constructor(opts) {
|
|
94
|
+
this.#dataDir = opts.dataDir;
|
|
95
|
+
this.#file = join(opts.dataDir, COORDINATOR_REGISTRY_FILENAME);
|
|
96
|
+
this.#log = opts.log;
|
|
97
|
+
this.#now = opts.now ?? (() => Date.now());
|
|
98
|
+
this.#entries = this.#load();
|
|
99
|
+
}
|
|
100
|
+
reserveLaunch(project, live) {
|
|
101
|
+
if (!isProject(project))
|
|
102
|
+
return { ok: false, reason: 'invalid' };
|
|
103
|
+
if (this.#reserved.has(project))
|
|
104
|
+
return { ok: false, reason: 'starting' };
|
|
105
|
+
if (this.#holders.has(project))
|
|
106
|
+
return { ok: false, reason: 'live' };
|
|
107
|
+
const stored = this.#entries.get(project)?.conversation;
|
|
108
|
+
if (stored !== undefined && live?.(stored) === true)
|
|
109
|
+
return { ok: false, reason: 'live' };
|
|
110
|
+
const reservation = Object.freeze({ project, kind: 'launch' });
|
|
111
|
+
this.#reserved.set(project, reservation);
|
|
112
|
+
return { ok: true, reservation };
|
|
113
|
+
}
|
|
114
|
+
reserveResume(project, conversation, sessionId) {
|
|
115
|
+
if (!isProject(project) || !isConversation(conversation))
|
|
116
|
+
return null;
|
|
117
|
+
if (this.#entries.get(project)?.conversation !== conversation || this.#reserved.has(project))
|
|
118
|
+
return null;
|
|
119
|
+
const holder = this.#holders.get(project);
|
|
120
|
+
if (holder !== undefined && holder !== sessionId)
|
|
121
|
+
return null;
|
|
122
|
+
const reservation = Object.freeze({
|
|
123
|
+
project, kind: 'resume', conversation, ...(sessionId === undefined ? {} : { sessionId }),
|
|
124
|
+
});
|
|
125
|
+
this.#reserved.set(project, reservation);
|
|
126
|
+
return reservation;
|
|
127
|
+
}
|
|
128
|
+
confirm(reservation, sessionId, conversation) {
|
|
129
|
+
const { project } = reservation;
|
|
130
|
+
const reserved = this.#reserved.get(project);
|
|
131
|
+
if (reserved === undefined || reserved !== reservation)
|
|
132
|
+
return false;
|
|
133
|
+
this.#reserved.delete(project);
|
|
134
|
+
if (!isConversation(conversation))
|
|
135
|
+
return false;
|
|
136
|
+
const holder = this.#holders.get(project);
|
|
137
|
+
if (holder !== undefined && holder !== sessionId)
|
|
138
|
+
return false;
|
|
139
|
+
if (reserved.kind === 'resume') {
|
|
140
|
+
if (reserved.sessionId !== undefined && reserved.sessionId !== sessionId)
|
|
141
|
+
return false;
|
|
142
|
+
if (reserved.conversation !== conversation)
|
|
143
|
+
return false;
|
|
144
|
+
if (this.#entries.get(project)?.conversation !== conversation)
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.#store(project, conversation);
|
|
149
|
+
}
|
|
150
|
+
this.#hold(project, sessionId);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
release(reservation) {
|
|
154
|
+
if (this.#reserved.get(reservation.project) === reservation)
|
|
155
|
+
this.#reserved.delete(reservation.project);
|
|
156
|
+
}
|
|
157
|
+
observe(candidate) {
|
|
158
|
+
const { sessionId, project, conversation, plugin } = candidate;
|
|
159
|
+
const held = this.#heldBy.get(sessionId);
|
|
160
|
+
if (held !== undefined && held !== project)
|
|
161
|
+
this.ended(sessionId);
|
|
162
|
+
if (!isProject(project))
|
|
163
|
+
return false;
|
|
164
|
+
const stored = this.#entries.get(project)?.conversation;
|
|
165
|
+
if (held === project) {
|
|
166
|
+
if (plugin && (conversation === undefined || conversation === stored))
|
|
167
|
+
return true;
|
|
168
|
+
this.ended(sessionId);
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
if (!plugin || conversation === undefined || conversation !== stored)
|
|
172
|
+
return false;
|
|
173
|
+
if (this.#holders.has(project) || this.#reserved.has(project))
|
|
174
|
+
return false;
|
|
175
|
+
this.#hold(project, sessionId);
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
ended(sessionId) {
|
|
179
|
+
const project = this.#heldBy.get(sessionId);
|
|
180
|
+
if (project === undefined)
|
|
181
|
+
return;
|
|
182
|
+
this.#heldBy.delete(sessionId);
|
|
183
|
+
if (this.#holders.get(project) === sessionId)
|
|
184
|
+
this.#holders.delete(project);
|
|
185
|
+
}
|
|
186
|
+
coordinatorOf(project) {
|
|
187
|
+
return this.#holders.get(project);
|
|
188
|
+
}
|
|
189
|
+
holds(sessionId) {
|
|
190
|
+
return this.#heldBy.has(sessionId);
|
|
191
|
+
}
|
|
192
|
+
idle() {
|
|
193
|
+
return this.#chain;
|
|
194
|
+
}
|
|
195
|
+
/** `sessionId` holds the role of `project`, and of no other project. */
|
|
196
|
+
#hold(project, sessionId) {
|
|
197
|
+
this.ended(sessionId);
|
|
198
|
+
this.#holders.set(project, sessionId);
|
|
199
|
+
this.#heldBy.set(sessionId, project);
|
|
200
|
+
}
|
|
201
|
+
/** Stores the Launch of `project` (it replaces the project's older coordinator) and schedules a write. */
|
|
202
|
+
#store(project, conversation) {
|
|
203
|
+
this.#entries.delete(project);
|
|
204
|
+
this.#entries.set(project, { conversation, since: new Date(this.#now()).toISOString() });
|
|
205
|
+
this.#drop(Math.max(0, this.#entries.size - COORDINATOR_REGISTRY_MAX_ENTRIES));
|
|
206
|
+
// A write not started yet takes this change too: it writes the entries as they are when it starts.
|
|
207
|
+
if (this.#writeQueued)
|
|
208
|
+
return;
|
|
209
|
+
this.#writeQueued = true;
|
|
210
|
+
this.#chain = this.#chain.then(() => {
|
|
211
|
+
this.#writeQueued = false;
|
|
212
|
+
return this.#write();
|
|
213
|
+
}).catch((err) => {
|
|
214
|
+
this.#log(`${PREFIX} ${COORDINATOR_REGISTRY_FILENAME} not written (${codeOf(err)})`);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Drops the `count` entries with the oldest Launch, the first ones of `#entries` (a Launch moves its project to the
|
|
219
|
+
* end, and the file keeps that order); a live holder of a dropped project loses the role.
|
|
220
|
+
*/
|
|
221
|
+
#drop(count) {
|
|
222
|
+
if (count <= 0)
|
|
223
|
+
return;
|
|
224
|
+
for (const project of [...this.#entries.keys()].slice(0, count)) {
|
|
225
|
+
this.#entries.delete(project);
|
|
226
|
+
const holder = this.#holders.get(project);
|
|
227
|
+
if (holder !== undefined)
|
|
228
|
+
this.ended(holder);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/** The entries as file text; the oldest entries leave while the text would be over the read cap. */
|
|
232
|
+
#body() {
|
|
233
|
+
const items = [...this.#entries].map(([project, entry]) => JSON.stringify({ project, conversation: entry.conversation, since: entry.since }));
|
|
234
|
+
const head = `{"format":${String(FORMAT)},"coordinators":[`;
|
|
235
|
+
const tail = ']}\n';
|
|
236
|
+
let size = Buffer.byteLength(head + tail, 'utf8')
|
|
237
|
+
+ items.reduce((sum, item) => sum + Buffer.byteLength(item, 'utf8'), 0) + Math.max(0, items.length - 1);
|
|
238
|
+
// The oldest Launch stands first (`#drop`).
|
|
239
|
+
let over = 0;
|
|
240
|
+
while (size > MAX_BYTES && over < items.length) {
|
|
241
|
+
size -= Buffer.byteLength(items[over] ?? '', 'utf8') + 1;
|
|
242
|
+
over += 1;
|
|
243
|
+
}
|
|
244
|
+
this.#drop(over);
|
|
245
|
+
return `${head}${items.slice(over).join(',')}${tail}`;
|
|
246
|
+
}
|
|
247
|
+
/** Atomic write of the current entries (temporary file, then `rename`); `0600` in a `0700` directory. */
|
|
248
|
+
async #write() {
|
|
249
|
+
const body = this.#body();
|
|
250
|
+
const tmp = join(this.#dataDir, `.${COORDINATOR_REGISTRY_FILENAME}.${randomBytes(6).toString('hex')}.tmp`);
|
|
251
|
+
try {
|
|
252
|
+
await mkdir(this.#dataDir, { recursive: true, mode: 0o700 });
|
|
253
|
+
await writeFile(tmp, body, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
254
|
+
await rename(tmp, this.#file);
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
await unlink(tmp).catch(() => undefined);
|
|
258
|
+
this.#log(`${PREFIX} ${COORDINATOR_REGISTRY_FILENAME} not written (${codeOf(err)})`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/** The file at start; missing = no coordinator yet, unreadable = one log line and no coordinator. */
|
|
262
|
+
#load() {
|
|
263
|
+
let text;
|
|
264
|
+
try {
|
|
265
|
+
// Regular files only: a FIFO, a device or a symlink under this name is an unreadable registry.
|
|
266
|
+
const read = readRegularFileSync(this.#file, { maxBytes: MAX_BYTES, followSymlink: false });
|
|
267
|
+
text = read === null || read.truncated ? null : read.bytes.toString('utf8');
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
if (codeOf(err) !== 'ENOENT')
|
|
271
|
+
this.#unreadable();
|
|
272
|
+
return new Map();
|
|
273
|
+
}
|
|
274
|
+
const entries = text === null ? null : parseRegistry(text);
|
|
275
|
+
if (entries === null) {
|
|
276
|
+
this.#unreadable();
|
|
277
|
+
return new Map();
|
|
278
|
+
}
|
|
279
|
+
return entries;
|
|
280
|
+
}
|
|
281
|
+
#unreadable() {
|
|
282
|
+
this.#log(`${PREFIX} ${COORDINATOR_REGISTRY_FILENAME} unreadable, starting with no coordinator; `
|
|
283
|
+
+ 'the next Launch of a coordinator replaces it');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/** Opens the registry: reads the file once, synchronously, so every answer after this comes from memory. */
|
|
287
|
+
export function openCoordinatorRegistry(opts) {
|
|
288
|
+
return new Registry(opts);
|
|
289
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const DIALOG = new Set(['waiting-permission', 'waiting-question', 'interrupted']);
|
|
2
|
+
const WORKING = new Set(['starting', 'running']);
|
|
3
|
+
/**
|
|
4
|
+
* A thread that failed, was closed or whose process is gone: no Merge can be offered on it (the Inbox gives it a
|
|
5
|
+
* failed card or none), so only a recorded merge shows.
|
|
6
|
+
*/
|
|
7
|
+
const ENDED = new Set(['error', 'limit-reached', 'done', 'resumable']);
|
|
8
|
+
/** A closed coordinator, or one whose process is gone, is no live coordinator. */
|
|
9
|
+
const NOT_LIVE = new Set(['done', 'resumable']);
|
|
10
|
+
function lastMerge(events) {
|
|
11
|
+
let last;
|
|
12
|
+
for (const event of events) {
|
|
13
|
+
if (event.kind === 'merge-delivered') {
|
|
14
|
+
last = { phase: 'running', at: event.at, checked: event.checked };
|
|
15
|
+
}
|
|
16
|
+
else if (last === undefined) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
else if (event.kind === 'peer-message') {
|
|
20
|
+
if (event.from === 'coordinator')
|
|
21
|
+
last = { phase: 'sent-back', checked: last.checked };
|
|
22
|
+
}
|
|
23
|
+
else if (last.phase === 'running') {
|
|
24
|
+
last = { phase: 'stopped', checked: last.checked };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return last;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The thread role of a session with its merge state. `name` is the exact name from the thread file; `previous` is the
|
|
31
|
+
* merge state the last summary carried, so `since` stays while the state stays; `now` stamps a state entered now.
|
|
32
|
+
*/
|
|
33
|
+
export function threadCoordination(name, facts, now, previous) {
|
|
34
|
+
const coordinator = facts.coordinator !== undefined && !NOT_LIVE.has(facts.coordinator.state)
|
|
35
|
+
? facts.coordinator
|
|
36
|
+
: undefined;
|
|
37
|
+
const result = { role: 'thread', name };
|
|
38
|
+
if (coordinator !== undefined)
|
|
39
|
+
result.coordinatorId = coordinator.id;
|
|
40
|
+
const merge = mergeOf(facts, coordinator !== undefined);
|
|
41
|
+
if (merge === undefined)
|
|
42
|
+
return result;
|
|
43
|
+
const since = previous?.state === merge.state ? previous.since : (merge.since ?? now);
|
|
44
|
+
result.merge = { state: merge.state, commits: facts.git.commits, files: facts.git.files, since };
|
|
45
|
+
if (merge.notMerged)
|
|
46
|
+
result.merge.outcome = 'not-merged';
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The merge state that wins over the session state, first match wins:
|
|
51
|
+
* 1. a dialog or an interrupt in the thread session: none, the session state speaks;
|
|
52
|
+
* 2. the thread session failed, was closed or its process is gone: `merged` when the thread file records the merge,
|
|
53
|
+
* otherwise none;
|
|
54
|
+
* 3. the coordinator works on a Merge of this thread: `merging`;
|
|
55
|
+
* 4. the thread session works or has a background task running: none;
|
|
56
|
+
* 5. the thread file records the merge: `merged` (needs no coordinator, so it survives the coordinator's end, the
|
|
57
|
+
* worktree's removal and a server restart);
|
|
58
|
+
* 6. the thread session waits for input, checks passed on the branch head, the worktree is clean and a coordinator
|
|
59
|
+
* is live: `ready`;
|
|
60
|
+
* 7. otherwise none.
|
|
61
|
+
*
|
|
62
|
+
* `merging` lasts from the delivery of the Merge prompt to the first of: the merge recorded in the thread file, a peer
|
|
63
|
+
* message from the coordinator to the thread (a send-back), the coordinator stopping (end of turn, Stop, interrupt,
|
|
64
|
+
* close). A coordinator standing on a dialog has not stopped. After a stop the thread is `ready` again with
|
|
65
|
+
* `outcome: 'not-merged'` while its checked commit is still the one the Merge was for. A send-back after the Merge,
|
|
66
|
+
* before or after the stop, keeps the thread from `ready` on that commit, because the coordinator sent the work back
|
|
67
|
+
* instead of merging it; a new checked commit or a new Merge lifts it.
|
|
68
|
+
*/
|
|
69
|
+
function mergeOf(facts, coordinatorLive) {
|
|
70
|
+
const { file, session, git } = facts;
|
|
71
|
+
if (DIALOG.has(session.state))
|
|
72
|
+
return undefined;
|
|
73
|
+
const recorded = file.merged !== undefined;
|
|
74
|
+
if (ENDED.has(session.state))
|
|
75
|
+
return recorded ? { state: 'merged' } : undefined;
|
|
76
|
+
const last = lastMerge(facts.events);
|
|
77
|
+
if (last?.phase === 'running' && coordinatorLive && !recorded)
|
|
78
|
+
return { state: 'merging', since: last.at };
|
|
79
|
+
if (WORKING.has(session.state) || session.backgroundWork)
|
|
80
|
+
return undefined;
|
|
81
|
+
if (recorded)
|
|
82
|
+
return { state: 'merged' };
|
|
83
|
+
const checked = file.checked;
|
|
84
|
+
if (session.state !== 'waiting-input' || !coordinatorLive || checked === undefined)
|
|
85
|
+
return undefined;
|
|
86
|
+
if (git.head !== checked || git.clean !== true)
|
|
87
|
+
return undefined;
|
|
88
|
+
const sameCommit = last !== undefined && last.checked === checked;
|
|
89
|
+
if (sameCommit && last.phase === 'sent-back')
|
|
90
|
+
return undefined;
|
|
91
|
+
if (sameCommit && last.phase === 'stopped')
|
|
92
|
+
return { state: 'ready', notMerged: true };
|
|
93
|
+
return { state: 'ready' };
|
|
94
|
+
}
|