mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 17:36:53 +01:00
Add open-ended bc-version range shorthand [N..]
A closed range like [23..28] wrongly implies guidance stops applying after BC28, so a reviewer targeting BC29+ would not match the file. Introduce an open-ended shorthand [N..] meaning ''version N and every later version''. - validate_frontmatter.py: RANGE_SHORTHAND allows an optional upper bound; expand_bc_version returns the normalized string ''N..'' for open-ended. - read.md: document the fourth bc-version form and its matching rule (matches target >= N; not enumerable). - write.md: prefer [N..] over a closed range for a feature introduced in N and not expected to be removed. - Apply [23..] to the actionable-errors article (actionable errors shipped in BC23 and are not version-bounded above). - README: mention [N..] in the frontmatter example. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
8901b83e07
commit
65f6f22157
5 changed files with 19 additions and 12 deletions
14
.github/scripts/validate_frontmatter.py
vendored
14
.github/scripts/validate_frontmatter.py
vendored
|
|
@ -59,7 +59,7 @@ MAX_KNOWLEDGE_LINES = 100
|
||||||
|
|
||||||
KEBAB_CASE = re.compile(r"^[a-z0-9]+(-[a-z0-9]+)*$")
|
KEBAB_CASE = re.compile(r"^[a-z0-9]+(-[a-z0-9]+)*$")
|
||||||
ISO_ALPHA2 = re.compile(r"^[a-z]{2}$")
|
ISO_ALPHA2 = re.compile(r"^[a-z]{2}$")
|
||||||
RANGE_SHORTHAND = re.compile(r"^(\d+)\.\.(\d+)$")
|
RANGE_SHORTHAND = re.compile(r"^(\d+)\.\.(\d+)?$")
|
||||||
FENCED_CODE_BLOCK = re.compile(r"^```", re.MULTILINE)
|
FENCED_CODE_BLOCK = re.compile(r"^```", re.MULTILINE)
|
||||||
HEADING_H2 = re.compile(r"^##\s+(.+?)\s*$", re.MULTILINE)
|
HEADING_H2 = re.compile(r"^##\s+(.+?)\s*$", re.MULTILINE)
|
||||||
|
|
||||||
|
|
@ -149,6 +149,8 @@ def expand_bc_version(value: Any) -> tuple[list[int] | str | None, str | None]:
|
||||||
"""Return (expanded, error-message). One of the two is None.
|
"""Return (expanded, error-message). One of the two is None.
|
||||||
|
|
||||||
For the universal sentinel ["all"], `expanded` is the string "all".
|
For the universal sentinel ["all"], `expanded` is the string "all".
|
||||||
|
For an open-ended range like ["26.."], `expanded` is the normalized
|
||||||
|
string "26.." (it cannot be enumerated; consumers match target >= 26).
|
||||||
Otherwise it is the expanded list of version integers.
|
Otherwise it is the expanded list of version integers.
|
||||||
"""
|
"""
|
||||||
if not isinstance(value, list) or not value:
|
if not isinstance(value, list) or not value:
|
||||||
|
|
@ -163,15 +165,19 @@ def expand_bc_version(value: Any) -> tuple[list[int] | str | None, str | None]:
|
||||||
if any(v <= 0 for v in value):
|
if any(v <= 0 for v in value):
|
||||||
return None, "integers must be positive"
|
return None, "integers must be positive"
|
||||||
return sorted(set(value)), None
|
return sorted(set(value)), None
|
||||||
# Case 2: single-element range-shorthand like "[26..28]"
|
# Case 2: single-element range shorthand — closed "[26..28]" or open-ended "[26..]"
|
||||||
if len(value) == 1 and isinstance(value[0], str):
|
if len(value) == 1 and isinstance(value[0], str):
|
||||||
m = RANGE_SHORTHAND.match(value[0].strip())
|
m = RANGE_SHORTHAND.match(value[0].strip())
|
||||||
if m:
|
if m:
|
||||||
start, end = int(m.group(1)), int(m.group(2))
|
start = int(m.group(1))
|
||||||
|
if m.group(2) is None:
|
||||||
|
# Open-ended: "start.." applies from start onwards, no upper bound.
|
||||||
|
return f"{start}..", None
|
||||||
|
end = int(m.group(2))
|
||||||
if start > end:
|
if start > end:
|
||||||
return None, f"range '{value[0]}' is not ascending"
|
return None, f"range '{value[0]}' is not ascending"
|
||||||
return list(range(start, end + 1)), None
|
return list(range(start, end + 1)), None
|
||||||
return None, "must be [all], a list of integers, or a single-element range shorthand like [26..28]"
|
return None, "must be [all], a list of integers, or a range shorthand like [26..28] or [26..]"
|
||||||
|
|
||||||
|
|
||||||
def headings_in_order(body: str) -> list[tuple[str, int]]:
|
def headings_in_order(body: str) -> list[tuple[str, int]]:
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ Every knowledge file is a markdown file with mandatory YAML frontmatter. Files t
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
bc-version: [all] # or [26..28] for version-gated guidance
|
bc-version: [all] # or [26..28], or [26..] for "26 and later"
|
||||||
domain: performance # security | performance | ux | telemetry | ...
|
domain: performance # security | performance | ux | telemetry | ...
|
||||||
keywords: [query, filtering, partial] # free-text tags for retrieval
|
keywords: [query, filtering, partial] # free-text tags for retrieval
|
||||||
technologies: [al] # al | javascript | powershell | ...
|
technologies: [al] # al | javascript | powershell | ...
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
bc-version: [23..28]
|
bc-version: [23..]
|
||||||
domain: error-handling
|
domain: error-handling
|
||||||
keywords: [errorinfo, actionable-errors, fix-it, show-it, addaction, addnavigationaction, error-dialog]
|
keywords: [errorinfo, actionable-errors, fix-it, show-it, addaction, addnavigationaction, error-dialog]
|
||||||
technologies: [al]
|
technologies: [al]
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ A file that violates any of these rules is invalid and MUST be skipped by consum
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
bc-version: [all] # or [26, 27, 28] or the range shorthand [26..28]
|
bc-version: [all] # or [26, 27, 28], the range [26..28], or the open-ended range [26..]
|
||||||
domain: performance
|
domain: performance
|
||||||
keywords: [query, filtering, partial]
|
keywords: [query, filtering, partial]
|
||||||
technologies: [al]
|
technologies: [al]
|
||||||
|
|
@ -39,13 +39,14 @@ All six fields are required. Missing or empty fields invalidate the file.
|
||||||
|
|
||||||
### Fields
|
### Fields
|
||||||
|
|
||||||
**`bc-version`** — Array. The Business Central major versions this file applies to. Three forms are accepted:
|
**`bc-version`** — Array. The Business Central major versions this file applies to. Four forms are accepted:
|
||||||
|
|
||||||
- Universal sentinel: `[all]` means the guidance applies to every BC version and matches any target.
|
- Universal sentinel: `[all]` means the guidance applies to every BC version and matches any target.
|
||||||
- Explicit list: `[26, 27, 28]`.
|
- Explicit list: `[26, 27, 28]`.
|
||||||
- Range shorthand: `[26..28]` means every integer from 26 through 28 inclusive.
|
- Closed range shorthand: `[26..28]` means every integer from 26 through 28 inclusive.
|
||||||
|
- Open-ended range shorthand: `[26..]` means version 26 and every later version, with no upper bound. Use it for guidance tied to a feature introduced in a specific version that is not expected to be removed.
|
||||||
|
|
||||||
`[all]` is mutually exclusive with explicit versions; do not combine. Consumers MUST expand ranges to the full set before comparison.
|
`[all]` is mutually exclusive with explicit versions; do not combine. Consumers MUST expand closed ranges to the full set before comparison; an open-ended range `[N..]` is not enumerable and instead matches any target version greater than or equal to `N`.
|
||||||
|
|
||||||
**`domain`** — String. A single domain tag that places the file within a broader area of concern. Standard values include `performance`, `security`, `ux`, `telemetry`, `testing`, `api`, `pipelines`, `finance`, `supply-chain`, `manufacturing`, `jobs`. New domains may be introduced by contributors; no closed enumeration is enforced at the schema level. Consumers MUST treat unknown domains as valid.
|
**`domain`** — String. A single domain tag that places the file within a broader area of concern. Standard values include `performance`, `security`, `ux`, `telemetry`, `testing`, `api`, `pipelines`, `finance`, `supply-chain`, `manufacturing`, `jobs`. New domains may be introduced by contributors; no closed enumeration is enforced at the schema level. Consumers MUST treat unknown domains as valid.
|
||||||
|
|
||||||
|
|
@ -94,7 +95,7 @@ Conflict detection is the consumer's responsibility; BCQuality does not enforce
|
||||||
|
|
||||||
When a consumer filters or matches files against a task context, these rules apply:
|
When a consumer filters or matches files against a task context, these rules apply:
|
||||||
|
|
||||||
- **`bc-version`** — the file matches if its set is `[all]`, or if the target BC version is an element of the file's expanded `bc-version` set. Range shorthand (`[26..28]`) MUST be expanded before comparison.
|
- **`bc-version`** — the file matches if its set is `[all]`, or if the target BC version is an element of the file's expanded `bc-version` set. Closed range shorthand (`[26..28]`) MUST be expanded before comparison; an open-ended range (`[26..]`) matches when the target BC version is greater than or equal to its lower bound.
|
||||||
- **`technologies`** — non-empty intersection between the task's technologies and the file's technologies. There is no sentinel for this field.
|
- **`technologies`** — non-empty intersection between the task's technologies and the file's technologies. There is no sentinel for this field.
|
||||||
- **`countries`** — the file matches if its set contains `w1`, or if there is a non-empty intersection with the task's countries.
|
- **`countries`** — the file matches if its set contains `w1`, or if there is a non-empty intersection with the task's countries.
|
||||||
- **`application-area`** — the file matches if its set contains `all`, or if there is a non-empty intersection with the task's application areas.
|
- **`application-area`** — the file matches if its set contains `all`, or if there is a non-empty intersection with the task's application areas.
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ Knowledge files do not contain code. Samples live as **sibling files** next to t
|
||||||
|
|
||||||
## Choosing frontmatter values
|
## Choosing frontmatter values
|
||||||
|
|
||||||
**`bc-version`.** Default to `[all]` when the guidance is universal — a BC language pattern, a property on a long-standing platform type, a CodeCop rule, or a platform behaviour that has not changed across versions. Use an explicit list or range (`[26, 27, 28]`, `[26..28]`) only when the guidance is tied to a version-gated API, a deprecation, or platform behaviour that genuinely differs across versions. Most knowledge files should be `[all]`; reach for a range only with a concrete reason.
|
**`bc-version`.** Default to `[all]` when the guidance is universal — a BC language pattern, a property on a long-standing platform type, a CodeCop rule, or a platform behaviour that has not changed across versions. Use an explicit list or range (`[26, 27, 28]`, `[26..28]`) only when the guidance is tied to a version-gated API, a deprecation, or platform behaviour that genuinely differs across versions. When guidance applies to a feature introduced in version N and not expected to be removed, prefer the open-ended range `[N..]` over a closed range so the file keeps matching future versions — reserve a closed upper bound for guidance that genuinely stops applying (for example, a behaviour removed or replaced in a later version). Most knowledge files should be `[all]`; reach for a range only with a concrete reason.
|
||||||
|
|
||||||
**`domain`.** Pick one. If two fit, the file is probably two concerns. If no existing domain fits, introduce a new one — domains are open. Prefer existing domains when they are a reasonable fit, to keep retrieval predictable.
|
**`domain`.** Pick one. If two fit, the file is probably two concerns. If no existing domain fits, introduce a new one — domains are open. Prefer existing domains when they are a reasonable fit, to keep retrieval predictable.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue