step 5 (partial): strip dropped packages from production code
Removed all references to dropped packages in non-test code.
Zero dropped imports, store refs, or model types remaining.
Major removals:
- scheduler/ package (entire dir) — tasks moved to extension track
- taskutil/ package (entire dir)
- health/ package (entire dir) — provider/tool health
- sandbox/provider_module.go — provider.complete module
- handlers: workflow_entry, workflow_instances, workflow_forms,
workflow_assignments, workflow_monitor, health_admin (6 files)
- auth/session.go, middleware/session_auth.go
- store/{postgres,sqlite}/sessions.go, tasks.go
Rewrites:
- store/{postgres,sqlite}/health.go — kernel-only Prune
(ws_tickets, rate_limit_counters, stale presence)
- handlers/admin.go: 847→467 lines (stripped provider CRUD)
- handlers/teams.go: 520→411 lines (stripped model listing)
- sandbox/runner.go: removed ProviderResolver
- sandbox/workflow_module.go: 216→83 lines (definition-only)
- main.go: 1579→1325 lines (stripped dropped package init)
- pages/pages.go: stripped channel/session lookups
- events/types.go: stripped chat/channel/workspace event routes
- models: stripped stale types, constants, notification types
Store interface cleanup:
- Removed SessionStore, TaskStore from Stores struct
- Stripped workflow assignment methods from WorkflowStore iface
- Stripped assignment methods from PG+SQLite workflow stores
- Updated testhelper.go table list to kernel-only
Migrations: removed 008_tasks.sql (both dialects)
-9665/+69 lines across 51 files.
This commit is contained in:
@@ -28,10 +28,6 @@ import (
|
||||
func BuildWorkflowModule(ctx context.Context, stores store.Stores) *starlarkstruct.Module {
|
||||
return MakeModule("workflow", starlark.StringDict{
|
||||
"get_definition": starlark.NewBuiltin("workflow.get_definition", workflowGetDef(ctx, stores)),
|
||||
"get_stage_data": starlark.NewBuiltin("workflow.get_stage_data", workflowGetStageData(ctx, stores)),
|
||||
"advance": starlark.NewBuiltin("workflow.advance", workflowAdvance(ctx, stores)),
|
||||
"reject": starlark.NewBuiltin("workflow.reject", workflowReject(ctx, stores)),
|
||||
"route": starlark.NewBuiltin("workflow.route", workflowRoute(ctx, stores)),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -82,135 +78,5 @@ func workflowGetDef(ctx context.Context, stores store.Stores) func(*starlark.Thr
|
||||
}
|
||||
}
|
||||
|
||||
func workflowGetStageData(ctx context.Context, stores store.Stores) func(*starlark.Thread, *starlark.Builtin, starlark.Tuple, []starlark.Tuple) (starlark.Value, error) {
|
||||
return func(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
||||
var channelID string
|
||||
if err := starlark.UnpackPositionalArgs("workflow.get_stage_data", args, kwargs, 1, &channelID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ws, err := stores.Channels.GetWorkflowStatus(ctx, channelID)
|
||||
if err != nil || ws == nil {
|
||||
return starlark.None, fmt.Errorf("workflow.get_stage_data: channel not found or not a workflow")
|
||||
}
|
||||
|
||||
result := starlark.NewDict(8)
|
||||
result.SetKey(starlark.String("current_stage"), starlark.MakeInt(ws.CurrentStage))
|
||||
result.SetKey(starlark.String("status"), starlark.String(ws.Status))
|
||||
|
||||
if ws.StageData != nil {
|
||||
var data map[string]any
|
||||
if json.Unmarshal(ws.StageData, &data) == nil {
|
||||
for k, v := range data {
|
||||
sv, err := goToStarlark(v)
|
||||
if err == nil {
|
||||
result.SetKey(starlark.String(k), sv)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
func workflowAdvance(ctx context.Context, stores store.Stores) func(*starlark.Thread, *starlark.Builtin, starlark.Tuple, []starlark.Tuple) (starlark.Value, error) {
|
||||
return func(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
||||
var channelID string
|
||||
if err := starlark.UnpackPositionalArgs("workflow.advance", args, kwargs, 1, &channelID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ws, err := stores.Channels.GetWorkflowStatus(ctx, channelID)
|
||||
if err != nil || ws == nil || ws.WorkflowID == nil {
|
||||
return starlark.None, fmt.Errorf("workflow.advance: channel not found or not a workflow")
|
||||
}
|
||||
|
||||
stages, err := stores.Workflows.ListStages(ctx, *ws.WorkflowID)
|
||||
if err != nil {
|
||||
return starlark.None, fmt.Errorf("workflow.advance: %w", err)
|
||||
}
|
||||
|
||||
nextStage, err := workflow.ResolveNextStage(stages, ws.CurrentStage, ws.StageData)
|
||||
if err != nil {
|
||||
return starlark.None, fmt.Errorf("workflow.advance: routing error: %w", err)
|
||||
}
|
||||
if nextStage >= len(stages) {
|
||||
// Complete the workflow
|
||||
if err := stores.Channels.CompleteWorkflow(ctx, channelID, ws.CurrentStage, ws.StageData); err != nil {
|
||||
return starlark.None, fmt.Errorf("workflow.advance: %w", err)
|
||||
}
|
||||
return starlark.String("completed"), nil
|
||||
}
|
||||
|
||||
if err := stores.Channels.AdvanceWorkflowStage(ctx, channelID, nextStage, ws.StageData); err != nil {
|
||||
return starlark.None, fmt.Errorf("workflow.advance: %w", err)
|
||||
}
|
||||
return starlark.String("advanced"), nil
|
||||
}
|
||||
}
|
||||
|
||||
func workflowReject(ctx context.Context, stores store.Stores) func(*starlark.Thread, *starlark.Builtin, starlark.Tuple, []starlark.Tuple) (starlark.Value, error) {
|
||||
return func(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
||||
var channelID, reason string
|
||||
if err := starlark.UnpackPositionalArgs("workflow.reject", args, kwargs, 2, &channelID, &reason); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ws, err := stores.Channels.GetWorkflowStatus(ctx, channelID)
|
||||
if err != nil || ws == nil {
|
||||
return starlark.None, fmt.Errorf("workflow.reject: channel not found or not a workflow")
|
||||
}
|
||||
|
||||
if ws.CurrentStage <= 0 {
|
||||
return starlark.None, fmt.Errorf("workflow.reject: already at stage 0")
|
||||
}
|
||||
|
||||
prevStage := ws.CurrentStage - 1
|
||||
if err := stores.Channels.RejectWorkflowToStage(ctx, channelID, prevStage); err != nil {
|
||||
return starlark.None, fmt.Errorf("workflow.reject: %w", err)
|
||||
}
|
||||
return starlark.String("rejected"), nil
|
||||
}
|
||||
}
|
||||
|
||||
// workflowRoute routes the workflow to a named stage (v0.35.0).
|
||||
// Starlark: workflow.route(channel_id, target_stage, reason)
|
||||
func workflowRoute(ctx context.Context, stores store.Stores) func(*starlark.Thread, *starlark.Builtin, starlark.Tuple, []starlark.Tuple) (starlark.Value, error) {
|
||||
return func(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
||||
var channelID, targetStage, reason string
|
||||
if err := starlark.UnpackPositionalArgs("workflow.route", args, kwargs, 3, &channelID, &targetStage, &reason); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ws, err := stores.Channels.GetWorkflowStatus(ctx, channelID)
|
||||
if err != nil || ws == nil || ws.WorkflowID == nil {
|
||||
return starlark.None, fmt.Errorf("workflow.route: channel not found or not a workflow")
|
||||
}
|
||||
if ws.Status != "active" {
|
||||
return starlark.None, fmt.Errorf("workflow.route: workflow is %s", ws.Status)
|
||||
}
|
||||
|
||||
stages, err := stores.Workflows.ListStages(ctx, *ws.WorkflowID)
|
||||
if err != nil {
|
||||
return starlark.None, fmt.Errorf("workflow.route: %w", err)
|
||||
}
|
||||
|
||||
targetOrdinal, err := workflow.ResolveStageByName(stages, targetStage)
|
||||
if err != nil {
|
||||
return starlark.None, fmt.Errorf("workflow.route: %w", err)
|
||||
}
|
||||
|
||||
if targetOrdinal >= len(stages) {
|
||||
if err := stores.Channels.CompleteWorkflow(ctx, channelID, targetOrdinal, ws.StageData); err != nil {
|
||||
return starlark.None, fmt.Errorf("workflow.route: %w", err)
|
||||
}
|
||||
return starlark.String("completed"), nil
|
||||
}
|
||||
|
||||
if err := stores.Channels.AdvanceWorkflowStage(ctx, channelID, targetOrdinal, ws.StageData); err != nil {
|
||||
return starlark.None, fmt.Errorf("workflow.route: %w", err)
|
||||
}
|
||||
return starlark.String("routed"), nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user