Nodes & @Rewire
Nodes are pre-registered Swift functions that PipeKit can execute remotely in production. They are the atomic units of runtime control.
What is a Node?
A node is a Swift function annotated with @Rewire that registers itself with PipeKit at app launch. Once registered, the node can be triggered remotely — individually or as part of a flow — without shipping an update.
Nodes are deterministic by design. Only functions declared at build time can execute. There is no arbitrary code injection, no eval, no dynamic payloads that run as code. This is what makes PipeKit safe for production.
Registering a Node
Use the @Rewire macro to register a function as a remotely executable node.
import PipeKitSDK@Rewire("clear-cache")func clearCache() async -> NodeResult {let freed = await CacheManager.shared.purge()return .success(["freed": "\(freed)MB"])}
Nodes with Parameters
Nodes can accept typed parameters. These are passed from the flow definition or provided at execution time via the dashboard or API.
@Rewire("toggle-feature")func toggleFeature(name: String, enabled: Bool) async -> NodeResult {FeatureFlags.set(name, enabled)return .success(["feature": name, "enabled": "\(enabled)"])}@Rewire("set-log-level")func setLogLevel(level: String) async -> NodeResult {guard let logLevel = LogLevel(rawValue: level) else {return .failure("Invalid log level: \(level)")}Logger.shared.level = logLevelreturn .success(["level": level])}
Node Results
Every node returns a NodeResult that reports success or failure back to PipeKit. Results are recorded in the execution log and visible in the dashboard.
.success(dict)Node completed. Optional metadata dictionary is stored in the execution log..failure(msg)Node failed. Error message is recorded and the flow can be configured to halt or continue.Node Catalog
When a device connects to PipeKit, the SDK reports all registered nodes to the server. These appear in the Nodes section of the dashboard, where you can see each node's identifier, parameter schema, and which devices have it registered.
Nodes are scoped to your app's bundle ID. Different apps maintain independent node catalogs.
Best Practices
Use descriptive identifiers
Node IDs like "clear-cache" or "toggle-feature" are easier to compose into flows than "action1" or "fn_23".
Keep nodes focused
Each node should do one thing. Compose complex behavior by chaining nodes in a flow.
Handle errors gracefully
Return .failure with a clear message rather than letting exceptions propagate.
Avoid side effects on registration
The @Rewire macro registers the function — it should not execute any logic at registration time.
