Skip to content

feat: add local fact type reclassifier - #365

Closed
hurttlocker wants to merge 2 commits into
mainfrom
feat/fact-type-local-classifier
Closed

hurttlocker wants to merge 2 commits into
mainfrom
feat/fact-type-local-classifier

Conversation

@hurttlocker

@hurttlocker hurttlocker commented Mar 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add an embedded local fact-type classifier and make cortex classify --reclassify use it by default
  • add first-class event and rule fact types plus the schema migration to support them on existing DBs
  • update UpdateFactType to refresh decay rates when fact types change
  • include the dataset/training scripts and seed labels used to build the embedded model

Why

The live DB was effectively unusable for the graph because almost everything was still kv.

Before live backfill:

  • kv 5367
  • state 229
  • decision 84
  • relationship 43
  • preference 38
  • identity 34
  • location 21
  • temporal 7
  • config 2

After running the new local backfill on ~/.cortex/cortex.db:

  • kv 3121
  • event 656
  • temporal 529
  • state 527
  • location 302
  • config 298
  • decision 157
  • rule 75
  • relationship 67
  • identity 50
  • preference 43

That dropped kv from about 92% of the typed backlog to about 54% and made the graph materially more structured.

Notes

  • active facts now get type-aware decay rates after reclassification
  • list --facts --type event and list --facts --type rule work after the migration
  • the embedded model is generated from the included bench scripts + seed labels, not hand-coded rules

Validation

  • go test ./internal/extract -run 'FactTypeLocal|ValidFactType|Classify|Extract'
  • go test ./internal/store -run 'MigrateFactTypeEnum|MigrateFactStateColumn|MigrateMemoryClassNullBackfill|UpdateFactType_UpdatesDecayRate'
  • go test ./cmd/cortex -run 'Classify|Import'
  • go build -o /tmp/cortex-facttype ./cmd/cortex
  • live smoke checks:
    • /tmp/cortex-facttype classify --reclassify --dry-run
    • /tmp/cortex-facttype list --facts --type event --limit 3 --json
    • /tmp/cortex-facttype list --facts --type rule --limit 3 --json

@hurttlocker
hurttlocker deleted the feat/fact-type-local-classifier branch March 27, 2026 00:27
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