Centralized constants module providing system-wide configuration
values, magic strings, and type mappings used throughout the Axion
framework. All shared constants belong here per project convention.
Constants are defined as Python class attributes with type hints,
then optionally overridden via a three-tier precedence system:
ObjConstants.py)ObjConstants.yaml — loaded at import time)This allows operators to tune constants per environment without
touching Python code.
Module: factory.core/ObjConstants.py
YAML: factory.core/ObjConstants.yaml
Test file: resource.test/pytests/factory.core/test_ObjConstants.py
DEFAULT_THREAD_MAX replaces per-module thread pool sizes.DO_DEBUG and DEF_VERSION stay per-module — they areTHIS_SERVICE stays per-module — identifies the serviceAt the bottom of ObjConstants.py, the function _apply_yaml_overlay()
runs automatically at import time. It reads ObjConstants.yaml from
the same directory and overlays matching values onto the Python
constant classes.
After the application initializes ConfigIni, it can call
apply_config_overlay(ini) to apply a second layer of overrides
from config.yaml.
config.yaml (package-specific section)
|
config.yaml (base section)
|
ObjConstants.yaml (defaults section)
|
Python class attribute (hardcoded default)
database:
queries: {}
schema: {}
defaults:
AiConstants:
# Tier-aware generation models (picked by ObjAI._active_tier).
GENERATION_CPU_LOW: "qwen3:1.7b"
GENERATION_CPU_HIGH: "qwen2.5:3b"
GENERATION_GPU_LOW: "gemma3"
GENERATION_GPU_HIGH: "qwen3:14b"
# Vision defaults — empty string on a tier means "skip".
VISION_CPU_LOW: ""
VISION_CPU_HIGH: "qwen2.5vl:3b"
VISION_GPU_LOW: "qwen2.5vl:7b"
VISION_GPU_HIGH: "llama3.2-vision:11b"
# Embedding defaults — small models, same on lower tiers.
EMBEDDING_CPU_LOW: "nomic-embed-text"
EMBEDDING_CPU_HIGH: "nomic-embed-text"
EMBEDDING_GPU_LOW: "nomic-embed-text"
EMBEDDING_GPU_HIGH: "mxbai-embed-large"
# Tier selection thresholds.
TIER_GPU_HIGH_MIN_VRAM_GB: 16
TIER_GPU_LOW_MIN_VRAM_GB: 4
TIER_CPU_HIGH_MIN_CORES: 8
# Legacy aliases — point at the GPU_HIGH tier for callers
# that have not yet migrated to get_model*() .
DEFAULT_OLLAMA_MODEL: "qwen3:14b"
DEFAULT_VISION_MODEL: "qwen2.5vl:7b"
DEFAULT_EMBEDDING_MODEL: "nomic-embed-text"
DEFAULT_OLLAMA_URI: "http://localhost:11434"
MonitorConstants:
MONITOR_DB: "monitor.axion"
PROBE_TIMEOUT_SECS: 3
CONNECTION_TIMEOUT_MS: 30000
WEBHOOK_PORT: 9500
module_level:
DEFAULT_TIMEOUT_SECS: 10
BLOOM_LIMIT: 200
The defaults section mirrors the Python class structure. Each
top-level key is a class name; nested keys are attribute names.
The special key module_level targets module-level constants
(not inside any class).
To change a default for all environments, edit ObjConstants.yaml.
To change a value for one package only, use config.yaml instead.
Add a constants section under base or any package section:
base:
constants:
AiConstants:
DEFAULT_OLLAMA_MODEL: "qwen3:32b"
MonitorConstants:
PROBE_TIMEOUT_SECS: 5
fullhouse:
constants:
MonitorConstants:
WEBHOOK_PORT: 9600
AiConstants:
DEFAULT_OLLAMA_MODEL: "deepseek-r1:14b"
The lookup uses ConfigIni.Get() with the section name
constants.<ClassName> and the attribute as the key:
ini.Get("constants.AiConstants", "DEFAULT_OLLAMA_MODEL")
This follows the standard ConfigIni package precedence: the active
package section is checked first, then base, then the default.
Call apply_config_overlay() after ConfigIni is initialized:
import Objects
from ObjConstants import apply_config_overlay
# After Objects.global_config is populated:
apply_config_overlay(Objects.global_config)
The overlay preserves the Python type of the original constant:
| Python type | YAML value | config.yaml value | Result |
|---|---|---|---|
int |
5 |
"5" |
int(5) |
float |
2.5 |
"2.5" |
float(2.5) |
bool |
true/false |
"true"/"false" |
bool |
str |
"value" |
"value" |
str |
list/dict/tuple |
(skipped) | (skipped) | unchanged |
Invalid conversions (e.g. "abc" for an int field) are silently
ignored — the original value is preserved.
Define the constant in the Python class (this is the default):
class MyConstants:
NEW_TIMEOUT: int = 30
Mirror it in ObjConstants.yaml under defaults.MyConstants:
defaults:
MyConstants:
NEW_TIMEOUT: 30
Operators can now override it per-package in config.yaml:
homechoice:
constants:
MyConstants:
NEW_TIMEOUT: 60
| Class | Purpose | Key Constants |
|---|---|---|
ConfigIniConstants |
Config file management | KEY_FOLDER, DEFAULT_PACKAGE, ENV_PACKAGE, SENSITIVE_KEYS, VAR_PACKAGE, REDACTED_VALUE |
EncryptionConstants |
Encryption operations | ENCRYPTION_PREFIX, DEFAULT_KEY_SIZE, KEY_CACHE_TTL |
PythonVersionConstants |
Interpreter requirements | MIN_MAJOR, MIN_MINOR, TARGET_MAJOR, TARGET_MINOR |
AppConstants |
General application | DEFAULT_RETRY_COUNT, LOG_FORMAT_DATETIME, DEFAULT_FILE_ENCODING |
| Class | Purpose | Key Constants |
|---|---|---|
WorkflowConstants |
Workflow orchestration | MULTIPROCESS_LIMIT, MAX_WORKFLOW_TRANSITIONS, PASSTHROUGH_NODE_TYPES, lane names |
WorkflowContextKeys |
Run context dict keys | PARAM1..PARAM3, RESULT, PROCESS_GUID, TRANSITIONS |
QueueContextKeys |
MongoDB queue dict keys | SERVICE_CODE, GUID, PACKAGE, STATUS, CONTEXT |
SimulationConstants |
Simulation/bloom analysis | RAW_VALUE_THRESHOLD, BAR_WIDTH, EMAIL_MAX_WIDTH, EMAIL_ATTACHMENT_MAX_GUIDS |
SchedulerConstants |
Scheduler operations | TRIGGER_INTERVAL_SECONDS, POLL_SLEEP_SECONDS, MAX_TASK_RETRIES |
| Class | Purpose | Key Constants |
|---|---|---|
WebHookConstants |
Webhook operations | HTTP_OK..HTTP_SERVER_ERROR, MAGIC_TOKEN, STATUS_ERROR/SUCCESS, value types, post types, table names |
| Class | Purpose | Key Constants |
|---|---|---|
DecisionSwitchConstants |
Decision trees | NODE_START/END, OPERATOR_MAP_SQL, CSV_COLUMNS, export formats, simulation limits |
DecisionSegmentConstants |
Segmentation engine | TABLE_SEGMENT/COLUMNS/HISTORY, operator groups, PATH_SEGMENTS, wildcards |
DecisionMatrixConstants |
Decision matrices | Match types, column names, cell types, CSV columns |
CalculationConstants |
Calculation engine | SERVICE_CODE, table names, SQL variants |
ScorecardConstants |
Scorecard evaluation | ELSE_ATTRIBUTE_ID, VIRTUAL_GUID_DEFAULT, ALPHA_EXCEPTIONS |
| Class | Purpose | Key Constants |
|---|---|---|
IconConstants |
Terminal/UI glyphs | OK/FAIL/WARN, tool icons (PYTHON, CYTHON), service icons (REDIS, DOCKER, SMTP) |
WorkflowNodeIcons |
BPMN node icons | One icon per workflow node type, grouped by category (tasks, events, gateways, meta states) |
| Class | Purpose | Key Constants |
|---|---|---|
AiConstants |
AI/LLM model defaults and hardware-tier picks | GENERATION_{CPU_LOW,CPU_HIGH,GPU_LOW,GPU_HIGH}, VISION_*, EMBEDDING_*, TIER_GPU_HIGH_MIN_VRAM_GB, TIER_CPU_HIGH_MIN_CORES, legacy DEFAULT_OLLAMA_MODEL / DEFAULT_VISION_MODEL / DEFAULT_EMBEDDING_MODEL |
MonitorConstants |
System monitoring | MONITOR_DB, PROBE_TIMEOUT_SECS, CONNECTION_TIMEOUT_MS, WEBHOOK_PORT |
InternetConstants |
LAN scanning | DEFAULT_SCAN_WORKERS, DEFAULT_PORT_WORKERS, SERVICE_FINGERPRINTS, PORT_HINTS |
| Class | Purpose | Key Constants |
|---|---|---|
TicketConstants |
Ticket/report | GENERAL_BUCKET, TECHNOCORE_COMPANY_KEY, INCIDENT_CAUSE_OPTIONS |
DocumentEnhancementConstants |
AI document processing | MAX_TEXT_CHARS, VISION_DOC_TYPES |
MqttConstants |
MQTT operations | ALERT_CHECK_INTERVAL_MINUTES |
GeoLocationConstants |
Geolocation | EARTH_RADIUS_KM, NOMINATIM_URL, POSTCODE_TABLE |
ConversationConstants |
Chat/messaging | DEFAULT_EXPIRE_TIME, AI_PROMPT_TIMEOUT_SECS, MAX_PAGE_LENGTH |
AclConstants |
Access control | ACL_CACHE_TTL_SECS, cache key prefixes |
| Class | Purpose | Key Constants |
|---|---|---|
TuiConstants |
Rich TUI dashboards | Refresh rates, display limits, thresholds (SUCCESS_RATE_HIGH, CPU_WARN_PCT), layout dimensions, poll intervals |
| Class | Purpose | Key Constants |
|---|---|---|
ThreadPoolConstants |
Thread/pool sizes | DEFAULT_THREAD_MAX = 20, DEFAULT_FETCH_SIZE, DEFAULT_INSTANCE_MAX |
RetryConstants |
Retry behaviour | MAX_RETRIES = 3, RETRY_DELAY_SECS = 0.5, RETRY_BACKOFF_BASE = 2 |
BatchConstants |
Batch sizes | DEFAULT_BATCH_SIZE = 10000, MAX_BLOCK_SIZE = 50000, SMALL_BATCH_SIZE = 100 |
EmailConstants |
SMTP/email | MAX_ATTACHMENT_SIZE_MB, MAX_EMAILS_PER_MINUTE, POP3_SSL_PORT |
SupervisorConstants |
Process supervision | MAX_SLEEP_SECS, MQ_QOS_BUFFER, MQ_MAX_BUFFER |
BackupConstants |
Backup operations | MIN_VALID_BACKUP_SIZE, DEFAULT_BACKUP_TIME, retention days |
DataImportConstants |
Import operations | FOLDER_SCAN_INTERVAL, IMPORT_MAX_ROWS |
CalendarConstants |
Time and calendar | WEEK_DAYS, SECONDS_PER_DAY, UTC_OFFSET |
MongoConstants |
MongoDB defaults | DEFAULT_MONGO_PORT = 27017 |
CacheConstants |
Cache buffer sizes | BUFFER_CACHE_MAX_SIZE = 1000 |
CdnConstants |
Frontend CDN URLs | jQuery, Bootstrap, Chart.js, DataTables, Mermaid, highlight.js, jsPDF, html2canvas, html2pdf, etc. |
| Constant | Value | Purpose |
|---|---|---|
EXTRACT_CONTEXT_PREFIXES |
["_form_", "_calc_", ...] |
Context parameter extraction |
REPORT_NOWRAP |
["_api", "_pdf", "_gui"] |
Report codes that skip HTML wrapping |
RESOURCE_IMAGES .. RESOURCE_TEST |
"resource.*" |
Static resource folder paths |
DATA_DOCUMENTS, LOCAL_DOCUMENTS, ARCHIVE_DOCUMENTS |
"*.documents" |
Document storage folders |
DEFAULT_PDF_DPI, LARGE_PDF_DPI |
500, 200 | PDF rendering DPI |
ICON_SIZE, PREVIEW_SIZE |
128, 512 | Document image sizing |
CACHE_TTL_LONG, CACHE_TTL_MEDIUM |
3600, 600 | LRU cache configuration |
REPORT_TTL_DEFAULT |
10 | Standard Redis cache TTL for reports (seconds) |
REPORT_TTL_DOCUMENTATION |
3600 | 1 hr Redis cache for documentation reports |
REPORT_TTL_STATIC |
300 | 5 min Redis cache for semi-static reports |
REPORT_TTL_REALTIME |
0 | No caching — report regenerated on every request |
DEFAULT_TIMEOUT_SECS, MONGODB_TIMEOUT_MS |
10, 5000 | Network timeout defaults |
MYSQL_TYPE_MAP |
dict[int, list[str]] |
MySQL type code to DDL mapping |
WORKFLOW_NODE_TYPE_MAP |
dict[str, str] |
Node type to executor class mapping |
from ObjConstants import (
LOCAL_DOCUMENTS,
DEFAULT_TIMEOUT_SECS,
IconConstants,
AiConstants,
)
path = os.path.join(LOCAL_DOCUMENTS, "report.pdf")
response = requests.get(url, timeout=DEFAULT_TIMEOUT_SECS)
self.debug(f"{IconConstants.OK} Connected")
model = f"mcp:ollama:{AiConstants.DEFAULT_OLLAMA_MODEL}"
Edit factory.core/ObjConstants.yaml:
defaults:
AiConstants:
DEFAULT_OLLAMA_MODEL: "qwen3:32b"
All modules importing AiConstants.DEFAULT_OLLAMA_MODEL will
now see "qwen3:32b" without any code changes.
base:
constants:
AiConstants:
DEFAULT_OLLAMA_MODEL: "qwen3:32b"
fullhouse:
constants:
AiConstants:
DEFAULT_OLLAMA_MODEL: "deepseek-r1:14b"
When the active package is fullhouse, the model will be
"deepseek-r1:14b". All other packages get "qwen3:32b".
When finding hardcoded values in existing code:
# Before
timeout = 3
model = "mistral"
# After
from ObjConstants import RetryConstants, AiConstants
timeout = RetryConstants.MAX_RETRIES
model = AiConstants.DEFAULT_OLLAMA_MODEL
_apply_yaml_overlay()Called automatically at import time. Reads ObjConstants.yaml
from the same directory as the module and overlays scalar values
onto matching class attributes.
apply_config_overlay(ini)Called manually after ConfigIni is initialized. Reads the
constants.<ClassName> sections from config.yaml via the
provided ConfigIni instance.
Args:
ini: A ConfigIni instance with a Get(section, key, default)Example:
import Objects
from ObjConstants import apply_config_overlay
apply_config_overlay(Objects.global_config)
The CdnConstants class holds versioned CDN URLs for all frontend
libraries used in reports and web views. Key entries added for the
documentation report system:
| Constant | Library | URL Pattern |
|---|---|---|
HIGHLIGHTJS_CSS_GITHUB_DARK |
highlight.js github-dark theme | cdnjs.cloudflare.com/.../github-dark.min.css |
JSPDF |
jsPDF 2.5 for PDF generation | cdnjs.cloudflare.com/.../jspdf.umd.min.js |
HTML2CANVAS |
html2canvas 1.4 for screenshots | cdnjs.cloudflare.com/.../html2canvas.min.js |
HTML2PDF |
html2pdf.js 0.10 bundle | cdnjs.cloudflare.com/.../html2pdf.bundle.min.js |
MERMAID_ESM |
Mermaid 10 ESM module import | cdn.jsdelivr.net/.../mermaid.esm.min.mjs |
These are used by ObjReportDocumentation._load_resources() to
inject the required <script> and <link> tags into documentation
reports. The existing MERMAID constant (non-ESM, Mermaid 11) and
HIGHLIGHTJS / HIGHLIGHTJS_CSS constants remain available for
other report types.
| Module | Constants Used |
|---|---|
ObjData.py |
MySQL type map, cache/timeout constants |
ObjWorkflow.py |
WorkflowConstants, context keys, node type map |
ObjHook.py |
WebHookConstants, context prefixes |
ObjAI.py |
AiConstants |
ObjMonitor.py |
MonitorConstants |
ObjInternet.py |
InternetConstants |
ObjBackup.py |
BackupConstants |
ObjDataImport.py |
DataImportConstants, BatchConstants |
ObjSupervisor.py |
SupervisorConstants |
ConfigIni.py |
ConfigIniConstants |