Skip to content

fix(vault): slug_hint, ghost-page guard, dedup proposals, warn on claim stub edits#220

Open
Tet-9 wants to merge 2 commits into
vouchdev:testfrom
Tet-9:fix/219-vault-to-kb-slug-and-guards
Open

fix(vault): slug_hint, ghost-page guard, dedup proposals, warn on claim stub edits#220
Tet-9 wants to merge 2 commits into
vouchdev:testfrom
Tet-9:fix/219-vault-to-kb-slug-and-guards

Conversation

@Tet-9

@Tet-9 Tet-9 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #219

What

vault_to_kb had four related bugs in the forward sync path:

1. Wrong proposal id (slug instead of page id)
propose_page was called without slug_hint, so the proposal id was
derived from _slugify(edited.title) instead of the page id from
frontmatter. A page with id auth-decision-001 and title "Auth Decision"
would produce a proposal for a new page auth-decision, silently
duplicating the KB entry on approve instead of updating it.
Fix: pass slug_hint=page_id to propose_page.

2. Ghost page proposals
If a page was deleted from the KB after the last backward sync, the mirror
file still exists in the vault. vault_to_kb would file a proposal for the
deleted page, which would fail on approve with an unresolvable artifact id.
Fix: call store.get_page(page_id) before filing; skip with a warning if
the page no longer exists.

3. Duplicate proposals on repeated runs
Running vault_to_kb twice before the first proposal is approved filed two
proposals for the same page edit. The second approve would then fail with
"page already exists".
Fix: added _has_pending_page_proposal helper that checks pending proposals
before filing; skips if one already targets the same page id.

4. Silent drop on claim stub edits
kb_to_vault writes claim stubs under <vault>/vouch/claims/. If the user
edits a stub in Obsidian, vault_to_kb silently dropped the edit with no
feedback — the stub path was not in the state file under pages/ so the
file was skipped. Fix: detect claim stub paths in the skip branch and emit
a warning directing the user to edit the citing page instead.

Changes

  • src/vouch/vault_sync.py: four fixes + new _has_pending_page_proposal
    helper function

Checklist

  • make check passes (ruff + mypy + pytest)
  • Targets test branch
  • No new dependencies

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f600872-4e9c-4094-bd42-b00b2fe59645

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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 and usage tips.

@Tet-9 Tet-9 changed the base branch from main to test June 16, 2026 23:01
@Tet-9 Tet-9 force-pushed the fix/219-vault-to-kb-slug-and-guards branch from 226e919 to d5a7075 Compare June 17, 2026 06:58
@Tet-9

Tet-9 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@plind-junior , this is ready to merge

@plind-junior

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5a7075ed1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/vouch/vault_sync.py
source_ids=list({*edited.sources, source.id}),
proposed_by=actor,
tags=list(edited.tags),
slug_hint=page_id,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge support approving page edits before reusing page ids

when a vault edit is proposed now, this slug_hint=page_id makes the page proposal payload id equal an already-existing page. the approve path in src/vouch/proposals.py calls _ensure_no_existing_artifact() before handling ProposalKind.PAGE, so vouch approve/kb.approve returns cannot approve: page <id> already exists for every normal vault edit instead of updating the page. either approval needs an edit/update path or the proposal must not use an existing id until that exists.

Useful? React with 👍 / 👎.

Comment thread src/vouch/vault_sync.py
# proposal is approved files duplicate proposals for the same edit,
# cluttering the review queue and causing the second approve to fail
# with "page already exists".
if _has_pending_page_proposal(store, page_id):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge preserve later edits while a page proposal is pending

when a user makes a second different edit to the same mirrored page while the first proposal is still pending, this condition only checks the page id and then treats the changed file as skipped/unchanged. in the default sync_vault direction (both), the following backward pass rewrites the vault from the current KB and drops that second edit without ever filing a proposal; in forward-only mode it remains an unreported changed file. compare the current bytes/pending payload or preserve the changed file instead of treating all same-page pending proposals as duplicates.

Useful? React with 👍 / 👎.

Comment thread src/vouch/vault_sync.py Outdated
"are read-only mirrors — edit the citing page instead",
rel,
)
result.pages_skipped_unknown_id.append(rel)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge report claim-stub skips with the right reason

when a claim stub edit reaches this branch, it is added to pages_skipped_unknown_id; the CLI renders every entry in that bucket as skipped — could not parse page id in sync_cmd, so a non-watch vouch sync reports a misleading parse-id error instead of the read-only-claim-stub guidance. clients consuming VaultSyncResult also cannot distinguish this case, so please surface a dedicated skip reason/result field or special-case claims/ paths before returning.

Useful? React with 👍 / 👎.

@igeabdulrahmanikeoluwa-str

Copy link
Copy Markdown

@codex review

That is one nice update you've made on the repo, kudos to you man💪.
But, it'd be better too if it could auto merge, I think you get that aspect, right

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@Tet-9 Tet-9 force-pushed the fix/219-vault-to-kb-slug-and-guards branch from d5a7075 to 5822f58 Compare June 17, 2026 22:36
@Tet-9

Tet-9 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@plind-junior , this is all done now.
Addressed all three Codex review points:

P1: Added update_page to KBStore (parallel to update_claim) and updated the approve path to call it when the page already exists, so vault-edit proposals approve cleanly without hitting _ensure_no_existing_artifact.

P2: _has_pending_page_proposal now accepts a body parameter and only skips when the pending proposal carries the same body — a second different edit while the first is pending files a new proposal instead of being silently dropped.

P3: Claim stub edits now land in a dedicated claim_stubs_edited field on VaultSyncResult instead of pages_skipped_unknown_id, so callers can distinguish the two cases and the CLI won't report a misleading "could not parse page id" message.

Added a regression test for P1 confirming vault-edit proposals approve without error.

Thus making it all set to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: vault_to_kb proposes page edits with wrong id — slugifies title instead of preserving existing page id

3 participants