Skip to content

πŸ› [v6] knowledge priming: search on what the issue is about, not hive routing - #17329

Draft
Danathar wants to merge 5 commits into
hivecommons:v6from
Danathar:fix/v6-knowledge-priming-query
Draft

Danathar wants to merge 5 commits into
hivecommons:v6from
Danathar:fix/v6-knowledge-priming-query

Conversation

@Danathar

@Danathar Danathar commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resident kicks and contributor role guidance get a "# Relevant Knowledge" section from a search built from the work's issues. On hive-routed work that search was mostly the hive's own routing words, so it pulled in knowledge about other repos, and on the projectbluefin hive it gave nearly every agent the same section. Now the search uses what the issue is about.

It cannot leave a kick without a section it gets today. If the filtered terms are empty, or they match no entry, the search runs again with exactly the old query.

Seen live: a scanner task on projectbluefin/utah-packages#879 built the query stage/010-actionable agent/reviewer kind/cleanup approved-direction reviewer review backlog style … (from the log line #17319 added), and was primed with review notes about knuckle, bluefin-lts and dakota.

Draft: the maintainer wants to review this before it is marked ready. This is round 3; two independent reviews and what changed are listed at the end.

What changes

All in extractKeywordsFor and renderKnowledge (src/pkg/scheduler/kick_priming.go). The knowledge package is untouched.

  • Routing labels are no longer search terms. Left out:

    • hive families: stage/ (stagelabels.Prefix), agent/ and origin/ (config.IsAgentLaneLabel / IsOriginLabel), hive/, hive: (hive: churn-triaged), hive-pause/ (github.HiveHoldLabelPrefix), author/ (authorkind.Prefix), triage/, size/, lifecycle/, do-not-merge, needs-, dco-signoff, sentinel-;
    • Prow's: tide/, ok-to-test, release-note, cncf-cla:;
    • single labels: approved-direction, hive-review, lgtm, approved, claimed;
    • the hive's never-claim labels from config (claims.never_claim_labels, default epic).

    Labels that describe the work stay, for example kind/cleanup, priority/high and area/*.

  • The complexity tier is no longer a search term. simple, medium and complex come from the hive's classifier, and medium was in every projectbluefin query sampled.

  • A filer tag comes off a title only when it names a hive filer: a built-in lane, an origin source (selfreport, governor, …) or an agent configured on this hive. A person's [nvidia] driver fails to build keeps nvidia.

  • A review backlog title is cut to its perspective and finding, with any leading tag: [reviewer] Review backlog (style): spec file mixes tabs searches as style spec file mixes tabs.

  • Two fallbacks keep today's sections:

    • if nothing is left to search on, the query is the old one (legacyKeywords);
    • if the filtered terms match no entry, renderKnowledge searches once more with the old query and logs knowledge primer: no entry matched the issue terms, retrying with the full query.

    legacyKeywords and the new query share one walk (collectKeywords), and the legacy filter is the old noiseLabels list unchanged.

What this can still change: when the filtered terms do match entries, the section holds those entries rather than the ones the routing words used to pull in. That is the intended change. On the projectbluefin hive every search returns the 25-entry maximum (see below), so in practice sections stay full and only their contents change.

Who it affects

The query is shared, so this changes both contributor role guidance (BuildAgentGuidanceForTask) and resident kicks (templates.go and the lane messages for scanner, quality, architect and other agents). Label-scoped entries (scope.labels, scope.lanes) are unaffected: the kick context still sees every label, including agent/* and stage/*.

What the projectbluefin hive shows (read-only, 2026-11-08 18:00Z to 2026-11-09 01:55Z)

  • Every resident kick's section was full. Each search returned the 25-entry maximum, and 9 to 13 entries fit under the 4 KiB cap.
  • The query was nearly constant. Kicks hour after hour logged the same leading keywords, epic, approved-direction, stage/010-actionable, stage/stalled, medium, …, and the reviewer, quality and sec-check kicks injected the identical 3,972 bytes from 12 entries.
  • Other hive labels seen in its queries: hive/already-done, hive/partially-addressed, hive/verified-open, hive: churn-triaged, origin/governor, agent/ci-maintainer.
  • I could not see which entries each kick carried (stored prompts and kick logs are cut before the section), so this comes from the search logs, not a per-entry comparison.

Not in this PR

  • Ranking the task repo's own entries first. Earlier rounds of this PR did that. Review showed it can change which entries survive the 25-entry and byte caps, has repo-matching edge cases (bare repo:<name> tags, multi-repo tags, five queued repos at once), and does nothing on the projectbluefin hive, whose vault has no repo: tags. It is now a separate local branch, fix/v6-knowledge-task-repo-rank, not opened.
  • Work-source hold_labels (Linear, Jira, GitLab sources). They are per source rather than hive-wide; GitHub's hold was already left out.

Files

  • src/pkg/scheduler/kick_priming.go: extractKeywordsFor (extractKeywords is its no-config form), legacyKeywords, collectKeywords, searchableTitle, hiveFilers, neverClaimLabels, isRoutingLabel; the no-hit retry in renderKnowledge. isNoiseLabel is unchanged.
  • src/docs/agent-knowledge-and-memory.md: primer diagram, step 1.
  • changelog.d/fixed-knowledge-priming-query.md.

Tests

CI is the verdict here. Nothing was run locally except gofmt -l.

src/pkg/scheduler/kick_priming_query_test.go:

  • TestExtractKeywords_DropsHiveRouting: the fix: tighten advisor/newcomer token permissionsΒ #879 issue, with its tier and every routing family including Prow's, gives exactly kind/cleanup style spec file mixes tabs spaces.
  • TestExtractKeywords_AllRoutingFallsBackToLegacyQuery: [ci-maintainer] Fix CI with only routing labels gets the old query.
  • TestExtractKeywords_ConfiguredNeverClaimLabels: a configured never_claim_labels: [Tracker] is left out, and epic then stays.
  • TestSearchableTitle: lane, origin-source and configured-agent tags come off; any tag before "Review backlog" comes off; [nvidia], [ACMM L0], an unconfigured agent name and "Review the backlog of …" stay.
  • TestIsRoutingLabel: every family above is left out; kind/cleanup, priority/high, area/packaging, stagehand, agentic, authoring and epic (as a label word) stay.
  • TestPrimeKnowledge_NoHitFallsBackToLegacyQuery: a wiki that matches only the old query's ci-maintainer terms. The kick still gets that entry, from a second search, and the first search was flaky lint job.

The existing keyword tests are unchanged and still hold. TestExtractKeywords_IncludesTier passes through the first fallback, since its issue has nothing but a tier.

Review history

Round 1 review finding Now
Missed hive labels (epic, claimed, author/*, hive-pause/*) Left out; never-claim labels come from config
Complexity tier still a search term Left out (kept in the fallback)
Any lowercase bracket stripped ([nvidia]) Only hive lanes, origin sources and configured agents
A routing-only issue could get no keywords Old query used
Repo boost: re-sort undone, confidence changed, tag matching Repo ranking removed from this PR
Hand-kept label list Uses the hive's helpers and prefixes where they exist
Local test runs claimed; stale test name Removed; CI only
Round 2 review finding Now
Fallback only when the query is empty, not when it finds nothing Second search with the old query when nothing matches
epic hard-coded; configured never-claim labels ignored cfg.Governor.Claims.EffectiveNeverClaimLabels()
Prow labels (ok-to-test, tide/, bare do-not-merge, …) kept Left out
Boost changes what survives the caps; bare-name, multi-tag and multi-repo matching Repo ranking removed from this PR (local branch)
Duplicate review-backlog regex missed unconfigured tags Regex takes any leading tag, same shape as pkg/github's
Two near-identical keyword loops; per-issue origin-source rebuild One collectKeywords walk; filer set built once
Two concerns in one PR One concern: the query

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

Danathar and others added 2 commits November 8, 2026 20:49
The "# Relevant Knowledge" query was an issue's labels plus title words,
and on hive-routed work those were mostly the hive's own routing:
stage/010-actionable, agent/reviewer, approved-direction and the
"[reviewer] Review backlog (style):" stem. They match review and scanning
notes in every repo, so utah-packages#879 was primed with other repos'
entries.

extractKeywords now drops the hive's routing label families and the
filer tag, and cuts a review backlog title to its perspective and
finding. The kick context carries the issues' repositories, and the
primer adds 0.1 to the rerank score of entries tagged
repo:<org>/<name> for them. The tag orders what the search found; it
admits nothing. Label-scoped entries still see every label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Douglas Baggett <doug.baggett@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Douglas Baggett <doug.baggett@gmail.com>
@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 9, 2026
@Danathar
Danathar marked this pull request as draft November 9, 2026 01:54
@kubestellar-prow kubestellar-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 9, 2026
Seen in the projectbluefin hive's primer queries: origin/governor and
hive: churn-triaged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Douglas Baggett <doug.baggett@gmail.com>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style review (head c9c5541). Approving; two maintainability notes the author may want to pick up, neither blocks.

1. TestKnowledgeKick_TaskRepoRanksItsEntriesFirst reaches for the role-guidance fixture just to get a config β€” src/pkg/scheduler/kick_priming_query_test.go:84. guidanceScheduler(t, "") (role_guidance_test.go:42) builds the golden scheduler, a checkouts dir and an AGENTS.md that this test never reads. kickContextFor accepts a nil config (covered by the "nil config keeps the agent name" case in kick_priming_scope_test.go:40), so the test can stand alone:

	kc := kickContextFor(nil, "scanner", []github.Issue{task})

Relatedly, the new Repos field is asserted only inside this integration test; TestKickContextFor (kick_priming_scope_test.go:11) is the table that already pins Lane/Labels/Paths for kickContextFor and is the natural home for a wantRepos column (de-dup, lower-casing, and the Contains("/") guard are untested as written).

2. Three label-noise tables where one would do β€” src/pkg/scheduler/kick_priming.go:684-718. noiseControlLabels has the same shape and purpose as the existing noiseLabels map directly above it ("labels that say nothing about the work"), and noiseLabels["triage/accepted"] (line 685) is now shadowed by the "triage/" prefix. Folding the four control labels into noiseLabels and dropping the redundant entry keeps isNoiseLabel to one map lookup plus the prefix loop.

Minor: the PR body names the first test TestExtractKeywords_DropsHiveRoutingAndNamesTheRepo; the file has TestExtractKeywords_DropsHiveRouting (line 20), which matches what it asserts.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Read the diff against v6 at c0dc472 plus the callers; this looks correct to me.

What I verified:

  • src/pkg/knowledge/primer.go:166 β€” boostTaskRepos runs after rerankFisherRao, which already overwrites Confidence with the blended score (primer.go:229 on v6), so adding taskRepoBoost to Confidence follows the existing pattern rather than inflating a stored wiki confidence. applyPriority (primer.go:277) tie-breaks on Confidence within a type, so the boost survives the final sort.
  • src/pkg/knowledge/scope.go β€” IsZero and Admits ignore Repos, so a kick with only a repo and no lane/labels still hits the kc.IsZero() passthrough in FilterByKickContext; the tag admits nothing, as the body says.
  • src/pkg/scheduler/kick_priming.go β€” issueshape.StripAgentPrefix resolves via the re-export in pkg/issueshape/issueshape.go:20 β†’ crux/issueshape/issueshape.go:206, so the new import compiles. kickContextFor still collects every label into kc.Labels independently of isNoiseLabel, so scope.labels entries keyed on agent/* / stage/* are unaffected, as claimed.
  • Existing tests TestIsNoiseLabel, TestExtractKeywords_* (scheduler_test.go:969-1038, scheduler_extra_test.go:212) and TestKickContextFor (kick_priming_scope_test.go) assert on individual fields, not a whole-struct DeepEqual, so the new Repos field and the widened noise set do not break them.

One nit in the PR body only: it names the test TestExtractKeywords_DropsHiveRoutingAndNamesTheRepo; the file has TestExtractKeywords_DropsHiveRouting (kick_priming_query_test.go:21). Worth syncing before the draft is marked ready.

No code changes requested.

Danathar and others added 2 commits November 8, 2026 21:34
Round 2, from an independent review of round 1:

- A query left empty by the filter falls back to the old one
  (legacyKeywords), so no kick loses a section it had.
- A leading [tag] comes off only when it names a hive lane, origin
  source or configured agent; "[nvidia] …" keeps nvidia.
- The complexity tier is no longer a search term; epic, claimed,
  author/* and hive-pause/* join the routing labels, using the config
  helpers for agent/* and origin/*.
- The task-repo boost is a separate rankBoost that applyPriority sorts
  on within a type; Confidence, which kicks show, is untouched. It uses
  FactRepo and matches a bare repo:<name> code-map tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Douglas Baggett <doug.baggett@gmail.com>
Round 3, from a second independent review:

- The repo ranking is out of this PR (kept on a local branch): it could
  change which entries survive the caps, and does nothing on a vault
  without repo: tags. The knowledge package is back to v6.
- When the issue's own terms match no entry, renderKnowledge searches
  again with the old query, so no kick loses the section it got.
- Never-claim labels come from claims.never_claim_labels; Prow's
  tide/, ok-to-test, release-note, cncf-cla: and bare do-not-merge are
  left out.
- One collectKeywords walk serves both queries; the review backlog
  regex takes any leading tag; the filer set is built once per query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Douglas Baggett <doug.baggett@gmail.com>
@Danathar Danathar changed the title πŸ› [v6] knowledge priming: search on the task, rank its repo first πŸ› [v6] knowledge priming: search on what the issue is about, not hive routing Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

No conflicting open PRs or same-file overlaps were found.

@clubanderson

Copy link
Copy Markdown
Member

Summary
Read the full diff against v6 (459cab3) and the callers. Round 3 is the right shape: the query drops what the hive put on the item, both fallbacks (extractKeywordsFor β†’ legacyKeywords on empty; renderKnowledge re-search on zero hits) make it strictly no-worse than today, and the repo-rank concern is correctly split out. No GitHub API calls added, 8192 primer cap and config defaults untouched, no goroutines/sleeps in the new tests.

Findings

  • P3 src/pkg/scheduler/kick_priming.go:408 β€” the no-hit retry logs at Info per kick. On small vaults (new spokes with a handful of entries) the filtered query will miss often and this becomes a per-kick line; Debug is enough, or fold it into the existing "knowledge bytes injected" line from ✨ kick priming: one log line per kick with knowledge bytes injected and entries skipped for the capΒ #17064 as a fallback=legacy field.
  • P3 src/pkg/scheduler/kick_priming.go:412 β€” the retry is a second search against every knowledge layer (HTTP to the wiki, not GitHub), so a miss costs 2Γ— layer queries per kick. Acceptable, just worth a sentence in the doc so nobody later "optimizes" it away without understanding why it exists.
  • P3 src/pkg/scheduler/kick_priming.go:795 β€” needs- and release-note as bare prefixes also catch non-hive labels (needs-design, release-notes-wanted). Those are still process labels, so I'm fine with it; noting so the choice is on record.
  • P3 src/pkg/scheduler/kick_priming_query_test.go:121 β€” TestPrimeKnowledge_NoHitFallsBackToLegacyQuery pins the exact first query "flaky lint job"; it will break on any future noise-word change rather than on a regression of the fallback. Consider asserting !strings.Contains(queries[0], "agent/") plus len == 2 instead.
  • OK β€” changelog.d/fixed-knowledge-priming-query.md uses a valid category (fixed), matches the πŸ› title; doc diagram updated. Tests cover: routing-only issue (empty β†’ legacy), configured never-claim labels, filer-tag vs person-tag, review-backlog stem, no-hit retry. Multi-issue dedupe is already covered by the existing TestExtractKeywords_*.
  • CI β€” only native-queue-policy fails, and that is the draft gate (head/base moved, draft, closed, or held), not this PR.

Questions / decision

  • "The maintainer wants to review this before it is marked ready": approach approved β€” please mark ready. The P3s above are optional follow-ups, not blockers.
  • Repo-first ranking (fix/v6-knowledge-task-repo-rank): keep it parked. Don't open it until a hive actually carries repo: tags and we can show a before/after on the cap survivors; the edge cases you listed (bare repo:<name>, multi-repo tags, 5 queued repos) need a design note first.
  • v5: our spokes run the v5 candidate and extractKeywords is identical there (src/pkg/scheduler/kick_priming.go:502 on origin/v5). Once this merges, please open a [v5] cherry-pick; it should apply cleanly since the knowledge package is untouched.

Verdict: approve.

@clubanderson

Copy link
Copy Markdown
Member

/lgtm

@clubanderson

Copy link
Copy Markdown
Member

/approve

@kubestellar-prow kubestellar-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Nov 9, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: f52082ff5f54f36a781af444ee72bde3e7f254bf

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clubanderson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 9, 2026
hivecommons-hive Bot pushed a commit that referenced this pull request Nov 9, 2026
…le CI runs (#17462)

While a CI / Review track runs, the stage chevron renders settled-current
(filled but still, icon only). The Open-column word tints (draft slate,
blocked yellow, New blue, stale amber-red) and the held-gate amber were
declared later in tracker.css at equal specificity, so they repainted the
settled chevron and the row showed two coloured chevrons β€” hive's own
#17329, a draft PR with no stage, read as slate Open + amber CI 51/64.

One higher-specificity settled-current rule after the tints restores the
neutral fill; the draft class stays for the tooltip. Node test covers the
rendered classes and the CSS ordering/specificity.

Fixes #17461

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants