Hmbown/CodeWhale · error

fleet task '{}' metadata.coordination_contracts accepts at m

Error message

fleet task '{}' metadata.coordination_contracts accepts at most 16 entries

What it means

The `metadata.coordination_contracts` array exceeds the hard cap of 16 entries. The limit keeps the coordination surface of a fleet task small and auditable; entries beyond 16 are not silently dropped — the whole spec is rejected. Duplicate strings are deduplicated later, but the length check runs on the raw array before dedup.

Source

Thrown at crates/tui/src/fleet/worker_runtime.rs:389

    Ok(if segments.is_empty() {
        ".".to_string()
    } else {
        segments.join("/")
    })
}

fn fleet_coordination_contracts(task_spec: &FleetTaskSpec) -> Result<Vec<String>> {
    let Some(value) = task_spec.metadata.get("coordination_contracts") else {
        return Ok(Vec::new());
    };
    let Some(values) = value.as_array() else {
        bail!(
            "fleet task '{}' metadata.coordination_contracts must be an array of strings",
            task_spec.id
        );
    };
    if values.len() > 16 {
        bail!(
            "fleet task '{}' metadata.coordination_contracts accepts at most 16 entries",
            task_spec.id
        );
    }
    let mut contracts = Vec::new();
    for value in values {
        let Some(value) = value.as_str() else {
            bail!(
                "fleet task '{}' metadata.coordination_contracts must contain only strings",
                task_spec.id
            );
        };
        let value = value.trim();
        if value.is_empty()
            || value.chars().count() > 128
            || value.chars().any(|ch| matches!(ch, '\0' | '\r' | '\n'))
        {
            bail!(

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Trim the list to at most 16 entries, removing duplicates first so the cap counts unique contracts.
  2. Consolidate fine-grained contracts into broader ones (e.g. one "ledger" instead of per-table entries).
  3. If contracts are generated, cap the generator at 16 and log when it truncates.

Example fix

# before
[metadata]
coordination_contracts = ["a", "b", "c", ... 20 entries ...]

# after
[metadata]
coordination_contracts = ["a", "b", "c"]  # <= 16 unique entries
Defensive patterns

Strategy: validation

Validate before calling

const MAX_CONTRACTS: usize = 16;

fn contracts_within_limit(values: &[serde_json::Value]) -> bool {
    values.len() <= MAX_CONTRACTS
}

Prevention

When it happens

Trigger: A spec listing 17+ contract strings, including duplicates (dedup happens after the count check, so 20 entries with 3 duplicates still fails).

Common situations: Generators enumerating every queue/topic as a contract; accumulated contracts from merging several task templates.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/5f8affe74c15aa53. Report an issue: GitHub.