Skip to content

feat(fleet-queue): DST-01 shared Command/Result contract in work/contracts.rs (#9451) - #12886

Merged
dezren39 merged 1 commit into
mainfrom
lane-eh-9451-contracts
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-eh-9451-contracts

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements DST-01 (#9451), the shared Command/Result contract slice of the PM orchestration design (#9200, program #9196), in its owned file pkgs/fleet/crates/fleet-queue/src/work/contracts.rs:

  • Shared envelope — Command (fleet.command/v1) and CommandResult (fleet.result/v1) exactly as architecture.md fixes them: snake_case wire names, explicitly nullable optionals, the shared Result.outcome vocabulary (rejected … verified_complete), effects naming requested/observed/verified separately.
  • Pair identity — WorkRef (authority_id, work_id); authority compared bytewise, work ID by arbitrary-precision integer value (9 < 10 despite the string encoding); fleet://<authority>/work/<id> qualified URI.
  • Exact integer-string serialization — versions/generations/work versions are canonical decimal strings, validated, never coerced through floats (a work_version beyond the u64 range round-trips exactly; a JSON number in a version's place is a typed schema failure).
  • Effect-separated reason-code registry — all 15 codes from the design(pm-orchestration): priority distribution, provenance & reconciliation across producers/consumers #9200 component table, each with its headline effect class (base mutation / derived pressure / advisory hint / no mutation) and per-kind field-effect permissions; an applier-facing check_field_effect refuses pairings the registry does not permit. Unknown codes return typed unsupported_reason_code and are never aliased; unknown major schema versions return typed unsupported_version.
  • Auth-vs-actor — actor_ref is audit-only and is never consulted by evaluate_authorization, which reads only the authenticated principal's verified capabilities. A client payload carrying an authorized field is rejected as a typed contract violation before any other interpretation.
  • Owner policy — the fleet.owner-priority-policy/v1 observation DTO and the atomic ref check: matching ref passes, stale ref → OWNER_POLICY_VERSION_CONFLICT, missing ref fails closed. Denied protected mutations carry OWNER_POLICY_PROTECTED.
  • Digest — RFC 8785 JCS canonicalization + the architecture byte framing (ASCII(domain) || 0x00 || UTF8(JCS(dto)), SHA-256, sha256: + 64 lowercase hex) over the exact intent DTO; domains only from the registry. Delivery/operation/dry-run changes do not move the digest; intent/precondition changes do.

Wiring beyond the owned file (noted per the sibling-slice pattern): one-line module export in work/mod.rs, and sha2 = { workspace = true } in fleet-queue's Cargo.toml (sha2 0.11 is already a pkgs/fleet workspace dependency) with its single Cargo.lock edge.

Evidence

Ran on the laptop (amd-6), worktree off origin/main (4c01d0497c7), through ~/tools/fleet-build-lock:

  • Done check, step 1 — both exact names listed:
    cargo test --manifest-path pkgs/fleet/Cargo.toml -p fleet-queue --lib --features client,queue-broker -- --list → work::contracts::tests::pmo_distribution_command_identity_reason_and_version: test and work::contracts::tests::pmo_distribution_command_policy_ref_round_trips: test.
  • Done check, step 2 — each filter run: pmo_distribution_command_identity_reason_and_version → 1 passed / 0 failed; pmo_distribution_command_policy_ref_round_trips → 1 passed / 0 failed. The identity/reason/version oracle enumerates each of the 15 reason codes against the registry table, checks the field-effect boundary and no-mutation on every refusal, covers the digest golden vectors from contracts/digest-vectors.json byte-for-byte, and proves an owner-looking actor_ref without a principal authorizes nothing.
  • Full package regression: same command without a filter → 513 passed / 0 failed.
  • rustfmt --check on the new file: clean.

The gate decision that unblocked this slice (the recorded "#9200 closed" gate leg was inverted — the container closes when its children complete) is recorded on #9451 as a decision:v1 note (comment 7091462341). Production adoption, migration, deployment and live acceptance remain separately authorized stages, as the issue states; this PR is the offline contract + fixtures work.

Merge Danger

Low. The module is additive and nothing consumes it yet; the only edits to existing files are the one-line module export, the one-line dependency declaration, and its lock edge. Revert is a single-commit revert with no data or wire impact.


Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…racts.rs (#9451)

The shared fleet.command/v1 / fleet.result/v1 envelope, (authority_id,
work_id) pair identity with numeric work-ID ordering, canonical
decimal-string versions, the effect-separated reason-code registry
(15 codes from the #9200 component, each with its permitted field
effects), the auth-vs-actor distinction (actor_ref is audit-only; a
client `authorized` field is a typed contract violation), the
fleet.owner-priority-policy/v1 observation with its atomic ref
check, and the RFC 8785 JCS + SHA-256 digest framing from
architecture.md, verified against the published framing vectors.

Proven by the issue's two named oracles:
pmo_distribution_command_identity_reason_and_version and
pmo_distribution_command_policy_ref_round_trips; full fleet-queue
lib suite passes (513 passed / 0 failed).

Wiring beyond the owned file: the one-line module export in
work/mod.rs and the sha2 workspace dependency (already a workspace
dependency) in fleet-queue's Cargo.toml, with its lock edge.
@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 04:29
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 21 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 334f11bb-8dc0-4c6c-8623-68972cb73f5f
Commits

Reviewing files that changed from the base of the PR and between 4e69f9e and bbd6e68.

Files ignored due to path filters: 1

  • pkgs/fleet/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 3

  • pkgs/fleet/crates/fleet-queue/Cargo.toml
  • pkgs/fleet/crates/fleet-queue/src/work/contracts.rs
  • pkgs/fleet/crates/fleet-queue/src/work/mod.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T04:31:11.741142Z bbd6e68 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant