architecture/network/gating

Connection-gating utilities and gate-aware repair helpers for network edits.

Gating is the lightweight way to let one node decide how strongly another connection should matter right now. That makes this chapter about more than a simple gate() setter. It also owns the awkward structural case where a hidden node is removed and the network tries to preserve useful gated behavior by reconnecting predecessor and successor nodes, then reassigning preserved gaters onto the new bridge connections.

The split inside this folder follows those two jobs. gate.utils keeps ordinary gate and ungate bookkeeping small and predictable. remove.utils handles the more invasive bridge-repair flow used during gate-aware hidden node removal. The shared types file only carries temporary collections used during that repair work; it is not the right chapter intro.

flowchart LR
  Gater[Gater node activation] --> Modulate[Modulate connection gain]
  Modulate --> Target[Target node input sum]
  Remove[Remove hidden node] --> Bridge[Create bridge connections]
  Bridge --> Preserve[Reassign preserved gaters]

A useful mental model is that gating changes when a connection is influential, while bridge repair tries to preserve where information can still travel after topology surgery. Keeping both concerns together makes the public surface easier to learn because callers usually encounter them in the same network-editing workflows.

Example: attach a hidden node as a gater for one connection.

network.gate(hiddenNode, connection);

Example: later remove that modulation and return the connection to static weighting.

network.ungate(connection);

architecture/network/gating/network.gating.utils.ts

gate

gate(
  node: default,
  connection: default,
): void

Attach a gater node to a connection so that the connection's effective weight becomes dynamically modulated by the gater's activation (see {@link Node.gate} for exact math).

Validation / invariants:

Complexity: O(1)

Parameters:

removeNode

removeNode(
  node: default,
): void

Remove a hidden node from the network while attempting to preserve functional connectivity.

Algorithm outline:

  1. Reject removal if node is input/output (structural invariants) or absent (error).
  2. Optionally collect gating nodes (if keep_gates flag) from inbound & outbound connections.
  3. Remove self-loop (if present) to simplify subsequent edge handling.
  4. Disconnect all inbound edges (record their source nodes) and all outbound edges (record targets).
  5. For every (input predecessor, output successor) pair create a new connection unless: a. input === output (avoid trivial self loops) OR b. an existing projection already connects them.
  6. Reassign preserved gater nodes randomly onto newly created bridging connections.
  7. Ungate connections that were gated BY this node (where node acted as gater).
  8. Remove node from network node list and flag node index cache as dirty.

Complexity summary:

Preservation rationale:

Parameters:

ungate

ungate(
  connection: default,
): void

Remove gating from a connection, restoring its static weight contribution.

Idempotent: If the connection is not currently gated, the call performs no structural changes (and optionally logs a warning). After ungating, the connection's weight will be used directly without modulation by a gater activation.

Complexity: O(n) where n = number of gated connections (indexOf lookup) – typically small.

Parameters:

architecture/network/gating/network.gating.gate.utils.ts

assertGaterNodeBelongsToNetwork

assertGaterNodeBelongsToNetwork(
  network: default,
  node: default,
): void

Validate that a candidate gater node belongs to the target network.

Parameters:

Returns: Nothing.

attachGaterToConnection

attachGaterToConnection(
  network: default,
  node: default,
  connection: default,
): void

Attach a gater to a connection and track that connection in the network gate list.

Parameters:

Returns: Nothing.

detachConnectionFromGater

detachConnectionFromGater(
  connection: default,
): void

Remove reverse gater bookkeeping from a connection's gater node.

Parameters:

Returns: Nothing.

findGateIndex

findGateIndex(
  network: default,
  connection: default,
): number

Find a connection position within the network global gates list.

Parameters:

Returns: Zero-based index in the gates list, or -1 when absent.

isConnectionAlreadyGated

isConnectionAlreadyGated(
  connection: default,
): boolean

Determine whether a connection already has a gater node assigned.

Parameters:

Returns: True when a gater is already set; otherwise false.

removeGateAtIndex

removeGateAtIndex(
  network: default,
  gateIndex: number,
): void

Remove a gated connection from the network global gate list.

Parameters:

Returns: Nothing.

warnConnectionAlreadyGated

warnConnectionAlreadyGated(): void

Emit a warning when a gate operation is skipped due to existing gating.

Returns: Nothing.

warnMissingGateConnection

warnMissingGateConnection(): void

Emit a warning when an ungate request targets a non-tracked connection.

Returns: Nothing.

architecture/network/gating/network.gating.remove.utils.ts

assertNodeRemovableAndGetIndex

assertNodeRemovableAndGetIndex(
  network: default,
  node: default,
): number

Ensure a node can be removed and return its index in the network node list.

Parameters:

Returns: Index of the node in the network node list.

createBridgingConnections

createBridgingConnections(
  network: default,
  predecessorNodes: ConnectedNodeList,
  successorNodes: ConnectedNodeList,
): BridgingConnectionList

Create bridging connections from each predecessor to each successor when valid.

Parameters:

Returns: Newly created bridge connections.

disconnectInboundConnections

disconnectInboundConnections(
  network: default,
  node: default,
  preservedGaters: PreservedGaters,
  subNodeConfig: NodeRemovalMutationConfig,
): ConnectedNodeList

Disconnect all inbound connections for a node while collecting predecessors.

Parameters:

Returns: Predecessor nodes that previously projected into the removed node.

disconnectNodeSelfLoop

disconnectNodeSelfLoop(
  network: default,
  node: default,
): void

Disconnect a node self-loop before broader edge rewiring.

Parameters:

Returns: Nothing.

disconnectOutboundConnections

disconnectOutboundConnections(
  network: default,
  node: default,
  preservedGaters: PreservedGaters,
  subNodeConfig: NodeRemovalMutationConfig,
): ConnectedNodeList

Disconnect all outbound connections for a node while collecting successors.

Parameters:

Returns: Successor nodes that were previously targeted by the removed node.

preserveGaterForReassignment

preserveGaterForReassignment(
  connection: default,
  removedNode: default,
  preservedGaters: PreservedGaters,
  subNodeConfig: NodeRemovalMutationConfig,
): void

Preserve a gater for later reassignment when gate retention is enabled.

Parameters:

Returns: Nothing.

reassignPreservedGaters

reassignPreservedGaters(
  network: default,
  preservedGaters: PreservedGaters,
  bridgingConnections: BridgingConnectionList,
): void

Reattach preserved gaters to randomly selected newly-created bridge connections.

Parameters:

Returns: Nothing.

removeNodeAtIndex

removeNodeAtIndex(
  network: default,
  nodeIndex: number,
): void

Remove a node from the network list and mark node indexing as dirty.

Parameters:

Returns: Nothing.

resolveSubNodeMutationConfig

resolveSubNodeMutationConfig(): NodeRemovalMutationConfig

Resolve the active SUB_NODE mutation configuration shape.

Returns: Normalized SUB_NODE config when available; otherwise undefined.

selectRandomIndex

selectRandomIndex(
  length: number,
): number

Select a uniformly random integer index in the range [0, length).

Parameters:

Returns: Random zero-based index.

shouldCreateBridgeConnection

shouldCreateBridgeConnection(
  predecessorNode: default,
  successorNode: default,
): boolean

Decide whether a predecessor-successor pair should receive a bridge connection.

Parameters:

Returns: True when the pair is distinct and no projection already exists.

ungateConnectionsGatedByNode

ungateConnectionsGatedByNode(
  network: default,
  node: default,
): void

Ungate all connections that are currently gated by the removed node.

Parameters:

Returns: Nothing.

architecture/network/gating/network.gating.utils.types.ts

BridgingConnectionList

Newly created connections that can be assigned preserved gaters.

ConnectedNodeList

Predecessor or successor node collection used during bridge construction.

MutableNetworkGatingProps

Network shape extension used to flag node index cache invalidation.

NodeRemovalMutationConfig

Normalized SUB_NODE mutation configuration used during node-removal rewiring.

PreservedGaters

Mutable gater collection retained while removing a hidden node.

architecture/network/gating/network.gating.errors.ts

Raised when a gating node does not belong to the target network.

NetworkGatingNodeMembershipError

Raised when a gating node does not belong to the target network.

NetworkGatingRemovalNodeNotFoundError

Raised when a gating removal request targets a node that is not in the network.

NetworkGatingStructuralAnchorRemovalError

Raised when a gating removal request targets a structural anchor node.

Generated from source JSDoc • GitHub