Everyone who is intrested in educational gaming and macros is welcome to join. drop it into @NicholaiMadias/sovereign-matrix.
- Matrix Reputation Engine
1.1 Data model
// types.ts export type ReputationVector = { karma: number; // actions → consequences community: number; // collaboration / generosity wisdom: number; // intelligence / experience / intuition integrity: number; // honesty / reliability / creditworthiness creditScore: number; // numeric credit-like score trustScore: number; // social trust / reputation };
1.2 Engine
// reputationEngine.ts import type { ReputationVector } from './types';
export type ReputationEventType = | 'karma' | 'community' | 'wisdom' | 'integrity';
export interface ReputationEvent { type: ReputationEventType; value: number; // positive or negative ts: number; source: string; }
export function applyReputationEvent( rep: ReputationVector, event: ReputationEvent ): ReputationVector { const next = { ...rep };
switch (event.type) { case 'karma': next.karma += event.value; break; case 'community': next.community += event.value; break; case 'wisdom': next.wisdom += event.value; break; case 'integrity': next.integrity += event.value; break; }
// Clamp base dimensions ['karma','community','wisdom','integrity'].forEach(k => { // @ts-ignore next[k] = Math.max(-1000, Math.min(1000, next[k])); });
// Derive credit & trust next.creditScore = Math.round( 0.4 * normalize(next.integrity) + 0.3 * normalize(next.karma) + 0.3 * normalize(next.wisdom) );
next.trustScore = Math.round( 0.5 * normalize(next.community) + 0.3 * normalize(next.integrity) + 0.2 * normalize(next.karma) );
return next; }
function normalize(v: number): number { // Map [-1000, 1000] → [0, 100] return ((v + 1000) / 2000) * 100; }
- Matrix Social Graph
2.1 Schema
// socialGraph.ts export interface Edge { from: string; // uid to: string; // uid weight: number; // strength of relationship tags: string[]; // e.g. ["mentor","ally","team"] }
export interface SocialGraph { nodes: Set; edges: Edge[]; }
2.2 Core operations
export function addInteraction( graph: SocialGraph, from: string, to: string, delta: number, tag?: string ): SocialGraph { const next: SocialGraph = { nodes: new Set(graph.nodes), edges: [...graph.edges] };
next.nodes.add(from); next.nodes.add(to);
const edge = next.edges.find(e => e.from === from && e.to === to); if (edge) { edge.weight += delta; if (tag && !edge.tags.includes(tag)) edge.tags.push(tag); } else { next.edges.push({ from, to, weight: delta, tags: tag ? [tag] : [] }); }
return next; }
export function getNeighbors(graph: SocialGraph, uid: string): Edge[] { return graph.edges.filter(e => e.from === uid || e.to === uid); }
- Matrix Karma Economy
3.1 Action → reward mapping
// karmaEconomy.ts export type KarmaAction = | 'helped_peer' | 'completed_mission' | 'donation' | 'spam' | 'exploit';
export interface KarmaRule { action: KarmaAction; karmaDelta: number; communityDelta: number; rewardStars?: number; rewardTokens?: number; }
export const KARMA_RULES: KarmaRule[] = [ { action: 'helped_peer', karmaDelta: 5, communityDelta: 8, rewardStars: 0, rewardTokens: 5 }, { action: 'completed_mission', karmaDelta: 10, communityDelta: 4, rewardStars: 1, rewardTokens: 10 }, { action: 'donation', karmaDelta: 15, communityDelta: 10, rewardStars: 1, rewardTokens: 20 }, { action: 'spam', karmaDelta: -20, communityDelta: -15 }, { action: 'exploit', karmaDelta: -40, communityDelta: -30 } ];
export function resolveKarmaAction(action: KarmaAction): KarmaRule {
const rule = KARMA_RULES.find(r => r.action === action);
if (!rule) throw new Error(Unknown karma action: ${action});
return rule;
}
3.2 Applying to MatrixState + Reputation
// karmaApply.ts import { applyTelemetryEvent } from './matrixTelemetry'; import { applyReputationEvent } from './reputationEngine'; import { resolveKarmaAction } from './karmaEconomy';
export function applyKarmaAction(matrixState: any, rep: any, action: KarmaAction) { const rule = resolveKarmaAction(action);
// Map to telemetry events if (rule.karmaDelta !== 0) { applyTelemetryEvent(matrixState, { type: 'karma', value: rule.karmaDelta, ts: Date.now(), source: 'karma-economy' }); }
if (rule.communityDelta !== 0) { applyTelemetryEvent(matrixState, { type: 'community', value: rule.communityDelta, ts: Date.now(), source: 'karma-economy' }); }
// Reputation rep = applyReputationEvent(rep, { type: 'karma', value: rule.karmaDelta, ts: Date.now(), source: 'karma-economy' });
rep = applyReputationEvent(rep, {
type: 'community',
value: rule.communityDelta,
ts: Date.now(),
source: '
