rhachet 1.1.0
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/LICENSE +21 -0
- package/dist/__nonpublished_modules__/file-fns/src/getFile.d.ts +6 -0
- package/dist/__nonpublished_modules__/file-fns/src/getFile.js +14 -0
- package/dist/__nonpublished_modules__/file-fns/src/getFile.js.map +1 -0
- package/dist/__test_assets__/directory.d.ts +1 -0
- package/dist/__test_assets__/directory.js +5 -0
- package/dist/__test_assets__/directory.js.map +1 -0
- package/dist/__test_assets__/genContextLogTrail.d.ts +2 -0
- package/dist/__test_assets__/genContextLogTrail.js +12 -0
- package/dist/__test_assets__/genContextLogTrail.js.map +1 -0
- package/dist/__test_assets__/genContextStitchTrail.d.ts +2 -0
- package/dist/__test_assets__/genContextStitchTrail.js +8 -0
- package/dist/__test_assets__/genContextStitchTrail.js.map +1 -0
- package/dist/__test_assets__/getContextOpenAI.d.ts +2 -0
- package/dist/__test_assets__/getContextOpenAI.js +18 -0
- package/dist/__test_assets__/getContextOpenAI.js.map +1 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.d.ts +14 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.js +23 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.js.map +1 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.d.ts +16 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.js +29 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.js.map +1 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.d.ts +15 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.js +97 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.js.map +1 -0
- package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.d.ts +13 -0
- package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.js +33 -0
- package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.js.map +1 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.d.ts +13 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.js +45 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.js.map +1 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.d.ts +29 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.js +76 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.js.map +1 -0
- package/dist/__test_assets__/threads/codeArtist.d.ts +6 -0
- package/dist/__test_assets__/threads/codeArtist.js +26 -0
- package/dist/__test_assets__/threads/codeArtist.js.map +1 -0
- package/dist/__test_assets__/threads/codeCritic.d.ts +6 -0
- package/dist/__test_assets__/threads/codeCritic.js +21 -0
- package/dist/__test_assets__/threads/codeCritic.js.map +1 -0
- package/dist/__test_assets__/threads/director.d.ts +6 -0
- package/dist/__test_assets__/threads/director.js +14 -0
- package/dist/__test_assets__/threads/director.js.map +1 -0
- package/dist/contract/sdk.d.ts +8 -0
- package/dist/contract/sdk.js +33 -0
- package/dist/contract/sdk.js.map +1 -0
- package/dist/domain/objects/Stitch.d.ts +42 -0
- package/dist/domain/objects/Stitch.js +9 -0
- package/dist/domain/objects/Stitch.js.map +1 -0
- package/dist/domain/objects/StitchChoice.d.ts +30 -0
- package/dist/domain/objects/StitchChoice.js +8 -0
- package/dist/domain/objects/StitchChoice.js.map +1 -0
- package/dist/domain/objects/StitchCycle.d.ts +44 -0
- package/dist/domain/objects/StitchCycle.js +8 -0
- package/dist/domain/objects/StitchCycle.js.map +1 -0
- package/dist/domain/objects/StitchFanout.d.ts +35 -0
- package/dist/domain/objects/StitchFanout.js +8 -0
- package/dist/domain/objects/StitchFanout.js.map +1 -0
- package/dist/domain/objects/StitchRoute.d.ts +22 -0
- package/dist/domain/objects/StitchRoute.js +8 -0
- package/dist/domain/objects/StitchRoute.js.map +1 -0
- package/dist/domain/objects/StitchSetEvent.d.ts +23 -0
- package/dist/domain/objects/StitchSetEvent.js +8 -0
- package/dist/domain/objects/StitchSetEvent.js.map +1 -0
- package/dist/domain/objects/StitchStep.d.ts +55 -0
- package/dist/domain/objects/StitchStep.js +11 -0
- package/dist/domain/objects/StitchStep.js.map +1 -0
- package/dist/domain/objects/StitchTrail.d.ts +26 -0
- package/dist/domain/objects/StitchTrail.js +19 -0
- package/dist/domain/objects/StitchTrail.js.map +1 -0
- package/dist/domain/objects/Stitcher.d.ts +105 -0
- package/dist/domain/objects/Stitcher.js +49 -0
- package/dist/domain/objects/Stitcher.js.map +1 -0
- package/dist/domain/objects/Stitcher.test.d.ts +1 -0
- package/dist/domain/objects/Stitcher.test.js +78 -0
- package/dist/domain/objects/Stitcher.test.js.map +1 -0
- package/dist/domain/objects/Thread.d.ts +31 -0
- package/dist/domain/objects/Thread.js +11 -0
- package/dist/domain/objects/Thread.js.map +1 -0
- package/dist/domain/objects/Threads.d.ts +56 -0
- package/dist/domain/objects/Threads.js +26 -0
- package/dist/domain/objects/Threads.js.map +1 -0
- package/dist/domain/objects/Weave.d.ts +0 -0
- package/dist/domain/objects/Weave.js +2 -0
- package/dist/domain/objects/Weave.js.map +1 -0
- package/dist/domain/objects/Weaver.d.ts +5 -0
- package/dist/domain/objects/Weaver.js +7 -0
- package/dist/domain/objects/Weaver.js.map +1 -0
- package/dist/domain/objects/index.d.ts +11 -0
- package/dist/domain/objects/index.js +30 -0
- package/dist/domain/objects/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/logic/stitch/adapters/imagineViaOpenAI.d.ts +13 -0
- package/dist/logic/stitch/adapters/imagineViaOpenAI.js +36 -0
- package/dist/logic/stitch/adapters/imagineViaOpenAI.js.map +1 -0
- package/dist/logic/stitch/enstitch.d.ts +27 -0
- package/dist/logic/stitch/enstitch.js +97 -0
- package/dist/logic/stitch/enstitch.js.map +1 -0
- package/dist/logic/stitch/enstitch.test.d.ts +1 -0
- package/dist/logic/stitch/enstitch.test.js +87 -0
- package/dist/logic/stitch/enstitch.test.js.map +1 -0
- package/dist/logic/stitch/invokeImagineStitcher.d.ts +10 -0
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.d.ts +1 -0
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.js +193 -0
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.js.map +1 -0
- package/dist/logic/stitch/invokeImagineStitcher.js +23 -0
- package/dist/logic/stitch/invokeImagineStitcher.js.map +1 -0
- package/dist/logic/stitch/withStitchTrail.d.ts +16 -0
- package/dist/logic/stitch/withStitchTrail.js +40 -0
- package/dist/logic/stitch/withStitchTrail.js.map +1 -0
- package/dist/logic/thread/enroleThread.d.ts +4 -0
- package/dist/logic/thread/enroleThread.js +6 -0
- package/dist/logic/thread/enroleThread.js.map +1 -0
- package/dist/logic/thread/genThread.d.ts +7 -0
- package/dist/logic/thread/genThread.js +10 -0
- package/dist/logic/thread/genThread.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.d.ts +17 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.js +3 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js +67 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.d.ts +18 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.js +3 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js +132 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.d.ts +23 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.js +3 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js +74 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.d.ts +24 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.js +3 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js +190 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.d.ts +36 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.js +3 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.js.map +1 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js +29 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.d.ts +65 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.js +3 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.js.map +1 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.test.js +420 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/asStitcher.d.ts +12 -0
- package/dist/logic/weave/compose/asStitcher.js +15 -0
- package/dist/logic/weave/compose/asStitcher.js.map +1 -0
- package/dist/logic/weave/compose/asStitcher.test.d.ts +1 -0
- package/dist/logic/weave/compose/asStitcher.test.js +95 -0
- package/dist/logic/weave/compose/asStitcher.test.js.map +1 -0
- package/dist/logic/weave/compose/asStitcherFlat.d.ts +10 -0
- package/dist/logic/weave/compose/asStitcherFlat.js +13 -0
- package/dist/logic/weave/compose/asStitcherFlat.js.map +1 -0
- package/dist/logic/weave/compose/asStitcherFlat.test.d.ts +1 -0
- package/dist/logic/weave/compose/asStitcherFlat.test.js +96 -0
- package/dist/logic/weave/compose/asStitcherFlat.test.js.map +1 -0
- package/dist/logic/weave/compose/genStitchChoice.d.ts +22 -0
- package/dist/logic/weave/compose/genStitchChoice.js +23 -0
- package/dist/logic/weave/compose/genStitchChoice.js.map +1 -0
- package/dist/logic/weave/compose/genStitchChoice.test.d.ts +1 -0
- package/dist/logic/weave/compose/genStitchChoice.test.js +200 -0
- package/dist/logic/weave/compose/genStitchChoice.test.js.map +1 -0
- package/dist/logic/weave/compose/genStitchCycle.d.ts +28 -0
- package/dist/logic/weave/compose/genStitchCycle.js +30 -0
- package/dist/logic/weave/compose/genStitchCycle.js.map +1 -0
- package/dist/logic/weave/compose/genStitchCycle.test.d.ts +1 -0
- package/dist/logic/weave/compose/genStitchCycle.test.js +152 -0
- package/dist/logic/weave/compose/genStitchCycle.test.js.map +1 -0
- package/dist/logic/weave/compose/genStitchFanout.d.ts +17 -0
- package/dist/logic/weave/compose/genStitchFanout.js +21 -0
- package/dist/logic/weave/compose/genStitchFanout.js.map +1 -0
- package/dist/logic/weave/compose/genStitchFanout.test.d.ts +1 -0
- package/dist/logic/weave/compose/genStitchFanout.test.js +79 -0
- package/dist/logic/weave/compose/genStitchFanout.test.js.map +1 -0
- package/dist/logic/weave/compose/genStitchRoute.d.ts +15 -0
- package/dist/logic/weave/compose/genStitchRoute.js +20 -0
- package/dist/logic/weave/compose/genStitchRoute.js.map +1 -0
- package/dist/logic/weave/compose/genStitchRoute.test.d.ts +1 -0
- package/dist/logic/weave/compose/genStitchRoute.test.js +120 -0
- package/dist/logic/weave/compose/genStitchRoute.test.js.map +1 -0
- package/dist/logic/weave/enweave.d.ts +0 -0
- package/dist/logic/weave/enweave.js +2 -0
- package/dist/logic/weave/enweave.js.map +1 -0
- package/dist/logic/weave/enweaveAllStitchers.d.ts +0 -0
- package/dist/logic/weave/enweaveAllStitchers.js +2 -0
- package/dist/logic/weave/enweaveAllStitchers.js.map +1 -0
- package/dist/logic/weave/enweaveOneChoice.d.ts +14 -0
- package/dist/logic/weave/enweaveOneChoice.js +48 -0
- package/dist/logic/weave/enweaveOneChoice.js.map +1 -0
- package/dist/logic/weave/enweaveOneChoice.test.d.ts +1 -0
- package/dist/logic/weave/enweaveOneChoice.test.js +181 -0
- package/dist/logic/weave/enweaveOneChoice.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneCycle.d.ts +19 -0
- package/dist/logic/weave/enweaveOneCycle.js +98 -0
- package/dist/logic/weave/enweaveOneCycle.js.map +1 -0
- package/dist/logic/weave/enweaveOneCycle.test.d.ts +1 -0
- package/dist/logic/weave/enweaveOneCycle.test.js +180 -0
- package/dist/logic/weave/enweaveOneCycle.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneFanout.d.ts +12 -0
- package/dist/logic/weave/enweaveOneFanout.integration.test.d.ts +1 -0
- package/dist/logic/weave/enweaveOneFanout.integration.test.js +166 -0
- package/dist/logic/weave/enweaveOneFanout.integration.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneFanout.js +37 -0
- package/dist/logic/weave/enweaveOneFanout.js.map +1 -0
- package/dist/logic/weave/enweaveOneRoute.d.ts +12 -0
- package/dist/logic/weave/enweaveOneRoute.integration.test.d.ts +1 -0
- package/dist/logic/weave/enweaveOneRoute.integration.test.js +159 -0
- package/dist/logic/weave/enweaveOneRoute.integration.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneRoute.js +33 -0
- package/dist/logic/weave/enweaveOneRoute.js.map +1 -0
- package/dist/logic/weave/enweaveOneStitcher.d.ts +11 -0
- package/dist/logic/weave/enweaveOneStitcher.integration.test.d.ts +2 -0
- package/dist/logic/weave/enweaveOneStitcher.integration.test.js +258 -0
- package/dist/logic/weave/enweaveOneStitcher.integration.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneStitcher.js +42 -0
- package/dist/logic/weave/enweaveOneStitcher.js.map +1 -0
- package/package.json +88 -0
- package/readme.md +61 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StitchFanout, ThreadsFromFanout } from '../../../domain/objects/StitchFanout';
|
|
2
|
+
import { StitchStep } from '../../../domain/objects/StitchStep';
|
|
3
|
+
import { GStitcher, Stitcher } from '../../../domain/objects/Stitcher';
|
|
4
|
+
import { Threads } from '../../../domain/objects/Threads';
|
|
5
|
+
import { GStitcherInferredFromFanout } from './GStitcherInferredFromFanout.generic';
|
|
6
|
+
/**
|
|
7
|
+
* .what = generates a stitcher that fans out to multiple parallel stitchers, then concludes with a final one
|
|
8
|
+
* .why =
|
|
9
|
+
* - enables parallel feedback or computation from multiple perspectives
|
|
10
|
+
* - merges results into a final output via the concluding stitcher
|
|
11
|
+
*/
|
|
12
|
+
export declare const genStitchFanout: <TParallels extends readonly [Stitcher<GStitcher<Threads<any, "single">, any, any>>, ...Stitcher<GStitcher<Threads<any, "single">, any, any>>[]], TConcluder extends StitchStep<GStitcher<ThreadsFromFanout<GStitcherInferredFromFanout<TParallels, TConcluder>>, any, any>>>(input: {
|
|
13
|
+
slug: string;
|
|
14
|
+
readme: string | null;
|
|
15
|
+
parallels: TParallels;
|
|
16
|
+
concluder: TConcluder;
|
|
17
|
+
}) => StitchFanout<GStitcherInferredFromFanout<TParallels, TConcluder>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.genStitchFanout = void 0;
|
|
4
|
+
const StitchFanout_1 = require("../../../domain/objects/StitchFanout");
|
|
5
|
+
/**
|
|
6
|
+
* .what = generates a stitcher that fans out to multiple parallel stitchers, then concludes with a final one
|
|
7
|
+
* .why =
|
|
8
|
+
* - enables parallel feedback or computation from multiple perspectives
|
|
9
|
+
* - merges results into a final output via the concluding stitcher
|
|
10
|
+
*/
|
|
11
|
+
const genStitchFanout = (input) => {
|
|
12
|
+
return new StitchFanout_1.StitchFanout({
|
|
13
|
+
form: 'FANOUT',
|
|
14
|
+
slug: input.slug,
|
|
15
|
+
readme: input.readme,
|
|
16
|
+
parallels: input.parallels,
|
|
17
|
+
concluder: input.concluder,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
exports.genStitchFanout = genStitchFanout;
|
|
21
|
+
//# sourceMappingURL=genStitchFanout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genStitchFanout.js","sourceRoot":"","sources":["../../../../src/logic/weave/compose/genStitchFanout.ts"],"names":[],"mappings":";;;AAAA,uEAG8C;AAM9C;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAY7B,KAKD,EAAqE,EAAE;IACtE,OAAO,IAAI,2BAAY,CAAC;QACtB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,SAAgB;QACjC,SAAS,EAAE,KAAK,CAAC,SAAgB;KAClC,CAAC,CAAC;AACL,CAAC,CAAC;AAzBW,QAAA,eAAe,mBAyB1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
4
|
+
const test_fns_1 = require("test-fns");
|
|
5
|
+
const genContextLogTrail_1 = require("../../../__test_assets__/genContextLogTrail");
|
|
6
|
+
const genContextStitchTrail_1 = require("../../../__test_assets__/genContextStitchTrail");
|
|
7
|
+
const StitchStep_1 = require("../../../domain/objects/StitchStep");
|
|
8
|
+
const Thread_1 = require("../../../domain/objects/Thread");
|
|
9
|
+
const enweaveOneFanout_1 = require("../enweaveOneFanout");
|
|
10
|
+
const genStitchFanout_1 = require("./genStitchFanout");
|
|
11
|
+
describe('genStitchFanout type preservation', () => {
|
|
12
|
+
const context = { ...(0, genContextStitchTrail_1.genContextStitchTrail)(), ...(0, genContextLogTrail_1.genContextLogTrail)() };
|
|
13
|
+
(0, test_fns_1.given)('a fanout with two compute steps and a numeric concluder', () => {
|
|
14
|
+
const threadMain = new Thread_1.Thread({
|
|
15
|
+
context: { role: 'main' },
|
|
16
|
+
stitches: [],
|
|
17
|
+
});
|
|
18
|
+
const parallelA = new StitchStep_1.StitchStepCompute({
|
|
19
|
+
slug: 'random:a',
|
|
20
|
+
readme: null,
|
|
21
|
+
form: 'COMPUTE',
|
|
22
|
+
stitchee: 'main',
|
|
23
|
+
invoke: () => ({ input: null, output: 10 }),
|
|
24
|
+
});
|
|
25
|
+
const parallelB = new StitchStep_1.StitchStepCompute({
|
|
26
|
+
slug: 'random:b',
|
|
27
|
+
readme: null,
|
|
28
|
+
form: 'COMPUTE',
|
|
29
|
+
stitchee: 'main',
|
|
30
|
+
invoke: () => ({ input: null, output: 20 }),
|
|
31
|
+
});
|
|
32
|
+
const concluder = new StitchStep_1.StitchStepCompute({
|
|
33
|
+
slug: 'sum',
|
|
34
|
+
readme: null,
|
|
35
|
+
form: 'COMPUTE',
|
|
36
|
+
stitchee: 'main',
|
|
37
|
+
invoke: ({ threads }) => {
|
|
38
|
+
const numbers = [threads.main.seed, ...threads.main.peers].map((t) => t.stitches.at(-1)?.output ?? 0);
|
|
39
|
+
return {
|
|
40
|
+
input: numbers,
|
|
41
|
+
output: numbers.reduce((a, b) => a + b, 0),
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const stitcherFanout = (0, genStitchFanout_1.genStitchFanout)({
|
|
46
|
+
slug: 'test:fanout:sum',
|
|
47
|
+
readme: null,
|
|
48
|
+
parallels: [parallelA, parallelB],
|
|
49
|
+
concluder,
|
|
50
|
+
});
|
|
51
|
+
(0, test_fns_1.when)('used in enweaveOneFanout', () => {
|
|
52
|
+
(0, test_fns_1.then)('it should produce a stitch.output of type number and multiple threads', async () => {
|
|
53
|
+
const { stitch, threads } = await (0, enweaveOneFanout_1.enweaveOneFanout)({
|
|
54
|
+
stitcher: stitcherFanout,
|
|
55
|
+
threads: { main: threadMain },
|
|
56
|
+
}, context);
|
|
57
|
+
// ✅ Compile-time check: output is number
|
|
58
|
+
const testOutput = stitch.output;
|
|
59
|
+
// ✅ Compile-time check: threads.main is in single shape
|
|
60
|
+
const stitches = threads.main.stitches;
|
|
61
|
+
// ✅ Runtime check: sum = 30
|
|
62
|
+
expect(testOutput).toEqual(30);
|
|
63
|
+
expect(stitches.length);
|
|
64
|
+
});
|
|
65
|
+
(0, test_fns_1.then)('it should fail if you assume wrong output type', async () => {
|
|
66
|
+
await (0, helpful_errors_1.getError)(async () => {
|
|
67
|
+
const { stitch } = await (0, enweaveOneFanout_1.enweaveOneFanout)({
|
|
68
|
+
stitcher: stitcherFanout,
|
|
69
|
+
threads: { main: threadMain },
|
|
70
|
+
}, context);
|
|
71
|
+
// @ts-expect-error: stitch.output is number, not string
|
|
72
|
+
const wrongType = stitch.output;
|
|
73
|
+
expect(wrongType);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=genStitchFanout.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genStitchFanout.test.js","sourceRoot":"","sources":["../../../../src/logic/weave/compose/genStitchFanout.test.ts"],"names":[],"mappings":";;AAAA,mDAA0C;AAC1C,uCAA6C;AAG7C,oFAAiF;AACjF,0FAAuF;AAEvF,mEAAuE;AAEvE,2DAAwD;AAExD,0DAAuD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AE,cAAc;wBACxB,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;qBAC9B,EACD,OAAO,CACR,CAAC;oBAEF,wDAAwD;oBACxD,MAAM,SAAS,GAAW,MAAM,CAAC,MAAM,CAAC;oBACxC,MAAM,CAAC,SAAS,CAAC,CAAC;gBACpB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StitchRoute } from '../../../domain/objects/StitchRoute';
|
|
2
|
+
import { GStitcher, Stitcher } from '../../../domain/objects/Stitcher';
|
|
3
|
+
import { Threads } from '../../../domain/objects/Threads';
|
|
4
|
+
import { GStitcherInferredFromRoute } from './GStitcherInferredFromRoute.generic';
|
|
5
|
+
/**
|
|
6
|
+
* .what = generates a thoroughly typesafe stitch route
|
|
7
|
+
* .why =
|
|
8
|
+
* - ensures typescript considers the input stitcher sequence to infer a composite stitcher for the stitch route declaration
|
|
9
|
+
* - results in a composite superset type of threads and context, plus accurate output type, on the output
|
|
10
|
+
*/
|
|
11
|
+
export declare const genStitchRoute: <TSequence extends readonly [Stitcher<GStitcher<Threads<any, "single">, any, any>>, ...Stitcher<GStitcher<Threads<any, "single">, any, any>>[]]>(input: {
|
|
12
|
+
slug: string;
|
|
13
|
+
readme: string | null;
|
|
14
|
+
sequence: TSequence;
|
|
15
|
+
}) => StitchRoute<GStitcherInferredFromRoute<TSequence>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.genStitchRoute = void 0;
|
|
4
|
+
const StitchRoute_1 = require("../../../domain/objects/StitchRoute");
|
|
5
|
+
/**
|
|
6
|
+
* .what = generates a thoroughly typesafe stitch route
|
|
7
|
+
* .why =
|
|
8
|
+
* - ensures typescript considers the input stitcher sequence to infer a composite stitcher for the stitch route declaration
|
|
9
|
+
* - results in a composite superset type of threads and context, plus accurate output type, on the output
|
|
10
|
+
*/
|
|
11
|
+
const genStitchRoute = (input) => {
|
|
12
|
+
return new StitchRoute_1.StitchRoute({
|
|
13
|
+
form: 'ROUTE',
|
|
14
|
+
slug: input.slug,
|
|
15
|
+
readme: input.readme,
|
|
16
|
+
sequence: input.sequence,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.genStitchRoute = genStitchRoute;
|
|
20
|
+
//# sourceMappingURL=genStitchRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genStitchRoute.js","sourceRoot":"","sources":["../../../../src/logic/weave/compose/genStitchRoute.ts"],"names":[],"mappings":";;;AAAA,qEAAkE;AAKlE;;;;;GAKG;AACI,MAAM,cAAc,GAAG,CAK5B,KAID,EAAsD,EAAE;IACvD,OAAO,IAAI,yBAAW,CAAC;QACrB,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,KAAK,CAAC,QAAe;KAChC,CAAC,CAAC;AACL,CAAC,CAAC;AAhBW,QAAA,cAAc,kBAgBzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_fns_1 = require("test-fns");
|
|
4
|
+
const StitchStep_1 = require("../../../domain/objects/StitchStep");
|
|
5
|
+
const asStitcher_1 = require("./asStitcher");
|
|
6
|
+
const genStitchRoute_1 = require("./genStitchRoute");
|
|
7
|
+
describe('genStitchRoute type preservation', () => {
|
|
8
|
+
(0, test_fns_1.given)('a route with two compute steps on the same thread', () => {
|
|
9
|
+
const step1 = new StitchStep_1.StitchStepCompute({
|
|
10
|
+
slug: 'step-1',
|
|
11
|
+
readme: null,
|
|
12
|
+
form: 'COMPUTE',
|
|
13
|
+
stitchee: 'main',
|
|
14
|
+
invoke: () => ({ input: null, output: 1 }),
|
|
15
|
+
});
|
|
16
|
+
const check1 = true;
|
|
17
|
+
expect(check1);
|
|
18
|
+
const step2 = new StitchStep_1.StitchStepCompute({
|
|
19
|
+
slug: 'step-2',
|
|
20
|
+
readme: null,
|
|
21
|
+
form: 'COMPUTE',
|
|
22
|
+
stitchee: 'main',
|
|
23
|
+
invoke: () => ({ input: null, output: 2 }),
|
|
24
|
+
});
|
|
25
|
+
const check2 = true;
|
|
26
|
+
expect(check2);
|
|
27
|
+
const route = (0, genStitchRoute_1.genStitchRoute)({
|
|
28
|
+
slug: 'route:example',
|
|
29
|
+
readme: null,
|
|
30
|
+
sequence: [step1, step2],
|
|
31
|
+
});
|
|
32
|
+
(0, test_fns_1.when)('checking assignability to Stitcher<GStitcher>', () => {
|
|
33
|
+
(0, test_fns_1.then)('it should produce single threads', () => {
|
|
34
|
+
const isSingle = true;
|
|
35
|
+
expect(isSingle);
|
|
36
|
+
});
|
|
37
|
+
(0, test_fns_1.then)('it should produce a valid gstitcher', () => {
|
|
38
|
+
const isValid = true;
|
|
39
|
+
expect(isValid);
|
|
40
|
+
});
|
|
41
|
+
(0, test_fns_1.then)('it should be assignable to StitchRoute<T extends GStitcher>', () => {
|
|
42
|
+
const isAssignable = true;
|
|
43
|
+
expect(isAssignable);
|
|
44
|
+
});
|
|
45
|
+
(0, test_fns_1.then)('it cannot be assignable to StitchRoute<GStitcher>', () => {
|
|
46
|
+
// @ts-expect-error: due to Generic Invariance on Classes
|
|
47
|
+
const isAssignable = true;
|
|
48
|
+
expect(isAssignable);
|
|
49
|
+
});
|
|
50
|
+
(0, test_fns_1.then)('it should be assignable generically', () => {
|
|
51
|
+
const checkA = true;
|
|
52
|
+
expect(checkA);
|
|
53
|
+
const checkB = true;
|
|
54
|
+
expect(checkB);
|
|
55
|
+
const checkC = true;
|
|
56
|
+
expect(checkC);
|
|
57
|
+
});
|
|
58
|
+
(0, test_fns_1.then)('it cannot be assignable exactly', () => {
|
|
59
|
+
// @ts-expect-error: due to Generic Invariance on Classes
|
|
60
|
+
const checkA = true;
|
|
61
|
+
expect(checkA);
|
|
62
|
+
// @ts-expect-error: due to Generic Invariance on Classes
|
|
63
|
+
const checkB = true;
|
|
64
|
+
expect(checkB);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
(0, test_fns_1.then)('you can still cast it manually with loss of type safety', () => {
|
|
68
|
+
const forced = route;
|
|
69
|
+
expect(forced.slug).toBe('route:example');
|
|
70
|
+
});
|
|
71
|
+
(0, test_fns_1.then)('it should be assignable if you normalize threads to Threads<..., "single">', () => {
|
|
72
|
+
const normalized = route;
|
|
73
|
+
expect(normalized.slug).toBe('route:example');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
(0, test_fns_1.given)('a route within a route', () => {
|
|
77
|
+
const step1 = new StitchStep_1.StitchStepCompute({
|
|
78
|
+
slug: 'step-1',
|
|
79
|
+
readme: null,
|
|
80
|
+
form: 'COMPUTE',
|
|
81
|
+
stitchee: 'main',
|
|
82
|
+
invoke: () => ({ input: null, output: 1 }),
|
|
83
|
+
});
|
|
84
|
+
const step2 = new StitchStep_1.StitchStepCompute({
|
|
85
|
+
slug: 'step-2',
|
|
86
|
+
readme: null,
|
|
87
|
+
form: 'COMPUTE',
|
|
88
|
+
stitchee: 'main',
|
|
89
|
+
invoke: () => ({ input: null, output: 2 }),
|
|
90
|
+
});
|
|
91
|
+
const innerRoute = (0, genStitchRoute_1.genStitchRoute)({
|
|
92
|
+
slug: 'route:inner',
|
|
93
|
+
readme: null,
|
|
94
|
+
sequence: [step1, step2],
|
|
95
|
+
});
|
|
96
|
+
const outerRoute = (0, genStitchRoute_1.genStitchRoute)({
|
|
97
|
+
slug: 'route:outer',
|
|
98
|
+
readme: null,
|
|
99
|
+
sequence: [(0, asStitcher_1.asStitcher)(innerRoute)],
|
|
100
|
+
});
|
|
101
|
+
(0, test_fns_1.then)('innerRoute should be assignable to Stitcher<GStitcher>', () => {
|
|
102
|
+
const result = true;
|
|
103
|
+
expect(result);
|
|
104
|
+
});
|
|
105
|
+
(0, test_fns_1.then)('outerRoute should be assignable to Stitcher<GStitcher>', () => {
|
|
106
|
+
const result = true;
|
|
107
|
+
expect(result);
|
|
108
|
+
});
|
|
109
|
+
(0, test_fns_1.then)('innerRoute should be assignable to StitchRoute<GStitcher>', () => {
|
|
110
|
+
const result = true;
|
|
111
|
+
expect(result);
|
|
112
|
+
});
|
|
113
|
+
(0, test_fns_1.then)('outerRoute stitches should include the inner step structure', () => {
|
|
114
|
+
const slug = outerRoute.slug;
|
|
115
|
+
expect(slug).toBe('route:outer');
|
|
116
|
+
expect(outerRoute.sequence[0].slug).toBe('route:inner');
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=genStitchRoute.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genStitchRoute.test.js","sourceRoot":"","sources":["../../../../src/logic/weave/compose/genStitchRoute.test.ts"],"names":[],"mappings":";;AAAA,uCAA6C;AAK7C,mEAAuE;AAQvE,6CAA0C;AAC1C,qDAAkD;AAElD,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,IAAA,gBAAK,EAAC,mDAAmD,EAAE,GAAG,EAAE;QAC9D,MAAM,KAAK,GAAG,IAAI,8BAAiB,CAEjC;YACA,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;SAC3C,CAAC,CAAC;QACH,MAAM,MAAM,GACV,IAAI,CAAC;QACP,MAAM,CAAC,MAAM,CAAC,CAAC;QAEf,MAAM,KAAK,GAAG,IAAI,8BAAiB,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I,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enweave.js","sourceRoot":"","sources":["../../../src/logic/weave/enweave.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enweaveAllStitchers.js","sourceRoot":"","sources":["../../../src/logic/weave/enweaveAllStitchers.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StitchChoice } from '../../domain/objects/StitchChoice';
|
|
2
|
+
import { StitchSetEvent } from '../../domain/objects/StitchSetEvent';
|
|
3
|
+
import { GStitcher } from '../../domain/objects/Stitcher';
|
|
4
|
+
/**
|
|
5
|
+
* .what = executes a StitchChoice by first running the decider to choose an option, then running the chosen option
|
|
6
|
+
* .why =
|
|
7
|
+
* - enables runtime branching based on input, context, or prior stitches
|
|
8
|
+
* - helps model decision trees, dynamic workflows, and rule-based logic
|
|
9
|
+
* - separates decision logic (decider) from action logic (options)
|
|
10
|
+
*/
|
|
11
|
+
export declare const enweaveOneChoice: <TStitcher extends GStitcher>(input: {
|
|
12
|
+
stitcher: StitchChoice<TStitcher>;
|
|
13
|
+
threads: TStitcher['threads'];
|
|
14
|
+
}, context: TStitcher['context']) => Promise<StitchSetEvent<TStitcher['threads'], TStitcher['output']>>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enweaveOneChoice = void 0;
|
|
4
|
+
const uni_time_1 = require("@ehmpathy/uni-time");
|
|
5
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
6
|
+
const StitchSetEvent_1 = require("../../domain/objects/StitchSetEvent");
|
|
7
|
+
const withStitchTrail_1 = require("../stitch/withStitchTrail");
|
|
8
|
+
const enweaveOneStitcher_1 = require("./enweaveOneStitcher");
|
|
9
|
+
/**
|
|
10
|
+
* .what = executes a StitchChoice by first running the decider to choose an option, then running the chosen option
|
|
11
|
+
* .why =
|
|
12
|
+
* - enables runtime branching based on input, context, or prior stitches
|
|
13
|
+
* - helps model decision trees, dynamic workflows, and rule-based logic
|
|
14
|
+
* - separates decision logic (decider) from action logic (options)
|
|
15
|
+
*/
|
|
16
|
+
exports.enweaveOneChoice = (0, withStitchTrail_1.withStitchTrail)(async (input, context) => {
|
|
17
|
+
const { decider, options } = input.stitcher;
|
|
18
|
+
// run the decider
|
|
19
|
+
const { stitch: decisionStitch, threads: threadsAfterDecide } = await (0, enweaveOneStitcher_1.enweaveOneStitcher)({
|
|
20
|
+
stitcher: decider,
|
|
21
|
+
threads: input.threads,
|
|
22
|
+
}, context);
|
|
23
|
+
// grab the chosen stitcher slug
|
|
24
|
+
const slugChosen = decisionStitch.output?.choice?.slug;
|
|
25
|
+
if (typeof slugChosen !== 'string')
|
|
26
|
+
helpful_errors_1.UnexpectedCodePathError.throw('no slug chosen from decider', {
|
|
27
|
+
decisionStitch,
|
|
28
|
+
});
|
|
29
|
+
// find the chosen stitcher
|
|
30
|
+
const chosenStitcher = options.find((s) => s.slug === slugChosen) ??
|
|
31
|
+
helpful_errors_1.UnexpectedCodePathError.throw('could not find chosen option', {
|
|
32
|
+
decisionStitch,
|
|
33
|
+
slugChosen,
|
|
34
|
+
options: options.map((option) => option.slug),
|
|
35
|
+
});
|
|
36
|
+
// run the chosen stitcher
|
|
37
|
+
const { stitch: resultStitch, threads: threadsAfterChoice } = await (0, enweaveOneStitcher_1.enweaveOneStitcher)({
|
|
38
|
+
stitcher: chosenStitcher,
|
|
39
|
+
threads: threadsAfterDecide,
|
|
40
|
+
}, context);
|
|
41
|
+
// declare the result
|
|
42
|
+
return StitchSetEvent_1.StitchSetEvent.build({
|
|
43
|
+
occurredAt: (0, uni_time_1.asUniDateTime)(new Date()),
|
|
44
|
+
stitch: resultStitch,
|
|
45
|
+
threads: threadsAfterChoice,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=enweaveOneChoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enweaveOneChoice.js","sourceRoot":"","sources":["../../../src/logic/weave/enweaveOneChoice.ts"],"names":[],"mappings":";;;AAAA,iDAAmD;AACnD,mDAAyD;AAGzD,wEAAqE;AAErE,+DAA4D;AAC5D,6DAA0D;AAE1D;;;;;;GAMG;AACU,QAAA,gBAAgB,GAAG,IAAA,iCAAe,EAC7C,KAAK,EACH,KAGC,EACD,OAA6B,EACuC,EAAE;IACtE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;IAE5C,kBAAkB;IAClB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAC3D,MAAM,IAAA,uCAAkB,EACtB;QACE,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,EACD,OAAO,CACR,CAAC;IAEJ,gCAAgC;IAChC,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC;IACvD,IAAI,OAAO,UAAU,KAAK,QAAQ;QAChC,wCAAuB,CAAC,KAAK,CAAC,6BAA6B,EAAE;YAC3D,cAAc;SACf,CAAC,CAAC;IAEL,2BAA2B;IAC3B,MAAM,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;QAC1C,wCAAuB,CAAC,KAAK,CAAC,8BAA8B,EAAE;YAC5D,cAAc;YACd,UAAU;YACV,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;SAC9C,CAAC,CAAC;IAEL,0BAA0B;IAC1B,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,kBAAkB,EAAE,GACzD,MAAM,IAAA,uCAAkB,EACtB;QACE,QAAQ,EAAE,cAAc;QACxB,OAAO,EAAE,kBAAkB;KAC5B,EACD,OAAO,CACR,CAAC;IAEJ,qBAAqB;IACrB,OAAO,+BAAc,CAAC,KAAK,CAAC;QAC1B,UAAU,EAAE,IAAA,wBAAa,EAAC,IAAI,IAAI,EAAE,CAAC;QACrC,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE,kBAAkB;KAC5B,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const uni_time_1 = require("@ehmpathy/uni-time");
|
|
4
|
+
const test_fns_1 = require("test-fns");
|
|
5
|
+
const genContextLogTrail_1 = require("../../__test_assets__/genContextLogTrail");
|
|
6
|
+
const genContextStitchTrail_1 = require("../../__test_assets__/genContextStitchTrail");
|
|
7
|
+
const StitchStep_1 = require("../../domain/objects/StitchStep");
|
|
8
|
+
const genThread_1 = require("../thread/genThread");
|
|
9
|
+
const asStitcher_1 = require("./compose/asStitcher");
|
|
10
|
+
const genStitchChoice_1 = require("./compose/genStitchChoice");
|
|
11
|
+
const enweaveOneChoice_1 = require("./enweaveOneChoice");
|
|
12
|
+
describe('enweaveOneChoice', () => {
|
|
13
|
+
const context = {
|
|
14
|
+
...(0, genContextLogTrail_1.genContextLogTrail)(),
|
|
15
|
+
...(0, genContextStitchTrail_1.genContextStitchTrail)(),
|
|
16
|
+
};
|
|
17
|
+
(0, test_fns_1.given)('a release decision with 3 options: release, iterate, abort', () => {
|
|
18
|
+
const stitcherOptionRelease = new StitchStep_1.StitchStepCompute({
|
|
19
|
+
slug: 'stitcherOptionRelease',
|
|
20
|
+
readme: 'Push this to prod',
|
|
21
|
+
form: 'COMPUTE',
|
|
22
|
+
stitchee: 'main',
|
|
23
|
+
invoke: () => ({ input: null, output: 'released' }),
|
|
24
|
+
});
|
|
25
|
+
const stitcherOptionIterate = new StitchStep_1.StitchStepCompute({
|
|
26
|
+
slug: 'stitcherOptionIterate',
|
|
27
|
+
readme: 'Keep improving before release',
|
|
28
|
+
form: 'COMPUTE',
|
|
29
|
+
stitchee: 'main',
|
|
30
|
+
invoke: () => ({ input: null, output: 'iterated' }),
|
|
31
|
+
});
|
|
32
|
+
const stitcherOptionAbort = new StitchStep_1.StitchStepCompute({
|
|
33
|
+
slug: 'stitcherOptionAbort',
|
|
34
|
+
readme: 'Stop this effort',
|
|
35
|
+
form: 'COMPUTE',
|
|
36
|
+
stitchee: 'main',
|
|
37
|
+
invoke: () => ({ input: null, output: 'aborted' }),
|
|
38
|
+
});
|
|
39
|
+
const stitcherDecideNextStep = new StitchStep_1.StitchStepCompute({
|
|
40
|
+
slug: 'stitcherDecideNextStep',
|
|
41
|
+
readme: 'Choose next step based on quality',
|
|
42
|
+
form: 'COMPUTE',
|
|
43
|
+
stitchee: 'main',
|
|
44
|
+
invoke: () => ({
|
|
45
|
+
input: null,
|
|
46
|
+
output: { choice: { slug: 'stitcherOptionIterate' } },
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
const chooseNextStep = (0, genStitchChoice_1.genStitchChoice)({
|
|
50
|
+
slug: 'chooseNextStep',
|
|
51
|
+
readme: 'Should we now release, iterate, or abort?',
|
|
52
|
+
decider: stitcherDecideNextStep,
|
|
53
|
+
options: [
|
|
54
|
+
stitcherOptionRelease,
|
|
55
|
+
stitcherOptionIterate,
|
|
56
|
+
stitcherOptionAbort,
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
(0, test_fns_1.when)('evaluating whether to release', () => {
|
|
60
|
+
const threads = {
|
|
61
|
+
main: (0, genThread_1.genThread)({ role: 'main' }),
|
|
62
|
+
};
|
|
63
|
+
(0, test_fns_1.then)('it should select "iterate" as next step', async () => {
|
|
64
|
+
const result = await (0, enweaveOneChoice_1.enweaveOneChoice)({
|
|
65
|
+
stitcher: chooseNextStep,
|
|
66
|
+
threads,
|
|
67
|
+
}, context);
|
|
68
|
+
console.log(JSON.stringify(result, null, 2));
|
|
69
|
+
expect(result.stitch.output).toBe('iterated');
|
|
70
|
+
expect(result.threads.main.stitches.length).toBe(2);
|
|
71
|
+
expect(result.occurredAt).toEqual((0, uni_time_1.asUniDateTime)(result.occurredAt));
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
(0, test_fns_1.given)('a nested decision tree for triaging a home issue', () => {
|
|
76
|
+
// Leaf stitchers
|
|
77
|
+
const stitcherOptionPlumberUrgent = new StitchStep_1.StitchStepCompute({
|
|
78
|
+
slug: 'plumber-urgent',
|
|
79
|
+
readme: null,
|
|
80
|
+
form: 'COMPUTE',
|
|
81
|
+
stitchee: 'main',
|
|
82
|
+
invoke: () => ({ input: null, output: 'plumber-urgent' }),
|
|
83
|
+
});
|
|
84
|
+
const stitcherOptionPlumberSchedule = new StitchStep_1.StitchStepCompute({
|
|
85
|
+
slug: 'inspect-later',
|
|
86
|
+
readme: null,
|
|
87
|
+
form: 'COMPUTE',
|
|
88
|
+
stitchee: 'main',
|
|
89
|
+
invoke: () => ({ input: null, output: 'inspection-scheduled' }),
|
|
90
|
+
});
|
|
91
|
+
const stitcherOptionElectricianRefer = new StitchStep_1.StitchStepCompute({
|
|
92
|
+
slug: 'refer-utility',
|
|
93
|
+
readme: null,
|
|
94
|
+
form: 'COMPUTE',
|
|
95
|
+
stitchee: 'main',
|
|
96
|
+
invoke: () => ({ input: null, output: 'refer-utility' }),
|
|
97
|
+
});
|
|
98
|
+
const stitcherOptionElectricianDispatch = new StitchStep_1.StitchStepCompute({
|
|
99
|
+
slug: 'dispatch-electrician',
|
|
100
|
+
readme: null,
|
|
101
|
+
form: 'COMPUTE',
|
|
102
|
+
stitchee: 'main',
|
|
103
|
+
invoke: () => ({ input: null, output: 'dispatch-electrician' }),
|
|
104
|
+
});
|
|
105
|
+
// Inner choice for "leaking water"
|
|
106
|
+
const leakDecider = new StitchStep_1.StitchStepCompute({
|
|
107
|
+
slug: 'decide-leak-type',
|
|
108
|
+
readme: null,
|
|
109
|
+
form: 'COMPUTE',
|
|
110
|
+
stitchee: 'main',
|
|
111
|
+
invoke: () => ({
|
|
112
|
+
input: null,
|
|
113
|
+
output: { choice: { slug: 'inspect-later' } },
|
|
114
|
+
}),
|
|
115
|
+
});
|
|
116
|
+
const leakChoice = (0, genStitchChoice_1.genStitchChoice)({
|
|
117
|
+
slug: 'choice:leak',
|
|
118
|
+
readme: null,
|
|
119
|
+
decider: leakDecider,
|
|
120
|
+
options: [stitcherOptionPlumberUrgent, stitcherOptionPlumberSchedule],
|
|
121
|
+
});
|
|
122
|
+
// Root decision tree
|
|
123
|
+
const rootDecider = new StitchStep_1.StitchStepCompute({
|
|
124
|
+
slug: 'decide-main-issue',
|
|
125
|
+
readme: null,
|
|
126
|
+
form: 'COMPUTE',
|
|
127
|
+
stitchee: 'main',
|
|
128
|
+
invoke: () => ({
|
|
129
|
+
input: null,
|
|
130
|
+
output: { choice: { slug: 'choice:leak' } },
|
|
131
|
+
}),
|
|
132
|
+
});
|
|
133
|
+
const rootChoice = (0, genStitchChoice_1.genStitchChoice)({
|
|
134
|
+
slug: 'choice:root',
|
|
135
|
+
readme: 'What kind of issue is this?',
|
|
136
|
+
decider: rootDecider,
|
|
137
|
+
options: [
|
|
138
|
+
(0, asStitcher_1.asStitcher)(leakChoice),
|
|
139
|
+
stitcherOptionElectricianRefer,
|
|
140
|
+
stitcherOptionElectricianDispatch,
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
(0, test_fns_1.when)('executing a multi-level decision tree', () => {
|
|
144
|
+
const threads = {
|
|
145
|
+
main: (0, genThread_1.genThread)({ role: 'main' }),
|
|
146
|
+
};
|
|
147
|
+
(0, test_fns_1.then)('it should follow nested decisions and reach final output', async () => {
|
|
148
|
+
const result = await (0, enweaveOneChoice_1.enweaveOneChoice)({
|
|
149
|
+
stitcher: rootChoice,
|
|
150
|
+
threads,
|
|
151
|
+
}, context);
|
|
152
|
+
expect(result.stitch.output).toEqual('inspection-scheduled');
|
|
153
|
+
expect(result.threads.main.stitches.length).toBeGreaterThanOrEqual(2);
|
|
154
|
+
expect(result.occurredAt).toEqual((0, uni_time_1.asUniDateTime)(result.occurredAt));
|
|
155
|
+
});
|
|
156
|
+
(0, test_fns_1.then)('it should error if decider picks an invalid slug', async () => {
|
|
157
|
+
const badDecider = new StitchStep_1.StitchStepCompute({
|
|
158
|
+
slug: 'bad-decider',
|
|
159
|
+
readme: null,
|
|
160
|
+
form: 'COMPUTE',
|
|
161
|
+
stitchee: 'main',
|
|
162
|
+
invoke: () => ({
|
|
163
|
+
input: null,
|
|
164
|
+
output: { choice: { slug: 'not-real' } },
|
|
165
|
+
}),
|
|
166
|
+
});
|
|
167
|
+
const brokenChoice = (0, genStitchChoice_1.genStitchChoice)({
|
|
168
|
+
slug: 'broken-choice',
|
|
169
|
+
readme: null,
|
|
170
|
+
decider: badDecider,
|
|
171
|
+
options: [stitcherOptionPlumberUrgent],
|
|
172
|
+
});
|
|
173
|
+
await expect((0, enweaveOneChoice_1.enweaveOneChoice)({
|
|
174
|
+
stitcher: brokenChoice,
|
|
175
|
+
threads,
|
|
176
|
+
}, context)).rejects.toThrow('could not find chosen option');
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=enweaveOneChoice.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enweaveOneChoice.test.js","sourceRoot":"","sources":["../../../src/logic/weave/enweaveOneChoice.test.ts"],"names":[],"mappings":";;AAAA,iDAAmD;AACnD,uCAA6C;AAG7C,iFAA8E;AAC9E,uFAAoF;AACpF,gEAAoE;AAGpE,mDAAgD;AA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{ HelpfulError } from 'helpful-errors';
|
|
2
|
+
import { StitchCycle } from '../../domain/objects/StitchCycle';
|
|
3
|
+
import { StitchSetEvent } from '../../domain/objects/StitchSetEvent';
|
|
4
|
+
import { GStitcher } from '../../domain/objects/Stitcher';
|
|
5
|
+
export declare class StitcherHaltedError extends HelpfulError {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* .what = executes a StitchCycle by looping repeatee until the decider chooses to stop
|
|
9
|
+
* .why =
|
|
10
|
+
* - enables iterative behaviors (e.g. retry, polling, feedback loops)
|
|
11
|
+
* - separates logic of repeated step vs control logic (decider)
|
|
12
|
+
* .note =
|
|
13
|
+
* - will halt by default after 100 cycles or 1 hr, configurable
|
|
14
|
+
* - if halted, will fail fast; can resume halted weaves on demand, after repair
|
|
15
|
+
*/
|
|
16
|
+
export declare const enweaveOneCycle: <TStitcher extends GStitcher>(input: {
|
|
17
|
+
stitcher: StitchCycle<TStitcher>;
|
|
18
|
+
threads: TStitcher['threads'];
|
|
19
|
+
}, context: TStitcher['context']) => Promise<StitchSetEvent<TStitcher['threads'], TStitcher['output']>>;
|