Python API

class netforge_rl.ActionEffect(success: bool, state_deltas: Dict[str, Any] | List[IStateDeltaCommand], observation_data: Dict[str, Any], eta: int = 0, action: BaseAction | None = None)[source]

Bases: object

Result of executing an action — consumed by the conflict resolver.

class netforge_rl.BaseAction(agent_id: str, target_ip: str | None = None, source_ip: str | None = None, cost: int = 1, financial_cost: int = 0, compute_cost: int = 0, duration: int = 1, required_prior_state: str | None = None)[source]

Bases: ABC

class netforge_rl.BaseObservation(agent_id: str)[source]

Bases: object

Per-agent partial view of the network.

update_from_state(global_state, _action_effects: list)[source]

Filter global_state down to what this agent can observe.

to_numpy(max_size: int = 256) → ndarray[source]

Pack observation into a fixed-size float32 vector for the agent.

class netforge_rl.GlobalNetworkState[source]

Bases: object

Mutable single source of truth for the legacy MARL physics engine.

apply_delta(delta_key: Any, delta_value: Any = None)[source]

Apply a state delta — either a Command object or a string.

can_route_to(target_ip: str, port: int = None, agent_id: str = None) → bool[source]

Evaluate subnet routing + firewall blocks + ZTNA gate.

get_adjacency_matrix() → ndarray[source]

100x100 adjacency matrix.

reallocate_dhcp(rng=None)[source]

Reshuffle IPs on every non-DMZ subnet; invalidates stale agent knowledge.

class netforge_rl.NetForgeRLEnv(scenario_config: dict | EnvConfig | None = None)[source]

Bases: BaseNetForgeRLEnv, EpisodeMetricsMixin, ObservationMixin

PettingZoo parallel env.

reset(seed=None, options=None) → tuple[dict, dict][source]

Resets the environment.

And returns a dictionary of observations (keyed by the agent name)

observation_space(agent)[source]

Takes in agent and returns the observation space for that agent.

MUST return the same value for the same agent name

Default implementation is to return the observation_spaces dict

action_space(agent)[source]

Takes in agent and returns the action space for that agent.

MUST return the same value for the same agent name

Default implementation is to return the action_spaces dict

step(agent_actions: dict)[source]

Receives a dictionary of actions keyed by the agent name.

Returns the observation dictionary, reward dictionary, terminated dictionary, truncated dictionary and info dictionary, where each dictionary is keyed by the agent.

render(mode: str = 'rgb_array')[source]

Displays a rendered frame from the environment, if supported.

Alternate render modes in the default environments are ‘rgb_array’ which returns a numpy array and is supported by all environments outside of classic, and ‘ansi’ which returns the strings printed (specific to classic environments).

Environment API · SIEM API · NLP encoder API · Sim2Real API