visualproof 0.4.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +16 -7
  2. package/dist/assets/tips/phone-fingers.light.mp4 +0 -0
  3. package/dist/assets/tips/phone-fingers.light.webp +0 -0
  4. package/dist/assets/tips/tour-agent.webp +0 -0
  5. package/dist/assets/tips/tour-arrange.webp +0 -0
  6. package/dist/assets/tips/tour-artwork.webp +0 -0
  7. package/dist/assets/tips/tour-checks.webp +0 -0
  8. package/dist/assets/tips/tour-keys.webp +0 -0
  9. package/dist/assets/tips/tour-library.webp +0 -0
  10. package/dist/assets/tips/tour-project.webp +0 -0
  11. package/dist/assets/tips/tour-review.webp +0 -0
  12. package/dist/assets/tips/tour-share.webp +0 -0
  13. package/dist/assets/tips/tour-source.webp +0 -0
  14. package/dist/assets/tips/tour-target.webp +0 -0
  15. package/dist/assets/tips/tour-view.webp +0 -0
  16. package/dist/assets/tips/tour.json +132 -117
  17. package/dist/assets/tips/tour.webp +0 -0
  18. package/dist/mcp/visualproof-mcp.mjs +20 -9
  19. package/dist/server/access.js +31 -1
  20. package/dist/server/accesspage.js +130 -0
  21. package/dist/server/agent.js +143 -50
  22. package/dist/server/askfollow.js +1 -1
  23. package/dist/server/buildwatch.js +133 -0
  24. package/dist/server/deploy.js +995 -0
  25. package/dist/server/doctor.js +15 -3
  26. package/dist/server/film.js +1 -1
  27. package/dist/server/historyapi.js +100 -50
  28. package/dist/server/historythread.js +206 -0
  29. package/dist/server/hover.js +8 -0
  30. package/dist/server/invites.js +113 -20
  31. package/dist/server/live.js +308 -60
  32. package/dist/server/main.js +450 -77
  33. package/dist/server/mcptools.js +33 -20
  34. package/dist/server/presence.js +3 -3
  35. package/dist/server/prompt.js +8 -3
  36. package/dist/server/readonlygate.js +4 -4
  37. package/dist/server/review.js +27 -7
  38. package/dist/server/reviewapi.js +51 -17
  39. package/dist/server/status.js +119 -46
  40. package/dist/server/talk.js +231 -115
  41. package/dist/server/tokens.js +10 -2
  42. package/dist/server/usage.js +51 -0
  43. package/dist/shared/board.js +2 -1
  44. package/dist/shared/build.js +35 -1
  45. package/dist/shared/collab.js +8 -0
  46. package/dist/shared/deploy.js +35 -0
  47. package/dist/shared/keys.js +66 -37
  48. package/dist/shared/layout.js +297 -70
  49. package/dist/shared/libm.js +366 -0
  50. package/dist/shared/lostfound.js +1 -0
  51. package/dist/shared/mentions.js +83 -0
  52. package/dist/shared/palette.js +1 -1
  53. package/dist/shared/query.js +13 -4
  54. package/dist/shared/review.js +91 -21
  55. package/dist/shared/reviewqueue.js +6 -1
  56. package/dist/shared/separate.js +556 -32
  57. package/dist/web/bundle/app.js +5022 -2736
  58. package/dist/web/bundle/edges.js +2 -1
  59. package/dist/web/bundle/layout.js +1026 -80
  60. package/dist/web/index.html +45 -9
  61. package/dist/web/src/canvas.js +47 -34
  62. package/dist/web/src/overview.js +4 -1
  63. package/dist/web/src/reviewqueue.js +52 -19
  64. package/dist/web/src/scene.js +13 -12
  65. package/dist/web/src/status.js +28 -0
  66. package/dist/web/src/theme.js +108 -0
  67. package/dist/web/src/trust.js +271 -0
  68. package/dist/web/style.css +283 -105
  69. package/docs/agent-api/README.md +13 -11
  70. package/docs/agent-api/advice.md +8 -2
  71. package/docs/agent-api/export.md +1 -1
  72. package/docs/agent-api/following.md +11 -12
  73. package/docs/agent-api/history.md +6 -2
  74. package/docs/agent-api/mcp.md +15 -15
  75. package/docs/agent-api/notes.md +1 -1
  76. package/docs/agent-api/reading.md +2 -2
  77. package/docs/agent-api/requests.md +16 -18
  78. package/docs/agent-api/talking.md +60 -55
  79. package/docs/agent-api/tcb.md +21 -21
  80. package/docs/agent-api/views.md +3 -4
  81. package/docs/agent-api/words.md +8 -8
  82. package/package.json +2 -1
@@ -33,6 +33,13 @@
33
33
  // stands at a build. A log may still hold such a line: the replay skips it (`readEvent`) without
34
34
  // calling it a problem, so that its writer writes on.
35
35
  //
36
+ // Since 2026-10-19 a reviewer may withdraw their current opinion (ReviewSpec decision 9, the owner's
37
+ // decision of 2026-10-19): a `withdraw` line, appended like any, never an erasure. The replay marks
38
+ // the opinion it takes back (`withdrawn`), which stays in the declaration's history; `current` and
39
+ // `advice`, and so every status, count and queue, read its author as having no opinion there, their
40
+ // earlier ones not restored. An agent withdraws its own advice alone, and a person may withdraw the
41
+ // opinion of the person they speak for, as recording one (decision 8).
42
+ //
36
43
  // Since 2026-10-09 a move (HistorySpec.md) carries what was said of one declaration to another, and
37
44
  // says where one is another renamed: shared/moves.ts replays it. Since 2026-10-11 the library's
38
45
  // files and the links into them are events too (AttachmentSpec.md): shared/library.ts replays them.
@@ -103,10 +110,11 @@ export function invalid(r) {
103
110
  return "agent";
104
111
  if (o.person !== undefined && (!validPersonId(o.person) || o.agent))
105
112
  return "person";
106
- // an opinion recorded for someone else (ReviewSpec decision 8): a person's, for another person
113
+ // an opinion recorded for someone else (ReviewSpec decision 8), or withdrawn for them (decision
114
+ // 9): a person's, for another person
107
115
  if (o.for !== undefined || o.forPerson !== undefined) {
108
- if (o.op !== "opinion")
109
- return "only an opinion is recorded for someone else";
116
+ if (o.op !== "opinion" && o.op !== "withdraw")
117
+ return "only an opinion, or its withdrawal, is recorded for someone else";
110
118
  if (o.agent)
111
119
  return "an agent records for no one";
112
120
  if (typeof o.for !== "string" || !validName(o.for.trim()))
@@ -133,6 +141,8 @@ export function invalid(r) {
133
141
  if (o.text !== undefined && o.statement !== undefined)
134
142
  return "a text or a statement, not both";
135
143
  return null;
144
+ case "withdraw":
145
+ return null;
136
146
  case "target":
137
147
  return typeof o.on === "boolean" ? null : "on";
138
148
  case "trust":
@@ -189,6 +199,18 @@ export function eventOf(d, r, toolchain, now) {
189
199
  }
190
200
  return e;
191
201
  }
202
+ case "withdraw": {
203
+ const e = { op: "withdraw", at: now, by, ...person, name: r.name };
204
+ // withdrawn for someone else (ReviewSpec decision 9)
205
+ if (r.for?.trim()) {
206
+ e.for = r.for.trim();
207
+ if (r.forPerson)
208
+ e.forPerson = r.forPerson;
209
+ }
210
+ if (r.agent)
211
+ e.agent = true;
212
+ return e;
213
+ }
192
214
  case "target":
193
215
  return { op: "target", at: now, by, ...person, name: r.name, on: r.on, ...agent };
194
216
  case "trust":
@@ -236,6 +258,18 @@ export function applyEvent(d, e) {
236
258
  (Object.hasOwn(d.opinions, name) ? d.opinions[name] : (d.opinions[name] = [])).push(forName === undefined ? o : recordedFor(d, o, forName, forPerson));
237
259
  return;
238
260
  }
261
+ case "withdraw": {
262
+ // the latest opinion of theirs, as `current` reads it, unless withdrawn already: marked, kept
263
+ // where it is (ReviewSpec decision 9); a line with nothing to take back does nothing
264
+ const ops = Object.hasOwn(d.opinions, e.name) ? d.opinions[e.name] : null;
265
+ const whose = voice(e);
266
+ const k = ops ? ops.findLastIndex((o) => author(o) === whose) : -1;
267
+ if (!ops || k < 0 || ops[k].withdrawn)
268
+ return;
269
+ const by = e.for === undefined ? {} : { recordedBy: { by: e.by, ...person } };
270
+ ops[k] = { ...ops[k], withdrawn: { at: e.at, ...by } };
271
+ return;
272
+ }
239
273
  case "target":
240
274
  if (!e.on)
241
275
  delete d.targets[e.name];
@@ -296,6 +330,8 @@ function named(d, id, name) {
296
330
  o.by = name;
297
331
  if (o.recordedBy?.person === id)
298
332
  o.recordedBy.by = name;
333
+ if (o.withdrawn?.recordedBy?.person === id)
334
+ o.withdrawn.recordedBy.by = name;
299
335
  }
300
336
  for (const t of Object.values(d.targets))
301
337
  if (t.person === id)
@@ -320,7 +356,8 @@ export function record(d, r, toolchain, now) {
320
356
  return e;
321
357
  }
322
358
  /** Whether recording `r` would change nothing: a target marked that is one, a prefix trusted that
323
- * is, a key declaration marked that is. Such a request is answered, and nothing is appended. */
359
+ * is, a key declaration marked that is, a withdrawal with no opinion standing to take back. Such a
360
+ * request is answered, and nothing is appended. */
324
361
  export function noChange(d, r) {
325
362
  if (r.op === "target")
326
363
  return Object.hasOwn(d.targets, r.name) === r.on;
@@ -328,6 +365,9 @@ export function noChange(d, r) {
328
365
  return d.trusted.includes(r.prefix) === r.on;
329
366
  if (r.op === "key")
330
367
  return keyMarked(d, r.target, r.name) === r.on;
368
+ // nothing standing to take back (ReviewSpec decision 9)
369
+ if (r.op === "withdraw")
370
+ return !standing(d, r.name, r.for?.trim() ? { by: r.for.trim(), ...(r.forPerson ? { person: r.forPerson } : {}) } : { by: r.by.trim(), agent: r.agent, person: r.person });
331
371
  if (r.op === "move")
332
372
  return moveIsIdle(d, { ...r, rename: r.rename || undefined });
333
373
  if (isLibraryOp(r.op))
@@ -384,19 +424,23 @@ export function readEvent(raw, agentLog, personLog = null) {
384
424
  if (e.text !== undefined && e.statement !== undefined)
385
425
  return "a text and a statement";
386
426
  // recorded for someone else (ReviewSpec decision 8): a person's line, for another person
387
- if (o.for !== undefined || o.forPerson !== undefined) {
388
- if (agentLog)
389
- return "an agent's opinion recorded for someone else";
390
- if (typeof o.for !== "string" || !validName(o.for))
391
- return "for";
392
- if (o.forPerson !== undefined && !validPersonId(o.forPerson))
393
- return "forPerson";
394
- if (o.for === by || (o.forPerson !== undefined && o.forPerson === personLog))
395
- return "an opinion recorded for its own writer";
396
- e.for = o.for;
397
- if (o.forPerson !== undefined)
398
- e.forPerson = o.forPerson;
399
- }
427
+ const f = readFor(o, by, agentLog, personLog);
428
+ if (typeof f === "string")
429
+ return f;
430
+ Object.assign(e, f);
431
+ if (agentLog)
432
+ e.agent = true;
433
+ return e;
434
+ }
435
+ case "withdraw": {
436
+ if (!str(o.name, 2000))
437
+ return "name";
438
+ const e = { op: "withdraw", at, by, ...person, name: o.name };
439
+ // withdrawn for someone else (ReviewSpec decision 9), as an opinion is recorded for them
440
+ const f = readFor(o, by, agentLog, personLog);
441
+ if (typeof f === "string")
442
+ return f;
443
+ Object.assign(e, f);
400
444
  if (agentLog)
401
445
  e.agent = true;
402
446
  return e;
@@ -423,6 +467,22 @@ export function readEvent(raw, agentLog, personLog = null) {
423
467
  return isLibraryOp(o.op) ? readLibraryEvent(o, at, by, agentLog, personLog) : "op";
424
468
  }
425
469
  }
470
+ /** Whom a line of an opinion or of a withdrawal is for, where it is another person's (ReviewSpec
471
+ * decisions 8 and 9): `for` and `forPerson` as read, none, or why the line cannot be read — an
472
+ * agent's line for anyone, a line for its own writer. */
473
+ function readFor(o, by, agentLog, personLog) {
474
+ if (o.for === undefined && o.forPerson === undefined)
475
+ return {};
476
+ if (agentLog)
477
+ return o.op === "withdraw" ? "an agent's withdrawal for someone else" : "an agent's opinion recorded for someone else";
478
+ if (typeof o.for !== "string" || !validName(o.for))
479
+ return "for";
480
+ if (o.forPerson !== undefined && !validPersonId(o.forPerson))
481
+ return "forPerson";
482
+ if (o.for === by || (o.forPerson !== undefined && o.forPerson === personLog))
483
+ return o.op === "withdraw" ? "a withdrawal for its own writer" : "an opinion recorded for its own writer";
484
+ return { for: o.for, ...(o.forPerson !== undefined ? { forPerson: o.forPerson } : {}) };
485
+ }
426
486
  /** Every log merged into one sequence: one writer's events in the order of their file, different
427
487
  * writers' by time; at the same time, by file name (the same on every replica, so every server
428
488
  * replays the same). A writer's clock going backwards keeps their order and delays nobody else's
@@ -549,9 +609,18 @@ export function problemsText(ps) {
549
609
  function author(o) {
550
610
  return o.person ? `link ${o.person}` : (o.agent ? "agent " : "person ") + o.by;
551
611
  }
552
- /** Whose an opinion line is: theirs it was recorded for (ReviewSpec decision 8), else its writer's. */
612
+ /** Whose a line of an opinion or a withdrawal is: theirs it was recorded for (ReviewSpec decisions 8
613
+ * and 9), else its writer's. */
553
614
  function voice(e) {
554
- return e.for === undefined ? author(e) : author({ by: e.for, verdict: e.verdict, at: e.at, ...(e.forPerson ? { person: e.forPerson } : {}) });
615
+ return e.for === undefined ? author(e) : author({ by: e.for, ...(e.forPerson ? { person: e.forPerson } : {}) });
616
+ }
617
+ /** The opinion of `who` on `name` that a withdrawal would take back (ReviewSpec decision 9): their
618
+ * latest, people's or an agent's, stale or not, unless it is withdrawn already; null where they
619
+ * have none standing. */
620
+ export function standing(d, name, who) {
621
+ const whose = author(who);
622
+ const o = (Object.hasOwn(d.opinions, name) ? d.opinions[name] : []).findLast((p) => author(p) === whose);
623
+ return o && !o.withdrawn ? o : null;
555
624
  }
556
625
  /** An opinion recorded for someone else (ReviewSpec decision 8), as the review holds it: theirs —
557
626
  * under their latest name where they are invited — saying who recorded it. */
@@ -561,14 +630,15 @@ function recordedFor(d, o, forName, forPerson) {
561
630
  return { ...rest, by: name, ...(forPerson ? { person: forPerson } : {}), recordedBy: { by, ...(person ? { person } : {}) } };
562
631
  }
563
632
  /** Each author's latest opinion on a declaration, people's or agents': a new one replaces their
564
- * earlier one. */
633
+ * earlier one; one withdrawn leaves its author none, their earlier ones not restored (ReviewSpec
634
+ * decision 9). */
565
635
  function latest(d, name, agents) {
566
636
  const out = new Map();
567
637
  // own keys only: a declaration may be called `constructor` or `toString`
568
638
  for (const o of Object.hasOwn(d.opinions, name) ? d.opinions[name] : [])
569
639
  if (!!o.agent === agents)
570
640
  out.set(author(o), o);
571
- return [...out.values()];
641
+ return [...out.values()].filter((o) => !o.withdrawn);
572
642
  }
573
643
  /** Each reviewer's latest opinion on a declaration: a new one replaces their earlier one. People
574
644
  * only: an agent's opinion is advice, and nothing read off this counts it. */
@@ -16,7 +16,7 @@
16
16
  import { SITE_BODY, SITE_STMT } from "./graph.js";
17
17
  import { current, fresh, STANDARD_AXIOMS, statusOf, trusted } from "./review.js";
18
18
  import { ALL_SITES } from "./viewgraph.js";
19
- import { evaluate, reviewScope } from "./query.js";
19
+ import { evaluate, keyScope, reviewScope } from "./query.js";
20
20
  /** The references a TCB follows: in statements and bodies, never inside a proof. */
21
21
  export const TCB_SITES = SITE_STMT | SITE_BODY;
22
22
  /** In how many of the targets' TCBs each declaration is. */
@@ -58,6 +58,11 @@ export function trustSplit(g, d, s, skip = -1) {
58
58
  export function reviewSet(g, d, root) {
59
59
  return evaluate(reviewScope(g.nodes[root].name), { g, review: d });
60
60
  }
61
+ /** What can be key for `root` (`keyScope`, ExportSpec decision 1): its TCB, trusted members
62
+ * included, and its review set, in the graph's numbering. No trust changes it. */
63
+ export function keyableSet(g, d, root) {
64
+ return evaluate(keyScope(g.nodes[root].name), { g, review: d });
65
+ }
61
66
  const VIA = 8;
62
67
  /** The non-standard axioms `root` rests on, through statements, bodies or proofs: those the axiom
63
68
  * sets of what it reaches name (the extractor's, through everything), and those it reaches as