Skip to content

SONA N-API applyMicroLora returns zero/delta instead of identity plus delta #706

Closed

Description

@thesoulpole

Version

  • @ruvector/sona@0.1.7
  • Also reproduced through agentdb@3.0.0-alpha.17
  • Node 26.4.0, macOS arm64

Reproduction

const input = [1, 0.5, -0.25, 0.75];
const engine = new SonaEngine(4);

console.log(engine.applyMicroLora(input));
// [0, 0, 0, 0]

AgentDB's SonaLearningBackend.enhance() returns the same zero vector before training.

After one raw trajectory followed by explicit flush(), applyMicroLora() returns a small nonzero delta, but still not the original input plus the learned delta.

Root cause

The Rust LoRA forward path has residual semantics: it adds the learned delta into the provided output buffer.

The N-API bindings in crates/sona/src/napi_simple.rs and crates/sona/src/napi.rs initialize that output buffer with zeros. Therefore the JavaScript API returns only the delta. AgentDB then replaces the query embedding with that returned value.

Impact

Before any learning, every enhanced query becomes the exact zero vector. After learning, queries become only a small adjustment vector rather than identity plus adjustment. This can collapse or badly distort retrieval rankings whenever SONA enhancement is enabled.

Requested fix

Initialize the micro-LoRA and base-LoRA output buffers from a clone of the input before invoking the Rust forward method.

Please add:

  • A cold-start identity test.
  • A post-feedback non-identity test.
  • AgentDB integration coverage confirming that a cold query is preserved rather than zeroed.

Activity

  1. ruvnet commented on Jul 27, 2026

    @ruvnet
    Owner

    Resolved by #708 and published in @ruvector/sona@0.1.8. Both N-API paths now seed residual outputs from the input, with cold-start identity and post-feedback regression coverage in npm/packages/sona/test/basic.test.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions