Skip to content

feat: Log per-object warehouse delivery outcomes - #8170

Merged
gagantrivedi merged 7 commits into
mainfrom
feat/warehouse-delivery-audit-ledger
Jul 31, 2026
Merged

feat: Log per-object warehouse delivery outcomes#8170
gagantrivedi merged 7 commits into
mainfrom
feat/warehouse-delivery-audit-ledger

Conversation

@gagantrivedi

@gagantrivedi gagantrivedi commented Jul 31, 2026

Copy link
Copy Markdown
Member

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #8149

  • New WarehouseDeliveryLog model: an append-only audit of each delivered or rejected event object, with the rows written and the warehouse's rejection error.
  • The delivery loop writes one row per object after its S3 move; the prefix state machine is unchanged.
  • No unique constraint on (connection, s3_key): at-least-once redelivery legitimately logs an object twice.
  • A daily recurring task deletes logs older than 60 days.

Retries and concurrency control from #8149 are not part of this PR.

How did you test this code?

Delivery task tests assert the exact log contents for delivered and rejected objects, plus retention cleanup; 36 task tests pass.

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 31, 2026 8:51am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ignored Ignored Preview Jul 31, 2026 8:51am
flagsmith-frontend-staging Ignored Ignored Preview Jul 31, 2026 8:51am

Request Review

@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates feature New feature or request and removed docs Documentation updates labels Jul 31, 2026
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.71%. Comparing base (6cf55a4) to head (70b890e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8170   +/-   ##
=======================================
  Coverage   98.71%   98.71%           
=======================================
  Files        1530     1531    +1     
  Lines       61201    61234   +33     
=======================================
+ Hits        60413    60446   +33     
  Misses        788      788           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 35805f1f-2a27-4ade-aef0-ce7de60d2430

📥 Commits

Reviewing files that changed from the base of the PR and between 8e95db0 and 70b890e.

📒 Files selected for processing (1)
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md

📝 Walkthrough

Walkthrough

The change adds persistent warehouse delivery logs with delivered and rejected outcomes. Each log stores the connection, S3 key, row count, error details, and creation time. A daily task deletes logs older than 60 days. Unit tests cover successful delivery, rejected delivery, and retention cleanup. Observability documentation now contains updated source-code references.

Estimated code review effort: 3 (Moderate) | ~20 minutes


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.

@github-actions github-actions Bot added the docs Documentation updates label Jul 31, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 31, 2026
@gagantrivedi
gagantrivedi marked this pull request as ready for review July 31, 2026 07:59
@gagantrivedi
gagantrivedi requested review from a team as code owners July 31, 2026 07:59
@gagantrivedi
gagantrivedi requested review from emyller and removed request for a team July 31, 2026 07:59
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-8170 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-8170 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-8170 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8170 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8170 Finished ✅ Results

@gagantrivedi
gagantrivedi requested review from Zaimwa9 and removed request for emyller July 31, 2026 08:00
@gagantrivedi

Copy link
Copy Markdown
Member Author

@coderabbitai review

@gagantrivedi

Copy link
Copy Markdown
Member Author

@themis-blindfold review

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-16 — run #18894 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  56.9 seconds
commit  8e95db0
info  🔄 Run: #18894 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #18894 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  36.8 seconds
commit  8e95db0
info  🔄 Run: #18894 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #18895 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.3 seconds
commit  70b890e
info  🔄 Run: #18895 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #18894 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  43.9 seconds
commit  8e95db0
info  🔄 Run: #18894 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #18894 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  41 seconds
commit  8e95db0
info  🔄 Run: #18894 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #18895 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.1 seconds
commit  70b890e
info  🔄 Run: #18895 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #18892 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute, 4 seconds
commit  90ffeb4
info  🔄 Run: #18892 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #18892 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  4 passed

Details

stats  4 tests across 3 suites
duration  10.4 seconds
commit  90ffeb4
info  🔄 Run: #18892 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #18893 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  47.6 seconds
commit  e48f592
info  🔄 Run: #18893 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #18892 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  43.7 seconds
commit  90ffeb4
info  🔄 Run: #18892 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #18893 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  32.7 seconds
commit  e48f592
info  🔄 Run: #18893 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #18892 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  32.4 seconds
commit  90ffeb4
info  🔄 Run: #18892 (attempt 1)

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

@coderabbitai

coderabbitai Bot commented Jul 31, 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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1b53207f-652a-4db7-a7a0-3b1b0c011494

📥 Commits

Reviewing files that changed from the base of the PR and between fd78b2b and 0dac30b.

📒 Files selected for processing (7)
  • api/experimentation/constants.py
  • api/experimentation/migrations/0012_warehouse_delivery_log.py
  • api/experimentation/models.py
  • api/experimentation/services.py
  • api/experimentation/tasks.py
  • api/tests/unit/experimentation/test_tasks.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md

Comment thread api/experimentation/models.py
Comment thread api/experimentation/services.py
@Zaimwa9

Zaimwa9 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@themis-blindfold review

@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 31, 2026
@themis-blindfold

Copy link
Copy Markdown
Contributor

⚖️ Themis review: ✅ Ship it

Append-only audit log for per-object warehouse delivery outcomes, with a daily 60-day retention cleanup. The new WarehouseDeliveryLog model records delivered and rejected objects with their row count and error details. One row is written after each S3 move in _deliver_pending_objects, so the existing prefix state machine is untouched. Tests cover delivered, rejected, and retention-cleanup paths; CI is green across all checks.

Area Score
🎯 Correctness 5/5
🧪 Test coverage 5/5
📐 Code quality 4/5
🚀 Product impact 3/5
📝 Walkthrough
  • Model + migration — new WarehouseDeliveryLog with (connection, created_at) composite index; outcome enum, nullable rows_count for deliveries, nullable error for rejections.
  • Delivery loop_deliver_pending_objects captures the per-object row count in a local, writes a log row after each move, and defers the running total increment.
  • Retention taskclean_up_old_warehouse_delivery_logs runs daily, deleting rows older than the 60-day DELIVERY_LOG_RETENTION constant.
  • Tests — existing delivery tests extended with ledger assertions; new test for the cleanup task covering both expired and recent logs.
  • Docs — events catalogue line numbers updated to reflect the inserted code.
🧪 How to verify
  1. Run the delivery task tests: pytest api/tests/unit/experimentation/test_tasks.py -k "deliver_events_for_connection or clean_up_old_warehouse" -v
  2. Confirm the migration applies cleanly: python manage.py migrate experimentation --check
  3. Inspect the generated SQL to confirm the composite index: python manage.py sqlmigrate experimentation 0012

Product take: Foundational step towards retry-capable warehouse delivery (#8149). No user-facing change yet, but the audit trail gives operators visibility into per-object outcomes and sets up the delivery-record model that retries and concurrency control will build on.

🧭 Assumptions & unverified claims
  • The s3_key CharField(max_length=1024) comment says "S3's own key length limit." AWS documents the limit as 1,024 bytes, not characters. In practice the keys are ASCII paths so the distinction is moot, but multi-byte characters would let a valid S3 key exceed the column width. Unlikely to matter for this codebase's key format.

An audit log that deletes itself after 60 days — the kind of record-keeping that respects everyone's storage budget. · reviewed at 0dac30b

@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 31, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request docs Documentation updates labels Jul 31, 2026
@gagantrivedi
gagantrivedi merged commit 10a3bb7 into main Jul 31, 2026
34 checks passed
@gagantrivedi
gagantrivedi deleted the feat/warehouse-delivery-audit-ledger branch July 31, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API docs Documentation updates feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants