Skip to content

feat: KB quality improvements — CHECK constraints, FTS coverage, outcome validation (#90) - #91

Merged
four-bytes-robby merged 2 commits into
mainfrom
feat/90-kb-quality-improvements
Jun 7, 2026
Merged

four-bytes-robby merged 2 commits into
mainfrom
feat/90-kb-quality-improvements

Conversation

@four-bytes-robby

@four-bytes-robby four-bytes-robby commented Jun 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Ports quality improvements from the standalone four-opencode-knowledge plugin to brain's src/knowledge/.

Changes

Schema — src/schema.ts

  • CHECK constraints on confidence (0.0–1.0), review_state (valid enum), outcome (valid enum)
  • Migration triggers for existing databases (follows migrateEntityTypeCheck pattern with retry)
  • FTS rebuild to include entry_key, kind, entity_type (previously only 5 columns)

Runtime — src/knowledge/store.ts

  • Outcome validation in kbRecord() — rejects invalid outcomes before INSERT with clear error message

Verification

  • ✅ Build passes
  • ✅ All 247 tests pass
  • ✅ Confidence migration applies on first run (visible in test logs)
  • ✅ FTS rebuild non-destructive (content table untouched)

Closes #90


Summary by cubic

Improves knowledge base data quality by enforcing constraints, making outcome validation unconditional, and rebuilding FTS for better search. Implements the KB quality work from #90.

  • New Features

    • CHECK constraints: confidence (0.0–1.0), review_state enum, occurrence outcome enum.
    • Outcome validation in kbRecord() now always runs before insert and throws a clear error with allowed values.
  • Migration

    • Rebuilds FTS to include entry_key, kind, entity_type and recreates sync triggers with full 8-column coverage; content table remains unchanged.
    • Adds retrying trigger-based migrations for existing DBs to enforce the new checks on insert/update.

Written for commit 0afa508. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 3 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/schema.ts
Comment thread src/knowledge/store.ts Outdated
@four-bytes-robby
four-bytes-robby force-pushed the feat/90-kb-quality-improvements branch from ba559f4 to 0afa508 Compare June 7, 2026 14:12
@four-bytes-robby
four-bytes-robby merged commit 29532a2 into main Jun 7, 2026
3 checks passed
@four-bytes-robby
four-bytes-robby deleted the feat/90-kb-quality-improvements branch June 7, 2026 14:16
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.

kb: port quality improvements from four-opencode-knowledge

1 participant