nervur 0.19.2 → 0.20.1

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 (235) hide show
  1. package/README.md +156 -104
  2. package/dist/being/being.d.ts +8 -15
  3. package/dist/being/being.js +20 -67
  4. package/dist/being/digest.d.ts +1 -1
  5. package/dist/being/digest.js +7 -27
  6. package/dist/being/faculty.d.ts +10 -0
  7. package/dist/being/faculty.js +74 -0
  8. package/dist/being/index.d.ts +5 -5
  9. package/dist/being/index.js +6 -5
  10. package/dist/being/kind.d.ts +4 -0
  11. package/dist/being/kind.js +28 -0
  12. package/dist/being/types.d.ts +35 -63
  13. package/dist/being/types.js +3 -57
  14. package/dist/being/words.d.ts +13 -0
  15. package/dist/being/words.js +14 -0
  16. package/dist/cli/command.d.ts +13 -0
  17. package/dist/cli/command.js +194 -0
  18. package/dist/cli/harbor.d.ts +21 -0
  19. package/dist/cli/harbor.js +141 -0
  20. package/dist/cli/main.d.ts +2 -0
  21. package/dist/cli/main.js +14 -0
  22. package/dist/contract/index.d.ts +39 -0
  23. package/dist/contract/index.js +33 -0
  24. package/dist/crypto/aes.d.ts +3 -0
  25. package/dist/crypto/aes.js +24 -0
  26. package/dist/crypto/bytes.d.ts +6 -0
  27. package/dist/crypto/bytes.js +33 -0
  28. package/dist/crypto/ed25519.d.ts +3 -0
  29. package/dist/crypto/ed25519.js +85 -0
  30. package/dist/crypto/hash.d.ts +2 -0
  31. package/dist/crypto/hash.js +11 -0
  32. package/dist/crypto/index.d.ts +7 -0
  33. package/dist/crypto/index.js +10 -0
  34. package/dist/crypto/json.d.ts +8 -0
  35. package/dist/crypto/json.js +250 -0
  36. package/dist/crypto/mlkem.d.ts +12 -0
  37. package/dist/crypto/mlkem.js +36 -0
  38. package/dist/crypto/subtle.d.ts +10 -0
  39. package/dist/crypto/subtle.js +29 -0
  40. package/dist/crypto/x25519.d.ts +2 -0
  41. package/dist/crypto/x25519.js +21 -0
  42. package/dist/folder/index.d.ts +14 -0
  43. package/dist/folder/index.js +87 -0
  44. package/dist/harbor/catalogue.d.ts +25 -0
  45. package/dist/harbor/catalogue.js +93 -0
  46. package/dist/harbor/dock.d.ts +29 -0
  47. package/dist/harbor/dock.js +122 -0
  48. package/dist/harbor/harbor.d.ts +31 -0
  49. package/dist/harbor/harbor.js +146 -0
  50. package/dist/harbor/index.d.ts +7 -10
  51. package/dist/harbor/index.js +9 -18
  52. package/dist/harbor/package.d.ts +10 -0
  53. package/dist/harbor/package.js +115 -0
  54. package/dist/harbor/registry.d.ts +9 -0
  55. package/dist/harbor/registry.js +78 -0
  56. package/dist/harbor/root-line.d.ts +9 -0
  57. package/dist/harbor/root-line.js +36 -0
  58. package/dist/harbor/terrain.d.ts +9 -0
  59. package/dist/harbor/terrain.js +2 -0
  60. package/dist/index.d.ts +7 -0
  61. package/dist/index.js +14 -0
  62. package/dist/pointer/bodies.d.ts +26 -0
  63. package/dist/pointer/bodies.js +64 -0
  64. package/dist/pointer/index.d.ts +2 -0
  65. package/dist/pointer/index.js +4 -0
  66. package/dist/pointer/world.d.ts +35 -0
  67. package/dist/pointer/world.js +85 -0
  68. package/dist/quo/door.d.ts +34 -0
  69. package/dist/quo/door.js +172 -0
  70. package/dist/quo/index.d.ts +8 -0
  71. package/dist/quo/index.js +11 -0
  72. package/dist/quo/invitation.d.ts +7 -0
  73. package/dist/quo/invitation.js +15 -0
  74. package/dist/quo/keys.d.ts +40 -0
  75. package/dist/quo/keys.js +79 -0
  76. package/dist/quo/payload.d.ts +15 -0
  77. package/dist/quo/payload.js +55 -0
  78. package/dist/quo/relations.d.ts +40 -0
  79. package/dist/quo/relations.js +33 -0
  80. package/dist/quo/reply.d.ts +13 -0
  81. package/dist/quo/reply.js +35 -0
  82. package/dist/quo/seal.d.ts +42 -0
  83. package/dist/quo/seal.js +78 -0
  84. package/dist/quo/standing.d.ts +39 -0
  85. package/dist/quo/standing.js +90 -0
  86. package/dist/tcp/frame.d.ts +29 -0
  87. package/dist/tcp/frame.js +74 -0
  88. package/dist/tcp/index.d.ts +18 -0
  89. package/dist/tcp/index.js +164 -0
  90. package/dist/ward/allowance.d.ts +13 -9
  91. package/dist/ward/allowance.js +28 -67
  92. package/dist/ward/cells.d.ts +6 -6
  93. package/dist/ward/cells.js +67 -179
  94. package/dist/ward/index.d.ts +6 -10
  95. package/dist/ward/index.js +7 -13
  96. package/dist/ward/partition.d.ts +44 -60
  97. package/dist/ward/partition.js +56 -285
  98. package/dist/ward/pilot.d.ts +8 -0
  99. package/dist/ward/pilot.js +50 -0
  100. package/dist/ward/stance.d.ts +27 -20
  101. package/dist/ward/stance.js +174 -406
  102. package/dist/ward/ward-being.d.ts +35 -0
  103. package/dist/ward/ward-being.js +82 -0
  104. package/dist/ward/ward.d.ts +45 -11
  105. package/dist/ward/ward.js +239 -357
  106. package/package.json +24 -31
  107. package/src/being/being.ts +35 -78
  108. package/src/being/digest.ts +7 -35
  109. package/src/being/faculty.ts +73 -0
  110. package/src/being/index.ts +6 -6
  111. package/src/being/kind.ts +30 -0
  112. package/src/being/types.ts +50 -146
  113. package/src/being/words.ts +31 -0
  114. package/src/cli/command.ts +188 -0
  115. package/src/cli/harbor.ts +137 -0
  116. package/src/cli/main.ts +13 -0
  117. package/src/contract/index.ts +73 -0
  118. package/src/crypto/aes.ts +26 -0
  119. package/src/crypto/bytes.ts +37 -0
  120. package/src/crypto/ed25519.ts +84 -0
  121. package/src/crypto/hash.ts +14 -0
  122. package/src/crypto/index.ts +10 -0
  123. package/src/crypto/json.ts +241 -0
  124. package/src/crypto/mlkem.ts +38 -0
  125. package/src/crypto/subtle.ts +33 -0
  126. package/src/crypto/x25519.ts +21 -0
  127. package/src/folder/index.ts +92 -0
  128. package/src/harbor/catalogue.ts +110 -0
  129. package/src/harbor/dock.ts +137 -0
  130. package/src/harbor/harbor.ts +180 -0
  131. package/src/harbor/index.ts +9 -19
  132. package/src/harbor/package.ts +131 -0
  133. package/src/harbor/registry.ts +73 -0
  134. package/src/harbor/root-line.ts +36 -0
  135. package/src/harbor/terrain.ts +15 -0
  136. package/src/index.ts +20 -0
  137. package/src/pointer/bodies.ts +65 -0
  138. package/src/pointer/index.ts +4 -0
  139. package/src/pointer/world.ts +94 -0
  140. package/src/quo/door.ts +178 -0
  141. package/src/quo/index.ts +11 -0
  142. package/src/quo/invitation.ts +15 -0
  143. package/src/quo/keys.ts +91 -0
  144. package/src/quo/payload.ts +61 -0
  145. package/src/quo/relations.ts +62 -0
  146. package/src/quo/reply.ts +38 -0
  147. package/src/quo/seal.ts +101 -0
  148. package/src/quo/standing.ts +111 -0
  149. package/src/stand/main.ts +20 -0
  150. package/src/stand/stand.ts +220 -0
  151. package/src/tcp/frame.ts +78 -0
  152. package/src/tcp/index.ts +173 -0
  153. package/src/ward/allowance.ts +37 -75
  154. package/src/ward/cells.ts +63 -176
  155. package/src/ward/index.ts +7 -17
  156. package/src/ward/partition.ts +86 -326
  157. package/src/ward/pilot.ts +50 -0
  158. package/src/ward/stance.ts +186 -420
  159. package/src/ward/ward-being.ts +103 -0
  160. package/src/ward/ward.ts +256 -359
  161. package/dist/being/lent.d.ts +0 -32
  162. package/dist/being/lent.js +0 -72
  163. package/dist/being/silence.d.ts +0 -12
  164. package/dist/being/silence.js +0 -41
  165. package/dist/conformance/assert.d.ts +0 -11
  166. package/dist/conformance/assert.js +0 -106
  167. package/dist/conformance/beings.d.ts +0 -199
  168. package/dist/conformance/beings.js +0 -188
  169. package/dist/conformance/estate.d.ts +0 -5
  170. package/dist/conformance/estate.js +0 -388
  171. package/dist/conformance/index.d.ts +0 -80
  172. package/dist/conformance/index.js +0 -819
  173. package/dist/conformance/reach.d.ts +0 -10
  174. package/dist/conformance/reach.js +0 -72
  175. package/dist/conformance/store.d.ts +0 -5
  176. package/dist/conformance/store.js +0 -113
  177. package/dist/harbor/box.d.ts +0 -121
  178. package/dist/harbor/box.js +0 -121
  179. package/dist/harbor/core.d.ts +0 -55
  180. package/dist/harbor/core.js +0 -662
  181. package/dist/harbor/dial.d.ts +0 -9
  182. package/dist/harbor/dial.js +0 -81
  183. package/dist/harbor/memory.d.ts +0 -29
  184. package/dist/harbor/memory.js +0 -104
  185. package/dist/harbor/reach.d.ts +0 -36
  186. package/dist/harbor/reach.js +0 -199
  187. package/dist/harbor/store.d.ts +0 -35
  188. package/dist/harbor/store.js +0 -62
  189. package/dist/vector/cases.d.ts +0 -42
  190. package/dist/vector/cases.js +0 -223
  191. package/dist/vector/index.d.ts +0 -6
  192. package/dist/vector/index.js +0 -8
  193. package/dist/vector/stand.d.ts +0 -9
  194. package/dist/vector/stand.js +0 -77
  195. package/dist/vector/world.d.ts +0 -144
  196. package/dist/vector/world.js +0 -209
  197. package/dist/ward/arithmetic.d.ts +0 -31
  198. package/dist/ward/arithmetic.js +0 -249
  199. package/dist/ward/door.d.ts +0 -18
  200. package/dist/ward/door.js +0 -186
  201. package/dist/ward/ground.d.ts +0 -29
  202. package/dist/ward/ground.js +0 -56
  203. package/dist/ward/heirs.d.ts +0 -13
  204. package/dist/ward/heirs.js +0 -117
  205. package/dist/ward/json.d.ts +0 -2
  206. package/dist/ward/json.js +0 -163
  207. package/dist/ward/owner.d.ts +0 -13
  208. package/dist/ward/owner.js +0 -220
  209. package/dist/ward/seal.d.ts +0 -52
  210. package/dist/ward/seal.js +0 -150
  211. package/src/being/lent.ts +0 -72
  212. package/src/being/silence.ts +0 -46
  213. package/src/conformance/assert.ts +0 -100
  214. package/src/conformance/beings.ts +0 -188
  215. package/src/conformance/estate.ts +0 -412
  216. package/src/conformance/index.ts +0 -965
  217. package/src/conformance/reach.ts +0 -83
  218. package/src/conformance/store.ts +0 -125
  219. package/src/harbor/box.ts +0 -131
  220. package/src/harbor/core.ts +0 -699
  221. package/src/harbor/dial.ts +0 -112
  222. package/src/harbor/memory.ts +0 -123
  223. package/src/harbor/reach.ts +0 -221
  224. package/src/harbor/store.ts +0 -91
  225. package/src/vector/cases.ts +0 -257
  226. package/src/vector/index.ts +0 -11
  227. package/src/vector/stand.ts +0 -76
  228. package/src/vector/world.ts +0 -232
  229. package/src/ward/arithmetic.ts +0 -251
  230. package/src/ward/door.ts +0 -186
  231. package/src/ward/ground.ts +0 -142
  232. package/src/ward/heirs.ts +0 -116
  233. package/src/ward/json.ts +0 -144
  234. package/src/ward/owner.ts +0 -214
  235. package/src/ward/seal.ts +0 -178
@@ -1,186 +1,74 @@
1
- // How deep a value may nest. Every walk over a value in the kit recurses,
2
- // and a peer chooses the depth of what she answers; a bound keeps a hostile
3
- // reply from ending a walk in a stack overflow instead of a refusal.
4
- export const DEPTH = 64;
5
- // How many values one written out may come to. Depth alone does not bound
6
- // what a value costs to keep: one subvalue may sit under two keys, and
7
- // nesting that forty levels deep is inside the depth bound and is a trillion
8
- // values once written down. What is walked here is the object graph, which is
9
- // small; what a harbor keeps is the tree it expands to, which is not. So the
10
- // walk counts the tree while it proves the graph, and refuses a value nobody
11
- // could write down. This is a bound on what a being holds, so it is this
12
- // kit's number and no word of the spec.
13
- export const BREADTH = 1 << 20;
14
- // Text a harbor can write down: every surrogate in a pair. A lone one is a
15
- // code unit with no character, which JSON escapes and UTF-8 cannot encode at
16
- // all, so a harbor that keeps strings as bytes loses it and one that keeps
17
- // the object does not. I-JSON says a string is text, and this is that rule
18
- // where the value is written rather than where it is read.
19
- const WELL_FORMED = /^(?:[^\uD800-\uDFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF])*$/;
20
- // I-JSON, all the way down. A number that JSON cannot write is not a number
21
- // a harbor can keep, a key on the prototype is not a key she wrote, and a
22
- // hole in a list, or a key named `__proto__`, is a thing JSON writes one way
23
- // and a runtime reads another.
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // A being's cells, guarded. Her cells are kept by whatever memory her
3
+ // terrain gives, and a memory that writes JSON would hand back something
4
+ // other than what she wrote if she wrote anything JSON cannot hold. So a
5
+ // write that is not a value throws where she wrote it, in her own frame,
6
+ // and her answer becomes silence like any throw.
24
7
  //
25
- // A fault is a sentence; anything else is the count of values under this one,
26
- // itself included. A value already counted is a value already proven, so a
27
- // graph that shares is walked once per node rather than once per path.
28
- function walk(v, path, seen, sized, depth) {
29
- if (v === null || typeof v === 'boolean')
30
- return 1;
31
- if (typeof v === 'string')
32
- return WELL_FORMED.test(v) ? 1 : `${path} carries a lone surrogate, which is no text a harbor can write down`;
33
- if (typeof v === 'number') {
34
- if (!Number.isFinite(v))
35
- return `${path} is ${String(v)}, which no harbor can write down`;
36
- // Minus zero is a number JSON writes as `0` and reads back as `0`. A
37
- // harbor that keeps values would hand her the sign she wrote and one that
38
- // writes JSON would not, and she is never told which she is standing in.
39
- return Object.is(v, -0) ? `${path} is minus zero, which comes back as zero from every harbor that writes JSON` : 1;
40
- }
41
- if (typeof v !== 'object')
42
- return `${path} is a ${typeof v}, which is not a value`;
43
- if (seen.has(v))
44
- return `${path} refers back to itself`;
45
- const counted = sized.get(v);
46
- if (counted !== undefined)
47
- return counted;
48
- if (depth >= DEPTH)
49
- return `${path} is nested past ${DEPTH} levels, which no harbor can keep`;
50
- seen.add(v);
51
- try {
52
- let size = 1;
53
- const under = (where, x) => {
54
- const r = walk(x, where, seen, sized, depth + 1);
55
- if (typeof r === 'string')
56
- return r;
57
- size += r;
58
- return size > BREADTH ? `${path} writes out to more than ${BREADTH} values, which no harbor can keep` : null;
59
- };
60
- if (Array.isArray(v)) {
61
- for (let i = 0; i < v.length; i += 1) {
62
- if (!(i in v))
63
- return `${path}[${i}] is a hole, which no harbor can write down`;
64
- const f = under(`${path}[${i}]`, v[i]);
65
- if (f)
66
- return f;
67
- }
68
- sized.set(v, size);
69
- return size;
70
- }
71
- const proto = Object.getPrototypeOf(v);
72
- if (proto !== Object.prototype && proto !== null)
73
- return `${path} is a ${(v).constructor?.name ?? 'object'}, which is not a value`;
74
- for (const k of Object.keys(v)) {
75
- if (k === '__proto__')
76
- return `${path}.__proto__ is a key no harbor can keep`;
77
- const f = under(`${path}.${k}`, v[k]);
78
- if (f)
79
- return f;
80
- }
81
- sized.set(v, size);
82
- return size;
83
- }
84
- finally {
85
- seen.delete(v);
86
- }
87
- }
88
- export const cellFault = (v, path) => {
89
- const out = walk(v, path, new Set(), new Map(), 0);
90
- return typeof out === 'string' ? out : null;
91
- };
92
- // The three keys at the root of her cells that are the ward's: it writes
93
- // them, she reads them, and a write of hers there is refused like a non-value.
94
- const WARDS = new Set(['standings', 'occupants', 'class']);
95
- // The guard is one proxy at the root and one for every container read through
96
- // it, so a write nested three deep is refused the same way a write at the top
97
- // is. Wrappers are remembered, so reading the same array twice is the same
98
- // object twice and a being may still compare what she holds.
99
- const wrapped = new WeakMap();
100
- const targets = new WeakMap();
101
- const guards = new WeakSet();
102
- // A name no partition can hold, wherever it appears. It is here beside the
103
- // guard that refuses it, because the ward refuses it too: a relation named
104
- // this one would be written into the bind table and then throw on her cells,
105
- // which is half a relation and a throw where a null is promised. One rule,
106
- // one place, read by the guard and by the stance.
107
- export const unkeepable = (k) => k === '__proto__';
108
- // A key a write may land on: a string that is not `__proto__`, and not one
109
- // of the ward's at the root. A symbol key is a thing JSON never writes.
8
+ // What passes is stored as a fresh copy of its JSON text, so a reference
9
+ // she kept to what she wrote is not a way around the guard. Every key lands
10
+ // as an own key, `__proto__` included. A list grows at its end: a slot or a
11
+ // length past it would leave a hole.
12
+ import { writeValue } from '../crypto/index.js';
13
+ export const DEPTH = 64;
110
14
  const refuse = (why) => {
111
15
  throw new TypeError(`cells hold values: ${why}`);
112
16
  };
113
- function keyFault(t, k, v, path, root) {
114
- if (typeof k !== 'string')
115
- refuse(`${path} takes no symbol key`);
116
- if (unkeepable(k))
117
- refuse(`${path}.__proto__ is a key no harbor can keep`);
118
- if (root && WARDS.has(k))
119
- refuse(`${path}.${k} is the ward's to write`);
120
- // A list grows by one at its end, or it has holes JSON cannot write. A
121
- // push sets the slot at its length and then the length: both pass. A
122
- // length set past what she wrote, or a slot beyond it, would leave holes.
123
- if (Array.isArray(t)) {
124
- if (k === 'length') {
125
- if (typeof v !== 'number' || v > t.length)
126
- refuse(`${path}.length set past what she wrote would leave holes`);
127
- return;
128
- }
129
- const i = Number(k);
130
- if (Number.isInteger(i) && i > t.length)
131
- refuse(`${path}[${i}] would leave a hole`);
17
+ const copy = (value, room, where) => {
18
+ const text = writeValue(value, room);
19
+ return text === undefined ? refuse(`${where} is not a value JSON keeps, within ${room} levels`) : JSON.parse(text);
20
+ };
21
+ export class Cells {
22
+ #guards = new WeakMap();
23
+ #wrote;
24
+ constructor(wrote) {
25
+ this.#wrote = wrote;
132
26
  }
133
- }
134
- function guard(target, path, wrote, root = false) {
135
- if (guards.has(target))
136
- return target;
137
- const had = wrapped.get(target);
138
- if (had)
139
- return had;
140
- const p = new Proxy(target, {
141
- get(t, k, r) {
142
- const v = Reflect.get(t, k, r);
143
- // A container reached through her cells is part of her cells.
144
- return v !== null && typeof v === 'object' && !ArrayBuffer.isView(v) ? guard(v, `${path}.${String(k)}`, wrote) : v;
145
- },
146
- set(t, k, v, r) {
147
- keyFault(t, k, v, path, root);
148
- const f = cellFault(v, `${path}.${String(k)}`);
149
- if (f)
150
- refuse(f);
151
- const ok = Reflect.set(t, k, v, r);
152
- wrote();
153
- return ok;
154
- },
155
- defineProperty(t, k, d) {
156
- if (!('value' in d))
157
- refuse(`${path}.${String(k)} is an accessor, which no harbor can keep`);
158
- keyFault(t, k, d.value, path, root);
159
- const f = cellFault(d.value, `${path}.${String(k)}`);
160
- if (f)
161
- refuse(f);
162
- const ok = Reflect.defineProperty(t, k, d);
163
- wrote();
164
- return ok;
165
- },
166
- deleteProperty(t, k) {
167
- if (root && typeof k === 'string' && WARDS.has(k))
168
- refuse(`${path}.${k} is the ward's to keep`);
169
- const ok = Reflect.deleteProperty(t, k);
170
- wrote();
27
+ // The guarded view of a being's cells.
28
+ guard(cells) {
29
+ return this.#guard(cells, 'cells', 1);
30
+ }
31
+ #guard(target, path, level) {
32
+ const had = this.#guards.get(target);
33
+ if (had)
34
+ return had;
35
+ const room = DEPTH - level;
36
+ const place = (t, k, value) => {
37
+ if (typeof k !== 'string')
38
+ return refuse(`${path} takes no symbol key`);
39
+ const where = `${path}.${k}`;
40
+ if (Array.isArray(t)) {
41
+ if (k === 'length') {
42
+ if (typeof value !== 'number' || value > t.length)
43
+ refuse(`${where} past its end would leave a hole`);
44
+ t.length = value;
45
+ this.#wrote();
46
+ return true;
47
+ }
48
+ if (!/^(0|[1-9]\d*)$/.test(k))
49
+ refuse(`${where} is not a slot of a list`);
50
+ if (Number(k) > t.length)
51
+ refuse(`${where} would leave a hole`);
52
+ }
53
+ const ok = Reflect.defineProperty(t, k, { value: copy(value, room, where), enumerable: true, writable: true, configurable: true });
54
+ this.#wrote();
171
55
  return ok;
172
- },
173
- });
174
- wrapped.set(target, p);
175
- targets.set(p, target);
176
- guards.add(p);
177
- return p;
56
+ };
57
+ const proxy = new Proxy(target, {
58
+ get: (t, k, r) => {
59
+ const v = Reflect.get(t, k, r);
60
+ return typeof k === 'string' && Object.hasOwn(t, k) && typeof v === 'object' && v !== null ? this.#guard(v, `${path}.${k}`, level + 1) : v;
61
+ },
62
+ set: (t, k, v) => place(t, k, v),
63
+ defineProperty: (t, k, d) => ('value' in d ? place(t, k, d.value) : refuse(`${path}.${String(k)} is an accessor`)),
64
+ deleteProperty: (t, k) => {
65
+ const ok = Reflect.deleteProperty(t, k);
66
+ this.#wrote();
67
+ return ok;
68
+ },
69
+ setPrototypeOf: () => refuse(`${path} keeps its prototype`),
70
+ });
71
+ this.#guards.set(target, proxy);
72
+ return proxy;
73
+ }
178
74
  }
179
- // Her cells, guarded. Called once per being at boot; the guarded object is
180
- // what goes into the partition and what the stance hands her, so there is no
181
- // second door onto the same cells. Every write that passes says so to the
182
- // ward, which says so to its harbor.
183
- export const guardCells = (cells, wrote = () => { }) => guard(cells, 'cells', wrote, true);
184
- // The cells behind the guard, for the ward alone: the one writer of the
185
- // three keys that are its own.
186
- export const unguarded = (cells) => (targets.get(cells) ?? cells);
@@ -1,10 +1,6 @@
1
- export { Ward } from './ward.ts';
2
- export type { Ground, WardPointers, Memory } from './ground.ts';
3
- export { BOX, OFFER, RETRACT, volatile } from './ground.ts';
4
- export type { Partition, Heir, Bind, StandingKeys } from './partition.ts';
5
- export { GONE, MINTED, KNOCKS } from './partition.ts';
6
- export type { AskPayload, ReplyPayload } from './seal.ts';
7
- export * as seal from './seal.ts';
8
- export * as arithmetic from './arithmetic.ts';
9
- export { allow, spent, DEFAULT, CEILING } from './allowance.ts';
10
- export type { Allowance } from './allowance.ts';
1
+ export { allow, CEILING, DEFAULT } from './allowance.ts';
2
+ export { HEAD_ROW, Partition, type BeingRow, type Head, type StandingRow } from './partition.ts';
3
+ export { DEPTH } from './stance.ts';
4
+ export { DOCK, Ward, type Catalogue, type Lender, type WardParts } from './ward.ts';
5
+ export { ownerAsk, pilots, WardBeing, type Steward, type WardBeingStance } from './ward-being.ts';
6
+ export { Pilot } from './pilot.ts';
@@ -1,14 +1,8 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- // nervur/ward — one function. Every ward is the same ward.
3
- export { Ward } from './ward.js';
4
- export { BOX, OFFER, RETRACT, volatile } from './ground.js';
5
- // The three bounds on what a partition may hold, for a kit that must keep
6
- // the same ones and for a test that pins them.
7
- export { GONE, MINTED, KNOCKS } from './partition.js';
8
- // The seal and the arithmetic, for a kit in another language to check its
9
- // bytes against, and for tests that speak to a door directly.
10
- export * as seal from './seal.js';
11
- export * as arithmetic from './arithmetic.js';
12
- // The allowance every ask carries, for a kit in another language and for
13
- // tests that speak to a door directly.
14
- export { allow, spent, DEFAULT, CEILING } from './allowance.js';
2
+ // The ward: its partition, its stances, its ward-being, and the ward.
3
+ export { allow, CEILING, DEFAULT } from './allowance.js';
4
+ export { HEAD_ROW, Partition } from './partition.js';
5
+ export { DEPTH } from './stance.js';
6
+ export { DOCK, Ward } from './ward.js';
7
+ export { ownerAsk, pilots, WardBeing } from './ward-being.js';
8
+ export { Pilot } from './pilot.js';
@@ -1,65 +1,49 @@
1
- import type { Cells } from '../being/types.ts';
2
- export declare const VERSION = "pre-1.0.0";
3
- export declare const READS: readonly string[];
4
- export type Heir = {
5
- being: string;
6
- id: string;
7
- current: string;
8
- announced: string | null;
9
- fresh: boolean;
10
- mark: number;
11
- spent: number[];
12
- last?: {
13
- seq: number;
14
- reply: string;
15
- };
16
- };
17
- export type StandingKeys = {
18
- ward: string;
19
- heir: string | null;
20
- current: string;
21
- next: string | null;
22
- seq: number;
23
- };
24
- export type Bind = {
25
- standings: Record<string, StandingKeys>;
26
- occupants: Record<string, string>;
27
- knocks: Record<string, {
28
- current: string;
29
- next: string | null;
30
- spoke: boolean;
31
- sent: boolean;
32
- seq: number;
1
+ import type { Lock } from '../crypto/index.ts';
2
+ import { type HeirRecord, type Invitation, type KeptLock, type Relations, type StandingState } from '../quo/index.ts';
3
+ import type { Rows } from '../contract/index.ts';
4
+ import type { JsonObject } from '../being/index.ts';
5
+ export declare const HEAD_ROW = "";
6
+ export type Head = {
7
+ lock?: KeptLock;
8
+ heirs: Record<string, HeirRecord>;
9
+ gone: string[];
10
+ bind: Record<string, {
11
+ being: string;
12
+ id: string;
33
13
  }>;
34
- answered: Record<string, true>;
35
- minted: string[];
14
+ public: string | null;
36
15
  };
37
- export type Gone = {
38
- current: string;
39
- announced: string | null;
16
+ export type StandingRow = {
17
+ invitation: Invitation;
18
+ state: StandingState;
19
+ seen: string | null;
40
20
  };
41
- export declare const GONE = 256;
42
- export declare const MINTED = 8;
43
- export declare const KNOCKS = 64;
44
- export declare const prune: (knocks: Record<string, unknown>, answered: Record<string, true>) => void;
45
- export type Partition = {
46
- version: string;
47
- beings: Record<string, Cells & {
48
- class?: string;
21
+ export type BeingRow = {
22
+ class: string;
23
+ cells: JsonObject;
24
+ occupants: Record<string, {
25
+ heir: string;
26
+ notes: JsonObject;
49
27
  }>;
50
- bind: Record<string, Bind>;
51
- heirs: Record<string, Heir>;
52
- gone: Record<string, Gone>;
53
- public: string | null;
28
+ standings: Record<string, StandingRow>;
54
29
  };
55
- export declare function open(memory: Record<string, unknown>): Partition;
56
- export declare const at: <T>(rec: Record<string, T>, key: string) => T | undefined;
57
- export declare const put: <T>(rec: Record<string, T>, key: string, value: T) => T;
58
- export declare const drop: (rec: Record<string, unknown>, key: string) => void;
59
- export declare const emptyCells: () => Cells;
60
- export declare const emptyBind: () => Bind;
61
- export declare const HEAD = "";
62
- export declare const rowOf: (p: Partition, row: string) => Record<string, unknown> | undefined;
63
- export declare const rowsIn: (p: Record<string, unknown>) => string[];
64
- export declare const restoreRow: (p: Partition, row: string, value: Record<string, unknown> | undefined) => void;
65
- export declare const fromRows: (rows: Record<string, Record<string, unknown>>) => Record<string, unknown>;
30
+ export declare class Partition {
31
+ readonly memory: Rows;
32
+ constructor(memory: Rows);
33
+ get head(): Head;
34
+ get beings(): Record<string, BeingRow>;
35
+ being(key: string): BeingRow | undefined;
36
+ told(key: string): void;
37
+ toldHead(): void;
38
+ kept(): Promise<boolean>;
39
+ }
40
+ export declare class PartitionRelations implements Relations {
41
+ #private;
42
+ constructor(partition: Partition);
43
+ lock(): Lock | undefined;
44
+ setLock(lock: Lock): void;
45
+ get(heir: string): HeirRecord | undefined;
46
+ set(heir: string, record: HeirRecord): void;
47
+ delete(heir: string): void;
48
+ kept(): Promise<boolean>;
49
+ }