citation-backfill
Rebuild bidirectional citation edges in a research corpus. Scans outgoing citations, computes the inverse map, rewrites incoming tables. Fixes one-directional graphs.
What this skill does
# Citation Backfill Rebuild bidirectional citation edges across the entire research corpus. After batch inductions or outgoing citation table updates, incoming citation tables across the corpus become stale. This command computes the inverse citation map and rewrites all incoming tables to match. ## Triggers - "backfill citations" - "rebuild citation edges" - "fix incoming citations" - "propagate citation edges" - "citation backfill" - `/citation-backfill` ## Parameters ### `--dry-run` (optional) Report what would change without writing any files. ### `--scope REF-XXX` (optional) Only propagate edges from a specific paper. Useful after inducting a single new source. ### `--format` (optional) Output format: `full` (default), `summary`, or `json`. ## Execution Flow ### Phase 1: Scan Outgoing Edges 1. **Glob** all citation sidecar files: - `.aiwg/research/citations/REF-*.yaml` (if YAML sidecars exist) - `.aiwg/research/findings/REF-*.md` — scan "Outgoing Citations" / "References" / "Cites" sections - `.aiwg/research/documentation/citations/REF-*.md` — scan citation tables 2. **Extract outgoing edges** from each source: ``` REF-016 → cites → [REF-018, REF-024, REF-121] REF-018 → cites → [REF-016, REF-024] REF-024 → cites → [REF-016] ``` 3. **Build the outgoing map**: `Map<source, Set<target>>` ### Phase 2: Compute Inverse Map Invert the outgoing map to produce the incoming map: ``` REF-016 ← cited-by ← [REF-018, REF-024] REF-018 ← cited-by ← [REF-016] REF-024 ← cited-by ← [REF-016, REF-018] REF-121 ← cited-by ← [REF-016] ``` Result: `Map<target, Set<source>>` ### Phase 3: Diff Against Current State For each target in the incoming map: 1. Read the current "Incoming Citations" / "Cited By" section 2. Parse existing incoming edges 3. Compute the diff: edges to add, edges to remove (if source was deleted) ### Phase 4: Write Updates For each target with changes: 1. Rewrite the "Incoming Citations" section with the computed set 2. Sort entries by REF number for stable output 3. Preserve any manually-added annotations (relationship type, notes) If `--dry-run`: report changes without writing. ### Phase 5: Report ``` Citation Backfill Complete ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Sources scanned: 372 Outgoing edges found: 1,247 Incoming edges computed: 1,247 Sidecars updated: 89 New edges propagated: 134 Stale edges removed: 3 Targets not found: 2 (REF-999, REF-888 — referenced but no note exists) Updated files: documentation/citations/REF-016.md (+3 incoming) documentation/citations/REF-018.md (+1 incoming) documentation/citations/REF-024.md (+2 incoming) ... ``` ## Edge Detection Patterns The backfill command recognizes citations in these formats: | Pattern | Example | Context | |---------|---------|---------| | Table row | `\| REF-016 \| Title \| relationship \|` | Citation sidecar tables | | Inline reference | `REF-016` in body text | Finding doc body | | YAML list | `- REF-016` under `outgoing:` or `cites:` | Citation YAML sidecars | | Markdown link | `[REF-016](../findings/REF-016.md)` | Cross-reference links | | Frontmatter | `related_refs: [REF-016, REF-018]` | YAML frontmatter | ## Integration Points | Component | Relationship | |-----------|-------------| | `induct-research` | Should auto-run backfill after batch induction (Phase 3.5) | | `address-issues` | Should auto-run when citation sidecars are modified | | `research-lint` | `cross-ref-bidirectional` rule validates what backfill fixes | | `corpus-health` | Reports citation completeness as a health metric | | `research-gap-detect` | Uses the completed graph for cluster analysis | ## Auto-Integration Hooks When called from other skills: ```yaml # After induct-research batch: post-induction: - /citation-backfill --scope <newly-inducted-refs> # After address-issues modifies citations: post-issue-resolution: - /citation-backfill --dry-run - # If changes detected, prompt user to run full backfill ``` ## Examples ```bash # Full corpus backfill /citation-backfill # Preview what would change /citation-backfill --dry-run # Backfill only edges from a specific paper /citation-backfill --scope REF-364 # JSON output for programmatic use /citation-backfill --format json ``` ## Deterministic implementation (`aiwg corpus`) For corpora laid out as `documentation/citations/REF-*-citations.md`, a TS-native implementation runs the inverse-map backfill deterministically — prefer it over hand-walking the tables: ```bash aiwg corpus citation-backfill # dry-run: missing incoming edges + dangling targets aiwg corpus citation-backfill --write # inject the missing incoming rows ``` It is paired with **`extract-crossrefs`**, which densifies the *outgoing* side — analysis docs often list peer REFs in a "Cross-References" / "Related Work" / "Referenced By" section that never made it into the formal Outgoing table: ```bash aiwg corpus extract-crossrefs # dry-run: cross-ref REFs (with sidecars) missing from Outgoing aiwg corpus extract-crossrefs --write # inject them as outgoing edges aiwg corpus extract-crossrefs --refs REF-056,REF-061 # restrict to specific sources ``` Run `extract-crossrefs` first (it adds outgoing edges), then `citation-backfill` (it mirrors them to incoming). Both default to dry-run. This skill orchestrates; the CLI executes. See the `sidecar-lint` skill for sidecar structural hygiene. ## References - @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/induct-research/SKILL.md — Triggers backfill post-induction - @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/research-lint/SKILL.md — Validates bidirectional edges - @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/sidecar-lint/SKILL.md — Sidecar structural lint + repair - @$AIWG_ROOT/agentic/code/frameworks/research-complete/lint/cross-ref-bidirectional.yaml — Lint rule for edge validation - @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/research-status/SKILL.md — Health scoring includes citation completeness - @$AIWG_ROOT/src/artifacts/corpus-tools/citation-densify.ts — extract-crossrefs + citation-backfill (deterministic)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.