Skip to content

fix(vault-sync): mirror post-approve WORKING/DRAFT artifacts (#583) - #586

Merged
plind-junior merged 6 commits into
vouchdev:testfrom
kurosawareiji7007-hub:fix/approve-promote-status
Jul 30, 2026
Merged

fix(vault-sync): mirror post-approve WORKING/DRAFT artifacts (#583)#586
plind-junior merged 6 commits into
vouchdev:testfrom
kurosawareiji7007-hub:fix/approve-promote-status

Conversation

@kurosawareiji7007-hub

@kurosawareiji7007-hub kurosawareiji7007-hub commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • pytest tests/test_vault_sync.py
  • CI green including trust-gate

Fixes #583

Summary by CodeRabbit

  • Bug Fixes
    • Vault synchronization now mirrors approved artifacts using post-approval defaults: WORKING claims and DRAFT pages.
    • ARCHIVED pages are no longer mirrored, and retracted claims remain excluded.
    • Stale mirror files are now removed when items are retracted or archived, preventing outdated content from lingering.
    • Sync results now explicitly report which mirrored pages and claims were removed.
  • Tests
    • Expanded backward-sync coverage for draft mirroring, approval behavior, mirror cleanup after retraction/archival, and preservation of untracked user files.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

kb_to_vault now mirrors durable WORKING claims and DRAFT pages, removes stale page and claim mirror files, and reports removed ids. Tests cover post-approval mirroring and archival/retraction cleanup, with the behavior documented in the changelog.

Changes

Approved artifact vault mirroring

Layer / File(s) Summary
Mirror live artifacts and remove stale files
src/vouch/vault_sync.py
VaultSyncResult records removed pages and claims; kb_to_vault reuses live artifact sets, deletes stale markdown files, and aggregates removal ids through sync_vault.
Validate approved mirroring and cleanup
tests/test_vault_sync.py, CHANGELOG.md
Tests cover draft-page mirroring, default post-approval statuses, cleanup after archival or retraction, and preservation of untracked files; the changelog records these rules.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant sync_vault
  participant kb_to_vault
  participant KBStore
  participant Vault
  sync_vault->>kb_to_vault: run backward synchronization
  kb_to_vault->>KBStore: collect live WORKING claims and DRAFT pages
  kb_to_vault->>Vault: write live page and claim mirrors
  kb_to_vault->>Vault: remove stale tracked mirrors
  kb_to_vault-->>sync_vault: return mirrored and removed ids
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: mirroring post-approve WORKING/DRAFT artifacts in vault sync.
Linked Issues check ✅ Passed The changes satisfy #583 by mirroring approved WORKING claims and DRAFT pages while excluding archived/retracted artifacts.
Out of Scope Changes check ✅ Passed The added cleanup, sync-state refresh, and regression tests all support the linked vault-sync fix and do not appear unrelated.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added docs documentation, specs, examples, and repo guidance storage kb storage, migrations, schemas, and proposals sync sync, vault mirror, and diff flows tests tests and fixtures size: S 50-199 changed non-doc lines labels Jul 29, 2026
@kurosawareiji7007-hub
kurosawareiji7007-hub force-pushed the fix/approve-promote-status branch from 04fb8f6 to 04b1fcb Compare July 29, 2026 12:55
@kurosawareiji7007-hub

Copy link
Copy Markdown
Contributor Author

rewrote commit history to remove the Co-authored-by: Cursor trailer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/vouch/proposals.py`:
- Around line 786-788: Lowercase ordinary prose in the comments at
src/vouch/proposals.py lines 786-788 and 816-817, preserving enum identifiers
such as WORKING, DRAFT, ACTIONABLE, and ACTIVE. At src/vouch/vault_sync.py lines
162-165, lowercase “Gate-approved” and replace “Obsidian” with lowercase prose
such as “vault”; make no code changes.

In `@src/vouch/vault_sync.py`:
- Around line 162-165: Update kb_to_vault() to remove existing vault mirror
files whose artifacts are absent from the current live set, including retracted
claims and archived pages, while preserving current writes for live artifacts.
Add a sync-after-retraction regression test covering removal of the stale
markdown file, and revise the nearby lifecycle comment so it does not imply
deletion already occurs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 861d0ed0-5815-4aac-967a-b8241765a65c

📥 Commits

Reviewing files that changed from the base of the PR and between 1fe8fb5 and 04b1fcb.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • src/vouch/proposals.py
  • src/vouch/vault_sync.py
  • tests/test_vault_sync.py

Comment thread src/vouch/proposals.py Outdated
Comment thread src/vouch/vault_sync.py Outdated
kurosawareiji7007-hub added a commit to kurosawareiji7007-hub/vouch that referenced this pull request Jul 29, 2026
address coderabbit on vouchdev#586: lowercase comment prose, exclude archived
pages from the live vault set, and remove leftover claim/page markdown
when artifacts leave that set.
@kurosawareiji7007-hub

Copy link
Copy Markdown
Contributor Author

addressed coderabbit:

  • lowercase comment prose (enum ids kept uppercase)
  • kb_to_vault deletes claim/page mirrors that left the live set (retracted / archived), with regression coverage
  • no cursor trailer

ready for re-review.

kurosawareiji7007-hub added a commit to kurosawareiji7007-hub/vouch that referenced this pull request Jul 29, 2026
address coderabbit on vouchdev#586: lowercase comment prose, exclude archived
pages from the live vault set, and remove leftover claim/page markdown
when artifacts leave that set.
@kurosawareiji7007-hub
kurosawareiji7007-hub force-pushed the fix/approve-promote-status branch from 1b8fc91 to 9dfad06 Compare July 29, 2026 16:37
@kurosawareiji7007-hub kurosawareiji7007-hub changed the title fix(proposals): promote claim/page status on approve fix(vault-sync): mirror post-approve WORKING claims (#583) Jul 29, 2026
kurosawareiji7007-hub added a commit to kurosawareiji7007-hub/vouch that referenced this pull request Jul 29, 2026
address coderabbit on vouchdev#586: lowercase comment prose, exclude archived
pages from the live vault set, and remove leftover claim/page markdown
when artifacts leave that set.
@kurosawareiji7007-hub
kurosawareiji7007-hub force-pushed the fix/approve-promote-status branch 4 times, most recently from a2cc000 to acd7b96 Compare July 29, 2026 17:52
@kurosawareiji7007-hub kurosawareiji7007-hub changed the title fix(vault-sync): mirror post-approve WORKING claims (#583) fix(vault-sync): mirror post-approve WORKING/DRAFT artifacts (#583) Jul 29, 2026
…v#583)


kb_to_vault skipped durable WORKING claims and DRAFT pages (the normal
propose+approve defaults), so Obsidian looked empty until statuses were
hand-edited. include those statuses in the live vault set, exclude
ARCHIVED/retracted, and delete stale mirrors.

vault-sync only - avoids core proposals.py so trust-gate can pass.

Fixes vouchdev#583
@github-actions github-actions Bot removed the storage kb storage, migrations, schemas, and proposals label Jul 29, 2026
@kurosawareiji7007-hub
kurosawareiji7007-hub force-pushed the fix/approve-promote-status branch from acd7b96 to ce9a1d8 Compare July 29, 2026 17:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_vault_sync.py`:
- Around line 154-157: Complete the VaultSyncResult partition assertions in
tests/test_vault_sync.py: at lines 154-157, assert that "obsidian-status" is in
result.claims_mirrored; at lines 178-182, assert that "alpha-claim" is absent
from result.claims_mirrored and "alpha-page" is absent from
result.pages_mirrored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7fc15ff8-2516-441c-af3c-53c3f43793c2

📥 Commits

Reviewing files that changed from the base of the PR and between a2cc000 and 5f35618.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/vouch/vault_sync.py
  • tests/test_vault_sync.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/vouch/vault_sync.py

Comment thread tests/test_vault_sync.py
address coderabbit on vouchdev#586: assert claims_mirrored for the approve path
and assert retracted artifacts are absent from mirrored partitions.
also lowercase vault_sync comment prose.
@kurosawareiji7007-hub

Copy link
Copy Markdown
Contributor Author

addressed coderabbit:

  • assert obsidian-status in result.claims_mirrored on the approve path
  • assert retracted alpha-claim / alpha-page are absent from mirrored partitions after removal
  • lowercase vault_sync comment prose

ready for re-review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/vouch/vault_sync.py (1)

269-280: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

do not delete untracked markdown files

this loop deletes every *.md file whose stem is outside the live-id set, including files that were never created by the mirror. however, vault_to_kb() explicitly treats files absent from sync state as arbitrary user files and skips them (src/vouch/vault_sync.py lines 335-344). a user-created pages/*.md or claims/*.md file can therefore be silently deleted on the next backward sync. restrict deletion to files known to be mirror-owned, such as paths recorded in sync state, and preserve untracked files.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/vouch/vault_sync.py` around lines 269 - 280, Update the mirror cleanup
loops in the backward-sync flow to delete only markdown paths recorded as
mirror-owned in sync state, rather than every file whose stem is absent from the
live ID sets. Preserve untracked user files in both mirror and claims_out, while
continuing to append removed owned page and claim IDs to the sync result.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/vouch/vault_sync.py`:
- Around line 269-280: Update the mirror cleanup loops in the backward-sync flow
to delete only markdown paths recorded as mirror-owned in sync state, rather
than every file whose stem is absent from the live ID sets. Preserve untracked
user files in both mirror and claims_out, while continuing to append removed
owned page and claim IDs to the sync result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ba767a24-a675-48d7-b62d-f3a98f70196f

📥 Commits

Reviewing files that changed from the base of the PR and between 5f35618 and 941688d.

📒 Files selected for processing (2)
  • src/vouch/vault_sync.py
  • tests/test_vault_sync.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_vault_sync.py

address coderabbit on vouchdev#586: kb_to_vault cleanup must not unlink
untracked user markdown under vouch/pages or vouch/claims. delete only
paths recorded in sync state that left the live set, and keep those
user files out of the refreshed state.
@kurosawareiji7007-hub

Copy link
Copy Markdown
Contributor Author

addressed coderabbit follow-up:

  • stale cleanup now deletes only mirror-owned paths recorded in .sync-state.json
  • untracked user markdown under vouch/pages / vouch/claims is preserved
  • sync state refresh no longer absorbs those untracked files
  • added test_kb_to_vault_preserves_untracked_user_files

ready for re-review.

@plind-junior
plind-junior merged commit 647c34d into vouchdev:test Jul 30, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs documentation, specs, examples, and repo guidance size: S 50-199 changed non-doc lines sync sync, vault mirror, and diff flows tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants