Skip to content

Autopudate#136

Merged
aojea merged 9 commits into
google:mainfrom
aojea:autopudate
Jun 23, 2026
Merged

Autopudate#136
aojea merged 9 commits into
google:mainfrom
aojea:autopudate

Conversation

@aojea

@aojea aojea commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request renames MCP tool configurations to servers, removes the unused A2A service type, introduces a --trust-hub-rbac flag to conditionally apply baseline rules, and adds target service extraction to the authorization frame. Feedback on these changes suggests updating remaining variable names, error messages, and logs to reflect the 'server' renaming for consistency. Additionally, it is recommended to use separate timeout contexts for sequential DHT provide calls to prevent starvation, and to log the detailed authorizer state at a debug level rather than error level to avoid leaking sensitive information in production logs.

Comment thread cmd/sam-hub/config.go
Comment on lines +74 to 77
for _, tool := range rolePolicy.MCP.AllowedServers {
if tool == "*" {
return fmt.Errorf("wildcard tool '*' is not allowed in role %q", role)
}

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.

medium

Since AllowedTools has been renamed to AllowedServers, the variable name tool and the error message should be updated to refer to server instead of tool for consistency and clarity.

Suggested change
for _, tool := range rolePolicy.MCP.AllowedServers {
if tool == "*" {
return fmt.Errorf("wildcard tool '*' is not allowed in role %q", role)
}
for _, server := range rolePolicy.MCP.AllowedServers {
if server == "*" {
return fmt.Errorf("wildcard server '*' is not allowed in role %q", role)
}
}

Comment thread cmd/sam-hub/main.go
Comment on lines +483 to 488
for _, tool := range rolePolicy.MCP.AllowedServers {
if err := builder.AddAuthorityFact(biscuit.Fact{Predicate: biscuit.Predicate{
Name: api.FactMCPTool,
Name: api.FactMCPServer,
IDs: []biscuit.Term{biscuit.String(tool)},
}}); err != nil {
logger.Errorw("Failed to add MCP tool fact to biscuit", "peer_id", remotePeer, "tool", tool, "error", err)

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.

medium

Since FactMCPTool was renamed to FactMCPServer and AllowedTools was renamed to AllowedServers, the variable name tool and the log message should be updated to refer to server instead of tool.

Suggested change
for _, tool := range rolePolicy.MCP.AllowedServers {
if err := builder.AddAuthorityFact(biscuit.Fact{Predicate: biscuit.Predicate{
Name: api.FactMCPTool,
Name: api.FactMCPServer,
IDs: []biscuit.Term{biscuit.String(tool)},
}}); err != nil {
logger.Errorw("Failed to add MCP tool fact to biscuit", "peer_id", remotePeer, "tool", tool, "error", err)
for _, server := range rolePolicy.MCP.AllowedServers {
if err := builder.AddAuthorityFact(biscuit.Fact{Predicate: biscuit.Predicate{
Name: api.FactMCPServer,
IDs: []biscuit.Term{biscuit.String(server)},
}}); err != nil {
logger.Errorw("Failed to add MCP server fact to biscuit", "peer_id", remotePeer, "server", server, "error", err)

if len(role.MCP.AllowedTools) != 1 || role.MCP.AllowedTools[0] != "query_database" {
t.Errorf("unexpected allowed tools: %v", role.MCP.AllowedTools)
if len(role.MCP.AllowedServers) != 1 || role.MCP.AllowedServers[0] != "query_database" {
t.Errorf("unexpected allowed tools: %v", role.MCP.AllowedServers)

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.

medium

The error message still refers to allowed tools instead of allowed servers. It should be updated to match the renamed field.

Suggested change
t.Errorf("unexpected allowed tools: %v", role.MCP.AllowedServers)
t.Errorf("unexpected allowed servers: %v", role.MCP.AllowedServers)

Comment thread cmd/sam-node/service_registry.go Outdated
Comment on lines 69 to 77
provideCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

if err := r.dht.Provide(provideCtx, srvNameCID, true); err != nil {
logger.Warnf("[ServiceRegistry] DHT Provide (name) for %s: %v", info.Name, err)
}
if err := r.dht.Provide(ctx, srvTypeCID, true); err != nil {
if err := r.dht.Provide(provideCtx, srvTypeCID, true); err != nil {
logger.Warnf("[ServiceRegistry] DHT Provide (type) for %s: %v", info.Name, err)
}

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.

medium

Using a single context with a 5-second timeout for both sequential Provide calls means that if the first call is slow or times out, the second call will be starved or automatically cancelled. It is safer to use a separate context and timeout for each Provide call.

Suggested change
provideCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
if err := r.dht.Provide(provideCtx, srvNameCID, true); err != nil {
logger.Warnf("[ServiceRegistry] DHT Provide (name) for %s: %v", info.Name, err)
}
if err := r.dht.Provide(ctx, srvTypeCID, true); err != nil {
if err := r.dht.Provide(provideCtx, srvTypeCID, true); err != nil {
logger.Warnf("[ServiceRegistry] DHT Provide (type) for %s: %v", info.Name, err)
}
provideCtx1, cancel1 := context.WithTimeout(ctx, 5*time.Second)
if err := r.dht.Provide(provideCtx1, srvNameCID, true); err != nil {
logger.Warnf("[ServiceRegistry] DHT Provide (name) for %s: %v", info.Name, err)
}
cancel1()
provideCtx2, cancel2 := context.WithTimeout(ctx, 5*time.Second)
if err := r.dht.Provide(provideCtx2, srvTypeCID, true); err != nil {
logger.Warnf("[ServiceRegistry] DHT Provide (type) for %s: %v", info.Name, err)
}
cancel2()

Comment thread cmd/sam-node/middleware.go
aojea added 6 commits June 23, 2026 15:22
This completely reverts the renaming of find_remote_tools, call_remote_tool,
and describe_remote_tool and their JSON fields back to using the 'tool'
terminology because they specifically describe and interact with MCP Tools,
preserving semantic correctness.
@aojea aojea merged commit 9fa9bf8 into google:main Jun 23, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant