Skip to content

feat(preferences): add custom traits config loader#1362

Merged
whoAbhishekSah merged 2 commits intomainfrom
feat/preference-custom-traits-config
Feb 3, 2026
Merged

feat(preferences): add custom traits config loader#1362
whoAbhishekSah merged 2 commits intomainfrom
feat/preference-custom-traits-config

Conversation

@whoAbhishekSah
Copy link
Member

@whoAbhishekSah whoAbhishekSah commented Jan 30, 2026

Summary

Allow custom preference traits to be loaded from a YAML config file at startup.

Changes:

  • LoadTraitsFromFile() - loads and merges custom traits with defaults
  • yaml tags on Trait struct for YAML unmarshaling
  • CustomTraitsPath config option in server config
  • Service updated to accept custom traits parameter
  • Wired up in cmd/serve.go to load traits at startup

Merge behavior:

  • Custom traits with same resource_type + name override defaults
  • New custom traits are appended to defaults

Example config:

app:
  custom_traits_path: "/path/to/custom-traits.yaml"

Example custom-traits.yaml:

traits:
  - resource_type: "app/user"
    name: "measurement_unit"
    input: "select"
    input_hints: "metric,imperial"
    default: "metric"

Part of: #1347

Test plan

  • Unit tests for LoadTraitsFromFile
  • Manual testing completed:
    • Default behavior (no config) - returns default traits only
    • Custom traits file adds new traits - merged with defaults
    • Custom traits file overrides default trait - override applied
    • Invalid YAML file - server fails to start with parse error
    • Non-existent file path - server fails to start with file not found error
    • Empty traits file - returns default traits only

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Feb 2, 2026 6:07am

@coveralls
Copy link

coveralls commented Jan 30, 2026

Pull Request Test Coverage Report for Build 21579288946

Details

  • 27 of 41 (65.85%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 37.915%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/serve.go 0 6 0.0%
core/preference/service.go 0 8 0.0%
Totals Coverage Status
Change from base Build 21512854764: 0.03%
Covered Lines: 15914
Relevant Lines: 41973

💛 - Coveralls

Allow custom preference traits to be loaded from a YAML config file
at startup, merged with DefaultTraits.

- Add LoadTraitsFromFile() to load and merge custom traits
- Add yaml tags to Trait struct for YAML unmarshaling
- Add CustomTraitsPath config option in server config
- Custom traits can add new traits or override defaults

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update Service to accept custom traits parameter
- Load custom traits from config file in cmd/serve.go
- Describe() now returns configured traits instead of hardcoded defaults

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ravisuhag
Copy link
Member

@whoAbhishekSah Do we have to call them custom-traits? Can this be simply traits.

@whoAbhishekSah
Copy link
Member Author

@ravisuhag The idea is to "extend" the existing hardcoded DefaultTraits traits at runtime.

We can call it "additional" as well, to show in the code that these are added with the hardcoded ones. For the handlers/service and repository, the traits are in a single list: [Default + Custom/Additional].

The word "custom" is used in config.yaml(as app.custom_traits_path) and in some variables in core/preference/config.go.
I am open to suggestions for better names for these. Feel free to add comments on the PR code files or here - it's still in draft.

@whoAbhishekSah
Copy link
Member Author

We can simply call it "traits" in our PR body, documentation, etc., once the PR is merged.

@whoAbhishekSah whoAbhishekSah marked this pull request as ready for review February 2, 2026 07:14
@whoAbhishekSah whoAbhishekSah merged commit a17d831 into main Feb 3, 2026
7 checks passed
@whoAbhishekSah whoAbhishekSah deleted the feat/preference-custom-traits-config branch February 3, 2026 09:06
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.

4 participants