Skip to content

fix(lore): validate --kind before import (fixes #87)#94

Closed
CatfishGG wants to merge 3 commits into
mathomhaus:mainfrom
CatfishGG:fix-issue-87-kind-validation
Closed

fix(lore): validate --kind before import (fixes #87)#94
CatfishGG wants to merge 3 commits into
mathomhaus:mainfrom
CatfishGG:fix-issue-87-kind-validation

Conversation

@CatfishGG
Copy link
Copy Markdown
Contributor

Summary

lore catalog DIR --kind <kind> accepted any string for --kind and silently stored it in the corpus, corrupting downstream filtering and search.

This PR validates --kind against the known taxonomy (idea, research, decision, observation, principle) before import and returns a descriptive error listing valid options if the value is unknown.

Changes

  • internal/lore/catalog.go: Added validation in Catalog() — rejects unknown kinds with a clear error message
  • internal/lore/catalog_cmd.go: Added validation in the CLI handler — same check before calling Catalog()
  • internal/lore/catalog_test.go: Added TestCatalog_InvalidKind covering the error case

Acceptance criteria (from #87)

  • Catalog rejects unknown --kind values up-front
  • Error message lists valid options
  • Default (no override) behavior unchanged — AllKinds() returned nil for empty input is still respected

Closes #87

CatfishGG added 2 commits May 12, 2026 22:20
…tions (fixes mathomhaus#85)

- loadNotes/loadEvents: explicitly select id column for reliable secondary
  sort when created_at timestamps collide at sub-second precision
- TestScroll_OrderChronological: add microsecond sleep between Journal
  calls to guarantee distinct timestamps and prevent flaky ordering under
  'go test -race'
@github-actions github-actions Bot added area: quest Quest board / task coordination area: lore Lore knowledge archive labels May 13, 2026
@github-actions github-actions Bot removed the area: quest Quest board / task coordination label May 13, 2026
@kunallanjewar
Copy link
Copy Markdown
Contributor

Closing in favor of #97, which landed as the fix for #87. Both PRs solved the right bug with the right test shape — the call came down to which one matched the existing kind-validation pattern in the lore package. #97 reuses the ErrInvalidKind sentinel and isValidKind helper that Inscribe (inscribe.go:116) and Update (update.go:129) already use, so all three write-paths now share one validator and callers can errors.Is against ErrInvalidKind uniformly.

Genuinely appreciate the work here — your test (verifying the error mentions every valid kind) was a thoughtful angle, and the dual-layer validation idea is defensible in cases where the CLI handler does pre-DB work that the lib can't see. In this codebase the handler just forwards inputs to Catalog(), so the lib check ended up being the right single gate. Hope you'll send more patches; the catalog/lore area still has open issues.

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

Labels

area: lore Lore knowledge archive

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] lore catalog: validate explicit --kind override before import

2 participants