tryharness 0.7.75 → 0.7.76

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/lib/manager.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { askLocalAgent } from "./localAgentAsk.mjs";
3
2
  import { nameOf } from "./members.mjs";
4
3
 
5
- // The swarm's manager (owner, November 1): it keeps the agents to what the person actually asked. Each of the person's
6
- // messages is sorted by Jev (src/server/swarm/manager.ts): new work and questions become asks, a steer changes the ask
7
- // it is about, exploring an idea, chatting or answering tracks nothing. When an agent reports, every open ask is
4
+ // The swarm's manager (owner, November 1): it keeps the agents to what the person actually asked. The dispatcher slot
5
+ // judges (dispatcher.mjs; owner: the dispatcher "checks results against the owner's words (sent back, done, waiting on
6
+ // the owner)"), with whatever model the person put in it. Each of the person's messages is sorted: new work and
7
+ // questions become asks, a steer changes the ask it is about, exploring an idea, chatting or answering tracks nothing. When an agent reports, every open ask is
8
8
  // judged against the person's own words: done needs something in the thread that shows it; a taste call waits for the
9
9
  // person's review; work ignored or contradicted goes back to that agent once with the person's words whole, then waits
10
10
  // on the person. The thread cannot close while an ask is open. The thread hears one short line when an ask changes.
@@ -23,24 +23,19 @@ const label = (ask) => {
23
23
  return `"${said.length > 60 ? `${said.slice(0, 57)}...` : said}" (#${first.seq})`;
24
24
  };
25
25
 
26
- const LOCAL_PROMPT = {
27
- message: `You keep a person's swarm of agents to what the person asked. The JSON below has the person's newest message (person_message), the posts before it, and the person's open asks. Answer with one JSON object only: {"new_work": 0 to 1, how sure you are it asks the agents for new work or a result not already in open_asks, "question": 0 to 1, that it asks the agents a question wanting an answer, "exploring": 0 to 1, that the person is exploring an idea or talking through the agents' reasoning without asking for it to be done, "answer": 0 to 1, that it answers a question or approves a choice put to the person, "steers": the index in open_asks that it changes, corrects or narrows, or null, "withdraws": 0 to 1, that it drops that ask}.`,
28
- report: `You keep a person's swarm of agents to what the person asked. The JSON below has an agent's report, the posts before it, and the person's open asks, each with the person's own words (newest word wins). Answer with one JSON object only: {"asks": [{"index": the ask's index, "state": "done" | "in_progress" | "ignored" | "contradicted" (ignored: reported finished without doing it or only part; contradicted: did something different, or claims something the thread does not show), "shown": 0 to 1, that something other than an agent saying so shows it done (a file, commit, command run with output, link, the result itself), "taste": 0 to 1, that only the person's own judgment can settle it}]}. For an ask of kind question, "done" means it was answered.`,
29
- };
30
-
31
26
  export function createManager({
32
27
  store,
33
- askHarness,
34
- // Whether this computer's rounds go to Harness's server, and whether that server judges for the manager.
35
- usesServer,
36
- // The coding agent here that judges on the privacy setting, or null.
37
- localJudge = () => null,
28
+ // The dispatcher slot (dispatcher.mjs): it judges each message and report.
29
+ dispatcher,
30
+ // The thread's goal (goals.mjs): a report that shows a check reached marks it, beside the ask it settles.
31
+ goals = null,
38
32
  // Wake an agent with work, as the coordinator does (its brief is posted in the thread first).
39
33
  handOn,
40
34
  post,
41
35
  notifyBoard,
36
+ // The last open ask was settled: the thread's next round can close it (it may have been blocked by the ask).
37
+ settled = () => {},
42
38
  log = () => {},
43
- ask = askLocalAgent,
44
39
  }) {
45
40
  const key = (threadId) => `owner-asks:${threadId}`;
46
41
  const asksOf = (threadId) => {
@@ -76,6 +71,14 @@ export function createManager({
76
71
  .slice(-BEFORE)
77
72
  .map(({ seq, author, kind, text }) => ({ seq, author, kind, text }));
78
73
 
74
+ // The goal's checks still open, which a report may show reached.
75
+ const openCriteria = (thread) =>
76
+ (goals?.record(thread.id)?.criteria ?? []).filter(
77
+ (criterion) => criterion.status === "open"
78
+ );
79
+ // What the dispatcher reads: the post, the posts before it, and the person's open asks. A report is judged against
80
+ // each open ask and each open check of the goal (kind "check") on its own: the base LFM3-Omni mixed items up in a
81
+ // list and judged only the first (dispatcher-slot, November 1).
79
82
  const inputFor = (thread, kind, entry, asks) => ({
80
83
  thread: { id: thread.id, title: thread.objective },
81
84
  kind,
@@ -85,47 +88,75 @@ export function createManager({
85
88
  kind: entry.kind,
86
89
  text: entry.text,
87
90
  },
88
- asks: asks.map(({ id, kind: what, words }) => ({ id, kind: what, words })),
91
+ asks: [
92
+ ...asks.map(({ id, kind: what, words }) => ({ id, kind: what, words })),
93
+ ...(kind === "report"
94
+ ? openCriteria(thread).map(({ id, text }) => ({
95
+ id,
96
+ kind: "check",
97
+ words: [{ text }],
98
+ }))
99
+ : []),
100
+ ],
89
101
  transcript: before(thread.id, entry.seq),
90
102
  });
91
103
 
92
- // Jev on Harness's server; on the privacy setting, a coding agent here with its tools off.
93
104
  const judge = async (input) => {
94
- if (usesServer()) {
95
- const reply = await askHarness("manage", input, null);
96
- if (!reply?.ok)
97
- throw new Error(reply?.error || "the manager did not judge");
98
- return reply.result ?? reply;
105
+ if (input.kind === "message") {
106
+ const said = await dispatcher.judge("message", input);
107
+ // The dispatcher names the message's kind; a model that answers in sureness (0 to 1, as Jev did) is read too.
108
+ const sure = (kind, field) =>
109
+ said?.kind === kind ? 1 : Number(said?.[field]) || 0;
110
+ return {
111
+ kind: "message",
112
+ message: {
113
+ newWork: sure("work", "new_work"),
114
+ question: sure("question", "question"),
115
+ exploring: sure("idea", "exploring"),
116
+ answer: sure("answer", "answer"),
117
+ steers: input.asks[said?.steers]?.id ?? null,
118
+ withdraws:
119
+ said?.withdraws === true ? 1 : Number(said?.withdraws) || 0,
120
+ },
121
+ };
99
122
  }
100
- const agent = localJudge();
101
- if (!agent) return null;
102
- const said = await ask(
103
- agent,
104
- `${LOCAL_PROMPT[input.kind]}\n\n${JSON.stringify(input)}`
105
- );
106
- return input.kind === "message"
107
- ? {
108
- kind: "message",
109
- message: {
110
- newWork: Number(said?.new_work) || 0,
111
- question: Number(said?.question) || 0,
112
- exploring: Number(said?.exploring) || 0,
113
- answer: Number(said?.answer) || 0,
114
- steers: input.asks[said?.steers]?.id ?? null,
115
- withdraws: Number(said?.withdraws) || 0,
116
- },
117
- }
118
- : {
119
- kind: "report",
120
- findings: (Array.isArray(said?.asks) ? said.asks : [])
121
- .filter((one) => input.asks[one?.index])
122
- .map((one) => ({
123
- id: input.asks[one.index].id,
124
- state: one.state,
125
- shown: Number(one.shown) || 0,
126
- taste: Number(one.taste) || 0,
127
- })),
128
- };
123
+ const truth = (value) => (value === true ? 1 : Number(value) || 0);
124
+ const judged = [];
125
+ for (const item of input.asks) {
126
+ const one = await dispatcher
127
+ .judge("report", {
128
+ thread: input.thread,
129
+ post: input.post,
130
+ transcript: input.transcript,
131
+ item: { kind: item.kind, words: item.words },
132
+ })
133
+ .catch((error) => {
134
+ log(
135
+ `manager: the dispatcher could not judge an item (${error.message})`
136
+ );
137
+ return null;
138
+ });
139
+ if (one?.state)
140
+ judged.push({
141
+ item,
142
+ state: one.state,
143
+ shown: truth(one.shown),
144
+ taste: truth(one.taste),
145
+ });
146
+ }
147
+ return {
148
+ kind: "report",
149
+ findings: judged
150
+ .filter(({ item }) => item.kind !== "check")
151
+ .map(({ item, ...found }) => ({ id: item.id, ...found })),
152
+ // The goal's checks shown reached, by id.
153
+ reached: judged
154
+ .filter(
155
+ ({ item, state, shown }) =>
156
+ item.kind === "check" && state === "done" && shown >= FLOOR
157
+ )
158
+ .map(({ item }) => item.id),
159
+ };
129
160
  };
130
161
 
131
162
  const say = (thread, lines) => {
@@ -182,9 +213,22 @@ export function createManager({
182
213
  const reported = (thread, entry) =>
183
214
  queue(thread.id, async () => {
184
215
  const asks = openOf(thread.id).slice(-MAX_ASKS);
185
- if (!asks.length) return;
216
+ const criteria = openCriteria(thread);
217
+ if (!asks.length && !criteria.length) return;
186
218
  const judged = await judge(inputFor(thread, "report", entry, asks));
187
219
  const findings = judged?.findings ?? [];
220
+ // The goal's checks this report shows reached, recorded with the post that shows them, so the goal and the asks
221
+ // say the same (the A1 thread showed "Done" beside a goal with every check open).
222
+ const reached = (judged?.reached ?? []).map((id) => ({
223
+ id,
224
+ evidence: [entry.seq],
225
+ }));
226
+ if (reached.length)
227
+ goals.progress(
228
+ thread.id,
229
+ { met: reached },
230
+ { by: thread.goal.facilitator }
231
+ );
188
232
  const all = asksOf(thread.id);
189
233
  const lines = [];
190
234
  for (const found of findings) {
@@ -223,6 +267,7 @@ export function createManager({
223
267
  }
224
268
  keep(thread.id, all);
225
269
  say(thread, lines);
270
+ if (findings.length && !openOf(thread.id).length) settled(thread.id);
226
271
  });
227
272
 
228
273
  // The person's words go back whole, every one of them for this ask, oldest first.
package/lib/members.json CHANGED
@@ -14,7 +14,7 @@
14
14
  { "agent": "hermes", "command": "hermes", "install": { "script": "https://hermes-agent.nousresearch.com/install.sh", "args": ["--skip-setup"] }, "signIn": "assistant", "harness": true }
15
15
  ],
16
16
  "members": [
17
- { "id": "harness", "name": "Harness", "aliases": [], "road": "server", "home": "cloud", "runs": "server", "target": true, "wake": "run",
17
+ { "id": "harness", "name": "Harness", "aliases": [], "road": "server", "home": "cloud", "runs": "server", "target": true, "wake": "run", "window": true,
18
18
  "about": "answers and researches with its own tools, makes the images and videos a thread needs (attached there for every agent), and works in the person's browser while their Harness window is open",
19
19
  "where": "on Harness's server", "limits": "Does not change files or run commands on this computer, so it does not edit, assemble or test anything here." },
20
20
  { "id": "claude-code", "name": "Claude Code", "aliases": ["claude code"], "road": "local", "home": "machine", "runs": "machine", "target": true, "wake": "run",
@@ -79,5 +79,9 @@
79
79
  { "id": "chatgpt", "name": "ChatGPT", "aliases": ["chat gpt"], "road": "hosted", "home": "cloud", "runs": "self", "target": false, "wake": "none",
80
80
  "about": "the ChatGPT app; can ask, cannot be woken",
81
81
  "where": "in OpenAI's cloud" }
82
+ ],
83
+ "signers": [
84
+ { "id": "jev", "name": "Jev" },
85
+ { "id": "dispatcher", "name": "Dispatcher" }
82
86
  ]
83
87
  }
package/lib/members.mjs CHANGED
@@ -63,6 +63,17 @@ export const speaksThroughHarness = (id) => {
63
63
  };
64
64
 
65
65
  export const member = (id) => byId.get(String(id)) ?? null;
66
+ /**
67
+ * The person's own agents whose words can reach this computer from the person's own computers or device rather than
68
+ * through Harness's server: every agent here, and one that speaks in the person's own Harness window (`window`, its
69
+ * words sealed from their device). The caller knows whether these words came through the server.
70
+ */
71
+ export const speaksFromPersonsSide = (id) => {
72
+ const entry = byId.get(String(id));
73
+ return (
74
+ Boolean(entry?.target) && (entry.road === "local" || entry.window === true)
75
+ );
76
+ };
66
77
  export const ids = (keep = () => true) =>
67
78
  MEMBERS.filter(keep).map((entry) => entry.id);
68
79
  /** Members others may hand work to, Harness included. */
@@ -80,7 +91,16 @@ export const CLOUD_HOMED = ids(
80
91
  export const ASKED_BY_TASK = ids(
81
92
  (entry) => entry.target && entry.runs !== "machine" && entry.id !== "harness"
82
93
  );
83
- export const nameOf = (id) => member(id)?.name ?? String(id);
94
+ // Who signs a thread's posts besides its agents (owner, November 1: each post is signed by what produced it): Jev's
95
+ // decisions and the dispatcher's words. Neither is an agent anyone tags. The server and the apps read the same list
96
+ // (members.json `signers`, src/shared/members.ts).
97
+ export const JEV = "jev";
98
+ export const DISPATCHER = "dispatcher";
99
+ export const SIGNERS = Object.fromEntries(
100
+ ROSTER.signers.map((signer) => [signer.id, signer.name])
101
+ );
102
+ export const nameOf = (id) =>
103
+ member(id)?.name ?? SIGNERS[String(id)] ?? String(id);
84
104
  export const aboutOf = (id) => {
85
105
  const entry = member(id);
86
106
  return entry ? `${entry.name}: ${entry.about}` : String(id);
package/lib/moves.mjs CHANGED
@@ -280,12 +280,25 @@ export function createMoves({
280
280
  say(`Still open: ${open.join("; ")}`);
281
281
  break;
282
282
  }
283
+ // Closed on the person's word only when they spoke after the work: in the A1 run the thread said "Closed on your
284
+ // word (your message #1)" of the question itself. Otherwise it closes on the work, naming its last result.
285
+ const lastResult = posts(thread.id).findLast(
286
+ (each) =>
287
+ SAID.has(each.kind) &&
288
+ each.author !== "user" &&
289
+ each.author !== thread.goal.facilitator &&
290
+ !store.meta(`coordinator-post:${each.id}`)
291
+ );
292
+ const onTheirWord =
293
+ message && (!lastResult || message.seq > lastResult.seq);
283
294
  finishGoal(
284
295
  thread.id,
285
296
  coordinator,
286
- message
297
+ onTheirWord
287
298
  ? `Closed on your word (your message #${message.seq}).`
288
- : "Closed: what was asked is done."
299
+ : lastResult
300
+ ? `Closed: what was asked is done (shown in #${lastResult.seq}).`
301
+ : "Closed: what was asked is done."
289
302
  );
290
303
  break;
291
304
  }
package/lib/plans.mjs CHANGED
@@ -11,6 +11,7 @@
11
11
  import fs from "node:fs";
12
12
  import path from "node:path";
13
13
  import { randomUUID } from "node:crypto";
14
+ import { DISPATCHER } from "./members.mjs";
14
15
  import { oneLine } from "./oneLine.mjs";
15
16
 
16
17
  const MAX_NODES = 50;
@@ -236,7 +237,7 @@ export function createPlans({
236
237
  moved = changed = true;
237
238
  store.roomPost({
238
239
  goalId: threadId,
239
- author: "harness",
240
+ author: DISPATCHER,
240
241
  kind: "note",
241
242
  text: `${node.agent}'s next step ("${oneLine(node.objective, 80)}") will not start: ${node.reason}.`,
242
243
  });
package/lib/projects.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
- import { nameOf } from "./members.mjs";
4
+ import { DISPATCHER, nameOf } from "./members.mjs";
5
5
  import { secretReason } from "./secrets.mjs";
6
6
  import { createRoomChannels, agreementHash } from "./roomChannels.mjs";
7
7
  import { createPieces, RECORD_KINDS } from "./projectPieces.mjs";
@@ -615,8 +615,10 @@ export function createProjects({
615
615
  brief: "",
616
616
  originAgent: "user",
617
617
  provenance: { trust: "user", chain: [] },
618
- team: ["harness"],
619
- facilitator: "harness",
618
+ // The dispatcher facilitates (owner, November 1: "facilitator is dispatcher"); agents join as they are named or
619
+ // handed work, Harness like any other. Rooms made before keep their team; the store relabels their facilitator.
620
+ team: [],
621
+ facilitator: DISPATCHER,
620
622
  workspace,
621
623
  maxPosts,
622
624
  maxWakes,
@@ -626,19 +628,24 @@ export function createProjects({
626
628
  };
627
629
  const note = (p, text) => {
628
630
  if (!p.roomId) return;
629
- store.roomPost({ goalId: p.roomId, author: "harness", kind: "note", text });
631
+ store.roomPost({
632
+ goalId: p.roomId,
633
+ author: DISPATCHER,
634
+ kind: "note",
635
+ text,
636
+ });
630
637
  notifyBoard(store.getTask(p.roomId));
631
638
  };
632
639
 
633
640
  let nextClash = null;
634
- // Harness's own posts about the project (a clash, a heads up) go across whatever agents may say.
641
+ // The dispatcher's own posts about the project (a clash, a heads up) go across whatever agents may say.
635
642
  let saying = false;
636
643
  /** A post made in a project's room on this computer: it goes to the other side, unless it must wait for the person. */
637
644
  const posted = (goalId, post) => {
638
645
  if (!post || String(post.author).includes("/")) return;
639
646
  const p = projectOfRoom(goalId);
640
647
  if (!p || !SHARED_KINDS.has(post.kind)) return;
641
- if (nextClash && post.author === "harness")
648
+ if (nextClash && post.author === DISPATCHER)
642
649
  store.meta(`project-clash-post:${post.id}`, JSON.stringify(nextClash));
643
650
  if (all("select 1 from project_posts where post_id = ?", post.id).length)
644
651
  return;
@@ -1380,7 +1387,7 @@ export function createProjects({
1380
1387
  );
1381
1388
  })();
1382
1389
  };
1383
- // Harness's post in the room, shared with the other side; `clash` names the work a clash post is about.
1390
+ // The dispatcher's post in the room, shared with the other side; `clash` names the work a clash post is about.
1384
1391
  const say = (p, text, mentions, clash = null) => {
1385
1392
  if (!p.roomId) return null;
1386
1393
  // The room's listener shares the post as it is made (posted), so the clash it names is set first.
@@ -1388,7 +1395,7 @@ export function createProjects({
1388
1395
  saying = true;
1389
1396
  const post = store.roomPost({
1390
1397
  goalId: p.roomId,
1391
- author: "harness",
1398
+ author: DISPATCHER,
1392
1399
  kind: "post",
1393
1400
  text,
1394
1401
  mentions,
@@ -1414,7 +1421,7 @@ export function createProjects({
1414
1421
  work.id
1415
1422
  );
1416
1423
  if (!waiting || !p.roomId) return;
1417
- const asker = String(waiting.asker || "harness");
1424
+ const asker = String(waiting.asker || DISPATCHER);
1418
1425
  const fromPartner = isPeer(p, asker);
1419
1426
  wakeRun(
1420
1427
  p.roomId,
@@ -5,6 +5,7 @@ import { spawnSync } from "node:child_process";
5
5
  import { PS } from "./nudge.mjs";
6
6
  import { paths } from "./paths.mjs";
7
7
  import {
8
+ DISPATCHER,
8
9
  MACHINE_RUNNERS,
9
10
  PROPOSERS,
10
11
  nameOf,
@@ -376,7 +377,7 @@ export function createRunAuthority({ store, installedAgents }) {
376
377
  if (why && store.withdrawProposed(task.id) && task.parent_id)
377
378
  store.roomPost({
378
379
  goalId: task.parent_id,
379
- author: "harness",
380
+ author: DISPATCHER,
380
381
  kind: "note",
381
382
  text: `${nameOf(task.target_agent)} waits for your Start: ${why}`,
382
383
  });
package/lib/runBrief.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { provenanceLine } from "./provenance.mjs";
2
- import { nameOf } from "./members.mjs";
2
+ import { DISPATCHER, nameOf } from "./members.mjs";
3
3
  import { claudeMemNotes } from "./claudemem.mjs";
4
4
  import { toldBlock } from "./cards.mjs";
5
5
  import { fitSections } from "./fit.mjs";
@@ -101,7 +101,7 @@ export function createRunBriefs({
101
101
  store.addContribution({
102
102
  taskId: task.id,
103
103
  kind: "context",
104
- author: "harness",
104
+ author: DISPATCHER,
105
105
  text: pack.text,
106
106
  source: "context-engine",
107
107
  });
package/lib/runWorker.mjs CHANGED
@@ -3,7 +3,7 @@ import { stopAgentTask } from "./runner.mjs";
3
3
  import { notifyDesktop } from "./notify.mjs";
4
4
  import { receipt, receiptLine } from "./receipts.mjs";
5
5
  import { readTrail } from "./trails.mjs";
6
- import { nameOf } from "./members.mjs";
6
+ import { DISPATCHER, nameOf } from "./members.mjs";
7
7
  import { sessionFile } from "./live.mjs";
8
8
  import { oneLine } from "./oneLine.mjs";
9
9
 
@@ -129,7 +129,7 @@ export function createRunWorker({
129
129
  store.meta(`wait-note:${task.id}`, "1");
130
130
  store.roomPost({
131
131
  goalId: task.parent_id,
132
- author: "harness",
132
+ author: DISPATCHER,
133
133
  kind: "note",
134
134
  text: why,
135
135
  });
@@ -290,7 +290,7 @@ export function createRunWorker({
290
290
  store.addContribution({
291
291
  taskId: task.id,
292
292
  kind: "note",
293
- author: "harness",
293
+ author: DISPATCHER,
294
294
  text: `Stopped because ${reason}. It starts again where it left off once the Mac can run it.`,
295
295
  source: "lid-closed",
296
296
  });
@@ -329,7 +329,7 @@ export function createRunWorker({
329
329
  if (line)
330
330
  store.roomPost({
331
331
  goalId: task.parent_id,
332
- author: "harness",
332
+ author: DISPATCHER,
333
333
  kind: "note",
334
334
  text: line,
335
335
  });
@@ -399,7 +399,7 @@ export function createRunWorker({
399
399
  store.addContribution({
400
400
  taskId,
401
401
  kind: "receipt",
402
- author: "harness",
402
+ author: DISPATCHER,
403
403
  text: line,
404
404
  source: "receipts",
405
405
  });
@@ -415,7 +415,7 @@ export function createRunWorker({
415
415
  if (forThread && post) {
416
416
  store.roomPost({
417
417
  goalId: task.parent_id,
418
- author: "harness",
418
+ author: DISPATCHER,
419
419
  kind: "note",
420
420
  text: line,
421
421
  });
package/lib/snippets.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
- import { nameOf } from "./members.mjs";
4
+ import { DISPATCHER, nameOf } from "./members.mjs";
5
5
  import { repositoryOf } from "./worktrees.mjs";
6
6
 
7
7
  // Code or a file for an agent that does not run on this computer (Grok Bot, Muse) leaves it only with the person's OK.
@@ -91,7 +91,7 @@ export function createSnippets({
91
91
  save(snippet);
92
92
  store.roomPost({
93
93
  goalId: threadId,
94
- author: "harness",
94
+ author: DISPATCHER,
95
95
  kind: "note",
96
96
  text: `${nameOf(agent)} asks to see lines ${from} to ${to} of ${file.path} ("${words.slice(0, 120)}"). They stay on this computer until you share them.`,
97
97
  });
@@ -170,7 +170,7 @@ export function createSnippets({
170
170
  save(snippet);
171
171
  store.roomPost({
172
172
  goalId: threadId,
173
- author: "harness",
173
+ author: DISPATCHER,
174
174
  kind: "note",
175
175
  text: `${nameOf(agent)} asks to see ${label} from your files ("${words.slice(0, 120)}"). It stays on this computer until you share it.`,
176
176
  });
@@ -222,7 +222,7 @@ export function createSnippets({
222
222
  if (share) {
223
223
  const post = store.roomPost({
224
224
  goalId: snippet.thread,
225
- author: "harness",
225
+ author: DISPATCHER,
226
226
  kind: "post",
227
227
  mentions: [snippet.agent],
228
228
  text: sharedText(snippet),
@@ -231,7 +231,7 @@ export function createSnippets({
231
231
  } else
232
232
  store.roomPost({
233
233
  goalId: snippet.thread,
234
- author: "harness",
234
+ author: DISPATCHER,
235
235
  kind: "note",
236
236
  text: `The person kept ${snippet.label ?? `lines ${snippet.from} to ${snippet.to} of ${snippet.path}`} on this computer.`,
237
237
  });
package/lib/store.mjs CHANGED
@@ -4,7 +4,7 @@ import sqliteWasm from "node-sqlite3-wasm";
4
4
  import { parseSession } from "./parsers.mjs";
5
5
  import { provenanceFor } from "./provenance.mjs";
6
6
  import { BOOK_TABLES } from "./book.mjs";
7
- import { PROPOSERS } from "./members.mjs";
7
+ import { DISPATCHER, PROPOSERS } from "./members.mjs";
8
8
 
9
9
  const SCHEMA_VERSION = 11;
10
10
  const INDEX_FORMAT_VERSION = 2;
@@ -412,6 +412,12 @@ export function openStore(file) {
412
412
  specialty text not null,
413
413
  set_at text not null
414
414
  );
415
+ -- The person's choices for the whole swarm, kept with the board so they follow home (the dispatcher slot).
416
+ create table if not exists board_settings (
417
+ key text primary key,
418
+ value text not null,
419
+ set_at text not null
420
+ );
415
421
  create table if not exists board_pins (
416
422
  specialty text primary key,
417
423
  agent text not null,
@@ -449,6 +455,40 @@ export function openStore(file) {
449
455
  db.exec(
450
456
  "update swarm_rounds set coordinator = 'jev' where coordinator = 'harness'"
451
457
  );
458
+ // Threads facilitated as "harness" are the dispatcher's (owner, November 1: "facilitator is dispatcher", "@harness is
459
+ // just another agent"): the facilitator, and what it posted in their rooms (the coordinator's marked posts and the
460
+ // kinds only a facilitator writes). Harness the agent's own posts and results keep its name.
461
+ db.exec(`
462
+ update board_contributions set author = 'dispatcher'
463
+ where author = 'harness' and source = 'room'
464
+ and task_id in (select goal_id from board_goals where facilitator = 'harness')
465
+ and (
466
+ kind in ('note', 'goal_update', 'answer', 'open_item', 'question', 'check_in')
467
+ or exists (
468
+ select 1 from board_meta where key = 'coordinator-post:' || board_contributions.id
469
+ )
470
+ )
471
+ `);
472
+ db.exec(
473
+ "update board_goals set facilitator = 'dispatcher' where facilitator = 'harness'"
474
+ );
475
+ // Harness was added to every thread's team as its facilitator; it stays on a thread only where it posted or ran.
476
+ for (const { goal_id: goalId, team } of db.all(
477
+ `select goal_id, team from board_goals where team like '%"harness"%'
478
+ and not exists (select 1 from board_contributions c where c.task_id = goal_id and c.author = 'harness')
479
+ and not exists (select 1 from board_tasks t where t.parent_id = goal_id and t.target_agent = 'harness')`
480
+ )) {
481
+ let members = [];
482
+ try {
483
+ members = JSON.parse(team);
484
+ } catch {
485
+ continue;
486
+ }
487
+ db.run("update board_goals set team = ? where goal_id = ?", [
488
+ JSON.stringify(members.filter((agent) => agent !== "harness")),
489
+ goalId,
490
+ ]);
491
+ }
452
492
  // Boards written before the lock existed: give every task a holder and a version.
453
493
  const boardColumns = new Set(
454
494
  db.all("pragma table_info(board_tasks)").map((column) => column.name)
@@ -1144,7 +1184,7 @@ export function openStore(file) {
1144
1184
  this.addContribution({
1145
1185
  taskId: parentId,
1146
1186
  kind: "result",
1147
- author: "harness",
1187
+ author: DISPATCHER,
1148
1188
  text: result,
1149
1189
  source: `group:${status}`,
1150
1190
  });
@@ -1471,6 +1511,30 @@ export function openStore(file) {
1471
1511
  new Date().toISOString()
1472
1512
  );
1473
1513
  },
1514
+ /** A choice of the person's for the whole swarm, as it was set, or null. */
1515
+ boardSetting(key) {
1516
+ const row = execute(
1517
+ "get",
1518
+ "select value from board_settings where key = ?",
1519
+ key
1520
+ );
1521
+ if (!row) return null;
1522
+ try {
1523
+ return JSON.parse(row.value);
1524
+ } catch {
1525
+ return null;
1526
+ }
1527
+ },
1528
+ setBoardSetting(key, value) {
1529
+ execute(
1530
+ "run",
1531
+ `insert into board_settings(key, value, set_at) values(?, ?, ?)
1532
+ on conflict(key) do update set value = excluded.value, set_at = excluded.set_at`,
1533
+ key,
1534
+ JSON.stringify(value),
1535
+ new Date().toISOString()
1536
+ );
1537
+ },
1474
1538
  pins() {
1475
1539
  return execute(
1476
1540
  "all",
@@ -2695,14 +2759,14 @@ export function openStore(file) {
2695
2759
  this.addContribution({
2696
2760
  taskId: id,
2697
2761
  kind: "receipt",
2698
- author: "harness",
2762
+ author: DISPATCHER,
2699
2763
  text,
2700
2764
  source: "route",
2701
2765
  });
2702
2766
  const receipt = this.addContribution({
2703
2767
  taskId: goalId,
2704
2768
  kind: "receipt",
2705
- author: "harness",
2769
+ author: DISPATCHER,
2706
2770
  text,
2707
2771
  source: "room",
2708
2772
  });