Repository navigation
feat(validate): let a rule acknowledge a trap notice by id - #723
Conversation
Each ast-grep trap notice gets a stable id, and a rule listing one under metadata.taskless.acknowledge stops drawing it. validate/verify --json report silenced notices under an always-present acknowledged array.
|
@claude /review |
|
Claude finished @aibex-agent[bot]'s task in 2m 57s —— View job Review completeReview mode: incremental — read 0 prior review thread(s) before reviewing.
SummaryThe implementation is clean and the wiring is complete: [New] One gap, posted inline on No other correctness, security, or test-adequacy issues found. The docs ( |
| } { | ||
| const ids = new Set<string>(); | ||
| const taskless = field(field(rule, "metadata"), "taskless"); | ||
| if (taskless === undefined || !("acknowledge" in taskless)) { |
There was a problem hiding this comment.
[New] readAcknowledgements only validates the shape of metadata.taskless.acknowledge itself (not-a-list-of-strings → a notice naming the known ids). It doesn't validate the shape of metadata.taskless one level up. If an author nests the id wrong — metadata: { taskless: ["awaited-generic-callee"] } or metadata: { taskless: "awaited-generic-callee" }, putting the id where acknowledge should sit — field(metadataObj, "taskless") returns undefined (line 141-144: non-object/array values return undefined), so this function takes the early return at line 110-112 and reports { ids: empty, notices: [] }. The trap keeps firing exactly as if nothing were declared, and — unlike an unknown id or a malformed acknowledge list — the author gets no notice telling them the acknowledgement did nothing.
That's the one authoring mistake this feature is most exposed to (three levels of nesting, taskless.acknowledge rather than taskless itself), and it's the one case D5 and the existing "unknown id" / "not a list" notices don't cover. Worth a third notice branch here: when metadata.taskless exists but isn't an object (or has no acknowledge key but isn't empty-object either), say so, the same way a bad acknowledge value does.
Not covered by any of the new tests either — sg-traps.test.ts's "ignores metadata that says nothing about Taskless" case uses metadata: { owner: "payments" } (no taskless key at all), not a malformed taskless value.
There was a problem hiding this comment.
Fixed in feb7a28. A metadata.taskless that is present but holds no acknowledge list (a list, a string, or an object missing the key) now draws a notice showing the right nesting and the known ids. Tests cover all three shapes, and the spec sentence now includes the case.
validatereports the ast-grep authoring traps as notices, but they are structural: the awaited-generic callee notice fires on every TypeScript calleeregexunderfield: functionwith noawait_expressionbranch, whether or not the code base ever writesawait fn<T>(). Nothing in a rule could record that the author had checked, so the notice repeated on every run. Two PMF survey runs reported it as noise.Narrowing the heuristic is not sound (
await api.get<Foo>()is a member callee too), so this lets the author say so instead.What changes
ellipsis-before-comma,comma-before-ellipsis,sibling-without-stopby,descent-without-stopby,awaited-generic-callee. The two$$$forms and the twostopByforms get separate ids because they are separate decisions with separate remedies.metadatais ast-grep's free-form field, so the rule still passes the vendored schema and ast-grep's own parse. Confirmed end to end withvalidate,verifyandcheck.validateandverifyskip an acknowledged notice and still print every other one. Acknowledgement is per rule and per id. It is not keyed to a relation's path, because that path shifts whenever a branch is added.--jsongains an always-presentacknowledged: [{ id, notice }]per rule, so an agent can tell a silenced notice from one that never fired.create-sg-rule(topic v19) documents the ids next to the Quirks table and prefers the in-rule spelling where one exists (stopBy: neighbor,strictness: ast).validate-rule(topic v13) documentsacknowledged.Why the rule file and not a sidecar or a comment:
.taskless/rule-metadata/has never been written by anything (seeagent rule-meta). The YAML parservalidateuses drops comments, so a comment would need a second parse and would not survive tools that rewrite the rule. The design is inopenspec/changes/archive/2026-11-29-acknowledge-sg-trap-notices/design.md.Checks
pnpm typecheck,pnpm lint, andpnpm testpass (3426 tests). New unit cases cover acknowledgement, isolation between traps, and unknown or malformed ids. A new end-to-endvalidate --jsoncase runs the issue's reproduction rule with and without the acknowledgement. The OpenSpec change is archived andcli-rule-validationkeeps every prior scenario (67 → 71).Fixes #713