Skip to content

Add ActorTemplate and ActorTemplateVersion as substrate resources; Add CRUD methods in redis package - #824

Open
Zoe Zhao (zoez7) wants to merge 7 commits into
agent-substrate:mainfrom
zoez7:atv-br-1.5
Open

Add ActorTemplate and ActorTemplateVersion as substrate resources; Add CRUD methods in redis package#824
Zoe Zhao (zoez7) wants to merge 7 commits into
agent-substrate:mainfrom
zoez7:atv-br-1.5

Conversation

@zoez7

@zoez7 Zoe Zhao (zoez7) commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Part of #477 .

All ATV fields are immutable. SandboxConifg will be frozen into ATV at creation time.
Adds per-resource store methods and the ateredis package for the AT and ATV as global resources.

Comment thread pkg/proto/ateapipb/ateapi.proto Outdated
Comment thread cmd/ateapi/internal/store/ateredis/ateredis.go Outdated
@zoez7 Zoe Zhao (zoez7) changed the title ateapi/store: persist ActorTemplate and ActorTemplateVersion Add ActorTemplate and ActorTemplateVersion as substrate resources; Add CRUD methods in redis package Aug 10, 2026
@zoez7
Zoe Zhao (zoez7) force-pushed the atv-br-1.5 branch 2 times, most recently from 8546ab7 to 47fb420 Compare August 10, 2026 20:26
…ne proto

Introduce ActorTemplate (identity + placement policy) and
ActorTemplateVersion (immutable workload definition), along with the
supporting SandboxClass/SandboxConfig, SnapshotsConfig, ResumeSource,
and OnResumeConfig messages. Both resources are flat: workload and
status fields live directly on the message, like Actor.

The version State enum (nested in ActorTemplateVersion, like
Actor.Status) mirrors the existing ActorTemplateVersion CRD PhaseType
(RESUME_GOLDEN_ACTOR -> WAIT_GOLDEN_ACTOR -> {READY | FAILED}, with
UNSPECIFIED for the initial empty phase).
Adds per-resource store methods and the ateredis implementation for the
two new global-scoped resources, following the Atespace/Actor patterns:
SetNX creates with server-owned metadata, WATCH+version CAS update for
ActorTemplate, and SCAN-based listing.

ListActorTemplateVersions filters by parent after fetching (the parent
lives in the value, not the key); matches count toward the page so pages
stay full. DeleteActorTemplate rejects while any version names it as
parent. DeleteActorTemplateVersion rejects while it is its parent's
default_version_on_create and deletes the golden snapshot recorded in
its status before removing the version record.
Comment thread pkg/proto/ateapipb/ateapi.proto Outdated
Comment thread cmd/ateapi/internal/store/store.go Outdated
// the stored resource with advanced metadata (version, update_time). The
// input is not mutated. Returns ErrNotFound if missing, or
// ErrVersionConflict on version mismatch.
UpdateActorTemplate(ctx context.Context, template *ateapipb.ActorTemplate, expectedVersion int64) (*ateapipb.ActorTemplate, error)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you sync with Luiz Oliveira (@laoj2)? We are reworking the way store should expose Update methods. See #763

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the UpdateActorTemplate impl in ed51c8d to follow the example in #829 .

// Returns store.ErrNotFound if the template does not exist, or
// store.ErrFailedPrecondition while any ActorTemplateVersion still names it
// as parent.
func (s *Persistence) DeleteActorTemplate(ctx context.Context, name string) (*ateapipb.ActorTemplate, error) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here's a TOCTOU problem - if DeleteActorTemplate happens after the ActorTemplate check in but before the actual creation of CreateActorTemplateVersion, then we would have a orphaned ATV.

This is similar to what I realize in DeleteAtespace and CreateActor in #396, this might need a same pattern to have a terminating marker that can prevent another operator from proceeding.

Maybe add a todo for that TOCTOU?

@zoez7 Zoe Zhao (zoez7) Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using API level locks, but I think adding deletion markers here makes sense too in case there is a bug in the API level locking. Added in 091cafb.

@zoez7
Zoe Zhao (zoez7) force-pushed the atv-br-1.5 branch 2 times, most recently from 29b39b8 to 1dff0cc Compare August 11, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants