Skip to content

Runtime Context

RuntimeContext lets you declare what you know about the environment before ixtract runs. It constrains the plan without polluting the learned baseline.

RuntimeContext is a set of user-declared beliefs about the current environment:

  • “The source database is under heavy load right now.”
  • “I only want 2 workers maximum.”
  • “This extraction must finish within 30 minutes.”

These beliefs constrain the planner’s search space. They are stored with the run for history and audit, but they never feed the controller — a constrained run does not teach ixtract that “fewer workers is better.”

The five-stage resolution runs in order:

Stage 1 base workers benchmark → controller → profiler
Stage 2 hard caps max_workers, min_workers
Stage 3 soft multipliers source_load × network_quality
Stage 4 priority low/normal/high priority multiplier
Stage 5 clamp floor(result), enforce min floor

Rounding is floor() everywhere. ceil() is never used.

Flags: --source-load high --network-quality degraded --priority low

Worker Resolution
──────────────────────────────────────────
base 8 (controller, converged)
× network 0.75 (degraded)
× source 0.50 (high load)
→ env 3 (floor(8 × 0.75 × 0.50))
priority: low → 2
final 2

Result: 2 workers extracted 10M rows at 920K rows/sec — faster than 8 workers on this table. Over-parallelization was confirmed.

FieldTypeEffect
max_workersintUpper bound on workers — hard override
min_workersintLower bound on workers

Hard caps are applied in Stage 2, before multipliers.

FieldValuesMultiplier
source_loadlow / normal / high1.25 / 1.0 / 0.50
network_qualitygood / normal / degraded1.10 / 1.0 / 0.75
prioritylow / normal / highfloor to 2 / 1.0 / 1.25×

Multipliers stack. source_load=high + network_quality=degraded = 0.50 × 0.75 = 0.375 multiplier on base workers.

Advisories are informational. They produce warnings in the plan output and affect the verdict, but do not block execution.

FieldTypeAdvisory
target_duration_secondsintWarns if estimated duration exceeds target
maintenance_window_minutesintWarns if estimated duration approaches window
disk_budget_gbfloatWarns if estimated output size exceeds budget
egress_budget_gbfloatWarns if estimated egress exceeds budget
VerdictMeaning
SAFE TO RUNNo issues
SAFE WITH WARNINGSAdvisory thresholds exceeded — review before running
NOT RECOMMENDEDHard constraint would produce a dangerous or invalid plan

NOT RECOMMENDED does not block execution by default. Use --force to proceed anyway, or call execute(result, force=True).

Terminal window
ixtract execute orders \
--source-load high \
--network-quality degraded \
--priority low \
--max-workers 4 \
--target-duration-seconds 60
Terminal window
ixtract execute orders --context-file ctx.json

ctx.json:

{
"source_load": "high",
"network_quality": "degraded",
"priority": "low",
"max_workers": 4
}
from ixtract import RuntimeContext, plan, execute
ctx = RuntimeContext(
source_load="high",
network_quality="degraded",
priority="low",
max_workers=4,
)
result = plan(intent, runtime_context=ctx)
print(result.verdict)
if result.is_safe:
execution = execute(result)
  • RuntimeContext never overrides the planner — it constrains the search space.
  • RuntimeContext never affects the controller — plan-time only.
  • RuntimeContext never feeds learning — stored for history only.
  • The system is identical without RuntimeContext — every field defaults to None.
  • Order is always: base → hard caps → multipliers → priority → clamp.