Skip to content

Commit

Permalink
v0.1.66
Browse files Browse the repository at this point in the history
  • Loading branch information
REllEK-IO committed May 14, 2024
1 parent 7f78f5d commit 6aa80f4
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 91 deletions.
6 changes: 3 additions & 3 deletions Concept.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ export type PrincipleFunction = (
observer: Subscriber<Action>,
concepts: Concepts,
concept$: UnifiedSubject,
semaphore: number
conceptSemaphore: number
) => void;

export function createPrinciple$(
principleFunc: PrincipleFunction,
concepts: Concepts,
concepts$: UnifiedSubject,
semaphore: number
conceptSemaphore: number
): Observable<Action>;
```
Concept's principle, governs a specific set of instructions that would allow for the functionality of other libraries not designed specifically for this system. Otherwise these act as action emitters of some value being watched off premise or subscribed to within the axium.
Expand All @@ -91,7 +91,7 @@ As this functionality lacks the addition of some abstraction to hand hold the us

Later we may create specific types of principles to handle the nuances of repeating the same functionality over and over again. But likewise that is not the scope of this release.

*Note the semaphore is specifically in utilization with "selectUnifiedState(concepts, semaphore)" to select your Concept's state regardless of its current state of unification.*
*Note the concept semaphore is specifically in utilization with "selectUnifiedState(concepts, semaphore)" to select your Concept's state regardless of its current state of unification.*

## Mode - The point of Recursion
```typescript
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ When in doubt simplify.
* [Unified Turing Machine](https://github.com/Phuire-Research/Stratimux/blob/main/The-Unified-Turing-Machine.md) - The governing concept for this entire framework.

## Change Log ![Tests](https://github.com/Phuire-Research/Stratimux/actions/workflows/node.js.yml/badge.svg)
### **BREAKING** v0.1.66 5/13/2024
* Revamped the Action Creator Functions to follow behind the current creator with an **options** parameter design choice.
* Note pure action creators will not provide an option for payload
* Cascaded priority to ActionStrategies to allow for planning priority ahead of time.
* Updated the PrincipleFunction documentation to have the semaphore parameter to now be conceptSemaphore. This allows for an easy drop in into the options parameter.
### v0.1.65 5/13/2024
* Removed one more level of deepness from DotPath(6 levels now), projects should now compile without the excessively deep error.
### v0.1.64 5/13/2024
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stratimux",
"license": "GPL-3.0",
"version": "0.1.65",
"version": "0.1.66",
"description": "Unified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
7 changes: 4 additions & 3 deletions src/concepts/axium/axium.principle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const axiumPrinciple: PrincipleFunction = (
observer: Subscriber<Action>,
concepts: Concepts,
concepts$: UnifiedSubject,
semaphore: number
conceptSemaphore: number
) => {
let allowAdd = true;
let allowRemove = true;
Expand Down Expand Up @@ -174,8 +174,9 @@ export const axiumPrinciple: PrincipleFunction = (
]);
observer.next(strategy.begin(strategy.create({
topic: 'Register Axium Add/Remove Plans',
initialNode: createActionNode(axiumRegisterStagePlanner({conceptName: axiumName, stagePlanner: addConceptsPlan}, semaphore), {
successNode: createActionNode(axiumRegisterStagePlanner({conceptName: axiumName, stagePlanner: removeConceptsPlan}, semaphore), {
initialNode: createActionNode(axiumRegisterStagePlanner({conceptName: axiumName, stagePlanner: addConceptsPlan}, {conceptSemaphore}), {
successNode:
createActionNode(axiumRegisterStagePlanner({conceptName: axiumName, stagePlanner: removeConceptsPlan}, {conceptSemaphore}), {
successNode: null,
failureNode: null
}),
Expand Down
2 changes: 1 addition & 1 deletion src/concepts/ownership/ownership.principle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const ownershipPrinciple: PrincipleFunction = (
}
}
if (payload.badActions.length > 0) {
newAction = createAction(axiumBadActionType, payload);
newAction = createAction(axiumBadActionType, {payload});
ownershipState.pendingActions = newPending;
concepts$.next(concepts);
observer.next(newAction);
Expand Down
106 changes: 62 additions & 44 deletions src/model/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@ export type Action = {
priority?: number;
};

export type ActionOptions = {
semaphore?: [number, number, number, number];
conceptSemaphore?: number;
strategy?: ActionStrategy;
keyedSelectors?: KeyedSelector[];
agreement?: number;
expiration?: number;
axium?: string;
priority?: number;
};

export type ActionWithPayloadOptions = {
semaphore?: [number, number, number, number];
conceptSemaphore?: number;
payload?: Record<string, unknown>;
strategy?: ActionStrategy;
keyedSelectors?: KeyedSelector[];
agreement?: number;
expiration?: number;
axium?: string;
priority?: number;
};

const createPayload = <T extends Record<string, unknown>>(payload: T) => payload;

export function primeAction(concepts: Concepts, action: Action): Action {
Expand Down Expand Up @@ -167,77 +190,72 @@ function getSpecialSemaphore(type: ActionType) {
}
}

export function createAction<T extends Record<string, unknown>>(
export function createAction(
type: ActionType,
payload?: T,
keyedSelectors?: KeyedSelector[],
agreement?: number,
_semaphore?: [number, number, number, number],
conceptSemaphore?: number,
priority?: number
options?: ActionWithPayloadOptions,
): Action {
const special = getSpecialSemaphore(type);
const semaphore = _semaphore !== undefined ? _semaphore : [0, 0, -1, special] as [number, number, number, number];
return {
type,
semaphore,
payload,
keyedSelectors,
agreement,
expiration: Date.now() + (agreement !== undefined ? agreement : 5000),
conceptSemaphore,
priority
};
const semaphore = options?.semaphore !== undefined ? options.semaphore : [0, 0, -1, special] as [number, number, number, number];
if (options) {
const {
payload,
keyedSelectors,
agreement,
conceptSemaphore,
priority
} = options;
return {
type,
semaphore,
payload,
keyedSelectors,
agreement,
expiration: Date.now() + (agreement !== undefined ? agreement : 5000),
conceptSemaphore,
priority
};
} else {
return {
type,
semaphore,
expiration: Date.now() + 5000,
};
}
}

export type ActionCreator = (
conceptSemaphore?: number,
keyedSelectors?: KeyedSelector[],
agreement?: number,
qualitySemaphore?: [number, number, number, number]
options?: ActionOptions
) => Action;

export function prepareActionCreator(actionType: ActionType) {
return (
conceptSemaphore?: number,
keyedSelectors?: KeyedSelector[],
agreement?: number,
qualitySemaphore?: [number, number, number, number],
priority?: number
options?: ActionOptions
) => {
return createAction(
actionType,
undefined,
keyedSelectors,
agreement,
qualitySemaphore,
conceptSemaphore,
priority
options
);
};
}

export function prepareActionWithPayloadCreator<T extends Record<string, unknown>>(actionType: ActionType) {
return (
payload: T,
conceptSemaphore?: number,
keyedSelectors?: KeyedSelector[],
agreement?: number,
semaphore?: [number, number, number, number],
priority?: number
options?: ActionOptions
): Action => {
const opt: ActionWithPayloadOptions = {
...options,
payload
};
return createAction(
actionType,
payload, keyedSelectors, agreement, semaphore, conceptSemaphore, priority);
opt
);
};
}
export type ActionCreatorWithPayload<T> = (
payload: T,
conceptSemaphore?: number,
keyedSelectors?: KeyedSelector[],
agreement?: number,
semaphore?: [number, number, number, number],
priority?: number
options?: ActionWithPayloadOptions
) => Action;

/**
Expand Down
67 changes: 42 additions & 25 deletions src/model/actionStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ export const createActionNodeFromStrategy = (strategy: ActionStrategy): ActionNo
} else {
action = createAction(
currentNode.actionType,
currentNode.payload,
currentNode.keyedSelectors,
currentNode.agreement,
currentNode.semaphore,
currentNode.conceptSemaphore,
currentNode.priority
{
payload: currentNode.payload,
keyedSelectors: currentNode.keyedSelectors,
agreement: currentNode.agreement,
semaphore: currentNode.semaphore,
conceptSemaphore: currentNode.conceptSemaphore,
priority: currentNode.priority
}
);
}
return createActionNode(action, {
Expand Down Expand Up @@ -235,11 +237,17 @@ export function createStrategy(
}

export const strategyBegin = (strategy: ActionStrategy, data?: Record<string, unknown>): Action => {
const currentNode = strategy.currentNode;
strategy.currentNode.action = createAction(
strategy.currentNode.actionType,
strategy.currentNode.payload,
strategy.currentNode.keyedSelectors,
strategy.currentNode.agreement
currentNode.actionType,
{
payload: currentNode.payload,
keyedSelectors: currentNode.keyedSelectors,
agreement: currentNode.agreement,
semaphore: currentNode.semaphore,
conceptSemaphore: currentNode.conceptSemaphore,
priority: currentNode.priority
}
);
strategy.currentNode.action.strategy = {
...strategy,
Expand Down Expand Up @@ -273,11 +281,14 @@ export const strategySuccess = (_strategy: ActionStrategy, data?: Record<string,
const nextNode = strategy.currentNode.successNode;
nextAction = createAction(
nextNode.actionType,
nextNode.payload,
nextNode.keyedSelectors,
nextNode.agreement,
nextNode.semaphore,
nextNode.conceptSemaphore
{
payload: nextNode.payload,
keyedSelectors: nextNode.keyedSelectors,
agreement: nextNode.agreement,
semaphore: nextNode.semaphore,
conceptSemaphore: nextNode.conceptSemaphore,
priority: nextNode.priority
}
);
nextNode.action = nextAction;
nextNode.lastActionNode = strategy.currentNode;
Expand Down Expand Up @@ -343,11 +354,14 @@ export function strategyFailed(_strategy: ActionStrategy, data?: Record<string,
const nextNode = strategy.currentNode.failureNode;
nextAction = createAction(
nextNode.actionType,
nextNode.payload,
nextNode.keyedSelectors,
nextNode.agreement,
nextNode.semaphore,
nextNode.conceptSemaphore
{
payload: nextNode.payload,
keyedSelectors: nextNode.keyedSelectors,
agreement: nextNode.agreement,
semaphore: nextNode.semaphore,
conceptSemaphore: nextNode.conceptSemaphore,
priority: nextNode.priority
}
);
nextNode.action = nextAction;
nextNode.lastActionNode = strategy.currentNode;
Expand Down Expand Up @@ -424,11 +438,14 @@ export const strategyDecide = (
const nextNode = decisionNodes[decideKey];
nextAction = createAction(
nextNode.actionType,
nextNode.payload,
nextNode.keyedSelectors,
nextNode.agreement,
nextNode.semaphore,
nextNode.conceptSemaphore
{
payload: nextNode.payload,
keyedSelectors: nextNode.keyedSelectors,
agreement: nextNode.agreement,
semaphore: nextNode.semaphore,
conceptSemaphore: nextNode.conceptSemaphore,
priority: nextNode.priority
}
);
nextNode.action = nextAction;
nextNode.lastActionNode = strategy.currentNode;
Expand Down
4 changes: 2 additions & 2 deletions src/model/principle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export function createPrinciple$(
principleFunc: PrincipleFunction,
concepts: Concepts,
concepts$: UnifiedSubject,
semaphore: number,
conceptSemaphore: number,
): Observable<Action> {
return new Observable(function (obs: Subscriber<Action>) {
principleFunc(obs, concepts, concepts$, semaphore);
principleFunc(obs, concepts, concepts$, conceptSemaphore);
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/actionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { axiumBadActionType } from '../concepts/axium/qualities/badAction.quali
import { axiumLog, axiumLogType } from '../concepts/axium/qualities/log.quality';

test('ActionController Expired Test', (done) => {
const act = axiumLog(undefined, undefined, 200);
const act = axiumLog({agreement: 200});
const cont = new ActionController(act);
cont.subscribe(union => {
expect(union[0].type).toBe(axiumBadActionType);
Expand All @@ -16,7 +16,7 @@ test('ActionController Expired Test', (done) => {
});

test('ActionController Next Test', (done) => {
const act = axiumLog(undefined, undefined, 200);
const act = axiumLog({agreement: 200});
const cont = new ActionController(act);
cont.subscribe(union => {
expect(union[0].type).toBe(axiumLogType);
Expand All @@ -26,7 +26,7 @@ test('ActionController Next Test', (done) => {
});

test('ActionController createActionController$ Test', (done) => {
const act = axiumLog(undefined, undefined, 200);
const act = axiumLog({agreement: 200});
const cont = createActionController$(act, (controller, action) => {
controller.fire(action);
});
Expand Down
2 changes: 1 addition & 1 deletion src/test/ownership.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('Ownership Test', (done) => {
const ownership = selectState<OwnershipState>(cpts, ownershipName);
if (ownership) {
console.log('Stage 2', ownership.ownershipLedger, ownership.pendingActions);
dispatch(counterSetCount({newCount: 1000}, undefined, undefined, 7000), { iterateStage: true});
dispatch(counterSetCount({newCount: 1000}, {agreement: 7000} ), { iterateStage: true});
}
}),
createStage((cpts, dispatch) => {
Expand Down
Loading

0 comments on commit 6aa80f4

Please sign in to comment.