-
Notifications
You must be signed in to change notification settings - Fork 1
review: add the per-lens consumer payload seam #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| "review": minor | ||
| --- | ||
|
|
||
| Add the per-lens consumer payload seam. A consuming repo may now define | ||
| `.github/aw/review/lenses/<lens>.md` for any of the eleven specialist lenses, plus | ||
| `lenses/correctness.md` for the always-on `correctness-reviewer`; each file is | ||
| runtime-imported (optional form) into a new "Repo-specific rules and hunts" section | ||
| of the matching reviewer prompt, carrying that repo's surface-specific rules and | ||
| extra tri-state hunts. Lens names stay generic and shared; only payloads vary per | ||
| repo. Behavior-neutral for every current consumer: no consumer carries a payload | ||
| file yet, and a missing optional import inlines nothing at runtime. | ||
| `correctness-checks.md` remains imported as a deprecated alias for | ||
| `lenses/correctness.md` (frontend carries one today); repos should migrate the file | ||
| and carry at most one of the two, and the alias is removed in the next major | ||
| release. Payloads are additive by contract: the lens prompts state that payload | ||
| rules never relax or override the shared rules, which win on any conflict. The | ||
| router now warns (through `routingConfig.warnings`, surfaced in the review body's | ||
| note lines) when a payload would be silently inert: a filename matching no imported | ||
| payload, a specialist payload no ROUTING rule routes, or the correctness alias | ||
| carried alongside its replacement. The eval's import resolution now matches | ||
| production for the optional form (missing resolves to empty, not the "(not | ||
| configured for this eval case)" note), so corpus case trees can carry payloads; the | ||
| required-form fallback note is unchanged. README documents the new surface and the | ||
| three-way contribution rule (shared skeleton vs lens payload vs skills) and fixes | ||
| two stale claims in the consumer-config section (the undocumented | ||
| `correctness-checks.md`, and the assertion that the optional import form was | ||
| dropped). |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import {describe, it, expect} from "vitest"; | ||
|
|
||
| import { | ||
| CORRECTNESS_ALIAS_PATH, | ||
| LENS_PAYLOAD_DIR, | ||
| lensPayloadWarnings, | ||
| } from "./lens-payloads.ts"; | ||
| import {SPECIALIST_LENSES} from "./router.ts"; | ||
| import type {Lens} from "./finding-schema.ts"; | ||
| import type {LensRule} from "./routing-config.ts"; | ||
|
|
||
| /** | ||
| * Lens-payload validation tests. The failure mode under test is silence: a | ||
| * payload file that nothing imports (typo, unknown name) or that an imported | ||
| * lens never reads (no ROUTING rule spawns it) is invisible at runtime, so | ||
| * the only surface where the author learns about it is these warnings. The | ||
| * CLI wiring (readdir + append to routingConfig.warnings) is pinned in | ||
| * router.test.ts. | ||
| */ | ||
|
|
||
| const routed = (lens: Lens): LensRule[] => [ | ||
| {pattern: "src/**", lenses: [lens]}, | ||
| ]; | ||
|
|
||
| const warningsFor = ( | ||
| payloadFiles: readonly string[], | ||
| lensRules: readonly LensRule[] = [], | ||
| aliasPresent = false, | ||
| ): string[] => | ||
| lensPayloadWarnings( | ||
| payloadFiles, | ||
| lensRules, | ||
| aliasPresent, | ||
| SPECIALIST_LENSES, | ||
| ); | ||
|
|
||
| describe("lensPayloadWarnings", () => { | ||
| it("is silent for a routed specialist payload and correctness.md", () => { | ||
| expect( | ||
| warningsFor( | ||
| ["security-auth.md", "correctness.md"], | ||
| routed("security-auth"), | ||
| ), | ||
| ).toEqual([]); | ||
| }); | ||
|
|
||
| it("warns on a filename matching no imported payload", () => { | ||
| const warnings = warningsFor( | ||
| ["security_auth.md", "README.md", "notes.txt"], | ||
| routed("security-auth"), | ||
| ); | ||
| expect(warnings).toHaveLength(3); | ||
| for (const warning of warnings) { | ||
| expect(warning).toContain("matches no imported payload"); | ||
| } | ||
| expect(warnings[0]).toContain(`${LENS_PAYLOAD_DIR}/security_auth.md`); | ||
| }); | ||
|
|
||
| it("warns on a specialist payload no ROUTING rule routes", () => { | ||
| const warnings = warningsFor( | ||
| ["money-payments.md"], | ||
| routed("security-auth"), | ||
| ); | ||
| expect(warnings).toHaveLength(1); | ||
| expect(warnings[0]).toContain("lens=money-payments"); | ||
| expect(warnings[0]).toContain("inert"); | ||
| }); | ||
|
|
||
| it("never flags correctness.md as unrouted (always-on reviewer)", () => { | ||
| expect(warningsFor(["correctness.md"])).toEqual([]); | ||
| }); | ||
|
|
||
| it("warns when correctness.md and its deprecated alias coexist", () => { | ||
| const warnings = warningsFor(["correctness.md"], [], true); | ||
| expect(warnings).toHaveLength(1); | ||
| expect(warnings[0]).toContain(CORRECTNESS_ALIAS_PATH); | ||
| }); | ||
|
|
||
| it("stays silent on the alias alone (supported during migration)", () => { | ||
| expect(warningsFor([], [], true)).toEqual([]); | ||
| }); | ||
|
|
||
| it("accepts every specialist lens name as a payload filename", () => { | ||
| for (const lens of SPECIALIST_LENSES) { | ||
| expect(warningsFor([`${lens}.md`], routed(lens))).toEqual([]); | ||
| } | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.