Files
rustfs/protocol/agent/v1
CCWinston 05446be442 fix(connect): align agent v1 job schema and fail-closed fixture validation (#9487)
* fix(connect): align agent v1 job schema and fail-closed fixture validation

Align the Agent v1 job envelope schema with the Rust runtime constants and
make fixture validation fail closed instead of silently skipping unknown or
unapproved cases.

- Pin drive CPU, memory, output, sample-period and timeout limits to the
  runtime values and require 64-char lowercase hex keyIds plus canonical
  Base64URL encoded Ed25519 signatures and nonces.
- Select the schema for each reject vector from that vector's own base
  instead of always using the first accept-vector schema.
- Fail on schema gaps unless they are explicitly allowlisted, and fail on
  unknown bases, duplicate IDs, invalid pointers and stale allowlist entries.
- Enable jsonschema FormatChecker so date-time values are actually asserted.
- Add Python regression suites, the fixture verifier, the regression runner
  and a GitHub Actions workflow.

Verified with scripts/run_agent_v1_regression.sh:
- 25/25 Python tests pass, 16/16 standalone schema tests pass.
- Fixture manifest: ok=68 bad=0.
- Accept vectors 2/2; reject vectors 10 rejected by schema and 2 approved
  runtime semantic gaps.

* fix(connect): validate JSON Pointer array indices and root manifest coverage

Two fail-closed gaps in the fixture verifier:

- Array tokens were converted with int(), which also accepts "-1" and "01".
  A reject vector such as /items/-1 could invalidate a different element and
  still be reported as rejected. Validate each token against the RFC 6901
  array-index grammar before indexing, including for removal.
- The root manifest was never compared with the fixture sets on disk, so an
  empty or partial root still reported success. Require every fixture set to
  be listed exactly once at the root, and fail on missing, extra or duplicate
  entries.

Add regressions for negative and zero-padded indices, empty root manifests,
unlisted fixture sets and duplicate root entries.

* fix(ci): pin agent protocol workflow actions

* fix(ci): bound the agent protocol regression job

* fix(ci): register the agent protocol validation workflow

---------

Co-authored-by: WinstonCCC <WinstonCCC@users.noreply.github.com>
Co-authored-by: Chris An <anzhengchao@gmail.com>
2026-11-23 04:12:43 +08:00
..

RustFS Connect Agent v1 — schema and fixture regression

This directory contains the Agent v1 JSON Schema files and the original protocol fixtures. The accompanying scripts validate the two schemas that are present in this repository snapshot and the diagnostic-scheduler vectors that reference them. Fixture families without a checked-in schema are covered only by manifest integrity checks; they are not claimed to have passed schema validation.

Run locally

From the repository root:

python -m pip install -r protocol/agent/v1/requirements.txt
scripts/run_agent_v1_regression.sh

The regression suite:

  1. Validates the Draft 2020-12 Schema documents and the existing Accept vectors.
  2. Validates each Reject vector against the Schema referenced by its own base Accept vector.
  3. Fails on unknown bases, duplicate IDs, malformed JSON Pointers, unsafe paths, stale allowlist entries, and unapproved Schema-accepted Reject vectors.
  4. Enables FormatChecker so format: date-time is asserted.
  5. Checks the job-envelope Schema limits against the corresponding Rust runtime constants in rustfs/src/connect/diagnostics/job.rs.
  6. Verifies the nested and top-level SHA-256 fixture manifest chain.

Runtime-only semantic checks

Exactly two existing Reject vectors are allowlisted because the corresponding rules require runtime context rather than structural JSON Schema validation:

  • health-service.job.wrong-target: organization, cluster, and device identity must match the enrolled Agent.
  • health-service.job.revoked-consent: consentExpiresAt must not precede the job's expireTime.

These checks remain mandatory in the Rust runtime validator. Every allowlist entry must have a matching Reject vector and an explicit Rust runtime test; unused allowlist entries fail CI.

Scope boundary

Only job-envelope.schema.json and health-service-result.schema.json are checked against JSON Schema in this source snapshot. Other fixture families do not have corresponding checked-in schemas here. The Python suite is not a replacement for the Rust Workspace unit/integration tests.