Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-19138-review-feedback-rules-settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The review-feedback rule capture now has `review_feedback.rules.*` keys in `hive.yaml` ([#19138](https://github.com/hivecommons/hive/issues/19138), part of [#19135](https://github.com/hivecommons/hive/issues/19135)): `enabled`, `trusted_associations`, `extra_phrases` (your own phrases that mark a reviewer's comment as a rule) and `disabled_signals` (built-in phrases to stop counting), plus an owner-only **Rules from review feedback** card in Settings, Features, Review that edits them in place. A change applies on the next sweep pass without a restart. The keys are additive: the `HIVE_REVIEW_FEEDBACK_RULES` and `HIVE_REVIEW_FEEDBACK_RULE_TRUSTED_ASSOCIATIONS` environment variables keep working and win when set, and the card says so. See [Reviewer-stated rules](src/docs/review-feedback-rules.md#settings).
51 changes: 51 additions & 0 deletions src/cmd/hive/review_feedback_rule_policy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package main

import (
"testing"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/reviewrules"
)

// hivecommons/hive#19138: the sweep reads review_feedback.rules from hive.yaml
// on every pass, so an owner's edit applies without a restart.
func TestReviewRulePolicyFollowsConfigLive(t *testing.T) {
t.Setenv(reviewrules.DisableEnvVar, "")
t.Setenv(reviewrules.TrustedAssociationsEnvVar, "")
cfg := &config.Config{}
if p := reviewRulePolicy(cfg); p.Off || !p.Trusted["COLLABORATOR"] || len(p.ExtraPhrases) != 0 {
t.Fatalf("defaults = %+v", p)
}
off := false
if err := cfg.SetReviewFeedbackRules(config.ReviewFeedbackRulesConfig{
Enabled: &off, TrustedAssociations: []string{"OWNER"}, ExtraPhrases: []string{"house rule"}, DisabledSignals: []string{"never"},
}); err != nil {
t.Fatal(err)
}
p := reviewRulePolicy(cfg)
if !p.Off || len(p.Trusted) != 1 || !p.Trusted["OWNER"] || p.ExtraPhrases[0] != "house rule" || !p.DisabledSignals["never"] {
t.Fatalf("after edit = %+v", p)
}
// The environment variables keep working and win.
t.Setenv(reviewrules.DisableEnvVar, "1")
if p := reviewRulePolicy(cfg); p.Off {
t.Fatal("HIVE_REVIEW_FEEDBACK_RULES=1 must keep capture on")
}
}

// A store that is already open takes the new policy on the next pass.
func TestReviewRuleStoreTakesPolicyWithoutReopen(t *testing.T) {
h := newRuleHarness(t, reviewrules.Config{})
t.Setenv(reviewrules.DisableEnvVar, "")
t.Setenv(reviewrules.TrustedAssociationsEnvVar, "")
cfg := &config.Config{}
if err := cfg.SetReviewFeedbackRules(config.ReviewFeedbackRulesConfig{ExtraPhrases: []string{"house rule"}}); err != nil {
t.Fatal(err)
}
h.rules.SetPolicy(reviewRulePolicy(cfg))
h.feedback(ruleItem("inline:7", "OWNER", "House rule: every analysis cites the scorecard."))
res := h.sweep(t).run(t.Context(), parseReviewFeedbackKey)
if res.RulesCaptured != 1 {
t.Fatalf("captured = %d, want 1 (%+v)", res.RulesCaptured, res)
}
}
34 changes: 31 additions & 3 deletions src/cmd/hive/review_feedback_wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,28 @@ func sweepReviewFeedback(ctx context.Context, cfg *config.Config, client *github
}
reviewFeedbackStore = st
}
if reviewRuleStore == nil && reviewrules.Enabled() {
rs, err := reviewrules.Open(reviewrules.Dir(), reviewrules.VaultDir(), reviewrules.ConfigFromEnv())
// The rule preferences are read from hive.yaml on every pass, so an owner's
// edit in Settings takes effect on the next pass without a restart
// (hivecommons/hive#19138). The environment variables still win.
rulePolicy := reviewRulePolicy(cfg)
if reviewRuleStore == nil && !rulePolicy.Off {
rcfg := reviewrules.ConfigFromEnv()
rcfg.Trusted = rulePolicy.Trusted
rs, err := reviewrules.Open(reviewrules.Dir(), reviewrules.VaultDir(), rcfg)
if err != nil {
logger.Warn("review feedback: rule index unreadable or not writable; rules kept in memory only", "dir", reviewrules.Dir(), "error", err)
}
reviewRuleStore = rs
}
var ruleStore *reviewrules.Store
if reviewRuleStore != nil {
reviewRuleStore.SetPolicy(rulePolicy)
for _, line := range reviewRuleStore.Reconcile(now) {
logger.Info("review feedback: rule changed by an operator", "change", line)
}
if !rulePolicy.Off {
ruleStore = reviewRuleStore
}
}
available := agentAvailability(cfg, agentMgr)
sweep := reviewFeedbackSweep{
Expand All @@ -410,7 +421,7 @@ func sweepReviewFeedback(ctx context.Context, cfg *config.Config, client *github
Cursor: reviewFeedbackCursor,
Now: now,
Logger: logger,
Rules: reviewRuleStore,
Rules: ruleStore,
Lane: cfg.BaseAgentName,
Managed: cfg.IsManagedRepo,
Route: func(owner string) reviewFeedbackRoute {
Expand All @@ -437,3 +448,20 @@ func sweepReviewFeedback(ctx context.Context, cfg *config.Config, client *github
"rules_captured", res.RulesCaptured, "rules_queued", res.RulesQueued, "rules_merged", res.RulesMerged)
}
}

// reviewRulePolicy is the effective rule-capture policy: review_feedback.rules
// in hive.yaml merged with the environment variables, which still win.
func reviewRulePolicy(cfg *config.Config) reviewrules.Policy {
return reviewrules.Resolve(reviewRuleSettings(cfg)).Policy
}

// reviewRuleSettings converts the yaml block to the package's plain settings.
func reviewRuleSettings(cfg *config.Config) reviewrules.Settings {
r := cfg.ReviewFeedbackRules()
return reviewrules.Settings{
Enabled: r.Enabled,
TrustedAssociations: r.TrustedAssociations,
ExtraPhrases: r.ExtraPhrases,
DisabledSignals: r.DisabledSignals,
}
}
2 changes: 2 additions & 0 deletions src/docs/api-reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f
| `PUT` | `/api/config/reference-repos/write-identity` | Owner only | Set `project.remote_write_identity` ([#18516](https://github.com/hivecommons/hive/issues/18516)): body `{"write_identity": "bot"}`, one of `bot`, `bot_only`, `owner`. 400 on an unknown value, or when a hand-written write entry would have no credential under the new value (the message boot exits 22 with); nothing is stored then. 500 when the file could not be written. On success the reference repos are re-resolved before the response, which is the same body as `GET /api/config/reference-repos`; audited as `config_remote_write_identity` with `previous` and `write_identity` | `pkg/dashboard/api.go:563` |
| `GET` | `/api/config/repos/parent-autoclose` | Owner only | `repos.<repo>.parent_autoclose` for every monitored repo: the effective value (`true`, `epics_too`, `trackers_too` or `false`), whether the repo carries its own, the default and the four options the Settings editor offers ([#19070](https://github.com/hivecommons/hive/issues/19070)) | `pkg/dashboard/api.go:560` |
| `PUT` | `/api/config/repos/parent-autoclose` | Owner only | Set one monitored repo's parent auto-close policy: `{"repo": "owner/name", "value": "true" \| "epics_too" \| "trackers_too" \| "false"}`. `true` is the default and clears the override. 400 for a missing repo or an invalid value, 404 for a repo that is not monitored, 500 when the file could not be written (previous value restored). Applies without a restart; audited as `config_repo_parent_autoclose`. Parents a person reopened and tracking issues are never auto-closed under any value | `pkg/dashboard/api.go:561` |
| `GET` | `/api/config/review-feedback/rules` | Owner only | `review_feedback.rules.*` ([#19138](https://github.com/hivecommons/hive/issues/19138)): the stored `enabled`, `trusted_associations`, `extra_phrases` and `disabled_signals`, the effective `effective_enabled` and `effective_trusted_associations` after the environment variables, `enabled_from_env` / `trusted_from_env` (an environment variable decides the value), and the vocabulary the Settings card offers (`associations`, `default_trusted_associations`, `signals`) | `pkg/dashboard/api_config_review_feedback_rules.go:102` |
| `PUT` | `/api/config/review-feedback/rules` | Owner only | Update `review_feedback.rules`. Every field is optional and an absent one is left alone: `{"enabled": bool, "trusted_associations": ["OWNER", ...], "extra_phrases": ["..."], "disabled_signals": ["never"]}`; an empty list restores the default or the built-in behaviour. 400 with nothing changed for an unknown association or signal, an extra phrase shorter than 4 or longer than 100 characters, or more than 50 phrases; 500 when the file could not be written (previous values restored). Applies on the next review-feedback sweep pass without a restart; audited as `config_review_feedback_rules`. Responds with the GET body | `pkg/dashboard/api_config_review_feedback_rules.go:103` |
| `GET` | `/api/config/prompt-sources` | Owner only | Repo-sourced prompt and definition gate ([#18490](https://github.com/hivecommons/hive/issues/18490)): `repos` (one row per managed repo, then any owner approval whose repo is no longer managed, each `{repo, managed, owner_approved, seed_allowed, allowed, approved_by, approved_at}`), `seed_enabled`, `seed_allowlist`, `trust_notice`, `seed_only_note` | `pkg/dashboard/api.go:572` |
| `PUT` | `/api/config/prompt-sources/owner-repos` | Owner only | `{"repo": "org/name", "allowed": true, "acknowledge_trust": true}` approves one of the hive's managed repos as a `prompt_source` / `definition_source` repo; `"allowed": false` revokes. 400 with nothing changed for a repo outside `project.repos` (still needs the seed edit), a malformed slug, or an approval without `acknowledge_trust: true`. Persisted to `variables.security.owner_github_prompt_repos` in the running config; audited as `config_prompt_source_repo`. Responds with the GET body | `pkg/dashboard/api.go:573` |
| `GET` | `/api/config/review` | Dashboard auth/session | Review Config Get | `pkg/dashboard/api.go:218` |
Expand Down
4 changes: 4 additions & 0 deletions src/docs/operator-reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ Go callers keep reading `cfg.Agents`, `cfg.Governor.Gateways` and so on through
| `governor.kick_limits.max_issues` / `max_prs` | `100` / `50` | Caps on every issue list and every PR list (actionable, stale drafts, merge-eligible, CI-failing) rendered into a kick prompt; a cut list ends with an explicit "… and N more" line. An absent key or a negative value means the default; an explicit `0` opts out of the cap entirely (`KickListUnlimited` — every item is listed), and anything above `500` is pinned to `500`. Editable without touching this file under **Settings → Repos → Kick prompt list caps**. Truncation drops the *newest, lowest-priority* items: issues are listed oldest first, and PRs in review-priority order (fixes, then refactors/docs, then tests, oldest first within each class), so lowering a cap never hides the most urgent work. Raise `max_prs` only if your agents actually work more than 50 PRs per turn; the tail of a long list costs tokens and delivery time on every kick without changing behaviour (#7368). |
| `project.agents_md_max_bytes` | `32768` (or env `HIVE_AGENTS_MD_MAX_BYTES`); clamped to `2048`..`262144`. `repos.<repo>.agents_md_max_bytes` overrides it per repo. | Caps the repo `AGENTS.md` block prepended to a kick. Whole sections (split at `#`/`##` headings; each resolved skill is its own unit) are kept or dropped, never clipped mid-rule; when any are dropped the kick carries a one-line `⚠️ AGENTS.md exceeded N bytes; … — read AGENTS.md …` warning naming them and the scheduler logs it. See [agents-md.md](../agents-md.md#size-cap-whole-sections-visible-warning). |
| `repos.<repo>.parent_autoclose` | `true` (default), `epics_too`, `trackers_too` or `false` | Decomposed-parent auto-close policy for the repo: `true` closes a parent when every child is closed except `epic`/`hold`-labelled issues; `epics_too` also closes those; `trackers_too` does that and also closes tracker/umbrella issues with no sub-issues once everything they reference is finished; `false` never closes a parent. A parent a person reopened after a hive auto-close is never re-closed under any value. Editable in Settings, Repos tab, Parent auto-close (owner only; applies without a restart). See [stage-labels.md](../labels-and-control-signals/stage-labels.md#decomposed-parents--closed-by-their-children-never-stalled). |
| `review_feedback.rules.enabled` | `true` (default) or `false` | Whether the review-feedback sweep records rules reviewers state on the hive's PRs into its knowledge. `false` stops capture; rules already recorded keep loading until retracted. `HIVE_REVIEW_FEEDBACK_RULES`, when set, decides instead. Editable in Settings, Features tab, Review (owner only; applies on the next sweep pass, without a restart). See [Reviewer-stated rules](../review-feedback-rules.md#settings). |
| `review_feedback.rules.trusted_associations` | list of GitHub author associations (`OWNER`, `MEMBER`, `COLLABORATOR`, `CONTRIBUTOR`, ...); empty = `OWNER, MEMBER, COLLABORATOR` | Associations whose rules are captured at once; every other reviewer's rule is queued for a person to approve. `HIVE_REVIEW_FEEDBACK_RULE_TRUSTED_ASSOCIATIONS`, when set, decides instead. |
| `review_feedback.rules.extra_phrases` | list of phrases, 4 to 100 characters each, at most 50 | Extra phrases that mark a comment as a rule, matched case-insensitively as whole words (never as patterns). Quoted lines, code blocks and questions are ignored, as for the built-in phrases. |
| `review_feedback.rules.disabled_signals` | list of built-in signal names | Built-in signals that no longer mark a comment as a rule: `source-of-truth`, `authoritative`, `always`, `never`, `going-forward`, `capture-request`, `assessment-criteria`, `knowledge-base`. |
| `project.style` | unset (built-in text applies) | Hive-wide **house style**: a short how-to-change rule list prepended to every kick on every backend, directly under the header. A managed repo's root `HIVE_STYLE.md` (read from `project.checkouts_dir`) overrides it; precedence repo > hive > built-in. Inline text wins over `project.style_file`. See [house-style.md](../house-style.md). |
| `project.style_file` | unset | Path on the hive host holding the hive-wide house style; used when `project.style` is empty. |
| `project.style_max_bytes` | `4096`; values under `512` are raised to `512`. | Caps each house-style candidate. An oversize candidate is skipped whole (not clipped) and the next source applies; the skip is audited as `house_style_skip`. The repo file is also run through ioscan at the issue-body policy and refused whole on a block. |
Expand Down
26 changes: 23 additions & 3 deletions src/docs/review-feedback-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ leaving it to the agent's discretion ([#19046](https://github.com/hivecommons/hi
and `knowledge-base`. Comment text is data: it is matched and quoted, never executed, fetched or followed.
2. **Extract.** The rule text is the sentences that carry a signal, without clauses that only ask for the capture, bounded to 600 characters.
3. **Gate on trust.** A rule changes what every later run is told, so only reviewers whose GitHub association is in
`HIVE_REVIEW_FEEDBACK_RULE_TRUSTED_ASSOCIATIONS` (default `OWNER,MEMBER,COLLABORATOR`) are captured at once. Any other reviewer's rule is
`review_feedback.rules.trusted_associations` (default `OWNER,MEMBER,COLLABORATOR`; see [Settings](#settings)) are captured at once. Any other reviewer's rule is
queued as a draft knowledge entry that a person approves. A trusted reviewer restating a queued rule activates it.
4. **Persist.** The rule gets an id (`R-1`, `R-2`, ...) and is written to the `review-rules` local knowledge channel as an entry tagged `pin`,
with provenance: the PR, the comment id and URL (the entry's `source`), the reviewer, their association, the time, and whether the hive or
Expand Down Expand Up @@ -77,10 +77,30 @@ neither kicks nor the dashboard wait for a restart. After a change, the primer r

## Settings

The preferences are `review_feedback.rules.*` keys in `hive.yaml`, and the owner edits them in Settings, **Features** tab, **Review** section, **Rules from review feedback**. A change applies on the sweep's next pass (every five minutes) without a restart. The card is owner-only; every other role sees that it is.

```yaml
review_feedback:
rules:
enabled: true # false stops capture; the sweep keeps running
trusted_associations: [OWNER, MEMBER, COLLABORATOR]
extra_phrases: ["house rule"] # phrases that also mark a comment as a rule
disabled_signals: [knowledge-base]
```

| Key | Default | Meaning |
|---|---|---|
| `review_feedback.rules.enabled` | on | `false` stops rule capture. Rules already recorded keep loading into kicks until retracted. |
| `review_feedback.rules.trusted_associations` | `OWNER,MEMBER,COLLABORATOR` | Associations whose rules are captured at once; others are queued. An empty list is the default. |
| `review_feedback.rules.extra_phrases` | none | Extra phrases that count as a signal named `extra-phrase`. Matched case-insensitively as whole words, never as patterns; 4 to 100 characters, at most 50. |
| `review_feedback.rules.disabled_signals` | none | Built-in signals (`source-of-truth`, `authoritative`, `always`, `never`, `going-forward`, `capture-request`, `assessment-criteria`, `knowledge-base`) that no longer count. |

The environment variables keep working and win over the yaml keys when they are set; the Settings card says so when one is, and the key is still saved. Extra phrases and disabled signals have no environment variable.

| Variable | Default | Meaning |
|---|---|---|
| `HIVE_REVIEW_FEEDBACK_RULES` | on | Set to `0`, `false`, `off` or `no` to stop rule capture. The sweep keeps running. |
| `HIVE_REVIEW_FEEDBACK_RULE_TRUSTED_ASSOCIATIONS` | `OWNER,MEMBER,COLLABORATOR` | Associations whose rules are captured at once; others are queued. |
| `HIVE_REVIEW_FEEDBACK_RULES` | on | Set to `0`, `false`, `off` or `no` to stop rule capture, or to any other value to keep it on whatever `review_feedback.rules.enabled` says. Unlike the yaml key, it also keeps the review-rules channel out of the kick primer. |
| `HIVE_REVIEW_FEEDBACK_RULE_TRUSTED_ASSOCIATIONS` | `OWNER,MEMBER,COLLABORATOR` | Overrides `review_feedback.rules.trusted_associations`. |
| `HIVE_REVIEW_FEEDBACK_RULES_MAX` | `200` | Bound on live (active or queued) rules. |
| `HIVE_REVIEW_FEEDBACK_RULE_MERGE_THRESHOLD` | `0.8` | Text similarity at which same-scope rules merge. |
| `HIVE_REVIEW_FEEDBACK_RULES_VAULT` | `/data/vaults/review-rules` | Knowledge channel the rules are written to. |
Expand Down
1 change: 1 addition & 0 deletions src/docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Optional capabilities, each off or inert until you turn it on. Where a feature h
- Spek stage runner: [Spektacular](spektacular.md).
- Auto-merge: [App self-merge sweep](operator-reference.md#app-self-merge-sweep-auto_merge), [Trusted bot authors](hive-merge.md#trusted-bot-authors), and [Trusted-author auto-merge](hive-merge.md#trusted-author-auto-merge).
- Review gate: [Review swarm](review-swarm.md#configuration), [Blocking line and backlog](review-swarm.md#blocking-line-reviewseverity-reviewbacklog), and [external review bot threads](review-bot-threads.md).
- Rules from review feedback: [Reviewer-stated rules](review-feedback-rules.md#settings). Owner only; the card edits `review_feedback.rules.*` and applies on the next sweep pass.
- Trajectory review: [Trajectory-Review Lane](trajectory-review.md#configuration).
- Linear agent: [Linear agent integration](linear-agent.md).
- Upstream watch: [Upstream watch](upstream-watch.md#configuration).
Expand Down
Loading
Loading