strom-research 1.35.0 → 1.36.0-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.
Files changed (59) hide show
  1. package/CHANGELOG.cs.md +45 -0
  2. package/CHANGELOG.de.md +53 -0
  3. package/CHANGELOG.md +48 -0
  4. package/CHANGELOG.pl.md +47 -0
  5. package/assets/lang/cs.json +47 -5
  6. package/assets/lang/de.json +47 -5
  7. package/assets/lang/pl.json +46 -4
  8. package/assets/plugins/gates/claude-usage/gate.ts +94 -16
  9. package/dist/cli/help.js +2 -2
  10. package/dist/cli/menu-links.js +58 -11
  11. package/dist/cli/menu-settings.js +19 -0
  12. package/dist/cli/menu-waiting.js +50 -1
  13. package/dist/cli/ui.js +41 -5
  14. package/dist/commands/analysis.js +20 -1
  15. package/dist/commands/guide.js +4 -1
  16. package/dist/commands/index.js +1 -0
  17. package/dist/commands/intake.js +32 -9
  18. package/dist/commands/links.js +10 -6
  19. package/dist/commands/media.js +166 -32
  20. package/dist/commands/setup.js +6 -0
  21. package/dist/commands/sourceretract.js +139 -0
  22. package/dist/commands/sources.js +42 -13
  23. package/dist/commands/sync.js +5 -3
  24. package/dist/commands/tasks.js +37 -9
  25. package/dist/commands/verify.js +7 -4
  26. package/dist/core/actions.js +11 -9
  27. package/dist/core/busy.js +9 -0
  28. package/dist/core/changelog.js +17 -0
  29. package/dist/core/config.js +7 -0
  30. package/dist/core/evidence.js +16 -0
  31. package/dist/core/import.js +9 -3
  32. package/dist/core/inboxwait.js +133 -15
  33. package/dist/core/inboxwatch.js +5 -4
  34. package/dist/core/links.js +13 -2
  35. package/dist/core/live.js +368 -33
  36. package/dist/core/material.js +12 -5
  37. package/dist/core/materialdelete.js +97 -23
  38. package/dist/core/media.js +4 -0
  39. package/dist/core/origin.js +16 -6
  40. package/dist/core/phrases.js +6 -0
  41. package/dist/core/queue.js +12 -4
  42. package/dist/core/report.js +1 -1
  43. package/dist/core/samescan.js +359 -0
  44. package/dist/core/sort.js +1 -1
  45. package/dist/core/sourcefields.js +16 -0
  46. package/dist/core/sourceretract.js +531 -0
  47. package/dist/core/sync.js +152 -7
  48. package/dist/core/taskaudit.js +104 -6
  49. package/dist/core/taskkind.js +58 -0
  50. package/dist/core/tree.js +1 -1
  51. package/dist/core/verify.js +12 -6
  52. package/dist/core/verifyfacts.js +7 -0
  53. package/dist/core/waiting.js +22 -3
  54. package/dist/core/waitkept.js +2 -0
  55. package/dist/gedcom/export.js +32 -9
  56. package/dist/gedcom/validate.js +8 -3
  57. package/dist/image/index.js +6 -3
  58. package/dist/image/jpeg-decode.js +80 -21
  59. package/package.json +4 -1
@@ -50,6 +50,13 @@ export function live(tree, id) {
50
50
  function isMaterial(i) {
51
51
  return !i.retracted && !!i.sha && (!!i.file || (!!originOf(i) && !!i.working)) && !i.sync && i.kind !== "tree" && !portraitOnly(i);
52
52
  }
53
+ /**
54
+ * A family tree's file the research keeps (spec 117 K2.1): an input of a family tree (GEDCOM, the app's JSON) with its
55
+ * bytes, not one a sync sent, not retracted — listed (GET /material?trees=1) and deleted as the material is.
56
+ */
57
+ export function isTreeFile(i) {
58
+ return !i.retracted && !!i.sha && !!i.file && i.kind === "tree" && !i.sync;
59
+ }
53
60
  function portraitOnly(i) {
54
61
  const links = i.links ?? [];
55
62
  // the research's own file a portrait was made of (the same bytes) stays material of the research (spec 102 M4)
@@ -235,7 +242,7 @@ export function material(tree, shared, only = {}) {
235
242
  const ids = only.ids ? new Set(only.ids) : undefined;
236
243
  const files = [];
237
244
  let idx;
238
- const all = tree.list("input").filter(isMaterial);
245
+ const all = tree.list("input").filter((i) => isMaterial(i) || (!!only.trees && isTreeFile(i)));
239
246
  // the oldest file of each content: the others are the same as it
240
247
  const firstOf = new Map();
241
248
  for (const i of [...all].sort((a, b) => a.created.localeCompare(b.created) || a.id.localeCompare(b.id)))
@@ -253,7 +260,7 @@ export function material(tree, shared, only = {}) {
253
260
  const file = materialFile(tree, shared, i);
254
261
  const s = i.sorted;
255
262
  // what the user said in the app comes before what sorting found
256
- const kind = i.materialKind ?? (s ? KIND_OF_SORT[s.as] : undefined);
263
+ const kind = isTreeFile(i) ? "tree" : (i.materialKind ?? (s ? KIND_OF_SORT[s.as] : undefined));
257
264
  const hidden = hiddenOf(i);
258
265
  const links = (i.links ?? []).filter((l) => !l.retracted).map((l) => ({ type: l.type, ref: l.type === "person" || (l.type === "event" && l.ref.startsWith("P")) ? live(tree, l.ref) : l.ref, ...(l.event ? { event: l.event } : {}) }));
259
266
  const used = usesFrom((idx ??= usesIndex(tree)), i);
@@ -336,8 +343,8 @@ export function peopleOf(tree, ids) {
336
343
  function refused(code, message, params = {}) {
337
344
  return new UsageError(message, { code, params, hint: code === "material.body" ? "strom help input assign" : "strom input list — the files of the material; strom person list — its people" });
338
345
  }
339
- /** The files asked for, as they are now: each a file of the material — or the first that is not, refused. */
340
- export function filesAsked(tree, ids) {
346
+ /** The files asked for, as they are now: each a file of the material (`trees`: a family tree's file too) — or the first that is not, refused. */
347
+ export function filesAsked(tree, ids, how = {}) {
341
348
  if (!ids.length)
342
349
  throw refused("material.body", "give the files (I…)");
343
350
  if (ids.length > MATERIAL_MOST_FILES)
@@ -352,7 +359,7 @@ export function filesAsked(tree, ids) {
352
359
  continue;
353
360
  seen.add(id);
354
361
  const i = tree.get(id);
355
- if (!i || i.type !== "input" || !isMaterial(i))
362
+ if (!i || i.type !== "input" || !(isMaterial(i) || (how.trees && isTreeFile(i))))
356
363
  throw refused("material.file", `the research has no file ${id} of the material${i?.retracted ? " (taken back)" : ""}`, { id });
357
364
  out.push(i);
358
365
  }
@@ -8,10 +8,16 @@
8
8
  // the store of originals (otherResearch). Only then do the source images of the same content and their excerpts go too
9
9
  // (a source loses the image, never its text). What a task held lets the file go as when it is hidden. The history
10
10
  // (git) keeps the record; the bytes stay only in a backup or a pack made before.
11
+ //
12
+ // A family tree's file too (spec 117 K2.1–K2.3): deleted as the material is — unless a source made of it stands
13
+ // (blockedBy, 409 material.source-live): then only with that source deleted in the same step (retractSources,
14
+ // core/sourceretract.ts), one confirmation over both. Everything is checked first, the sources deleted, the files taken
15
+ // back, written — and only then do the bytes go (R7: the caller removes them after its commit).
11
16
  import fs from "node:fs";
12
17
  import path from "node:path";
13
18
  import { UsageError } from "./errors.js";
14
- import { filesAsked, letGo, live, materialFile, materialPersons, MATERIAL_MOST_EDIT } from "./material.js";
19
+ import { filesAsked, isTreeFile, letGo, live, materialFile, materialPersons, MATERIAL_MOST_EDIT } from "./material.js";
20
+ import { deletedSource, retractImpacts, retractSources } from "./sourceretract.js";
15
21
  import { mediaRecords } from "./mediaindex.js";
16
22
  import { update } from "./records.js";
17
23
  import { sha256, signRecord, verifyRecord } from "./seal.js";
@@ -29,7 +35,7 @@ const ACTIVE = ["open", "doing", "parked", "waiting"];
29
35
  function deleteAsked(tree, ids) {
30
36
  if (ids.length > DELETE_MOST_FILES)
31
37
  throw new UsageError(`at most ${DELETE_MOST_FILES} files at once`, { code: "material.body", params: { most: String(DELETE_MOST_FILES) }, hint: "strom help input delete" });
32
- return filesAsked(tree, ids);
38
+ return filesAsked(tree, ids, { trees: true });
33
39
  }
34
40
  /** The contents of a file: its own, and its working copy's (the picture the app shows of it). */
35
41
  const shasOf = (i) => [...new Set([i.sha, i.working?.sha].filter((s) => !!s))];
@@ -142,6 +148,8 @@ function impactOf(tree, idx, i, asked, others) {
142
148
  .map((t) => t.id)
143
149
  .sort();
144
150
  const keptWhy = sameAs.length ? "sameAs" : others(shas) ? "otherResearch" : undefined;
151
+ // a family tree's file a source standing was made of (source.input, input.source): never deleted without it (K2.2)
152
+ const blockedBy = isTreeFile(i) ? idx.sources.filter((s) => s.input === i.id || i.source === s.id).map((s) => s.id).sort() : [];
145
153
  return {
146
154
  id: i.id,
147
155
  name: i.name,
@@ -154,6 +162,7 @@ function impactOf(tree, idx, i, asked, others) {
154
162
  bytes: keptWhy ? "kept" : "deleted",
155
163
  ...(keptWhy ? { keptWhy } : {}),
156
164
  ...(sameAs.length ? { sameAs } : {}),
165
+ ...(blockedBy.length ? { blockedBy } : {}),
157
166
  };
158
167
  }
159
168
  /**
@@ -168,12 +177,51 @@ export function deleteImpacts(tree, _shared, ids) {
168
177
  return files.map((i) => impactOf(tree, idx, i, asked, others));
169
178
  }
170
179
  /**
171
- * The files deleted for good, as deleteImpacts says (checked whole first: nothing is written when one is refused).
172
- * The caller holds the tree lock and commits; a dry run of the tree deletes nothing on the disk.
180
+ * The sources standing that a family tree's file was made of and that are not deleted with it: refused, 409
181
+ * material.source-live {sources} (spec 117 K2.2) — the person deletes the source with the file (retractSources).
182
+ */
183
+ export function refuseLiveSources(impacts, retracting = []) {
184
+ const with_ = new Set(retracting);
185
+ const live = [...new Set(impacts.flatMap((i) => i.blockedBy ?? []))].filter((s) => !with_.has(s)).sort();
186
+ if (live.length)
187
+ throw new UsageError(`a source of the research was made of the file and stands (${live.join(", ")}): the file goes only with it — nothing deleted`, {
188
+ code: "material.source-live",
189
+ params: { sources: live.join(",") },
190
+ hint: `the person deletes the source with it: strom input delete <I…> --retract-sources ${live.join(",")}`,
191
+ });
192
+ }
193
+ /**
194
+ * The sources asked to be deleted with the files: only those made of them (blockedBy) — any other is deleted on its
195
+ * own (strom source retract), never by deleting a file: refused before anything, material.body.
196
+ */
197
+ export function checkRetractWith(impacts, retracting) {
198
+ const of = new Set(impacts.flatMap((i) => i.blockedBy ?? []));
199
+ const other = retracting.filter((s) => !of.has(s));
200
+ if (other.length)
201
+ throw new UsageError(`not a source made of the files given (${other.join(", ")}): only those are deleted with them — nothing deleted`, {
202
+ code: "material.body",
203
+ params: { sources: other.join(",") },
204
+ hint: "strom input delete <I…> --dry-run — impacts[].blockedBy; another source: strom source retract (the person's)",
205
+ });
206
+ }
207
+ /** What deleting the sources with the files would take (strom input delete --retract-sources --dry-run): nothing written. */
208
+ export function deleteSourceImpacts(tree, sources) {
209
+ return sources.length ? retractImpacts(tree, sources) : [];
210
+ }
211
+ /**
212
+ * The files deleted for good, as deleteImpacts says (checked whole first: nothing is written when one is refused) —
213
+ * with the sources given (`retractSources`) deleted first (spec 117 K2.2): a family tree's file with a source standing
214
+ * that is not among them refused (material.source-live). The caller holds the tree lock, commits, and only then
215
+ * removes the bytes (`removeBytes`, R7); a dry run of the tree deletes nothing on the disk.
173
216
  */
174
- export function deleteMaterial(tree, shared, ids, by) {
217
+ export function deleteMaterial(tree, shared, ids, by, how = {}) {
175
218
  const files = deleteAsked(tree, ids);
176
219
  const impacts = deleteImpacts(tree, shared, ids);
220
+ const asked = how.retractSources ?? [];
221
+ checkRetractWith(impacts, asked);
222
+ refuseLiveSources(impacts, asked);
223
+ // the sources first, checked whole by core/sourceretract.ts (unknown, deleted already: refused before anything)
224
+ const retracted = asked.length ? retractSources(tree, asked, how.via ? { via: how.via } : {}) : undefined;
177
225
  const at = new Date().toISOString();
178
226
  const why = by === "app" || by === "user" ? "deleted for good by the user" : `deleted for good (${by})`;
179
227
  const gone = [];
@@ -187,9 +235,10 @@ export function deleteMaterial(tree, shared, ids, by) {
187
235
  retracted: { at, reason: "deleted" },
188
236
  ...(x.links?.length ? { links: x.links.map((l) => (l.retracted ? l : { ...l, retracted: { at, reason: "removed" } })) } : {}),
189
237
  }), { op: "input.delete", summary: `${i.id} deleted for good ("${i.name.slice(0, 50)}")${impact.bytes === "kept" ? `, its content kept (${impact.keptWhy})` : ""}`, reason: why });
190
- // a source made of it keeps its text and citations: only its link to the file goes
238
+ // a source made of it keeps its text and citations: only its link to the file goes — a source the person deleted
239
+ // too (R8: restored, it is without the file)
191
240
  for (const s of tree.list("source")) {
192
- if (s.retracted || s.input !== i.id)
241
+ if (s.input !== i.id || (s.retracted && !deletedSource(s)))
193
242
  continue;
194
243
  update(tree, s.id, "source", (x) => {
195
244
  const next = { ...x };
@@ -230,12 +279,28 @@ export function deleteMaterial(tree, shared, ids, by) {
230
279
  update(tree, id, "media", (x) => ({ ...x, retracted: { at, reason: "deleted" } }), { op: "media.retract", summary: `${id} retracted: its file deleted for good`, reason: why });
231
280
  }
232
281
  const tasks = letGo(tree, files.map((i) => i.id), "deleted");
282
+ const goFiles = files.filter((i) => gone.includes(i.id));
283
+ const goImages = [...images].map((id) => tree.get(id)).filter(Boolean);
284
+ // the research's own files go with the commit (its history keeps them: a write that fails puts them back)
233
285
  if (!tree.dryRun)
234
- removeBytes(tree, shared, files.filter((i) => gone.includes(i.id)), [...images].map((id) => tree.get(id)).filter(Boolean));
235
- return { files: files.map((i) => i.id), deleted: files.map((i) => i.id), impacts, tasks, unlinked, images: lostImages };
286
+ removeBytes(tree, shared, goFiles, goImages, "own");
287
+ return {
288
+ files: files.map((i) => i.id),
289
+ deleted: files.map((i) => i.id),
290
+ impacts,
291
+ tasks,
292
+ unlinked,
293
+ images: lostImages,
294
+ ...(retracted ? { retracted: retracted.retracted, sourceImpacts: retracted.impacts } : {}),
295
+ removeBytes: () => {
296
+ if (!tree.dryRun)
297
+ removeBytes(tree, shared, goFiles, goImages, "rest");
298
+ },
299
+ };
236
300
  }
237
301
  /** The files on the disk: the original (shared store or inputs/), its working copy, the images of it, their previews. */
238
- function removeBytes(tree, shared, files, images) {
302
+ /** The bytes removed: the research's own (inputs/, kept by its history: removed before the commit, committed with it) or the rest (the shared store, previews: after it, R7). */
303
+ function removeBytes(tree, shared, files, images, which) {
239
304
  const paths = new Set();
240
305
  const shas = new Set();
241
306
  // never a path that leaves its folder (a record says where its file is)
@@ -245,14 +310,17 @@ function removeBytes(tree, shared, files, images) {
245
310
  };
246
311
  for (const i of files) {
247
312
  const own = i.file ? materialFile(tree, shared, i) : undefined;
248
- if (own)
249
- within(i.file.startsWith("inputs/") ? path.join(tree.root, "inputs") : shared, own);
313
+ const inTree = i.file?.startsWith("inputs/") ?? false;
314
+ if (own && inTree === (which === "own"))
315
+ within(inTree ? path.join(tree.root, "inputs") : shared, own);
316
+ if (which === "own")
317
+ continue;
250
318
  if (shared && i.working)
251
319
  within(shared, path.join(shared, workingRel(shared, i.working)));
252
320
  for (const s of shasOf(i))
253
321
  shas.add(s);
254
322
  }
255
- if (shared)
323
+ if (shared && which === "rest")
256
324
  for (const m of images)
257
325
  within(shared, path.join(shared, m.file));
258
326
  for (const sha of shas)
@@ -260,6 +328,9 @@ function removeBytes(tree, shared, files, images) {
260
328
  paths.add(thumbPath(tree.root, sha, px));
261
329
  for (const p of paths) {
262
330
  try {
331
+ // the research's own: what a command that fails afterwards puts back (its rollback), as any file it wrote
332
+ if (which === "own")
333
+ tree.remember(p);
263
334
  fs.rmSync(p, { force: true });
264
335
  }
265
336
  catch {
@@ -268,22 +339,25 @@ function removeBytes(tree, shared, files, images) {
268
339
  }
269
340
  }
270
341
  const CONFIRM_KIND = "material.delete";
271
- /** The mark of a list of impacts (what the person saw): its hash. */
272
- const markOf = (impacts) => sha256(JSON.stringify(canonicalize(impacts))).slice(0, 32);
342
+ /** The mark of a list of impacts (what the person saw): its hash — with the sources' impacts when they go with the files. */
343
+ const markOf = (impacts, sources) => sha256(JSON.stringify(canonicalize(sources?.sources.length ? { impacts, sourceImpacts: sources.impacts } : impacts))).slice(0, 32);
344
+ /** What the signature is over: the files, the mark, when — and the sources deleted with them. */
345
+ const signed = (files, mark, at, sources) => ({ files, impacts: mark, at, ...(sources?.sources.length ? { sources: sources.sources } : {}) });
273
346
  /**
274
347
  * The bridge's confirmation of a dry run (POST /material/delete {dryRun: true}): signed with the research's seal key
275
- * over the files, the impacts the person was shown and when — "<ms>.<mark>.<signature>". Only a strom of this computer
276
- * makes one; an agent of the research has no key.
348
+ * over the files, the impacts the person was shown and when — "<ms>.<mark>.<signature>"; with the sources deleted with
349
+ * them (retractSources), over those and their impacts too. Only a strom of this computer makes one; an agent of the
350
+ * research has no key.
277
351
  */
278
- export function deleteConfirm(key, files, impacts, at = Date.now()) {
279
- const mark = markOf(impacts);
280
- return `${at}.${mark}.${signRecord(key, CONFIRM_KIND, { files, impacts: mark, at })}`;
352
+ export function deleteConfirm(key, files, impacts, at = Date.now(), sources) {
353
+ const mark = markOf(impacts, sources);
354
+ return `${at}.${mark}.${signRecord(key, CONFIRM_KIND, signed(files, mark, at, sources))}`;
281
355
  }
282
356
  /**
283
357
  * A confirmation checked against the impacts now: `ok`; `changed` — signed, but the research changed since the person
284
358
  * saw it (material.delete-changed); `invalid` — none, not signed here, or older than 15 minutes (material.body).
285
359
  */
286
- export function checkDeleteConfirm(key, files, impacts, token, now = Date.now()) {
360
+ export function checkDeleteConfirm(key, files, impacts, token, now = Date.now(), sources) {
287
361
  if (!key || typeof token !== "string" || token.length > 200)
288
362
  return "invalid";
289
363
  const m = /^(\d{1,15})\.([0-9a-f]{32})\.([0-9a-f]{64})$/u.exec(token);
@@ -292,7 +366,7 @@ export function checkDeleteConfirm(key, files, impacts, token, now = Date.now())
292
366
  const at = Number(m[1]);
293
367
  if (!(at <= now + 60_000 && now - at <= DELETE_CONFIRM_MS))
294
368
  return "invalid";
295
- if (!verifyRecord(key, CONFIRM_KIND, { files, impacts: m[2], at }, m[3]))
369
+ if (!verifyRecord(key, CONFIRM_KIND, signed(files, m[2], at, sources), m[3]))
296
370
  return "invalid";
297
- return m[2] === markOf(impacts) ? "ok" : "changed";
371
+ return m[2] === markOf(impacts, sources) ? "ok" : "changed";
298
372
  }
@@ -216,11 +216,15 @@ export function imageNumbers(files) {
216
216
  return files.map(numberInName);
217
217
  }
218
218
  /** The shared inbox by folder ("" = files lying in the inbox itself): one download, one record set. */
219
+ /** A file of the inbox strom set aside, not taken (commands/media.ts takeFiles): a question, never a download. */
220
+ export const SET_ASIDE = /\.(?:same-as|other-than)-M\p{N}+$/u;
219
221
  export function inboxFolders(inbox) {
220
222
  if (!fs.existsSync(inbox))
221
223
  return [];
222
224
  const by = new Map();
223
225
  for (const f of collectFiles([inbox])) {
226
+ if (SET_ASIDE.test(f.normalize("NFC")))
227
+ continue;
224
228
  const rel = path.relative(inbox, f).split(path.sep);
225
229
  const folder = rel.length > 1 ? rel[0] : "";
226
230
  by.set(folder, [...(by.get(folder) ?? []), f]);
@@ -20,7 +20,7 @@
20
20
  // `place`, `value`, `given`, `surname`, or the GEDCOM's DATE, PLAC, VAL, GIVN, SURN, SEX).
21
21
  import { UsageError } from "./errors.js";
22
22
  import { refuseRemoved } from "./citeorder.js";
23
- import { isWeak, defaultStatus, checkStatus } from "./evidence.js";
23
+ import { isWeak, defaultStatus, checkStatus, citableSource } from "./evidence.js";
24
24
  import { editEvent, editPerson, findEventOwner, markPrimaryName, retractEvent } from "./actions.js";
25
25
  import { create, update } from "./records.js";
26
26
  import { gedcomName, primaryName } from "./people.js";
@@ -31,6 +31,7 @@ import { ui } from "../cli/ui.js";
31
31
  import { eventName } from "../cli/human.js";
32
32
  import { factValue, factWords, ownerWords, plainName, sexWords, staleProposal } from "./proposals.js";
33
33
  import { whileDeciding } from "./proposalsettle.js";
34
+ import { deletedSource } from "./sourceretract.js";
34
35
  export const FACT_PARTS = ["date", "place", "value"];
35
36
  export const NAME_PARTS = ["given", "surname"];
36
37
  /**
@@ -60,8 +61,7 @@ function recordsCited(tree, citations) {
60
61
  }
61
62
  /** A citation's source is one of the research's (the change rests on it). */
62
63
  export function checkCited(tree, c) {
63
- if (tree.get(c.source)?.type !== "source")
64
- throw new UsageError(`no source ${c.source}`, { hint: 'strom source add "<title>" …', code: "record.none", params: { kind: "source", id: c.source } });
64
+ citableSource(tree, c.source);
65
65
  }
66
66
  /**
67
67
  * The verdict on an agent's change of parts of a value: a user's part — a proposal; an import's — a proposal where the
@@ -492,7 +492,8 @@ export function revertImported(tree, target) {
492
492
  back.was = { ...was, parts: left };
493
493
  else
494
494
  delete back.was;
495
- const cites = (was.cites ?? (was.source ? [{ source: was.source }] : [])).filter((c) => tree.get(c.source)?.type === "source");
495
+ // a source the person deleted comes back with nothing (spec 117 R6): only strom source restore puts it back
496
+ const cites = (was.cites ?? (was.source ? [{ source: was.source }] : [])).filter((c) => tree.get(c.source)?.type === "source" && !tree.get(c.source)?.retracted);
496
497
  if (cites.length)
497
498
  back.citations = citationsWith(n.citations ?? [], cites);
498
499
  back.origin = { by: "user" };
@@ -535,7 +536,7 @@ export function revertImported(tree, target) {
535
536
  delete back.was;
536
537
  // the import's citation again
537
538
  const cites = was.cites ?? (was.source ? [{ source: was.source }] : []);
538
- back.citations = citationsWith(e.citations, cites.filter((c) => tree.get(c.source)?.type === "source"));
539
+ back.citations = citationsWith(e.citations, cites.filter((c) => tree.get(c.source)?.type === "source" && !tree.get(c.source)?.retracted));
539
540
  back.origin = { by: "user" };
540
541
  update(tree, owner.id, owner.type, (o) => ({ ...o, events: o.events.map((x) => (x.id === e.id ? back : x)) }), {
541
542
  op: "event.revert",
@@ -575,9 +576,15 @@ function sameImport(a, b) {
575
576
  export function knownImportSource(tree, imp) {
576
577
  return tree.list("source").find((s) => !!s.imported && !s.retracted && sameImport(s.imported, imp));
577
578
  }
579
+ /** The source of an import the person deleted (spec 117 J6), where the research has no other of it: never made again. */
580
+ export function deletedImportSource(tree, imp) {
581
+ const same = tree.list("source").filter((s) => s.imported && sameImport(s.imported, imp));
582
+ return same.some((s) => !s.retracted) ? undefined : same.find((s) => deletedSource(s));
583
+ }
578
584
  /**
579
585
  * The source of an import the Strom app names (HEAD `1 _STROM_IMPORT Ix`): the one made of it before, reused on every
580
- * later sync — or a new one (a family tree: authored, secondary), of the material it came in (`input`).
586
+ * later sync — or a new one (a family tree: authored, secondary), of the material it came in (`input`). One the person
587
+ * deleted is never made again (spec 117 J6): it is given back `deleted` — its values keep their origin, cite it never.
581
588
  */
582
589
  export function importSourceFor(tree, imp, input) {
583
590
  return tree.withTreeLock(() => {
@@ -585,6 +592,9 @@ export function importSourceFor(tree, imp, input) {
585
592
  const found = same.find((s) => !s.retracted);
586
593
  if (found)
587
594
  return { source: found, created: false };
595
+ const gone = same.find((s) => deletedSource(s));
596
+ if (gone)
597
+ return { source: gone, created: false, deleted: true };
588
598
  // the one a sync's undo withdrew (nothing cited it any more): the same again, never one more
589
599
  const back = same.find((s) => /^sync I\d+ undone$/u.test(s.retracted?.reason ?? ""));
590
600
  if (back) {
@@ -111,6 +111,7 @@ export const PHRASES = {
111
111
  "waiting.held": "kept for later: the research waits for its agent, which is not on this computer; back in the queue when the agent is here",
112
112
  "archive.removed": "removed in the Strom app",
113
113
  "archive.wait": "Decision on downloading from the archive {title}",
114
+ "audit.wait.images": "Images {images} of {book}",
114
115
  "history.why.archive": "Nothing is looked for while the research is kept as an archive.",
115
116
  "history.why.held": "Another research on this computer is looking for the events of {region}.",
116
117
  "history.why.nobody": "Nobody of the tree lived there in those years.",
@@ -293,6 +294,7 @@ export const PHRASES = {
293
294
  "browser.wait.held": "images {images} of {book}, saved by the agent's browser from {url} — the browser held image {n} back: {host} to be allowed to download several files in the browser profile the agent works in, once (the icon at the right end of the browser's address bar)",
294
295
  "wait.group.app": "The Strom app",
295
296
  "wait.group.tune": "The reading of scans",
297
+ "wait.group.aside": "Images saved by hand",
296
298
  "wait.group.conflicts": "Conflicts to decide",
297
299
  "wait.group.places": "Places to identify",
298
300
  "wait.group.branches": "Branches off the lines",
@@ -338,6 +340,10 @@ export const PHRASES = {
338
340
  "log.person.restore": "Back again: {who}",
339
341
  "log.family.retract": "Family withdrawn: {who}",
340
342
  "log.source.retract": "Record withdrawn: {name}",
343
+ "log.source.deleted": "Source withdrawn: {name} [{id}] – {cites, plural, one {# citation} other {# citations}}, {stories, plural, one {# story} other {# stories}}",
344
+ "log.source.restored": "Source restored: {name} [{id}] – {cites, plural, one {# citation} other {# citations}} back",
345
+ "log.conflict.keep": "Decision stands without the withdrawn source: {name}",
346
+ "source.retracted.task": "source withdrawn ({id})",
341
347
  "log.place.retract": "Place withdrawn: {name}",
342
348
  "log.repository.retract": "Archive withdrawn: {name}",
343
349
  "log.name.remove": "Name taken off: {name} – {who}",
@@ -32,8 +32,9 @@
32
32
  // is kept for the turn: it is counted from the sessions.
33
33
  // The tasks of verification against the originals (core/verify.ts, core/verifyfacts.ts): the sweep's (verify:auto) and
34
34
  // the person's bulk one (verify:bulk, a family tree's leads' search too) come after the lines' work, whatever the
35
- // strategy, but after VERIFY_EVERY − 1
36
- // sessions since the last one on them one comes forward, the nearest ancestor first; never in a loop (each fact once,
35
+ // strategy (a bulk one's try first, as the person's "verify": queueAt next — two tries in the order they were made),
36
+ // but after VERIFY_EVERY − 1 sessions since the last one on them one comes forward, the nearest ancestor first; never
37
+ // in a loop (each fact once,
37
38
  // its task done when every fact of it has its result). The person's "verify" of a person, a family or a fact
38
39
  // (verify:asked, verify:search) comes first (queueAt next), like strom task order next. One whose originals have no
39
40
  // image here waits for the download as any work that reads records.
@@ -52,7 +53,7 @@ import { forHistory, HISTORY_PLACES_ORIGIN, historyHeld, historyOrder, historyTu
52
53
  import { Settings } from "./config.js";
53
54
  import { personQueued, placesFirst } from "./placeid.js";
54
55
  import { branchModeOf, placer, readOffline } from "./offline.js";
55
- import { readsOriginals, VERIFY_EVERY, verifiesInTurn, verifyLacksImages } from "./verifyfacts.js";
56
+ import { isBulkTry, readsOriginals, VERIFY_EVERY, verifiesInTurn, verifyLacksImages } from "./verifyfacts.js";
56
57
  import { booksOfTask } from "./books.js";
57
58
  export const LEVEL_ORDER = { intake: 0, locate: 1, link: 2, verify: 3, enrich: 4, request: 5, narrate: 6 };
58
59
  /** Levels that read records: without images of their record sets they can only ask the user for them. */
@@ -345,6 +346,11 @@ export function rankTasks(tree, tasks, strategy = "balanced", opts = {}) {
345
346
  .map((t) => ({ t, gen: place(t)?.gen ?? OFF_LINE_GENERATION }))
346
347
  .sort((a, b) => a.gen - b.gen || a.t.created.localeCompare(b.t.created) || a.t.id.localeCompare(b.t.id, undefined, { numeric: true }))[0]?.t.id
347
348
  : undefined;
349
+ // the tries of a bulk verification (verify bulk --try): one block among the person's "next" choices, at the time of
350
+ // the latest try — within it the tries in the order they were made, the older one's tasks first (each "next" else
351
+ // the latest chosen first)
352
+ const bulkTry = (t) => !forHistory(t) && isBulkTry(t) && own(t) === "next";
353
+ const triesAt = open.filter(bulkTry).reduce((m, t) => (t.queueAt.at > m ? t.queueAt.at : m), "");
348
354
  const rows = open.map((t) => {
349
355
  const hist = forHistory(t);
350
356
  const p = hist ? {} : placing(t);
@@ -440,13 +446,15 @@ export function rankTasks(tree, tasks, strategy = "balanced", opts = {}) {
440
446
  ...(ahead || verifyNow ? { turn: true } : {}),
441
447
  ...(inBook ? { sameBook: sameBook.book } : {}),
442
448
  };
443
- return { task: t, why, storyTurn, extra, own: mine === "next" ? -1 : mine === "last" ? 1 : 0, nextAt: mine === "next" ? t.queueAt.at : "", offLine: offRank, doing: t.state === "doing" ? 0 : 1, hist: !hist ? 0 : t.id === turnTask ? -1 : 1, horder: hist ? order(t) : 0, first: first || placesAsked ? 0 : 1, blocked: blocked ? 1 : 0, inBook: inBook ? 0 : 1, story: storyTurn ? 0 : forStory(t) ? 2 : 1, score, gen, lineRank: lineAt ?? working.length };
449
+ return { task: t, why, storyTurn, extra, own: mine === "next" ? -1 : mine === "last" ? 1 : 0, nextAt: mine === "next" ? (bulkTry(t) ? triesAt : t.queueAt.at) : "", tryAt: mine === "next" && bulkTry(t) ? t.queueAt.at : "", offLine: offRank, doing: t.state === "doing" ? 0 : 1, hist: !hist ? 0 : t.id === turnTask ? -1 : 1, horder: hist ? order(t) : 0, first: first || placesAsked ? 0 : 1, blocked: blocked ? 1 : 0, inBook: inBook ? 0 : 1, story: storyTurn ? 0 : forStory(t) ? 2 : 1, score, gen, lineRank: lineAt ?? working.length };
444
450
  });
445
451
  const cmp = (a, b) => a.doing - b.doing ||
446
452
  // the person's own turn: next before everything but the work at hand (the last chosen first: the latest "do it
447
453
  // next" goes next), last after everything
448
454
  a.own - b.own ||
449
455
  b.nextAt.localeCompare(a.nextAt) ||
456
+ // two tries of a bulk verification: the older one's tasks first
457
+ a.tryAt.localeCompare(b.tryAt) ||
450
458
  // the tasks of history after everything — but at history's turn its first one before all — the needed one first
451
459
  a.hist - b.hist ||
452
460
  a.horder - b.horder ||
@@ -622,7 +622,7 @@ export function launchedFrom(env, tty) {
622
622
  }
623
623
  /** The settings that say nothing of a person (a whitelist: anything else of the settings never goes). */
624
624
  const CONFIG_PLAIN = [
625
- "lang", "mode", "stromVersion", "lastVersion", "lastChannel", "npmChannel", "stories", "runGate", "archivePace", "readApp", "briefBudget", "runMinutes",
625
+ "lang", "mode", "stromVersion", "lastVersion", "lastChannel", "npmChannel", "stories", "runGate", "runConfirm", "archivePace", "readApp", "briefBudget", "runMinutes",
626
626
  "webPerHost", "readParallel", "queueStrategy", "queueOffLine", "queueOffLineShare", "queueSuggestLines", "queueSuggestTasks", "queueSuggestPersons", "queueSameBook", "booksMinTasks",
627
627
  "connectorsConsent", "browserDownloads", "experimentsHistory", "experimentsHistoryPace", "experimentsHistoryPlaces", "experimentsPlaceHistory",
628
628
  "historyKinds", "historyAsked", "stromApp", "links", "shortcut", "appBrowser", "terminal", "updates", "excerptsQuality", "excerptsFor", "excerptsMb",