@ibgib/ts-gib 0.4.9

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 (87) hide show
  1. package/.vscode/launch.json +24 -0
  2. package/.vscode/settings.json +34 -0
  3. package/.vscode/tasks.json +37 -0
  4. package/CHANGELOG.md +159 -0
  5. package/README.md +502 -0
  6. package/dist/V1/constants.d.mts +22 -0
  7. package/dist/V1/constants.d.mts.map +1 -0
  8. package/dist/V1/constants.mjs +21 -0
  9. package/dist/V1/constants.mjs.map +1 -0
  10. package/dist/V1/factory.d.mts +23 -0
  11. package/dist/V1/factory.d.mts.map +1 -0
  12. package/dist/V1/factory.mjs +78 -0
  13. package/dist/V1/factory.mjs.map +1 -0
  14. package/dist/V1/index.d.mts +6 -0
  15. package/dist/V1/index.d.mts.map +1 -0
  16. package/dist/V1/index.mjs +6 -0
  17. package/dist/V1/index.mjs.map +1 -0
  18. package/dist/V1/sha256v1.d.mts +19 -0
  19. package/dist/V1/sha256v1.d.mts.map +1 -0
  20. package/dist/V1/sha256v1.mjs +86 -0
  21. package/dist/V1/sha256v1.mjs.map +1 -0
  22. package/dist/V1/transforms/fork.d.mts +16 -0
  23. package/dist/V1/transforms/fork.d.mts.map +1 -0
  24. package/dist/V1/transforms/fork.mjs +111 -0
  25. package/dist/V1/transforms/fork.mjs.map +1 -0
  26. package/dist/V1/transforms/index.d.mts +5 -0
  27. package/dist/V1/transforms/index.d.mts.map +1 -0
  28. package/dist/V1/transforms/index.mjs +5 -0
  29. package/dist/V1/transforms/index.mjs.map +1 -0
  30. package/dist/V1/transforms/mut8.d.mts +50 -0
  31. package/dist/V1/transforms/mut8.d.mts.map +1 -0
  32. package/dist/V1/transforms/mut8.mjs +246 -0
  33. package/dist/V1/transforms/mut8.mjs.map +1 -0
  34. package/dist/V1/transforms/rel8.d.mts +14 -0
  35. package/dist/V1/transforms/rel8.d.mts.map +1 -0
  36. package/dist/V1/transforms/rel8.mjs +176 -0
  37. package/dist/V1/transforms/rel8.mjs.map +1 -0
  38. package/dist/V1/transforms/transform-helper.d.mts +92 -0
  39. package/dist/V1/transforms/transform-helper.d.mts.map +1 -0
  40. package/dist/V1/transforms/transform-helper.mjs +189 -0
  41. package/dist/V1/transforms/transform-helper.mjs.map +1 -0
  42. package/dist/V1/types.d.mts +79 -0
  43. package/dist/V1/types.d.mts.map +1 -0
  44. package/dist/V1/types.mjs +12 -0
  45. package/dist/V1/types.mjs.map +1 -0
  46. package/dist/helper.d.mts +77 -0
  47. package/dist/helper.d.mts.map +1 -0
  48. package/dist/helper.mjs +179 -0
  49. package/dist/helper.mjs.map +1 -0
  50. package/dist/index.cjs +4 -0
  51. package/dist/index.cjs.map +1 -0
  52. package/dist/index.d.cts +4 -0
  53. package/dist/index.d.cts.map +1 -0
  54. package/dist/index.d.mts +4 -0
  55. package/dist/index.d.mts.map +1 -0
  56. package/dist/index.mjs +4 -0
  57. package/dist/index.mjs.map +1 -0
  58. package/dist/types.d.mts +242 -0
  59. package/dist/types.d.mts.map +1 -0
  60. package/dist/types.mjs +2 -0
  61. package/dist/types.mjs.map +1 -0
  62. package/jasmine-browser.json +18 -0
  63. package/jasmine.json +6 -0
  64. package/package.json +61 -0
  65. package/src/V1/constants.mts +23 -0
  66. package/src/V1/factory.mts +110 -0
  67. package/src/V1/factory.spec.mts +162 -0
  68. package/src/V1/index.mts +5 -0
  69. package/src/V1/sha256v1.mts +85 -0
  70. package/src/V1/sha256v1.spec.mts +221 -0
  71. package/src/V1/transforms/fork.mts +100 -0
  72. package/src/V1/transforms/fork.spec.mts +410 -0
  73. package/src/V1/transforms/index.mts +4 -0
  74. package/src/V1/transforms/mut8.mts +239 -0
  75. package/src/V1/transforms/mut8.spec.mts +656 -0
  76. package/src/V1/transforms/rel8.mts +173 -0
  77. package/src/V1/transforms/rel8.spec.mts +556 -0
  78. package/src/V1/transforms/transform-helper.mts +263 -0
  79. package/src/V1/transforms/transform-helper.spec.mts +45 -0
  80. package/src/V1/types.mts +84 -0
  81. package/src/helper.mts +192 -0
  82. package/src/helper.spec.mts +127 -0
  83. package/src/index.cts +3 -0
  84. package/src/index.mts +3 -0
  85. package/src/types.mts +242 -0
  86. package/tsconfig.json +15 -0
  87. package/tsconfig.test.json +10 -0
package/README.md ADDED
@@ -0,0 +1,502 @@
1
+ # ibgib
2
+
3
+ This is the core part of the ibgib engine, written in TypeScript.
4
+ This is responsible for creating quantum ibgib frames based on
5
+ existing ibgib quanta.
6
+
7
+ ## data structure: `ib`, `gib`, `data`, `rel8ns`
8
+
9
+ Each ibgib can be thought of both as individual nodes in a Merkle DAG, and as
10
+ streams through time with those individual nodes as reified discrete quanta.
11
+
12
+ Each quantum node has up to four fields, and each field in one word:
13
+
14
+ * `ib` - metadata
15
+ * `gib` - checksum
16
+ * `data` - internals
17
+ * `rel8ns` - externals
18
+
19
+ This is extremely terse and naive of course. Here are slight more fleshed out
20
+ descriptions of each field.
21
+
22
+ * `ib`
23
+ * data and metadata
24
+ * contains simple, core data you want to see _without loading the entire datum into memory_.
25
+ * Especially important when viewing only a linked relationship ib^gib address.
26
+ * `gib`
27
+ * metadata
28
+ * for complex data, this is the hash of the datum's other three fields
29
+ * so for
30
+
31
+ ```json
32
+ {
33
+ "ib": "bob",
34
+ "data": {
35
+ "bday": "1/1/1"
36
+ },
37
+ "rel8ns": {
38
+ "past": ["bob^OLDHASH123456HOOGLEDYBOOGLEDY"]
39
+ }
40
+ }
41
+ ```
42
+
43
+ , the gib could be the hash of the concatenated hashes of the `ib`, `data` and `rel8ns`, e.g. `hash(hash(ib)+hash(data)+hash(rel8ns))
44
+ * for primitives (e.g. '7' or '"some string"'), implied 'gib' value
45
+ * so if you see 'test^gib', this implies { ib: test, gib: falsy or 'gib', data: falsy, rel8ns: falsy }
46
+ * `data`
47
+ * intrinsic 'simple' primitive data.
48
+ * e.g. `data: { name: "arthur", age: 42 }`
49
+ * You can nest primitive-ish data objects, depending on your use case.
50
+ * `rel8ns`
51
+ * extrinsic 'complex' data
52
+ * named lists of merkle pointers to other content addressable ibgibs via their `ib^gib` addresses.
53
+ * e.g. `"rel8ns": { "past": ["bob^OLDHASH123456HOOGLEDYBOOGLEDY"] }`
54
+ * depending on type of rel8ns you're using, this can be ...
55
+ * a single pointer like a linked list or blockchain style.
56
+ * multiple pointers like a hash table.
57
+ * these pointers are cryptographic merkle links to immutable frames
58
+ but in practice often point to a timeline of a mutable ibgib entity.
59
+
60
+ Here is more detailed information about these fields.
61
+
62
+ ### `ib`
63
+
64
+ The `ib` is for data and/or metadata that you want to be included in pointers
65
+ to the ibgib record. The entirety of this field will be used, in combination with
66
+ the `gib`, to uniquely identify an ibgib at a particular moment in "time". (Time
67
+ meaning the ibgib's own recorded mutations form a timeline, not necessarily wall time.)
68
+
69
+ In these examples, I'll give the `ib` and a corresponding possible `ib^gib` address
70
+ using gib placeholders like 'ABC123' which correspond to cryptographic hashes.
71
+
72
+ * simple
73
+ * '[name]' or '[title]' or '[filename]'
74
+ * 'bob' > 'bob^ABC123'
75
+ * 'Life, The Universe, Everything' > 'Life, The Universe, Everything^DEF456'
76
+ * 'foo.txt' > 'foo.txt^GHI789'
77
+ * more complex
78
+ * '[name] [date]' or '[filename] [username]'
79
+ * 'bob 1/1/2001' > 'bob 1/1/2001^XYZ321'
80
+ * 'foo.txt bob' > 'foo.txt bob^DDD444'
81
+ * real world complex
82
+ * 'tx [id] [token] [flag] [mask] [attempts]'
83
+ * 'tx 123 JWThErE12x.y.z_no_spaces T 0110 1^AAA111'
84
+ * 'tx 345 JWThErE12x.y.z_no_spaces T 0110 999^BBB284'
85
+ * 'rx|[id]|[token]|[flag]|[mask]|[retries-left]'
86
+ * 'rx|321|JWT_we can have spaces now in the token..|0|0101|3'
87
+
88
+ **NOTHING IS HARD CODED IN THE BASE GRAPH LIB REGARDING SCHEMAS.**
89
+
90
+ With the ibgib protocol, you can have your version control specs on-chain.
91
+ One of these specs can be a canon/template/schema for the `ib` field, or you can keep the
92
+ structure of the ib off-chain (but lose the usefulness of on-chain-ness).
93
+ This includes how the ib is delimited. For example, I often space-delimit the ib's
94
+ various pieces, which themselves are underscore or hyphen delimited. Since
95
+ the ib is much like a filename, it is often convenient to consider which
96
+ characters are allowed in which OSes you will want to interop with.
97
+
98
+ ### `gib`
99
+
100
+ For starters, you can simply think of this as the hash of the other three fields.
101
+ It provides integrity of the record by default, and helps in building out
102
+ ibgib's version of a Merkle DAG.
103
+
104
+ ### `rel8ns`
105
+
106
+ The `rel8ns` is a mapping of relationships among ibgibs, in a very similar
107
+ manner to edges/links in a graph. It's not quite the same, because the
108
+ graph is NOT just a DAG (directed acyclic graph), but we'll get to that.
109
+
110
+ #### a note on `ib^gib` addresses
111
+
112
+ Ibgib has a content addressable design. This means that we create an
113
+ address that is directly (and deterministically) related to the content
114
+ of the data.
115
+
116
+ In many other content addressing systems, only the hash is used, with some
117
+ using hard-coded metadata tacked on post-hoc and hard-coded in source code.
118
+ Ibgibs however use the `ib` field plus a delimiter (`^` by default) and the
119
+ `gib`, often referred to just as its `ib^gib`.
120
+
121
+ _This allows for on-chain, use-case driven decisions for exactly what metadata to include with the addresses!_
122
+
123
+ I've found over the years of programming with this approach that this is
124
+ ludicrously useful for making decisions in functions, algorithms and workflows
125
+ without requiring the resources to fully load a datum.
126
+
127
+ #### `rel8ns` structure V1
128
+
129
+ So the `rel8ns` themselves have the structure of rel8n names to arrays of
130
+ `ib^gib` addresses.
131
+
132
+ ```json
133
+ "rel8ns": {
134
+ "[rel8nName]": ["ib^gib address", "ib^gib2", "ib^1ac45ff5631f4a98a2148e24abc534d3"], // <<< general form
135
+ "past": ["bob^OLDHASH123456HOOGLEDYBOOGLEDY"],
136
+ "ancestor": ["bob^gib"],
137
+ "tjp": ["bob^OLDHASH123456HOOGLEDYBOOGLEDY"],
138
+ "friend": ["alice^34a807c927d84068af2e8b1cd24b4cb8", "charlie^0b54e0760c54441285374125563ef672", ],
139
+ }
140
+ ```
141
+
142
+ There are a couple special rel8n names here: `past`, `ancestor` and `tjp`.
143
+
144
+ #### `past` rel8n
145
+
146
+ Ibgib is largely an append-only system very much like other version control systems.
147
+ _(I often conceive it as a semantic version control system, not hyperoptimized for text)_
148
+ Whenever you add/remove/edit an ibgib's property (`ib`, `data` or `rel8ns`), you are
149
+ mutating that ibgib across "time". That timeline is defined in the ibgib's terms
150
+ as its past. This is like what some other systems call an audit log, or like the previous links
151
+ of a blockchain. But it isn't - not in ibgib's terms. It is much more appropriate to think of
152
+ the ibgib as an entity progressing through time, and the record is like an echo/metric/projection
153
+ of that entity in our data space(s).
154
+
155
+ _The data is never the ibgib though!_
156
+
157
+ So when we notice a change of the ibgib either intrinsically (its `data` field)
158
+ or extrinsically (via its `rel8ns` to other ibgibs), we record a new ibgib datum/frame/quantum
159
+ with those changed intrinsic/extrinsic attributes and link the record to the previous one
160
+ via the `past` rel8n, either by appending the previous to the current frame's `past`
161
+ rel8n (which costs more in terms of storage resources), or by replacing the
162
+ `past` array with the single `ib^gib` address of the previous incarnation.
163
+ If the former, then we are growing the record each time, which will cost us
164
+ more resources in terms of storage but will provide quicker access to previous
165
+ frames. If the latter, which is more a blockchain linked-list style, then we
166
+ inevitably use less storage because it's always just one address, but it will
167
+ cost more to traverse the linked list both in terms of memory and processing costs.
168
+
169
+ This tradeoff between rel8n style is not just with the `past` rel8n but can be
170
+ with any rel8n you desire per use case.
171
+
172
+ Append style (default):
173
+ ```json
174
+ {
175
+ "past": [""],
176
+ }
177
+ // mut8 or rel8 transform
178
+ {
179
+ "past": ["bob^OLDHASH123456HOOGLEDYBOOGLEDY"],
180
+ }
181
+ // mut8 or rel8 transform
182
+ {
183
+ "past": ["bob^OLDHASH123456HOOGLEDYBOOGLEDY", "bob^070e3fc9aab34f4ba1090f9519d9676a"],
184
+ }
185
+ // mut8 or rel8 transform
186
+ {
187
+ "past": ["bob^OLDHASH123456HOOGLEDYBOOGLEDY", "bob^070e3fc9aab34f4ba1090f9519d9676a", "bob^e556d72ace93428a98d222c960135e29"],
188
+ }
189
+ ```
190
+
191
+ See how it keeps growing? That will cost us in the long run in storage if we expect a lot of records.
192
+
193
+ Linked style (via `linkedRel8ns` parameter):
194
+
195
+ ```json
196
+ {
197
+ "past": [""],
198
+ }
199
+ // mut8 or rel8 transform
200
+ {
201
+ "past": ["bob^OLDHASH123456HOOGLEDYBOOGLEDY"],
202
+ }
203
+ // mut8 or rel8 transform
204
+ {
205
+ "past": ["bob^070e3fc9aab34f4ba1090f9519d9676a"],
206
+ }
207
+ // mut8 or rel8 transform
208
+ {
209
+ "past": ["bob^e556d72ace93428a98d222c960135e29"],
210
+ }
211
+ ```
212
+
213
+ In this case, we simply have a single rel8n to only the previous frame of the ibgib's existence,
214
+ much like a linked list or a blockchain. This will save in terms of storage, but we
215
+ will need to load each previous record in order to get the prior one. To combat this,
216
+ and for many other reasons, the `tjp` rel8n is required which is a pointer to the
217
+ very first unique address of the ibgib. But first, the `ancestor` rel8n.
218
+
219
+ #### `ancestor` rel8n
220
+
221
+ Creating "new" ibgibs is actually a process of `fork`-ing existing ones, with
222
+ theoretically something "brand new" being a fork of the root ibgib
223
+ (with the actual address of `ib^gib`). When we perform this `fork` transform
224
+ (we'll get to that), we will clear out the `past` rel8n and add the source
225
+ ibgib to the `ancestor` rel8n.
226
+
227
+ _NOTE: If we're forking from the root, we'll leave `ancestor` empty just to save space, but whenever you see an empty array, it's always populated with at least `ib^gib`!_
228
+
229
+ So while an ibgib mutating intrinsically (via `mut8` transform) or extrinsically (via `rel8` transform) will append to its
230
+ `past` rel8n, a `fork` transform will clear the `past` and append to the `ancestor` rel8n. (This ain't your
231
+ grandpa's blockchain!)
232
+
233
+ #### `tjp` rel8n
234
+
235
+ Have you ever seen Back to the Future II? Do you remember the scene where Biff steals the Delorean
236
+ and goes back to 1955 - **the same point in time Marty went back to in Back to the Future I!!!**
237
+
238
+ Doc Brown calls that the Temporal Junction Point (or maybe it's just a coincidence). So that's what
239
+ I've called it. But that is extremely long to write, and it's so important that the terse `tjp` is
240
+ acceptable (I usually vehemently eschew variable names so short, if you don't mind a few $5 words).
241
+
242
+ So it turns out that this is **extremely** important. When you want to refer to an instance in time
243
+ for an ibgib, then you can refer to its `ib^gib` address. But when you want to refer to the _timeline_
244
+ of an ibgib, then you refer to its temporal junction point (`tjp`). This is used, for example,
245
+ in tracking the latest version of an ibgib. Also for subscribing to changes to an ibgib.
246
+
247
+ #### `dna` rel8n
248
+
249
+ If you choose, you can capture not only the ibgib frames in the ibgib timeline, but also the
250
+ "code" that was used to create each proceeding frame.
251
+
252
+ See the following section on transforms for more info.
253
+
254
+ ### `data`
255
+
256
+ This is where you "link" to intrinsic, usually primitive data. For example, say you had
257
+
258
+ ```json
259
+ "data": {
260
+ "name": "Bob",
261
+ "favoriteNumber": 42,
262
+ }
263
+ ```
264
+
265
+ You could think of both "Bob" and 42 as being "Bob"^gib and 42^gib, so these indeed are
266
+ "rel8ns" to these primitives similar to the `rel8ns` property.
267
+
268
+ But for the most part, it's easiest to just think of the `data` as containing the
269
+ "actual" reified, simple data payloads.
270
+
271
+ ## transforms
272
+
273
+ The three primary low-level transforms are: `fork`, `mut8` and `rel8`.
274
+
275
+ Each is encapsulated in an ibgib record of its own, and if you choose to track the
276
+ transform, its transform `ib^gib` address will be related to the newly created ibgib
277
+ via the special `dna` rel8n name.
278
+
279
+ For those familiar with event sourcing, this is quite similar to memo-izing both
280
+ the events and the aggregate values. The primary proximal benefit of this design however,
281
+ beyond those we get from the ibgib architecture in general, is that unlike with
282
+ event sourcing, we can apply this dna not only to rehydrate to produce the same
283
+ output, but to reapply to a different ibGib (or the same ibgib in a different space)
284
+ specifically to produce _different_ output.
285
+
286
+ Think applying diffs to different branches during merges...but instead of only
287
+ working in the text level, we're working at the semantic level!
288
+
289
+ _(We can optimize for storage through other methods such as compression of less used ibgibs...it's relatively easy to index them since we're using content addressing to begin with.)_
290
+
291
+ ### `fork` transform
292
+
293
+ When we `fork` an ibgib A, we create a "new" ibgib B. This clears out `B.rel8ns.past`
294
+ and appends A's address to `B.rel8ns.ancestor` (remember all hashes are just made up here):
295
+
296
+ ```
297
+ // source A that we will `fork`
298
+ {
299
+ "ib": "A",
300
+ "gib": "ed4ce4c485b84bdb95c59affbefc138e",
301
+ "rel8ns": {
302
+ "past": ["A^fbb1369596684e61ad093f33486ed615, A^7464b055d8524b638818aabab078e146, A^a96e9afc41c04245ad02036f7c1f7b53],
303
+ "ancestor": [], // implied "ib^gib", but not too important :-0
304
+ "dna": []
305
+ },
306
+ "data": {
307
+ "foo": "bar",
308
+ "bar": "bazzz"
309
+ }
310
+ }
311
+
312
+ // transform T
313
+ {
314
+ "ib": "fork",
315
+ "gib": "bebbe34768434d909fc1ca3ab47c0b9f",
316
+ "data": {
317
+ "type": "fork",
318
+ "srcAddr": "A^ed4ce4c485b84bdb95c59affbefc138e",
319
+ "destIb": "B",
320
+ "dna": true,
321
+ ...
322
+ },
323
+ "rel8ns": {
324
+ "ancestor": ["fork^gib"] // ancestry often acts as a "type" hierarchy
325
+ ...
326
+ }
327
+ }
328
+
329
+ // output B produced by the `fork`
330
+ {
331
+ "ib": "B", // new ib
332
+ "gib": "f94448aa676d4d398241b80575c8e31e",
333
+ "rel8ns": {
334
+ "past": [], // cleared
335
+ "ancestor": ["a^ed4ce4c485b84bdb95c59affbefc138e"], // added source address
336
+ "dna": ["fork^bebbe34768434d909fc1ca3ab47c0b9f"]
337
+ },
338
+ "data": { // same data
339
+ "foo": "bar",
340
+ "bar": "bazzz"
341
+ }
342
+ }
343
+ // output B
344
+ ```
345
+
346
+ In this example, we `fork` with source A (A^ed4ce4c485b84bdb95c59affbefc138e), with
347
+ `fork` transform T (fork^bebbe34768434d909fc1ca3ab47c0b9f), specifying a new ib "B" (`T.data.destIb`),
348
+ and it produced the "new" B with a cleared `B.rel8ns.past`. We didn't _have_ to give it a new
349
+ ib, that's just to point out that these are two distinct timelines.
350
+
351
+ _The hierarchy via `ancestor` is also its own kind of "timeline", but that's for another time._
352
+
353
+ ### `mut8` transform
354
+
355
+ ### `rel8` transform
356
+
357
+ ## so what
358
+
359
+ ### v bitcoin
360
+
361
+ nothing.
362
+
363
+ But if that's not exciting enough for you, ibgib was developed for distributed
364
+ computation apart from the bitcoin world. Here are just some of the design decision
365
+ differences:
366
+
367
+ * consensus is off-chain (or rather on-chain in git which itself is another Merkle DAG)
368
+ * PoW is hard-coded
369
+ * thus PoW is naive (in the computation sense), since it requires huge effort to recode/move to some other proof.
370
+ * the source code is not part of the blockchain
371
+ * so it's open src, and it's open data, but the src and data live in silos.
372
+ * centralized in the source code.
373
+ * you're at the mercy of their coders to write the one chain to rule them all.
374
+ * these lead to consequences that make things like data projection & replication
375
+ extremely non-trivial, let alone MANY other opportunity costs with technical debt.
376
+
377
+ What's good about bitcoin? Well it's awesome and still in wide use across the globe.
378
+ PoW was extremely novel and cool.
379
+
380
+ ### v permissioned blockchains/DLTs
381
+
382
+ Basically, people are taking the blockchain/distributed ledger paradigm and trying
383
+ to apply it to other forms of distributed computing. without exception, each of these
384
+ starts by writing source code that is stored in a separate distributed ledger (called
385
+ git or [insert vcs here]) with no plan on dogfooding the source code back into the
386
+ process. Now you have to write and maintain code for (at least) both your source code
387
+ and your data, whereas you should be able to reuse code analysis/replication/identity
388
+ tools in a streamlined fashion.
389
+
390
+ For example, if I write a view that presents data in a certain way, I might now use
391
+ that same view to look at other data (possibly the code for the view itself) with
392
+ little-to-no modification. And if I am a learner
393
+
394
+ ...anyway, lotsa writing. I invariably seem to write these kinds of things to get
395
+ the brain going, but I digress...
396
+
397
+ ## contributing
398
+
399
+ ### to add unit tests (specs)
400
+
401
+ Add a file in the same folder as the one you want to test.
402
+ Copy the filename and add .spec just before the extension,
403
+ e.g. src/folder/file-here.ts -> src/folder/file-here.spec.ts
404
+
405
+ ## questions
406
+
407
+ ### what is an ibgib?
408
+
409
+ what isn't?
410
+
411
+ ### no really...
412
+
413
+ Semi-structured (JSON) data structure which creates a DLT graph with directed,
414
+ non-directed, cyclic and acyclic qualities. Very much like a semantic version
415
+ control system on a graph substrate to "track" "things".
416
+
417
+ ### attention and devil's advocate
418
+
419
+ Think of the dynamic between our brain's process of "attention" and
420
+ the possibility of "playing devil's advocate". Essentially, you can
421
+ either point your attention at some "thing" where you think of
422
+ extending that same thing over time, or you can think of "splitting"
423
+ that thing and considering the result to be some "new" thing.
424
+
425
+ But each of these actions (and other permutations and actions not listed)
426
+ itself can be one of those "things". So you can devolve and never extend
427
+ anything, where everything is essentially meaningless. Or you can
428
+ go the other way and say how everything is still the same (one) thing.
429
+
430
+ But we experience time as a combination of these two options, always with
431
+ the ability to use our own attention to increase the sameness or
432
+ different-ness of any thing.
433
+
434
+ ### semantic version control system
435
+
436
+ Computer people usually think of version control systems like
437
+ git, OpenCVS, subversion, etc. These usually borrow jargon from
438
+ the evolution of a river or a plant through time, e.g. branching,
439
+ forking, root. But these were developed with source control specifically
440
+ in mind, and they have been hyper-optimized for dealing with text.
441
+ Git has added on non-textual functionality, but it was an afterthought.
442
+
443
+ ibgib has been made as a self-referencing, bootstrapping semantic
444
+ version control system, and more fundamentally, the protocol that
445
+ underlies this system. By this, all configuration, source code,
446
+ issue tracking, etc., can be stored _inside_ the ibgib data
447
+ structures and using ibgib nodal exchanges.
448
+
449
+ You can think of the data structure as a Directed Acyclic Graph (DAG),
450
+ but this is only at the physical level **and does not capture
451
+ the cyclic nature of the ability for ibgibs over time to be
452
+ self-referencing** _(and self-negating and other self-thingies)_.
453
+
454
+ Two of the big focus points are:
455
+ 1) Each datum is from some perspective, i.e. it's a belief held by an identity.
456
+ 2) Each datum has context where it is "true" and where it is "false", which actually
457
+ defines what these terms mean.
458
+
459
+ Truth/falseness is determined by the attention on a thing, i.e. wherever
460
+ the ibgibs that continue to evolve and persist, those are said to be
461
+ "true within that context". Each context itself can be an ibgib, and
462
+ this framework provides an addressing scheme/space for this process of attention
463
+ that streamlines interaction between microservices/systems, ais, humans,
464
+ multi-human organizations, etc. It also does a lot of other stuff.
465
+
466
+ Ibgibs are also mobile, and can move among contexts proactively,
467
+ in addition to the contexts themselves changing over time.
468
+
469
+ ### goedelian numbers counting to infinity
470
+
471
+ For the even more abstract out there (can't imagine many here on Earth): Each ibgib
472
+ datum is a goedelian number. The `ib^gib` (content) address ends up being this number,
473
+ and what we are actually doing is counting through time to infinity. But things
474
+ "at" infinity act differently than in the finite world.
475
+
476
+ When you "add" a number, the number was already there from some other context. This
477
+ stems from the existence of one infinity not only implies but requires _all infinities_
478
+ "to exist". But we experience this process over time. So it also requires that
479
+ _all infinities_ "do NOT exist".
480
+
481
+ Remember the aforementioned attention? This is where we resolve the issue of seemingly
482
+ self-negating statements, e.g., "This statement is false." If you think of this naively
483
+ with the dead concept of true/false, then you run into a problem. Most scientists and
484
+ mathematicians dislike this, just as they dislike most quantum outcomes - a feeling
485
+ which manifests itself as these effects being "weird". But back to the attention.
486
+
487
+ "Both" pathways through a self-negating statement are "true" in some context,
488
+ and as such when you are also in "that" context, you will attend to that pathway.
489
+ You will provide more time to it _within you yourself as a context_.
490
+
491
+ Just as you have competing thoughts and emotions (terms which are much more
492
+ easily understood with the concept of ibgib) within yourself which can seem to be
493
+ diametrically opposed, so any statement can be. This can lead to understanding the
494
+ difficulties with current friction between, e.g., pure and applied mathematicians.
495
+ Context for "proofs" is absolutely paramount: Under this condition X,Y,Z using these
496
+ axioms, etc. But neither axioms, nor their corollaries or proofs, are "true"
497
+ absolutely. If you agree with this, then it is true within your context. On down
498
+ the road of your life, when you disagree with this, it is false within your context.
499
+ Etc...
500
+
501
+ Enough typing for now, back to coding. Feel free (future and past beings), jump in with
502
+ your isomorphic ibgib engines in the chat, or email me at bill.mybiz@gmail.com .
@@ -0,0 +1,22 @@
1
+ import { IbGib_V1 } from './types.mjs';
2
+ export declare const IB = "ib";
3
+ export declare const GIB = "gib";
4
+ export declare const ROOT: IbGib_V1;
5
+ export declare const IBGIB_DELIMITER = "^";
6
+ /**
7
+ * Gib is often just a single hash for a single ib^gib record.
8
+ * But if the ibgib has a tjp, which implies a timeline ("stream"
9
+ * in some senses), then we will include the tjp gib hash alongside the
10
+ * individual punctilear ibgib frame.
11
+ *
12
+ * ATOW this has the default schema of
13
+ *
14
+ * @example "comment abc^TJPHASH123", "comment abc^TJPHASH123.THISRECORDHASH456"
15
+ */
16
+ export declare const GIB_DELIMITER = ".";
17
+ export declare const ROOT_ADDR = "ib^gib";
18
+ /**
19
+ * Some rel8ns should not be able to be renamed or removed.
20
+ */
21
+ export declare const FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES: string[];
22
+ //# sourceMappingURL=constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/V1/constants.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,eAAO,MAAM,EAAE,OAAO,CAAC;AACvB,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,IAAI,EAAE,QAAgC,CAAA;AACnD,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,MAAM,CAAC;AACjC,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC;;GAEG;AACH,eAAO,MAAM,uCAAuC,UAAqC,CAAC"}
@@ -0,0 +1,21 @@
1
+ export const IB = 'ib';
2
+ export const GIB = 'gib';
3
+ export const ROOT = { ib: IB, gib: GIB, };
4
+ export const IBGIB_DELIMITER = '^';
5
+ /**
6
+ * Gib is often just a single hash for a single ib^gib record.
7
+ * But if the ibgib has a tjp, which implies a timeline ("stream"
8
+ * in some senses), then we will include the tjp gib hash alongside the
9
+ * individual punctilear ibgib frame.
10
+ *
11
+ * ATOW this has the default schema of
12
+ *
13
+ * @example "comment abc^TJPHASH123", "comment abc^TJPHASH123.THISRECORDHASH456"
14
+ */
15
+ export const GIB_DELIMITER = '.';
16
+ export const ROOT_ADDR = 'ib^gib'; // `${IB}${IBGIB_DELIMITER}${GIB}`;
17
+ /**
18
+ * Some rel8ns should not be able to be renamed or removed.
19
+ */
20
+ export const FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES = ['past', 'ancestor', 'dna', 'tjp'];
21
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/V1/constants.mts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;AACvB,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AACzB,MAAM,CAAC,MAAM,IAAI,GAAa,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AACnC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,mCAAmC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Ib, IbGib, IbGibRel8ns, TransformResult, TemporalJunctionPointOptions } from '../types.mjs';
2
+ import { IbGib_V1 } from './types.mjs';
3
+ export declare class Factory_V1 {
4
+ static root(): IbGib_V1<import("./types.mjs").IbGibData_V1, import("./types.mjs").IbGibRel8ns_V1>;
5
+ static primitive({ ib }: {
6
+ ib: Ib;
7
+ }): IbGib_V1;
8
+ static primitives({ ibs }: {
9
+ ibs: Ib[];
10
+ }): IbGib_V1<import("./types.mjs").IbGibData_V1, import("./types.mjs").IbGibRel8ns_V1>[];
11
+ static firstGen<TData = any>({ ib, parentIbGib, data, rel8ns, dna, tjp, linkedRel8ns, noTimestamp, nCounter, }: {
12
+ ib: Ib;
13
+ parentIbGib: IbGib;
14
+ data?: TData;
15
+ rel8ns?: IbGibRel8ns;
16
+ dna?: boolean;
17
+ tjp?: TemporalJunctionPointOptions;
18
+ linkedRel8ns?: string[];
19
+ noTimestamp?: boolean;
20
+ nCounter?: boolean;
21
+ }): Promise<TransformResult<IbGib_V1<import("./types.mjs").IbGibData_V1, import("./types.mjs").IbGibRel8ns_V1>>>;
22
+ }
23
+ //# sourceMappingURL=factory.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.mts","sourceRoot":"","sources":["../../src/V1/factory.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,qBAAa,UAAU;IACnB,MAAM,CAAC,IAAI;IAGX,MAAM,CAAC,SAAS,CAAC,EACb,EAAE,EACL,EAAE;QACC,EAAE,EAAE,EAAE,CAAA;KACT,GAAG,QAAQ;IAIZ,MAAM,CAAC,UAAU,CAAC,EACd,GAAG,EACN,EAAE;QACC,GAAG,EAAE,EAAE,EAAE,CAAA;KACZ;WAIY,QAAQ,CAAC,KAAK,GAAG,GAAG,EAAE,EAC/B,EAAO,EACP,WAA+B,EAC/B,IAAI,EACJ,MAAM,EACN,GAAG,EACH,GAAG,EACH,YAAY,EACZ,WAAW,EACX,QAAQ,GACX,EAAE;QACC,EAAE,EAAE,EAAE,CAAC;QACP,WAAW,EAAE,KAAK,CAAC;QACnB,IAAI,CAAC,EAAE,KAAK,CAAC;QACb,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,GAAG,CAAC,EAAE,4BAA4B,CAAC;QACnC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACtB;CA8DJ"}
@@ -0,0 +1,78 @@
1
+ import { fork } from './transforms/fork.mjs';
2
+ import { mut8 } from './transforms/mut8.mjs';
3
+ import { rel8 } from './transforms/rel8.mjs';
4
+ import { IB, GIB, ROOT } from './constants.mjs';
5
+ export class Factory_V1 {
6
+ static root() {
7
+ return Factory_V1.primitive({ ib: IB });
8
+ }
9
+ static primitive({ ib }) {
10
+ return { ib, gib: GIB };
11
+ }
12
+ static primitives({ ibs }) {
13
+ return ibs.map(ib => Factory_V1.primitive({ ib }));
14
+ }
15
+ static async firstGen({ ib = IB, parentIbGib = Factory_V1.root(), data, rel8ns, dna, tjp, linkedRel8ns, noTimestamp, nCounter, }) {
16
+ const lc = `[firstGen]`;
17
+ /** * Multiple transform steps will create multiple results. */
18
+ const interimResults = [];
19
+ let src = parentIbGib || ROOT;
20
+ let resFork = await fork({
21
+ src,
22
+ destIb: ib,
23
+ tjp,
24
+ dna,
25
+ linkedRel8ns,
26
+ noTimestamp,
27
+ nCounter,
28
+ });
29
+ interimResults.push(resFork);
30
+ src = resFork.newIbGib;
31
+ if (data) {
32
+ let resMut8 = await mut8({
33
+ src,
34
+ dataToAddOrPatch: data,
35
+ dna,
36
+ linkedRel8ns,
37
+ noTimestamp,
38
+ nCounter,
39
+ });
40
+ interimResults.push(resMut8);
41
+ src = resMut8.newIbGib;
42
+ }
43
+ ;
44
+ if (rel8ns) {
45
+ let resRel8 = await rel8({
46
+ src,
47
+ rel8nsToAddByAddr: rel8ns,
48
+ dna,
49
+ linkedRel8ns,
50
+ noTimestamp,
51
+ nCounter,
52
+ });
53
+ interimResults.push(resRel8);
54
+ // src = resRel8.newIbGib; // not needed because not used (this is the last step)
55
+ }
56
+ if (interimResults.length > 1) {
57
+ const newIbGib = interimResults.slice(interimResults.length - 1)[0].newIbGib;
58
+ const result = {
59
+ newIbGib,
60
+ intermediateIbGibs: interimResults.slice(0, interimResults.length - 1).map(x => x.newIbGib),
61
+ };
62
+ if (dna) {
63
+ let dnas = [];
64
+ interimResults.forEach(res => { dnas = dnas.concat(res.dnas); });
65
+ result.dnas = dnas;
66
+ }
67
+ return result;
68
+ }
69
+ else if (interimResults.length === 1) {
70
+ // for some reason the caller just used this as a fork.
71
+ return interimResults[0];
72
+ }
73
+ else {
74
+ throw new Error(`${lc} hmm, I'm not sure...`);
75
+ }
76
+ }
77
+ }
78
+ //# sourceMappingURL=factory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.mjs","sourceRoot":"","sources":["../../src/V1/factory.mts"],"names":[],"mappings":"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"}
@@ -0,0 +1,6 @@
1
+ export * from './sha256v1.mjs';
2
+ export * from './factory.mjs';
3
+ export * from './types.mjs';
4
+ export * from './constants.mjs';
5
+ export * from './transforms/index.mjs';
6
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/V1/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}