feat(cohorts): add validation endpoint and enforce references at startup#267
Merged
feat(cohorts): add validation endpoint and enforce references at startup#267
Conversation
- Call ValidateReferences() during farmer startup to catch broken compound cohort configs (missing operands, circular refs, depth) - Add ValidateReferencesAll() to collect all errors instead of just first - Add cohorts.validate NATS handler and CLI command (grlx cohorts validate) - Add client.ValidateCohorts() for programmatic access - Map cohorts.validate to ActionView in RBAC middleware - Full test coverage across rbac, natsapi handlers, and client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the gap where nested/compound cohort reference validation was implemented in the rbac package but never wired into farmer startup or exposed as an API.
Changes
Farmer startup validation
loadCohortRegistry()now callsValidateReferences()after loading cohorts from config, logging errors for broken compound references (missing operands, circular refs, exceeded depth)New
ValidateReferencesAll()methodValidateReferences()which returns on first error, this collects all validation errors — useful for config debuggingNew
cohorts.validateAPI endpoint{valid, errors[], cohorts}responseActionViewin RBAC middleware (any viewer can check config validity)New
grlx cohorts validateCLI command-o json)Client library
client.ValidateCohorts()for programmatic accessTests
TestValidateReferencesAll*— multiple errors, no errors, mixed circular+missingTestHandleCohortsValidate*— empty registry, valid compound, missing ref, nil registryTestValidateCohorts_*— client success, failure, NATS errorAll existing tests pass.
staticcheckclean.