Skip to content

fix: read schema definitions from file instead of stale database metadata#635

Open
groksrc wants to merge 2 commits intomainfrom
fix-schema-validate-stale-metadata
Open

fix: read schema definitions from file instead of stale database metadata#635
groksrc wants to merge 2 commits intomainfrom
fix-schema-validate-stale-metadata

Conversation

@groksrc
Copy link
Member

@groksrc groksrc commented Feb 28, 2026

Summary

  • Schema validation (schema-validate, schema-diff) now reads schema note frontmatter directly from the file instead of relying on entity_metadata in the database
  • This ensures the latest schema settings (validation mode, field declarations) are always used, even when the file watcher hasn't synced changes
  • Falls back to database metadata if the file can't be read

Problem

When users edit schema files externally (in their editor), schema-validate used stale entity_metadata from the database. CLI commands (bm tool) don't start file watchers, so the database never gets updated until a manual bm reindex. Meanwhile read-note reads from the file and shows the correct data, making the stale validation results confusing.

Changes

  • Added _schema_frontmatter_from_file() helper that reads and parses frontmatter via file_service
  • Updated validate_schema and diff_schema_endpoint to use file-based schema resolution
  • Added FileServiceV2ExternalDep to both endpoints
  • Notes being validated still use database metadata (their type field is stable)

Test plan

  • All 13 existing schema router tests pass
  • Full test suite passes (2374 passed, lint clean, typecheck clean)
  • Manual verification: set DB to warn, file to strict — validation correctly uses strict from file

Fixes #634

🤖 Generated with Claude Code

…data

schema-validate and schema-diff now read schema note frontmatter directly
from the file via file_service, instead of relying on entity_metadata in
the database. This ensures validation always uses the latest schema
settings (validation mode, field declarations) even when the file watcher
hasn't synced changes to the database.

Falls back to database metadata if the file can't be read.

Fixes #634

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Drew Cain <groksrc@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 28, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link

@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: f7d2f35a2e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Validate that file frontmatter has required 'entity' and 'schema' fields
before using it. If the file is mid-edit with incomplete metadata, fall
back to database metadata to avoid 500 responses from parse_schema_note().

Addresses Codex review feedback on #635.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Drew Cain <groksrc@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 28, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

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.

schema-validate uses stale entity_metadata when files edited externally

1 participant