Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/components-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
{"name":"state-sync","context":"./components/runners/state-sync","image":"quay.io/ambient_code/vteam_state_sync","dockerfile":"./components/runners/state-sync/Dockerfile"},
{"name":"public-api","context":"./components/public-api","image":"quay.io/ambient_code/vteam_public_api","dockerfile":"./components/public-api/Dockerfile"},
{"name":"ambient-api-server","context":"./components/ambient-api-server","image":"quay.io/ambient_code/vteam_api_server","dockerfile":"./components/ambient-api-server/Dockerfile"},
{"name":"ambient-control-plane","context":"./components/ambient-control-plane","image":"quay.io/ambient_code/vteam_control_plane","dockerfile":"./components/ambient-control-plane/Dockerfile"},
{"name":"ambient-control-plane","context":"./components","image":"quay.io/ambient_code/vteam_control_plane","dockerfile":"./components/ambient-control-plane/Dockerfile"},
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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Dockerfile inputs for ambient-control-plane ==="
rg -n '^\s*COPY\s+(ambient-api-server/|ambient-sdk/go-sdk/)' components/ambient-control-plane/Dockerfile

echo
echo "=== Current workflow path filters ==="
rg -n "components/ambient-(api-server|control-plane|sdk)/\*\*" .github/workflows/components-build-deploy.yml

Repository: ambient-code/platform

Length of output: 439


Add components/ambient-sdk/** to workflow path filters

The Dockerfile for ambient-control-plane copies from ambient-sdk/go-sdk/ (lines 7–8 of the Dockerfile), but the workflow's on.push.paths and on.pull_request.paths do not include components/ambient-sdk/**. Changes to the SDK will not trigger a rebuild of this image.

Add to both push and pull_request path filters
     paths:
       - '.github/workflows/components-build-deploy.yml'
       - 'components/ambient-api-server/**'
+      - 'components/ambient-sdk/**'
       - 'components/ambient-control-plane/**'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/components-build-deploy.yml at line 62, The workflow’s
path filters for the component image list (see the ambient-control-plane entry
with name "ambient-control-plane" and context "./components") are missing the
SDK path; update the workflow triggers under on.push.paths and
on.pull_request.paths to include "components/ambient-sdk/**" so changes inside
components/ambient-sdk will trigger rebuilds of the ambient-control-plane image.

{"name":"ambient-mcp","context":"./components/ambient-mcp","image":"quay.io/ambient_code/vteam_mcp","dockerfile":"./components/ambient-mcp/Dockerfile"}
]'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prod-release-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ jobs:
{"name":"state-sync","context":"./components/runners/state-sync","image":"quay.io/ambient_code/vteam_state_sync","dockerfile":"./components/runners/state-sync/Dockerfile"},
{"name":"public-api","context":"./components/public-api","image":"quay.io/ambient_code/vteam_public_api","dockerfile":"./components/public-api/Dockerfile"},
{"name":"ambient-api-server","context":"./components/ambient-api-server","image":"quay.io/ambient_code/vteam_api_server","dockerfile":"./components/ambient-api-server/Dockerfile"},
{"name":"ambient-control-plane","context":"./components/ambient-control-plane","image":"quay.io/ambient_code/vteam_control_plane","dockerfile":"./components/ambient-control-plane/Dockerfile"},
{"name":"ambient-control-plane","context":"./components","image":"quay.io/ambient_code/vteam_control_plane","dockerfile":"./components/ambient-control-plane/Dockerfile"},
{"name":"ambient-mcp","context":"./components/ambient-mcp","image":"quay.io/ambient_code/vteam_mcp","dockerfile":"./components/ambient-mcp/Dockerfile"}
]'

Expand Down
44 changes: 21 additions & 23 deletions components/ambient-api-server/plugins/agents/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,30 @@ func migration() *gormigrate.Migration {
}

func agentSchemaExpansionMigration() *gormigrate.Migration {
type Agent struct {
db.Model
ProjectId string
ParentAgentId *string `gorm:"index"`
OwnerUserId *string
Name string
DisplayName *string
Description *string
Prompt *string `gorm:"type:text"`
RepoUrl *string
WorkflowId *string
LlmModel *string
LlmTemperature *float64
LlmMaxTokens *int32
BotAccountName *string
ResourceOverrides *string
EnvironmentVariables *string
Labels *string
Annotations *string
CurrentSessionId *string
}

return &gormigrate.Migration{
ID: "202604181000",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(&Agent{})
stmts := []string{
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS parent_agent_id TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS owner_user_id TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS display_name TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS description TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS repo_url TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS workflow_id TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_model TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_temperature DOUBLE PRECISION`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_max_tokens INTEGER`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS bot_account_name TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS resource_overrides TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS environment_variables TEXT`,
Comment on lines +48 to +60
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Model field nullability (non-pointer primitives expected non-null DB values):"
rg -n 'OwnerUserId|LlmModel|LlmTemperature|LlmMaxTokens' components/ambient-api-server/plugins/agents/model.go

echo
echo "Migration SQL currently defining these columns:"
rg -n 'owner_user_id|llm_model|llm_temperature|llm_max_tokens' components/ambient-api-server/plugins/agents/migration.go

Repository: ambient-code/platform

Length of output: 1082


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking for follow-up migrations after migration.go ==="
fd -e go migration | head -20

echo
echo "=== Checking if other fields have gorm NOT NULL constraints we missed ==="
rg -n 'gorm:"' components/ambient-api-server/plugins/agents/model.go | grep -E 'LlmModel|LlmTemperature|LlmMaxTokens|OwnerUserId'

echo
echo "=== Looking for any ALTER TABLE that adds NOT NULL to these columns ==="
rg -n 'ALTER TABLE agents' components/ambient-api-server/plugins/agents/ | grep -E 'owner_user_id|llm_model|llm_temperature|llm_max_tokens.*NOT NULL'

Repository: ambient-code/platform

Length of output: 1300


Add NOT NULL constraint to owner_user_id column in migration.

Line 50 creates owner_user_id as nullable, but the model at line 12 declares it as gorm:"not null". This violates the model contract and risks scan failures.

Migration fix
 			stmts := []string{
 				`ALTER TABLE agents ADD COLUMN IF NOT EXISTS parent_agent_id TEXT`,
-				`ALTER TABLE agents ADD COLUMN IF NOT EXISTS owner_user_id TEXT`,
+				`ALTER TABLE agents ADD COLUMN IF NOT EXISTS owner_user_id TEXT NOT NULL DEFAULT ''`,
 				`ALTER TABLE agents ADD COLUMN IF NOT EXISTS display_name TEXT`,

Consider applying similar constraints to llm_model, llm_temperature, and llm_max_tokens (lines 55–57), since they are non-pointer primitives. Code-level defaults exist, but nullable columns create unnecessary null-check risk.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
stmts := []string{
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS parent_agent_id TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS owner_user_id TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS display_name TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS description TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS repo_url TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS workflow_id TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_model TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_temperature DOUBLE PRECISION`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_max_tokens INTEGER`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS bot_account_name TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS resource_overrides TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS environment_variables TEXT`,
stmts := []string{
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS parent_agent_id TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS owner_user_id TEXT NOT NULL DEFAULT ''`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS display_name TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS description TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS repo_url TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS workflow_id TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_model TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_temperature DOUBLE PRECISION`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_max_tokens INTEGER`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS bot_account_name TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS resource_overrides TEXT`,
`ALTER TABLE agents ADD COLUMN IF NOT EXISTS environment_variables TEXT`,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/ambient-api-server/plugins/agents/migration.go` around lines 48 -
60, The migration builds the SQL statements in the stmts slice and currently
creates owner_user_id as nullable, which conflicts with the model's gorm:"not
null"; update the corresponding statement in stmts to add "NOT NULL" and a
sensible DEFAULT (e.g., empty string) to avoid migration failures, and likewise
change the llm_model, llm_temperature and llm_max_tokens column statements to
include NOT NULL with appropriate DEFAULT values (e.g., '' for llm_model, 0.0
for llm_temperature, 0 for llm_max_tokens) so the SQL schema matches the
non-pointer model fields; adjust the ALTER TABLE statements that reference
owner_user_id, llm_model, llm_temperature and llm_max_tokens in the stmts slice
accordingly.

`CREATE INDEX IF NOT EXISTS idx_agents_parent_agent_id ON agents(parent_agent_id)`,
}
for _, s := range stmts {
if err := tx.Exec(s).Error; err != nil {
return err
}
}
return nil
},
Rollback: func(tx *gorm.DB) error {
cols := []string{
Expand Down
27 changes: 5 additions & 22 deletions components/ambient-api-server/plugins/credentials/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ func removeCredentialReaderRoleMigration() *gormigrate.Migration {
}

func rolesMigration() *gormigrate.Migration {
type roleRow struct {
ID string
Name string
DisplayName string
Description string
Permissions string
BuiltIn bool
}

seed := []struct {
name string
displayName string
Expand Down Expand Up @@ -96,18 +87,10 @@ func rolesMigration() *gormigrate.Migration {
if err != nil {
return err
}
var row roleRow
if err := tx.Table("roles").
Where("name = ?", r.name).
Attrs(roleRow{
ID: api.NewID(),
Name: r.name,
DisplayName: r.displayName,
Description: r.description,
Permissions: string(permsJSON),
BuiltIn: true,
}).
FirstOrCreate(&row).Error; err != nil {
if err := tx.Exec(
`INSERT INTO roles (id, name, display_name, description, permissions, built_in) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT (name) DO NOTHING`,
api.NewID(), r.name, r.displayName, r.description, string(permsJSON), true,
).Error; err != nil {
return err
}
}
Expand All @@ -118,7 +101,7 @@ func rolesMigration() *gormigrate.Migration {
for i, r := range seed {
names[i] = r.name
}
return tx.Table("roles").Where("name IN ?", names).Delete(&roleRow{}).Error
return tx.Exec("DELETE FROM roles WHERE name IN ?", names).Error
},
}
}
25 changes: 4 additions & 21 deletions components/ambient-api-server/plugins/roles/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ func migration() *gormigrate.Migration {
}

func seedBuiltInRoles(tx *gorm.DB) error {
type roleRow struct {
ID string
Name string
DisplayName string
Description string
Permissions string
BuiltIn bool
}

builtInRoles := []struct {
name string
displayName string
Expand Down Expand Up @@ -105,18 +96,10 @@ func seedBuiltInRoles(tx *gorm.DB) error {
if err != nil {
return err
}
var row roleRow
if err := tx.Table("roles").
Where("name = ?", r.name).
Attrs(roleRow{
ID: api.NewID(),
Name: r.name,
DisplayName: r.displayName,
Description: r.description,
Permissions: string(permsJSON),
BuiltIn: true,
}).
FirstOrCreate(&row).Error; err != nil {
if err := tx.Exec(
`INSERT INTO roles (id, name, display_name, description, permissions, built_in) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT (name) DO NOTHING`,
api.NewID(), r.name, r.displayName, r.description, string(permsJSON), true,
).Error; err != nil {
return err
}
}
Expand Down
Loading