refactor(controlplane): move the store-backed server out of internal/app
This commit is contained in:
59 files changed
+154
-154
No files matched your search
@@ -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",
|
||||
} {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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."}
|
||||
}
|
||||
|
||||
@@ -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"}
|
||||
|
||||
@@ -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 "<org>/<job id>" 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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import "github.com/samcharles93/archie-core/internal/config"
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+2
-2
@@ -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"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import "github.com/samcharles93/archie-core/internal/config"
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+2
-2
@@ -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()...)
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"slices"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"errors"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -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": [
|
||||
{
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package controlplane
|
||||
package controlplanestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -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 (
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user