Skip to content
Merged
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-19046-capture-reviewer-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Rules and sources of truth that people state in review feedback on the hive's own agent PRs are now captured deterministically into the hive's knowledge, so they hold for future work and not only for the PR they were written on ([#19046](https://github.com/hivecommons/hive/issues/19046)). The review-feedback sweep classifies each comment in a burst from explicit phrase signals (for example "source of truth", "going forward", "capture this", "assessment criteria"), writes a rule to a local `review-rules` knowledge channel with its provenance (PR, comment, reviewer, association, time), deduplicates by comment id and by near-identical text, and replies on the PR "recorded as rule R-n in the hive's knowledge, applies to ..." so the reviewer can object. Only `OWNER`, `MEMBER` and `COLLABORATOR` reviewers are captured at once (`HIVE_REVIEW_FEEDBACK_RULE_TRUSTED_ASSOCIATIONS`); other reviewers' rules are queued as drafts for a person to approve. The kick primer now carries pinned entries whose scope admits the kick whatever its keywords are, so the quality agent receives its rules on its next run. The kicked agent may end its reply with a validated `hive:review-rules` block to sharpen a rule, and a rule whose proper home is another project's repo gets exactly one needs-human note with the proposed text instead of a write there. Retract with `hivectl knowledge state rule-r-1 deprecated`. Set `HIVE_REVIEW_FEEDBACK_RULES=off` to stop capture.
39 changes: 39 additions & 0 deletions src/cmd/hive/boot_knowledge_primer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package main

import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/hivecommons/hive/pkg/dashboard"
"github.com/hivecommons/hive/pkg/knowledge"
"github.com/hivecommons/hive/pkg/reviewrules"
)

// beadSynthVaultPath is where the bead synthesizer writes its facts.
Expand Down Expand Up @@ -52,12 +55,48 @@ func (b *boot) registerKnowledgeStores(p *knowledge.Primer) {
b.logger.Info("bead-synth vault registered with primer", "layer", layer)
}
}
b.registerReviewRuleVault(api, p)
if gs := api.GraphStore(); gs != nil {
p.SetGraphStore(gs)
api.WireContext7Suggester(p)
}
}

// registerReviewRuleVault connects the local channel the review-feedback sweep
// writes reviewer-stated rules into (hivecommons/hive#19046) and registers it
// with p as a pinned store: an approved rule whose scope admits a kick reaches
// that kick whatever its keywords are. The channel shows in the dashboard's
// knowledge list like any other, with each rule's source comment and reviewer.
func (b *boot) registerReviewRuleVault(api *knowledge.KnowledgeAPI, p *knowledge.Primer) {
if !reviewrules.Enabled() {
return
}
dir := reviewrules.VaultDir()
store := api.GetVaultStore(dir)
if store == nil {
// Create the channel only beside the hive's other vaults. A host
// with no vaults directory gets the channel on the first capture
// and connects it at the next boot.
if _, err := os.Stat(filepath.Dir(dir)); err != nil {
if _, derr := os.Stat(dir); derr != nil {
return
}
}
if err := os.MkdirAll(dir, 0o755); err != nil {
b.logger.Debug("review-rule vault not created; reviewer rules are not primed", "dir", dir, "error", err)
return
}
if err := api.ConnectVault(dir, reviewrules.VaultName); err != nil {
b.logger.Warn("review-rule vault not connected; reviewer rules are not primed", "dir", dir, "error", err)
return
}
store = api.GetVaultStore(dir)
}
if store != nil {
p.AddPinnedFileStore(reviewrules.VaultName, store, knowledge.LayerProject)
}
}

// knowledgeRestartReason names what a live-registered primer cannot apply
// because knowledgeAPI is the file-only fallback bootKnowledge builds when
// knowledge.enabled is false at boot. Empty when nothing waits on a restart.
Expand Down
Loading
Loading