ruvnet/ruflo · error

Cannot compose morphisms: ${f.name} (target: ${f.target}) an

Error message

Cannot compose morphisms: ${f.name} (target: ${f.target}) and ${g.name} (source: ${g.source}) - target of first must equal source of second

What it means

CategoryEngine.compose() verified composability of the two morphisms and f.target does not equal g.source — composing g after f is undefined in category theory. The error names both morphisms and their mismatched objects; align the target/source before composing.

Source

Thrown at v3/plugins/prime-radiant/src/engines/CategoryEngine.ts:100

      return {
        valid: false,
        result: null,
        naturalTransformation: false
      };
    }
  }

  /**
   * Compose two morphisms: g . f (apply f then g)
   *
   * @param f - First morphism
   * @param g - Second morphism
   * @returns Composed morphism
   */
  async compose(f: Morphism, g: Morphism): Promise<Morphism> {
    // Verify composability: f.target === g.source
    if (f.target !== g.source) {
      throw new Error(
        `Cannot compose morphisms: ${f.name} (target: ${f.target}) and ${g.name} (source: ${g.source}) - ` +
        `target of first must equal source of second`
      );
    }

    // Create composed morphism
    const composedName = `${g.name} . ${f.name}`;

    // Register the composed functor
    const fFunctor = this.functorRegistry.get(f.name);
    const gFunctor = this.functorRegistry.get(g.name);

    if (fFunctor && gFunctor) {
      this.functorRegistry.set(composedName, (input: unknown) => {
        const intermediate = fFunctor(input);
        return gFunctor(intermediate);
      });
    }

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Inspect the underlying cause in logs, fix the root issue, and retry the operation.
  2. Validate inputs and preconditions before invoking this code path so the error is avoided.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at v3/plugins/prime-radiant/src/engines/CategoryEngine.ts:100 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/35299b84bd6188d6. Report an issue: GitHub.