Skip to content

fix(integrations): read bm_schema fields the backend actually returns - #1998

Merged
groksrc merged 1 commit into
mainfrom
fix/1997-openclaw-schema-fields
Oct 30, 2026
Merged

groksrc merged 1 commit into
mainfrom
fix/1997-openclaw-schema-fields

Conversation

@groksrc

@groksrc groksrc commented Oct 30, 2026

Copy link
Copy Markdown
Member

Fixes #1997. With this fix, the OpenClaw plugin's schema_validate, schema_infer and schema_diff tools show the backend's real results. Before, a note that passed validation was shown to the agent as **undefined** — invalid.

The bug

The plugin read field names that bm_schema never returns. The client casts the JSON payload to its declared types without translating anything, so TypeScript couldn't catch the mismatch.

Plugin read Backend sends (src/basic_memory/schemas/schema.py) Rendered as
entity_type note_type **Type:** undefined
identifier note_identifier **undefined**
valid passed every note invalid
declared_in no such field declared in undefined

The unit test fixtures used the same wrong names, so CI passed.

What changes

  • bm-client.ts: SchemaValidationResult, SchemaInferResult and SchemaDiffResult now mirror the backend's ValidationReport, InferenceReport and DriftReport. With the corrected types, tsc flagged every stale read.
  • tools/schema-validate.ts: notes render by note_identifier, with valid or invalid taken from passed. passed stays true when a note has only warnings, so a warn-mode note shows as valid and lists its warnings.
  • tools/schema-infer.ts, tools/schema-diff.ts: type headings use note_type.
  • Dropped fields: each is described the way BM's own drift report does, e.g. **fax** (observation) — 10% (1/10). The section is now titled "rare in notes", because a dropped field can still appear in a few notes.

Missing schemas and empty note types are unaffected. Since 1.0, BM reports them as NOT_FOUND tool errors, and each tool's existing error handling already shows those.

Regression tests

  • Unit (tools/schema-*.test.ts): fixtures are rebuilt from the backend models, and assertions check exact rendered lines.
    • Validate covers a passing note, a passing note with a warning, and a failing note with an error.
    • Validate also covers a single-note result where BM leaves out note_type.
    • Infer covers the type heading.
    • Diff covers the type heading and a dropped field.
  • Integration (integration/bm-client.integration.test.ts): writes a contact schema in warn mode and two notes, then runs all three tools against a real bm mcp.
    • The raw payload has note_type, note_identifier and passed.
    • Both notes render as valid, and Bob's warning is kept.
    • No output contains undefined.

Run against main's source (77f40181), four unit tests and the integration test fail. All pass with this change.

Verification

  • just package-check-openclaw: exit 0, 286 tests pass.
  • bun run test:int against a real bm mcp from this checkout: 6 pass, 0 fail.
  • Before writing the fix, I reproduced the bug with main's plugin source against a real bm 1.0.0 project. All three tools rendered undefined, matching the report.
  • Not verified: this build hasn't been installed on a live OpenClaw gateway.

🤖 Generated with Claude Code

The OpenClaw schema_validate, schema_infer and schema_diff tools read
entity_type, identifier, valid and declared_in. BM's ValidationReport,
InferenceReport and DriftReport send note_type, note_identifier and
passed, and have no declared_in. The client casts the payload without
translating fields, so every validated note rendered as
"**undefined** — invalid", type headings read "undefined", and dropped
fields read "declared in undefined".

- Align SchemaValidationResult, SchemaInferResult and SchemaDiffResult
  with the backend models in src/basic_memory/schemas/schema.py.
- Render notes by note_identifier and passed, and type headings by
  note_type.
- Describe a dropped field by its source and frequency, as BM's own
  drift report does, and label the section "rare in notes": a dropped
  field can still appear in a few notes.

The unit fixtures used the same stale field names, so they passed. They
now follow the backend models and assert exact rendered lines. A new
integration test runs all three tools against a real bm mcp.

Fixes #1997

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Drew Cain <groksrc@gmail.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T13:53:41.222896Z f1722a1 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@groksrc
groksrc merged commit d7b1612 into main Oct 30, 2026
24 checks passed
@groksrc
groksrc deleted the fix/1997-openclaw-schema-fields branch October 30, 2026 14:38
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.

[BUG] OpenClaw schema tools misread response fields: valid notes render as undefined - invalid

1 participant