Skip to content

skills: no rule stages a stepwise fold's nodes and registers them once #2370

Done

Description

@OmarAlJarrah

Problem

morphic-designing-code has no rule for a fold that has to run in steps, where each step makes a node at an ID the type registry holds once. references/design-rules.md#fold-the-whole-set says a merge of several declarations "chooses from all of them at once, never folding each into what the ones before it left". It gives no route for when a fold cannot do that, such as a cycle of compositions whose members each compose the next, folded as a chain of pairwise folds. If each step registers its node, the next step's node meets an ID that is already taken. The registry refuses it, and the first step's node stands.

$ git grep -n -i -E '\bstag(e|ed|ing)\b|register(ed|s)? once|working value' origin/main -- .claude/skills/morphic-designing-code; echo "exit $?"
exit 1

A ring of three models, each redeclaring id as a different enum:

openapi: 3.1.0
info: {title: t, version: "1"}
paths: {}
components:
  schemas:
    A: {allOf: [{$ref: '#/components/schemas/B'}], properties: {id: {type: string, enum: [a, b, c, d]}}}
    B: {allOf: [{$ref: '#/components/schemas/C'}], properties: {id: {type: string, enum: [b, c, d, e]}}}
    C: {allOf: [{$ref: '#/components/schemas/A'}], properties: {id: {type: string, enum: [c, d, e, f]}}}

At 3a57bcf, a commit of the work on #2354 that its branch does not hold yet, which registered each step's node:

$ morphic compile --diagnostics-per-code-limit 0 ring.yaml > ring.json; echo "exit $?"
error compile/registry-refused: internal: the type registry refused an entry: register rejected: id="type/composed/components/schemas/A/allOf/properties/id" already holds a different node
warning pass/composition-cycle ring.yaml#/components/schemas/A: composition never ends: base type/openapi/components/schemas/B leads back into a cycle of bases and mixins
warning pass/composition-cycle ring.yaml#/components/schemas/B: composition never ends: base type/openapi/components/schemas/C leads back into a cycle of bases and mixins
warning pass/composition-cycle ring.yaml#/components/schemas/C: composition never ends: base type/openapi/components/schemas/A leads back into a cycle of bases and mixins
exit 1
$ jq -c '.types["type/composed/components/schemas/A/allOf/properties/id"] | {kind, members: [.members[].value.string]}' ring.json
{"kind":"enum","members":["b","c","d"]}

The enum is the first pairwise fold's (b, c, d), not the one all three declarations meet at (c, d). Its child 73bfb75 fixed it by holding each step's node in a working set keyed by ID. Each later step reads that set before the registry, and the nodes are registered once, after the last step. Its test compiles the ring in all six orders to one registry, and fails if each step's node is registered.

Direction

A draft, a rule beside fold-the-whole-set:

  • Rule. Where a fold cannot choose from the whole set at once and runs in steps, each making a node at an ID the registry holds once, hold each step's node in a working set keyed by that ID. Every later step reads that set before the registry. Register once after the last step, so that only the final node is registered. A node no later step keeps is never registered.
  • Probe. Three declarations in all six orders compile with no compile/registry-refused and to one registry. A plant registering each step's node turns that test red.

Out of scope

Whether a cycle of compositions should fold at all, which pass/composition-cycle reports.

Related: #2354

Priority: P4, rule 1 (housekeeping): a skills change that alters no lowering, validation, IR or emit-contract behaviour. The git grep above → no match (morphic @4a7a384c9). The compile above → compile/registry-refused, exit 1 (morphic @3a57bcfe0).

Activity

  1. added
    type:feature
    priority:P4
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P4type:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions