Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepareActionWithPayloadCreator workflow. #81

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ActionStrategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface ActionNode {
```
* action - Is an union data pattern to bind the functionality of the ActionNode, ActionStrategy, and Action. This allows for each part to be responsible for itself and to allow for additional functionality at runtime.
* actionType - Is merely the type of action to be created at runtime, these should be verbose as to their intended effect as it informs the STRX sentence structure's body.
* payload - Is set to unknown to allow for the explicit typecasting during consumption, reducer, method, or principle. Use createPayload<_Type>(payload: _Type) to ensure type casting in the reducer will be the same type as used in createPayload. This is a logical determination in line with Javascript core functionality.
* payload - Is set to unknown to allow for the explicit typecasting during consumption, reducer, method, or principle. Be sure to import actions directly to ensure payload type safety in the reducer. This is a logical determination in line with Javascript core functionality.
* keyedSelectors - An Array of KeyedSelector that locks some property during the life time of the created action.
* semaphore - First is concept's index, second is the quality's index, and the final is the generation of the sets of concepts currently stored on the Axium. *Explicitly setting this value, denotes a primed action without additional look up at runtime.*
* agreement - Is time in milliseconds of the lock's expiration time. Default is currently 5000, but such will be reduced upon testing and feedback.
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let finalRun = true;
const axium = createAxium('ownershipTest', [
createOwnershipConcept(),
createCounterConcept(),
createExperimentConcept(createExperimentActionQueState(), [checkInQuality], [experimentActionQuePrinciple])
createExperimentConcept(createExperimentActionQueState(), [checkInStrategyQuality], [experimentActionQuePrinciple])
], true, true);
const plan = axium.stage(
'Testing Ownership Staging', [
Expand All @@ -56,7 +56,7 @@ const plan = axium.stage(
// This will place a counting strategy in the experiment actionQue to be later dispatched.
// Via its principle, to simulate an action moving off premise.
dispatch(strategyBegin(puntCountingStrategy()), {
iterateStep: true
iterateStage: true
});
}
},
Expand All @@ -65,15 +65,15 @@ const plan = axium.stage(
// Will be ran after both counting strategies conclude.
const ownership = selectState<OwnershipState>(cpts, ownershipName);
console.log('Stage 2', ownership.ownershipLedger, ownership.pendingActions);
dispatch(counterSetCount(createPayload<SetCountPayload>({newCount: 1000}), undefined, 7000), { iterateStep: true});
dispatch(counterSetCount({newCount: 1000}, undefined, 7000), { iterateStage: true});
},
(cpts, dispatch) => {
const ownership = selectState<OwnershipState>(cpts, ownershipName);
console.log('Stage 3', ownership.ownershipLedger, ownership.pendingActions);
const counter = selectState<Counter>(cpts, counterName);
console.log('Count: ', counter.count);
dispatch(strategyBegin(experimentPrimedCountingStrategy(cpts)), {
iterateStep: true
iterateStage: true
});
},
(cpts, dispatch) => {
Expand Down Expand Up @@ -134,15 +134,15 @@ const sub = axium.subscribe((concepts: Concept[]) => {
}
});
```
The above demonstrates two solutions. One of the ability to network axiums together unlike the design of FLUX that would restrict all calculations to a singular source of truth. That is accomplished via the ownership pattern and halts upon multiple concluding strategies that would have some race condition within the network. The second would be the comments to demonstrate the power of a finite state machine and its ability to return some output that can be logically determined. Noting the comment selections. This is presented as such to provide a testable back and forth with the developer to inform some intuition as to STRX's inner workings.
the above demonstrates two solutions. one of the ability to network axiums together unlike the design of flux that would restrict all calculations to a singular source of truth. that is accomplished via the ownership pattern and halts upon multiple concluding strategies that would have some race condition within the network. the second would be the comments to demonstrate the power of a finite state machine and its ability to return some output that can be logically determined. noting the comment selections. this is presented as such to provide a testable back and forth with the developer to inform some intuition as to strx's inner workings.

### STRX - *ST*rategic *R*eactive(X) Framework
STRX is the graph computational framework release of a new Unified Turing Machine. The internal structure of this machine directly relays to a form of written intelligence of doing, over that of knowledge retrieval, and data entry. But may be written to facilitate any preexisting paradigm such as that same expert system paradigm of classic. The importance of this machine to the now of 2023, is the functionality of the ActionStrategy pattern as it relays to human and machine intelligence. As the pattern itself is a unified set of logical explanations of doing as a series of functions. Unified to the mechanism of that doing via code implementations of that logical explanation. We organize using concepts as it relays to a historic pursuit of unifying all fields of science in addition to a logical explanation. And is the comparable comparison to a graph of machine learning universal functions, and the generated Neural Network of layers that aggregate to greater universal functions. The comparison to that of LLM, during runtime these actions are outputted to an ActionList that is later composed as a STRX sentence.
### strx - *st*rategic *r*eactive(x) framework
strx is the graph computational framework release of a new unified turing machine. the internal structure of this machine directly relays to a form of written intelligence of doing, over that of knowledge retrieval, and data entry. but may be written to facilitate any preexisting paradigm such as that same expert system paradigm of classic. the importance of this machine to the now of 2023, is the functionality of the actionstrategy pattern as it relays to human and machine intelligence. as the pattern itself is a unified set of logical explanations of doing as a series of functions. unified to the mechanism of that doing via code implementations of that logical explanation. we organize using concepts as it relays to a historic pursuit of unifying all fields of science in addition to a logical explanation. and is the comparable comparison to a graph of machine learning universal functions, and the generated neural network of layers that aggregate to greater universal functions. the comparison to that of llm, during runtime these actions are outputted to an actionlist that is later composed as a strx sentence.

#### The Anatomy of a STRX Sentence
#### the anatomy of a strx sentence
```
Preposition(/+)Decision + Body + Denoter
Example: Finally + Open Axium + to Notify Subscribers of State changes.
preposition(/+)decision + body + denoter
example: Finally + Open Axium + to Notify Subscribers of State changes.
```
This allows for a STRX Dialog to be constructed in the same formalization of that of a paragraph. Where the strategy topic is the literal topic sentence of a paragraph. And is followed by all steps and possible decision that create a unified paragraph.
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@phuire/strx",
"version": "0.0.25",
"version": "0.0.26",
"description": "Unified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
7 changes: 2 additions & 5 deletions src/concepts/axium/qualities/addConceptsFromQue.quality.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { Observable, Subject, Subscriber, catchError } from 'rxjs';
import { defaultMethodCreator } from '../../../model/concept';
import { AxiumState } from '../axium.concept';
import { Action, ActionType } from '../../../model/action';
import { Action, ActionType, prepareActionCreator } from '../../../model/action';
import { createQuality } from '../../../model/concept';
import { blockingMethodSubscription } from '../../../model/axium';

export const axiumAddConceptFromQueType: ActionType = 'Add Concepts from Axium Concept Que';

export type AddConceptsFromQuePayload = {
action$: Subject<Action>;
}
export const axiumAddConceptFromQue = prepareActionCreator(axiumAddConceptFromQueType);

function addConceptsFromQueReducer(state: AxiumState, _ : Action) {
const methodSubscribers = state.methodSubscribers;
Expand Down
32 changes: 4 additions & 28 deletions src/concepts/axium/qualities/appendActionListToDialog.quality.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,17 @@
import { map, Subject } from 'rxjs';
import { Method, MethodCreator } from '../../../model/concept';
import { Action, ActionType } from '../../../model/action';
import { createAction } from '../../../model/action';
import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action';
import { createQuality } from '../../../model/concept';
import { AxiumState } from '../axium.concept';
import { axiumConcludeType } from './conclude.quality';
import { selectPayload } from '../../../model/selector';

export const axiumAppendActionListToDialogType: ActionType = 'append Action List to Axium\'s Dialog';

export type AppendActionListToDialogPayload = {
actionList: Array<string>;
strategyTopic: string;
}

// const createAppendActionListToDialogMethodCreator: MethodCreator = (concepts$: UnifiedSubject) => {
const createAppendActionListToDialogMethodCreator: MethodCreator = () => {
const logSubject = new Subject<Action>();
const logMethod: Method = logSubject.pipe(
// withLatestFrom(subConcepts$),
// map(([action, concepts]) => {
map(() => {
// const axiumState = concepts[0].state as AxiumState;
// if (axiumState.logging) {
// const payload = action.payload as AppendActionListToDialogPayload;
// let newDialog = payload.strategyKey + '. ';
// payload.actionList.forEach(str => {newDialog += str + ' ';});
// console.log(newDialog);
// }
return createAction(axiumConcludeType);
})
);
return [
logMethod,
logSubject
];
};
export const axiumAppendActionListToDialogType: ActionType = 'append Action List to Axium\'s Dialog';
export const axiumAppendActionListToDialog =
prepareActionWithPayloadCreator<AppendActionListToDialogPayload>(axiumAppendActionListToDialogType);

export function appendActionListToDialogReducer(state: AxiumState, action: Action) {
const payload = selectPayload<AppendActionListToDialogPayload>(action);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Concept, defaultMethodCreator } from '../../../model/concept';
import { AxiumState } from '../axium.concept';
import { Action, ActionType } from '../../../model/action';
import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action';
import { createQuality } from '../../../model/concept';
import { selectPayload } from '../../../model/selector';

export const axiumAppendConceptsToAddQueType: ActionType = 'append Concepts to Axium\'s Add Concept Que';

export type AppendConceptsToAddQuePayload = {
concepts: Concept[]
}
export const axiumAppendConceptsToAddQueType: ActionType = 'append Concepts to Axium\'s Add Concept Que';
export const axiumAppendConceptsToAddQue =
prepareActionWithPayloadCreator<AppendConceptsToAddQuePayload>(axiumAppendConceptsToAddQueType);

export function appendConceptsToAddQueReducer(state: AxiumState, action: Action) {
const payload = selectPayload<AppendConceptsToAddQuePayload>(action);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Concept, defaultMethodCreator } from '../../../model/concept';
import { AxiumState } from '../axium.concept';
import { Action, ActionType } from '../../../model/action';
import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action';
import { createQuality } from '../../../model/concept';
import { selectPayload } from '../../../model/selector';

export const axiumAppendConceptsToRemoveQueType: ActionType = 'append Concepts to Axium\'s Remove Concept Que';

export type AppendConceptsToRemoveQuePayload = {
concepts: Concept[]
}
export const axiumAppendConceptsToRemoveQueType: ActionType = 'append Concepts to Axium\'s Remove Concept Que';
export const axiumAppendConceptsToRemoveQue =
prepareActionWithPayloadCreator<AppendConceptsToRemoveQuePayload>(axiumAppendConceptsToRemoveQueType);

export function appendConceptsToRemoveQueReducer(state: AxiumState, action: Action) {
const payload = selectPayload<AppendConceptsToRemoveQuePayload>(action);
Expand Down
5 changes: 3 additions & 2 deletions src/concepts/axium/qualities/badAction.quality.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Action, ActionType } from '../../../model/action';
import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action';
import { createQuality } from '../../../model/concept';
import { selectPayload } from '../../../model/selector';
import { AxiumState } from '../axium.concept';

export const axiumBadActionType: ActionType = 'Axium received a Bad Action';
export type BadActionPayload = Action[];
export const axiumBadActionType: ActionType = 'Axium received a Bad Action';
export const axiumBadAction = prepareActionWithPayloadCreator<BadActionPayload>(axiumBadActionType);

export function badActionReducer(state: AxiumState, action: Action) {
const payload = selectPayload<BadActionPayload>(action);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { defaultMethodCreator, createQuality } from '../../../model/concept';
import { Action, ActionType, prepareActionCreator } from '../../../model/action';
import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action';
import { AxiumState } from '../axium.concept';
import { selectPayload } from '../../../model/selector';

export const axiumClearBadActionTypeFromBadActionListType: ActionType = 'clear ActionType from Axium\'s badAction list';
export const axiumClearBadActionTypeFromBadActionList = prepareActionCreator(axiumClearBadActionTypeFromBadActionListType);
export type ClearBadActionTypeFromBadActionListPayload = ActionType;
export const axiumClearBadActionTypeFromBadActionListType: ActionType = 'clear ActionType from Axium\'s badAction list';
export const axiumClearBadActionTypeFromBadActionList =
prepareActionWithPayloadCreator<ClearBadActionTypeFromBadActionListPayload>(axiumClearBadActionTypeFromBadActionListType);

function clearBadActionTypeFromBadActionListReducer(state: AxiumState, action: Action): AxiumState {
const actionType = selectPayload<ClearBadActionTypeFromBadActionListPayload>(action);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { defaultMethodCreator, createQuality } from '../../../model/concept';
import { Action, ActionType, prepareActionCreator } from '../../../model/action';
import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action';
import { AxiumState } from '../axium.concept';
import { selectPayload } from '../../../model/selector';

export const axiumClearBadPlanFromBadPlanListType: ActionType = 'clear Plan Topic from Axium\'s badPlan list';
export const axiumClearBadPlanFromBadPlanList = prepareActionCreator(axiumClearBadPlanFromBadPlanListType);
export type ClearBadPlanFromBadPlanListPayload = string;
export const axiumClearBadPlanFromBadPlanListType: ActionType = 'clear Plan Topic from Axium\'s badPlan list';
export const axiumClearBadPlanFromBadPlanList =
prepareActionWithPayloadCreator<ClearBadPlanFromBadPlanListPayload>(axiumClearBadPlanFromBadPlanListType);

function clearBadPlanFromBadPlanListReducer(state: AxiumState, action: Action): AxiumState {
const title = selectPayload<ClearBadPlanFromBadPlanListPayload>(action);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { defaultMethodCreator, createQuality } from '../../../model/concept';
import { Action, ActionType, prepareActionCreator } from '../../../model/action';
import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action';
import { AxiumState } from '../axium.concept';
import { selectPayload } from '../../../model/selector';

export const axiumClearBadStrategyTopicFromBadActionListType: ActionType = 'clear Strategy Topic from Axium\'s badAction list';
export const axiumClearBadStrategyTopicFromBadActionList = prepareActionCreator(axiumClearBadStrategyTopicFromBadActionListType);
export type ClearBadStrategyTopicFromBadActionListPayload = string;
export const axiumClearBadStrategyTopicFromBadActionListType: ActionType = 'clear Strategy Topic from Axium\'s badAction list';
export const axiumClearBadStrategyTopicFromBadActionList =
prepareActionWithPayloadCreator<ClearBadStrategyTopicFromBadActionListPayload>(axiumClearBadStrategyTopicFromBadActionListType);

function clearBadStrategyTopicFromBadActionListReducer(state: AxiumState, action: Action): AxiumState {
const strategyTopic = selectPayload<ClearBadStrategyTopicFromBadActionListPayload>(action);
Expand Down
3 changes: 2 additions & 1 deletion src/concepts/axium/qualities/conclude.quality.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionType } from '../../../model/action';
import { ActionType, prepareActionCreator } from '../../../model/action';

/**
* axiumConcludeType
Expand All @@ -9,3 +9,4 @@ import { ActionType } from '../../../model/action';
* This should not be used Directly
*/
export const axiumConcludeType: ActionType = 'Conclude';
export const axiumConclude = prepareActionCreator(axiumConcludeType);
7 changes: 4 additions & 3 deletions src/concepts/axium/qualities/initializePrinciples.quality.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Subject, Subscriber } from 'rxjs';
import { Concept, defaultMethodCreator } from '../../../model/concept';
import { createPrinciple$ } from '../../../model/principle';
import { Action, ActionType } from '../../../model/action';
import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action';
import { AxiumState } from '../axium.concept';
import { createQuality } from '../../../model/concept';
import { UnifiedSubject } from '../../../model/unifiedSubject';
import { selectPayload } from '../../../model/selector';

export const axiumInitializePrinciplesType: ActionType = 'initialize Principles and set new Subscribers to General Subscribers list';

export type InitializePrinciplesPayload = {
concepts: Concept[];
}
export const axiumInitializePrinciplesType: ActionType = 'initialize Principles and set new Subscribers to General Subscribers list';
export const axiumInitializePrinciples =
prepareActionWithPayloadCreator<InitializePrinciplesPayload>(axiumInitializePrinciplesType);

export function initializePrinciplesReducer(state: AxiumState, _action: Action) {
const payload = selectPayload<InitializePrinciplesPayload>(_action);
Expand Down
5 changes: 2 additions & 3 deletions src/concepts/axium/qualities/log.quality.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { map, Subject } from 'rxjs';
import { Method, MethodCreator, defaultReducer } from '../../../model/concept';
import { Action, ActionType, prepareActionCreator } from '../../../model/action';
import { createAction } from '../../../model/action';
import { createQuality } from '../../../model/concept';
import { axiumConcludeType } from './conclude.quality';
import { axiumConclude } from './conclude.quality';
import { strategySuccess } from '../../../model/actionStrategy';

export const axiumLogType: ActionType = 'logged a message passed to Axium';
Expand All @@ -17,7 +16,7 @@ const createLogMethodCreator: MethodCreator = () => {
if (action.strategy) {
return strategySuccess(action.strategy);
}
return createAction(axiumConcludeType);
return axiumConclude();
})
);
return [
Expand Down
Loading