diff --git a/cmd/archie-messaging/architecture_test.go b/cmd/archie-messaging/architecture_test.go index 58af6b79b..3ecacf93f 100644 --- a/cmd/archie-messaging/architecture_test.go +++ b/cmd/archie-messaging/architecture_test.go @@ -26,7 +26,7 @@ func TestMessagingDoesNotLinkStoreOrWorkflowRuntime(t *testing.T) { for _, pkg := range []string{ "github.com/jackc/pgx/v5/pgxpool", "github.com/samcharles93/archie-core/internal/infrastructure/postgres", - "github.com/samcharles93/archie-core/internal/app/controlplane", + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore", "github.com/samcharles93/archie-core/internal/domain/workflow", "github.com/samcharles93/archie-core/internal/agentexec", } { diff --git a/internal/app/archied/bootstrap.go b/internal/app/archied/bootstrap.go index 43d09d179..6b54e5976 100644 --- a/internal/app/archied/bootstrap.go +++ b/internal/app/archied/bootstrap.go @@ -24,7 +24,6 @@ import ( "time" "github.com/samcharles93/archie-core/internal/app/chattask" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/container" @@ -48,6 +47,7 @@ import ( "github.com/samcharles93/archie-core/internal/gateway" infraaccess "github.com/samcharles93/archie-core/internal/infrastructure/access" "github.com/samcharles93/archie-core/internal/infrastructure/configuration" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/infrastructure/eventbus/nats" "github.com/samcharles93/archie-core/internal/infrastructure/extension" "github.com/samcharles93/archie-core/internal/infrastructure/kitrun" @@ -71,7 +71,7 @@ type boot struct { catalog *modelcatalog.Catalog cfg config.Config log *slog.Logger - playbooks *controlplane.LivePlaybooks + playbooks *controlplanestore.LivePlaybooks // stderrLog keeps setupLogging on stderr, never touching cfg.Log.File. An // offline command reads the bootstrap config but is not the daemon: creating @@ -110,7 +110,7 @@ type boot struct { // (daemon.RunCredentialIssuer), wrapping the same *staterpc.Client as // stateStore, which also verifies a credential for a worktree push. stateStoreGrants *staterpc.GrantIssuer - controlPlane *controlplane.Client + controlPlane *controlplanestore.Client // controlPlaneRPC is the State Store's control-plane transport, kept so the // daemon root can build its workflow-definitions client from it // (openDaemonWorkflowDefinitions). The gateway root never builds that client: @@ -119,7 +119,7 @@ type boot struct { // workflowDefinitions is the one control-plane surface that resolves // workflow step types. It is separate from controlPlane because it is the // only surface that needs the process's step vocabulary. - workflowDefinitions *controlplane.WorkflowDefinitionsClient + workflowDefinitions *controlplanestore.WorkflowDefinitionsClient // executionSettings is the last workflow execution settings the control // plane published. They arrive on a watch rather than in the file // document, so reloadConfig re-applies them from here. @@ -303,7 +303,7 @@ func (b *boot) openStateStoreAdapter(ctx context.Context) error { b.taskModels = client b.taskInstructions = client b.controlPlaneRPC = client.ControlPlane() - b.controlPlane = controlplane.NewRPCClient(b.controlPlaneRPC) + b.controlPlane = controlplanestore.NewRPCClient(b.controlPlaneRPC) b.applyStatus = applystatus.New(b.processName, client, b.log) b.stateStoreGrants = &staterpc.GrantIssuer{Client: client} b.addCleanup(cleanup) @@ -865,8 +865,8 @@ func (b *boot) startModelCatalogRefresh(ctx context.Context) { }) } -func (b *boot) livePlaybooks() *controlplane.LivePlaybooks { - b.playbooks = controlplane.NewLivePlaybooks(b.controlPlaneRPC, b.log) +func (b *boot) livePlaybooks() *controlplanestore.LivePlaybooks { + b.playbooks = controlplanestore.NewLivePlaybooks(b.controlPlaneRPC, b.log) b.playbooks.ApplyStatus = b.applyStatus return b.playbooks } diff --git a/internal/app/archied/control_plane.go b/internal/app/archied/control_plane.go index 951ec1bf4..bed945336 100644 --- a/internal/app/archied/control_plane.go +++ b/internal/app/archied/control_plane.go @@ -6,11 +6,11 @@ import ( "fmt" "time" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/domain/workflow" "github.com/samcharles93/archie-core/internal/infrastructure/configuration" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog" ) @@ -100,18 +100,18 @@ func (b *boot) startWorkflowExecutionSettings(ctx context.Context) error { return err } var lastApplyErr, streamErr error - open := func(ctx context.Context, after int64) (<-chan controlplane.AppliedSettings, error) { + open := func(ctx context.Context, after int64) (<-chan controlplanestore.AppliedSettings, error) { updates, err := b.controlPlane.WatchWorkflowExecutionSettings(ctx, after) if err == nil { - b.applyStatus.Report(ctx, controlplane.WorkflowExecutionSettingsKind, after, lastApplyErr) + b.applyStatus.Report(ctx, controlplanestore.WorkflowExecutionSettingsKind, after, lastApplyErr) } return updates, err } - go servicekit.KeepWatch(ctx, b.log, controlplane.WorkflowExecutionSettingsKind, version, updates, + go servicekit.KeepWatch(ctx, b.log, controlplanestore.WorkflowExecutionSettingsKind, version, updates, open, servicekit.WaitFor, - func(update controlplane.AppliedSettings) int64 { return update.Version }, - func(update controlplane.AppliedSettings) { + func(update controlplanestore.AppliedSettings) int64 { return update.Version }, + func(update controlplanestore.AppliedSettings) { if update.Err != nil { // A refused document carries its version, while a stream failure // does not. Keep a refusal visible across a transport outage; when @@ -119,7 +119,7 @@ func (b *boot) startWorkflowExecutionSettings(ctx context.Context) error { // outage until a watch is re-established. if update.Version > 0 { lastApplyErr = update.Err - b.applyStatus.Report(ctx, controlplane.WorkflowExecutionSettingsKind, update.Version, update.Err) + b.applyStatus.Report(ctx, controlplanestore.WorkflowExecutionSettingsKind, update.Version, update.Err) } else { streamErr = update.Err } @@ -135,7 +135,7 @@ func (b *boot) startWorkflowExecutionSettings(ctx context.Context) error { if streamErr == nil { streamErr = fmt.Errorf("control-plane watch stream ended") } - b.applyStatus.Report(ctx, controlplane.WorkflowExecutionSettingsKind, 0, + b.applyStatus.Report(ctx, controlplanestore.WorkflowExecutionSettingsKind, 0, fmt.Errorf("workflow execution settings watch unavailable: %w", streamErr)) streamErr = nil }) @@ -159,7 +159,7 @@ type executionSettingsCandidate struct { // // The kind's schema is deliberately not re-checked here. The store validates // every document before it is written (Definition.Decode) and -// controlplane.Client validates it again as it decodes it, so re-running +// controlplanestore.Client validates it again as it decodes it, so re-running // workflow.ExecutionSettings.Validate at this point would be a guard no // producer can trip. func (b *boot) buildExecutionSettingsCandidate(settings workflow.ExecutionSettings) (executionSettingsCandidate, error) { @@ -193,13 +193,13 @@ func (b *boot) buildExecutionSettingsCandidate(settings workflow.ExecutionSettin func (b *boot) applyWorkflowExecutionSettings(ctx context.Context, settings workflow.ExecutionSettings, version int64) error { candidate, err := b.buildExecutionSettingsCandidate(settings) if err != nil { - b.applyStatus.Report(ctx, controlplane.WorkflowExecutionSettingsKind, version, err) + b.applyStatus.Report(ctx, controlplanestore.WorkflowExecutionSettingsKind, version, err) b.log.Error("workflow execution settings rejected; the running settings stay", "version", version, "err", err) return err } b.executionSettings.Store(&candidate.settings) b.publishConfig(ctx, candidate.cfg) - b.applyStatus.Report(ctx, controlplane.WorkflowExecutionSettingsKind, version, nil) + b.applyStatus.Report(ctx, controlplanestore.WorkflowExecutionSettingsKind, version, nil) b.log.Info("workflow execution settings applied", "version", version) if limit, uptime := settings.MaxTaskRuntime, candidate.cfg.Containers.MaxUptime.Std(); uptime > 0 && (limit <= 0 || limit > uptime) { b.log.Warn("containers.max_uptime is shorter than the task time limit; the container is killed first", "max_uptime", uptime, "max_task_runtime", limit) @@ -266,19 +266,19 @@ func (b *boot) startLiveSettings(ctx context.Context) error { // the client (the daemon's root forge and the root task RPC servers), so a // rotated credential reaches the next operation without a restart. var runtimeResourceKinds = []string{ - controlplane.TaskPolicyKind, - controlplane.ProviderSettingsKind, - controlplane.ModelAliasesKind, - controlplane.RepositoryPoliciesKind, - controlplane.SchedulingPolicyKind, - controlplane.ToolSettingsKind, - controlplane.PluginSettingsKind, - controlplane.ChannelSettingsKind, - controlplane.ContainerRuntimePoliciesKind, - controlplane.CredentialBindingsKind, - controlplane.IdentityGrantsKind, - controlplane.AgentProfileKind, - controlplane.ForgeConnectionsKind, + controlplanestore.TaskPolicyKind, + controlplanestore.ProviderSettingsKind, + controlplanestore.ModelAliasesKind, + controlplanestore.RepositoryPoliciesKind, + controlplanestore.SchedulingPolicyKind, + controlplanestore.ToolSettingsKind, + controlplanestore.PluginSettingsKind, + controlplanestore.ChannelSettingsKind, + controlplanestore.ContainerRuntimePoliciesKind, + controlplanestore.CredentialBindingsKind, + controlplanestore.IdentityGrantsKind, + controlplanestore.AgentProfileKind, + controlplanestore.ForgeConnectionsKind, } // startRuntimeResourceWatches keeps a watch per live kind established for the @@ -294,7 +294,7 @@ func (b *boot) startRuntimeResourceWatches(ctx context.Context, versions map[str return fmt.Errorf("watch %s: %w", kind, err) } var lastApplyErr, streamErr error - open := func(ctx context.Context, afterVersion int64) (<-chan controlplane.AppliedResource, error) { + open := func(ctx context.Context, afterVersion int64) (<-chan controlplanestore.AppliedResource, error) { next, err := b.controlPlane.WatchResource(ctx, kind, afterVersion) if err == nil { // A live watch is re-established: the outage clears, and an @@ -306,8 +306,8 @@ func (b *boot) startRuntimeResourceWatches(ctx context.Context, versions map[str go servicekit.KeepWatch(ctx, b.log, kind, versions[kind], updates, open, servicekit.WaitFor, - func(update controlplane.AppliedResource) int64 { return update.Version }, - func(update controlplane.AppliedResource) { + func(update controlplanestore.AppliedResource) int64 { return update.Version }, + func(update controlplanestore.AppliedResource) { if update.Err != nil { // A stream failure carries no version at all, and a process // must never report an unreachable store as its own @@ -361,8 +361,8 @@ func (b *boot) startRuntimeResourceWatches(ctx context.Context, versions map[str // The returned error is the refusal or rejection, for the watch to keep as // lastApplyErr: it is what keeps the outage callback from overwriting a // refusal the record already shows with a transport gap. -func (b *boot) applyRuntimeResourceUpdate(ctx context.Context, kind string, update controlplane.AppliedResource) error { - if kind == controlplane.PluginSettingsKind { +func (b *boot) applyRuntimeResourceUpdate(ctx context.Context, kind string, update controlplanestore.AppliedResource) error { + if kind == controlplanestore.PluginSettingsKind { if err := b.refuseSkillsDirChange(ctx); err != nil { b.applyStatus.Report(ctx, kind, update.Version, err) b.log.Error("plugin settings refused; the running settings stay", "version", update.Version, "err", err) @@ -385,13 +385,13 @@ func (b *boot) applyRuntimeResourceUpdate(ctx context.Context, kind string, upda } b.publishConfig(ctx, cfg) b.log.Info("runtime settings applied", "kind", kind, "version", update.Version) - if kind == controlplane.ContainerRuntimePoliciesKind { + if kind == controlplanestore.ContainerRuntimePoliciesKind { // The pool reads the republished config itself; the dispatcher holds // its limit, so a raise must be woken to admit queued work now and a // lower must be honoured as running tasks finish. b.resizeTaskDispatcher(cfg.Containers.MaxConcurrency) } - if kind == controlplane.ForgeConnectionsKind { + if kind == controlplanestore.ForgeConnectionsKind { // The forge client is built from the credential rather than taken from // the published config, so the change that published it must reach the // client too: a rotated token otherwise keeps authenticating with the @@ -420,7 +420,7 @@ func (b *boot) refuseSkillsDirChange(ctx context.Context) error { var stored struct { SkillsDir string `json:"skills_dir"` } - _, found, err := b.controlPlane.Query(ctx, controlplane.PluginSettingsKind, func(value []byte) error { + _, found, err := b.controlPlane.Query(ctx, controlplanestore.PluginSettingsKind, func(value []byte) error { return json.Unmarshal(value, &stored) }) if err != nil { diff --git a/internal/app/archied/issue_discovery.go b/internal/app/archied/issue_discovery.go index 7371c5c1b..42ff0ae5d 100644 --- a/internal/app/archied/issue_discovery.go +++ b/internal/app/archied/issue_discovery.go @@ -4,13 +4,13 @@ import ( "context" "encoding/json" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/daemon" "github.com/samcharles93/archie-core/internal/domain/access" "github.com/samcharles93/archie-core/internal/domain/identity" "github.com/samcharles93/archie-core/internal/domain/org" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" ) // orgAgents is every organisation with the principals that may act in it, @@ -82,7 +82,7 @@ func (b *boot) issueSources(ctx context.Context) []daemon.IssueSource { log := b.log.With("org", o.owner) octx := o.act(ctx) var repos []config.Repo - if _, found, err := b.controlPlane.Query(octx, controlplane.RepositoryPoliciesKind, func(value []byte) error { return json.Unmarshal(value, &repos) }); err != nil || !found { + if _, found, err := b.controlPlane.Query(octx, controlplanestore.RepositoryPoliciesKind, func(value []byte) error { return json.Unmarshal(value, &repos) }); err != nil || !found { log.Warn("issue discovery: repositories unavailable", "err", err) continue } diff --git a/internal/app/archied/repository_access.go b/internal/app/archied/repository_access.go index 3b7cc4d55..1bcdc8c6c 100644 --- a/internal/app/archied/repository_access.go +++ b/internal/app/archied/repository_access.go @@ -6,13 +6,13 @@ import ( "fmt" "strings" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/daemon" "github.com/samcharles93/archie-core/internal/domain/access" "github.com/samcharles93/archie-core/internal/domain/org" "github.com/samcharles93/archie-core/internal/domain/workflow" "github.com/samcharles93/archie-core/internal/forge" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/worktree" ) @@ -54,7 +54,7 @@ func (b *boot) repositoryAccess(ctx context.Context, task *workflow.Task, operat func (b *boot) repositoryBinding(ctx context.Context, owner, name string) (config.Repo, error) { var repos []config.Repo - _, found, err := b.controlPlane.Query(ctx, controlplane.RepositoryPoliciesKind, func(value []byte) error { return json.Unmarshal(value, &repos) }) + _, found, err := b.controlPlane.Query(ctx, controlplanestore.RepositoryPoliciesKind, func(value []byte) error { return json.Unmarshal(value, &repos) }) if err != nil || !found { return config.Repo{}, &forge.AccessError{Code: "configuration_unavailable", Message: "Repository settings could not be loaded. Try again."} } @@ -68,7 +68,7 @@ func (b *boot) repositoryBinding(ctx context.Context, owner, name string) (confi func (b *boot) repositoryConnections(ctx context.Context) ([]config.ForgeConnection, error) { var connections []config.ForgeConnection - _, found, err := b.controlPlane.Query(ctx, controlplane.ForgeConnectionsKind, func(value []byte) error { return json.Unmarshal(value, &connections) }) + _, found, err := b.controlPlane.Query(ctx, controlplanestore.ForgeConnectionsKind, func(value []byte) error { return json.Unmarshal(value, &connections) }) if err != nil || !found { return nil, &forge.AccessError{Code: "configuration_unavailable", Message: "Connection settings could not be loaded. Try again."} } diff --git a/internal/app/archied/repository_access_test.go b/internal/app/archied/repository_access_test.go index 86d6784e6..c62de654e 100644 --- a/internal/app/archied/repository_access_test.go +++ b/internal/app/archied/repository_access_test.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/config" controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1" daemonpb "github.com/samcharles93/archie-core/internal/contracts/daemon/v1" @@ -30,6 +29,7 @@ import ( "github.com/samcharles93/archie-core/internal/domain/org" "github.com/samcharles93/archie-core/internal/domain/workflow" infraaccess "github.com/samcharles93/archie-core/internal/infrastructure/access" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/secret" "github.com/samcharles93/archie-core/internal/worktree" ) @@ -42,7 +42,7 @@ type repositoryDocuments struct { func (d *repositoryDocuments) Query(ctx context.Context, r *controlpb.QueryRequest, _ ...grpc.CallOption) (*controlpb.QueryResponse, error) { var doc any = d.repos[org.OrgFromContext(ctx)] - if r.Kind == controlplane.ForgeConnectionsKind { + if r.Kind == controlplanestore.ForgeConnectionsKind { doc = d.connections[org.OrgFromContext(ctx)] } value, err := json.Marshal(doc) @@ -55,7 +55,7 @@ func TestRepositoryConnectionAccess(t *testing.T) { repos: map[org.OrgID][]config.Repo{"org-a": {{Owner: "acme", Name: "app", Connection: "github", Base: "main"}}}, connections: map[org.OrgID][]config.ForgeConnection{"org-a": {{ID: "github", Name: "GitHub", Type: "github", Host: "github.com", Token: config.SecretRef{Engine: "env", Key: "ARCHIE_TEST_CONNECTION_TOKEN"}, Permits: map[string][]string{"bot-a": {"clone"}}}}}, } - b := &boot{controlPlane: controlplane.NewRPCClient(docs), cfgHolder: config.NewHolder(config.Config{WorkDir: t.TempDir(), BotUser: "author", BotEmail: "author@example.test"}), secrets: secret.NewRegistry(), log: slog.New(slog.DiscardHandler)} + b := &boot{controlPlane: controlplanestore.NewRPCClient(docs), cfgHolder: config.NewHolder(config.Config{WorkDir: t.TempDir(), BotUser: "author", BotEmail: "author@example.test"}), secrets: secret.NewRegistry(), log: slog.New(slog.DiscardHandler)} for _, tt := range []struct { name, actingOrg, agent, op string denied bool @@ -174,7 +174,7 @@ func TestPrivateRepositoryConnection(t *testing.T) { })) defer fixture.Close() docs := &repositoryDocuments{repos: map[org.OrgID][]config.Repo{"org-a": {{Owner: "acme", Name: "app", Connection: "private", Base: "main"}}}, connections: map[org.OrgID][]config.ForgeConnection{"org-a": {{ID: "private", Name: "Private forge", Type: "gitea", Host: fixture.URL, Account: "forge-account", Token: config.SecretRef{Engine: "env", Key: "ARCHIE_TEST_CONNECTION_TOKEN"}, Permits: map[string][]string{"bot-a": {"clone", "push"}}}}}} - b := &boot{controlPlane: controlplane.NewRPCClient(docs), cfgHolder: config.NewHolder(config.Config{WorkDir: t.TempDir(), BotUser: "Commit author", BotEmail: "author@example.test"}), secrets: secret.NewRegistry(), log: slog.New(slog.DiscardHandler)} + b := &boot{controlPlane: controlplanestore.NewRPCClient(docs), cfgHolder: config.NewHolder(config.Config{WorkDir: t.TempDir(), BotUser: "Commit author", BotEmail: "author@example.test"}), secrets: secret.NewRegistry(), log: slog.New(slog.DiscardHandler)} b.d = &daemon.Daemon{Access: infraaccess.New(access.ShippedOrgPolicies("org-a")), Principals: connectionPrincipals{"bot-a": "org-a", "bot-b": "org-b"}, IdentityRepository: connectionIdentities{}, AgentAssignments: connectionAssignments{}, ResolveRepository: b.repositoryAccess} checker := &repositoryServer{boot: b} request := &daemonpb.CheckRepositoryRequest{Owner: "acme", Repository: "app", IdentityId: "bot-a"} diff --git a/internal/app/archied/scheduling.go b/internal/app/archied/scheduling.go index 0e1dbb3d0..c470ce185 100644 --- a/internal/app/archied/scheduling.go +++ b/internal/app/archied/scheduling.go @@ -8,13 +8,13 @@ import ( "strings" "time" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/domain/access" "github.com/samcharles93/archie-core/internal/domain/org" "github.com/samcharles93/archie-core/internal/domain/scheduling" "github.com/samcharles93/archie-core/internal/events" "github.com/samcharles93/archie-core/internal/gateway" "github.com/samcharles93/archie-core/internal/infrastructure/configuration" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/infrastructure/crondelivery" "github.com/samcharles93/archie-core/internal/infrastructure/cronevents" ) @@ -117,7 +117,7 @@ type orgDirectory interface { // ids are "/" so one engine ticks all orgs, and each lookup or // run record acts under the owning org's principal. type scheduleResourceStore struct { - client *controlplane.Client + client *controlplanestore.Client orgs orgDirectory log *slog.Logger } @@ -275,11 +275,11 @@ func (s scheduleResourceStore) MarkRun(ctx context.Context, key string, runAt ti if err == nil { return nil } - if !errors.Is(err, controlplane.ErrVersionConflict) { + if !errors.Is(err, controlplanestore.ErrVersionConflict) { return err } } - return controlplane.ErrVersionConflict + return controlplanestore.ErrVersionConflict } // shutdownSchedulingEngine returns a cleanup that stops the ticker engine. diff --git a/internal/app/archied/step_vocabulary.go b/internal/app/archied/step_vocabulary.go index a36ce8621..77753ffd0 100644 --- a/internal/app/archied/step_vocabulary.go +++ b/internal/app/archied/step_vocabulary.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/domain/workflow" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/infrastructure/workflowsteps" ) @@ -37,14 +37,14 @@ func stepVocabulary() (*workflow.Manager, error) { return workflowsteps.NewManag // cannot consume it must not be failed by it. // // The daemon reads definitions through it; no production process replaces -// definitions yet (see controlplane.WorkflowDefinitionsClient. +// definitions yet (see controlplanestore.WorkflowDefinitionsClient. // ReplaceWorkflowDefinitions). func (b *boot) openDaemonWorkflowDefinitions() error { steps, err := stepVocabulary() if err != nil { return fmt.Errorf("register workflow step vocabulary: %w", err) } - definitions, err := controlplane.NewWorkflowDefinitionsClient(b.controlPlaneRPC, steps) + definitions, err := controlplanestore.NewWorkflowDefinitionsClient(b.controlPlaneRPC, steps) if err != nil { return fmt.Errorf("build workflow definitions client: %w", err) } diff --git a/internal/app/archied/update_image.go b/internal/app/archied/update_image.go index b4c56cb08..a0bfb66f8 100644 --- a/internal/app/archied/update_image.go +++ b/internal/app/archied/update_image.go @@ -8,10 +8,10 @@ import ( "fmt" "log/slog" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/app/servicekit" pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1" "github.com/samcharles93/archie-core/internal/domain/presence" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" ) // imagePolicy is the control plane's agent image, reached through the State @@ -44,7 +44,7 @@ func (p imagePolicy) SetImage(ctx context.Context, expected, desired string) err if err != nil { return err } - _, err = rpc.Command(ctx, &pb.CommandRequest{Kind: controlplane.ContainerRuntimePoliciesKind, Command: "replace", ValueJson: data, ExpectedVersion: response.Resource.Version, Actor: "self-update", Source: "installer", RequestId: fmt.Sprintf("self-update-%x-%d", sha256.Sum256(data), response.Resource.Version)}) + _, err = rpc.Command(ctx, &pb.CommandRequest{Kind: controlplanestore.ContainerRuntimePoliciesKind, Command: "replace", ValueJson: data, ExpectedVersion: response.Resource.Version, Actor: "self-update", Source: "installer", RequestId: fmt.Sprintf("self-update-%x-%d", sha256.Sum256(data), response.Resource.Version)}) return err }) } @@ -60,7 +60,7 @@ func (p imagePolicy) with(ctx context.Context, use func(pb.ControlPlaneServiceCl } defer cleanup() rpc := client.ControlPlane() - response, err := rpc.Query(ctx, &pb.QueryRequest{Kind: controlplane.ContainerRuntimePoliciesKind}) + response, err := rpc.Query(ctx, &pb.QueryRequest{Kind: controlplanestore.ContainerRuntimePoliciesKind}) if err != nil { return err } diff --git a/internal/app/archiegateway/curators.go b/internal/app/archiegateway/curators.go index ba07317d7..0fccc482a 100644 --- a/internal/app/archiegateway/curators.go +++ b/internal/app/archiegateway/curators.go @@ -11,11 +11,11 @@ import ( "github.com/samcharles93/ai-sdk/runtime" "github.com/samcharles93/archie-core/internal/agentexec/modelloop" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/domain/curator" "github.com/samcharles93/archie-core/internal/domain/usage" "github.com/samcharles93/archie-core/internal/events" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" infraMemory "github.com/samcharles93/archie-core/internal/infrastructure/memory" "github.com/samcharles93/archie-core/internal/infrastructure/sessioncurator" "github.com/samcharles93/archie-core/internal/infrastructure/skillcurator" @@ -161,7 +161,7 @@ func (r curatorLLMRunner) Chat(ctx context.Context, req curator.ChatRequest) (cu func (b *server) applyCurators(ctx context.Context, defs []config.CuratorDefinition) error { definitions := make([]curator.Definition, 0, len(defs)) for _, def := range defs { - definitions = append(definitions, controlplane.CuratorDefinition(def)) + definitions = append(definitions, controlplanestore.CuratorDefinition(def)) } return b.curatorRuntime.ReplaceDefinitions(ctx, definitions) } @@ -171,10 +171,10 @@ func (b *server) watchCurators(ctx context.Context, version int64) error { if err != nil { return err } - watchStatus(ctx, b.applyStatus.Report, b.log, controlplane.CuratorsKind, "curators", version, updates, b.controlPlane.WatchCurators, - func(update controlplane.AppliedCurators) int64 { return update.Version }, - func(update controlplane.AppliedCurators) error { return update.Err }, - func(update controlplane.AppliedCurators) error { return b.applyCurators(ctx, update.Definitions) }) + watchStatus(ctx, b.applyStatus.Report, b.log, controlplanestore.CuratorsKind, "curators", version, updates, b.controlPlane.WatchCurators, + func(update controlplanestore.AppliedCurators) int64 { return update.Version }, + func(update controlplanestore.AppliedCurators) error { return update.Err }, + func(update controlplanestore.AppliedCurators) error { return b.applyCurators(ctx, update.Definitions) }) return nil } @@ -190,7 +190,7 @@ func (b *server) startCurators(ctx context.Context) error { if err == nil { err = b.applyCurators(ctx, defs) } - b.applyStatus.Report(ctx, controlplane.CuratorsKind, version, err) + b.applyStatus.Report(ctx, controlplanestore.CuratorsKind, version, err) if err != nil { b.log.Error("curator definitions apply failed", "err", err) } diff --git a/internal/app/archiegateway/gateway_runtime.go b/internal/app/archiegateway/gateway_runtime.go index 5eec330f3..393ddd884 100644 --- a/internal/app/archiegateway/gateway_runtime.go +++ b/internal/app/archiegateway/gateway_runtime.go @@ -7,7 +7,6 @@ import ( "github.com/samcharles93/archie-core/internal/agentexec/modelloop" "github.com/samcharles93/archie-core/internal/app/chattask" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/buildinfo" "github.com/samcharles93/archie-core/internal/config" @@ -16,6 +15,7 @@ import ( "github.com/samcharles93/archie-core/internal/domain/taskactions" "github.com/samcharles93/archie-core/internal/gateway" "github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/taskstate" "github.com/samcharles93/archie-core/internal/tools" ) @@ -49,7 +49,7 @@ func (b *server) setupChatRuntime(ctx context.Context, cfg config.Config, actor } b.soul = newSoulSource(b.cfgPath, b.log) b.applySoul(soul, version) - b.applyStatus.Report(ctx, controlplane.SoulKind, version, nil) + b.applyStatus.Report(ctx, controlplanestore.SoulKind, version, nil) if err := b.watchSoul(ctx, version); err != nil { return fmt.Errorf("watch soul: %w", err) } @@ -162,11 +162,11 @@ func (b *server) watchSoul(ctx context.Context, version int64) error { return err } watchStatus(ctx, b.applyStatus.Report, b.log, - controlplane.SoulKind, "soul", version, updates, + controlplanestore.SoulKind, "soul", version, updates, b.controlPlane.WatchSoul, - func(update controlplane.AppliedSoul) int64 { return update.Version }, - func(update controlplane.AppliedSoul) error { return update.Err }, - func(update controlplane.AppliedSoul) error { + func(update controlplanestore.AppliedSoul) int64 { return update.Version }, + func(update controlplanestore.AppliedSoul) error { return update.Err }, + func(update controlplanestore.AppliedSoul) error { b.applySoul(update.Soul, update.Version) return nil }) diff --git a/internal/app/archiegateway/server.go b/internal/app/archiegateway/server.go index c6e8fa0a2..2688d1a68 100644 --- a/internal/app/archiegateway/server.go +++ b/internal/app/archiegateway/server.go @@ -16,7 +16,6 @@ import ( natsio "github.com/nats-io/nats.go" "github.com/samcharles93/ai-sdk/runtime" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/domain/applystatus" @@ -28,6 +27,7 @@ import ( "github.com/samcharles93/archie-core/internal/events" "github.com/samcharles93/archie-core/internal/gateway" "github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog" "github.com/samcharles93/archie-core/internal/infrastructure/readiness" "github.com/samcharles93/archie-core/internal/infrastructure/rpctls" @@ -66,7 +66,7 @@ type server struct { id *rpctls.Identity engines *secretengine.Runner stateStore *staterpc.Client - controlPlane *controlplane.Client + controlPlane *controlplanestore.Client applyStatus *applystatus.Reporter runtimeVersions map[string]int64 catalog *modelcatalog.Catalog @@ -183,7 +183,7 @@ func (b *server) openState(ctx context.Context) error { } b.addCleanup(cleanup) b.stateStore = client - b.controlPlane = controlplane.NewRPCClient(client.ControlPlane()) + b.controlPlane = controlplanestore.NewRPCClient(client.ControlPlane()) b.applyStatus = applystatus.New(applystatus.Gateway, client, b.log) source := secretengine.Source{Query: b.controlPlane, Packages: client} report := func(ctx context.Context, version int64, err error) { @@ -289,9 +289,9 @@ func (b *server) startModelCatalogRefresh(ctx context.Context) { // gatewayRuntimeKinds are the kinds the Gateway applies live: the settings its // chat runtime and tool providers are built from. var gatewayRuntimeKinds = []string{ - controlplane.ProviderSettingsKind, - controlplane.ModelAliasesKind, - controlplane.ToolSettingsKind, + controlplanestore.ProviderSettingsKind, + controlplanestore.ModelAliasesKind, + controlplanestore.ToolSettingsKind, } func (b *server) startRuntimeWatches(ctx context.Context) error { @@ -301,7 +301,7 @@ func (b *server) startRuntimeWatches(ctx context.Context) error { base := b.cfgHolder.Get() catalog := b.catalogState() modelcatalog.Apply(&base, catalog) - _ = b.relayer(ctx, base, controlplane.ProviderSettingsKind) + _ = b.relayer(ctx, base, controlplanestore.ProviderSettingsKind) }) for _, kind := range gatewayRuntimeKinds { updates, err := b.controlPlane.WatchResource(ctx, kind, b.runtimeVersions[kind]) @@ -309,7 +309,7 @@ func (b *server) startRuntimeWatches(ctx context.Context) error { return fmt.Errorf("watch %s: %w", kind, err) } var lastApplyErr, streamErr error - open := func(ctx context.Context, afterVersion int64) (<-chan controlplane.AppliedResource, error) { + open := func(ctx context.Context, afterVersion int64) (<-chan controlplanestore.AppliedResource, error) { next, err := b.controlPlane.WatchResource(ctx, kind, afterVersion) if err == nil { // A live watch is re-established: the outage clears, and an @@ -321,8 +321,8 @@ func (b *server) startRuntimeWatches(ctx context.Context) error { go servicekit.KeepWatch(ctx, b.log, kind, b.runtimeVersions[kind], updates, open, servicekit.WaitFor, - func(update controlplane.AppliedResource) int64 { return update.Version }, - func(update controlplane.AppliedResource) { + func(update controlplanestore.AppliedResource) int64 { return update.Version }, + func(update controlplanestore.AppliedResource) { if update.Err != nil { // A stream failure carries no version: the outage is what the // end callback records. A refused document carries its version @@ -373,7 +373,7 @@ func (b *server) relayer(ctx context.Context, base config.Config, kind string) e b.cfgHolder.Set(cfg) b.rebuildChatModelRuntime(cfg) var problems []error - if kind == controlplane.ToolSettingsKind { + if kind == controlplanestore.ToolSettingsKind { if err := b.reconcileToolSettings(ctx, cfg); err != nil { b.applyStatus.Report(ctx, kind, versions[kind], err) b.log.Error("tool settings reconciled with errors; the running servers stay", "err", err) diff --git a/internal/app/archiegateway/skills.go b/internal/app/archiegateway/skills.go index 1783a5cc2..e5e60f122 100644 --- a/internal/app/archiegateway/skills.go +++ b/internal/app/archiegateway/skills.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/domain/applystatus" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/skill" ) @@ -40,17 +40,17 @@ func (b *server) refreshSkills(ctx context.Context, applied *string) { cfg, log := b.cfg, b.log catalog, err := skill.CatalogRoots(skill.DefaultRoots(cfg.WorkDir, cfg.SkillsDir)...) if err != nil { - b.applyStatus.Report(ctx, controlplane.SkillsKind, 0, err) + b.applyStatus.Report(ctx, controlplanestore.SkillsKind, 0, err) log.Warn("skill catalog load failed", "err", err) return } stored, version, err := b.storedSkills(ctx, catalog) if err != nil { - b.applyStatus.Report(ctx, controlplane.SkillsKind, version, err) + b.applyStatus.Report(ctx, controlplanestore.SkillsKind, version, err) return } var applyErr error - defer func() { b.applyStatus.Report(ctx, controlplane.SkillsKind, version, applyErr) }() + defer func() { b.applyStatus.Report(ctx, controlplanestore.SkillsKind, version, applyErr) }() catalog = append(catalog, stored...) b.setSkillList(catalog) signature := catalogSignature(catalog) @@ -73,8 +73,8 @@ func (b *server) refreshSkills(ctx context.Context, applied *string) { // have. An unreadable resource leaves the running catalog in place. func (b *server) storedSkills(ctx context.Context, have []skill.CatalogEntry) ([]skill.CatalogEntry, int64, error) { var out []skill.CatalogEntry - version, _, err := b.controlPlane.Query(ctx, controlplane.SkillsKind, func(value []byte) error { - var collection controlplane.SkillCollection + version, _, err := b.controlPlane.Query(ctx, controlplanestore.SkillsKind, func(value []byte) error { + var collection controlplanestore.SkillCollection if err := json.Unmarshal(value, &collection); err != nil { return err } diff --git a/internal/app/statestore/audit_retention.go b/internal/app/statestore/audit_retention.go index 10b60f0a5..6de345438 100644 --- a/internal/app/statestore/audit_retention.go +++ b/internal/app/statestore/audit_retention.go @@ -6,9 +6,9 @@ import ( "slices" "time" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/domain/storecontract" "github.com/samcharles93/archie-core/internal/events" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/infrastructure/postgres" ) @@ -138,14 +138,14 @@ func (b *server) pruneAuditEvents(ctx context.Context) { if !ok { return } - resource, err := resources.Resource(ctx, storecontract.DefaultOrgID, controlplane.AuditRetentionKind) + resource, err := resources.Resource(ctx, storecontract.DefaultOrgID, controlplanestore.AuditRetentionKind) if err != nil { if ctx.Err() == nil { b.log.Warn("audit retention not applied: setting unreadable, sweep skipped", "err", err) } return } - retention, err := controlplane.RuntimeEventRetention(resource.Value) + retention, err := controlplanestore.RuntimeEventRetention(resource.Value) if err != nil { if ctx.Err() == nil { b.log.Warn("audit retention not applied: setting invalid, sweep skipped", "err", err) diff --git a/internal/app/statestore/recovery.go b/internal/app/statestore/recovery.go index 94836dc20..5f3c084c2 100644 --- a/internal/app/statestore/recovery.go +++ b/internal/app/statestore/recovery.go @@ -24,11 +24,11 @@ import ( "fmt" "time" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/config" pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1" "github.com/samcharles93/archie-core/internal/domain/storecontract" "github.com/samcharles93/archie-core/internal/infrastructure/configuration" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" ) // The audit identity every offline rollback records. A rollback is one more @@ -79,7 +79,7 @@ func RunRecovery(ctx context.Context, options RecoveryOptions) (string, error) { // checkBootGate runs the writer's per-resource validation over what is stored, // then boot's gate over the file config with the stored resources layered on, // and returns how many stored resources validated. -func checkBootGate(ctx context.Context, server *controlplane.Server, stored bool, options RecoveryOptions) (int, error) { +func checkBootGate(ctx context.Context, server *controlplanestore.Server, stored bool, options RecoveryOptions) (int, error) { checked := 0 if stored { var err error @@ -126,7 +126,7 @@ func bootConfig(ctx context.Context, options RecoveryOptions) (config.Config, er // replayRevision puts back the revision options names through the control // plane's ordinary replace. The caller holds the store's ownership claim. -func replayRevision(ctx context.Context, resources controlplane.ResourceStore, options RecoveryOptions) (string, error) { +func replayRevision(ctx context.Context, resources controlplanestore.ResourceStore, options RecoveryOptions) (string, error) { server, err := openStateStoreControlPlane(resources) if err != nil { return "", err @@ -163,7 +163,7 @@ func replayRevision(ctx context.Context, resources controlplane.ResourceStore, o // revisionToReplay picks the value to put back: the revision the operator // named, or the newest one older than the value the resource carries now. -func revisionToReplay(ctx context.Context, st controlplane.ResourceStore, kind string, current, requested int64) (storecontract.Resource, error) { +func revisionToReplay(ctx context.Context, st controlplanestore.ResourceStore, kind string, current, requested int64) (storecontract.Resource, error) { history, err := st.ResourceHistory(ctx, storecontract.DefaultOrgID, kind, 0) if err != nil { return storecontract.Resource{}, fmt.Errorf("read %s history: %w", kind, err) diff --git a/internal/app/statestore/server.go b/internal/app/statestore/server.go index e1e8a081b..2d3dafdc7 100644 --- a/internal/app/statestore/server.go +++ b/internal/app/statestore/server.go @@ -15,7 +15,6 @@ import ( "github.com/jackc/pgx/v5/pgxpool" "google.golang.org/grpc" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/domain/access" @@ -29,6 +28,7 @@ import ( "github.com/samcharles93/archie-core/internal/domain/storepkg" "github.com/samcharles93/archie-core/internal/domain/usage" infraaccess "github.com/samcharles93/archie-core/internal/infrastructure/access" + "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" "github.com/samcharles93/archie-core/internal/infrastructure/postgres" "github.com/samcharles93/archie-core/internal/infrastructure/readiness" "github.com/samcharles93/archie-core/internal/infrastructure/rpcidentity" @@ -95,7 +95,7 @@ func Run(ctx context.Context, options Options) error { //nolint:cyclop // the co } // The validating side's control plane, built here at the composition root // before the first definition is read or replaced. - resources, ok := b.st.(controlplane.ResourceStore) + resources, ok := b.st.(controlplanestore.ResourceStore) if !ok { return fmt.Errorf("state store does not support control-plane resources") } @@ -200,7 +200,7 @@ func (b *server) seedAndValidatePolicies(ctx context.Context) error { // It is a method rather than a loop in Run because the boot sequence // is at its complexity budget: the branch belongs to the report's own policy, // not to the sequence that triggers it. -func (b *server) reportUnseededResources(skipped []controlplane.SeedSkip) { +func (b *server) reportUnseededResources(skipped []controlplanestore.SeedSkip) { for _, skip := range skipped { b.log.Error("control-plane resource not seeded; the kind stays absent and the file's value is the one in effect", "kind", skip.Kind, "err", skip.Err) @@ -214,12 +214,12 @@ func (b *server) reportUnseededResources(skipped []controlplane.SeedSkip) { // registers before it compiles one, so within one build a definition this // server admits is compilable there; a skewed deploy is only fixed by a // matching deploy. -func openStateStoreControlPlane(resources controlplane.ResourceStore) (*controlplane.Server, error) { +func openStateStoreControlPlane(resources controlplanestore.ResourceStore) (*controlplanestore.Server, error) { steps, err := workflowsteps.NewManager() if err != nil { return nil, fmt.Errorf("register workflow step vocabulary: %w", err) } - server, err := controlplane.NewServer(resources, steps) + server, err := controlplanestore.NewServer(resources, steps) if err != nil { return nil, fmt.Errorf("build control plane server: %w", err) } @@ -522,21 +522,21 @@ func newPackageProjections(pool *pgxpool.Pool) (map[string]storepkg.FamilyProjec if err != nil { return nil, fmt.Errorf("register workflow step vocabulary: %w", err) } - workflows, err := controlplane.NewWorkflowPackageProjector( + workflows, err := controlplanestore.NewWorkflowPackageProjector( postgres.NewResources(pool), postgres.NewPackageContributions(pool), steps) if err != nil { return nil, fmt.Errorf("build workflow package projector: %w", err) } resources, ledger := postgres.NewResources(pool), postgres.NewPackageContributions(pool) - playbooks, err := controlplane.NewPlaybookPackageProjector(resources, ledger) + playbooks, err := controlplanestore.NewPlaybookPackageProjector(resources, ledger) if err != nil { return nil, fmt.Errorf("build playbook package projector: %w", err) } - profiles, err := controlplane.NewProfilePackageProjector(resources, ledger) + profiles, err := controlplanestore.NewProfilePackageProjector(resources, ledger) if err != nil { return nil, fmt.Errorf("build profile package projector: %w", err) } - skills, err := controlplane.NewSkillPackageProjector(resources, ledger) + skills, err := controlplanestore.NewSkillPackageProjector(resources, ledger) if err != nil { return nil, fmt.Errorf("build skill package projector: %w", err) } @@ -550,7 +550,7 @@ func newPackageProjections(pool *pgxpool.Pool) (map[string]storepkg.FamilyProjec // controlPlaneDeps serves the control plane and the per-org model answers // built on it. -func controlPlaneDeps(deps *staterpc.Deps, control *controlplane.Server) { +func controlPlaneDeps(deps *staterpc.Deps, control *controlplanestore.Server) { deps.ControlPlane = control deps.OrgModels = func(ctx context.Context, orgID string) (map[string]string, map[string]config.Provider, error) { models, err := control.ModelsFor(ctx, orgID) diff --git a/internal/infrastructure/controlplanerpc/client.go b/internal/infrastructure/controlplanerpc/client.go index 250964b4b..b64e33848 100644 --- a/internal/infrastructure/controlplanerpc/client.go +++ b/internal/infrastructure/controlplanerpc/client.go @@ -18,7 +18,7 @@ import ( // ChannelSettingsKind is the control-plane resource kind holding the channel // settings document. It is declared here because this package owns the document -// and the client names the kind; internal/app/controlplane re-exports it, so the +// and the client names the kind; internal/infrastructure/controlplanestore re-exports it, so the // store-backed side and its callers keep one name for one kind. const ChannelSettingsKind = "channel-settings" @@ -39,7 +39,7 @@ func NewRPCClient(client pb.ControlPlaneServiceClient) *Client { return &Client{ // ResourceReader is the read side of the control-plane client: one resource // query per kind. The store-backed server implements it too, which is why the -// layering functions here are shared with internal/app/controlplane. +// layering functions here are shared with internal/infrastructure/controlplanestore. type ResourceReader interface { Query(ctx context.Context, kind string, decode func([]byte) error) (int64, bool, error) } diff --git a/internal/app/controlplane/agent_profiles.go b/internal/infrastructure/controlplanestore/agent_profiles.go similarity index 98% rename from internal/app/controlplane/agent_profiles.go rename to internal/infrastructure/controlplanestore/agent_profiles.go index 9ff138b24..cb748506f 100644 --- a/internal/app/controlplane/agent_profiles.go +++ b/internal/infrastructure/controlplanestore/agent_profiles.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import "github.com/samcharles93/archie-core/internal/config" diff --git a/internal/app/controlplane/audit_retention.go b/internal/infrastructure/controlplanestore/audit_retention.go similarity index 99% rename from internal/app/controlplane/audit_retention.go rename to internal/infrastructure/controlplanestore/audit_retention.go index 2c9390694..78fd1e291 100644 --- a/internal/app/controlplane/audit_retention.go +++ b/internal/infrastructure/controlplanestore/audit_retention.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "bytes" diff --git a/internal/app/controlplane/channel_settings.go b/internal/infrastructure/controlplanestore/channel_settings.go similarity index 98% rename from internal/app/controlplane/channel_settings.go rename to internal/infrastructure/controlplanestore/channel_settings.go index 651ab5330..bd29e8922 100644 --- a/internal/app/controlplane/channel_settings.go +++ b/internal/infrastructure/controlplanestore/channel_settings.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "encoding/json" diff --git a/internal/app/controlplane/client.go b/internal/infrastructure/controlplanestore/client.go similarity index 99% rename from internal/app/controlplane/client.go rename to internal/infrastructure/controlplanestore/client.go index 2c6d5258a..d226e587a 100644 --- a/internal/app/controlplane/client.go +++ b/internal/infrastructure/controlplanestore/client.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/container_settings.go b/internal/infrastructure/controlplanestore/container_settings.go similarity index 99% rename from internal/app/controlplane/container_settings.go rename to internal/infrastructure/controlplanestore/container_settings.go index 4bd1fadb4..79f44e3e0 100644 --- a/internal/app/controlplane/container_settings.go +++ b/internal/infrastructure/controlplanestore/container_settings.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "encoding/json" diff --git a/internal/app/controlplane/controlplane.go b/internal/infrastructure/controlplanestore/controlplane.go similarity index 98% rename from internal/app/controlplane/controlplane.go rename to internal/infrastructure/controlplanestore/controlplane.go index 717287161..d30334e82 100644 --- a/internal/app/controlplane/controlplane.go +++ b/internal/infrastructure/controlplanestore/controlplane.go @@ -1,5 +1,5 @@ -// Package controlplane owns control-plane resource registration, dispatch, and validation. -package controlplane +// Package controlplanestore owns control-plane resource registration, dispatch, and validation. +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/credential_bindings.go b/internal/infrastructure/controlplanestore/credential_bindings.go similarity index 99% rename from internal/app/controlplane/credential_bindings.go rename to internal/infrastructure/controlplanestore/credential_bindings.go index c23449bc0..a3f363ee4 100644 --- a/internal/app/controlplane/credential_bindings.go +++ b/internal/infrastructure/controlplanestore/credential_bindings.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import "github.com/samcharles93/archie-core/internal/config" diff --git a/internal/app/controlplane/curators.go b/internal/infrastructure/controlplanestore/curators.go similarity index 99% rename from internal/app/controlplane/curators.go rename to internal/infrastructure/controlplanestore/curators.go index 1cc84bac0..aa1b00f91 100644 --- a/internal/app/controlplane/curators.go +++ b/internal/infrastructure/controlplanestore/curators.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/definitions.go b/internal/infrastructure/controlplanestore/definitions.go similarity index 96% rename from internal/app/controlplane/definitions.go rename to internal/infrastructure/controlplanestore/definitions.go index 28fbc6d58..86a98c54b 100644 --- a/internal/app/controlplane/definitions.go +++ b/internal/infrastructure/controlplanestore/definitions.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1" @@ -6,7 +6,7 @@ import ( ) // Schemas are not declared here: each Definition names its document type, and -// Definition.Descriptor derives the JSON Schema from it (internal/app/controlplane/schema.go). +// Definition.Descriptor derives the JSON Schema from it (internal/infrastructure/controlplanestore/schema.go). func builtinDefinitions(steps workflow.StepRegistry, settings map[string]any) []Definition { definitions := []Definition{taskPolicyDefinition(), workflowDefinition(), workflowDefinitionsDefinition(steps, settings), workflowDraftsDefinition(), workflowEnablementDefinition(), curatorDefinition(), soulDefinition(), scheduleDefinition(), agentProfileDefinition(), playbooksDefinition(), skillsDefinition(), credentialBindingsDefinition(), identityGrantsDefinition(), orgModelPolicyDefinition(), forgeConnectionsDefinition()} definitions = append(definitions, modelDefinitions()...) diff --git a/internal/app/controlplane/forge_connection_layering_test.go b/internal/infrastructure/controlplanestore/forge_connection_layering_test.go similarity index 99% rename from internal/app/controlplane/forge_connection_layering_test.go rename to internal/infrastructure/controlplanestore/forge_connection_layering_test.go index 0a101a73f..db0a8d4d6 100644 --- a/internal/app/controlplane/forge_connection_layering_test.go +++ b/internal/infrastructure/controlplanestore/forge_connection_layering_test.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/forge_connections.go b/internal/infrastructure/controlplanestore/forge_connections.go similarity index 99% rename from internal/app/controlplane/forge_connections.go rename to internal/infrastructure/controlplanestore/forge_connections.go index 1a3179efd..bd6fe8131 100644 --- a/internal/app/controlplane/forge_connections.go +++ b/internal/infrastructure/controlplanestore/forge_connections.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "fmt" diff --git a/internal/app/controlplane/forge_connections_test.go b/internal/infrastructure/controlplanestore/forge_connections_test.go similarity index 99% rename from internal/app/controlplane/forge_connections_test.go rename to internal/infrastructure/controlplanestore/forge_connections_test.go index 1a4ddba12..b602db1e1 100644 --- a/internal/app/controlplane/forge_connections_test.go +++ b/internal/infrastructure/controlplanestore/forge_connections_test.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "encoding/json" diff --git a/internal/app/controlplane/identity_grants.go b/internal/infrastructure/controlplanestore/identity_grants.go similarity index 99% rename from internal/app/controlplane/identity_grants.go rename to internal/infrastructure/controlplanestore/identity_grants.go index edf553dc9..ec7aa972b 100644 --- a/internal/app/controlplane/identity_grants.go +++ b/internal/infrastructure/controlplanestore/identity_grants.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/identity_grants_test.go b/internal/infrastructure/controlplanestore/identity_grants_test.go similarity index 98% rename from internal/app/controlplane/identity_grants_test.go rename to internal/infrastructure/controlplanestore/identity_grants_test.go index cf9a17c69..83573c119 100644 --- a/internal/app/controlplane/identity_grants_test.go +++ b/internal/infrastructure/controlplanestore/identity_grants_test.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "slices" diff --git a/internal/app/controlplane/instance_only_test.go b/internal/infrastructure/controlplanestore/instance_only_test.go similarity index 98% rename from internal/app/controlplane/instance_only_test.go rename to internal/infrastructure/controlplanestore/instance_only_test.go index 7c95651be..654210c02 100644 --- a/internal/app/controlplane/instance_only_test.go +++ b/internal/infrastructure/controlplanestore/instance_only_test.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "errors" diff --git a/internal/app/controlplane/instructions.go b/internal/infrastructure/controlplanestore/instructions.go similarity index 96% rename from internal/app/controlplane/instructions.go rename to internal/infrastructure/controlplanestore/instructions.go index 413c88f7b..1f5e2da2c 100644 --- a/internal/app/controlplane/instructions.go +++ b/internal/infrastructure/controlplanestore/instructions.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/model_settings.go b/internal/infrastructure/controlplanestore/model_settings.go similarity index 99% rename from internal/app/controlplane/model_settings.go rename to internal/infrastructure/controlplanestore/model_settings.go index 05f82626c..f674b5ac0 100644 --- a/internal/app/controlplane/model_settings.go +++ b/internal/infrastructure/controlplanestore/model_settings.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "fmt" diff --git a/internal/app/controlplane/operational_settings.go b/internal/infrastructure/controlplanestore/operational_settings.go similarity index 99% rename from internal/app/controlplane/operational_settings.go rename to internal/infrastructure/controlplanestore/operational_settings.go index e91193d07..18dd2735d 100644 --- a/internal/app/controlplane/operational_settings.go +++ b/internal/infrastructure/controlplanestore/operational_settings.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "fmt" diff --git a/internal/app/controlplane/org_models.go b/internal/infrastructure/controlplanestore/org_models.go similarity index 99% rename from internal/app/controlplane/org_models.go rename to internal/infrastructure/controlplanestore/org_models.go index df74f3d58..900f76fe0 100644 --- a/internal/app/controlplane/org_models.go +++ b/internal/infrastructure/controlplanestore/org_models.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/org_models_test.go b/internal/infrastructure/controlplanestore/org_models_test.go similarity index 99% rename from internal/app/controlplane/org_models_test.go rename to internal/infrastructure/controlplanestore/org_models_test.go index 16c1962cf..59aa5fe41 100644 --- a/internal/app/controlplane/org_models_test.go +++ b/internal/infrastructure/controlplanestore/org_models_test.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/package_projection.go b/internal/infrastructure/controlplanestore/package_projection.go similarity index 99% rename from internal/app/controlplane/package_projection.go rename to internal/infrastructure/controlplanestore/package_projection.go index e0a568804..a1593d7ac 100644 --- a/internal/app/controlplane/package_projection.go +++ b/internal/infrastructure/controlplanestore/package_projection.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/playbooks.go b/internal/infrastructure/controlplanestore/playbooks.go similarity index 99% rename from internal/app/controlplane/playbooks.go rename to internal/infrastructure/controlplanestore/playbooks.go index 5927081c1..31b119cd8 100644 --- a/internal/app/controlplane/playbooks.go +++ b/internal/infrastructure/controlplanestore/playbooks.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "encoding/json" diff --git a/internal/app/controlplane/playbooks_client.go b/internal/infrastructure/controlplanestore/playbooks_client.go similarity index 99% rename from internal/app/controlplane/playbooks_client.go rename to internal/infrastructure/controlplanestore/playbooks_client.go index 992690ff6..dbe85a007 100644 --- a/internal/app/controlplane/playbooks_client.go +++ b/internal/infrastructure/controlplanestore/playbooks_client.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/profiles_projector.go b/internal/infrastructure/controlplanestore/profiles_projector.go similarity index 99% rename from internal/app/controlplane/profiles_projector.go rename to internal/infrastructure/controlplanestore/profiles_projector.go index fcc3a451a..22a02bdac 100644 --- a/internal/app/controlplane/profiles_projector.go +++ b/internal/infrastructure/controlplanestore/profiles_projector.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/registry.go b/internal/infrastructure/controlplanestore/registry.go similarity index 99% rename from internal/app/controlplane/registry.go rename to internal/infrastructure/controlplanestore/registry.go index f63182194..4485ecd8a 100644 --- a/internal/app/controlplane/registry.go +++ b/internal/infrastructure/controlplanestore/registry.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "bytes" diff --git a/internal/app/controlplane/runtime_config.go b/internal/infrastructure/controlplanestore/runtime_config.go similarity index 99% rename from internal/app/controlplane/runtime_config.go rename to internal/infrastructure/controlplanestore/runtime_config.go index a87243507..45443b62b 100644 --- a/internal/app/controlplane/runtime_config.go +++ b/internal/infrastructure/controlplanestore/runtime_config.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/schedules.go b/internal/infrastructure/controlplanestore/schedules.go similarity index 98% rename from internal/app/controlplane/schedules.go rename to internal/infrastructure/controlplanestore/schedules.go index 676c0e621..dda23d021 100644 --- a/internal/app/controlplane/schedules.go +++ b/internal/infrastructure/controlplanestore/schedules.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "encoding/json" diff --git a/internal/app/controlplane/schema.go b/internal/infrastructure/controlplanestore/schema.go similarity index 99% rename from internal/app/controlplane/schema.go rename to internal/infrastructure/controlplanestore/schema.go index 5db7fd6f5..8f129d194 100644 --- a/internal/app/controlplane/schema.go +++ b/internal/infrastructure/controlplanestore/schema.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "encoding/json" diff --git a/internal/app/controlplane/skills.go b/internal/infrastructure/controlplanestore/skills.go similarity index 99% rename from internal/app/controlplane/skills.go rename to internal/infrastructure/controlplanestore/skills.go index f27a35de1..eaa4604bc 100644 --- a/internal/app/controlplane/skills.go +++ b/internal/infrastructure/controlplanestore/skills.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "encoding/json" diff --git a/internal/app/controlplane/soul.go b/internal/infrastructure/controlplanestore/soul.go similarity index 97% rename from internal/app/controlplane/soul.go rename to internal/infrastructure/controlplanestore/soul.go index 5258e1b74..c04b0d750 100644 --- a/internal/app/controlplane/soul.go +++ b/internal/infrastructure/controlplanestore/soul.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "encoding/json" diff --git a/internal/app/controlplane/task_policy.go b/internal/infrastructure/controlplanestore/task_policy.go similarity index 98% rename from internal/app/controlplane/task_policy.go rename to internal/infrastructure/controlplanestore/task_policy.go index 28af3ab39..04cb24d4e 100644 --- a/internal/app/controlplane/task_policy.go +++ b/internal/infrastructure/controlplanestore/task_policy.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "fmt" diff --git a/internal/app/controlplane/testdata/dashboard-validators.json b/internal/infrastructure/controlplanestore/testdata/dashboard-validators.json similarity index 92% rename from internal/app/controlplane/testdata/dashboard-validators.json rename to internal/infrastructure/controlplanestore/testdata/dashboard-validators.json index d663fa5c7..0d846bb6e 100644 --- a/internal/app/controlplane/testdata/dashboard-validators.json +++ b/internal/infrastructure/controlplanestore/testdata/dashboard-validators.json @@ -1,5 +1,5 @@ { - "description": "Shared accept/reject fixtures for the control-plane validators the dashboard hand-mirrors in ui/src/settings/validation.ts. The control plane is the authority: every case's `valid` is what internal/app/controlplane accepts or refuses. The Go test in this package runs the real server validators over these cases; the node test ui/test/control-plane-validator-parity.test.ts runs the real dashboard validators over the same cases. A one-sided change to either rule makes one of the two tests fail, which is the tie that stops the two implementations drifting apart (archie-core-ui-dashboard-3). Add a case here, never only to one side.", + "description": "Shared accept/reject fixtures for the control-plane validators the dashboard hand-mirrors in ui/src/settings/validation.ts. The control plane is the authority: every case's `valid` is what internal/infrastructure/controlplanestore accepts or refuses. The Go test in this package runs the real server validators over these cases; the node test ui/test/control-plane-validator-parity.test.ts runs the real dashboard validators over the same cases. A one-sided change to either rule makes one of the two tests fail, which is the tie that stops the two implementations drifting apart (archie-core-ui-dashboard-3). Add a case here, never only to one side.", "cases": { "model-aliases": [ { diff --git a/internal/app/controlplane/tool_settings.go b/internal/infrastructure/controlplanestore/tool_settings.go similarity index 99% rename from internal/app/controlplane/tool_settings.go rename to internal/infrastructure/controlplanestore/tool_settings.go index aa7de7376..fea305cd3 100644 --- a/internal/app/controlplane/tool_settings.go +++ b/internal/infrastructure/controlplanestore/tool_settings.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "fmt" diff --git a/internal/app/controlplane/workflow_definitions.go b/internal/infrastructure/controlplanestore/workflow_definitions.go similarity index 98% rename from internal/app/controlplane/workflow_definitions.go rename to internal/infrastructure/controlplanestore/workflow_definitions.go index 7b1837836..0f4130910 100644 --- a/internal/app/controlplane/workflow_definitions.go +++ b/internal/infrastructure/controlplanestore/workflow_definitions.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "encoding/json" diff --git a/internal/app/controlplane/workflow_drafts.go b/internal/infrastructure/controlplanestore/workflow_drafts.go similarity index 97% rename from internal/app/controlplane/workflow_drafts.go rename to internal/infrastructure/controlplanestore/workflow_drafts.go index 38cb2af68..5b36f3922 100644 --- a/internal/app/controlplane/workflow_drafts.go +++ b/internal/infrastructure/controlplanestore/workflow_drafts.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "fmt" diff --git a/internal/app/controlplane/workflow_enablement.go b/internal/infrastructure/controlplanestore/workflow_enablement.go similarity index 98% rename from internal/app/controlplane/workflow_enablement.go rename to internal/infrastructure/controlplanestore/workflow_enablement.go index d24ae260f..23182f8a5 100644 --- a/internal/app/controlplane/workflow_enablement.go +++ b/internal/infrastructure/controlplanestore/workflow_enablement.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/workflow_projector.go b/internal/infrastructure/controlplanestore/workflow_projector.go similarity index 99% rename from internal/app/controlplane/workflow_projector.go rename to internal/infrastructure/controlplanestore/workflow_projector.go index 7aed85a31..bf4fbcc8b 100644 --- a/internal/app/controlplane/workflow_projector.go +++ b/internal/infrastructure/controlplanestore/workflow_projector.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/app/controlplane/workflow_settings.go b/internal/infrastructure/controlplanestore/workflow_settings.go similarity index 99% rename from internal/app/controlplane/workflow_settings.go rename to internal/infrastructure/controlplanestore/workflow_settings.go index 7b55b5e50..9f5a181ce 100644 --- a/internal/app/controlplane/workflow_settings.go +++ b/internal/infrastructure/controlplanestore/workflow_settings.go @@ -1,4 +1,4 @@ -package controlplane +package controlplanestore import ( "context" diff --git a/internal/webui/api_harness.go b/internal/webui/api_harness.go index 84deea773..ea22771e3 100644 --- a/internal/webui/api_harness.go +++ b/internal/webui/api_harness.go @@ -21,7 +21,7 @@ import ( ) // The control-plane resources the harness page reads. The kinds are spelled -// here rather than imported from internal/app/controlplane so the dashboard +// here rather than imported from internal/infrastructure/controlplanestore so the dashboard // package stays a leaf: api_workflow_enablement.go does the same for // "workflow-enablement". const ( diff --git a/ui/AGENTS.md b/ui/AGENTS.md index 531b81560..f8a132319 100644 --- a/ui/AGENTS.md +++ b/ui/AGENTS.md @@ -106,7 +106,7 @@ must fail on the relevant assertion before the fix. - Keep tests fast and cheap to maintain. Test helpers and fixtures belong in test/, never in production code solely for tests. - For mirrored control-plane validators, extend the shared fixture at - internal/app/controlplane/testdata/dashboard-validators.json rather than + internal/infrastructure/controlplanestore/testdata/dashboard-validators.json rather than duplicating accept/reject cases in UI-only tests. - Use browser checks for rendered behavior. Matching a Vue file with a regex does not verify what the user sees. Mocked API checks verify UI behavior, not diff --git a/ui/src/settings/validation.ts b/ui/src/settings/validation.ts index c1778da4b..18ddfb459 100644 --- a/ui/src/settings/validation.ts +++ b/ui/src/settings/validation.ts @@ -6,11 +6,11 @@ import { parseGoDuration } from "../components/ui/duration-input/duration.ts"; * The server validates every replace, so this is not the only line of * defence: it exists so Save can be refused before the round-trip and the * operator sees the reason beside the field. The rules mirror the server's - * (internal/app/controlplane), and the same map is read by the store, the + * (internal/infrastructure/controlplanestore), and the same map is read by the store, the * save bar and the pages' inline messages, so a rule is written once. * * A hand-written mirror drifts, which is why every rule here is pinned to the - * server's by internal/app/controlplane/testdata/dashboard-validators.json: + * server's by internal/infrastructure/controlplanestore/testdata/dashboard-validators.json: * a Go test runs the server validators over that fixture and this file's * tests run these validators over the same cases, so changing one side alone * fails a test. Add a case to the fixture, not to one side only. diff --git a/ui/test/control-plane-validator-parity.test.ts b/ui/test/control-plane-validator-parity.test.ts index 346e160c5..6ae0f3914 100644 --- a/ui/test/control-plane-validator-parity.test.ts +++ b/ui/test/control-plane-validator-parity.test.ts @@ -20,7 +20,7 @@ import { * refused values the server accepted. * * This runs the real dashboard validators over - * internal/app/controlplane/testdata/dashboard-validators.json -- the same + * internal/infrastructure/controlplanestore/testdata/dashboard-validators.json -- the same * fixture the Go test in that package runs the real server validators over. * Either side changing its rule without the other fails a test here or there * (archie-core-ui-dashboard-3). @@ -35,7 +35,7 @@ interface ValidatorCase { const fixture = JSON.parse( readFileSync( new URL( - "../../internal/app/controlplane/testdata/dashboard-validators.json", + "../../internal/infrastructure/controlplanestore/testdata/dashboard-validators.json", import.meta.url, ), "utf8",