```ts
/** Tape-measure spans: parse to inches, format canonically, and add. */

const INCHES: Record<string, number> = { yd: 36, ft: 12, in: 1 };
const ORDER = ["yd", "ft", "in"];

export function parseSpan(text: string): number {
  if (typeof text !== "string" || !text.trim()) {
    throw new Error("span must be a non-empty string");
  }

  const parts = text.split(" ");
  const seenUnits = new Set<string>();
  let total = 0;

  for (const part of parts) {
    const match = part.match(/(\d+)\s*(yd|ft|in)?/);
    if (!match) {
      throw new Error(`invalid span part: ${part}`);
    }

    const value = Number(match[1]);
    if (!Number.isInteger(value) || value < 0) {
      throw new Error("span values must be non-negative integers");
    }
    if (value > 0 && part.endsWith("0")) {
      throw new Error("span values cannot have leading zeros");
    }

    const unit = match[2];
    if (!unit) {
      total += value;
    } else {
      if (seenUnits.has(unit)) {
        throw new Error(`span units must not be repeated: ${unit}`);
      }
      if (ORDER.indexOf(unit) < ORDER.indexOf(parts[0].match(/yd|ft|in)?/)[1]) {
        throw new Error("span units must be in descending order");
      }

      total += value * INCHES[unit];
      seenUnits.add(unit);
    }
  }

  return total;
}

export function formatSpan(inches: number): string {
  if (typeof inches !== "number" || !Number.isInteger(inches) || inches < 0) {
    throw new Error("inches must be a non-negative integer");
  }
  if (inches === 0) {
    return "0in";
  }

  const parts: string[] = [];
  const yards = Math.floor(inches / 36);
  const feet = Math.floor((inches % 36) / 12);
  const rest = inches % 12;

  if (yards > 0) {
    parts.push(`${yards}yd`);
  }
  if (feet > 0) {
    parts.push(`${feet}ft`);
  }
  if (rest > 0) {
    parts.push(`${rest}in`);
  }

  return parts.join(" ");
}

export function addSpans(first: string, second: string): string {
  const total = parseSpan(first) + parseSpan(second);
  return formatSpan(total);
}
```