For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Remove deprecated AIEngineType field, add STT/TTS/EngineData fields to WebhookMessage and OpenAPI, remove stale transcribe_id from OpenAPI, and fix field name mismatches.
Architecture: The AIcall model (Go struct, DB, OpenAPI, WebhookMessage) has drifted. This plan syncs all four representations by removing deprecated fields and exposing missing ones externally.
Tech Stack: Go, Alembic (Python), OpenAPI 3.0, oapi-codegen
Files:
- Modify:
bin-ai-manager/models/aicall/main.go:17(remove AIEngineType field) - Modify:
bin-ai-manager/models/aicall/field.go:12(remove FieldAIEngineType constant) - Modify:
bin-ai-manager/models/aicall/filters.go:13(remove AIEngineType from FieldStruct)
Step 1: Remove AIEngineType field from AIcall struct
In bin-ai-manager/models/aicall/main.go, remove line 17:
AIEngineType ai.EngineType `json:"ai_engine_type,omitempty" db:"ai_engine_type"`Step 2: Remove FieldAIEngineType constant from field.go
In bin-ai-manager/models/aicall/field.go, remove line 12:
FieldAIEngineType Field = "ai_engine_type"Step 3: Remove AIEngineType from FieldStruct in filters.go
In bin-ai-manager/models/aicall/filters.go, remove line 13:
AIEngineType ai.EngineType `filter:"ai_engine_type"`Also remove the "monorepo/bin-ai-manager/models/ai" import if no other fields reference it. Check: AIEngineModel still uses ai.EngineModel, so the import stays.
Files:
- Modify:
bin-ai-manager/models/aicall/webhook.go
Step 1: Update WebhookMessage struct
Replace the current struct fields (lines 14-36) with:
type WebhookMessage struct {
identity.Identity
AIID uuid.UUID `json:"ai_id,omitempty"`
AIEngineModel ai.EngineModel `json:"ai_engine_model,omitempty"`
AIEngineData map[string]any `json:"ai_engine_data,omitempty"`
AITTSType ai.TTSType `json:"ai_tts_type,omitempty"`
AITTSVoiceID string `json:"ai_tts_voice_id,omitempty"`
AISTTType ai.STTType `json:"ai_stt_type,omitempty"`
ActiveflowID uuid.UUID `json:"activeflow_id,omitempty"`
ReferenceType ReferenceType `json:"reference_type,omitempty"`
ReferenceID uuid.UUID `json:"reference_id,omitempty"`
ConfbridgeID uuid.UUID `json:"confbridge_id,omitempty"`
Status Status `json:"status,omitempty"`
Gender Gender `json:"gender,omitempty"`
Language string `json:"language,omitempty"`
TMEnd *time.Time `json:"tm_end"`
TMCreate *time.Time `json:"tm_create"`
TMUpdate *time.Time `json:"tm_update"`
TMDelete *time.Time `json:"tm_delete"`
}Changes: Removed AIEngineType. Added AIEngineData, AITTSType, AITTSVoiceID, AISTTType.
Step 2: Update ConvertWebhookMessage()
Replace the return struct (lines 40-62) with:
func (h *AIcall) ConvertWebhookMessage() *WebhookMessage {
return &WebhookMessage{
Identity: h.Identity,
AIID: h.AIID,
AIEngineModel: h.AIEngineModel,
AIEngineData: h.AIEngineData,
AITTSType: h.AITTSType,
AITTSVoiceID: h.AITTSVoiceID,
AISTTType: h.AISTTType,
ActiveflowID: h.ActiveflowID,
ReferenceType: h.ReferenceType,
ReferenceID: h.ReferenceID,
ConfbridgeID: h.ConfbridgeID,
Status: h.Status,
Gender: h.Gender,
Language: h.Language,
TMEnd: h.TMEnd,
TMCreate: h.TMCreate,
TMUpdate: h.TMUpdate,
TMDelete: h.TMDelete,
}
}Files:
- Modify:
bin-ai-manager/pkg/aicallhandler/db.go:42(remove AIEngineType assignment)
Step 1: Remove AIEngineType from Create method
In bin-ai-manager/pkg/aicallhandler/db.go, remove line 42:
AIEngineType: c.EngineType,Files:
- Modify:
bin-ai-manager/models/aicall/main_test.go - Modify:
bin-ai-manager/models/aicall/webhook_test.go - Modify:
bin-ai-manager/models/aicall/field_test.go - Modify:
bin-ai-manager/models/aicall/filters_test.go - Modify:
bin-ai-manager/pkg/dbhandler/aicall_test.go - Modify:
bin-ai-manager/pkg/aicallhandler/db_test.go - Modify:
bin-ai-manager/pkg/aicallhandler/start_test.go
Step 1: Update main_test.go
Remove all aiEngineType test struct fields, test data assignments, and assertions:
- Remove
aiEngineType ai.EngineTypefrom test struct definition (line 16) - Remove
aiEngineType: ai.EngineTypeNonefrom all test cases (lines 34, 52, 70, 88) - Remove
AIEngineType: tt.aiEngineType,from AIcall construction (line 108) - Remove
if ac.AIEngineType != tt.aiEngineTypeassertion block (lines 126-128)
Step 2: Update webhook_test.go
Remove AIEngineType: ai.EngineTypeNone, from test case AIcall structs (line 27).
Step 3: Update field_test.go
Remove the field_ai_engine_type test case (lines 28-32):
{
name: "field_ai_engine_type",
constant: FieldAIEngineType,
expected: "ai_engine_type",
},Step 4: Update filters_test.go
Remove AIEngineType: ai.EngineTypeNone, (line 20) and AIEngineType: "", (line 38) from test cases.
If ai.EngineTypeNone was the only usage of the ai import, remove the import too.
Step 5: Update dbhandler/aicall_test.go
Remove AIEngineType: ai.EngineTypeNone, from both test case structs (lines 42, 68).
Step 6: Update aicallhandler/db_test.go
Remove AIEngineType: ai.EngineTypeNone, from the expectAIcall struct (line 79).
Step 7: Update aicallhandler/start_test.go
Remove AIEngineType: ai.EngineTypeNone, from responseAIcall (line 92) and expectAIcall (line 121) structs.
Step 8: Run tests to verify
Run: cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup/bin-ai-manager && go test ./...
Expected: All tests pass.
Files:
- Modify:
bin-ai-manager/scripts/database_scripts_test/table_ai_aicalls.sql
Step 1: Remove ai_engine_type column and stale transcribe_id index
Remove line 7: ai_engine_type varchar(255), -- ai engine type
Remove line 39: create index idx_ai_aicalls_transcribe_id on ai_aicalls(transcribe_id);
Step 1: Run full verification workflow
Run:
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup/bin-ai-manager
go mod tidy && go mod vendor && go generate ./... && go test ./... && golangci-lint run -v --timeout 5mExpected: All steps pass.
Step 2: Commit Go changes
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup
git add bin-ai-manager/
git commit -m "NOJIRA-aicall-schema-cleanup
- bin-ai-manager: Remove deprecated AIEngineType field from AIcall struct
- bin-ai-manager: Add AIEngineData, AITTSType, AITTSVoiceID, AISTTType to WebhookMessage
- bin-ai-manager: Remove stale transcribe_id index from test SQL
- bin-ai-manager: Update all tests for field removal"Files:
- Create:
bin-dbscheme-manager/bin-manager/main/versions/<hash>_ai_aicalls_drop_column_ai_engine_type.py
Step 1: Generate migration file
Run:
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup/bin-dbscheme-manager/bin-manager
cp alembic.ini.sample alembic.ini 2>/dev/null; trueCreate the migration file manually with revision ID and down_revision matching the latest:
"""ai_aicalls drop column ai_engine_type
Revision ID: a1b2c3d4e5f6
Revises: fe1a2b3c4d5e
Create Date: 2026-02-24 15:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a1b2c3d4e5f6'
down_revision = 'fe1a2b3c4d5e'
branch_labels = None
depends_on = None
def upgrade():
op.execute("""ALTER TABLE ai_aicalls DROP COLUMN ai_engine_type;""")
def downgrade():
op.execute("""ALTER TABLE ai_aicalls ADD ai_engine_type varchar(255) DEFAULT '' AFTER ai_id;""")Step 2: Commit migration
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup
git add bin-dbscheme-manager/
git commit -m "NOJIRA-aicall-schema-cleanup
- bin-dbscheme-manager: Add migration to drop ai_engine_type column from ai_aicalls"Files:
- Modify:
bin-openapi-manager/openapi/openapi.yaml(AIManagerAIcall schema, ~lines 1808-1895)
Step 1: Update AIManagerAIcall schema
Replace the properties section of AIManagerAIcall (lines ~1810-1895). The changes:
- Remove
engine_typeproperty (lines 1829-1832) - Rename
engine_modeltoai_engine_model(lines 1833-1836) - Remove
transcribe_idproperty (lines 1859-1864) - Add
ai_engine_dataproperty (after ai_engine_model) - Add
ai_tts_typeproperty (after ai_engine_data) - Add
ai_tts_voice_idproperty (after ai_tts_type) - Add
ai_stt_typeproperty (after ai_tts_voice_id)
The updated properties section for AIManagerAIcall should be:
AIManagerAIcall:
type: object
properties:
id:
type: string
format: uuid
x-go-type: string
description: The unique identifier of the AI call.
example: "550e8400-e29b-41d4-a716-446655440000"
customer_id:
type: string
format: uuid
x-go-type: string
description: "The unique identifier of the associated customer. Returned from the `GET /customers` response."
example: "7c4d2f3a-1b8e-4f5c-9a6d-3e2f1a0b4c5d"
ai_id:
type: string
format: uuid
x-go-type: string
description: "The unique identifier of the associated AI. Returned from the `POST /ais` or `GET /ais` response."
example: "550e8400-e29b-41d4-a716-446655440000"
ai_engine_model:
$ref: '#/components/schemas/AIManagerAIEngineModel'
description: Model of the AI engine used for this call.
example: "openai.gpt-4o"
ai_engine_data:
type: object
additionalProperties: true
description: Custom key-value configuration data specific to the AI engine type.
ai_tts_type:
type: string
description: Text-to-speech provider type used for this call.
example: "elevenlabs"
ai_tts_voice_id:
type: string
description: Text-to-speech voice identifier used for this call.
example: "21m00Tcm4TlvDq8ikWAM"
ai_stt_type:
type: string
description: Speech-to-text provider type used for this call.
example: "deepgram"
activeflow_id:
type: string
format: uuid
x-go-type: string
description: "The unique identifier of the activeflow. Returned from the `GET /activeflows` response."
example: "550e8400-e29b-41d4-a716-446655440000"
reference_type:
$ref: '#/components/schemas/AIManagerAIcallReferenceType'
description: Type of reference associated with the AI call.
example: "call"
reference_id:
type: string
format: uuid
x-go-type: string
description: "The unique identifier of the referenced resource. The actual resource type is determined by reference_type. Returned from the corresponding resource endpoint."
example: "550e8400-e29b-41d4-a716-446655440000"
confbridge_id:
type: string
format: uuid
x-go-type: string
description: "The unique identifier of the conference bridge. Returned from the `GET /conferences` response."
example: "550e8400-e29b-41d4-a716-446655440000"
status:
$ref: '#/components/schemas/AIManagerAIcallStatus'
description: Status of the AI call.
example: "progressing"
gender:
$ref: '#/components/schemas/AIManagerAIcallGender'
description: Gender associated with the AI call.
example: "female"
language:
type: string
description: Language used during the AI call.
example: "en-US"
tm_end:
type: string
format: date-time
x-go-type: string
description: Timestamp when the AI call ended.
example: "2026-01-15T09:30:00.000000Z"
tm_create:
type: string
format: date-time
x-go-type: string
description: Timestamp when the AI call was created.
example: "2026-01-15T09:30:00.000000Z"
tm_update:
type: string
format: date-time
x-go-type: string
description: Timestamp when the AI call was last updated.
example: "2026-01-15T09:30:00.000000Z"
tm_delete:
type: string
format: date-time
x-go-type: string
description: Timestamp when the AI call was deleted.
example: "2026-01-15T09:30:00.000000Z"Step 1: Regenerate bin-openapi-manager
Run:
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup/bin-openapi-manager
go generate ./...Step 2: Verify bin-openapi-manager
Run:
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup/bin-openapi-manager
go mod tidy && go mod vendor && go test ./... && golangci-lint run -v --timeout 5mStep 3: Regenerate bin-api-manager
Run:
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup/bin-api-manager
go generate ./...Step 4: Verify bin-api-manager
Run:
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup/bin-api-manager
go mod tidy && go mod vendor && go test ./... && golangci-lint run -v --timeout 5mStep 5: Commit OpenAPI and generated code
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup
git add bin-openapi-manager/ bin-api-manager/
git commit -m "NOJIRA-aicall-schema-cleanup
- bin-openapi-manager: Remove transcribe_id and engine_type from AIManagerAIcall schema
- bin-openapi-manager: Add ai_engine_data, ai_tts_type, ai_tts_voice_id, ai_stt_type
- bin-openapi-manager: Fix engine_model field name to ai_engine_model
- bin-api-manager: Regenerate server code from updated OpenAPI spec"Step 1: Re-run bin-ai-manager verification
The test SQL was updated and regeneration may have affected things:
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup/bin-ai-manager
go mod tidy && go mod vendor && go generate ./... && go test ./... && golangci-lint run -v --timeout 5mStep 2: Check for conflicts with main
cd ~/gitvoipbin/monorepo-worktrees/NOJIRA-aicall-schema-cleanup
git fetch origin main
git merge-tree $(git merge-base HEAD origin/main) HEAD origin/main | grep -E "^(CONFLICT|changed in both)"
git log --oneline HEAD..origin/mainStep 3: Push and create PR
git push -u origin NOJIRA-aicall-schema-cleanupCreate PR with title NOJIRA-aicall-schema-cleanup and body summarizing all changes.