Skip to content

feat(lineage): enable soft-delete + tombstone GC by default - #201

Merged
yilu331 merged 1 commit into
mainfrom
feat/lineage-enable-defaults
Jun 22, 2026
Merged

feat(lineage): enable soft-delete + tombstone GC by default#201
yilu331 merged 1 commit into
mainfrom
feat/lineage-enable-defaults

Conversation

@yilu331

@yilu331 yilu331 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Makes soft-delete + tombstone GC the default for lineage — fulfilling the design's rev-3 intent ("soft-delete is the DEFAULT"). The mechanism has been merged and tested for several phases but shipped OFF; this flips the defaults ON so the next deployment activates it (the deploy applies the retired_at migration first, then picks up the new defaults — migration coverage is automatic).

Changes

  • LineageGCConfig.enabled: False → True (GC runs by default; 90-day grace window unchanged). Docstring rewritten to document enabled-by-default + how to disable for an extended audit hold.
  • is_dedup_soft_delete_enabled / is_aggregation_soft_delete_enabled: now default-open via a new _is_default_open_flag_enabled helper — absent key → ON; malformed config → OFF (safe fallback); explicit enabled:false + per-org enabled_org_ids override preserved; strict-bool/strict-list guards intact. Both flip together with GC so tombstones are always reclaimed (no unbounded growth).

Test Plan

  • Full OSS suite: 1295 passed, 3 skipped. 5 existing tests updated (absent-key cases now expect ON; hard-delete-path tests pin the flag OFF explicitly); new TestSoftDeleteDefaultOn + an end-to-end test proving soft-supersede → tombstone → GC reclaims aged / retains fresh.
  • Enterprise supabase soft/GC paths pass. (Pre-existing local shared-DB-pollution failures in test_lineage_gc/reconstruct_enterprise_integration are unrelated — A/B-verified identical with this change reverted; CI uses a fresh DB.)

Activation note

Merging lands this on main; production activates on the next deployment (GC + soft-delete on for all orgs). Irreversible deletes begin after the 90-day grace window. Disable per-deployment via LineageGCConfig.enabled=false if needed.

Summary by CodeRabbit

Release Notes

  • New Features

    • Lineage garbage collection is now enabled by default with a 90-day grace window for tombstone cleanup.
    • Soft-delete features are now enabled by default for both dedup and aggregation operations.
  • Tests

    • Updated test suites to reflect new default enablement behaviors and verify proper fallback handling.

- LineageGCConfig.enabled: False → True (GC on by default; tombstones
  now reclaimed after the 90-day grace window without explicit config)
- is_dedup_soft_delete_enabled + is_aggregation_soft_delete_enabled:
  fail-closed → default-open; absent key returns True, not False
  (mechanism: new _is_default_open_flag_enabled helper; explicit disable
  via enabled=False still works; strict-bool + strict-list guards kept)
- Test fallout: 5 tests that asserted off-by-default now assert on-by-default;
  4 hard-delete path tests pinned is_aggregation_soft_delete_enabled=False
- New tests: TestSoftDeleteDefaultOn (6), test_lineage_gc_can_be_explicitly_disabled,
  TestDefaultOnEndToEnd (3 e2e: supersede → tombstone, GC reclaim aged, GC retain fresh)
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Two features are flipped to default-ON: LineageGCConfig.enabled changes from False to True, and a new _is_default_open_flag_enabled helper replaces the fail-closed evaluator for both is_dedup_soft_delete_enabled and is_aggregation_soft_delete_enabled. All related tests are updated to reflect the new defaults.

Changes

Soft-delete and lineage GC default-ON

Layer / File(s) Summary
LineageGCConfig default flip to enabled=True
reflexio/models/config_schema.py, tests/models/test_lineage_gc_config.py
LineageGCConfig.enabled field default changed from False to True; docstring rewritten to describe tombstone GC as enabled by default with a 90-day grace window. Model tests updated to assert enabled is True by default, and a new explicit-disable test is added.
_is_default_open_flag_enabled helper and exported functions
reflexio/server/site_var/feature_flags.py
New _is_default_open_flag_enabled function implements default-ON semantics: returns True when the key is absent, False on malformed config (with warnings), requires enabled is True for global enablement, and checks exact org_id membership for per-org. Both is_dedup_soft_delete_enabled and is_aggregation_soft_delete_enabled are rewired to this helper.
Feature flag unit tests updated to assert default-ON
tests/server/site_var/test_feature_flags.py
Absent-key test cases for both soft-delete flags are changed from asserting False to asserting True. Contrast tests documenting divergence are replaced with agreement tests. New TestSoftDeleteDefaultOn class adds regression coverage for absent-key default, explicit global disable, and per-org disable.
Playbook aggregator and dedup integration tests for default-ON
tests/server/services/playbook/test_cluster_change_detection.py, tests/server/services/playbook/test_playbook_aggregator.py, tests/server/services/profile/test_dedup_soft_delete_integration.py
Existing playbook tests patch is_aggregation_soft_delete_enabled to False to keep testing hard-delete behavior in the flag-off path. A new TestDefaultOnEndToEnd integration class verifies tombstone creation, GC reclaim with hard_delete lineage event, and GC retention for fresh tombstones—all without flag patching, using production defaults against SQLite.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ReflexioAI/reflexio#188: Introduces LineageGCConfig and its enabled field with the original False default that this PR flips to True.
  • ReflexioAI/reflexio#191: Introduces the fail-closed is_dedup_soft_delete_enabled gate that this PR replaces with a default-open evaluator.
  • ReflexioAI/reflexio#197: Modifies feature_flags.py with stricter fail-closed validation for the same dedup_soft_delete/aggregation_soft_delete keys that this PR changes to default-open.

Poem

🐇 Hop hop, no more gates to pry,
Tombstones vanish, soft-deletes fly!
The GC wakes without a nudge,
Default ON—no need to budge.
Flags open wide, like fields in spring,
The rabbit cheers for everything! 🌸

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(lineage): enable soft-delete + tombstone GC by default' directly and clearly summarizes the main change: enabling soft-delete and tombstone garbage collection by default for lineage functionality, which is the core purpose of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 87.18% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/lineage-enable-defaults

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.

@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.

🧹 Nitpick comments (2)
tests/server/services/profile/test_dedup_soft_delete_integration.py (1)

405-411: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Make the SQLite fixture deterministic regardless of expansion-mode settings.

Line 405 currently patches only _get_embedding. If expansion mode is enabled, add_user_profile can take the _expand_document branch and make this test path environment-dependent. Force _should_expand_documents to False in the fixture.

Proposed fixture update
     `@pytest.fixture`
     def db(self):
         with (
             tempfile.TemporaryDirectory() as tmp,
+            patch.object(SQLiteStorage, "_should_expand_documents", return_value=False),
             patch.object(SQLiteStorage, "_get_embedding", return_value=[0.0] * 512),
         ):
             yield SQLiteStorage(org_id="e2e_default_org", db_path=f"{tmp}/e2e.db")
🤖 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 `@tests/server/services/profile/test_dedup_soft_delete_integration.py` around
lines 405 - 411, The db fixture currently only patches _get_embedding on
SQLiteStorage, which makes the test non-deterministic if expansion mode is
enabled since add_user_profile may take different code paths. Add an additional
patch for the _should_expand_documents method on SQLiteStorage in the same
patch.object context manager, setting it to return False to ensure the test
behavior is deterministic and independent of expansion-mode settings.
tests/server/services/playbook/test_playbook_aggregator.py (1)

671-680: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Strengthen flag-OFF tests with negative assertions for soft-delete calls.

On Line 690, Line 768, and Line 834 you assert hard-delete calls, but these tests would still pass if a regression invoked both soft-delete and hard-delete paths. Add assert_not_called() checks to lock exclusivity.

Proposed test hardening
@@
     def test_rerun_deletes_archived_playbooks_after_success(
         self, mock_gen, mock_clust, _mock_flag
     ):
@@
         agg.storage.delete_archived_agent_playbooks_by_playbook_name.assert_has_calls(
             [
                 call(SINGLETON_USER_PLAYBOOK_NAME, agent_version="v1"),
                 call("test_fb", agent_version="v1"),
             ],
             any_order=True,
         )
+        agg.storage.supersede_agent_playbooks_by_playbook_name.assert_not_called()
@@
     def test_incremental_with_changes_archives_selectively(
         self, mock_gen, mock_clust, _mock_flag
     ):
@@
         agg.storage.archive_agent_playbooks_by_ids.assert_called_once_with([50])
         agg.storage.delete_agent_playbooks_by_ids.assert_called_once_with([50])
+        agg.storage.supersede_agent_playbooks_by_ids.assert_not_called()
@@
     def test_change_log_exception_is_caught(self, mock_gen, mock_clust, _mock_flag):
@@
         # Despite the exception, hard-delete should still proceed (flag OFF path)
         agg.storage.delete_archived_agent_playbooks_by_playbook_name.assert_called()
+        agg.storage.supersede_agent_playbooks_by_playbook_name.assert_not_called()

Also applies to: 740-749, 811-818, 833-834

🤖 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 `@tests/server/services/playbook/test_playbook_aggregator.py` around lines 671
- 680, The test test_rerun_deletes_archived_playbooks_after_success mocks
is_aggregation_soft_delete_enabled to return False to test the hard-delete path,
but it only asserts that hard-delete methods are called without asserting that
soft-delete methods are NOT called. This creates a gap where a regression that
invokes both soft-delete and hard-delete paths would still pass the test. Add
assert_not_called() assertions for the soft-delete related mock objects to
ensure exclusivity between the two deletion paths when the flag is OFF. Apply
the same pattern to the other affected tests around lines 740-749, 811-818, and
833-834 where the soft-delete flag is mocked to False.
🤖 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.

Nitpick comments:
In `@tests/server/services/playbook/test_playbook_aggregator.py`:
- Around line 671-680: The test
test_rerun_deletes_archived_playbooks_after_success mocks
is_aggregation_soft_delete_enabled to return False to test the hard-delete path,
but it only asserts that hard-delete methods are called without asserting that
soft-delete methods are NOT called. This creates a gap where a regression that
invokes both soft-delete and hard-delete paths would still pass the test. Add
assert_not_called() assertions for the soft-delete related mock objects to
ensure exclusivity between the two deletion paths when the flag is OFF. Apply
the same pattern to the other affected tests around lines 740-749, 811-818, and
833-834 where the soft-delete flag is mocked to False.

In `@tests/server/services/profile/test_dedup_soft_delete_integration.py`:
- Around line 405-411: The db fixture currently only patches _get_embedding on
SQLiteStorage, which makes the test non-deterministic if expansion mode is
enabled since add_user_profile may take different code paths. Add an additional
patch for the _should_expand_documents method on SQLiteStorage in the same
patch.object context manager, setting it to return False to ensure the test
behavior is deterministic and independent of expansion-mode settings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: feee6b11-ec7d-4adb-9d7f-a9a4eab19064

📥 Commits

Reviewing files that changed from the base of the PR and between 572b652 and 0b22476.

📒 Files selected for processing (7)
  • reflexio/models/config_schema.py
  • reflexio/server/site_var/feature_flags.py
  • tests/models/test_lineage_gc_config.py
  • tests/server/services/playbook/test_cluster_change_detection.py
  • tests/server/services/playbook/test_playbook_aggregator.py
  • tests/server/services/profile/test_dedup_soft_delete_integration.py
  • tests/server/site_var/test_feature_flags.py

@yilu331
yilu331 merged commit 0955cf7 into main Jun 22, 2026
1 check passed
@yilu331
yilu331 deleted the feat/lineage-enable-defaults branch June 22, 2026 05:30
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