How aeriesec/orgforge works
1. What this repo is
OrgForge is a deterministic, event-driven simulation engine for generating synthetic enterprise corpora. The core architectural idea is that a single simulated state machine produces a canonical event log, and all downstream artifacts are derived from that log rather than independently “invented” by LLM calls.
2. Top-level execution flow
The main runtime starts in src/flow.py, which acts as the simulation orchestrator. It advances day by day, applies org lifecycle changes, asks planners for what should happen next, dispatches those plans into typed activities, and records every significant action as a SimEvent in the shared memory/event bus.
3. Planning boundary vs execution boundary
src/day_planner.py and src/planner_models.py handle the LLM-facing planning layer: they propose daily activities per department and define the structured plan objects. src/plan_validator.py is the important integrity boundary; it checks the LLM-produced plan before execution so invalid or out-of-sequence actions do not enter the simulation.
4. Normal-day artifact generation
src/normal_day.py is the dispatcher for routine simulation output. It turns validated activities into concrete artifacts such as Slack chatter, Confluence pages, JIRA tickets, Zoom transcripts, Git PRs, and other day-to-day business output. This is where typed artifact generation happens, but only from already-established simulation facts.
5. Shared event log and memory
src/memory.py is the central knowledge substrate. It stores the SimEvent stream and supports retrieval for later artifact generation. The architecture is intentionally grounded here: artifacts read facts from the event log, which prevents temporal drift across multi-day output and makes the corpus suitable for evaluation.
6. Org lifecycle and knowledge gaps
src/org_lifecycle.py models hires, departures, and associated knowledge gaps. Departures are not just HR events; they trigger state changes that affect incident handoffs, ownership, and future explanations in generated artifacts. The README’s “departure cascade” is a key cross-cutting behavior that propagates into planning, graph dynamics, and downstream documents.
7. Social graph and stress propagation
src/graph_dynamics.py maintains the weighted relationship graph for the organization. It drives stress propagation, edge decay, escalation routing, and recomputation of centrality after roster changes. This subsystem is important because it influences who gets pulled into incidents, how load shifts after departures, and how morale/stress evolves over time.
8. CRM and customer-facing propagation
src/crm_system.py manages Salesforce and Zendesk behavior as a coupled domain. When incidents occur, the simulation can propagate effects into customer support tickets, account risk flags, opportunity status, and escalations. This is a major boundary because it links internal engineering events to customer-impact artifacts.
9. Specialized domain handlers
Several modules generate domain-specific outputs from shared simulation state: src/confluence_writer.py, src/external_email_ingest.py, src/ticket_assigner.py, src/causal_chain_handler.py, and src/post_sim_artifacts.py. They are not separate sources of truth; they are consumers of the event log and simulation state, each responsible for one output surface or post-processing step.
10. Stateful world components
src/sim_clock.py provides deterministic time progression; src/genesis.py and src/org_lifecycle.py bootstrap the org state; src/artifact_registry.py tracks artifact types and outputs; src/agent_factory.py and src/flow.py coordinate the roles that participate in the simulation. Together these form the internal world model that the planner and artifact writers operate against.
11. Insider threat as an isolated overlay
src/insider_threat.py adds an optional adversarial layer without contaminating the normal simulation path. When enabled, it emits separate security telemetry and keeps ground truth distinct from normal enterprise artifacts. This is architecturally important because the threat signals are an orthogonal data stream, not part of the main business-event corpus.
12. Embedding and retrieval support
src/embed_worker.py supports vector embedding generation for memory/RAG-style workflows. The README indicates the project can use local Ollama models, AWS Bedrock, OpenAI embeddings, or local GPU models depending on config/config.yaml. That means model choice is a deployment/runtime concern, while the simulation semantics remain the same.
13. Configuration and deployment boundaries
config/config.yaml is the single source of truth for company structure, personas, lifecycle schedules, quality presets, and external contacts. The repo is containerized with Docker and docker-compose.yaml, and can run with MongoDB plus either local Ollama or cloud LLM services. Those infrastructure choices affect how model calls and persistence are wired, but not the core simulation architecture.
14. Evaluation and export pipeline
The eval/ subtree contains dataset export and insider-threat evaluation scripts, including HuggingFace export support. This is a downstream analysis layer, separate from simulation generation. It consumes exported artifacts and ground truth to benchmark retrieval, rescore outputs, and package datasets for external use.
15. Testing and correctness strategy
The tests/ directory covers the major architectural seams: flow, lifecycle, memory, planning, routing, CRM behavior, external email handling, insider threat, and post-simulation artifacts. That test layout mirrors the subsystem boundaries and reinforces that the repo’s correctness depends on deterministic state transitions and consistent cross-artifact grounding.
Main entry points: memory.py Memory · flow.py Flow · normal_day.py Normal day · genesis.py Genesis
Components 21
Simulation core
Deterministic runtime, planning, memory, and state transitions.
- Flow · Main day-by-day simulation runtime.
src/flow.py - Clock · Deterministic simulation time progression.
src/sim_clock.py - Genesis · Initial org and world-state construction.
src/genesis.py - Lifecycle · Hires, departures, and knowledge-gap transitions.
src/org_lifecycle.py - Graph · Weighted relationships, stress propagation, and centrality updates.
src/graph_dynamics.py - Planner · Daily activity proposal layer.
src/day_planner.py - Plan models · Structured plan and activity definitions.
src/planner_models.py - Validator · Checks planned activities before execution.
src/plan_validator.py - Memory · Canonical SimEvent store and retrieval substrate.
src/memory.py
Domain outputs
Concrete business and security artifact generation surfaces.
- Normal day · Routes validated activities into routine artifacts.
src/normal_day.py - CRM · Salesforce and Zendesk coupled customer-impact state.
src/crm_system.py - Confluence · Generates knowledge-base pages from simulation facts.
src/confluence_writer.py - Email ingest · Processes external email-driven signals.
src/external_email_ingest.py - Ticketing · Assigns and routes operational tickets.
src/ticket_assigner.py - Causal chain · Derives linked event narratives and explanations.
src/causal_chain_handler.py - Post-sim · Generates final artifacts after simulation ends.
src/post_sim_artifacts.py - Insider threat · Optional adversarial telemetry stream.
src/insider_threat.py
Config and runtime
Configuration, embedding, persistence, and deployment boundaries.
Evaluation
Export and benchmarking workflows.
- Export · Converts artifacts for external evaluation use.
eval/export_to_hf.py - Threat eval · Insider-threat evaluation and rescoring pipeline.
eval/insider_threat/eval_insider_threat.py
Connections 22
- Config → Genesis: bootstrap · Configuration seeds initial org state.
- Genesis → Flow: start · Initial world state enters the main runtime.
- Clock → Flow: ticks · Deterministic time advances the simulation.
- Flow → Lifecycle: applies · Roster and ownership changes are executed.
- Flow → Graph: updates · Relationship graph is recomputed after state changes.
- Flow → Planner: requests · Daily planning is generated from current state.
- Planner → Plan models: produces · LLM-facing planner emits structured plans.
- Plan models → Validator: validated by · Plan schema and sequencing are checked before execution.
- Validator → Normal day: approves · Only valid activities reach the dispatcher.
- Flow → Memory: records · Significant actions are appended as canonical events.
- Normal day → Memory: reads/writes · Routine artifact generation consumes and emits grounded facts.
- Memory → Normal day: retrieves · Artifacts are derived from prior event log context.
- Normal day → Confluence: writes · Generates knowledge-base pages.
- Normal day → CRM: updates · Propagates incidents into customer-facing systems.
- Normal day → Ticketing: routes · Creates and assigns operational tickets.
- Email ingest → Memory: ingests · External mail becomes simulation-grounded evidence.
- Causal chain → Memory: explains · Derives narrative chains from the event log.
- Post-sim → Export: exports · Final corpus is packaged for downstream analysis.
- Insider threat → Memory: separates · Security telemetry remains an orthogonal stream.
- Embedding → Memory: indexes · Embeddings support retrieval over stored events.
- Flow → Insider threat: optional · Adversarial overlay may run alongside normal simulation.
- Memory → Threat eval: benchmarks · Ground truth and outputs support insider-threat evaluation.