Skip to content

Commit

Permalink
Merge pull request #161 from Phuire-Research/UI
Browse files Browse the repository at this point in the history
BREAKING: All action payloads must extend Record<string, unknown>
  • Loading branch information
REllEK-IO authored Nov 15, 2023
2 parents a3394b7 + c715edd commit 6f74af2
Show file tree
Hide file tree
Showing 24 changed files with 93 additions and 86 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ User Interface Proof of Concept and Demo: [logixUX](https://github.com/Phuire-Re

*Note if you notice a strange any capitalization, this is a new format that is being formalized as conceptual logic. Where we capitalize not just people, places, and things, but concepts as well. In addition, there was no generative intelligence used in the creation of this framework or documentation. This is **100% hand written.***

## Change Log ![Tests](https://github.com/Phuire-Research/Stratimux/actions/workflows/node.js.yml/badge.svg)
### 11/15/23
* Action Payloads must extend type: Record<string, unknown>
* This change is to provide a guarantee of advanced functionality in the current UI Proof of Concept.

----
![Tests](https://github.com/Phuire-Research/Stratimux/actions/workflows/node.js.yml/badge.svg)
### Abstract
One of the greatest gaps of understanding in the modern age is whether what we speak has some mechanical bearing, or is just some statistical output. What the Unified Turing Machine, and by extension Stratimux accomplishes is to make plain the unifying aspect of the unknown mechanics of language. This is accomplished via logical verbose descriptions that are unified by code implementations and proved via a test. That currently we have trouble distinguishing logic from opinion in our speech, thus this approach seeks to prove a distinction between speech that is testable versus not. As we are currently in the age of post truth and such would only be magnified without some test due to the advent of Ai. Where we can describe logically the exact process that would transform some data into something else in our very speech. Then back that description up with a code implementation that accomplishes the transformation. There is backing to this in the original Unified Science International Encyclopedia, via its entry on the "Foundations of Logic and Mathematics." But in the current generalized scope, there had been no further pursuit to understand the unifying aspect of language and mathematics. And colloquially are presented as if they are completely separate concepts. Yet mathematics is just one aspect of programming, we formalize mainly through logic and describe our functions and variables via names. Therefore programming is a fundamentally unified format that may be used to prove sound verbose logic.

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.0.72",
"version": "0.0.73",
"description": "Unified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
7 changes: 2 additions & 5 deletions src/concepts/axium/axium.mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { Subject } from 'rxjs';
import { Concepts, Mode } from '../../model/concept';
import { Action, primeAction } from '../../model/action';
import { AxiumState } from './axium.concept';
import { axiumBadActionType } from './qualities/badAction.quality';
import { Concept } from '../../model/concept.js';
import { axiumSetBlockingModeType } from './qualities/setBlockingMode.quality';
import { axiumConcludeType } from './qualities/conclude.quality';
import { UnifiedSubject } from '../../model/stagePlanner';
import { BadActionPayload } from './qualities/badAction.quality';

export const isActionable = (axiumState: AxiumState, action: Action): boolean => {
let actionable = true;
Expand Down Expand Up @@ -46,7 +43,7 @@ export const permissiveMode: Mode = (
const nextAction = primeAction(concepts, action);
// Logical Determination: axiumBadActionType
if (nextAction.semaphore[3] === 1) {
const payload = [action];
const payload: BadActionPayload = {badActions: [action]};
nextAction.payload = payload;
}
if (nextAction.semaphore[2] === axiumState.generation) {
Expand Down
6 changes: 4 additions & 2 deletions src/concepts/axium/qualities/badAction.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { createQuality } from '../../../model/concept';
import { selectPayload } from '../../../model/selector';
import { AxiumState } from '../axium.concept';

export type BadActionPayload = Action[];
export type BadActionPayload = {
badActions: 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);
const payload = selectPayload<BadActionPayload>(action).badActions;
if (state.logging) {
console.log('Axium Received a Bad Action: ', action);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../mo
import { AxiumState } from '../axium.concept';
import { selectPayload } from '../../../model/selector';

export type ClearBadActionTypeFromBadActionListPayload = ActionType;
export type ClearBadActionTypeFromBadActionListPayload = {
actionType: 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);
const actionType = selectPayload<ClearBadActionTypeFromBadActionListPayload>(action).actionType;
return {
...state,
badActions: state.badActions.filter(act => act.type !== actionType),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../mo
import { AxiumState } from '../axium.concept';
import { selectPayload } from '../../../model/selector';

export type ClearBadPlanFromBadPlanListPayload = string;
export type ClearBadPlanFromBadPlanListPayload = {
title: 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);
const title = selectPayload<ClearBadPlanFromBadPlanListPayload>(action).title;
return {
...state,
badPlans: state.badPlans.filter(act => act.title !== title),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../mo
import { AxiumState } from '../axium.concept';
import { selectPayload } from '../../../model/selector';

export type ClearBadStrategyTopicFromBadActionListPayload = string;
export type ClearBadStrategyTopicFromBadActionListPayload = {
topic: 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);
const strategyTopic = selectPayload<ClearBadStrategyTopicFromBadActionListPayload>(action).topic;
const badActions = state.badActions.filter(act => {
if (act.strategy && act.strategy.topic !== strategyTopic) {
return true;
Expand Down
8 changes: 5 additions & 3 deletions src/concepts/axium/qualities/open.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../mo
import { AxiumState } from '../axium.concept';
import { selectPayload } from '../../../model/selector';

export type OpenPayload = boolean;
export type OpenPayload = {
open: boolean
};

export const axiumOpenType: ActionType = 'Open Axium';
export const axiumOpen = prepareActionWithPayloadCreator<OpenPayload>(axiumOpenType);

export function openReducer(state: AxiumState, action: Action): AxiumState {
const payload = selectPayload<OpenPayload>(action);
const open = selectPayload<OpenPayload>(action).open;
return {
...state,
open: payload,
open,
};
}
export const axiumOpenQuality = createQuality(
Expand Down
5 changes: 2 additions & 3 deletions src/concepts/axium/strategies/addConcept.strategy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Subject } from 'rxjs';
import { createStrategy, ActionStrategy, ActionStrategyParameters, createActionNode } from '../../../model/actionStrategy';
import { Concept, Concepts } from '../../../model/concept';
import { Action, getSemaphore} from '../../../model/action';
import { getSemaphore} from '../../../model/action';
import { axiumAddConceptFromQue, axiumAddConceptFromQueType } from '../qualities/addConceptsFromQue.quality';
import { axiumAppendConceptsToAddQue, axiumAppendConceptsToAddQueType } from '../qualities/appendConceptsToAddQue.quality';
import { axiumOpen, axiumOpenType } from '../qualities/open.quality';
Expand Down Expand Up @@ -42,7 +41,7 @@ export function addConceptsFromQueThenUnblockStrategy(conceptualSet: Concepts):
const setDefaultModeSemaphore = getSemaphore(conceptualSet, axiumName, axiumSetDefaultModeType);
const openSemaphore = getSemaphore(conceptualSet, axiumName, axiumOpenType);

const stepThree = createActionNode(axiumOpen(true), {
const stepThree = createActionNode(axiumOpen({open: true}), {
successNode: null,
successNotes: {
preposition: 'Reinstate',
Expand Down
2 changes: 1 addition & 1 deletion src/concepts/axium/strategies/initialization.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function initializationStrategy(concepts: Concepts): ActionStrategy {
const setDefaultModeSemaphore = getSemaphore(concepts, axiumName, axiumSetDefaultModeType);
const openSemaphore = getSemaphore(concepts, axiumName, axiumOpenType);

const stepThree: ActionNode = createActionNode(axiumOpen(true), {
const stepThree: ActionNode = createActionNode(axiumOpen({open: true}), {
semaphore: openSemaphore,
successNode: null,
successNotes: {
Expand Down
2 changes: 1 addition & 1 deletion src/concepts/axium/strategies/removeConcept.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function removeConceptsViaQueThenUnblockStrategy(concepts: Concepts): Act
const setDefaultModeSemaphore = getSemaphore(concepts, axiumName, axiumSetDefaultModeType);
const openSemaphore = getSemaphore(concepts, axiumName, axiumOpenType);

const stepThree = createActionNode(axiumOpen(true), {
const stepThree = createActionNode(axiumOpen({open: true}), {
semaphore: openSemaphore,
successNode: null,
successNotes: {
Expand Down
8 changes: 0 additions & 8 deletions src/concepts/counter/qualities/add.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@ import { defaultMethodCreator, Method, MethodCreator } from '../../../model/conc
import { Counter } from '../counter.concept';
import { createQuality } from '../../../model/concept';
import { counterSelectCount } from '../counter.selector';
// import { createMethod } from '../../../model/method';
// import { strategySuccess } from '../../../model/actionStrategy';

export const counterAddType: ActionType = 'Counter Add';

export const counterAdd = prepareActionCreator(counterAddType);
// const createAddMethodCreator: MethodCreator = () => createMethod((action) => {
// if (action.strategy) {
// return strategySuccess(action.strategy);
// }
// return action;
// });
export function addReducer(state: Counter, _: Action) {
return {
...state,
Expand Down
2 changes: 1 addition & 1 deletion src/concepts/counter/strategies/counting.strategy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createStrategy, ActionStrategy, ActionStrategyParameters, createActionNode } from '../../../model/actionStrategy';
import { Concept, Concepts} from '../../../model/concept';
import { Concepts} from '../../../model/concept';
import { getSemaphore } from '../../../model/action';
import { counterAdd, counterAddType } from '../qualities/add.quality';
import { counterSubtract, counterSubtractType } from '../qualities/subtract.quality';
Expand Down
4 changes: 2 additions & 2 deletions src/concepts/experiment/experiment.principle.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Subscriber } from 'rxjs';
import { Action, primeAction } from '../../model/action';
import { PrincipleFunction } from '../../model/principle';
import { Concept, Concepts } from '../../model/concept';
import { Concepts } from '../../model/concept';
import { UnifiedSubject } from '../../model/stagePlanner';
import { selectState, selectUnifiedState } from '../../model/selector';
import { selectUnifiedState } from '../../model/selector';
import { ExperimentState, experimentName } from './experiment.concept';
import { axiumRegisterStagePlanner } from '../axium/qualities/registerStagePlanner.quality';
import { axiumSelectOpen } from '../axium/axium.selector';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ActionStrategy, ActionStrategyParameters, createActionNode, createStrategy } from '../../../model/actionStrategy';
import { counterSelectCount } from '../../counter/counter.selector';
import { experimentMockTrue } from '../qualities/mockTrue.quality';
import { experimentTimerEmitActionWithState } from '../qualities/timerEmitActionWithState.quality';

Expand Down
4 changes: 2 additions & 2 deletions src/concepts/ownership/ownership.mode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Subject } from 'rxjs';
import { Action, createAction } from '../../model/action';
import { Concept, Concepts } from '../../model/concept';
import { Action } from '../../model/action';
import { Concepts } from '../../model/concept';
import { Mode } from '../../model/concept';
import { permissiveMode, blockingMode } from '../axium/axium.mode';
import { checkIn, clearStubs, ownershipShouldBlock, updateAddToPendingActions } from '../../model/ownership';
Expand Down
14 changes: 8 additions & 6 deletions src/concepts/ownership/ownership.principle.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Subscriber } from 'rxjs';
import { Concept, Concepts } from '../../model/concept';
import { Concepts } from '../../model/concept';
import { PrincipleFunction } from '../../model/principle';
import { OwnershipState, ownershipName} from '../ownership/ownership.concept';
import { setOwnershipModeStrategy } from './strategies/setOwnerShipMode.strategy';
import { Action, areSemaphoresEqual, createAction, primeAction } from '../../model/action';
import { selectState, selectUnifiedState } from '../../model/selector';
import { selectUnifiedState } from '../../model/selector';
import { strategyBegin } from '../../model/actionStrategy';
import { OwnershipTicket, createOwnershipLedger, isActionReady } from '../../model/ownership';
import { UnifiedSubject } from '../../model/stagePlanner';
Expand Down Expand Up @@ -69,17 +69,19 @@ export const ownershipPrinciple: PrincipleFunction = (
concepts$.next(concepts);
observer.next(newAction);
} else if (!newAction && ownershipState.pendingActions.length !== 0) {
const badActions: BadActionPayload = [];
const payload: BadActionPayload = {
badActions: []
};
const newPending: Action[] = [];
for (const pending of ownershipState.pendingActions) {
if (pending.expiration < Date.now()) {
badActions.push(denoteExpiredPending(pending));
payload.badActions.push(denoteExpiredPending(pending));
} else {
newPending.push(pending);
}
}
if (badActions.length > 0) {
newAction = createAction(axiumBadActionType, badActions);
if (payload.badActions.length > 0) {
newAction = createAction(axiumBadActionType, payload);
ownershipState.pendingActions = newPending;
concepts$.next(concepts);
observer.next(newAction);
Expand Down
6 changes: 4 additions & 2 deletions src/concepts/ownership/qualities/clearPayloadStubs.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { OwnershipState } from '../ownership.concept';
import { OwnershipTicket, OwnershipTicketStub } from '../../../model/ownership';
import { selectPayload } from '../../../model/selector';

export type ClearPayloadStubsPayload = OwnershipTicketStub[];
export type ClearPayloadStubsPayload = {
stubs: OwnershipTicketStub[]
};
export const ownershipClearPayloadStubsType: ActionType = 'clear payload Stubs from Ownership Ledger';
export const ownershipClearPayloadStubs = prepareActionWithPayloadCreator<ClearPayloadStubsPayload>(ownershipClearPayloadStubsType);

export function clearPayloadStubsReducer(state: OwnershipState, action: Action): OwnershipState {
const stubs = selectPayload<ClearPayloadStubsPayload>(action);
const stubs = selectPayload<ClearPayloadStubsPayload>(action).stubs;
const ownershipLedger = state.ownershipLedger;
stubs.forEach(ticketStub => {
const line = ownershipLedger.get(ticketStub.key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { OwnershipState } from '../ownership.concept';
import { ActionStrategyTopic } from '../../../model/actionStrategy';
import { selectPayload } from '../../../model/selector';

export type ClearPendingActionsOfStrategyPayload = ActionStrategyTopic;
export type ClearPendingActionsOfStrategyPayload = {
topic: ActionStrategyTopic
};
export const ownershipClearPendingActionsOfStrategyType: ActionType = 'clear Ownership\'s Pending Actions of Strategy Topic';
export const ownershipClearPendingActionsOfStrategy =
prepareActionWithPayloadCreator<ClearPendingActionsOfStrategyPayload>(ownershipClearPendingActionsOfStrategyType);

export function clearPendingActionsOfStrategyReducer(state: OwnershipState, action: Action): OwnershipState {
const topic = selectPayload<ClearPendingActionsOfStrategyPayload>(action);
const topic = selectPayload<ClearPendingActionsOfStrategyPayload>(action).topic;
const newPendingActions: Action[] = [];
for (const act of state.pendingActions) {
if (act.strategy?.topic) {
Expand Down
12 changes: 6 additions & 6 deletions src/model/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export type Action = {
type: ActionType;
semaphore: [number, number, number, number];
conceptSemaphore?: number;
payload?: unknown;
payload?: Record<string, unknown>;
strategy?: ActionStrategy;
keyedSelectors?: KeyedSelector[];
agreement?: number;
expiration: number;
axium?: string;
};

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

export function primeAction(concepts: Concepts, action: Action): Action {
const expired = action.expiration < Date.now();
Expand Down Expand Up @@ -63,7 +63,7 @@ export function primeAction(concepts: Concepts, action: Action): Action {
}
const badAction: Action = {
type: axiumBadActionType,
payload: createPayload<BadActionPayload>([action]),
payload: createPayload<BadActionPayload>({badActions: [action]}),
expiration: Date.now() + 5000,
semaphore: getSemaphore(concepts, concepts[0].name, axiumBadActionType)
};
Expand Down Expand Up @@ -157,9 +157,9 @@ function getSpecialSemaphore(type: ActionType) {
}
}

export function createAction(
export function createAction<T extends Record<string, unknown>>(
type: ActionType,
payload?: unknown,
payload?: T,
keyedSelectors?: KeyedSelector[],
agreement?: number,
_semaphore?: [number, number, number, number],
Expand Down Expand Up @@ -188,7 +188,7 @@ export function prepareActionCreator(actionType: ActionType) {
return createAction(actionType, undefined, keyedSelectors, agreement, qualitySemaphore, conceptSemaphore);
};
}
export function prepareActionWithPayloadCreator<T>(actionType: ActionType) {
export function prepareActionWithPayloadCreator<T extends Record<string, unknown>>(actionType: ActionType) {
return (
payload: T,
conceptSemaphore?: number,
Expand Down
4 changes: 2 additions & 2 deletions src/model/actionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ActionController extends Subject<Action> {
strategyData_appendFailure(this.action.strategy, failureConditions.controllerExpired)
));
} else {
this.next(axiumBadAction([this.action]));
this.next(axiumBadAction({badActions: [this.action]}));
}
} else {
this.timer = setTimeout(() => {
Expand All @@ -30,7 +30,7 @@ export class ActionController extends Subject<Action> {
strategyData_appendFailure(this.action.strategy, failureConditions.controllerExpired)
));
} else {
this.next(axiumBadAction([this.action]));
this.next(axiumBadAction({badActions: [this.action]}));
}
}, this.expiration - Date.now());
}
Expand Down
Loading

0 comments on commit 6f74af2

Please sign in to comment.