knowns icon indicating copy to clipboard operation
knowns copied to clipboard

[Bug]: False-positive BROKEN_DOC_REF when @doc refs have trailing punctuation or appear in Markdown links

Open HarryVu176 opened this issue 6 months ago • 1 comments

Bug Description

Knowns validation reports `BROKEN_DOC_REF` for valid docs when the `@doc/...` reference is followed by punctuation or appears inside Markdown link syntax.

The referenced docs exist, but the parser appears to include extra Markdown/punctuation characters in the parsed doc path. This creates noisy false positives and makes it harder to distinguish real stale refs from parser issues.

Steps to Reproduce

1. Create or update a Knowns doc/memory with a valid doc ref followed by punctuation:
     `@doc/specs/meal-menu-class-targeting:`
2. Run Knowns validation.
3. Observe that validation reports a broken doc ref for:
     `@doc/specs/meal-menu-class-targeting:`
4. Also test a Markdown-wrapped ref:
     `[@doc/patterns/entity-pattern](patterns/entity-pattern)`
5. Run validation again.
6. Observe that validation reports a broken doc ref similar to:
     `@doc/patterns/entity-pattern](patterns/entity-pattern`

Expected Behavior

Knowns should resolve the valid doc path only.
For:
`@doc/specs/meal-menu-class-targeting:`
Expected parsed path:
`specs/meal-menu-class-targeting`
The trailing colon should be treated as prose punctuation, not part of the path.
For:
`[@doc/patterns/entity-pattern](patterns/entity-pattern)`
Expected parsed path:
`patterns/entity-pattern`
or the Markdown link text should be ignored, depending on intended behavior. It should not include `](patterns/entity-pattern` in the doc path.

Actual Behavior

Knowns validation reports false-positive `BROKEN_DOC_REF` items.
Examples:
`@doc/specs/meal-menu-class-targeting:` is treated as missing, even though `@doc/specs/meal-menu-class-targeting` exists.
`[@doc/patterns/entity-pattern](patterns/entity-pattern)` is parsed as something like:
`@doc/patterns/entity-pattern](patterns/entity-pattern`
and reported as missing.

Suspected cause: the ref parser scans raw Markdown greedily from `@doc/` instead of using a bounded ref grammar or Markdown-aware parsing.

Knowns CLI Version

0.23.0

Operating System

Windows

Node.js Version

No response

Error Logs


Additional Context

No response

HarryVu176 avatar Jun 04 '26 01:06 HarryVu176

Thanks for report issue

howznguyen avatar Jun 04 '26 02:06 howznguyen