@ibgib/core-gib 0.1.38 → 0.1.40
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.
- package/dist/common/other/graph-helper.d.mts.map +1 -1
- package/dist/common/other/graph-helper.mjs +18 -3
- package/dist/common/other/graph-helper.mjs.map +1 -1
- package/dist/sync/graft-info/graft-info-helpers.mjs +1 -1
- package/dist/sync/graft-info/graft-info-helpers.mjs.map +1 -1
- package/dist/sync/sync-conflict-adv-multitimelines.respec.mjs +321 -235
- package/dist/sync/sync-conflict-adv-multitimelines.respec.mjs.map +1 -1
- package/dist/sync/sync-conflict-basic-multitimelines.respec.mjs +6 -6
- package/dist/sync/sync-conflict-basic-multitimelines.respec.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +49 -12
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +4 -0
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
- package/dist/test-helpers.d.mts +104 -47
- package/dist/test-helpers.d.mts.map +1 -1
- package/dist/test-helpers.mjs +335 -131
- package/dist/test-helpers.mjs.map +1 -1
- package/dist/test-types.d.mts +25 -7
- package/dist/test-types.d.mts.map +1 -1
- package/dist/witness/space/reconciliation-space/reconciliation-space-helper.mjs +2 -2
- package/dist/witness/space/reconciliation-space/reconciliation-space-helper.mjs.map +1 -1
- package/package.json +1 -1
- package/src/common/other/graph-helper.mts +14 -2
- package/src/sync/SYNC_TESTING.md +135 -70
- package/src/sync/graft-info/graft-info-helpers.mts +1 -1
- package/src/sync/sync-conflict-adv-multitimelines.respec.mts +332 -245
- package/src/sync/sync-conflict-basic-multitimelines.respec.mts +5 -5
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +1 -1
- package/src/sync/sync-saga-coordinator.mts +58 -14
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +4 -0
- package/src/test-helpers.mts +429 -152
- package/src/test-types.mts +30 -7
- package/src/witness/space/reconciliation-space/reconciliation-space-helper.mts +2 -2
- package/tmp.md +205 -1160
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
1
|
+
import { clone, extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
2
2
|
import { getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
|
|
3
3
|
import { mut8 } from "@ibgib/ts-gib/dist/V1/transforms/mut8.mjs";
|
|
4
4
|
import { rel8 } from "@ibgib/ts-gib/dist/V1/transforms/rel8.mjs";
|
|
@@ -85,7 +85,7 @@ export async function applyTransforms({ src, createdIbGibs_Running, dnaAddrsToAp
|
|
|
85
85
|
}
|
|
86
86
|
// we have our dna to apply, so do so against the incoming src
|
|
87
87
|
// any transform options is actually the dna.data plus src info.
|
|
88
|
-
let argTransform = dnaIbGib.data;
|
|
88
|
+
let argTransform = clone(dnaIbGib.data);
|
|
89
89
|
argTransform.src = src;
|
|
90
90
|
argTransform.srcAddr = getIbGibAddr({ ibGib: src });
|
|
91
91
|
let resTransform;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconciliation-space-helper.mjs","sourceRoot":"","sources":["../../../../src/witness/space/reconciliation-space/reconciliation-space-helper.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;
|
|
1
|
+
{"version":3,"file":"reconciliation-space-helper.mjs","sourceRoot":"","sources":["../../../../src/witness/space/reconciliation-space/reconciliation-space-helper.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MA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AC/D,kEAAkE;YAClE,8DAA8D;YAC9D,IAAI,CAAC,YAAY,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvC,IAAI,CAAC,YAAY,CAAC,IAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,EAAE,CAAC;oBACpE,mKAAmK;oBACnK,MAAM,IAAI,KAAK,CAAC,GAAG,EAAE,sFAAsF,cAAc,wCAAwC,CAAC,CAAC;gBACvK,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,yEAAyE,cAAc,uCAAuC,CAAC,CAAA;YACrJ,CAAC;YAGD,mBAAmB;YACnB,OAAO,MAAM,eAAe,CAAC;gBACzB,GAAG,EAAE,YAAY,CAAC,QAAQ;gBAC1B,qBAAqB;gBACrB,8CAA8C,EAAE,8CAA8C;gBAC9F,cAAc;aACjB,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACJ,wBAAwB;YACxB,4CAA4C;YAC5C,IAAI,qBAAqB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,6MAA6M,CAAC,CAAA;YACpO,CAAC;YACD,OAAO,GAAG,CAAC;QACf,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibgib/core-gib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"description": "ibgib core functionality, including base architecture for witnesses, spaces, apps, robbots, etc., as well as shared utility functions. Node v19+ needed for heavily-used isomorphic webcrypto hashing consumed in both node and browsers.",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "individual",
|
|
@@ -372,8 +372,20 @@ async function getGraphProjection_getIbGibsInIbGibAddrs({
|
|
|
372
372
|
addrsToGet = addrsToGet.filter(x => !gottenAddrs.includes(x));
|
|
373
373
|
}
|
|
374
374
|
} else {
|
|
375
|
-
// failed,
|
|
376
|
-
|
|
375
|
+
// failed, maybe partial maybe completely
|
|
376
|
+
const gottenIbGibs: IbGib_V1[] = (resGetThese.rawResultIbGib as any).ibGibs ?? [];
|
|
377
|
+
if (gottenIbGibs.length > 0) {
|
|
378
|
+
// failed partial
|
|
379
|
+
gottenIbGibs.forEach(x => resIbGibs.push(x));
|
|
380
|
+
// resGetThese.ibGibs.forEach(x => ibGibs.push(x));
|
|
381
|
+
const gottenAddrs = gottenIbGibs.map(x => getIbGibAddr({ ibGib: x }));
|
|
382
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} got some.`) }
|
|
383
|
+
// got only some, prune addrsToGet for next retry (if any)
|
|
384
|
+
addrsToGet = addrsToGet.filter(x => !gottenAddrs.includes(x));
|
|
385
|
+
} else {
|
|
386
|
+
// failed completely, addrsToGet stays the same
|
|
387
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} failed. addrs: ${addrsToGet?.join(',')}`) }
|
|
388
|
+
}
|
|
377
389
|
}
|
|
378
390
|
retryCount++;
|
|
379
391
|
}
|
package/src/sync/SYNC_TESTING.md
CHANGED
|
@@ -1,37 +1,46 @@
|
|
|
1
1
|
# Sync Testing Guidelines
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
💣💥 USE THESE GUIDELINES TO MITIGATE COMPLEXITY EXPLOSION 💣💥
|
|
4
|
+
|
|
5
|
+
Sync needs thorough testing and complexity increases exponentially. Ridiculously
|
|
6
|
+
exponentially. I mean you won't believe just how vastly, hugely, mind-bogglingly
|
|
7
|
+
fast...
|
|
4
8
|
|
|
5
9
|
## Core Concepts
|
|
6
10
|
|
|
7
11
|
### Rounds
|
|
8
12
|
|
|
9
|
-
Tests are organized into **rounds
|
|
13
|
+
Tests are organized into **rounds**. Each round represents a complete cycle of:
|
|
10
14
|
1. **State Setup**: Establish expected initial conditions
|
|
11
15
|
2. **Actions**: Perform mutations, relations, and sync operations
|
|
12
16
|
3. **Verification**: Assert final state expectations
|
|
13
17
|
|
|
14
|
-
The **first round** establishes common history between source and dest
|
|
18
|
+
The **first round** is establishes common history between source and dest, and
|
|
19
|
+
subsequent rounds perform one or more op(s) and sync(s).
|
|
15
20
|
|
|
16
|
-
### Test Scenarios
|
|
21
|
+
### Broad Test Scenarios
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
Here are the broad category of ops that can occur to timelines WRT syncing:
|
|
24
|
+
* **Fast-Forward (Source Ahead)**: Source has newer versions that dest lacks
|
|
25
|
+
* **Fast-Forward (Dest Ahead)**: Dest has newer versions that source lacks
|
|
26
|
+
* **Conflict**: Both source and dest have divergent edits from a common ancestor
|
|
27
|
+
* **No Change**: Timeline exists on both sides with no edits
|
|
28
|
+
* **Stones**: Stones are treated slightly differently in the sync engine right
|
|
29
|
+
now, so these must also be tested in various permutations.
|
|
23
30
|
|
|
24
31
|
## Variable Naming Convention
|
|
25
32
|
|
|
26
|
-
|
|
33
|
+
Variable names are a COMBINATION of BOTH snake_case AND camelCase:
|
|
34
|
+
|
|
35
|
+
Format: `round_timeline_version_location_commentsHereInCamelCase_possiblyOtherComments`
|
|
27
36
|
|
|
28
37
|
### Components
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
* **Round**: `r1`, `r2`, `r3`, etc. (round number)
|
|
40
|
+
* **Timeline**: Greek letter (`alpha`, `beta`, `gamma`, `delta`, `epsilon`, etc.)
|
|
41
|
+
* **Version**: `v0`, `v1`, `v2`, etc. (from test POV, NOT necessarily matching `data.n`)
|
|
42
|
+
* **Location**: `source` or `dest` (where the ibgib was **created**, not where it currently exists)
|
|
43
|
+
* **Comments**: Optional descriptive suffixes (can chain multiple)
|
|
35
44
|
|
|
36
45
|
### Examples
|
|
37
46
|
|
|
@@ -51,38 +60,73 @@ r2_alpha_v4_dest_postConflict // Round 2, alpha v4 on dest, after
|
|
|
51
60
|
|
|
52
61
|
```typescript
|
|
53
62
|
await respecfully(sir, `Test Suite Name`, async () => {
|
|
54
|
-
//
|
|
63
|
+
// Setup Spaces, Coordinators, Peer, etc.
|
|
64
|
+
|
|
65
|
+
// #region Round 1 - Common History Establishment
|
|
55
66
|
|
|
56
|
-
//
|
|
57
|
-
// #region r1 source setup
|
|
58
|
-
// #endregion r1 source setup
|
|
67
|
+
// domain create/edits required before our verify pre state
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
const r1_alpha_v0_source_yada = await testTransformer.create({...});
|
|
70
|
+
const r1_beta_v0_source_yada = await testTransformer.create({...});
|
|
62
71
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
await ifWeMight(sir, 'alpha synced correctly', async () => {
|
|
72
|
+
await respecfully(sir, `r1 verify pre`, async () => {
|
|
73
|
+
await ifWe(sir, 'alpha exists in source and NOT exist on dest (or whatever)', async () => {
|
|
66
74
|
// timeline-specific assertions
|
|
67
75
|
});
|
|
68
|
-
await
|
|
76
|
+
await ifWe(sir, 'beta exists in source and NOT exist on dest (or whatever)', async () => {
|
|
69
77
|
// timeline-specific assertions
|
|
70
78
|
});
|
|
71
79
|
});
|
|
72
80
|
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
// do the sync(s) with possible other edit(s)
|
|
82
|
+
const r1_syncSaga = await senderCoordinator.sync({ ... });
|
|
83
|
+
|
|
84
|
+
await respecfully(sir, `r1 verify post`, async () => {
|
|
85
|
+
await ifWe(sir, 'alpha synced correctly', async () => {
|
|
86
|
+
// timeline-specific assertions
|
|
87
|
+
});
|
|
88
|
+
await ifWe(sir, 'beta synced correctly', async () => {
|
|
89
|
+
// timeline-specific assertions
|
|
90
|
+
});
|
|
91
|
+
});
|
|
76
92
|
|
|
77
|
-
// #
|
|
78
|
-
// #endregion r2 dest edits
|
|
93
|
+
// #endregion Round 1 - Common History Establishment
|
|
79
94
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
95
|
+
// #region Round 2 - Some divergent edits are synced
|
|
96
|
+
|
|
97
|
+
// domain create/edits required before our verify pre state
|
|
98
|
+
|
|
99
|
+
await respecfully(sir, `r2 verify pre`, async () => {
|
|
100
|
+
await ifWe(sir, 'latest alpha only on source', async () => {
|
|
101
|
+
// timeline-specific assertions
|
|
102
|
+
});
|
|
103
|
+
await ifWe(sir, 'beta still synced on source/dest', async () => {
|
|
104
|
+
// timeline-specific assertions
|
|
84
105
|
});
|
|
85
106
|
});
|
|
107
|
+
|
|
108
|
+
// do the sync(s) with possible other edit(s) which can be lengthy, so
|
|
109
|
+
// encapsulate in regions as needed
|
|
110
|
+
|
|
111
|
+
// #region r2 edits
|
|
112
|
+
|
|
113
|
+
const r2_alpha_v1_source_rel8dToBeta = testTransformer.rel8({...});
|
|
114
|
+
|
|
115
|
+
// #endregion r2 edits
|
|
116
|
+
|
|
117
|
+
const r2_syncSaga = await senderCoordinator.sync({ ... });
|
|
118
|
+
|
|
119
|
+
await respecfully(sir, `r2 verify post`, async () => {
|
|
120
|
+
await ifWe(sir, 'alpha synced correctly in some specific way', async () => {
|
|
121
|
+
// timeline-specific assertions
|
|
122
|
+
});
|
|
123
|
+
await ifWe(sir, 'beta synced correctly in some specific way', async () => {
|
|
124
|
+
// timeline-specific assertions
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// #endregion Round 2 - Common History Establishment
|
|
129
|
+
|
|
86
130
|
});
|
|
87
131
|
```
|
|
88
132
|
|
|
@@ -90,25 +134,29 @@ await respecfully(sir, `Test Suite Name`, async () => {
|
|
|
90
134
|
|
|
91
135
|
Use `// #region` and `// #endregion` tags to encapsulate **timeline edit groupings** within a round. This allows collapsing code sections to manage complexity.
|
|
92
136
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
137
|
+
Always include the round in a region tag, and the endregion tag should have the same exact text as the begin region tag.
|
|
138
|
+
|
|
139
|
+
Pattern examples:
|
|
140
|
+
* `// #region r{N} setup` - For initial timeline creation
|
|
141
|
+
* `// #region r{N} edits` - For mutations/relations within a round
|
|
96
142
|
|
|
97
143
|
### Verification Blocks
|
|
98
144
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
145
|
+
* **`respecfully`**: Outer verification block per round with text "r{N} verify pre/post"
|
|
146
|
+
* **`ifWeMight`**: Per-timeline verification within a round
|
|
147
|
+
* NOTE: Graphs should be used for verification of sync, not individual addrs/ibgibs
|
|
148
|
+
in most (all?) cases
|
|
149
|
+
* **`iReckon`**: Individual assertions
|
|
102
150
|
|
|
103
151
|
Example:
|
|
104
152
|
```typescript
|
|
105
153
|
await respecfully(sir, `r1 verify results`, async () => {
|
|
106
|
-
await
|
|
154
|
+
await ifWe(sir, 'alpha exists on both sides', async () => {
|
|
107
155
|
iReckon(sir, alphaOnSource).asTo('alpha on source').isGonnaBeTruthy();
|
|
108
156
|
iReckon(sir, alphaOnDest).asTo('alpha on dest').isGonnaBeTruthy();
|
|
109
157
|
});
|
|
110
158
|
|
|
111
|
-
await
|
|
159
|
+
await ifWe(sir, 'dependency graphs match', async () => {
|
|
112
160
|
const graphsMatch = graphsAreEquivalent({ graphA, graphB });
|
|
113
161
|
iReckon(sir, graphsMatch).asTo('graphs equivalent').isGonnaBeTrue();
|
|
114
162
|
});
|
|
@@ -118,10 +166,12 @@ await respecfully(sir, `r1 verify results`, async () => {
|
|
|
118
166
|
## Multiple Syncs Per Round
|
|
119
167
|
|
|
120
168
|
A single round can have **multiple sync calls**. This is useful when:
|
|
121
|
-
|
|
122
|
-
|
|
169
|
+
* Creating multiple timeline pairs (some on source, some on dest)
|
|
170
|
+
* Testing specific sync scenarios in isolation
|
|
123
171
|
|
|
124
|
-
Key principle: Verify **final state** at end of round, not intermediate states
|
|
172
|
+
Key principle: Verify **final state** at end of round, not intermediate states
|
|
173
|
+
between syncs. We don't want to get bogged down trying to test every detail
|
|
174
|
+
after every sync. The broad coverage should handle this.
|
|
125
175
|
|
|
126
176
|
```typescript
|
|
127
177
|
// Round 1: Establish common history
|
|
@@ -155,18 +205,30 @@ Advanced tests focus on **domain-level correctness**, not protocol mechanics:
|
|
|
155
205
|
4. **Minimal Commenting**: Rely on naming and structure over heavy comments
|
|
156
206
|
5. **Test Helpers**: Use helper functions to reduce boilerplate (see below)
|
|
157
207
|
|
|
158
|
-
### Test
|
|
208
|
+
### Test Transformer
|
|
159
209
|
|
|
160
|
-
|
|
210
|
+
Tests are making relatively arbitrary fork/mut8/rel8 calls. To help reduce
|
|
211
|
+
implementation detail noise, the `TestTransformer` helper class was created.
|
|
161
212
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
213
|
+
These methods return a `TestStepInfo` which itself has references to the `ibGib`
|
|
214
|
+
and `addr`, as well as other metadata. So the variable
|
|
215
|
+
`r2_alpha_v2_source_arbitraryMut8` does NOT reference an ibgib, rather, it
|
|
216
|
+
references one of these test step info objects.
|
|
166
217
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
const r2_beta_v0_source = await testTransformer.create({
|
|
221
|
+
ib: 'beta',
|
|
222
|
+
in: 'source',
|
|
223
|
+
data: { fieldA: 'beta field A created on source' },
|
|
224
|
+
name: 'r2_beta_v0_source'
|
|
225
|
+
});
|
|
226
|
+
const r2_alpha_v2_source_arbitraryMut8 = await testTransformer.mut8({
|
|
227
|
+
ibGib: r1_alpha_v1_source_common.ibGib, // refers to previous step.ibGib
|
|
228
|
+
in: 'source',
|
|
229
|
+
strField: 'fieldA',
|
|
230
|
+
name: 'r2_alpha_v2_source_arbitraryMut8'
|
|
231
|
+
});
|
|
170
232
|
```
|
|
171
233
|
|
|
172
234
|
See `test-helpers.mts` and `test-types.mts` for implementations.
|
|
@@ -174,27 +236,30 @@ See `test-helpers.mts` and `test-types.mts` for implementations.
|
|
|
174
236
|
## Scenarios to Test
|
|
175
237
|
|
|
176
238
|
### Basic Scenarios
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
239
|
+
* Fast-forward (source ahead)
|
|
240
|
+
* Fast-forward (dest ahead)
|
|
241
|
+
* Simple conflict (different fields edited)
|
|
242
|
+
* No changes
|
|
181
243
|
|
|
182
244
|
### Advanced Scenarios
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
245
|
+
* **Divergent edits on related ibgibs**: Alpha conflicts while beta (rel8'd from alpha) also conflicts
|
|
246
|
+
* **One-sided new timelines**: Timeline exists only on source or dest initially
|
|
247
|
+
* **Transitive dependencies**: Delta rel8'd from alpha, alpha rel8'd from beta
|
|
248
|
+
* **Reverse dependencies**: Timeline created on dest, source adds rel8n to it
|
|
249
|
+
* **Removal conflicts**: Source removes rel8n while dest mut8s the rel8'd ibgib
|
|
250
|
+
* **Chain edits**: Mutation → rel8 → mutation again on same timeline in one round
|
|
251
|
+
* **Text edits**: Edit ibGib.data.text. If this is found to be different in
|
|
252
|
+
divergent cases, then a special handler will try to merge the texts using
|
|
253
|
+
basic text merging algorithm.
|
|
189
254
|
|
|
190
255
|
## Summary
|
|
191
256
|
|
|
192
257
|
These guidelines aim to **minimize complexity** in necessarily complex integration tests through:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
258
|
+
* Consistent naming conventions
|
|
259
|
+
* Round-based mental model
|
|
260
|
+
* Region-based code organization
|
|
261
|
+
* Domain-level focus
|
|
262
|
+
* Helper function abstraction
|
|
263
|
+
* Clear verification patterns
|
|
199
264
|
|
|
200
265
|
When in doubt, prioritize **readability** and **maintainability** over brevity.
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { mut8 } from "@ibgib/ts-gib/dist/V1/transforms/mut8.mjs";
|
|
25
25
|
import { CommentData_V1 } from "../../common/comment/comment-types.mjs";
|
|
26
26
|
|
|
27
|
-
const logalot = GLOBAL_LOG_A_LOT;
|
|
27
|
+
const logalot = GLOBAL_LOG_A_LOT || true;
|
|
28
28
|
const lc = `[graft-info-helpers]`;
|
|
29
29
|
|
|
30
30
|
/**
|