ADR-012: Five Engines Platform Architecture + Economic Engine
- LANDVEX_PLATFORM_ARCHITECTURE.md: Five Engines (Reality, Knowledge, Decision, Mission, Economic) - Credit: first-class economic object with types (mission, validation, training, priority, emergency) - IntelligenceLedger: tracks value creation separate from financial accounting - KnowledgeGap: missing information that drives missions - Hotspot: composite score for mission generation - Contradiction: conflicting information as opportunity Key principle: Every component answers 'What value is created here? Who pays for it?' Next: PR-005A — Minimal Mission Import UI for MVP-0
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Credit — First-class economic object
|
||||
*
|
||||
* ADR-012: Economic Engine
|
||||
* Credits are not just balances. They are typed, budgeted, tracked.
|
||||
*/
|
||||
|
||||
export type CreditType = 'mission' | 'validation' | 'training' | 'priority' | 'emergency';
|
||||
|
||||
export interface Credit {
|
||||
readonly id: string;
|
||||
readonly type: CreditType;
|
||||
readonly amount: number; // In smallest unit (öre/cents)
|
||||
readonly currency: 'SEK' | 'EUR' | 'USD';
|
||||
readonly budgetId: string;
|
||||
readonly missionId?: string;
|
||||
readonly status: 'reserved' | 'consumed' | 'released';
|
||||
readonly createdAt: Date;
|
||||
readonly expiresAt?: Date;
|
||||
}
|
||||
|
||||
export interface CreditBudget {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly totalAmount: number;
|
||||
readonly consumedAmount: number;
|
||||
readonly reservedAmount: number;
|
||||
readonly creditTypes: CreditType[];
|
||||
readonly validFrom: Date;
|
||||
readonly validTo: Date;
|
||||
}
|
||||
|
||||
export class CreditFactory {
|
||||
static create(params: {
|
||||
id: string;
|
||||
type: CreditType;
|
||||
amount: number;
|
||||
currency: 'SEK' | 'EUR' | 'USD';
|
||||
budgetId: string;
|
||||
missionId?: string;
|
||||
expiresAt?: Date;
|
||||
}): Credit {
|
||||
return {
|
||||
...params,
|
||||
status: 'reserved',
|
||||
createdAt: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
static consume(credit: Credit): Credit {
|
||||
return { ...credit, status: 'consumed' };
|
||||
}
|
||||
|
||||
static release(credit: Credit): Credit {
|
||||
return { ...credit, status: 'released' };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Intelligence Ledger — Track value creation
|
||||
*
|
||||
* ADR-012: Economic Engine
|
||||
* Separate from financial accounting.
|
||||
* Tracks: knowledge produced, decisions made, business impact, ROI.
|
||||
*/
|
||||
|
||||
export interface IntelligenceLedgerEntry {
|
||||
readonly id: string;
|
||||
readonly missionId: string;
|
||||
readonly budgetId: string;
|
||||
readonly creditsAllocated: number;
|
||||
readonly creditsConsumed: number;
|
||||
readonly observationsProduced: number;
|
||||
readonly decisionsProduced: number;
|
||||
readonly businessImpact?: string;
|
||||
readonly roi?: number; // Percentage
|
||||
readonly createdAt: Date;
|
||||
}
|
||||
|
||||
export interface IntelligenceLedger {
|
||||
readonly entries: IntelligenceLedgerEntry[];
|
||||
|
||||
// Queries
|
||||
totalKnowledgeProduced(): number;
|
||||
totalDecisionsProduced(): number;
|
||||
averageRoi(): number;
|
||||
costPerDecision(): number;
|
||||
}
|
||||
|
||||
export class IntelligenceLedgerFactory {
|
||||
static createEntry(params: {
|
||||
id: string;
|
||||
missionId: string;
|
||||
budgetId: string;
|
||||
creditsAllocated: number;
|
||||
creditsConsumed: number;
|
||||
observationsProduced: number;
|
||||
decisionsProduced: number;
|
||||
businessImpact?: string;
|
||||
}): IntelligenceLedgerEntry {
|
||||
const roi = params.creditsConsumed > 0
|
||||
? ((params.observationsProduced + params.decisionsProduced * 10) / params.creditsConsumed) * 100
|
||||
: 0;
|
||||
|
||||
return {
|
||||
...params,
|
||||
roi,
|
||||
createdAt: new Date(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,27 @@ export {
|
||||
DataLifecycleStep,
|
||||
DataLifecycleRules,
|
||||
} from './artifacts/data-lifecycle';
|
||||
|
||||
// Economic Engine
|
||||
export {
|
||||
Credit,
|
||||
CreditType,
|
||||
CreditBudget,
|
||||
CreditFactory,
|
||||
} from './economic/credit';
|
||||
|
||||
export {
|
||||
IntelligenceLedger,
|
||||
IntelligenceLedgerEntry,
|
||||
IntelligenceLedgerFactory,
|
||||
} from './economic/intelligence-ledger';
|
||||
|
||||
// Mission Engine
|
||||
export {
|
||||
KnowledgeGap,
|
||||
Hotspot,
|
||||
Contradiction,
|
||||
} from './mission/knowledge-gap';
|
||||
export * from './common/enums';
|
||||
export * from './common/errors';
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Knowledge Gap — Missing information that drives missions
|
||||
*
|
||||
* ADR-012: Mission Engine
|
||||
* Knowledge gaps drive new missions, not just customer orders.
|
||||
*/
|
||||
|
||||
import { GeoLocation } from '../common/value-objects';
|
||||
|
||||
export interface KnowledgeGap {
|
||||
readonly id: string;
|
||||
readonly areaId: string;
|
||||
readonly location: GeoLocation;
|
||||
readonly coverage: number; // 0.0 to 1.0
|
||||
readonly confidence: number; // 0.0 to 1.0
|
||||
readonly priority: 'low' | 'medium' | 'high' | 'critical';
|
||||
readonly estimatedValue: number; // In credits
|
||||
readonly budgetId?: string;
|
||||
readonly recommendedMissionType: 'inspection' | 'verification' | 'survey';
|
||||
readonly createdAt: Date;
|
||||
}
|
||||
|
||||
export interface Hotspot {
|
||||
readonly id: string;
|
||||
readonly areaId: string;
|
||||
readonly location: GeoLocation;
|
||||
readonly score: number; // Composite score
|
||||
readonly factors: {
|
||||
readonly observationDensity: number;
|
||||
readonly contradictions: number;
|
||||
readonly customerRequests: number;
|
||||
readonly riskTrend: number;
|
||||
readonly businessValue: number;
|
||||
};
|
||||
readonly recommendedMissions: string[]; // KnowledgeGap IDs
|
||||
}
|
||||
|
||||
export interface Contradiction {
|
||||
readonly id: string;
|
||||
readonly sourceA: {
|
||||
readonly type: 'observation' | 'register' | 'prediction';
|
||||
readonly id: string;
|
||||
readonly value: string;
|
||||
};
|
||||
readonly sourceB: {
|
||||
readonly type: 'observation' | 'register' | 'prediction';
|
||||
readonly id: string;
|
||||
readonly value: string;
|
||||
};
|
||||
readonly confidence: number;
|
||||
readonly potentialValue: number;
|
||||
readonly suggestedMissionId?: string;
|
||||
readonly createdAt: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user