Repository navigation
✨ knowledge: scope block on entries and a kick-context filter in the Primer - #17060
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. @clubanderson this PR is held at Why:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. |
…Primer A knowledge entry can now say where it applies with a frontmatter scope: block (paths, labels, lanes). FileStore parses it into Fact.Scope; Primer.PrimeForKick takes the kick's lane, issue labels and known file paths and keeps a scoped fact only when one dimension matches (OR), both in the ranked set and in graph expansion. Unscoped facts are unchanged. The scheduler passes the base lane name and the primed issues' labels; paths stay empty on the kick path. The count excluded is reported as PrimedKnowledge.ScopedOut and in the "knowledge primed" log line. Proposed by @gregoryhunt at the 2026-11-05 community meeting. Fixes #17045 Part of #17043 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
f54b598 to
18df130
Compare
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
There was a problem hiding this comment.
One verified gap from the rebase onto #17068, otherwise the scope filter reads correctly.
Lane-/label-scoped entries never surface through the mid-task advisor. knowledgeAdviser.Advise (src/cmd/hive/knowledge_adviser.go:87 at this head) calls primer.PrimeScoped(ctx, agentScope, paths, scope.Keywords), and PrimeScoped wraps that as KickContext{Paths: filePaths} (src/pkg/knowledge/primer.go:100) — no Lane, no Labels. FactScope.Admits (src/pkg/knowledge/scope.go) then only matches on kc.Paths, so an entry with scope: {lanes: [reviewer]} is scoped out for the reviewer agent mid-task, and labels:-scoped entries likewise. That is the inverse of what #17068 merged to do ("surface scoped knowledge mid-task"), and it is silent apart from the scoped_out counter. Advise already has agent, so the fix is small: build the context explicitly, e.g. primer.PrimeForKick(ctx, agentScope, knowledge.KickContext{Lane: cfg.BaseAgentName(agent), Paths: paths}, scope.Keywords). Labels aren't available in crux.KnowledgeScope, so that dimension staying unevaluable there is fine as long as the doc says so (the knowledge-toc.md paragraph currently only mentions paths being unknown on the kick path).
Checked and fine:
Admitsreturns true for an unscoped fact (IsZero), and dimensions are OR-ed exactly asknowledge-toc.mddocuments;matchSegmentshandles**across zero or more segments and falls back topath.Matchper segment, sosrc/scripts/**matchessrc/scriptsandsrc/scripts/a/b.kickContextFor(src/pkg/scheduler/kick_priming.go:382) lowercases and dedupes labels and usescfg.BaseAgentName, matchingcontainsFoldon the scope side.- Graph-expanded related facts go through the same gate (
expandWithGraph(prioritized, scope, kc)), so a scoped fact cannot sneak back in via a neighbour. - Frontmatter: inline lists only, block lists skipped — documented, and
parseScopeListstrips brackets/quotes as described.
No security surface. Changelog fragment and knowledge-toc.md are updated.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Fixes #17045 — phase 2 of #17043 (RFC: AGENTS.md carries tone only; knowledge becomes scoped skills surfaced on demand). Proposed by @gregoryhunt at the 2026-11-05 community meeting; owner Andy (@clubanderson).
What
scope:frontmatter block on knowledge entries, parsed byFileStore(parseObsidianFileDetailed) into a newFact.Scope *FactScope{Paths, Labels, Lanes}(json:"scope,omitempty", so existing payloads are byte-identical). Inline lists only; block-list items insidescope:are skipped rather than leaking intotags. All-empty scope collapses to nil.Primer.PrimeForKick(ctx, scope, KickContext{Lane, Labels, Paths}, keywords). After the lifecycle andagent_scopesfilters,FilterByKickContextkeeps a scoped fact only when at least one declared dimension matches the kick (OR across dimensions;**globs for paths; case-insensitive labels/lanes). Unscoped facts are untouched. Graph-expanded neighbours are gated the same way.PrimeScopedis unchanged in signature and now delegates withPaths: filePaths.primeKnowledgepasseskickContextFor(cfg, agent, issues)— the base lane name (replicas resolve to their base) and the de-duplicated, lower-cased union of the primed issues' labels. Paths stay empty on the kick path (nothing there knows which files an agent will touch — that is the mid-task advisor, tracked separately).PrimedKnowledge.ScopedOutandscoped_outon the existingknowledge primedlog line.src/docs/knowledge-toc.md→ "Entry scope (scope:frontmatter)". Entry format and the entries themselves are in 🌱 AGENTS.md: keep tone and workflow rules; move repository facts into scoped knowledge entries #17051.knowledge.primer.max_bytes(default 4096) already exists; no second knob added.Tests (table-driven, no
time.Sleep)scope_test.go: glob semantics;Admits(nil/empty scope, each dimension, OR, unevaluable dimension);FilterByKickContext; frontmatter parsing (inline lists, keys after the block still parsed, all-empty → nil, block items do not leak into tags, scope keys outside a block ignored); end-to-endPrimeForKickagainst a tempFileStore(scoped entry hidden without context, admitted by label or path,ScopedOutcounts,PrimeScopedfile paths double as kick paths).kick_priming_scope_test.go:kickContextForlane/replica/labels/nil-config.Semantics worth a look
A declared dimension the kick cannot evaluate does not admit by default — a
paths-only entry is never injected at kick time today. That is deliberate (the point of a scope is not paying for the fact on every kick); such entries are lookup targets for a CLI agent reading the directory, and become kick-injectable once a caller supplies paths.