Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions agentplane/central_sampler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ go_library(
"executor_processes.go",
"executor_session.go",
"exporter_outbox.go",
"migration.go",
"native_context.go",
"native_store.go",
"notification.go",
Expand Down Expand Up @@ -368,10 +367,6 @@ go_library(
"unified_exec.go",
"view_image.go",
],
embedsrcs = [
"schema/0015_baseline.sql",
"schema/0016_provider_attempts.sql",
],
importpath = "github.com/agentydragon/ducktape/agentplane/central_sampler",
visibility = [
"//agentplane/central_sampler/cmd:__pkg__",
Expand All @@ -381,11 +376,11 @@ go_library(
"//agentplane/central_sampler/api:sampler_go_proto",
"//agentplane/central_sampler/historyexport",
"//agentplane/central_sampler/internal/codemode",
"//agentplane/central_sampler/internal/content",
"//agentplane/central_sampler/internal/eventcodec",
"//agentplane/central_sampler/internal/outputbuffer",
"//agentplane/central_sampler/internal/promptimage",
"//agentplane/central_sampler/internal/settings",
"//agentplane/central_sampler/internal/storage",
"//agentplane/central_sampler/internal/toolcontract",
"//agentplane/central_sampler/internal/tooloutput",
"//agentplane/central_sampler/protocol",
Expand All @@ -398,7 +393,6 @@ go_library(
"//agentplane/net/peertls",
"//agentplane/postgres",
"//agentplane/postgres/lease",
"//agentplane/postgres/migrate",
"//agentplane/postgres/wakeups",
"//agentplane/proto:command_go_proto",
"//agentplane/proto:delegation_go_proto",
Expand Down Expand Up @@ -457,9 +451,10 @@ go_test(
"//agentplane/central_sampler/api:sampler_go_proto",
"//agentplane/central_sampler/historyexport",
"//agentplane/central_sampler/internal/codemode",
"//agentplane/central_sampler/internal/content",
"//agentplane/central_sampler/internal/outputbuffer",
"//agentplane/central_sampler/internal/settings",
"//agentplane/central_sampler/internal/storage",
"//agentplane/central_sampler/migrations",
"//agentplane/central_sampler/protocol",
"//agentplane/central_sampler/providers/anthropic",
"//agentplane/central_sampler/providers/responses",
Expand Down Expand Up @@ -498,8 +493,8 @@ go_test(
race = "on",
deps = [
"//agentplane/central_sampler/internal/codemode",
"//agentplane/central_sampler/internal/content",
"//agentplane/central_sampler/internal/settings",
"//agentplane/central_sampler/internal/storage",
"//agentplane/central_sampler/protocol",
"//agentplane/central_sampler/providers/anthropic",
"//agentplane/central_sampler/providers/responses",
Expand Down
8 changes: 4 additions & 4 deletions agentplane/central_sampler/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -750,10 +750,10 @@ general JSON node format or serializer.

Native `anthropic`/`responses` packages own their private stored types, packing/reconstruction
codecs, API types, request construction, streaming and continuation semantics. They use the
sampler-private `internal/storage` content reader/writer: typed IDs/kinds, standard JSON encoding,
content hashing and integrity checks. Shared storage imports neither provider nor semantic protocol
packages and does not interpret provider payloads. The shared `protocol` package defines semantic
contracts, not persisted records. The sampler owns PostgreSQL, transactions, context roots,
sampler-private `internal/content` content reader/writer: typed IDs/kinds, standard JSON encoding,
content hashing and integrity checks. The content package imports neither provider nor semantic
protocol packages and does not interpret provider payloads. The shared `protocol` package defines
semantic contracts, not persisted records. The sampler owns PostgreSQL, transactions, context roots,
authorization and request history. The shared table holds native item/block JSON and small
provider-specific message/profile reference records, not a universal message schema.

Expand Down
8 changes: 5 additions & 3 deletions agentplane/central_sampler/baseline_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"database/sql"
"sync"
"testing"

"github.com/agentydragon/ducktape/agentplane/central_sampler/migrations"
)

func migrationExec(t *testing.T, db *sql.DB, query string, args ...any) {
Expand Down Expand Up @@ -60,7 +62,7 @@ func TestSamplerBaselineAdoptsCompletedRewriteWithoutTouchingData(t *testing.T)
t.Fatal(err)
}
for range 2 {
if err := Migrate(t.Context(), store.DB()); err != nil {
if err := migrations.Up(t.Context(), store.DB()); err != nil {
t.Fatal(err)
}
}
Expand Down Expand Up @@ -97,7 +99,7 @@ func TestSamplerBaselineRejectsIncompletePredecessors(t *testing.T) {
if mode == "partial_schema" {
migrationExec(t, store.DB(), `ALTER TABLE sampler_model_request DROP COLUMN source_context_id`)
}
if err := Migrate(t.Context(), store.DB()); err == nil {
if err := migrations.Up(t.Context(), store.DB()); err == nil {
t.Fatal("accepted incomplete predecessor")
}
})
Expand All @@ -111,7 +113,7 @@ func TestSamplerBaselineConcurrentFreshCreation(t *testing.T) {
failures := make(chan error, 2)
for range 2 {
workers.Add(1)
go func() { defer workers.Done(); failures <- Migrate(t.Context(), store.DB()) }()
go func() { defer workers.Done(); failures <- migrations.Up(t.Context(), store.DB()) }()
}
workers.Wait()
close(failures)
Expand Down
1 change: 1 addition & 0 deletions agentplane/central_sampler/cmd/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ go_library(
"//agentplane/central_sampler/api:sampler_go_proto",
"//agentplane/central_sampler/historyexport",
"//agentplane/central_sampler/internal/settings",
"//agentplane/central_sampler/migrations",
"//agentplane/grpc/graceful",
"//agentplane/identity/auth",
"//agentplane/net/listener",
Expand Down
5 changes: 3 additions & 2 deletions agentplane/central_sampler/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
samplerpb "github.com/agentydragon/ducktape/agentplane/central_sampler/api/samplerpb"
"github.com/agentydragon/ducktape/agentplane/central_sampler/historyexport"
samplersettings "github.com/agentydragon/ducktape/agentplane/central_sampler/internal/settings"
"github.com/agentydragon/ducktape/agentplane/central_sampler/migrations"
"github.com/agentydragon/ducktape/agentplane/grpc/graceful"
"github.com/agentydragon/ducktape/agentplane/identity/auth"
netlistener "github.com/agentydragon/ducktape/agentplane/net/listener"
Expand Down Expand Up @@ -79,7 +80,7 @@ func run(ctx context.Context, settings samplersettings.Settings) error {
slog.Warn("Agentplane platform guidance is not configured; new Sessions retain caller-only instructions")
}
databaseURL := strings.Replace(settings.DatabaseURL, "postgresql+asyncpg://", "postgresql://", 1)
if err := migrate.Run(ctx, databaseURL, centralsampler.Migrate); err != nil {
if err := migrate.Run(ctx, databaseURL, migrations.Up); err != nil {
return atStartupStage("database_migrations", err)
}
// Allow session state writes and lease renewals, eight exporter workers, and sixteen RPCs.
Expand Down Expand Up @@ -170,7 +171,7 @@ func main() {
slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stderr, nil)))
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()
if handled, err := migrate.RunOnly(ctx, os.Args[1:], "AGENTPLANE_CENTRAL_SAMPLER_DATABASE_URL", centralsampler.Migrate); handled {
if handled, err := migrate.RunOnly(ctx, os.Args[1:], "AGENTPLANE_CENTRAL_SAMPLER_DATABASE_URL", migrations.Up); handled {
if err != nil {
slog.Error("central sampler migration stopped", startupLogAttrs(atStartupStage("migration_only", err))...)
os.Exit(1)
Expand Down
12 changes: 6 additions & 6 deletions agentplane/central_sampler/content_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"

"github.com/agentydragon/ducktape/agentplane/central_sampler/internal/storage"
"github.com/agentydragon/ducktape/agentplane/central_sampler/internal/content"

"github.com/agentydragon/ducktape/agentplane/central_sampler/protocol"
"github.com/agentydragon/ducktape/agentplane/central_sampler/providers/anthropic"
Expand All @@ -20,8 +20,8 @@ func renderProviderRequest(store *contentStore, request ProviderRequest) ([]byte
if err != nil {
return nil, err
}
ids = append(append(append([]storage.ContentID{}, request.PrefixIDs...), ids...), request.SuffixIDs...)
roots := append([]storage.ContentID{request.ProfileID}, ids...)
ids = append(append(append([]content.ContentID{}, request.PrefixIDs...), ids...), request.SuffixIDs...)
roots := append([]content.ContentID{request.ProfileID}, ids...)
if err := store.prefetch(roots); err != nil {
return nil, err
}
Expand All @@ -39,7 +39,7 @@ func renderProviderRequest(store *contentStore, request ProviderRequest) ([]byte
}
}

func finishStoredRequest(store *contentStore, request ProviderRequest, profile storage.ContentID, ids []storage.ContentID) (ProviderRequest, []byte, error) {
func finishStoredRequest(store *contentStore, request ProviderRequest, profile content.ContentID, ids []content.ContentID) (ProviderRequest, []byte, error) {
contextID, err := store.storeContext(request.API, ids)
if err != nil {
return ProviderRequest{}, nil, err
Expand All @@ -65,7 +65,7 @@ func saveProviderRequest(ctx context.Context, tx *sql.Tx, id, conversationID str
type StoredProviderRequest struct {
RequestID string
ContextID string
ProfileID storage.ContentID
ProfileID content.ContentID
Method string
URL string
Headers map[string]string
Expand Down Expand Up @@ -104,7 +104,7 @@ func (s *Store) LoadProviderRequest(ctx context.Context, sessionID, accountUID,
return result, err
}

func contentIDArray(ids []storage.ContentID) pq.StringArray {
func contentIDArray(ids []content.ContentID) pq.StringArray {
values := make(pq.StringArray, 0, len(ids))
for _, id := range ids {
values = append(values, string(id))
Expand Down
Loading
Loading