LearnNewsExamplesServices
Frontmatter
id8190
titleFeat: Neural Link - Runtime Code Hot-Patching
stateClosed
labels
enhancementaiarchitecture
assigneestobiu
createdAtDec 28, 2025, 10:26 PM
updatedAtJan 4, 2026, 1:49 PM
githubUrlhttps://github.com/neomjs/neo/issues/8190
authortobiu
commentsCount1
parentIssue8169
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 4, 2026, 1:49 PM

Feat: Neural Link - Runtime Code Hot-Patching

Closed v11.18.0 enhancementaiarchitecture
tobiu
tobiu commented on Dec 28, 2025, 10:26 PM

Context: To support true "Self-Healing" capabilities, agents need a mechanism to apply fixes to the running application without a full reload cycle.

Scope:

  1. Enhance RuntimeService:

    • Add patchCode(sessionId, className, methodName, source).
    • Implementation:
      • Send command to App Worker.
      • Locate class via Neo.ns(className).
      • Apply new method: prototype[methodName] = eval(...).
    • Security: This feature MUST be gated behind a Neo.config.enableHotPatching flag (default false).
  2. Tools:

    • patch_code: Applies the fix.

Goal: Enable sub-second self-healing loops for rapid iteration.

tobiu added the enhancement label on Dec 28, 2025, 10:26 PM
tobiu added the ai label on Dec 28, 2025, 10:26 PM
tobiu added the architecture label on Dec 28, 2025, 10:26 PM
tobiu added parent issue #8169 on Dec 28, 2025, 10:26 PM
tobiu assigned to @tobiu on Jan 1, 2026, 11:44 PM
tobiu referenced in commit 5394db6 - "feat(ai): Implement Runtime Code Hot-Patching (#8190) on Jan 4, 2026, 1:48 PM
tobiu
tobiu Jan 4, 2026, 1:49 PM

Input from Gemini 3 pro:

✦ Implemented patch_code capability in RuntimeService.

Key Implementation Details:

  • Placement: The logic resides in src/ai/client/RuntimeService.mjs (App Worker) rather than Neo.worker.App to maintain separation of concerns.
  • Security:
    • The feature is strictly gated behind Neo.config.enableHotPatching === true.
    • We used new Function('return ' + source)() instead of eval() or new Function(body). This ensures that the patched code is created in the global scope and cannot accidentally capture local variables from the patchCode method (scope isolation).
  • Protocol: The tool expects source to be a full function expression string (e.g., function(args) { ... }).
  • Audit: All hot-patch operations are logged to the console with console.warn.
tobiu closed this issue on Jan 4, 2026, 1:49 PM
tobiu cross-referenced by #8309 on Jan 4, 2026, 1:54 PM