Skip to content

fix(sync): preserve omitted targets when any document is refused - #7

Closed
albertovincenzi wants to merge 1 commit into
masterfrom
fix/sync-no-reap-on-refusal
Closed

fix(sync): preserve omitted targets when any document is refused#7
albertovincenzi wants to merge 1 commit into
masterfrom
fix/sync-no-reap-on-refusal

Conversation

@albertovincenzi

Copy link
Copy Markdown
Collaborator

Problem

The target sync endpoint kept processing after a document was refused and then always entered its destructive reap phase. A partially invalid desired-state list could therefore return ok: false while deleting an existing one-node graph omitted from the request.

Fix

  • run the reap phase only when every submitted document was accepted;
  • keep successful declarations applied, but treat a refusal as proof that the submitted set is not safe deletion authority;
  • add a broker-backed regression that declares two targets, submits one valid plus one invalid document, and verifies the omitted target survives.

Review notes for Alice

This PR intentionally changes only the boundary between declaration and deletion. It does not attempt a distributed transaction across the valid declarations or broker-backed store. The safety invariant is narrower and explicit: validation/provisioning refusal means zero reap operations.

Verification

  • cargo test --workspace
  • cargo clippy -p gate-server --all-targets -- -D warnings
  • cargo fmt --all -- --check

The end-to-end regression follows the existing live-test convention and requires GATE_TEST_QUEEN_URL.

albertovincenzi added a commit that referenced this pull request Sep 5, 2026
The regression declared one target and then synced a list naming only an
invalid document. That proves the reap did not run, but not the property the
change is about: a list that is partly valid is still not authority to delete
what it leaves out.

Two targets now, and the submitted list carries one valid document plus one
broken one. `keep` is applied, `broken` is refused, and `drop` — the target
nobody named — is still declared and still running.

Taken from #7, which fixes the same bug with a byte-identical change to
`do_sync` and can be closed once this lands.

Claude-Session: https://claude.ai/code/session_012K8u7BEJyd6nDNMCQAgH3z
@albertovincenzi

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate of #29.

The two branches make a byte-identical change to do_syncdiff of the two declare.rs files shows only a comment difference — and they conflict with each other in that file, so only one can land.

#29 is the one to keep, because #46 is stacked on it. The stronger regression from this PR has been ported there: #29's test now declares two targets, submits one valid document plus one broken one, and asserts that the omitted target survives, which is the property neither test covered before.

https://claude.ai/code/session_012K8u7BEJyd6nDNMCQAgH3z

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.

1 participant