@gurupanguji

Source Citation Rendering Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Replace the risky raw markdown blockquote plus Source: pattern with a markdown-only standalone source-link shape across the safe archive set, then block the old pattern from being added again.

Architecture: Add one narrow normalizer that rewrites only the safe markdown quote-source shape into the canonical [Source: ...](...) form, and also repairs any temporary gp-quote HTML introduced during remediation. Extend the post validator so future content cannot rely on Kramdown’s accidental citation folding or drift back to HTML quote markup.

Tech Stack: Python 3, unittest, regex/string parsing, Jekyll markdown content, existing repository validators


Task 1: Add Failing Tests For Safe Source-Citation Conversion

Files:

Assert that:

> Quoted text.

Source: [Example Story](https://example.com/story)

becomes:

> Quoted text.

[Source: Example Story](https://example.com/story)

Assert that multiple markdown quote paragraphs remain blockquote paragraphs and the source becomes the standalone markdown link line.

Run: python3 -m unittest tests/test_normalize_source_citations.py Expected: FAIL because the normalizer does not exist yet

Task 2: Implement The Minimal Safe Source-Citation Normalizer

Files:

Keep YAML front matter unchanged and operate only on the markdown body.

Match only:

Output:

Run: python3 -m unittest tests/test_normalize_source_citations.py Expected: PASS for the safe conversion cases

Task 3: Add Failing Tests For Skip Cases And CLI Behavior

Files:

Use a quote followed by Source: text that is not a valid markdown link and assert the file is skipped.

Use one quote block with two adjacent Source: lines and assert the normalizer skips it as ambiguous.

Use a temporary gp-quote HTML block and assert the normalizer converts it back into the markdown-only canonical shape.

Assert that default execution reports pending rewrites without modifying files, and --write updates safe files in place.

Run: python3 -m unittest tests/test_normalize_source_citations.py Expected: FAIL until skip logic and CLI behavior are implemented

Task 4: Implement Skip Reporting And CLI

Files:

Track:

Default to reporting only. Require --write to edit files.

Support one or more explicit post paths so individual files can be tested before a full run.

Run: python3 -m unittest tests/test_normalize_source_citations.py Expected: PASS

Task 5: Add The Validator Guardrail

Files:

Cover:

Flag only the precise unsafe shape that triggers accidental Kramdown cite generation.

Apply the guardrail only to posts on or after the new policy date so the historical archive can be cleaned in a controlled pass.

Run: python3 -m unittest tests/test_validate_posts.py Expected: PASS

Task 6: Audit The Real Candidate Set Before Writing

Files:

Run: python3 scripts/normalize_source_citations.py Expected:

Open:

If the script is matching noisy shapes, tighten the matcher before writing changes.

Task 7: Apply The Bulk Archive Cleanup

Files:

Run: python3 scripts/normalize_source_citations.py --write Expected:

Run: git diff --stat Expected: spec, plan, new script/tests, validator/layout changes, and the converted posts

Check that:

Task 8: Verify Repository Compatibility

Files:

Run:

python3 -m unittest \
  tests/test_normalize_source_citations.py \
  tests/test_validate_posts.py

Expected: PASS

Run: python3 scripts/validate_posts.py --today 2026-03-27 Expected: PASS

Inspect the two issue posts plus one older converted sample and confirm the canonical markdown shape is present.

Task 9: Commit, Push, And Open The PR

Files:

Confirm only intended files changed.

Run:

git add docs/superpowers/specs/2026-03-27-source-citation-rendering-design.md \
        docs/superpowers/plans/2026-03-27-source-citation-rendering-implementation-plan.md \
        scripts/normalize_source_citations.py \
        scripts/validate_posts.py \
        tests/test_normalize_source_citations.py \
        tests/test_validate_posts.py \
        _layouts/post.html \
        _posts
git commit -m "fix: normalize source citations in quoted link posts"

Run:

git push -u origin fix/source-citation-rendering
gh pr create --fill

Expected: branch is pushed and PR is open for review