Hoc manifest pattern

From openreachtech/hora-skills-ort-core · View interactive version

Hoc manifest pattern is an AI agent skill from the GitHub repository openreachtech/hora-skills-ort-core. The manifest pattern, also called the super strategy pattern: a structure keeps one shared object declaring its wiring, and everything the structure is made of may take that object. Use when deciding what a class receives, or when a collector starts naming each member's own parameters. The shape of

How to use this skill

Skill file

Manifest Pattern

Also called the super strategy pattern. The two names are one thing.

A structure — a server, an application, a subsystem — keeps **one object declaring its shared

wiring**. It is built once at boot and lives as long as the structure does. Everything the

structure is made of may take that object, and does.

The role travels under more than one name. A class holding it takes ~Manifest or ~Engine

as its main suffix, and whatever it is called, the parameter is named after that suffix. What

names the pattern is what the object does: it declares the structure's wiring and holds no

logic of its own.

Grand principle: anything in the structure may take the manifest

**A class belonging to a structure may declare the manifest in its interface, and needs no reason

for it.** Receiving it is not a dependency being smuggled in. It is access to the object the

structure already shares with everything inside it.

// OK: every member of the family takes the same thing
static isAcceptable ({
  manifest,
}) {
  return manifest.isProduction()
}

static async createAsync ({
  manifest,
}) {
  const threshold = this.resolveThreshold({
    manifest,
  })

  return this.create({
    threshold,
  })
}

— one reads its config, another its error declarations, a third its environment — and nothing

above it has to know which.

convention. This skill is about what a class may be handed.

Why the interface is uniform

**Where every member takes the manifest, whoever collects them treats them all alike, and adding

a member changes nothing at the call site.**

// OK: the collector lists candidates; it knows nothing of what each one needs
const acceptableCtors = MemberCtors.filter(it =>
  it.isAcceptable({
    manifest: this,
  })
)

const memberPromises = acceptableCtors.map(it =>
  it.createAsync({
    manifest: this,
  })
)

return Promise.all(memberPromises)
// NG: narrowed to "just the values each one needs", so the collector knows all of them
const alphaMembers = this.config.alphaLimit
  ? [
    AlphaMember.create({
      threshold: this.config.alphaLimit,
      reporter: this.reporterHash[AlphaMember.reporterName],
    }),
  ]
  : []

const betaMembers = this.env.isProduction()
  ? [
    BetaMember.create({
      reporter: this.reporterHash[BetaMember.reporterName],
    }),
  ]
  : []

The narrowed form looks like the smaller dependency and is the larger one. Every member's

parameter list has moved into the collector, so a new member edits shared code — the very thing

the strategy pattern exists to stop. This is where the super in the other name earns itself: an

ordinary strategy hands each variant its own arguments, and this one hands every variant the same

structure.

collector decides, it grows a branch per member; where the member declares it, the collector

grows a line.

The line: a manifest is not a per-call object

**What may be passed freely is the structure's own object. What arrives with a single call is

not.** A validation context, a request, a response, a transaction, a session — each belongs to

one call rather than to the structure, and taking one is a real dependency that needs a reason.

The test is one question: would this be the same object on the next call?

| Object | Same next call | May be taken freely |

| :-- | :-- | :-- |

| The manifest | yes — built once at boot | yes |

| A call's context, a request, a job payload | no — one per call | only where the member's own work needs it |

// NG: the base takes a per-call object so that it can report through it
reportError ({
  context,
  value = null,
}) {
  context.reportError(
    this.ErrorCtor.create({
      value,
    })
  )
}

// OK: the base builds the value; handing it to a per-call object belongs to whoever holds one
createError ({
  value = null,
}) {
  return this.ErrorCtor.create({
    value,
  })
}

the per-call object does take it — that is its work, not a channel it was handed.

Taking the manifest is not holding it

A static member taking the manifest does not put it on the instance. The factory reads what

it needs and hands the constructor plain values; the instance holds those and never sees the

manifest again.

widens what the instance depends on for its whole life, where the factory needed it for one

statement.

— holding it is correct, and the class design principles convention governs it.

Symptoms of getting it wrong

Each of these reads as a different defect and has one cause: the manifest was treated as an

ordinary dependency.

| Symptom | What actually happened |

| :-- | :-- |

| A collector's method grows a branch per member | The members were never asked whether they apply |

| A collector names each member's constructor parameters | The members were handed values instead of the manifest |

| The shared object grows one policy member per member of a family | A question the member should answer was answered for it, because the manifest held the data |

| A caller reaches through a field of the manifest to a method behind it | The manifest was treated as a bag of collaborators instead of an interface |

Reading the manifest is one hop, and one hop only

Taking the manifest freely is not licence to reach through it. manifest.env is the

interface the structure declares; manifest.env.isProduction() is the caller reaching past that

interface to a collaborator behind it, and the general rule against reaching through objects

applies to it in full. The manifest is not an exception to that rule — it is the object the rule

is measured from.

// NG: the caller now depends on env, and on what env offers
return manifest.env.isProduction()

// OK: the manifest answers for itself
return manifest.isProduction()

grows #isProduction(), which delegates to whatever it holds. Adding a member is a cheap

direction and it compounds: once the method exists, the next caller reaches it without ever

meeting the field behind it.

a property gave back; nothing behind the property is being reached for. What this rule turns

away is a hop to a collaborator whose behaviour is a decision of its own.

in the coding-styles convention. A line that

has to be chopped to satisfy it is usually a line that should not exist.

Where the manifest is a plain object

A manifest that cannot grow a method is a design mistake, and the correction is to make it an

instance of a class that can. Where that is cheap, do it.

may be read from everywhere, and giving it a class touches every one of those sites.

and report it** as a refactoring target rather than starting one. The review convention has no

WARNING; the level this takes there is MEDIUM — a departure that will mislead the next

reader, with no defect behind it.

to grow. Deciding to spend that is not this convention's call.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.