Files
Agent-System/internal/app/run_control_owner_test.go
weichen 016135d946 feat(intentflow): wire U9–U12 live adapters for multi-intent closeout
Connect LLM segment proposals into HandleTurn, replace U10–U12 dry-run stubs
with production owners (blackboard supplement, docgov claim/submit, workflow
run/resume) when flags are on, and update policy/sysadmin maturity metadata.
2026-09-23 15:26:46 +00:00

50 lines
1.5 KiB
Go

package app
import (
"context"
"testing"
"chat-agent-system/internal/app/intentflow"
)
func TestRunControlOwnerForbiddenWithoutAccess(t *testing.T) {
owner := NewRunControlOwner(func(context.Context, int64, int64) error {
return intentflow.ErrPlanActionForbidden
}, nil, nil)
_, err := owner.Execute(context.Background(), intentflow.StepExec{
ActionKey: "workflow.run",
IdempotencyKey: "rc-auth", ActionDigest: "d",
Principal: intentflow.Principal{UserID: 1, ProjectID: 2, SessionID: "s"},
})
if err != intentflow.ErrPlanActionForbidden {
t.Fatalf("want forbidden, got %v", err)
}
}
func TestRunControlOwnerResumeMissingWorkDirFailClosed(t *testing.T) {
owner := NewRunControlOwner(func(context.Context, int64, int64) error { return nil }, nil, nil)
_, err := owner.Execute(context.Background(), intentflow.StepExec{
ActionKey: "run.resume",
IdempotencyKey: "rc-resume", ActionDigest: "d",
Principal: intentflow.Principal{UserID: 1, ProjectID: 2, SessionID: "s"},
})
if err != intentflow.ErrPlanActionForbidden {
t.Fatalf("missing work_dir must fail closed, got %v", err)
}
}
func TestRunControlOwnerNonLiveKeyUsesDryRun(t *testing.T) {
owner := NewRunControlOwner(nil, nil, nil)
rec, err := owner.Execute(context.Background(), intentflow.StepExec{
ActionKey: "workflow.switch",
StepID: "s", IdempotencyKey: "rc-sw", ActionDigest: "d",
Principal: intentflow.Principal{UserID: 1, ProjectID: 2, SessionID: "s"},
})
if err != nil {
t.Fatal(err)
}
if rec.SafeSummary == "" {
t.Fatal("expected dry-run summary")
}
}