mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-05 14:46:55 +01:00
Add read-only planning and repository-changing development skills so BCQuality knowledge can guide features, bug fixes, refactors, upgrades, and maintenance before the existing AL review gate runs. Track Microsoft Learn ingestion and add development and BCApps-shaped guidance evaluation fixtures. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 638b66d2-9f06-4f60-8781-808709e1485c
138 lines
12 KiB
Markdown
138 lines
12 KiB
Markdown
# How agents consume BCQuality
|
|
|
|
BCQuality is content — knowledge files and skills. It is consumed by agents that live elsewhere (AL-Go, a VS Code extension, a GitHub Agent invocation, etc.). This document explains the end-to-end flow, so that skill authors, orchestrator maintainers, and contributors share one mental model.
|
|
|
|
For the high-level framing and repo structure, start with the [README](README.md). This document is the operational view.
|
|
|
|
## The actors
|
|
|
|
- **Orchestrator** — the tool that triggers work (e.g. AL-Go on a pull request, or a VS Code extension on save). Lives *outside* BCQuality. Knows *when* to run something, not *what* to run.
|
|
- **Agent** — an LLM-driven process spawned by the orchestrator. The agent has no built-in knowledge of BC or of BCQuality's conventions. It knows how to read instructions and call tools.
|
|
- **BCQuality repo** — two kinds of content:
|
|
- **Global skills** in `/skills/` — the `entry.md` entry-point skill plus the READ · DO · WRITE contracts that govern the rest of the repo.
|
|
- **Layer content** in `/microsoft/`, `/community/`, and `/custom/` — knowledge files and action skills grouped by authority.
|
|
|
|
When BCQuality is installed as a standalone plugin, it additionally exposes
|
|
`skills/al-code-review/SKILL.md` and
|
|
`skills/al-development/SKILL.md`. These are host-format adapters, not
|
|
additional action skills: each creates the task context and enters the same
|
|
flow at Entry.
|
|
|
|
## The flow
|
|
|
|
```mermaid
|
|
flowchart LR
|
|
O[Orchestrator<br/>AL-Go] -->|1 trigger + task context| A[Agent]
|
|
A -->|2 invoke entry.md| E[Entry<br/>routing skill]
|
|
E -->|3 dispatch record| A
|
|
A -->|4 invoke dispatched skill| S[Action skill<br/>e.g. al-code-review]
|
|
S -->|5 execute| P[Source → Relevance<br/>→ Worklist → Action<br/>reading READ · DO on demand]
|
|
P -->|6 emit| R[Findings report<br/>or implementation report]
|
|
R -->|7 integrate| O
|
|
```
|
|
|
|
### 1. Orchestrator triggers
|
|
The orchestrator has a URL setting that points at BCQuality (default: `github.com/microsoft/BCQuality`) and a task to perform. It hands the agent a **task context** — goal, inputs available (`pr-diff`, `file-path`, …), technologies, BC version, enabled layers — and says: *your source of truth lives at that URL; start by invoking `/skills/entry.md`*.
|
|
|
|
### 2. Agent invokes Entry
|
|
The agent reads `/skills/entry.md` and runs it against the task context. Entry applies its Source → Relevance → Worklist → Action steps over the action skills under `*/skills/**/*.md` and returns a **dispatch record**: the set of action skills to invoke, plus a list of candidates it skipped (with reasons). Routing is a skill, not orchestrator logic.
|
|
|
|
For a standalone plugin installation, the host activates the matching adapter
|
|
first. The adapter preserves the caller's actual goal, constructs the task
|
|
context, and invokes Entry. It does not select the internal review or
|
|
development action skill itself or duplicate Entry's preparation, routing, and
|
|
failure semantics.
|
|
|
|
### 3. Agent consumes the dispatch record
|
|
The dispatch record names one or more action skills and the subset of inputs each should receive. If the outcome is `no-match` or `failed`, the agent returns the record to the orchestrator unchanged.
|
|
|
|
### 4. Agent invokes each dispatched action skill
|
|
Action skills live inside the layers — `/microsoft/skills/`, `/community/skills/`, `/custom/skills/` — so their authority is carried by their location. For a PR review, Entry typically dispatches `microsoft/skills/review/al-code-review.md`. The agent reads the file and executes it.
|
|
|
|
### 5. Action skill executes the four-step pattern
|
|
|
|
Each action skill is a markdown file that specifies what to do at each step. The template is always the same:
|
|
|
|
| Step | What happens |
|
|
| --- | --- |
|
|
| **Source** | Declare which knowledge folders and tags to search. |
|
|
| **Relevance** | Filter by frontmatter — `bc-version`, `technologies`, `countries`, `application-area`. |
|
|
| **Worklist** | Narrow from N candidates to the M that apply to this specific task. |
|
|
| **Action** | Apply the relevant knowledge and produce structured output. |
|
|
|
|
Example: the Microsoft-owned performance review skill selects `performance` entries across every enabled layer, filters to `bc-version: 26` and `technologies: [al]`, narrows the candidate files to those that apply to the changed objects, and then evaluates each file against the diff. Its canonical corpus lives beside it under `/microsoft/knowledge/performance/`; cross-layer entries are limited to custom overrides or short-lived promotion work.
|
|
|
|
At this point the agent reads READ and DO on demand — it needs READ to interpret each knowledge file's frontmatter and sections, and DO to shape its output. Those contracts are fetched when first needed, not as part of bootstrap.
|
|
|
|
### 5a. The knowledge index (Source acceleration)
|
|
|
|
Discovering candidates at the Source step naively means opening every file under a domain folder just to read its frontmatter `keywords` — on a large corpus that is hundreds of file reads per review. To avoid this, BCQuality maintains a **knowledge index**: a single artifact (`knowledge-index.json`) that lists every article surviving the consumer's layer/allow-deny filtering and carries, per article, the exact inputs the Source/Worklist steps consume — `path`, `layer`, `domain`, frontmatter dimensions, `keywords`, `title`, and a one-line `description` hint.
|
|
|
|
The index is **owned and produced by BCQuality**, not by each consumer: its generator (`tools/Build-KnowledgeIndex.ps1`) ships here, next to the skills and knowledge it derives from, so the index schema stays in lockstep with the Source contract and every consumer gets the same faithful index for free instead of re-implementing the parser. The consuming orchestrator does **not** build or invoke the index — it only prunes its clone to policy as it already does. The index is then (re)generated by BCQuality itself: **Entry's preparation step runs `Build-KnowledgeIndex.ps1` over the live, already-pruned clone** at the start of every run (see `skills/entry.md`), and BCQuality CI (`.github/workflows/knowledge-index.yml`) validates that the generator is healthy and deterministic. Building over the *pruned* clone — rather than shipping a committed full-corpus index that consumers trust — keeps the index exact for any consumer policy: it can never list an article the consumer denied, so policy-excluded rules cannot leak into discovery.
|
|
|
|
The index changes only *how candidates are discovered*, never *which are selected*. The Worklist predicate is unchanged — `keywords` still drive selection — and the agent still opens each worklisted article **in full** to read its `## Best Practice` / `## Anti Pattern` rule bodies; the index is discovery metadata only and never substitutes for the article body. When no index is present, skills fall back to path-based discovery (collect by domain folder), so review still works.
|
|
|
|
### 6. Agent emits structured output
|
|
The output contracts are defined in the DO meta-skill:
|
|
|
|
- A **findings report** carries review findings, domain labels, references, confidence, and suppressions.
|
|
- A **development guidance report** carries read-only knowledge constraints and validation considerations for an existing plan.
|
|
- An **implementation report** carries the development plan, classified mode, knowledge applied, changed files, validation results, final review, and remaining work.
|
|
|
|
The orchestrator parses this **without skill-specific logic**. This is the point of the contract: orchestrators and action skills evolve independently.
|
|
|
|
For development, the action happens before the report: the skill
|
|
first invokes the read-only planning skill to select applicable knowledge, then
|
|
changes the target repository, runs its native validation, and invokes the
|
|
configured review quality-skill over the resulting diff. A specialized
|
|
repository orchestrator may invoke only the planning skill and feed its
|
|
guidance report into its own implementation phases. The implementation report
|
|
is a machine-readable record of persisted work, not a code proposal for the
|
|
orchestrator to apply later.
|
|
|
|
### 7. Orchestrator integrates
|
|
The orchestrator turns findings into PR comments, build gates, or IDE diagnostics. For implementation it presents the changed files and validation state, while the agent has already persisted the requested change in the target repository.
|
|
|
|
## Repository-specific development orchestrators
|
|
|
|
A repository-specific workflow can keep ownership of implementation and consume
|
|
BCQuality only for planning and review:
|
|
|
|
1. Produce its normal development plan after repository investigation.
|
|
2. Invoke Entry with `inputs-available: [development-plan, repository]` plus
|
|
the resolved applicability dimensions.
|
|
3. Execute the dispatched `al-development-plan` skill and preserve its
|
|
`development-guidance-report`.
|
|
4. Pass the selected article references, constraints, samples, and validation
|
|
considerations into its own test, implementation, and critique phases.
|
|
5. Run its existing BCQuality-backed review gate over the completed diff.
|
|
|
|
This is the integration model for specialized bug-fix or release workflows.
|
|
They keep environment provisioning, retries, state, commits, propagation, and
|
|
pull-request delivery; BCQuality supplies shared product knowledge before and
|
|
after the code change.
|
|
|
|
## Knowledge-backed and agent findings
|
|
|
|
BCQuality is an **additive** knowledge layer. The agent surfaces two kinds of findings, both shaped to the same DO output contract:
|
|
|
|
- **Knowledge-backed findings** carry one or more entries in `references[]` pointing at BCQuality knowledge files. Their `id` is the primary file's repo-relative path. Leaf sub-skills set `domain` to their human-readable display label, and super-skills preserve it verbatim during rollup.
|
|
- **Agent findings** carry an empty `references: []`, use a slug `id` prefixed `agent:`, and have `confidence` capped at `medium`. A leaf can emit one strictly within its own domain and uses that leaf's display label. A super-skill can emit a cross-cutting agent finding with `from-sub-skill: "agent"` and `domain: "Agent"`. Their `message` is self-contained because there is no knowledge-file footer to fall back on.
|
|
|
|
Before a skill emits an agent finding, it validates the candidate against the BCQuality knowledge already loaded for the task: a matching file upgrades the candidate to a knowledge-backed finding (and merges or deduplicates against relevant existing output); a contradicting file suppresses the candidate. Only candidates with no BCQuality coverage become agent findings.
|
|
|
|
Orchestrators MUST tolerate an absent `domain` in reports from older producers. When it is present, treat it as display text rather than an identifier: preserve the full string and its case, whitespace, punctuation, and non-ASCII characters, escaping only for the target rendering format. Do not tokenize it on spaces or use a lowercased or slugified form as the sole metadata or deduplication key, because distinct labels can collapse to the same slug. Retain the exact string, use a lossless encoding, or use a collision-resistant digest instead. Orchestrators MAY render knowledge-backed and agent findings differently and MAY apply independent severity floors; `references: []` and the `agent:` id prefix distinguish agent findings, while `from-sub-skill: "agent"` identifies those emitted by the super-skill itself.
|
|
|
|
## Why this architecture
|
|
|
|
- **Entry is the only hardcoded thing.** Orchestrators ship with one convention — *"invoke `/skills/entry.md` first"* — and nothing else. New action skills and new knowledge files are picked up automatically because Entry discovers them at dispatch time.
|
|
- **Standalone installation adds an adapter, not another policy layer.** The
|
|
plugin's host-format `al-code-review` skill only translates the invocation
|
|
into Entry's task context. Entry and the dispatched action skills remain
|
|
authoritative.
|
|
- **Layers decide authority, not code.** The agent sees `/microsoft/` and `/community/` together; if two files conflict, the precedence rule defined in READ resolves it. A partner fork can disable `/community/` — that's a config choice, not a code change.
|
|
- **Knowledge and skills evolve independently within their owning layer.** A new knowledge file requires no skill changes because existing skills pick it up via frontmatter filters. Layer placement still follows skill ownership, so promoting a skill also promotes its canonical corpus.
|
|
|
|
## The mental model, in one sentence
|
|
|
|
The orchestrator knows **when** to run; Entry decides **which skill** to run; the action skills define **what** to do; the meta-skills teach the agent **how** to behave; the knowledge files are **what** the agent knows.
|