feat(s3): evaluate requiredCategories (spec v0.4 §4.3) — 0.2.2 - #52
Merged
Conversation
The category-OR the T1 Build evidence demanded: for every node matching the rule's component, each requiredCategories entry must have >= min descendants belonging to the category, membership resolved through the contract's categories declarations exactly like forbiddenCategories, LOCAL to the matching node's descendants — a member elsewhere in the surface satisfies nothing, and the finding message says so explicitly. Ten ratified pins in required-categories.test.ts: text-only form-control FAILs carrying the owner-approved rationale verbatim; empty FAILs; input / textarea / select each PASS; locality (interactive elsewhere does not satisfy); min 2 with one found FAILs naming both numbers; multiple entries keep AND semantics; requiredSubComponents unchanged; forbidden-composition unchanged alongside. 129/129 green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds S3 lint support for the spec v0.4 §4.3 requiredCategories extension on required-composition rules, along with a dedicated test suite and a version bump to 0.2.2.
Changes:
- Extend
RequiredCompositionRulewithrequiredCategories?: { id, min? }[]and implement evaluation viacategoryIndex(contract)scoped to each matching node’s descendants. - Add 10 “ratified pin” tests validating failure/pass/locality/min/AND semantics and rationale propagation.
- Bump package version to
0.2.2.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/core/lint/rules.ts | Implements requiredCategories evaluation for required-composition using contract category membership. |
| src/core/lint/required-categories.test.ts | Adds a comprehensive vitest suite covering the new rule behavior and invariants. |
| src/core/contract.ts | Extends the contract rule interface with the new requiredCategories field and semantics documentation. |
| package.json | Version bump to 0.2.2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+128
to
+141
| for (const requirement of rule.requiredCategories ?? []) { | ||
| const min = requirement.min ?? 1; | ||
| const found = descendants.filter((d) => (categories!.get(d.node.component) ?? []).includes(requirement.id)).length; | ||
| if (found < min) { | ||
| findings.push( | ||
| finding( | ||
| rule, | ||
| `Required category '${requirement.id}' (min ${min}) not found among descendants (found ${found}) — no descendant of this node is a '${requirement.id}' member; members elsewhere in the surface do not satisfy this rule.`, | ||
| locationOf(visited), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
Comment on lines
+96
to
+102
| /** | ||
| * spec v0.4 §4.3 (2026-08-07 amendment, lifted from the §6 ceiling on the | ||
| * T1 Build evidence): categories from which at least `min` descendants must | ||
| * appear beneath each matching node. AND across entries, OR within a | ||
| * category's membership; LOCAL to the matching node's descendants. | ||
| */ | ||
| requiredCategories?: Array<{ id: string; min?: number }>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
S3 support for the dspack#36 rule-language amendment, driven by the T1 Build evidence (zero-control forms passing every gate).
RequiredCompositionRulegainsrequiredCategories?: {id, min?}[]; the evaluator resolves membership through the existingcategoryIndex, local to each matching node's descendants — an interactive member elsewhere in the surface satisfies nothing, and the finding message states that explicitly for actionable repair feedback.required-categories.test.ts): text-only FAIL, empty FAIL, input/textarea/select PASS, locality FAIL,min: 2FAIL naming counts, AND across entries,requiredSubComponentsunchanged,forbiddenCategoriesunchanged.🤖 Generated with Claude Code