Repository navigation
feature: runtime-neutral Task execution, Cluster resource, tenant-enforced APIs, and unified contracts - #17
Merged
Merged
Conversation
…ced APIs, and unified contracts
Consolidates a period of internal iteration.
BREAKING CHANGE: The Task data structure is not backward compatible.
Existing Task/Job/Workflow objects written with the old schema will not
validate or reconcile. Recommended path: create a new environment on this
version and recreate workloads from the new manifests. An in-place upgrade
requires rewriting every manifest before the first reconcile, and a
downgrade is not lossless (removed fields are not restored).
Highlights:
- Data plane: runtime-neutral Task execution framework under
pkg/agent/execution/** (host, coordination/coordinator, workload, binding,
environment, runtime, plan, trigger, evidence, observability, fault, gRPC
transports); concrete Kubernetes implementations under controllers/task/**;
supervisor-based management of Ray and workload SSH processes.
- Task CRD redesign: spec.runtime{kind,name}, spec.workload
{kind,version,parameters,carrier,template}, spec.placement.nodeSelector,
spec.environments[], spec.suspended; removes spec.agentType, top-level
nodeSelector, kubernetes/docker/raw specs, tensorBoardDir, prepareScript,
runScript, sshPublicKey, and the deprecated pvcStorageMap/pvcSizeGbMap.
Job/Workflow spec.stopped renamed to spec.suspended.
- Unified Phase/Condition/ObservedGeneration contract across Job, Workflow,
Task, Domain, Addon, Node, and Cluster.
- New cluster-scoped Cluster resource with heartbeat-Lease-derived phase and
durable cordon/drain intent.
- Tenant-aware business resources with server-side enforcement at the Gateway
(list narrowing, 403/404 semantics, write-path quotas).
- Gateway/DB hardening: unified ErrorResponse and X-Request-Id middleware,
strict list filter/pagination validation, deterministic ordering, and no
synthesized UIDs.
- Job archive with a pluggable persistence backend and POST /jobs/{name}/start.
- StorageClass moved to the distribution model.
- UI TypeScript CRD models generated from the CRD bases; swagger consistency gate.
- Pinned proto toolchain, proto/execution protocol v2, and sdks/execution-go.
- Configurable Kind-based e2e test framework.
- Documentation updated in English and Chinese.
Signed-off-by: pigeonligh <[email protected]>
lkygithub
approved these changes
Oct 23, 2026
This was referenced Oct 23, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change consolidates a period of internal iteration. The headline themes:
1. Runtime-neutral Task execution architecture (data plane)
A new internal framework (
apps/rlark/pkg/agent/execution/**) splits one Task reconcile into orthogonal, testable layers:host(claim/finalizer, one-Task serialization, the only writer of Agent-owned Task status),coordination/coordinator(selection, compile→bind→observe→diff→apply),workload(runtime-neutral Adapter contracts),binding,environment(declaration-vs-effect, allow-listed mutation targets, trusted handler ordering, a restricted secret-material lease),runtime(Provider, ownership, typed reconcile profiles),plan,trigger,evidence(conservative fast-observation gate),observability,fault, and gRPC transports (protocol v2). Concrete Kubernetes implementations live inapps/rlark/pkg/agent/controllers/task/**; the framework never imports them.2. Task execution contract redesign (BREAKING)
TaskSpecis rewritten:spec.runtime{kind,name},spec.workload{kind,version,parameters,carrier{type,version,parameters},template},spec.placement.nodeSelector,spec.environments[]{type,version,parameters},spec.suspended;status.observedGeneration.spec.agentType, top-levelspec.nodeSelector,spec.domain,spec.kubernetes.*,spec.docker.*,spec.raw.*,spec.tensorBoardDir,spec.prepareScript,spec.runScript,spec.sshPublicKey, and the deprecatedpvcStorageMap/pvcSizeGbMap. Ray becomes workloadrlinf.io/ray@v1with a Kubernetes carrier; SSH/network/TensorBoard becomeenvironments.Job.spec.stopped→suspended,Workflow.spec.stopped→suspended.WaitingForChange/Blockedrather than an in-place migration (delete and recreate the Task).3. Unified Phase/Condition/ObservedGeneration contract
New
api/rlark.io/v1alpha1/conditions.goandconsts.go;status.conditions(map-keyed) added across Job/Workflow/Task/Domain/Addon/Node/Cluster.ObservedGenerationadded where a Spec-derived verdict exists and is documented as a controller contract (not an API-server guarantee). Controllers and the Agent now write conditions throughmeta.SetStatusConditionwith stable reasons.4. Cluster as a first-class resource
New cluster-scoped
ClusterCRD withspec.agentNamespaceas the authoritative membership scope, durablecordoned/drainingintent, and a heartbeat Lease-derived phase (Online/Offline/Downgraded/Cordoned/Draining) plus aReadycondition. Node aggregation in the Gateway is now namespace-membership based; Cluster write paths are removed from the Gateway.5. Tenant-aware business resources and server-side enforcement
Tenant identity is carried in metadata (
rlark.io/tenant-id,rlark.io/created-by) with inheritance Workflow→Job→Task→Pod; the Gateway stamps identity on create, preserves it on update, strips it on patch, and enforces scope on every entry point (list narrowing, 403 for out-of-scope filters, 404 for other tenants' named objects, no-assignment refusal). Read-onlyusers/tenantsroutes added. Write-path quotas for Job tags enforced in the Gateway (deliberately not in the CRD schema).6. Gateway/DB hardening
Unified
ErrorResponse {code,message,reason,requestId,details}with a closed machine-readable code set andX-Request-Idmiddleware; unified list filter/pagination semantics with strict validation (400 instead of silent coercion),maxListLimit=500, deterministic ordering, correct!=missing-key semantics (IS DISTINCT FROM), parameterized JSON-path SQL, and removal of synthesized UIDs (missingmetadata.uidnow stays empty). A new swagger consistency gate ties routes, error-code enums, and$refs together.7. Job archive and persistence
Finished Jobs are persisted and then archived (deleted from the management API after
ArchiveTTL, default 5m) with a newPOST /jobs/{name}/startto restore them (new UID, same name/spec). Pluggable persistence backends (PostgreSQL / Secret). Removed theGET /jobs/{name}/metricsstub route.8. StorageClass moved to the distribution model
StorageClasses are now management-plane declarations distributed to target clusters (declaration vs. observed delivery), rather than live per-agent query.
9. UI typed CRD models
TypeScript models are generated from the CRD bases (
scripts/generate-crd-models.mjs) with a kind-set contract check and committed output undersrc/generated/**; hand-written CRD interfaces were removed. UI follows the new Task/Cluster/Job contracts (suspended,/start, new cluster phases).10. Proto toolchain pin, execution protocol, SDKs
Pinned
protoc/plugins/bufviaproto/toolchain.mkwithprotoc-check,buf lint, andbuf breakinggates; newproto/execution(protocol v2) andsdks/execution-go; embodied-runtime stubs regenerated; Python SDK floors raised (grpcio>=1.84.0,protobuf>=7.35.1,<8, Python ≥3.10).11. e2e framework
A product-neutral, configurable Kind-based e2e framework (
test/e2e/**) with a provider abstraction, scenario runner, ownership-proven cleanup, and an RLark smoke scenario (make test-e2e-rlark).12. Documentation
New/updated EN+zh pages: design-principles, api-conventions, runtime-provider, tenancy, e2e-testing, project-layout, agent admin guide, concepts, architecture, storage-api, clusters-nodes, jobs, ssh-keys, configuration, CRD reference; new
verify-generatedand proto CI gates.Motivation and Context
The previous Task model collapsed runtime, workload, and environment concerns into
agentType-specific fields, hard-coded Ray/Kubernetes lifecycle into shell scripts, derived cluster state ad hoc from Node records, and exposed tenant identity/authorization only in the UI. As more runtimes, workloads, environments, tenants, and nodes are added, this prevented clean extension and made correctness depend on event ordering and implicit ownership.This change moves the code toward the documented Project Design Principles: reconcile from state, separate intent/observation/operations/history, prove ownership, evolve contracts conservatively, enforce tenancy at trusted boundaries, and test failure and recovery. It also makes the Task structure explicitly runtime-neutral so Docker/Raw and additional workloads can be added without redesigning the core contract — at the cost of a hard, intentional break with the old Task/Job schema.
How has this been tested?
make test-go/make test-webandmake lint-go/make lint-webfor the repository suites.-race:go test ./pkg/agent/execution/...andgo test -race ./pkg/agent/execution/....$refresolution), list/selector validation and!=semantics tests, migration ordering/reversibility tests, and deterministic-ordering tests.ObservedGenerationbehavior tests.make verify-generated(CRDs, clients, docs, UI models) andmake verify-proto-generated.make lint-protoandmake proto-breaking.make test-e2e-rlarkKind smoke scenario (install, discovery, deployment availability, uninstall).Types of changes
Checklist: