Skip to content

Add OpenClaw memory adapter and MiniLM fix#66

Open
christopherkarani wants to merge 1 commit intomainfrom
codex/zig
Open

Add OpenClaw memory adapter and MiniLM fix#66
christopherkarani wants to merge 1 commit intomainfrom
codex/zig

Conversation

@christopherkarani
Copy link
Copy Markdown
Owner

Summary

  • Add broker-backed OpenClaw-style memory/session tooling, markdown projection, HTTP MCP transport, and native plugin packaging/docs.
  • Add corpus build manifest reuse plus related MCP/broker test coverage.
  • Restore the non-quantized MiniLM CoreML asset, refresh the baseline fixture, and add a fast regression test for the known W8A8/NaN asset shape.

Verification

  • swift build --disable-automatic-resolution
  • swift build --target WaxVectorSearchMiniLM --disable-automatic-resolution
  • swift build --target WaxVectorSearchArctic --disable-automatic-resolution
  • swift test --filter QueryAwareEmbeddingTests --disable-automatic-resolution
  • swift test --filter BinaryCodecTests --disable-automatic-resolution
  • swift test --filter MiniLMFloat16DecodingTests --disable-automatic-resolution
  • swift test --filter minilmBundledModelDoesNotUseKnownBadW8A8Quantization --disable-automatic-resolution
  • WAX_TEST_MINILM=1 swift test --filter MiniLMEmbeddingQualityTests --disable-automatic-resolution
  • swift test --filter READMEExamplesTests --disable-automatic-resolution

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bcbda9204

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +187 to +190
try StoreLockProbe.preflightExclusiveAccess(
at: URL(fileURLWithPath: storePath),
timeout: .milliseconds(50)
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat lock probe failures as retryable during shutdown wait

brokerShutdownCompleted throws if StoreLockProbe.preflightExclusiveAccess cannot get the lock within 50ms, and shutdownStartedBroker does not catch that exception inside its retry loop. In practice, broker shutdown can leave the lock held briefly after the socket disappears, so this path can fail immediately instead of waiting մինչև the configured deadline, causing spurious shutdown errors even when the broker would have exited cleanly moments later.

Useful? React with 👍 / 👎.

Comment on lines +1322 to +1325
guard let match = filtered.first else {
throw BrokerValidationError.invalid("No resumable session manifest matched the requested selectors")
}
return match
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Select an active manifest before resuming a session

resolveSessionManifest returns the first manifest matching selectors without filtering for .active, but sessionResume rejects ended manifests afterward. If the most recently updated matching manifest is ended while another matching manifest is still active, session_resume incorrectly fails with “already been ended” instead of resuming the active one.

Useful? React with 👍 / 👎.

Comment on lines +168 to +171
private func closeSession(_ sessionID: String) async {
guard let session = sessions.removeValue(forKey: sessionID) else { return }
await session.transport.disconnect()
logger.info("Closed HTTP session", metadata: ["sessionID": "\(sessionID)"])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop session server when closing HTTP MCP sessions

Each HTTP initialize creates and starts a dedicated Server, but closeSession only disconnects the transport and removes the session entry. Because server.stop() is never called on normal session end/expiry/app shutdown, per-session server state can remain running and accumulate over time, leading to avoidable resource leaks in long-lived HTTP deployments.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64c0360093

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +580 to +581
if let sessionID {
normalizedMetadata[MemoryMetadataKeys.promotedFromSession] = sessionID.uuidString
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve implicit session before promotion bookkeeping

When memory_promote is called without session_id (allowed when exactly one session is active), the method resolves a session only for sourcing content, but later bookkeeping still checks the original optional argument. In that path sessionID stays nil, so wax.promoted_from_session is not written and no promotion event/lease refresh is recorded for the active session, which breaks provenance and session-derived promotion signals.

Useful? React with 👍 / 👎.

Comment on lines +181 to +182
while true {
try? await Task.sleep(for: .seconds(60))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make HTTP cleanup loop honor cancellation

The cleanup worker runs in an infinite loop and ignores cancellation by using try? around Task.sleep. Because start() launches this as an untracked background task, stop() has no way to terminate it, so the task can outlive shutdown and keep waking forever, leaking resources across long-running HTTP app lifecycles.

Useful? React with 👍 / 👎.

@christopherkarani
Copy link
Copy Markdown
Owner Author

Merge preparation status

Local verification completed:

  • swift build --product wax-mcp --traits default,MCPServer --disable-automatic-resolution
  • bash -n scripts/verify-openclaw-adapter.sh scripts/verify-openclaw-native-memory.sh scripts/verify-waxmcp-http.sh scripts/benchmark-openclaw-memory.sh
  • git diff --check origin/main...HEAD
  • npm pack --dry-run in Resources/openclaw/wax-memory-plugin
  • Previous issue-sweep verification listed in the PR description, including MiniLM runtime quality tests and targeted Swift builds/tests.

Review cleanup pushed in 77dc3e0f:

  • Added the four verifier/benchmark scripts referenced by README/docs so the docs do not point at ignored local-only files.
  • Removed trailing whitespace from newly added docs/marketing/SVG files so git diff --check is clean.

Current merge blocker:

  • GitHub checks are not currently proving the branch. The prior run failed before executing jobs because the account is locked due to a billing issue. Re-run checks after the billing/account state is fixed, or intentionally bypass branch protection if that is the desired release call.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 77dc3e0ffe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +89 to +93
let channel = try await bootstrap.bind(host: configuration.host, port: configuration.port).get()
self.channel = channel
Task { await sessionCleanupLoop() }
try await channel.closeFuture.get()
try await group.shutdownGracefully()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Shut down the NIO group when HTTP bind fails

start() creates a MultiThreadedEventLoopGroup before binding, but shutdownGracefully() is only reached after channel.closeFuture completes. If bind throws (for example, port already in use), the function exits early and leaves the event-loop threads running, which leaks resources and can poison subsequent start attempts in long-lived processes/tests.

Useful? React with 👍 / 👎.

Comment on lines +1177 to +1181
let document = if let frameID {
documents.first { $0.frameId == frameID }
} else {
documents.sorted { $0.timestampMs > $1.timestampMs }.first
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve selected frame_id in compat memory promotion

When memory_promote is called without frame_id, this branch selects the latest session document but never assigns that document’s frameId back to the variable later used for provenance and recall-signal lookup. As a result, promoted memories lose wax.promoted_from_frame and promotion scoring skips frame-specific recall signals in this common path.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant