Skip to content

feat(cogs): ChangeStream trait, preparation for backend instrumentation - #590

Open
matt-codecov wants to merge 1 commit into
matth/storage-inventory-trackerfrom
matth/storage-inventory-tracker-2
Open

feat(cogs): ChangeStream trait, preparation for backend instrumentation#590
matt-codecov wants to merge 1 commit into
matth/storage-inventory-trackerfrom
matth/storage-inventory-tracker-2

Conversation

@matt-codecov

@matt-codecov matt-codecov commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Depends on #588

ChangeStream trait wraps InventoryTracker to log/count/swallow errors and allow a NoopStream to be plugged in for tests to avoid pulling in Kafka stuff.

@matt-codecov
matt-codecov requested a review from a team as a code owner August 6, 2026 01:55
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.12%. Comparing base (d180831) to head (f819003).

Additional details and impacted files
@@                         Coverage Diff                         @@
##           matth/storage-inventory-tracker     #590      +/-   ##
===================================================================
- Coverage                            93.31%   88.12%   -5.19%     
===================================================================
  Files                                   10      100      +90     
  Lines                                  703    16448   +15745     
===================================================================
+ Hits                                   656    14495   +13839     
- Misses                                  47     1953    +1906     
Components Coverage Δ
Rust Backend 92.34% <ø> (∅)
Rust Client 81.97% <ø> (∅)
Python Client 93.31% <ø> (ø)

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

Comment thread objectstore-inventory-tracker/src/kafka.rs Outdated
Comment thread objectstore-service/src/backend/common.rs Outdated
/// a change stream for our storage backends.
///
/// See [module docs](self).
pub trait InventorySink: fmt::Debug + Send + Sync + 'static {

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.

Calling out that this interface is close to what is being created in #582. I don't have a concrete design in mind yet, but it seems the "inventory" concept would be capable of solving both problems:

  • Storage cost tracking, which requires to know which files are stored until when
  • GC / eviction, which requires to know which files are stored until when

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah yes. Agreed with this.

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.

Apart from that we don't want to couple the two in-flight PRs too much, so this is probably more relevant for the other PR:

The biggest difference is how they are needed: Cost tracking requires the inventory independent of the backend, and will export it via kafka to a remote system. Conversely, the S3 and FS backends need the inventory as part of their inner workings. Per design, GC is part of the backend's responsibility.

We might be able to separate this cleanly if we:

  • Hook the inventory up in the service like the PR here does (sort of like an event bus)
  • Allow multiple inventory exporters
  • One is the kafka sink used for cost tracking
  • Another one is a database sink (like sqlite, PG) for GC, configured/hooked when S3/FS are used
    • GC is still an external command then, that queries said database

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

my direction here is very much "fail open" and errors are logged and swallowed. if inventory tracking is load-bearing for GC in some backends, that'll need to change

correct me if i'm wrong: for self-hosted, in order to support the automatic TTI/TTL GC that we advertise, we have to implement it ourselves atop filesystem and S3 as we anticipate those will be popular in self-hosted deployments?

@matt-codecov
matt-codecov force-pushed the matth/storage-inventory-tracker-2 branch from 94e1e3a to f819003 Compare August 7, 2026 01:45
@matt-codecov matt-codecov changed the title feat(cogs): InventorySink trait, preparation for backend instrumentation feat(cogs): ChangeStream trait, preparation for backend instrumentation Aug 7, 2026

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f819003. Configure here.

/// a change stream for our storage backends.
///
/// See [module docs](self).
pub trait ChangeStream: fmt::Debug + Send + Sync + 'static {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New change stream module never compiled

Medium Severity

backend/mod.rs has no change_stream declaration, so this file is not part of the crate. Nothing in it is type-checked, ChangeStream/NoopStream/ProducerStream are unreachable from other modules, and the unit tests here never run — silently leaving the newly added objectstore-inventory-tracker dependency unused until a follow-up wires it in.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f819003. Configure here.

@matt-codecov matt-codecov Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oops lol artifact of commit splitting

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.

3 participants