Skip to main content

execute_object

Function execute_object 

Source
pub fn execute_object(
    nodes_batch: &RecordBatch,
    node_id: &str,
    call_args: &str,
    timeout: Option<Duration>,
) -> Result<ExecutionResult>
Expand description

Execute a CodeNode’s body as Python code.

Reads the node’s signature and docstring from the Arrow batch, constructs a minimal Python script, and executes it via python3 -c. This proves the D4 principle (“there are no files”) — code executes from graph objects.

§Arguments

  • nodes_batch — The CodeNodes RecordBatch
  • node_id — ID of the function/method to execute
  • call_args — Arguments to pass to the function (Python expression)
  • timeout — Maximum execution time (None = 30 seconds)

§Safety — UNSAFE: call_args is not sanitized

call_args is interpolated directly into a Python string and executed. This is an internal API for trusted agent callers only. Do NOT pass untrusted user input as call_args — it enables arbitrary code execution. Input validation deferred to V14.1 sandboxing.

§Limitations (V14.0)

  • Only functions/methods with pure computation (no I/O, no imports beyond stdlib)
  • Body is reconstructed from signature + “pass” (actual body storage is Phase 2)
  • No import sandboxing in V14.0
  • subprocess-based, not in-process (PyO3 deferred to V14.1)