@graview/core 0.2.6 → 0.2.7

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 (51) hide show
  1. package/dist/binding-served.d.ts +3 -1
  2. package/dist/binding-served.d.ts.map +1 -1
  3. package/dist/binding-served.js +7 -2
  4. package/dist/binding-served.js.map +1 -1
  5. package/dist/binding-ungranted.d.ts +4 -0
  6. package/dist/binding-ungranted.d.ts.map +1 -1
  7. package/dist/binding-ungranted.js +15 -4
  8. package/dist/binding-ungranted.js.map +1 -1
  9. package/dist/binding.d.ts +25 -0
  10. package/dist/binding.d.ts.map +1 -1
  11. package/dist/binding.js +257 -46
  12. package/dist/binding.js.map +1 -1
  13. package/dist/cli/check/policy.js +4 -4
  14. package/dist/cli/check/policy.js.map +1 -1
  15. package/dist/cli/document-schema.d.ts.map +1 -1
  16. package/dist/cli/document-schema.js +9 -2
  17. package/dist/cli/document-schema.js.map +1 -1
  18. package/dist/document/compile.d.ts.map +1 -1
  19. package/dist/document/compile.js +35 -9
  20. package/dist/document/compile.js.map +1 -1
  21. package/dist/document/compiled.d.ts +2 -1
  22. package/dist/document/compiled.d.ts.map +1 -1
  23. package/dist/document/compiled.js +24 -1
  24. package/dist/document/compiled.js.map +1 -1
  25. package/dist/document/edit.js +2 -2
  26. package/dist/document/edit.js.map +1 -1
  27. package/dist/document/schema.d.ts +19 -4
  28. package/dist/document/schema.d.ts.map +1 -1
  29. package/dist/document/schema.js +20 -2
  30. package/dist/document/schema.js.map +1 -1
  31. package/dist/document.schema.json +199 -179
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/ops/undo.d.ts.map +1 -1
  37. package/dist/ops/undo.js +15 -3
  38. package/dist/ops/undo.js.map +1 -1
  39. package/dist/store.d.ts.map +1 -1
  40. package/dist/store.js +9 -0
  41. package/dist/store.js.map +1 -1
  42. package/dist/version.d.ts +1 -1
  43. package/dist/version.js +1 -1
  44. package/dist/views/types.d.ts +8 -0
  45. package/dist/views/types.d.ts.map +1 -1
  46. package/dist/views/types.js +1 -1
  47. package/dist/views/types.js.map +1 -1
  48. package/dist/workflows/findings.d.ts.map +1 -1
  49. package/dist/workflows/findings.js +15 -2
  50. package/dist/workflows/findings.js.map +1 -1
  51. package/package.json +2 -2
@@ -6,13 +6,15 @@ import type { Principal, Refusal } from "./permissions/types.js";
6
6
  export declare const BIND_PERSON = "bind-person";
7
7
  /** The name of the act that moves a seat, and what it did, from the record it is bound to onto another (Roadmap f-rebind-after-acting). */
8
8
  export declare const REBIND_PERSON = "rebind-person";
9
+ /** The name of the act that binds a seat with a record of its own to a person entered for it, the own record merged in (Roadmap f-merge-own-record-into-person). */
10
+ export declare const BIND_OWN_RECORD = "bind-own-record";
9
11
  /** The acts that say whose record a person is: the framework's own, the host's alone, and never an app's. */
10
12
  export declare const BINDING_ACTS: readonly string[];
11
13
  /** Whether a name is one of the binding acts (`BINDING_ACTS`). */
12
14
  export declare const isBindingAct: (name: string | undefined) => boolean;
13
15
  /** What `@graview/core/binding` teaches the store when it is loaded, as `PUBLISHING` does for a publish. */
14
16
  export interface BindingServed {
15
- /** The binding act of this name (`bind-person`, `rebind-person`) for this store, or none where no kind is the people. */
17
+ /** The binding act of this name (`bind-person`, `rebind-person`, `bind-own-record`) for this store, or none where no kind is the people. */
16
18
  act?: (store: object, name: string) => unknown;
17
19
  /** Whether this seat may run this binding: the host's system seat alone, acting for the app's owner; no grant gives it. */
18
20
  judged?: (store: object, call: MutationCall, principal: Principal) => {
@@ -1 +1 @@
1
- {"version":3,"file":"binding-served.d.ts","sourceRoot":"","sources":["../src/binding-served.ts"],"names":[],"mappings":"AAUA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE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AG,OAAO,CAMnG;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE;QAAE,GAAG,IAAI,SAAS,SAAS,EAAE,CAAA;KAAE,CAAA;CAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAyBpI;AAED,wGAAwG;AACxG,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAUlD,8IAA8I;AAC9I,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,GAAE,SAAmB,GAAG,CAAC,CAIlE;AAED,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,GAAE,SAAmB,GAAG,SAAS,GAAG,SAAS,CAiBzG;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,GAAE,SAAmB,GAAG,SAAS,CAS/E;AAED,gHAAgH;AAChH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAEjG;AAED,oJAAoJ;AACpJ,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAIzD"}
@@ -14,10 +14,12 @@ import { bindable, isSystem, seatPersonOf } from "./permissions/policy.js";
14
14
  export const BIND_PERSON = "bind-person";
15
15
  /** The name of the act that moves a seat, and what it did, from the record it is bound to onto another (Roadmap f-rebind-after-acting). */
16
16
  export const REBIND_PERSON = "rebind-person";
17
+ /** The name of the act that binds a seat with a record of its own to a person entered for it, the own record merged in (Roadmap f-merge-own-record-into-person). */
18
+ export const BIND_OWN_RECORD = "bind-own-record";
17
19
  /** The acts that say whose record a person is: the framework's own, the host's alone, and never an app's. */
18
- export const BINDING_ACTS = [BIND_PERSON, REBIND_PERSON];
20
+ export const BINDING_ACTS = [BIND_PERSON, REBIND_PERSON, BIND_OWN_RECORD];
19
21
  /** Whether a name is one of the binding acts (`BINDING_ACTS`). */
20
- export const isBindingAct = (name) => name === BIND_PERSON || name === REBIND_PERSON;
22
+ export const isBindingAct = (name) => name === BIND_PERSON || name === REBIND_PERSON || name === BIND_OWN_RECORD;
21
23
  /* One object for the store and `@graview/core/binding`, found by a key every copy agrees on. */
22
24
  export const BINDING = (globalThis[Symbol.for("@graview/core:binding")] ??= {});
23
25
  /** The op an undo chain begins with: the change itself, however often it was taken back and put back. */
@@ -37,6 +39,9 @@ export function takesBindingBack(op, get) {
37
39
  if (op.undoes === undefined)
38
40
  return false;
39
41
  const root = rootOfChain(op, get);
42
+ // A merge taken back makes the seat its own record's again (Roadmap f-merge-own-record-into-person).
43
+ if (root.mutation?.name === BIND_OWN_RECORD)
44
+ return true;
40
45
  return root.mutation?.name === BIND_PERSON && root.mutation.args?.["end"] !== true;
41
46
  }
42
47
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"binding-served.js","sourceRoot":"","sources":["../src/binding-served.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAkB,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG3E,yEAAyE;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AAEzC,2IAA2I;AAC3I,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAE7C,6GAA6G;AAC7G,MAAM,CAAC,MAAM,YAAY,GAAsB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAE5E,kEAAkE;AAClE,MAAM,CAAC,MAAM,YAAY,GAAG,C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AI,CAAC;IAC3C,MAAM,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC;AAC9D,CAAC"}
@@ -1,3 +1,7 @@
1
+ /** What each act the framework keeps for binding does, in the words a refusal of an app's act of that name says it with. */
2
+ export declare const bindingActDoes: (act: string) => string;
3
+ /** The sentence an app's or a document's own act under a kept binding name is refused with (`binding-act-taken`). */
4
+ export declare const bindingActTaken: (act: string) => string;
1
5
  /** The sentence a grant that names a binding act is refused with. */
2
6
  export declare const bindingUngranted: (act?: string) => string;
3
7
  //# sourceMappingURL=binding-ungranted.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding-ungranted.d.ts","sourceRoot":"","sources":["../src/binding-ungranted.ts"],"names":[],"mappings":"AASA,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,GAAI,MAAK,MAAoB,KAAG,MAGgF,CAAC"}
1
+ {"version":3,"file":"binding-ungranted.d.ts","sourceRoot":"","sources":["../src/binding-ungranted.ts"],"names":[],"mappings":"AAUA,4HAA4H;AAC5H,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAK0B,CAAC;AAExE,qHAAqH;AACrH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,MAAgG,CAAC;AAE/I,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,GAAI,MAAK,MAAoB,KAAG,MAKkF,CAAC"}
@@ -1,13 +1,24 @@
1
1
  /**
2
- * WHY NO GRANT NAMES `bind-person` OR `rebind-person` (Roadmap
3
- * f-invite-binds-existing-person, f-rebind-after-acting), as the checker, a
2
+ * WHY NO GRANT NAMES `bind-person`, `rebind-person` OR `bind-own-record`
3
+ * (Roadmap f-invite-binds-existing-person, f-rebind-after-acting,
4
+ * f-merge-own-record-into-person), as the checker, a
4
5
  * compile and an edit say it: whose record a person is is the host's to
5
6
  * say, as an invitation is accepted or a binding is corrected. Kept out of
6
7
  * what a page draws with.
7
8
  */
8
- import { BIND_PERSON } from "./binding-served.js";
9
+ import { BIND_PERSON, BIND_OWN_RECORD, REBIND_PERSON } from "./binding-served.js";
10
+ /** What each act the framework keeps for binding does, in the words a refusal of an app's act of that name says it with. */
11
+ export const bindingActDoes = (act) => act === REBIND_PERSON
12
+ ? "the host's moving of a person bound to the wrong record to the right one"
13
+ : act === BIND_OWN_RECORD
14
+ ? "the host's merging of a member's own record into the person entered for them"
15
+ : "the host's binding of an account to the person entered for it";
16
+ /** The sentence an app's or a document's own act under a kept binding name is refused with (`binding-act-taken`). */
17
+ export const bindingActTaken = (act) => `"${act}" is a name the framework keeps for an act of its own, ${bindingActDoes(act)}`;
9
18
  /** The sentence a grant that names a binding act is refused with. */
10
19
  export const bindingUngranted = (act = BIND_PERSON) => act === BIND_PERSON
11
20
  ? `"${BIND_PERSON}" is the host's, and no grant gives it: only the host binds an account to the person entered for it, as an invitation is accepted`
12
- : `"${act}" is the host's, and no grant gives it: only the host moves an account, and what it did, from one person's record to another's`;
21
+ : act === BIND_OWN_RECORD
22
+ ? `"${act}" is the host's, and no grant gives it: only the host merges an account's own record into the person entered for it`
23
+ : `"${act}" is the host's, and no grant gives it: only the host moves an account, and what it did, from one person's record to another's`;
13
24
  //# sourceMappingURL=binding-ungranted.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding-ungranted.js","sourceRoot":"","sources":["../src/binding-ungranted.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAc,WAAW,EAAU,EAAE,CACpE,GAAG,KAAK,WAAW;IACjB,CAAC,CAAC,IAAI,WAAW,mIAAmI;IACpJ,CAAC,CAAC,IAAI,GAAG,gIAAgI,CAAC"}
1
+ {"version":3,"file":"binding-ungranted.js","sourceRoot":"","sources":["../src/binding-ungranted.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAElF,4HAA4H;AAC5H,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE,CACpD,GAAG,KAAK,aAAa;IACnB,CAAC,CAAC,0EAA0E;IAC5E,CAAC,CAAC,GAAG,KAAK,eAAe;QACvB,CAAC,CAAC,8EAA8E;QAChF,CAAC,CAAC,+DAA+D,CAAC;AAExE,qHAAqH;AACrH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,IAAI,GAAG,0DAA0D,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;AAE/I,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAc,WAAW,EAAU,EAAE,CACpE,GAAG,KAAK,WAAW;IACjB,CAAC,CAAC,IAAI,WAAW,mIAAmI;IACpJ,CAAC,CAAC,GAAG,KAAK,eAAe;QACvB,CAAC,CAAC,IAAI,GAAG,qHAAqH;QAC9H,CAAC,CAAC,IAAI,GAAG,gIAAgI,CAAC"}
package/dist/binding.d.ts CHANGED
@@ -1,6 +1,17 @@
1
1
  import type { Principal } from "./permissions/types.js";
2
2
  import type { AnySchema } from "./schema/schema.js";
3
3
  import type { ApplyOptions, ApplyResult, Store } from "./store.js";
4
+ /**
5
+ * THE HOST'S OWN SEAT (Roadmap f-rebind-follow-ups): the system seat a host
6
+ * binds, moves, merges and ends a person's binding as, and takes one back
7
+ * as. Every other system seat is refused those: one a sync or another app
8
+ * writes as, a migration, the app's own actor, a workflow, and one that is
9
+ * only called what the host is. `id` and `name` say who it is in the log.
10
+ */
11
+ export declare function hostSeat(seat?: {
12
+ readonly id?: string;
13
+ readonly name?: string;
14
+ }): Principal;
4
15
  /**
5
16
  * BIND A JOINING ACCOUNT TO THE PERSON ENTERED FOR IT: what a host calls as
6
17
  * an invitation is accepted. `joining` is the seat as the host will serve it
@@ -37,6 +48,20 @@ export declare function unbindPerson<S extends AnySchema>(store: Store<S>, leavi
37
48
  * sentence a host can show.
38
49
  */
39
50
  export declare function rebindPerson<S extends AnySchema>(store: Store<S>, person: Principal, record: string, options?: ApplyOptions): ApplyResult<S>;
51
+ /**
52
+ * MERGE A MEMBER'S OWN RECORD INTO THE PERSON ENTERED FOR THEM (Roadmap
53
+ * f-merge-own-record-into-person): what a host calls where `bindPerson`
54
+ * says the account that joined already has its own record. `person` is the
55
+ * seat as the host serves it; `record` the person entered for it, of the
56
+ * people and nobody's. The seat is `record` from now on, every act it did
57
+ * as its own record is said as `record`, its own record's links move to
58
+ * `record`, and its own record is set aside. The `bind-own-record` act, run as
59
+ * `options.author`, the host's own seat (`hostSeat`), as a binding is: one
60
+ * change, which undo takes back whole — until the person has acted as
61
+ * `record`. Refused (`ActRefusal`, or `PermissionDeniedError` for who may)
62
+ * in a sentence a host can show.
63
+ */
64
+ export declare function mergePerson<S extends AnySchema>(store: Store<S>, person: Principal, record: string, options?: ApplyOptions): ApplyResult<S>;
40
65
  /**
41
66
  * WHETHER A RECORD MAY BE BOUND, ASKED BEFORE THERE IS A SEAT TO BIND
42
67
  * (Roadmap f-binding-dry-run-and-seat-rules): what a host asks as it offers
@@ -1 +1 @@
1
- {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAW,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA2SnE;;;;;;;;;GASG;AACH,wBAAgB,UA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AOrJ"}
package/dist/binding.js CHANGED
@@ -4,13 +4,16 @@
4
4
  * before he joins — his household, his lists — and when his account accepts
5
5
  * an invitation, the host binds it to that record rather than making a
6
6
  * second Bud (`bindPerson`). Bound to the wrong record, he is moved to the
7
- * right one with what he did there (`rebindPerson`). A host's, on no page:
8
- * loading it teaches every store the `bind-person` and `rebind-person`
9
- * acts, that the host alone runs them, and when they may be taken back
7
+ * right one with what he did there (`rebindPerson`); joined with a record
8
+ * of his own, it is merged into the one entered for him (`mergePerson`). A
9
+ * host's, on no page: loading it teaches every store the `bind-person`,
10
+ * `rebind-person` and `bind-own-record` acts, that the host's own seat
11
+ * (`hostSeat`) alone runs them, and when they may be taken back
10
12
  * (`BINDING`). Resolving a seat to its record is the main entry's.
11
13
  */
12
- import { BIND_PERSON, BINDING, boundAtHorizon, isBindingAct, REBIND_PERSON, takesBindingBack } from "./binding-served.js";
13
- import { isArchived, PERSON_SEAT, personSeatOf } from "./graph/archived.js";
14
+ import { BIND_PERSON, BINDING, boundAtHorizon, isBindingAct, BIND_OWN_RECORD, REBIND_PERSON, rootOfChain, takesBindingBack } from "./binding-served.js";
15
+ import { ARCHIVED, isArchived, PERSON_SEAT, personSeatOf } from "./graph/archived.js";
16
+ import { edgeId } from "./graph/types.js";
14
17
  import { isUnset, UNSET } from "./graph/primitives.js";
15
18
  import { MissingRecordError, NO_SUCH_RECORD } from "./graph/graph.js";
16
19
  import { signedOutSeat } from "./mutations/vote-suggestion.js";
@@ -23,24 +26,47 @@ const SEAT = /^[^~]+(~[\w-]{1,64})?$/;
23
26
  const NOBODY_BINDABLE = "Nobody here can be bound to a record: this app says of no kind that it is its people.";
24
27
  /**
25
28
  * EACH SEAT ONE OP MOVED FROM ONE RECORD TO ANOTHER (Roadmap
26
- * f-rebind-after-acting): the seat taken off one record and put on another
27
- * in the same op — a `rebind-person`, its undo, or its redo. The op is the
28
- * record of the move; nothing before it in the log is rewritten.
29
+ * f-rebind-after-acting): the first record the op touched the seat's mark
30
+ * on, and the last — a `rebind-person`, its undo, or its redo. A move of a
31
+ * binding that had ended puts the mark on each record and takes it off
32
+ * again, so it reads the same way and leaves both nobody's. A merge
33
+ * (Roadmap f-merge-own-record-into-person) puts the seat on a record and
34
+ * sets aside the seat's own record, whose id is the seat's: a move from it;
35
+ * taken back, a move to it. The op is the record of the move; nothing
36
+ * before it in the log is rewritten.
29
37
  */
30
38
  function movesIn(op) {
31
- const off = new Map();
32
- const on = new Map();
39
+ const touched = new Map();
40
+ const setAside = new Set();
41
+ const broughtBack = new Set();
33
42
  for (const primitive of op.primitives) {
34
- if (primitive.op !== "patch-node" || !Object.hasOwn(primitive.after, PERSON_SEAT))
43
+ if (primitive.op !== "patch-node")
35
44
  continue;
36
- const seat = primitive.after[PERSON_SEAT];
45
+ if (Object.hasOwn(primitive.after, ARCHIVED))
46
+ (primitive.after[ARCHIVED] === true ? setAside : broughtBack).add(primitive.id);
47
+ if (!Object.hasOwn(primitive.after, PERSON_SEAT))
48
+ continue;
49
+ const now = primitive.after[PERSON_SEAT];
37
50
  const was = primitive.before[PERSON_SEAT];
38
- if (typeof seat === "string" && !isUnset(seat))
39
- on.set(seat, primitive.id);
40
- else if (typeof was === "string" && !isUnset(was))
41
- off.set(was, primitive.id);
51
+ const on = typeof now === "string" && !isUnset(now);
52
+ const seat = on ? now : typeof was === "string" && !isUnset(was) ? was : undefined;
53
+ if (seat === undefined)
54
+ continue;
55
+ const one = touched.get(seat) ?? { records: [], on };
56
+ if (one.records.at(-1) !== primitive.id)
57
+ one.records.push(primitive.id);
58
+ one.on = on;
59
+ touched.set(seat, one);
42
60
  }
43
- return [...off].flatMap(([seat, from]) => (on.has(seat) && on.get(seat) !== from ? [{ seat, from, to: on.get(seat) }] : []));
61
+ return [...touched].flatMap(([seat, { records, on }]) => {
62
+ if (records.length > 1)
63
+ return records[0] !== records.at(-1) ? [{ seat, from: records[0], to: records.at(-1) }] : [];
64
+ if (on && setAside.has(seat))
65
+ return [{ seat, from: seat, to: records[0] }];
66
+ if (!on && broughtBack.has(seat))
67
+ return [{ seat, from: records[0], to: seat }];
68
+ return [];
69
+ });
44
70
  }
45
71
  /**
46
72
  * WHO WAS DONE AS WHICH RECORD, read from the log: each op's author as the
@@ -160,7 +186,7 @@ function bindPersonMutation(store) {
160
186
  throw new ActRefusal(`That account was ${before ? named(before) : `another ${noun}`} here: bind it to them again.`);
161
187
  const own = full.getNode(seat);
162
188
  if (own && schema.tryDefinition(own.kind)?.people)
163
- throw new ActRefusal(`That account already has its own record here, ${named(own)}: merge the two instead.`);
189
+ throw new ActRefusal(`That account already has its own record here, ${named(own)}: merge it into ${named(node)} instead.`);
164
190
  ctx.patchNode(record, { [PERSON_SEAT]: seat });
165
191
  },
166
192
  };
@@ -200,19 +226,179 @@ function rebindPersonMutation(store) {
200
226
  throw new MissingRecordError(from, NO_SUCH_RECORD.change);
201
227
  if (!now || !ctx.graph.getNode(to))
202
228
  throw new MissingRecordError(to, NO_SUCH_RECORD.change);
203
- if (personSeatOf(was) !== seat)
229
+ // Bound to `from` now, or bound to it last and ended since (Roadmap f-rebind-follow-ups).
230
+ const bound = personSeatOf(was) === seat;
231
+ if (!bound && !(full.personBoundTo(seat) === undefined && endedIn(store).get(seat) === from))
204
232
  throw new ActRefusal(`That account is not ${named(was)} here.`);
205
233
  if (from === to)
206
234
  throw new ActRefusal(`That account is ${named(was)} here already.`);
207
235
  const refused = recordRefusal(store, now, seat);
208
236
  if (refused)
209
237
  throw new ActRefusal(refused);
210
- ctx.patchNode(from, { [PERSON_SEAT]: UNSET });
211
- ctx.patchNode(to, { [PERSON_SEAT]: seat });
238
+ // The links its acts made as `from` where their call never named it (`$me`) go with it.
239
+ const links = linksMadeAs(store, seat, from);
240
+ if (bound) {
241
+ ctx.patchNode(from, { [PERSON_SEAT]: UNSET });
242
+ ctx.patchNode(to, { [PERSON_SEAT]: seat });
243
+ }
244
+ else {
245
+ // An ended binding moved stays ended, on `to`: the mark put on each record and taken off again, so the op says both (`movesIn`).
246
+ for (const id of [from, to]) {
247
+ ctx.emit({ op: "patch-node", id, before: { [PERSON_SEAT]: UNSET }, after: { [PERSON_SEAT]: seat } });
248
+ ctx.emit({ op: "patch-node", id, before: { [PERSON_SEAT]: seat }, after: { [PERSON_SEAT]: UNSET } });
249
+ }
250
+ }
251
+ moveLinks(ctx, store.graph, links, to);
252
+ },
253
+ };
254
+ }
255
+ /**
256
+ * THE LINKS A SEAT'S ACTS MADE AS A RECORD (Roadmap f-rebind-follow-ups):
257
+ * each link an act it did as the person added at the person's end, where
258
+ * the act's call never named that end — made through `$me` — followed
259
+ * through every move and merge since (and their undo), and at `record`
260
+ * now. A link a call named was the call's to make, and stays. Read from the
261
+ * log: a link made behind its horizon (a store loaded from a snapshot, or
262
+ * compacted) is not found, and stays where it is.
263
+ */
264
+ function linksMadeAs(store, seat, record) {
265
+ const all = store.log.all();
266
+ const at = new Map(all.map((op, index) => [op.seq, index]));
267
+ const get = (id) => store.log.get(id);
268
+ const found = new Map();
269
+ for (const one of doneAs(store)) {
270
+ if (one.seat !== seat || one.record !== record)
271
+ continue;
272
+ const index = at.get(one.seq);
273
+ const op = index === undefined ? undefined : all[index];
274
+ if (!op?.mutation)
275
+ continue;
276
+ const args = JSON.stringify(op.mutation.args) ?? "";
277
+ for (const primitive of op.primitives) {
278
+ if (primitive.op !== "add-edge")
279
+ continue;
280
+ for (const end of ["from", "to"]) {
281
+ if (args.includes(JSON.stringify(primitive.edge[end])))
282
+ continue;
283
+ const now = followed(all, index + 1, get, primitive.edge, end);
284
+ if (now?.[end] !== record)
285
+ continue;
286
+ const held = store.graph.outEdges(now.from).find((edge) => edgeId(edge) === edgeId(now));
287
+ if (held)
288
+ found.set(edgeId(held), { edge: held, end });
289
+ }
290
+ }
291
+ }
292
+ return [...found.values()];
293
+ }
294
+ /** Where a link is now: followed through each binding since (a move, a merge, their undo) that took it off one person's record onto another's at that end; undefined where one dropped it. */
295
+ function followed(all, from, get, edge, end) {
296
+ let now = edge;
297
+ const other = end === "from" ? "to" : "from";
298
+ for (let index = from; index < all.length; index++) {
299
+ const op = all[index];
300
+ if (!isBindingAct(rootOfChain(op, get).mutation?.name))
301
+ continue;
302
+ if (!op.primitives.some((one) => one.op === "remove-edge" && edgeId(one.edge) === edgeId(now)))
303
+ continue;
304
+ const next = op.primitives.find((one) => one.op === "add-edge" && one.edge.kind === now.kind && one.edge[other] === now[other] && one.edge[end] !== now[end]);
305
+ if (!next)
306
+ return undefined;
307
+ now = next.edge;
308
+ }
309
+ return now;
310
+ }
311
+ /** Each link moved from one record to another at its person's end in the act being made, as a merge moves them: never onto one the record has. */
312
+ function moveLinks(ctx, graph, links, to) {
313
+ const edges = graph;
314
+ const has = new Set([...edges.outEdges(to), ...edges.inEdges(to)].map(edgeId));
315
+ for (const { edge, end } of links) {
316
+ ctx.graph.getNode(edge.from);
317
+ ctx.graph.getNode(edge.to);
318
+ const next = { ...edge, [end]: to };
319
+ // A link between the two records stays: moved, it would be a link to itself.
320
+ if (next.from === next.to)
321
+ continue;
322
+ ctx.removeEdge(edge);
323
+ if (!has.has(edgeId(next))) {
324
+ has.add(edgeId(next));
325
+ ctx.addEdge(next);
326
+ }
327
+ }
328
+ }
329
+ /**
330
+ * The `bind-own-record` act for a store, where a kind is its people (Roadmap
331
+ * f-merge-own-record-into-person): a seat with a record of its own — the
332
+ * record whose id is the seat's, made as it joined or first opened the app
333
+ * — is bound to `record`, entered for it and nobody's, and its own record
334
+ * is merged into `record`: its links moved there and it set aside. What
335
+ * the seat did as its own record is done as `record` from this op on
336
+ * (`doneAs`, `movesIn`). One change, which undo takes back whole.
337
+ */
338
+ function mergePersonMutation(store) {
339
+ const schema = store.schema;
340
+ const people = schema.definitions.find((definition) => definition.people);
341
+ if (!people)
342
+ return undefined;
343
+ const noun = nounOf(people, people.kind);
344
+ const named = (node) => labelOf(schema.tryDefinition(node.kind), node);
345
+ const isPerson = (node) => schema.tryDefinition(node?.kind ?? "")?.people === true;
346
+ return {
347
+ name: BIND_OWN_RECORD,
348
+ title: `Merge an account's own record into this ${noun}`,
349
+ description: `The account that joined is this ${noun} from now on, what it did as its own record is done as them, and its own record's links move here; its own record is set aside.`,
350
+ subject: { kinds: [people.kind], arg: "record" },
351
+ input: z.object({ seat: z.string().check(z.regex(SEAT)), record: z.string().check(z.minLength(1)) }),
352
+ describe: (args, graph) => {
353
+ const node = graph.getNode(String(args.record));
354
+ return `Merge the account's own record into ${node ? named(node) : `the ${noun}`}`;
355
+ },
356
+ apply(ctx, args) {
357
+ const { seat, record } = args;
358
+ const full = store.graph;
359
+ const own = full.getNode(seat);
360
+ if (!own || !isPerson(own))
361
+ throw new ActRefusal(`That account has no record of its own here: bind it to the ${noun} entered for it instead.`);
362
+ if (!ctx.graph.getNode(seat))
363
+ throw new MissingRecordError(seat, NO_SUCH_RECORD.change);
364
+ const node = full.getNode(record);
365
+ if (!node || !ctx.graph.getNode(record))
366
+ throw new MissingRecordError(record, NO_SUCH_RECORD.change);
367
+ if (record === seat)
368
+ throw new ActRefusal(`That account's own record is ${named(own)}: merge it into the ${noun} entered for it.`);
369
+ const other = full.personBoundTo(seat);
370
+ const theirs = other === undefined ? undefined : full.getNode(other);
371
+ if (other !== undefined && other !== seat)
372
+ throw new ActRefusal(`That account is already ${theirs ? named(theirs) : `another ${noun}`} here.`);
373
+ const ended = endedIn(store).get(seat);
374
+ const was = ended === undefined ? undefined : full.getNode(ended);
375
+ if (ended !== undefined)
376
+ throw new ActRefusal(`That account was ${was ? named(was) : `another ${noun}`} here: bind it to them again.`);
377
+ if (isArchived(own))
378
+ throw new ActRefusal(`${named(own)} is set aside: bring them back before merging them.`);
379
+ const refused = recordRefusal(store, node, seat);
380
+ if (refused)
381
+ throw new ActRefusal(refused);
382
+ ctx.patchNode(record, { [PERSON_SEAT]: seat });
383
+ ctx.mergeNode(seat, record);
212
384
  },
213
385
  };
214
386
  }
215
387
  const refused = (call, message, wouldNeed = []) => ({ ok: false, refusal: { mutation: call.name, wouldNeed: [...wouldNeed], message } });
388
+ /** What marks the host's own seat: carried by the object a host mints (`hostSeat`) and its copies in memory, and by nothing written as JSON — a record, the wire, a sync, a suggestion. */
389
+ const HOST = Symbol.for("@graview/core:host-seat");
390
+ /**
391
+ * THE HOST'S OWN SEAT (Roadmap f-rebind-follow-ups): the system seat a host
392
+ * binds, moves, merges and ends a person's binding as, and takes one back
393
+ * as. Every other system seat is refused those: one a sync or another app
394
+ * writes as, a migration, the app's own actor, a workflow, and one that is
395
+ * only called what the host is. `id` and `name` say who it is in the log.
396
+ */
397
+ export function hostSeat(seat = {}) {
398
+ return Object.freeze({ kind: "system", ...(seat.id !== undefined ? { id: seat.id } : {}), ...(seat.name !== undefined ? { name: seat.name } : {}), [HOST]: true });
399
+ }
400
+ /** Whether a seat is the host's own (`hostSeat`), and not set to run unattended. */
401
+ const isHostSeat = (principal) => isSystem(principal) && principal[HOST] === true && principal.automated !== true;
216
402
  /**
217
403
  * WHO MAY BIND A SEAT TO A PERSON: the host's system seat, acting for the
218
404
  * app's owner when an invitation is accepted — and nobody else. No grant
@@ -223,28 +409,31 @@ const refused = (call, message, wouldNeed = []) => ({ ok: false, refusal: { muta
223
409
  */
224
410
  function judgedBinding(_store, call, principal) {
225
411
  const moving = call.name === REBIND_PERSON;
226
- const doing = moving ? "move an account from one record to another" : "bind an account to a record";
227
- const hostOnly = moving ? "Not permitted: only the host moves an account from one record to another here." : "Not permitted: only the host binds an account to a record here, as an invitation is accepted.";
412
+ const merging = call.name === BIND_OWN_RECORD;
413
+ const doing = moving ? "move an account from one record to another" : merging ? "merge an account's own record into another" : "bind an account to a record";
414
+ const hostOnly = moving
415
+ ? "Not permitted: only the host moves an account from one record to another here."
416
+ : merging
417
+ ? "Not permitted: only the host merges an account's own record into another here."
418
+ : "Not permitted: only the host binds an account to a record here, as an invitation is accepted.";
228
419
  if (signedOutSeat(principal))
229
420
  return refused(call, `Sign in to ${doing} here.`);
230
421
  // A person binds, never an agent nor anybody acting for one: what an agent reads in a record could steer it to.
231
422
  if (principal.kind === "agent" || principal.onBehalfOf !== undefined)
232
423
  return refused(call, `An agent cannot ${doing} here: a person who runs this app does that.`);
233
424
  /*
234
- * The host itself, and nothing else that writes as the system: never the
235
- * app's own actor or a workflow (`automated`), whose suggestion a vote
236
- * could carry in, nor another app's change arriving here.
425
+ * The host's own seat (`hostSeat`), and nothing else that writes as the
426
+ * system: never the app's own actor or a workflow (`automated`), whose
427
+ * suggestion a vote could carry in, another app's change arriving here,
428
+ * a sync, a migration, or a seat only called what the host is.
237
429
  */
238
- if (isSystem(principal)) {
239
- if (principal.automated === true || /^(workflow|app|template):/.test(principal.id ?? ""))
240
- return refused(call, hostOnly);
241
- return { ok: true };
242
- }
430
+ if (isSystem(principal))
431
+ return isHostSeat(principal) ? { ok: true } : refused(call, hostOnly);
243
432
  const seat = call.args["seat"];
244
433
  const records = [call.args["record"], call.args["from"], call.args["to"]];
245
434
  const account = actingAs(principal).id;
246
435
  if ((typeof seat === "string" && account !== undefined && (seat === account || seat.startsWith(`${account}~`))) || records.some((record) => typeof record === "string" && ownsId(principal, record))) {
247
- return refused(call, moving ? "You cannot move yourself to another record here: only the host does that." : "You cannot bind yourself to a record here: only the host does that, as an invitation is accepted.");
436
+ return refused(call, moving ? "You cannot move yourself to another record here: only the host does that." : merging ? "You cannot merge your own record here: only the host does that." : "You cannot bind yourself to a record here: only the host does that, as an invitation is accepted.");
248
437
  }
249
438
  return refused(call, hostOnly);
250
439
  }
@@ -257,8 +446,8 @@ function judgedBinding(_store, call, principal) {
257
446
  */
258
447
  function bindingKept(store, op, root) {
259
448
  const held = store;
260
- if (root.mutation?.name === REBIND_PERSON)
261
- return moveKept(held, op);
449
+ if (root.mutation?.name === REBIND_PERSON || root.mutation?.name === BIND_OWN_RECORD)
450
+ return moveKept(held, op, root.mutation.name === BIND_OWN_RECORD ? "the merge" : "the move");
262
451
  const args = (root.mutation?.args ?? {});
263
452
  if (typeof args.record !== "string" || typeof args.seat !== "string")
264
453
  return undefined;
@@ -289,19 +478,21 @@ const setAside = (store, node) => `This cannot be taken back: ${labelOf(store.sc
289
478
  * then — bound to another seat, or one another seat was done as or whose
290
479
  * binding ended.
291
480
  */
292
- function moveKept(store, op) {
481
+ function moveKept(store, op, what) {
293
482
  for (const { seat, from, to } of movesIn(op)) {
294
483
  // Taking it back takes the seat off the record it moved to: refused once the seat has acted as that record since, as an unbinding is.
295
484
  if (doneAs(store).some((one) => one.seq > op.seq && one.seat === seat && one.record === to)) {
296
485
  const moved = store.graph.getNode(to);
297
486
  const name = moved ? labelOf(store.schema.tryDefinition(moved.kind), moved) : "They";
298
- return `${name} has acted here: undoing the move would hand what they did to someone else.`;
487
+ return `${name} has acted here: undoing ${what} would hand what they did to someone else.`;
299
488
  }
300
489
  // Taking this op back puts the seat on the record it took it off.
301
490
  const node = store.graph.getNode(from);
302
491
  if (!node)
303
492
  return "This cannot be taken back: the record was removed since.";
304
- if (isArchived(node))
493
+ // A merge set the own record aside itself, and taking it back brings it back.
494
+ const setAsideHere = op.primitives.some((one) => one.op === "patch-node" && one.id === from && one.after[ARCHIVED] === true);
495
+ if (isArchived(node) && !setAsideHere)
305
496
  return setAside(store, node);
306
497
  const bound = personSeatOf(node);
307
498
  if ((bound !== undefined && bound !== seat) || doneAs(store).some((one) => one.record === from && one.seat !== seat) || [...endedIn(store)].some(([one, was]) => was === from && one !== seat)) {
@@ -319,22 +510,20 @@ function endedIn(store) {
319
510
  const ended = new Map();
320
511
  const get = (id) => store.log.get(id);
321
512
  for (const op of store.log.all()) {
322
- // A seat moved to another record ended nothing (Roadmap f-rebind-after-acting): the record it left is nobody's again.
323
- const moved = new Set(movesIn(op).map((move) => move.seat));
324
- for (const primitive of op.primitives) {
325
- if (primitive.op !== "patch-node" || !Object.hasOwn(primitive.after, PERSON_SEAT))
326
- continue;
513
+ const marks = op.primitives.flatMap((primitive) => (primitive.op === "patch-node" && Object.hasOwn(primitive.after, PERSON_SEAT) ? [primitive] : []));
514
+ marks.forEach((primitive, at) => {
327
515
  const seat = primitive.after[PERSON_SEAT];
328
516
  const was = primitive.before[PERSON_SEAT];
329
517
  if (typeof seat === "string" && !isUnset(seat))
330
518
  ended.delete(seat);
331
- else if (typeof was === "string" && !isUnset(was) && !moved.has(was) && !takesBindingBack(op, get))
519
+ // A seat put on another record later in the same op was moved, which ends nothing (Roadmap f-rebind-after-acting): the record it left is nobody's again.
520
+ else if (typeof was === "string" && !isUnset(was) && !marks.slice(at + 1).some((next) => next.after[PERSON_SEAT] === was) && !takesBindingBack(op, get))
332
521
  ended.set(was, primitive.id);
333
- }
522
+ });
334
523
  }
335
524
  return ended;
336
525
  }
337
- BINDING.act = (store, name) => (name === REBIND_PERSON ? rebindPersonMutation(store) : bindPersonMutation(store));
526
+ BINDING.act = (store, name) => (name === REBIND_PERSON ? rebindPersonMutation(store) : name === BIND_OWN_RECORD ? mergePersonMutation(store) : bindPersonMutation(store));
338
527
  BINDING.judged = judgedBinding;
339
528
  BINDING.undo = bindingKept;
340
529
  /**
@@ -389,11 +578,33 @@ export function rebindPerson(store, person, record, options = {}) {
389
578
  if (!store.schema.definitions.some((definition) => definition.people))
390
579
  throw new ActRefusal(NOBODY_BINDABLE);
391
580
  const seat = bindable(withValidProfile(person)) ? seatPersonOf(withValidProfile(person)) : undefined;
392
- const from = seat === undefined ? undefined : store.graph.personBoundTo(seat);
581
+ // Bound now, or bound last to a record whose binding ended (Roadmap f-rebind-follow-ups).
582
+ const from = seat === undefined ? undefined : (store.graph.personBoundTo(seat) ?? endedIn(store).get(seat));
393
583
  if (seat === undefined || from === undefined)
394
584
  throw new ActRefusal("That account is nobody's record here.");
395
585
  return store.apply({ name: REBIND_PERSON, args: { seat, from, to: record } }, options);
396
586
  }
587
+ /**
588
+ * MERGE A MEMBER'S OWN RECORD INTO THE PERSON ENTERED FOR THEM (Roadmap
589
+ * f-merge-own-record-into-person): what a host calls where `bindPerson`
590
+ * says the account that joined already has its own record. `person` is the
591
+ * seat as the host serves it; `record` the person entered for it, of the
592
+ * people and nobody's. The seat is `record` from now on, every act it did
593
+ * as its own record is said as `record`, its own record's links move to
594
+ * `record`, and its own record is set aside. The `bind-own-record` act, run as
595
+ * `options.author`, the host's own seat (`hostSeat`), as a binding is: one
596
+ * change, which undo takes back whole — until the person has acted as
597
+ * `record`. Refused (`ActRefusal`, or `PermissionDeniedError` for who may)
598
+ * in a sentence a host can show.
599
+ */
600
+ export function mergePerson(store, person, record, options = {}) {
601
+ if (!store.schema.definitions.some((definition) => definition.people))
602
+ throw new ActRefusal(NOBODY_BINDABLE);
603
+ const seat = bindable(withValidProfile(person)) ? seatPersonOf(withValidProfile(person)) : undefined;
604
+ if (seat === undefined)
605
+ throw new ActRefusal("Only somebody who signed in can be bound to a record here.");
606
+ return store.apply({ name: BIND_OWN_RECORD, args: { seat, record } }, options);
607
+ }
397
608
  /**
398
609
  * WHETHER A RECORD MAY BE BOUND, ASKED BEFORE THERE IS A SEAT TO BIND
399
610
  * (Roadmap f-binding-dry-run-and-seat-rules): what a host asks as it offers