Skip to content

feat: Add filtered collection truncate - #5097

Merged
iverc merged 6 commits into
developfrom
iverc/purge-by-doc-ids
Aug 27, 2026
Merged

feat: Add filtered collection truncate#5097
iverc merged 6 commits into
developfrom
iverc/purge-by-doc-ids

Conversation

@iverc

@iverc iverc commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Relevant issue(s)

Resolves #5117

Description

Adds an optional filter to the existing collection truncate operation so callers can permanently remove matching documents from the local node without introducing another delete command. Truncating without a filter keeps the existing collection-wide behavior.

Filtered truncate removes the selected document data and associated local state, including heads, indexes, ID mappings, signatures, encryption blocks, and searchable-encryption records. The optional pruneHistory setting also removes history blocks that are not shared by another document.

The filter is supported by the Go, HTTP, CLI, and C APIs, and GraphQL now exposes truncate_<Collection> mutations. No new dependencies are added.

Limitations:

  • Truncate is local and does not replicate. Propagate soft-delete tombstones first when peers must not reintroduce the data.
  • History pruning is rejected for branchable collections until collection-DAG pruning semantics are defined.
  • Filtered truncate runs in bounded chunks and may be partially applied if a later chunk fails.
  • Filtered truncate cannot run inside a caller-supplied transaction. GraphQL truncate must be a standalone mutation.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

  • Unit coverage for filtering, storage cleanup, shared history, indexes, ID mappings, signatures, encryption, searchable encryption, transaction chunking, and LevelDB behavior.
  • Integration coverage for collection and GraphQL truncate flows, DAC authorization, and searchable encryption.
  • Race tests for the changed database and GraphQL paths.
  • Repository lint and generated documentation checks.

Specify the platform(s) on which this was tested:

  • MacOS

@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

Walkthrough

Adds targeted local document purging by document ID with optional history pruning. The operation spans storage cleanup, transactions, authorization, HTTP, CLI, JavaScript, cgo, and integration tests.

Changes

Document purge

Layer / File(s) Summary
Purge execution and contracts
client/collection.go, internal/db/collection_purge.go, internal/db/txn_collection.go, internal/db/collection_index.go, client/options/collection.go, acp/types/types.go
Adds PurgeByDocIDs, identity options, transaction handling, bounded cleanup, index removal, datastore cleanup, and the purge-document permission.
Block ownership and history pruning
internal/db/id/document.go, internal/db/collection_truncate.go, internal/db/collection_purge_test.go, internal/db/id/document_test.go
Tracks block owners and aliases, prunes reachable unowned blocks, preserves shared blocks, and validates conflict behavior.
HTTP, CLI, JavaScript, and cgo adapters
http/*collection.go, cli/*collection*.go, js/client_collection.go, cbindings/*collection*.go, docs/website/references/http/openapi.json, docs/website/references/cli/*purge-docs*
Exposes document purging through HTTP, CLI, JavaScript, and cgo interfaces.
Integration validation
tests/action/purge_docs.go, tests/clients/*/wrapper_collection.go, tests/integration/collection/purge/*, tests/integration/acp/*/purge*, tests/integration/searchable_encryption/purge_test.go
Adds purge actions, client wrappers, and coverage for repeated purges, authorization, soft-deleted documents, and searchable-encryption cleanup.
Storage and test infrastructure
internal/db/db.go, internal/db/db_test.go, .github/*, Makefile, cli/wizard/unit_test.go, go.mod, internal/db/p2p/*, tests/action/active_peers.go
Updates LevelDB transaction handling and adds CI, vulnerability, test cleanup, peer discovery, and Go-version changes.

Estimated code review effort: 5 (Critical) | ~90 minutes

Assessment against linked issues

Objective Addressed Explanation
Targeted local purge with optional history pruning [#5117]
Cleanup of document values, heads, indexes, mappings, markers, signatures, encryption blocks, and searchable-encryption records [#5117]
Go, HTTP, CLI, C, and JavaScript exposure [#5117]
Authorization, locality, transaction semantics, and branchable-history restriction [#5117]

Out-of-scope changes

Code Change Explanation
Active-peer ID conversion and synchronization changes (internal/db/p2p/p2p.go:287-304, internal/db/p2p/sync_doc.go:97-105, internal/db/p2p/sync_branchable_col.go:93-101) These changes do not implement targeted document purging or its required interfaces.
System-keyring test restructuring (cli/wizard/unit_test.go:250-695) These test-fixture changes are unrelated to purge behavior.
Vulnerability allowlist and workflow changes (.github/known-vulnerabilities.txt:1-6, .github/workflows/check-vulnerabilities.yml:50-55) These changes modify vulnerability-check maintenance, not document purging.
Replicator timeout and generic test-runner changes (cli/test/integration/p2p/replicator_list_test.go:135, Makefile:71, Makefile:327, .github/workflows/test-macos.yml:79-84) These changes modify test execution timing or configuration without implementing purge requirements.

Possibly related PRs

Suggested labels: feature, area/datastore, area/testing

Suggested reviewers: shahzadlone, fredcarle


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.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.00722% with 144 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.40%. Comparing base (3e7f8ee) to head (b408367).

Files with missing lines Patch % Lines
internal/db/collection_truncate_filter.go 65.64% 28 Missing and 28 partials ⚠️
internal/db/collection_truncate.go 78.16% 10 Missing and 9 partials ⚠️
internal/db/id/document.go 64.15% 11 Missing and 8 partials ⚠️
http/handler_collection.go 64.29% 6 Missing and 4 partials ⚠️
internal/planner/truncate.go 71.43% 7 Missing and 3 partials ⚠️
internal/db/collection_index.go 68.00% 4 Missing and 4 partials ⚠️
cbindings/collection_truncate.go 60.00% 3 Missing and 3 partials ⚠️
internal/keys/key.go 25.00% 6 Missing ⚠️
cbindings/wrapper_collection.go 84.62% 1 Missing and 1 partial ⚠️
cli/collection_truncate.go 88.24% 1 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5097      +/-   ##
===========================================
+ Coverage    76.29%   76.40%   +0.11%     
===========================================
  Files          645      647       +2     
  Lines        51122    51555     +433     
===========================================
+ Hits         39001    39387     +386     
- Misses        8840     8849       +9     
- Partials      3281     3319      +38     
Flag Coverage Δ
all-tests 76.40% <74.01%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
client/options/collection.go 95.98% <100.00%> (+4.26%) ⬆️
client/request/mutation.go 100.00% <ø> (ø)
http/errors.go 78.57% <100.00%> (+0.26%) ⬆️
http/openapi.go 98.48% <ø> (ø)
internal/db/document_update.go 80.95% <100.00%> (+2.19%) ⬆️
internal/db/errors.go 51.99% <ø> (ø)
internal/db/request.go 93.48% <100.00%> (+2.30%) ⬆️
internal/keys/datastore_se.go 89.29% <100.00%> (+0.40%) ⬆️
internal/planner/mapper/mapper.go 90.54% <100.00%> (+0.13%) ⬆️
internal/planner/operation.go 79.52% <100.00%> (ø)
... and 15 more

... and 17 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e7f8ee...b408367. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@iverc
iverc force-pushed the iverc/purge-by-doc-ids branch from 813ef44 to 6f15733 Compare July 29, 2026 19:43

@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 `@cli/collection_purge_docs.go`:
- Around line 30-32: Update the Long help text for the collection purge command
to clarify that --prune-history removes reachable blocks only when they are no
longer shared with other documents; shared history blocks are retained until
their final owning document is purged. Apply the same clarification to the
corresponding help text referenced by the additional location.
🪄 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: 24fee146-880a-4bae-9697-6b7efde010d3

📥 Commits

Reviewing files that changed from the base of the PR and between 813ef44 and 6f15733.

📒 Files selected for processing (23)
  • cbindings/collection_purge.go
  • cbindings/wrapper_collection.go
  • cli/cli.go
  • cli/collection_purge_docs.go
  • client/collection.go
  • client/mocks/collection.go
  • docs/website/references/http/openapi.json
  • http/client_collection.go
  • http/handler_collection.go
  • internal/db/collection_index.go
  • internal/db/collection_purge.go
  • internal/db/collection_purge_conflict_test.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_truncate.go
  • internal/db/document_delete.go
  • internal/db/id/document.go
  • internal/db/id/document_test.go
  • internal/db/txn_collection.go
  • js/client_collection.go
  • tests/action/purge_docs.go
  • tests/clients/cli/wrapper_collection.go
  • tests/clients/js/wrapper_collection.go
  • tests/integration/collection/purge/simple_test.go
🚧 Files skipped from review as they are similar to previous changes (21)
  • tests/clients/cli/wrapper_collection.go
  • tests/clients/js/wrapper_collection.go
  • cli/cli.go
  • js/client_collection.go
  • cbindings/collection_purge.go
  • http/client_collection.go
  • internal/db/collection_index.go
  • tests/integration/collection/purge/simple_test.go
  • internal/db/txn_collection.go
  • internal/db/id/document.go
  • http/handler_collection.go
  • client/mocks/collection.go
  • client/collection.go
  • docs/website/references/http/openapi.json
  • tests/action/purge_docs.go
  • internal/db/collection_purge.go
  • internal/db/collection_truncate.go
  • internal/db/document_delete.go
  • internal/db/id/document_test.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_purge_conflict_test.go
📜 Review details
⏰ Context from checks skipped due to timeout. (52)
  • GitHub Check: Check vulnerabilities job
  • GitHub Check: Test coverage job (http, file, collection-named)
  • GitHub Check: Start binary job
  • GitHub Check: Test coverage job (cli, memory, collection-save)
  • GitHub Check: Test coverage job (c, memory, collection-save)
  • GitHub Check: Test coverage job (c, file, gql)
  • GitHub Check: Test coverage job (cli, file, collection-save)
  • GitHub Check: Test coverage job (c, file, collection-save)
  • GitHub Check: Test coverage job (go, file, gql)
  • GitHub Check: Test coverage job (c, file, collection-named)
  • GitHub Check: Test coverage job (c, memory, collection-named)
  • GitHub Check: Test coverage job (http, file, gql)
  • GitHub Check: Test coverage job (http, memory, collection-named)
  • GitHub Check: Test coverage job (http, memory, gql)
  • GitHub Check: Test coverage job (c, memory, gql)
  • GitHub Check: Test coverage job (cli, memory, collection-named)
  • GitHub Check: Test coverage job (cli, file, gql)
  • GitHub Check: Test coverage job (go, memory, gql)
  • GitHub Check: Test coverage job (http, memory, collection-save)
  • GitHub Check: Test coverage job (cli, memory, gql)
  • GitHub Check: Test coverage job (cli, file, collection-named)
  • GitHub Check: Test coverage job (go, file, collection-save)
  • GitHub Check: Test coverage job (http, file, collection-save)
  • GitHub Check: Test coverage job (go, memory, collection-save)
  • GitHub Check: Test coverage job (go, memory, collection-named)
  • GitHub Check: Test coverage job (go, file, collection-named)
  • GitHub Check: Check mocks job
  • GitHub Check: Lint GoLang job
  • GitHub Check: Test coverage document acp job (go, source-hub)
  • GitHub Check: Test coverage JS job
  • GitHub Check: Test coverage secondary index job
  • GitHub Check: Test coverage document acp job (http, source-hub)
  • GitHub Check: Test coverage leveldb job
  • GitHub Check: Test coverage document acp job (c, source-hub)
  • GitHub Check: Test coverage document acp job (cli, source-hub)
  • GitHub Check: Test coverage signed docs job
  • GitHub Check: Test coverage lens job (wazero)
  • GitHub Check: Test coverage telemetry job
  • GitHub Check: Test coverage view job
  • GitHub Check: Build dependencies job
  • GitHub Check: Test coverage encryption job
  • GitHub Check: Build, install, and test Debian package
  • GitHub Check: Test Limited Resource job
  • GitHub Check: Check http documentation job
  • GitHub Check: Check data format changes job
  • GitHub Check: Check wizard health job
  • GitHub Check: Test NPX/JS build job
  • GitHub Check: Test macos job
  • GitHub Check: Build and test Linux C shared library
  • GitHub Check: Check cli documentation job
  • GitHub Check: Validate containerfile job
  • GitHub Check: Lint GoLang job
⚠️ CI failures not shown inline (2)

GitHub Actions: Validate Title Workflow / Validate title job: feat: add targeted document purge

Conclusion: failure

View job details

##[group]Run ./tools/scripts/validate-conventional-style.sh "feat: add targeted document purge"
 �[36;1m./tools/scripts/validate-conventional-style.sh "feat: add targeted document purge"�[0m
 shell: /usr/bin/bash -e {0}
 ##[endgroup]
 Info: label = [feat]
 Info: description = [ add targeted document purge]
 Error: First character after the label is not an uppercase alphabet.
 ##[error]Process completed with exit code 7.

GitHub Actions: Validate Title Workflow / 0_Validate title job.txt: feat: add targeted document purge

Conclusion: failure

View job details

##[group]Run ./tools/scripts/validate-conventional-style.sh "feat: add targeted document purge"
 �[36;1m./tools/scripts/validate-conventional-style.sh "feat: add targeted document purge"�[0m
 shell: /usr/bin/bash -e {0}
 ##[endgroup]
 Info: label = [feat]
 Info: description = [ add targeted document purge]
 Error: First character after the label is not an uppercase alphabet.
 ##[error]Process completed with exit code 7.
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-03-27T08:24:16.083Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4661
File: http/middleware.go:93-93
Timestamp: 2026-03-27T08:24:16.083Z
Learning: When handling `client.ErrNotAuthorizedToPerformOperation` in the defradb repository, treat it as an unauthenticated/missing-identity condition (not insufficient permissions). Map it to HTTP 401 Unauthorized rather than 403 Forbidden; this mapping is intentional and consistent with prior behavior (pre-PR `#4661`).

Applied to files:

  • cli/collection_purge_docs.go
  • cbindings/wrapper_collection.go
📚 Learning: 2026-06-18T16:47:47.339Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4942
File: internal/db/db.go:227-231
Timestamp: 2026-06-18T16:47:47.339Z
Learning: When reviewing this repository’s Go code, do not flag `sync.WaitGroup.Go()` (e.g., `wg.Go(fn)`) as a compilation error. This method exists starting in Go 1.25; it should be treated as valid as long as the repo’s configured/minimum Go toolchain version is 1.25+ (e.g., per `go.mod` and/or CI). If the project is building with an older Go version, then it may be appropriate to flag it.

Applied to files:

  • cli/collection_purge_docs.go
  • cbindings/wrapper_collection.go
📚 Learning: 2026-06-18T16:47:47.339Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4942
File: internal/db/db.go:227-231
Timestamp: 2026-06-18T16:47:47.339Z
Learning: In sourcenetwork/defradb code reviews, do not raise findings that are likely compiler/type-check errors (e.g., code that would fail `go test`/`go build`) because CI pipelines will catch compilation failures. Only flag compilation-related problems if there is a clear, verifiable issue beyond what CI will already surface (e.g., a mismatched build tag or missing generated artifact that CI would not cover).

Applied to files:

  • cli/collection_purge_docs.go
  • cbindings/wrapper_collection.go
🔇 Additional comments (2)
cli/collection_purge_docs.go (1)

37-54: LGTM!

cbindings/wrapper_collection.go (1)

26-34: LGTM!

Also applies to: 335-389

Comment thread cli/collection_purge_docs.go Outdated
@iverc iverc changed the title feat: add targeted document purge feat: Add targeted document purge Jul 30, 2026

@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 `@docs/website/references/cli/defradb_client_collection_purge-docs.md`:
- Line 14: Update the fenced code blocks in defradb_client_collection_purge
documentation by adding language identifiers: use console for the command
synopsis and text for the option listings, including the additional referenced
fences.
🪄 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: d64a2897-d6f1-4807-9411-d8fcb525013f

📥 Commits

Reviewing files that changed from the base of the PR and between 6f15733 and b33f518.

📒 Files selected for processing (8)
  • cli/collection_purge_docs.go
  • client/mocks/collection.go
  • docs/website/references/cli/defradb_client_collection.md
  • docs/website/references/cli/defradb_client_collection_purge-docs.md
  • internal/db/collection_index.go
  • internal/db/collection_purge.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_truncate.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/db/collection_purge.go
  • cli/collection_purge_docs.go
  • client/mocks/collection.go
📜 Review details
⏰ Context from checks skipped due to timeout. (52)
  • GitHub Check: Test coverage job (c, memory, gql)
  • GitHub Check: Test coverage job (cli, memory, collection-save)
  • GitHub Check: Test coverage job (cli, memory, collection-named)
  • GitHub Check: Test coverage job (http, memory, gql)
  • GitHub Check: Test coverage job (c, file, collection-save)
  • GitHub Check: Test coverage job (c, file, collection-named)
  • GitHub Check: Test coverage job (c, memory, collection-named)
  • GitHub Check: Test coverage job (c, file, gql)
  • GitHub Check: Test coverage job (http, memory, collection-named)
  • GitHub Check: Test coverage job (http, memory, collection-save)
  • GitHub Check: Test coverage job (cli, file, collection-named)
  • GitHub Check: Test coverage job (cli, file, gql)
  • GitHub Check: Test coverage job (cli, file, collection-save)
  • GitHub Check: Test coverage job (cli, memory, gql)
  • GitHub Check: Test coverage job (c, memory, collection-save)
  • GitHub Check: Test coverage job (http, file, collection-named)
  • GitHub Check: Test coverage job (go, file, gql)
  • GitHub Check: Test coverage job (http, file, gql)
  • GitHub Check: Test coverage job (go, file, collection-save)
  • GitHub Check: Test coverage document acp job (c, source-hub)
  • GitHub Check: Test coverage job (go, memory, collection-named)
  • GitHub Check: Test coverage document acp job (http, source-hub)
  • GitHub Check: Test coverage job (http, file, collection-save)
  • GitHub Check: Test coverage job (go, memory, gql)
  • GitHub Check: Test coverage secondary index job
  • GitHub Check: Test coverage job (go, file, collection-named)
  • GitHub Check: Test coverage job (go, memory, collection-save)
  • GitHub Check: Test coverage leveldb job
  • GitHub Check: Test coverage document acp job (go, source-hub)
  • GitHub Check: Test coverage view job
  • GitHub Check: Test coverage lens job (wazero)
  • GitHub Check: Test coverage document acp job (cli, source-hub)
  • GitHub Check: Test coverage encryption job
  • GitHub Check: Test coverage signed docs job
  • GitHub Check: Test coverage telemetry job
  • GitHub Check: Test coverage JS job
  • GitHub Check: Check data format changes job
  • GitHub Check: Test NPX/JS build job
  • GitHub Check: Test Limited Resource job
  • GitHub Check: Build, install, and test Debian package
  • GitHub Check: Check wizard health job
  • GitHub Check: Lint GoLang job
  • GitHub Check: Check mocks job
  • GitHub Check: Test macos job
  • GitHub Check: Validate containerfile job
  • GitHub Check: Check http documentation job
  • GitHub Check: Check cli documentation job
  • GitHub Check: Check vulnerabilities job
  • GitHub Check: Build and test Linux C shared library
  • GitHub Check: Start binary job
  • GitHub Check: Build dependencies job
  • GitHub Check: Lint GoLang job
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-03-27T08:24:16.083Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4661
File: http/middleware.go:93-93
Timestamp: 2026-03-27T08:24:16.083Z
Learning: When handling `client.ErrNotAuthorizedToPerformOperation` in the defradb repository, treat it as an unauthenticated/missing-identity condition (not insufficient permissions). Map it to HTTP 401 Unauthorized rather than 403 Forbidden; this mapping is intentional and consistent with prior behavior (pre-PR `#4661`).

Applied to files:

  • internal/db/collection_index.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_truncate.go
📚 Learning: 2026-06-18T16:47:47.339Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4942
File: internal/db/db.go:227-231
Timestamp: 2026-06-18T16:47:47.339Z
Learning: When reviewing this repository’s Go code, do not flag `sync.WaitGroup.Go()` (e.g., `wg.Go(fn)`) as a compilation error. This method exists starting in Go 1.25; it should be treated as valid as long as the repo’s configured/minimum Go toolchain version is 1.25+ (e.g., per `go.mod` and/or CI). If the project is building with an older Go version, then it may be appropriate to flag it.

Applied to files:

  • internal/db/collection_index.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_truncate.go
📚 Learning: 2026-06-18T16:47:47.339Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4942
File: internal/db/db.go:227-231
Timestamp: 2026-06-18T16:47:47.339Z
Learning: In sourcenetwork/defradb code reviews, do not raise findings that are likely compiler/type-check errors (e.g., code that would fail `go test`/`go build`) because CI pipelines will catch compilation failures. Only flag compilation-related problems if there is a clear, verifiable issue beyond what CI will already surface (e.g., a mismatched build tag or missing generated artifact that CI would not cover).

Applied to files:

  • internal/db/collection_index.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_truncate.go
🪛 markdownlint-cli2 (0.23.1)
docs/website/references/cli/defradb_client_collection_purge-docs.md

[warning] 14-14: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


[warning] 20-20: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


[warning] 32-32: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (5)
docs/website/references/cli/defradb_client_collection.md (1)

40-40: LGTM!

internal/db/collection_purge_test.go (1)

204-221: LGTM!

internal/db/collection_truncate.go (2)

529-679: LGTM on the purge-specific ownership/traversal logic (deleteBlockMapping, deleteBlock, and the DAG-walk fallback at Lines 573 and 619) — the write-vs-read-snapshot split for owner checks is well reasoned and covered by the new tests.


494-528: 🗄️ Data Integrity & Integration

Caller-txn block-visibility fallback is not needed for collection-wide truncate.

Collection-wide truncate clears document data/headstore keys before walking collection commit blocks, and these deletes run outside the explicit transaction via corekv.SetCtxTxn(ctx, nil). deleteBlocks is called with docID == "", so per-document uncommitted owner edges cannot be present; if a newly created committed block were encountered, it would already be removed in the earlier hard delete pass.

			> Likely an incorrect or invalid review comment.
internal/db/collection_index.go (1)

348-391: 🎯 Functional Correctness

No change needed.

The soft-delete path calls deleteIndexedDocWithID(..., false) before marking the document deleted, so purge’s early return for already-deleted documents does not leave index entries behind.

Comment thread docs/website/references/cli/defradb_client_document_purge.md Outdated
@iverc

iverc commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Final scale and correctness verification:

  • The permanent 500-document regression first runs the same purge in one caller transaction and confirms Badger rejects it with "Txn is too big". The bounded implicit path then purges all 500 successfully.
  • The permanent ownership test confirms the new presence check reads one owner key, while the previous full-list path reads all 500 owner mappings.
  • An ad hoc 5x1s benchmark with 1,000 owners on an Apple M5 Max measured a median 1.47us, 1,792 B, and 16 allocs for the new first-owner check versus 52.9us, 52,976 B, and 1,027 allocs for the previous full scan: about 36x faster, 30x less memory, and 64x fewer allocations.
  • Added coverage for two documents created in one caller transaction sharing a block, then purging one while retaining the shared block for the survivor.

Verified internal/db and internal/db/id package tests, the purge integration matrix, focused race tests, and golangci-lint with 0 new issues.

@iverc

iverc commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

CI note:

  • Coverage passed 36/37 jobs. The remaining LevelDB failure matches the latest develop run exactly: TestTxn_DeleteIndex_WithCommit_Succeeds times out waiting for an index drop, then TestColVersionUpdateReplaceIsActive_GetCollectionsWithTxn hangs until the 10-minute package timeout.
  • The macOS run failed the exact same six tests as the latest develop run: five system-keyring checks and TestP2PAdd_WithP2PCollectionOnLastNodeInNodeChain_ShouldPropagateUpdate timing out while waiting for a merge event.
  • The vulnerability workflow is also failing on develop; its expected vulnerability count is stale relative to the current dependency scan.

Base coverage: https://github.com/sourcenetwork/defradb/actions/runs/30392652964/job/90391332793
Base macOS: https://github.com/sourcenetwork/defradb/actions/runs/30392652787/job/90387826797
Base vulnerability check: https://github.com/sourcenetwork/defradb/actions/runs/30392652739

Comment thread cli/collection_purge_docs.go Outdated
Comment thread internal/db/collection_purge.go Outdated
@iverc
iverc requested a review from shahzadlone August 3, 2026 04:58
@iverc iverc self-assigned this Aug 4, 2026

@shahzadlone shahzadlone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this PR, I have done the first round of review and left some comments. I think there is some work that needs to be done before we can merge this.

In addition to the comments I noticed a pattern where you piggy-backed/used some truncate code for the purge code, is this purposeful? For example rather than defining a new NAC ACP permission using the truncate one or also the use of options.TruncateCollectionOptions over a tailored option for Purge. Please find and sort any and all such actions that I may not have caught where this same pattern might be repeated.

One additional nitpick: The parent collection command synopsis in cli/collection.go still lists add, describe, patch, set-active, delete, and truncate, but omits purge-docs. The regenerated parent documentation preserves that omission. Please include the new command so it is discoverable from the parent help.

Comment thread internal/db/collection_truncate.go Outdated
Comment thread internal/db/collection_index.go Outdated
Comment thread internal/db/collection_purge.go Outdated
Comment thread internal/db/collection_purge.go Outdated
Comment thread internal/db/collection_truncate.go Outdated
Comment thread internal/db/collection_truncate.go Outdated
Comment thread internal/db/collection_purge.go Outdated
Comment thread internal/db/collection_purge.go Outdated
Comment thread internal/db/collection_purge.go Outdated
@shahzadlone

Copy link
Copy Markdown
Member

suggestion: I don't see a linked issue and the PR description is not using the DefraDB PR description template style, will appreciate if you can adhere to that please :).

More info: https://github.com/sourcenetwork/defradb?tab=contributing-ov-file#-link-with-relevant-issues

@iverc

iverc commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review in dba27a2 and 48ee8e9:

  • Added dedicated purge permission and options instead of reusing truncate contracts.
  • Audited and updated Go, HTTP, CLI, C, JS, mocks, and test wrappers.
  • Added purge-docs to the parent collection synopsis and regenerated CLI docs.
  • Added LevelDB, large-history, branchable, DAC/NAC, shared signature/encryption, marker, alias, and two-node searchable-encryption regressions.

Local validation is green across Go, HTTP, CLI, C, and WASM purge flows, plus both pinned lint configurations.

@iverc

iverc commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review round in dba27a222 and 48ee8e9eb:

  • removed the remaining purge coupling to truncate options and permissions
  • added a dedicated purge-document permission and PurgeByDocIDsOptions
  • removed the nested LevelDB read transaction and added regressions for purge and truncate
  • made implicit history pruning resumable for a single large document
  • rejected branchable history pruning until its collection-DAG semantics are defined
  • preserved shared blocks and signatures, and cleaned ownerless encryption blocks
  • removed primary markers and canonical, alias, and unmatched searchable-encryption records
  • added DAC, NAC, LevelDB, shared-history, signed-document, encrypted-document, 3,000-update, and end-to-end searchable-encryption coverage
  • added purge-docs to the parent collection synopsis

I also added issue #5117 and updated the PR body to the repository template with the operation limitations. Focused tests, race tests, lint, generated CLI docs, and generated OpenAPI checks pass locally. Fresh CI is running now.

@iverc

iverc commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up CI fix: removed the test-only alternate collection identity. Purge tests now follow the normal collection lookup on every client; unauthorized callers fail at get-collection, while node admins proceed through the dedicated purge-document check.

The targeted NAC tests pass through Go, HTTP, CLI, and C, and the full client matrix is green. The remaining vulnerability check is also failing on develop because its expected govulncheck count is stale.

@iverc
iverc requested a review from shahzadlone August 4, 2026 21:45
@iverc

iverc commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review items and pushed the follow-up fixes. Purge now has its own options and NAC permission, the parent help/docs include purge-docs, and the SourceHub ACP and secondary-index matrices are green. The vulnerability job is failing the same way on develop; LevelDB and macOS are still queued. Ready for another pass.

@iverc iverc mentioned this pull request Aug 4, 2026
@iverc

iverc commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Stacked #5119 so CI now runs against the fixes for the three default-branch failures. The LevelDB hang was a nested-transaction regression from #5101: the exact failing test went from timing out after 45 seconds to passing in 1.65 seconds, and the purge flow now passes on LevelDB as well. All review threads are resolved and this is ready for another look.

@iverc

iverc commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

The first full rerun exposed one more baseline test-harness issue: transactional DeleteIndex was waiting for background cleanup before its transaction committed. #5119 now gives it the same transaction guard already used by NewIndex. The full LevelDB transaction package and 10 repeated runs of the failing test pass locally; the follow-up is stacked here for the new CI run.

@iverc

iverc commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

The remaining deterministic LevelDB failures had the same teardown cause: integration cases left explicit transactions open, then node shutdown waited on an index worker blocked acquiring LevelDB transaction access. The harness now discards those transactions before closing nodes. All three formerly hanging cases pass three consecutive runs; their full packages and the purge tests pass under the race detector. The Wazero failure was a separate P2P sync timeout, and the two affected sync cases passed 40 combined consecutive local executions, so no product change was made for it. Fresh CI is running.

@iverc

iverc commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Stacked the verified peer-sync baseline from #5119. The latest #5097 macOS retry had no purge failure; its only failure was the open Darwin race-runtime crash in golang/go#80292.

The shared update fixes the underlying peer-ID bookkeeping and network-readiness races, and adds a bounded macOS retry that still fails on data races, multiple failures, or a repeated failure. On the stacked branch, P2P internals, network info, document and branchable sync, and purge integration all pass together under shuffled race execution. Fresh CI is running.

@iverc

iverc commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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

🧹 Nitpick comments (3)
internal/db/collection_purge_leveldb_test.go (1)

41-56: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Close the database on the timeout path too.

db.Close() runs only when the operation returns. If the operation blocks, the select takes the timeout branch and the LevelDB handle stays open for the rest of the package run, while the operation goroutine keeps running. t.TempDir() cleanup then removes files that LevelDB still holds open, which can add a confusing secondary failure on top of the real hang report.

Register the close in newLevelDBForPurgeTest with t.Cleanup so it runs on every path, and remove the close from this helper.

♻️ Proposed cleanup handling
 func newLevelDBForPurgeTest(t *testing.T, ctx context.Context) *DB {
 	t.Helper()
 
 	rootstore, err := leveldb.NewDatastore(t.TempDir(), nil)
 	require.NoError(t, err)
 	adminInfo, err := acpDB.NewNACInfo(ctx, "", false)
 	require.NoError(t, err)
 	db, err := newDB(ctx, rootstore, adminInfo)
 	require.NoError(t, err)
+	t.Cleanup(func() { db.Close() })
 	return db
 }
 
 func requireLevelDBOperationCompletes(t *testing.T, db *DB, operation func() error) {
 	t.Helper()
 
 	done := make(chan error, 1)
 	go func() {
 		done <- operation()
 	}()
 
 	select {
 	case err := <-done:
-		db.Close()
 		require.NoError(t, err)
 	case <-time.After(5 * time.Second):
 		t.Fatal("operation blocked while opening a nested LevelDB transaction")
 	}
 }

The db parameter then becomes unused; drop it from the helper signature and from both call sites.

🤖 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 `@internal/db/collection_purge_leveldb_test.go` around lines 41 - 56, Register
db.Close with t.Cleanup in newLevelDBForPurgeTest so the database closes on both
completion and timeout paths. Remove db.Close from
requireLevelDBOperationCompletes, drop its now-unused db parameter, and update
both call sites to pass only the testing handle and operation.
internal/db/collection_purge.go (1)

275-318: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid re-scanning the whole searchable-encryption prefix on each chunk.

In the non-transactional path, the loop breaks after hardDeleteChunkSize matched keys and then restarts the iterator at the collection-wide keys.DatastoreSE prefix. Every pass re-reads all non-matching entries that were already inspected. For a collection with N searchable-encryption records and M matching records, the total scan cost is about (M / hardDeleteChunkSize) * N.

Resume iteration after the last inspected key instead of restarting from the prefix.

♻️ Suggested resumable-cursor approach
 	ds := datastore.NewMultistore(c.db.rootstore, c.db.lockSet, c.db.blockStoreChunkSize).Datastore()
 	_, transactional := corekv.TryGetCtxTxn(ctx)
+	var resumeAfter []byte
 	for {
 		iter, err := ds.Iterator(ctx, datastore.IterOptions{
 			Prefix:   keys.DatastoreSE{CollectionShortID: shortID},
 			KeysOnly: true,
+			// Continue after the last key inspected in the previous chunk.
+			StartAfter: resumeAfter,
 		})

Set resumeAfter to a copy of iter.Key() for the last inspected entry before you break out of the inner loop. Use the option name that datastore.IterOptions exposes for an exclusive start bound.

🤖 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 `@internal/db/collection_purge.go` around lines 275 - 318, Update the purge
loop around the datastore iterator to retain a copy of the last inspected
iterator key when the non-transactional chunk limit is reached, then pass it as
the exclusive resume bound in the next datastore.IterOptions call. Preserve the
initial collection prefix, transactional behavior, deletion flow, and completion
handling while ensuring subsequent chunks do not rescan previously inspected
entries.
internal/db/collection_purge_test.go (1)

135-135: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the transaction-limit failure without matching a Badger message string.

Badger already exposes badgerds.ErrTxnTooBig for this condition, so the test should assert that sentinel instead of "Txn is too big".

🤖 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 `@internal/db/collection_purge_test.go` at line 135, Update the
transaction-limit assertion in the purge test to verify the returned error
matches Badger’s badgerds.ErrTxnTooBig sentinel, replacing the brittle
message-string check while preserving the existing failure assertion.
🤖 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/integration/acp/nac/purge_document_test.go`:
- Around line 58-63: Update
tests/integration/acp/nac/purge_document_test.go:58-63 to retain or rename the
missing-identity preflight case and add a separate caller with collection-get
but without purge-document, asserting the purge-specific denial; at 82-87 grant
collection-get to the wrong identity while withholding purge-document and add
the corresponding successful grant case. Update
tests/integration/acp/nac/relation_admin/purge_document_test.go:35-40 so the
initial relation grants only collection-get, then grant the permission
authorizing purge and verify success.

In `@tests/integration/searchable_encryption/purge_test.go`:
- Around line 62-79: Update the purge test’s post-purge requests so the empty
searchable-encryption result is queried from node 1, matching the node targeted
by PurgeDocs. Add a separate node-0 assertion that queries the same record and
confirms it remains available, preserving the local, non-replicated purge
behavior.

---

Nitpick comments:
In `@internal/db/collection_purge_leveldb_test.go`:
- Around line 41-56: Register db.Close with t.Cleanup in newLevelDBForPurgeTest
so the database closes on both completion and timeout paths. Remove db.Close
from requireLevelDBOperationCompletes, drop its now-unused db parameter, and
update both call sites to pass only the testing handle and operation.

In `@internal/db/collection_purge_test.go`:
- Line 135: Update the transaction-limit assertion in the purge test to verify
the returned error matches Badger’s badgerds.ErrTxnTooBig sentinel, replacing
the brittle message-string check while preserving the existing failure
assertion.

In `@internal/db/collection_purge.go`:
- Around line 275-318: Update the purge loop around the datastore iterator to
retain a copy of the last inspected iterator key when the non-transactional
chunk limit is reached, then pass it as the exclusive resume bound in the next
datastore.IterOptions call. Preserve the initial collection prefix,
transactional behavior, deletion flow, and completion handling while ensuring
subsequent chunks do not rescan previously inspected entries.
🪄 Autofix

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: ead081c4-5dcc-4b2b-ad8b-5b428434a86f

📥 Commits

Reviewing files that changed from the base of the PR and between b012152 and e1194e6.

📒 Files selected for processing (50)
  • .github/known-vulnerabilities.txt
  • .github/workflows/check-vulnerabilities.yml
  • .github/workflows/test-macos.yml
  • Makefile
  • acp/types/types.go
  • cbindings/collection_purge.go
  • cbindings/wrapper_collection.go
  • cli/collection.go
  • cli/collection_purge_docs.go
  • cli/test/integration/p2p/replicator_list_test.go
  • cli/wizard/unit_test.go
  • client/collection.go
  • client/mocks/collection.go
  • client/options/collection.go
  • docs/website/references/cli/defradb_client_collection.md
  • docs/website/references/cli/defradb_client_collection_purge-docs.md
  • go.mod
  • http/client_collection.go
  • http/errors.go
  • http/errors_test.go
  • http/handler_collection.go
  • internal/db/collection_index.go
  • internal/db/collection_purge.go
  • internal/db/collection_purge_conflict_test.go
  • internal/db/collection_purge_leveldb_test.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_truncate.go
  • internal/db/db.go
  • internal/db/db_test.go
  • internal/db/errors.go
  • internal/db/id/document.go
  • internal/db/id/document_test.go
  • internal/db/p2p/p2p.go
  • internal/db/p2p/p2p_test.go
  • internal/db/p2p/sync_branchable_col.go
  • internal/db/p2p/sync_doc.go
  • internal/db/txn_collection.go
  • js/client_collection.go
  • tests/action/active_peers.go
  • tests/action/delete_index.go
  • tests/action/purge_docs.go
  • tests/clients/cli/wrapper_collection.go
  • tests/clients/js/wrapper_collection.go
  • tests/integration/acp/dac/purge_test.go
  • tests/integration/acp/nac/purge_document_test.go
  • tests/integration/acp/nac/relation_admin/purge_document_test.go
  • tests/integration/net/info/connect_peers_test.go
  • tests/integration/net/sync/documents_test.go
  • tests/integration/searchable_encryption/purge_test.go
  • tests/integration/utils.go
💤 Files with no reviewable changes (1)
  • tests/integration/net/info/connect_peers_test.go
🚧 Files skipped from review as they are similar to previous changes (9)
  • tests/clients/cli/wrapper_collection.go
  • docs/website/references/cli/defradb_client_collection_purge-docs.md
  • js/client_collection.go
  • cli/collection_purge_docs.go
  • internal/db/txn_collection.go
  • docs/website/references/cli/defradb_client_collection.md
  • http/handler_collection.go
  • cbindings/wrapper_collection.go
  • internal/db/id/document_test.go
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Check data format changes job
  • GitHub Check: Test macos job
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2026-03-27T08:24:16.083Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4661
File: http/middleware.go:93-93
Timestamp: 2026-03-27T08:24:16.083Z
Learning: When handling `client.ErrNotAuthorizedToPerformOperation` in the defradb repository, treat it as an unauthenticated/missing-identity condition (not insufficient permissions). Map it to HTTP 401 Unauthorized rather than 403 Forbidden; this mapping is intentional and consistent with prior behavior (pre-PR `#4661`).

Applied to files:

  • cli/test/integration/p2p/replicator_list_test.go
  • http/errors_test.go
  • cli/collection.go
  • internal/db/p2p/sync_branchable_col.go
  • internal/db/collection_purge_leveldb_test.go
  • internal/db/errors.go
  • tests/action/delete_index.go
  • tests/integration/acp/nac/relation_admin/purge_document_test.go
  • tests/integration/acp/nac/purge_document_test.go
  • tests/integration/net/sync/documents_test.go
  • http/errors.go
  • internal/db/collection_purge_conflict_test.go
  • internal/db/db.go
  • tests/action/purge_docs.go
  • internal/db/p2p/sync_doc.go
  • internal/db/db_test.go
  • cbindings/collection_purge.go
  • internal/db/p2p/p2p.go
  • acp/types/types.go
  • client/options/collection.go
  • http/client_collection.go
  • tests/integration/searchable_encryption/purge_test.go
  • client/collection.go
  • tests/integration/acp/dac/purge_test.go
  • internal/db/p2p/p2p_test.go
  • tests/action/active_peers.go
  • tests/integration/utils.go
  • tests/clients/js/wrapper_collection.go
  • internal/db/collection_purge.go
  • internal/db/collection_truncate.go
  • client/mocks/collection.go
  • cli/wizard/unit_test.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_index.go
  • internal/db/id/document.go
📚 Learning: 2026-06-18T16:47:47.339Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4942
File: internal/db/db.go:227-231
Timestamp: 2026-06-18T16:47:47.339Z
Learning: When reviewing this repository’s Go code, do not flag `sync.WaitGroup.Go()` (e.g., `wg.Go(fn)`) as a compilation error. This method exists starting in Go 1.25; it should be treated as valid as long as the repo’s configured/minimum Go toolchain version is 1.25+ (e.g., per `go.mod` and/or CI). If the project is building with an older Go version, then it may be appropriate to flag it.

Applied to files:

  • cli/test/integration/p2p/replicator_list_test.go
  • http/errors_test.go
  • cli/collection.go
  • internal/db/p2p/sync_branchable_col.go
  • internal/db/collection_purge_leveldb_test.go
  • internal/db/errors.go
  • tests/action/delete_index.go
  • tests/integration/acp/nac/relation_admin/purge_document_test.go
  • tests/integration/acp/nac/purge_document_test.go
  • tests/integration/net/sync/documents_test.go
  • http/errors.go
  • internal/db/collection_purge_conflict_test.go
  • internal/db/db.go
  • tests/action/purge_docs.go
  • internal/db/p2p/sync_doc.go
  • internal/db/db_test.go
  • cbindings/collection_purge.go
  • internal/db/p2p/p2p.go
  • acp/types/types.go
  • client/options/collection.go
  • http/client_collection.go
  • tests/integration/searchable_encryption/purge_test.go
  • client/collection.go
  • tests/integration/acp/dac/purge_test.go
  • internal/db/p2p/p2p_test.go
  • tests/action/active_peers.go
  • tests/integration/utils.go
  • tests/clients/js/wrapper_collection.go
  • internal/db/collection_purge.go
  • internal/db/collection_truncate.go
  • client/mocks/collection.go
  • cli/wizard/unit_test.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_index.go
  • internal/db/id/document.go
📚 Learning: 2026-06-18T16:47:47.339Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4942
File: internal/db/db.go:227-231
Timestamp: 2026-06-18T16:47:47.339Z
Learning: In sourcenetwork/defradb code reviews, do not raise findings that are likely compiler/type-check errors (e.g., code that would fail `go test`/`go build`) because CI pipelines will catch compilation failures. Only flag compilation-related problems if there is a clear, verifiable issue beyond what CI will already surface (e.g., a mismatched build tag or missing generated artifact that CI would not cover).

Applied to files:

  • cli/test/integration/p2p/replicator_list_test.go
  • http/errors_test.go
  • cli/collection.go
  • internal/db/p2p/sync_branchable_col.go
  • internal/db/collection_purge_leveldb_test.go
  • internal/db/errors.go
  • tests/action/delete_index.go
  • tests/integration/acp/nac/relation_admin/purge_document_test.go
  • tests/integration/acp/nac/purge_document_test.go
  • tests/integration/net/sync/documents_test.go
  • http/errors.go
  • internal/db/collection_purge_conflict_test.go
  • internal/db/db.go
  • tests/action/purge_docs.go
  • internal/db/p2p/sync_doc.go
  • internal/db/db_test.go
  • cbindings/collection_purge.go
  • internal/db/p2p/p2p.go
  • acp/types/types.go
  • client/options/collection.go
  • http/client_collection.go
  • tests/integration/searchable_encryption/purge_test.go
  • client/collection.go
  • tests/integration/acp/dac/purge_test.go
  • internal/db/p2p/p2p_test.go
  • tests/action/active_peers.go
  • tests/integration/utils.go
  • tests/clients/js/wrapper_collection.go
  • internal/db/collection_purge.go
  • internal/db/collection_truncate.go
  • client/mocks/collection.go
  • cli/wizard/unit_test.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_index.go
  • internal/db/id/document.go
📚 Learning: 2026-06-06T20:14:54.888Z
Learnt from: fredcarle
Repo: sourcenetwork/defradb PR: 4879
File: cli/test/integration/p2p/disconnect_test.go:46-67
Timestamp: 2026-06-06T20:14:54.888Z
Learning: In sourcenetwork/defradb, tests under cli/test/integration/p2p/ are intentionally limited to CLI command-level validation (e.g., argument parsing, command error handling, and user-facing error messages). Do not add assertions that require actual P2P connection state (e.g., verifying peers after connect/disconnect). For end-to-end connection-state verification (connect → disconnect → assert active peers are empty), add/extend tests in tests/integration/net/info/ (e.g., TestNetInfoDisconnectSinglePeer / TestNetInfoDisconnectMultiplePeers).

Applied to files:

  • cli/test/integration/p2p/replicator_list_test.go
📚 Learning: 2026-08-04T14:08:52.524Z
Learnt from: ChrisBQu
Repo: sourcenetwork/defradb PR: 5099
File: tests/clients/java/wrapper_collection.go:228-271
Timestamp: 2026-08-04T14:08:52.524Z
Learning: In DefraDB client batch-document insertion paths, return successfully when the document list is empty before JSON marshaling. In Go, marshaling a nil slice produces `null`, which must not be sent as an add-document payload; apply equivalent empty-input handling in the C bindings path.

Applied to files:

  • tests/clients/js/wrapper_collection.go
🪛 GitHub Check: codecov/patch
internal/db/p2p/p2p.go

[warning] 290-290: internal/db/p2p/p2p.go#L290
Added line #L290 was not covered by tests


[warning] 297-297: internal/db/p2p/p2p.go#L297
Added line #L297 was not covered by tests

internal/db/collection_purge.go

[warning] 54-54: internal/db/collection_purge.go#L54
Added line #L54 was not covered by tests


[warning] 73-73: internal/db/collection_purge.go#L73
Added line #L73 was not covered by tests


[warning] 81-81: internal/db/collection_purge.go#L81
Added line #L81 was not covered by tests


[warning] 87-87: internal/db/collection_purge.go#L87
Added line #L87 was not covered by tests


[warning] 90-90: internal/db/collection_purge.go#L90
Added line #L90 was not covered by tests


[warning] 98-98: internal/db/collection_purge.go#L98
Added line #L98 was not covered by tests


[warning] 106-106: internal/db/collection_purge.go#L106
Added line #L106 was not covered by tests


[warning] 132-132: internal/db/collection_purge.go#L132
Added line #L132 was not covered by tests


[warning] 157-157: internal/db/collection_purge.go#L157
Added line #L157 was not covered by tests


[warning] 160-160: internal/db/collection_purge.go#L160
Added line #L160 was not covered by tests


[warning] 189-189: internal/db/collection_purge.go#L189
Added line #L189 was not covered by tests


[warning] 195-195: internal/db/collection_purge.go#L195
Added line #L195 was not covered by tests


[warning] 202-202: internal/db/collection_purge.go#L202
Added line #L202 was not covered by tests


[warning] 221-221: internal/db/collection_purge.go#L221
Added line #L221 was not covered by tests


[warning] 230-230: internal/db/collection_purge.go#L230
Added line #L230 was not covered by tests


[warning] 240-240: internal/db/collection_purge.go#L240
Added line #L240 was not covered by tests


[warning] 250-250: internal/db/collection_purge.go#L250
Added line #L250 was not covered by tests


[warning] 259-259: internal/db/collection_purge.go#L259
Added line #L259 was not covered by tests


[warning] 270-270: internal/db/collection_purge.go#L270
Added line #L270 was not covered by tests


[warning] 281-281: internal/db/collection_purge.go#L281
Added line #L281 was not covered by tests


[warning] 289-289: internal/db/collection_purge.go#L289
Added line #L289 was not covered by tests


[warning] 296-296: internal/db/collection_purge.go#L296
Added line #L296 was not covered by tests


[warning] 301-302: internal/db/collection_purge.go#L301-L302
Added lines #L301 - L302 were not covered by tests


[warning] 307-307: internal/db/collection_purge.go#L307
Added line #L307 was not covered by tests


[warning] 312-312: internal/db/collection_purge.go#L312
Added line #L312 was not covered by tests

internal/db/collection_truncate.go

[warning] 300-303: internal/db/collection_truncate.go#L300-L303
Added lines #L300 - L303 were not covered by tests


[warning] 529-529: internal/db/collection_truncate.go#L529
Added line #L529 was not covered by tests


[warning] 535-535: internal/db/collection_truncate.go#L535
Added line #L535 was not covered by tests


[warning] 573-573: internal/db/collection_truncate.go#L573
Added line #L573 was not covered by tests


[warning] 587-587: internal/db/collection_truncate.go#L587
Added line #L587 was not covered by tests

internal/db/collection_index.go

[warning] 399-399: internal/db/collection_index.go#L399
Added line #L399 was not covered by tests


[warning] 404-404: internal/db/collection_index.go#L404
Added line #L404 was not covered by tests


[warning] 407-407: internal/db/collection_index.go#L407
Added line #L407 was not covered by tests

internal/db/id/document.go

[warning] 280-280: internal/db/id/document.go#L280
Added line #L280 was not covered by tests


[warning] 287-287: internal/db/id/document.go#L287
Added line #L287 was not covered by tests


[warning] 294-294: internal/db/id/document.go#L294
Added line #L294 was not covered by tests


[warning] 302-302: internal/db/id/document.go#L302
Added line #L302 was not covered by tests


[warning] 315-315: internal/db/id/document.go#L315
Added line #L315 was not covered by tests


[warning] 333-333: internal/db/id/document.go#L333
Added line #L333 was not covered by tests

🔇 Additional comments (51)
internal/db/db.go (1)

25-25: LGTM!

Also applies to: 120-120, 267-291

internal/db/db_test.go (1)

21-21: LGTM!

Also applies to: 75-109

go.mod (1)

3-3: LGTM!

.github/known-vulnerabilities.txt (1)

1-6: LGTM!

.github/workflows/check-vulnerabilities.yml (1)

50-55: LGTM!

cli/wizard/unit_test.go (1)

250-287: LGTM!

Also applies to: 316-325, 358-376, 424-446, 495-517, 568-590, 653-695

internal/db/collection_index.go (3)

14-14: LGTM!

Also applies to: 32-32


117-124: LGTM!


350-410: LGTM!

internal/db/id/document.go (2)

202-237: LGTM!


267-351: LGTM!

http/client_collection.go (1)

224-264: LGTM!

http/errors.go (1)

174-188: LGTM!

http/errors_test.go (1)

65-78: LGTM!

cli/collection.go (1)

22-28: LGTM!

tests/integration/acp/nac/purge_document_test.go (1)

22-43: LGTM!

tests/clients/js/wrapper_collection.go (1)

160-176: LGTM!

tests/action/purge_docs.go (1)

62-62: LGTM!

tests/integration/acp/dac/purge_test.go (1)

21-83: LGTM!

tests/integration/net/sync/documents_test.go (1)

54-59: LGTM!

Also applies to: 130-135, 210-215, 377-382

cbindings/collection_purge.go (1)

29-82: LGTM!

tests/integration/utils.go (1)

304-304: LGTM!

Also applies to: 366-366, 700-707, 843-848, 1006-1015, 1029-1029, 1057-1057, 1262-1301, 2394-2394

Makefile (1)

71-71: LGTM!

Also applies to: 327-327, 386-394

.github/workflows/test-macos.yml (1)

79-84: LGTM!

cli/test/integration/p2p/replicator_list_test.go (1)

15-15: LGTM!

Also applies to: 135-135

tests/action/delete_index.go (1)

105-107: LGTM!

tests/action/active_peers.go (1)

15-17: LGTM!

Also applies to: 26-29, 73-85

internal/db/p2p/p2p_test.go (1)

19-51: LGTM!

internal/db/p2p/p2p.go (1)

24-24: LGTM!

Also applies to: 287-303

internal/db/p2p/sync_branchable_col.go (1)

93-100: LGTM!

internal/db/p2p/sync_doc.go (1)

97-104: LGTM!

client/collection.go (1)

193-204: LGTM!

client/options/collection.go (1)

438-465: LGTM!

internal/db/collection_purge.go (6)

41-64: LGTM!


66-111: LGTM!


138-210: LGTM!


212-262: LGTM!


345-345: LGTM!


113-136: 🩺 Stability & Availability

No change needed. Committing a chunk transaction does not release the collection lock because lock lifecycle callbacks are attached to lockTxn; the derived chunk transaction has the same ID but does not reuse the same lock-set entry or callbacks.

internal/db/errors.go (1)

109-109: LGTM!

Also applies to: 245-245

acp/types/types.go (2)

231-232: LGTM!


125-125: 🔒 Security & Privacy

Authorization Bypass (CWE-863): Incorrect Authorization

Reachability: External

Verify that the permission constant and the permission-name list stay index-aligned.

NodePurgeDocumentPerm is appended at the end of the constant block, and "purge-document" is appended at the end of RequiredResourcePermissionsForNode. If the constant-to-name conversion uses the constant's ordinal as an index into this slice, the two orderings must match for every entry. A mismatch would map the purge permission to a different policy permission and authorize purge under the wrong rule.

Confirm how the node permission constant is converted to its resource permission name.

#!/bin/bash
# Confirm the ordering of node permission constants and how they map to names.
set -euo pipefail

rg -nP -B4 -A60 'NodeBypassDACPerm|NodeResourcePermission\b' acp/types/types.go | head -120

rg -nP -C6 'RequiredResourcePermissionsForNode' --type=go

rg -nP -C8 '\bfunc .*(String|Name)\s*\(\).*(string)' acp/types/types.go

rg -nP -C6 'NodePurgeDocumentPerm' --type=go

Also applies to: 182-182

client/mocks/collection.go (1)

1063-1138: LGTM!

internal/db/collection_purge_test.go (2)

109-134: LGTM!

Also applies to: 136-154


156-183: LGTM!

Also applies to: 185-238, 240-311, 313-355, 542-552, 585-611

internal/db/collection_purge_conflict_test.go (1)

25-57: LGTM!

internal/db/collection_truncate.go (3)

300-307: LGTM!


470-569: LGTM!


571-586: 🩺 Stability & Availability

Verify DeleteBlock is idempotent before relying on purge resumption.

deleteBlocks deletes encryption blocks before post-order blocks, then releases owner mappings. If a later DeleteBlock call fails and DeleteBlock propagates missing CIDs instead of ignoring them, a resumed purge can call DeleteBlock again on an already-deleted encryption or signature CID and return early before cleaning remaining blocks. Confirm the v0.3.1 github.com/sourcenetwork/corekv/blockstore implementation ignores missing CIDs, or add local ipld.ErrNotFound/corekv.ErrNotFound handling at these calls.

internal/db/collection_purge_leveldb_test.go (2)

29-39: LGTM!


58-124: LGTM!

Comment thread tests/integration/acp/nac/purge_document_test.go Outdated
Comment thread tests/integration/searchable_encryption/purge_test.go Outdated
@iverc

iverc commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the final review pass in 50ac61e: the SE cleanup scan now resumes within the collection range, block cleanup explicitly ignores missing blocks during retries, LevelDB cleanup runs on timeout, and both Badger limit checks use the sentinel. The direct NAC test also verifies the exact purge-document permission before and after an admin grant. Focused unit and integration tests pass under -race; lint reports 0 issues.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

@iverc: I will review the updated changes in commit 50ac61edf.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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 (1)
internal/db/collection_purge_test.go (1)

141-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert that a denied purge does not modify the document.

Lines 141-143 only verify the returned error. A purge that deletes the document before returning client.ErrNotAuthorizedToPerformOperation would pass this test. Before granting the admin relationship, assert that the owner can still find doc.ID().

Proposed test assertion
 	require.ErrorIs(t, err, client.ErrNotAuthorizedToPerformOperation)
 	require.ErrorContains(t, err, "Permission: purge-document")
+	exists, err := col.ExistsDocument(
+		ctx,
+		doc.ID(),
+		options.ExistsDocument().SetIdentity(owner),
+	)
+	require.NoError(t, err)
+	require.True(t, exists)
 
 	_, err = db.AddNACActorRelationship(
🤖 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 `@internal/db/collection_purge_test.go` around lines 141 - 143, Extend the
denied-purge test around the existing error assertions to verify the document
remains unchanged: before granting the admin relationship, use the owner client
to find doc.ID() and assert that lookup succeeds. Keep the existing
authorization and permission error checks intact.
🤖 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 `@internal/db/collection_purge_test.go`:
- Around line 141-143: Extend the denied-purge test around the existing error
assertions to verify the document remains unchanged: before granting the admin
relationship, use the owner client to find doc.ID() and assert that lookup
succeeds. Keep the existing authorization and permission error checks intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 33b0cf01-4c5a-4909-9d9d-a0d26d121a2a

📥 Commits

Reviewing files that changed from the base of the PR and between e1194e6 and 50ac61e.

📒 Files selected for processing (10)
  • internal/db/collection_purge.go
  • internal/db/collection_purge_leveldb_test.go
  • internal/db/collection_purge_test.go
  • internal/db/collection_truncate.go
  • internal/db/collection_truncate_test.go
  • internal/db/p2p/p2p_test.go
  • internal/keys/datastore_se.go
  • internal/keys/key.go
  • tests/integration/acp/nac/purge_document_test.go
  • tests/integration/searchable_encryption/purge_test.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • internal/db/collection_purge_leveldb_test.go
  • tests/integration/searchable_encryption/purge_test.go
  • tests/integration/acp/nac/purge_document_test.go
  • internal/db/collection_truncate.go
  • internal/db/collection_purge.go
📜 Review details
⏰ Context from checks skipped due to timeout. (51)
  • GitHub Check: Test macos job
  • GitHub Check: Test Limited Resource job
  • GitHub Check: Check data format changes job
  • GitHub Check: Test coverage job (c, memory, collection-named)
  • GitHub Check: Test coverage job (c, file, collection-save)
  • GitHub Check: Test coverage job (cli, memory, collection-named)
  • GitHub Check: Test coverage job (c, file, gql)
  • GitHub Check: Test coverage job (cli, file, gql)
  • GitHub Check: Test coverage job (http, file, collection-save)
  • GitHub Check: Test coverage job (c, memory, gql)
  • GitHub Check: Test coverage job (cli, file, collection-named)
  • GitHub Check: Test coverage job (http, memory, gql)
  • GitHub Check: Test coverage job (cli, file, collection-save)
  • GitHub Check: Test coverage job (c, memory, collection-save)
  • GitHub Check: Test coverage job (cli, memory, collection-save)
  • GitHub Check: Test coverage job (c, file, collection-named)
  • GitHub Check: Test coverage job (http, file, collection-named)
  • GitHub Check: Test coverage job (http, memory, collection-named)
  • GitHub Check: Check mocks job
  • GitHub Check: Test coverage job (cli, memory, gql)
  • GitHub Check: Test coverage job (http, file, gql)
  • GitHub Check: Test coverage job (go, file, gql)
  • GitHub Check: Test coverage job (http, memory, collection-save)
  • GitHub Check: Test coverage job (go, memory, gql)
  • GitHub Check: Test coverage job (go, file, collection-named)
  • GitHub Check: Test coverage job (go, memory, collection-save)
  • GitHub Check: Test coverage job (go, file, collection-save)
  • GitHub Check: Test coverage job (go, memory, collection-named)
  • GitHub Check: Test coverage view job
  • GitHub Check: Test coverage document acp job (c, source-hub)
  • GitHub Check: Test coverage signed docs job
  • GitHub Check: Test coverage lens job (wazero)
  • GitHub Check: Test coverage telemetry job
  • GitHub Check: Test coverage leveldb job
  • GitHub Check: Test coverage document acp job (http, source-hub)
  • GitHub Check: Start binary job
  • GitHub Check: Test coverage JS job
  • GitHub Check: Test coverage document acp job (go, source-hub)
  • GitHub Check: Test coverage document acp job (cli, source-hub)
  • GitHub Check: Test coverage secondary index job
  • GitHub Check: Test coverage encryption job
  • GitHub Check: Build, install, and test Debian package
  • GitHub Check: Validate containerfile job
  • GitHub Check: Check vulnerabilities job
  • GitHub Check: Build dependencies job
  • GitHub Check: Lint GoLang job
  • GitHub Check: Check wizard health job
  • GitHub Check: Check cli documentation job
  • GitHub Check: Build and test Linux C shared library
  • GitHub Check: Check http documentation job
  • GitHub Check: Lint GoLang job
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-03-27T08:24:16.083Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4661
File: http/middleware.go:93-93
Timestamp: 2026-03-27T08:24:16.083Z
Learning: When handling `client.ErrNotAuthorizedToPerformOperation` in the defradb repository, treat it as an unauthenticated/missing-identity condition (not insufficient permissions). Map it to HTTP 401 Unauthorized rather than 403 Forbidden; this mapping is intentional and consistent with prior behavior (pre-PR `#4661`).

Applied to files:

  • internal/keys/datastore_se.go
  • internal/keys/key.go
  • internal/db/collection_truncate_test.go
  • internal/db/p2p/p2p_test.go
  • internal/db/collection_purge_test.go
📚 Learning: 2026-06-18T16:47:47.339Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4942
File: internal/db/db.go:227-231
Timestamp: 2026-06-18T16:47:47.339Z
Learning: When reviewing this repository’s Go code, do not flag `sync.WaitGroup.Go()` (e.g., `wg.Go(fn)`) as a compilation error. This method exists starting in Go 1.25; it should be treated as valid as long as the repo’s configured/minimum Go toolchain version is 1.25+ (e.g., per `go.mod` and/or CI). If the project is building with an older Go version, then it may be appropriate to flag it.

Applied to files:

  • internal/keys/datastore_se.go
  • internal/keys/key.go
  • internal/db/collection_truncate_test.go
  • internal/db/p2p/p2p_test.go
  • internal/db/collection_purge_test.go
📚 Learning: 2026-06-18T16:47:47.339Z
Learnt from: islamaliev
Repo: sourcenetwork/defradb PR: 4942
File: internal/db/db.go:227-231
Timestamp: 2026-06-18T16:47:47.339Z
Learning: In sourcenetwork/defradb code reviews, do not raise findings that are likely compiler/type-check errors (e.g., code that would fail `go test`/`go build`) because CI pipelines will catch compilation failures. Only flag compilation-related problems if there is a clear, verifiable issue beyond what CI will already surface (e.g., a mismatched build tag or missing generated artifact that CI would not cover).

Applied to files:

  • internal/keys/datastore_se.go
  • internal/keys/key.go
  • internal/db/collection_truncate_test.go
  • internal/db/p2p/p2p_test.go
  • internal/db/collection_purge_test.go
🔇 Additional comments (8)
internal/db/collection_truncate_test.go (1)

15-58: LGTM!

internal/keys/datastore_se.go (1)

36-36: LGTM!

Also applies to: 76-78

internal/keys/key.go (1)

31-47: LGTM!

internal/db/p2p/p2p_test.go (1)

25-37: LGTM!

Also applies to: 39-52, 54-61, 63-71

internal/db/collection_purge_test.go (4)

25-25: LGTM!

Also applies to: 34-34


60-109: LGTM!


159-204: LGTM!


290-339: LGTM!

@AndrewSisley AndrewSisley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey Ivan, I'm not sure we want to expose this behaviour in this format - I've opened a discussion on discord, please do not merge this until the team has reached a decision.

@iverc
iverc force-pushed the iverc/purge-by-doc-ids branch from fc0e2d8 to 4d47281 Compare August 21, 2026 03:17
@iverc iverc changed the title feat: Add targeted document purge feat: Add filtered collection truncate Aug 21, 2026
@iverc
iverc requested review from a team and AndrewSisley August 21, 2026 03:22

@AndrewSisley AndrewSisley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is looking good, thank you very much Ivan! Just a handful of smaller requests from me before merge.

Comment thread tests/integration/collection/truncate/simple_test.go Outdated
Comment thread tests/integration/collection/truncate/simple_test.go Outdated
Comment thread tests/integration/mutation/truncate/simple_test.go
Comment thread client/options/collection.go Outdated
Comment thread internal/request/graphql/schema/generate.go Outdated
Comment thread client/collection.go
Comment thread cbindings/collection_truncate.go
Comment thread cbindings/collection_truncate.go
Comment thread internal/planner/operation.go
Comment thread internal/planner/explain.go Outdated
@iverc

iverc commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Is looking good, thank you very much Ivan! Just a handful of smaller requests from me before merge.

Thank you so much, @AndrewSisley . Addressing the feedback!

@iverc
iverc force-pushed the iverc/purge-by-doc-ids branch from 32a10f6 to bc4065d Compare August 26, 2026 20:02
@iverc
iverc requested a review from AndrewSisley August 26, 2026 20:08
Comment thread client/options/collection.go

@AndrewSisley AndrewSisley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great to me, thanks for all the extra effort on this one Ivan.

Approving now, but please make sure PruneHistory is removed before merge (for ref. discussed over discord), and please expand the documentation on the filter option.

@iverc

iverc commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Looks great to me, thanks for all the extra effort on this one Ivan.

Approving now, but please make sure PruneHistory is removed before merge (for ref. discussed over discord), and please expand the documentation on the filter option.

Thank you! Removed PruneHistory option: 85dca42

@iverc iverc added this to the DefraDB v1.1 milestone Aug 27, 2026
@iverc iverc added feature New feature or request area/collections Related to the collections system labels Aug 27, 2026
@iverc
iverc requested review from shahzadlone and removed request for shahzadlone August 27, 2026 02:04
@iverc
iverc force-pushed the iverc/purge-by-doc-ids branch from 59fe922 to b408367 Compare August 27, 2026 02:07
@shahzadlone
shahzadlone dismissed their stale review August 27, 2026 08:23

Has an approval and seems to block some things

@iverc
iverc merged commit 6ada504 into develop Aug 27, 2026
59 of 63 checks passed
@iverc
iverc deleted the iverc/purge-by-doc-ids branch August 27, 2026 08:24
@islamaliev

Copy link
Copy Markdown
Contributor

Bug bash results:
tested against real defradb running locally. Everything is working properly but I wonder if filter: {} should remove all the docs. This is how it works now.

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

Labels

area/collections Related to the collections system feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support filtered collection truncate

4 participants