Skip to content

fix(learning): keep the generation when community permissions are saved unchanged (#373) - #33

Merged
jcguo123 merged 1 commit into
mainfrom
sync/community-resave
Oct 28, 2026
Merged

jcguo123 merged 1 commit into
mainfrom
sync/community-resave

Conversation

@jcguo123

Copy link
Copy Markdown
Collaborator

Sync of private jcguo123/Choruz#373, merged as c0d12a84. The same patch is applied on public main; the branch tree equals private main's tree.


Type

  • bugfix — fixes a bug

Agent Note

New: .agents/notes/implemented/bug-fix/2026-10-28-unchanged-community-save-keeps-generation.md

Summary

Symptom. A reviewed learning candidate could be orphaned: its automatic evaluation was never queued, it was never applied, and the owner saw no error.

Cause.

  • configure_behavior_community incremented the policy generation on every save, including a save of the permissions already stored.
  • The learning dialog saves community permissions as part of its normal flow.
  • Since background workers wake immediately (#371), a learning check can commit a reviewed candidate about one second after learning settings are saved, before that community save.
  • The save then moves the policy to a new generation. pending_experience_optimizations only queues candidates from the current generation, so the candidate is never queued.

Fix. configure_behavior_community now locks the policy row and compares the stored and requested settings as CommunitySettings. When they are equal it writes nothing. A changed consent still advances the generation, clears the learning lease and releases behavior-event leases.

How it was found. The remote learning e2e failed on #372, a CI-only PR.

  • That failure showed only an inactive candidate, with no errors.
  • The diagnostic in 8e4f27be (included here) makes the activation timeout report the evaluation list and the policy errors.
  • The next run reported Evaluations when activation timed out: [].

Ownership

  • Owner: DbService::configure_behavior_community remains the single place that decides what a community consent change fences.
  • Removed: the unconditional increment.

Tests

Test What it checks Status
tests::experience::reliability::saving_unchanged_community_permissions_keeps_the_learning_generation (new) Commits and releases a reviewed candidate on an optimized policy, then re-saves the default permissions: the generation is unchanged and pending_experience_optimizations() still lists the binding. Saving search: true then advances the generation by one. Fails against the previous behavior.rs: left: 2, right: 1, captured
Existing consent-fencing tests in tests::experience, e.g. "revoked consent must fence an already prepared projection" A real consent change still fences prepared work. 29 passed
E2e diagnostic, terminal.spec.ts (test-only) On an activation timeout, reports each evaluation's status, error, case and application state, plus the policy's errors. —

Ran locally

On 7e3c28ac:

  • cargo clippy --workspace --all-targets -- -D warnings: 0 findings.
  • cargo test --workspace --no-fail-fast, with source infra/host/setup_test_database.sh: 64 binaries, 969 passed, 0 failed.
  • cargo fmt --check and verify_agent_notes both pass.

Remote learning e2e with the fix, 12 runs with 6 workers and no retries: 11 passed.

  • The "never activates" failure did not recur.
  • The single failure was a separate, pre-existing learning prepare HTTP 409 race. The gateway warn log shows an activation during preparation: binding_changed=true, revision_before=None, revision_after=Some(…).
  • That race is not addressed here.

Independent audit: GPT-5.6 Terra used choruz-pre-simplify-audit on origin/main..7e3c28ac and returned PASS.

Risk

A re-save of identical permissions no longer refreshes leases or the generation. Any flow that relied on a no-op save to retry blocked work must use retry_behavior, which already exists for that purpose.

This PR was written by an AI agent (Claude), which ran every command listed above.

…ed unchanged (#373)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jcguo123
jcguo123 merged commit df4318c into main Oct 28, 2026
13 checks passed
@jcguo123
jcguo123 deleted the sync/community-resave branch October 28, 2026 11:13
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