feat(scheduler-agent): Phase 1 write operations — submit/cancel/hold/release + templates

Add write operations to the scheduler-agent MCP server (Phase 1):

- schedulerclient: SubmitJob/CancelJob/HoldJob/ReleaseJob + JobSpec/
  SubmitJobResult/JobControlRequest/ControlResult types + doPost helper
  (HTTP 200 + envelope-code dual check). TDD: 12 new tests.
- mcp-server: 4 write tools (scheduler_submit/cancel/hold/release) with
  destructive annotations; scheduler_submit has dry_run review mode +
  general_serial (通用串行脚本) job template registry. Fix the 6 read-only
  tools' misleading destructive annotations. TDD: 14 new tests.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
lei.chen 2026-08-01 09:54:38 +00:00
parent 2e299f4a76
commit 35416d5cf4
9 changed files with 1447 additions and 6 deletions

View file

@ -4,7 +4,7 @@ import "context"
// ── Client interface ────────────────────────────────────────────────────────
// Client provides read-only access to the scheduler cluster through a
// Client provides read and write access to the scheduler cluster through a
// scheduler-agnostic unified resource model (URM).
//
// Implementations talk to the apiserver's REST API and authenticate via
@ -36,4 +36,18 @@ type Client interface {
// GetClusterMetrics returns a snapshot of overall cluster resource usage.
GetClusterMetrics(ctx context.Context) (*Metrics, error)
// ── Write operations (Phase 1) ──
// SubmitJob submits a job and returns its assigned ID.
SubmitJob(ctx context.Context, spec JobSpec) (*SubmitJobResult, error)
// CancelJob kills a job (action "kill", default SIGTERM).
CancelJob(ctx context.Context, id string) error
// HoldJob suspends a job (action "stop", default SIGTSTP).
HoldJob(ctx context.Context, id string) error
// ReleaseJob resumes a suspended job (action "resume", default SIGCONT).
ReleaseJob(ctx context.Context, id string) error
}