Skip to content

Conversation

@tanujnay112
Copy link
Contributor

@tanujnay112 tanujnay112 commented Nov 19, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Consolidate the Get paths in attached functions to match the pattern of the getters for the Collections table
    • AttachedFunction.{GetBy*} have been replaced by GetAttachedFunctions(...)
  • New functionality
    • ...

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the _docs section?_

@github-actions
Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor Author

tanujnay112 commented Nov 19, 2025

@tanujnay112 tanujnay112 marked this pull request as ready for review November 19, 2025 00:16
@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Nov 19, 2025

Chore: Consolidate Attached-Function Getters into a Single Filter-Based API Across Go, Rust & gRPC

This PR removes all specialised "get attached functions" helpers and replaces them with a single, filter-driven endpoint that is surfaced consistently in the data layer, gRPC service and CLI. By centralising the logic, we eliminate duplicated code paths, ensure uniform permission checks and make it easier to extend the query surface (e.g., new filters) in the future. All internal callers, generated mocks and tests have been migrated; external clients must switch to the new ListAttachedFunctions RPC and regenerate proto stubs.

Key Changes

• Deleted legacy methods GetAttachedFunctionsByCollection/Tenant/Task in both Go and Rust DAOs
• Introduced GetAttachedFunctions(ctx, queryOpts) (Go) / get_attached_functions(filters) (Rust) as the single data-access point
• Updated coordinator.proto to expose one RPC: ListAttachedFunctions, deprecating all previous variants
• Refactored server handlers, CLI helpers and coordinator utilities to use the new RPC
• Added new query/filter structs and regenerated mocks & tests; all unit, integration and e2e suites updated

Affected Areas

• SysDb / DAO layer (Go & Rust)
• coordinator.proto & generated gRPC stubs
• Task service server implementation
• Coordinator helpers and Rust CLI (chroma-task-manager)
• Mocks, fixtures and all test suites

This summary was automatically generated by @propel-code-bot

@tanujnay112 tanujnay112 force-pushed the attach_fn2 branch 2 times, most recently from e713158 to b6edf1a Compare November 19, 2025 00:18
@blacksmith-sh

This comment has been minimized.

@tanujnay112 tanujnay112 changed the base branch from attach_fn2 to graphite-base/5884 November 19, 2025 01:06
@tanujnay112 tanujnay112 changed the base branch from graphite-base/5884 to attach_fn2 November 19, 2025 08:44
err := s.catalog.txImpl.Transaction(ctx, func(txCtx context.Context) error {
// Double-check attached function doesn't exist (check both ready and not-ready)
concurrentAttachedFunction, err := s.catalog.metaDomain.AttachedFunctionDb(txCtx).GetAnyByName(req.InputCollectionId, req.Name)
results, err := s.catalog.metaDomain.AttachedFunctionDb(txCtx).GetAttachedFunctions(nil, &req.Name, &req.InputCollectionId, false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two UUID params here, can we strongly type?

optional string id = 1;
optional string name = 2;
optional string input_collection_id = 3;
optional bool only_ready = 4;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Default behavior should be we get ready things.

@tanujnay112 tanujnay112 changed the base branch from attach_fn2 to graphite-base/5884 November 20, 2025 03:02
@tanujnay112 tanujnay112 changed the base branch from graphite-base/5884 to attach_fn2 November 20, 2025 03:15
collection_id: CollectionUuid,
) -> Result<Vec<chroma_proto::AttachedFunction>, ListAttachedFunctionsError> {
options: crate::GetAttachedFunctionsOptions,
) -> Result<Vec<chroma_types::AttachedFunction>, ListAttachedFunctionsError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

The new get_attached_functions function returns a ListAttachedFunctionsError. To fully align with the refactoring and the new function name, it would be more consistent to rename ListAttachedFunctionsError to GetAttachedFunctionsError.

This might require changes in the chroma_types crate, so it could be addressed in this PR or a follow-up.

Context for Agents
The new `get_attached_functions` function returns a `ListAttachedFunctionsError`. To fully align with the refactoring and the new function name, it would be more consistent to rename `ListAttachedFunctionsError` to `GetAttachedFunctionsError`.

This might require changes in the `chroma_types` crate, so it could be addressed in this PR or a follow-up.

File: rust/sysdb/src/sysdb.rs
Line: 463

@blacksmith-sh

This comment has been minimized.

@tanujnay112 tanujnay112 changed the base branch from attach_fn2 to graphite-base/5884 November 21, 2025 09:53
@graphite-app graphite-app bot changed the base branch from graphite-base/5884 to main November 21, 2025 09:55
Comment on lines +29 to +32
log.Info("GetAttachedFunctions",
zap.Stringp("id", req.Id),
zap.Stringp("name", req.Name),
zap.Stringp("input_collection_id", req.InputCollectionId))
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

For better observability, it would be helpful to include the only_ready filter in this log message as well.

Suggested change
log.Info("GetAttachedFunctions",
zap.Stringp("id", req.Id),
zap.Stringp("name", req.Name),
zap.Stringp("input_collection_id", req.InputCollectionId))
log.Info("GetAttachedFunctions",
zap.Stringp("id", req.Id),
zap.Stringp("name", req.Name),
zap.Stringp("input_collection_id", req.InputCollectionId),
zap.Boolp("only_ready", req.OnlyReady))
Context for Agents
For better observability, it would be helpful to include the `only_ready` filter in this log message as well.

```suggestion
	log.Info("GetAttachedFunctions",
		zap.Stringp("id", req.Id),
		zap.Stringp("name", req.Name),
		zap.Stringp("input_collection_id", req.InputCollectionId),
		zap.Boolp("only_ready", req.OnlyReady))
```

File: go/pkg/sysdb/grpc/task_service.go
Line: 32

Comment on lines +1325 to +1328
.input_collection_id
.map(|id| id.0.to_string())
.unwrap_or_else(|| "unknown".to_string());
ListAttachedFunctionsError::NotFound(id_str)
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

The NotFound error message is based only on input_collection_id, which might be confusing if the query was filtered by other criteria like id or name. We could construct a more descriptive error message based on the filters provided in options.

Suggested change
.input_collection_id
.map(|id| id.0.to_string())
.unwrap_or_else(|| "unknown".to_string());
ListAttachedFunctionsError::NotFound(id_str)
let not_found_msg = if let Some(id) = options.id {
format!("id: {}", id)
} else if let Some(name) = &options.name {
format!("name: '{}'", name)
} else if let Some(coll_id) = options.input_collection_id {
format!("collection_id: {}", coll_id)
} else {
"(no filters provided)".to_string()
};
ListAttachedFunctionsError::NotFound(not_found_msg)
Context for Agents
The `NotFound` error message is based only on `input_collection_id`, which might be confusing if the query was filtered by other criteria like `id` or `name`. We could construct a more descriptive error message based on the filters provided in `options`.

```suggestion
                    let not_found_msg = if let Some(id) = options.id {
                        format!("id: {}", id)
                    } else if let Some(name) = &options.name {
                        format!("name: '{}'", name)
                    } else if let Some(coll_id) = options.input_collection_id {
                        format!("collection_id: {}", coll_id)
                    } else {
                        "(no filters provided)".to_string()
                    };
                    ListAttachedFunctionsError::NotFound(not_found_msg)
```

File: rust/sysdb/src/sysdb.rs
Line: 1328

@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Nov 21, 2025

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
github.com/chroma-core/chroma/go/pkg/sysdb/metastore/db/dao/
TestAttachedFunctionDbTestSuite
View Logs


Fix in Cursor

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.

2 participants