mirror of
https://github.com/agent-substrate/substrate.git
synced 2026-10-02 03:24:42 +08:00
Follow up on issue #1168 and the base PR #1215 **Overview:** Continues the declarative validation (DV) migration from #1215 by converting the `Worker` resource. This moves immutable-field enforcement from the storage layer up to the service layer. With `WorkerPoolSyncer` now using RPCs, nearly all write paths share the exact same validation. **Key Changes:** * **Schema (`ateapi.proto`):** Added full DV tags (required, format, immutable) to `Worker` pod-coordinates and metadata. `WorkerStatus.state` is now strictly bounded to its enum range. * **Service Layer:** Replaced ~60 lines of hand-written validation with 1-line generated calls. `CreateWorker` and `UpdateWorker` now scrub server-owned fields and enforce immutability *before* hitting the store. * **Storage Layer:** Removed `store.CheckWorkerMutation`. `atepg.UpdateWorker` is optimized to only clone metadata instead of the whole worker. Immutability contract tests were moved to the service layer. * **Behavior Tweaks (Tightenings):** * `page_token` is now capped at 256 chars. * `DeleteOptions.uid` must be a valid UUID. * Global-ref atespace violations now correctly return `Forbidden` instead of `Invalid`. * Immutability checks now natively cover the `WorkerPoolSyncer` path. * **Testing:** Added comprehensive positive/negative cases for all newly tagged fields, boundary cases, and moved the immutability test suite. All suites pass cleanly. - [x] Tests pass - [x] Appropriate changes to documentation are included in the PR