← Back to Pull requests

fix(sync): preserve frontmatter when adding permalink #2126

Closed
unknown closed this pull request without merging on Nov 19, 2026 07:36 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 07:20 UTC
Author

What changed

  • Add a helper that inserts a missing frontmatter field before the closing fence without re-serializing existing YAML or changing the note body.

  • Use it when a canonical permalink is absent. Existing permalink updates keep their current behavior.

  • Route missing-field updates in FileService.update_frontmatter_with_result through the same helper, so forced reindexing also preserves existing YAML and body content.

  • Cover flow-style YAML, quoting, CRLF, trailing newlines, notes without frontmatter, and the real move-preparation path.

  • After review, handle top-level flow mappings and a BOM followed by a blank line as well.
  • Fixes #2125.

    Validation

  • The new move-preparation test fails with the base src/ changes stashed and passes with the fix.

  • The new file-service regression fails on the old rewrite path and passes with the missing-field path.

  • pytest tests/services/test_file_service.py tests/utils/test_file_utils.py tests/services/test_entity_service_prepare.py test-int/test_mandatory_permalinks_integration.py -q: 141 passed.

  • The original bm reset --reindex repro now changes only the permalink: repro/note line and preserves the trailing newline.

  • Ruff format/check: passed on all changed files.

  • uv run --extra milvus ty check src tests test-int: passed.

  • Sandboxed doctor --local: passed.

  • A full unit-suite run was attempted earlier. It hits the existing timezone-sensitive test_import_chatgpt assertion (expected date 20250111, actual 20250112), which is unrelated to these changes.
  • AI assistance: Kimi Code helped with the implementation and local validation.

    Diff: 204 lines (+153 / -51) across 2 files Reviewer: tonydzi Review duration: 2895m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 204 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.318
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2126"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.3% (MEDIUM) · Higher = larger blast radius
    36.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.3% · Safe to merge
    14.3%