@nervur.org/genome 0.37.6 → 0.37.8

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 (45) hide show
  1. package/cage/run/given.js +1 -1
  2. package/cage/run/input.js +3 -2
  3. package/contracts/carriers/contract.js +1 -1
  4. package/docs/changelog.md +5 -15
  5. package/genome/brain/kit.js +1 -1
  6. package/genome/brain/whole.d.ts +1 -1
  7. package/genome/brain/whole.js +15 -8
  8. package/genome/carry/carry.js +1 -1
  9. package/genome/carry/gear.js +1 -1
  10. package/genome/carry/held.js +1 -1
  11. package/genome/carry/organ.js +1 -1
  12. package/genome/cells/index.d.ts +1 -1
  13. package/genome/cells/index.js +1 -0
  14. package/genome/cells/rows.d.ts +2 -1
  15. package/genome/cells/rows.js +8 -1
  16. package/genome/faculties/ear/blueprint.js +1 -1
  17. package/genome/faculties/ear/text.js +1 -1
  18. package/genome/faculties/library/blueprint.js +1 -1
  19. package/genome/faculties/library/text.js +1 -1
  20. package/genome/faculties/mouth/blueprint.js +1 -1
  21. package/genome/faculties/mouth/text.js +1 -1
  22. package/genome/faculties/scheduler/blueprint.js +1 -1
  23. package/genome/faculties/scheduler/text.js +1 -1
  24. package/genome/log/open.js +1 -1
  25. package/genome/log/record.d.ts +6 -2
  26. package/genome/log/record.js +14 -15
  27. package/genome/organism/body.js +1 -1
  28. package/genome/pure/frozen.js +9 -14
  29. package/genome/store/store.js +1 -1
  30. package/kit/brain/rig.js +2 -1
  31. package/kit/core/chance.d.ts +1 -0
  32. package/kit/core/chance.js +7 -0
  33. package/kit/core/foundation.js +2 -2
  34. package/kit/core/index.d.ts +1 -1
  35. package/kit/core/index.js +1 -1
  36. package/kit/organism/peer.js +2 -2
  37. package/kit/organism/rig.d.ts +2 -1
  38. package/kit/organism/rig.js +22 -5
  39. package/kit/presence/home.js +2 -6
  40. package/kit/presence/screen-half.js +1 -1
  41. package/package.json +1 -1
  42. package/seams/carriers/carriers.js +1 -1
  43. package/seams/entry/configuration.js +1 -1
  44. package/standard/blueprint/blueprint.js +1 -1
  45. package/standard/version.js +1 -1
@@ -33,19 +33,14 @@ const listOf = (items ) => ({ type: 'array', items });
33
33
 
34
34
  const FROZEN = objectOf({
35
35
  genome: text,
36
- store: {
37
- type: 'object',
38
- properties: {
39
- key: bytes,
40
- sequence: count,
41
- end: count,
42
- slot: { enum: [0, 1] },
43
- sealed: count,
44
- pairs: listOf(objectOf({ key: bytes, value: bytes })),
45
- },
46
- required: ['key', 'sequence', 'end', 'slot', 'pairs'],
47
- additionalProperties: false,
48
- },
36
+ store: objectOf({
37
+ key: bytes,
38
+ sequence: count,
39
+ end: count,
40
+ slot: { enum: [0, 1] },
41
+ sealed: count,
42
+ pairs: listOf(objectOf({ key: bytes, value: bytes })),
43
+ }),
49
44
  alarms: listOf(objectOf({ kind: { enum: ['wake', 'booting', 'expiry'] }, at: { type: 'number', minimum: 0 } })),
50
45
  bounds: listOf(objectOf({ far: text, bound: count })),
51
46
  carry: objectOf({
@@ -170,7 +165,7 @@ const storeOf = (fields ) => ({
170
165
  sequence: numberAt(fields, 'sequence'),
171
166
  end: numberAt(fields, 'end'),
172
167
  slot: numberAt(fields, 'slot') === 0 ? 0 : 1,
173
- sealed: typeof fields['sealed'] === 'number' ? fields['sealed'] : 0,
168
+ sealed: numberAt(fields, 'sealed'),
174
169
  pairs: recordsAt(fields, 'pairs').map((pair) => ({
175
170
  key: bytesAt(pair, 'key'),
176
171
  value: bytesAt(pair, 'value'),
@@ -67,7 +67,7 @@ import {
67
67
 
68
68
 
69
69
 
70
-
70
+
71
71
 
72
72
 
73
73
 
package/kit/brain/rig.js CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  committingOn,
14
14
  configurationOf,
15
15
  must,
16
+ freshSeed,
16
17
  passing,
17
18
  seeded,
18
19
 
@@ -167,7 +168,7 @@ const linkedOver = (
167
168
  const time = clockOver(clock, keptIn(cellsOf(cache, BRAIN, false)));
168
169
  const commits = ridingTime(found.commits, () => cellsOf(cache, BRAIN, true), time);
169
170
  const linked = wired({
170
- fills: { time, chance: seeded(7), queues: genomeQueues, codec, crypto, unlocker },
171
+ fills: { time, chance: seeded(freshSeed()), queues: genomeQueues, codec, crypto, unlocker },
171
172
  clock: time,
172
173
  configuration,
173
174
  shipped: GENOME_SHIPPED,
@@ -1,4 +1,5 @@
1
1
  import type { ChanceSeam } from '#seams';
2
+ export declare const freshSeed: () => number;
2
3
  export declare const seeded: (seed: number, draws?: Uint8Array[]) => ChanceSeam & {
3
4
  below(limit: number): number;
4
5
  };
@@ -1,6 +1,13 @@
1
1
  // SPDX-License-Identifier: FSL-1.1-ALv2
2
2
 
3
3
 
4
+ let fresh = 1000;
5
+
6
+ export const freshSeed = () => {
7
+ fresh += 1;
8
+ return fresh;
9
+ };
10
+
4
11
  export const seeded = (seed , draws ) => {
5
12
  let state = seed;
6
13
  const next = () => {
@@ -7,7 +7,7 @@ import { makeCommits, } from '../../genome/commits/
7
7
  import { memoryPages, } from '../pages/index.js';
8
8
  import { createStore, openStore, } from '../../genome/store/index.js';
9
9
  import { } from '../../cage/index.js';
10
- import { seeded } from './chance.js';
10
+ import { freshSeed, seeded } from './chance.js';
11
11
  import { WALL, } from './clock.js';
12
12
  import { WASM } from './wasm.js';
13
13
 
@@ -58,7 +58,7 @@ export const STILL_TIME = {
58
58
 
59
59
  export const storeGearOf = (
60
60
  memory = memoryPages(),
61
- seed = 1,
61
+ seed = freshSeed(),
62
62
  time = STILL_TIME,
63
63
  ) => ({
64
64
  pages: memory.pages,
@@ -1,4 +1,4 @@
1
- export { seeded } from './chance.js';
1
+ export { freshSeed, seeded } from './chance.js';
2
2
  export { dataFrom, type Draw } from './data.js';
3
3
  export { clockOf, WALL, type Clock } from './clock.js';
4
4
  export { configurationOf } from './configuration.js';
package/kit/core/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: FSL-1.1-ALv2
2
- export { seeded } from './chance.js';
2
+ export { freshSeed, seeded } from './chance.js';
3
3
  export { dataFrom, } from './data.js';
4
4
  export { clockOf, WALL, } from './clock.js';
5
5
  export { configurationOf } from './configuration.js';
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: FSL-1.1-ALv2
2
2
  import { nobleCrypto, read, readInvitation, seal, standingOn, } from '#quo';
3
- import { seeded } from '../core/index.js';
3
+ import { freshSeed, seeded } from '../core/index.js';
4
4
  import { HOST_SCHEMES } from './carriers.js';
5
5
 
6
6
 
@@ -10,7 +10,7 @@ import { HOST_SCHEMES } from './carriers.js';
10
10
 
11
11
 
12
12
 
13
- export const peerOf = (text , seed = 21) => {
13
+ export const peerOf = (text , seed = freshSeed()) => {
14
14
  const invitation = readInvitation(text, HOST_SCHEMES);
15
15
  if (invitation === null) throw new Error('rig: the text is no invitation');
16
16
  const chance = seeded(seed);
@@ -1,4 +1,4 @@
1
- import type { BridgeTransportSeam, CarriersSeam, Configuration, Fills, Init, Start, UnlockerSeam, VitalsSeam } from '#seams';
1
+ import type { BridgeTransportSeam, CarriersSeam, ChanceSeam, Configuration, Fills, Init, Start, UnlockerSeam, VitalsSeam } from '#seams';
2
2
  import { type Answer, type Data } from '#standard';
3
3
  import { type Clock } from '../core/index.js';
4
4
  import { type MemoryPages } from '../pages/index.js';
@@ -26,6 +26,7 @@ export type Gear = {
26
26
  readonly configuration?: Configuration;
27
27
  readonly init?: Init;
28
28
  readonly seed?: number;
29
+ readonly chance?: ChanceSeam;
29
30
  readonly key?: Uint8Array;
30
31
  readonly upgrade?: Start['upgrade'];
31
32
  };
@@ -3,6 +3,7 @@ import { nobleCrypto } from '#quo';
3
3
 
4
4
 
5
5
 
6
+
6
7
 
7
8
 
8
9
 
@@ -13,7 +14,16 @@ import { nobleCrypto } from '#quo';
13
14
  import { admits, isFields, } from '#standard';
14
15
  import { laidOf, withFaculties } from './laid.js';
15
16
  import { genomeCodec } from '../../cage/codec/index.js';
16
- import { BOOT_KEY, clockOf, configurationOf, passing, seeded, startedOn, } from '../core/index.js';
17
+ import {
18
+ BOOT_KEY,
19
+ clockOf,
20
+ configurationOf,
21
+ freshSeed,
22
+ passing,
23
+ seeded,
24
+ startedOn,
25
+
26
+ } from '../core/index.js';
17
27
  import { memoryPages, } from '../pages/index.js';
18
28
  import { puppetEngine, } from '../puppet/index.js';
19
29
  import { genomeQueues } from '../../genome/queues/index.js';
@@ -106,8 +116,10 @@ const fieldOf = (data , key ) => (isFields(data) ? (data[key]
106
116
 
107
117
 
108
118
 
109
-
119
+
110
120
 
121
+
122
+
111
123
 
112
124
 
113
125
 
@@ -202,11 +214,14 @@ const answered = (method , answer ) => {
202
214
  };
203
215
 
204
216
  export const rigOver = async (wasm , faculties , options = {}) => {
205
- const { seed = 1, memory = memoryPages(), init = { kind: 'first-install' } } = options;
217
+ const { seed = freshSeed(), memory = memoryPages(), init = { kind: 'first-install' } } = options;
206
218
  const clock = clockOf();
207
219
  if (options.wall !== undefined) clock.setWall(options.wall);
208
220
  const { carriers, door, vitals, hearing } = options;
209
- const fills = fillsOf(memory, clock, faculties, seed, carriers, door, vitals, hearing);
221
+ const fills = {
222
+ ...fillsOf(memory, clock, faculties, seed, carriers, door, vitals, hearing),
223
+ chance: options.chance ?? seeded(seed),
224
+ };
210
225
  const { start, configured } = beginOf(options, faculties, fills, init);
211
226
  const made = await startedOn(clock, () => memory.pending() > 0, startOn(options.form ?? 'device', start, wasm));
212
227
  if (!('started' in made)) throw new Error(`rig: the organism is not started: ${made.why}`);
@@ -242,7 +257,9 @@ export const rigOver = async (wasm , faculties , options
242
257
  },
243
258
  restart: (gear = {}) => {
244
259
  memory.crash();
245
- return rigOver(wasm, faculties, againOf(options, gear, { seed, memory, configured }));
260
+ const again = againOf(options, gear, { seed, memory, configured });
261
+ const handed = gear.seed !== undefined || gear.chance !== undefined;
262
+ return rigOver(wasm, faculties, handed ? again : { ...again, chance: fills.chance });
246
263
  },
247
264
  };
248
265
  };
@@ -8,7 +8,7 @@ import { CONSOLE, SCREEN, } from '../../genome/presence/index
8
8
  import { KIT_SKINS, } from './skins.js';
9
9
  import { consoleHalf, } from './console-half.js';
10
10
  import { screenHalf, } from './screen-half.js';
11
- import { BOOT_KEY, clockOf, configurationOf, passing, seeded, startedOn, WASM } from '../core/index.js';
11
+ import { BOOT_KEY, clockOf, configurationOf, freshSeed, passing, seeded, startedOn, WASM } from '../core/index.js';
12
12
  import { startOn, } from '../organism/forms.js';
13
13
  import { fillsOf, heldCarriers, startOf, } from '../organism/rig.js';
14
14
  import { memoryPages, } from '../pages/index.js';
@@ -98,15 +98,11 @@ export const DESKTOP = desktopOf(KIT_SKINS);
98
98
 
99
99
  const stood = new WeakMap ();
100
100
 
101
- const FIRST_SEED = 1000;
102
- let homes = 0;
103
-
104
101
  const chanceOn = (memory , seed ) => {
105
102
  const held = stood.get(memory);
106
103
  if (held !== undefined) return held;
107
104
  const draws = [];
108
- homes += 1;
109
- const drawn = seeded(seed ?? FIRST_SEED + homes);
105
+ const drawn = seeded(seed ?? freshSeed());
110
106
  const chance = {
111
107
  draw: (length) => {
112
108
  const bytes = drawn.draw(length);
@@ -65,7 +65,7 @@ const wiresIn = (data ) =>
65
65
 
66
66
 
67
67
 
68
-
68
+
69
69
 
70
70
 
71
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nervur.org/genome",
3
- "version": "0.37.6",
3
+ "version": "0.37.8",
4
4
  "description": "What every Nervur organism is, on every host: the brain, the lobes and their engine, the store, Quo, and the seams a host fills. 0.x, unstable.",
5
5
  "keywords": [
6
6
  "agents",
@@ -265,7 +265,7 @@ export const gathered = async (
265
265
 
266
266
 
267
267
 
268
-
268
+
269
269
 
270
270
 
271
271
 
@@ -38,7 +38,7 @@ export const LOBE_MEMORY = 32 * 1024 * 1024;
38
38
 
39
39
 
40
40
 
41
-
41
+
42
42
 
43
43
 
44
44
 
@@ -5,7 +5,7 @@ import { checkMethod, fieldOf, } from './method.js';
5
5
 
6
6
 
7
7
 
8
-
8
+
9
9
 
10
10
 
11
11
 
@@ -1,2 +1,2 @@
1
1
  // SPDX-License-Identifier: FSL-1.1-ALv2
2
- export const GENOME_VERSION = '0.37.6';
2
+ export const GENOME_VERSION = '0.37.8';