Problem
The citation-manager extract links command reports links as failed with "Heading not found" even though the same links are validated as valid by both the internal validation phase and the validate command. This creates contradictory status messages that confuse users.
Reproduction Steps
- Run extract links on a file with heading-anchored citations:
citation-manager extract links tools/citation-manager/design-docs/features/20251119-type-contract-restoration/ROLLBACK-PLAN.md
- Observe contradictory output for link on line 329:
[Level 3: Components](../../ARCHITECTURE-Citation-Manager.md#Level%203%20Components)
{
"sourceLink": {
"text": "Level 3: Components",
"validation": {
"status": "valid"
}
},
"status": "failed",
"failureDetails": {
"reason": "Heading not found: Level 3 Components"
}
}
- Confirm validation command says link is valid:
citation-manager validate tools/citation-manager/design-docs/features/20251119-type-contract-restoration/ROLLBACK-PLAN.md --lines 329-329
# Output: VALID CITATIONS (1)
- Confirm heading exists in target file:
grep -n "^## Level 3: Components" tools/citation-manager/design-docs/ARCHITECTURE-Citation-Manager.md
# Output: 79:## Level 3: Components
Root Cause
ContentExtractor uses different heading resolution logic than CitationValidator, causing inconsistent results. Possible issues:
- URL encoding handling (
Level%203%20Components vs Level 3 Components)
- Case sensitivity differences
- Whitespace normalization differences
- Different anchor matching algorithms
Expected Behavior
If validation.status is "valid", the extraction should either:
- Succeed in extracting content from the valid heading, OR
- Report a different, accurate error (not "heading not found" for a heading that exists)
Related
Acceptance Criteria
Definition of Done
Problem
The
citation-manager extract linkscommand reports links asfailedwith "Heading not found" even though the same links are validated asvalidby both the internal validation phase and thevalidatecommand. This creates contradictory status messages that confuse users.Reproduction Steps
{ "sourceLink": { "text": "Level 3: Components", "validation": { "status": "valid" } }, "status": "failed", "failureDetails": { "reason": "Heading not found: Level 3 Components" } }citation-manager validate tools/citation-manager/design-docs/features/20251119-type-contract-restoration/ROLLBACK-PLAN.md --lines 329-329 # Output: VALID CITATIONS (1)Root Cause
ContentExtractor uses different heading resolution logic than CitationValidator, causing inconsistent results. Possible issues:
Level%203%20ComponentsvsLevel 3 Components)Expected Behavior
If
validation.statusis "valid", the extraction should either:Related
Acceptance Criteria
extract linksreturnsstatus: "success"for citations thatvalidatereports as validLevel%203%20Components→Level 3: Components)## Level 3: Components)validation.statusand extractionstatusDefinition of Done
npm run build -w tools/citation-manager && npm link -w tools/citation-managerstatus: "success"for the test link