Harness Intelligence Wiki
SpecsCLIFrontend Composition Layer

Frontend Composition Layer

Spec: Frontend Composition Layer

Context

Four client frontends (pegasus, apito, emera, assolombarda) have no legal owner for shells, providers and page templates. The current frontend-domain-structure skill puts them in the route folder, which cannot hold them, and forbids modules from importing features. Agents therefore put combining code in features/, components/ or a catch-all modules/, and the repositories show feature cycles, peer-feature imports and prototype code on production paths (brief).

This capability gives the skill one fixed layer model with a top Composition layer, and enforces it with a managed lint asset:

<layer root>/        src/ if present, else the package root
├── app/ or routes/  route layer; imports only composition
├── composition/     providers/ + one folder per Surface
├── features/        flat; a Feature never imports another Feature
├── modules/         app-local capabilities that several features use
├── integrations/    outside systems, client setup, mock and demo runtimes
├── ui/              primitives and shadcn components (single-package repo only)
└── server/          outside the layers; effect-backend-structure

Actors: an operating agent that plans or implements frontend work; the managed lint run in each React Software Scope; a project maintainer who reads lint errors. Canonical terms: glossary.

Non-Goals

  • Migration of pegasus, apito, emera or assolombarda in this delivery (Q10).
  • A violation baseline or ratchet (Q16).
  • A mechanism that refuses a local rule override (Q20).
  • Per-project layer names, route folder names or exemption lists (Q8, Q23, Q25).
  • Lint checks inside a Surface folder (Q29).
  • Resolution of tsconfig paths aliases other than @/ (Q32).

Requirements and Outcomes

OUT-001: The skill reference defines one fixed layer model

references/structure.md is the single authority for layer names, layer order, domains, public entrypoints and the Lint Rules table.

Architecture: OUT-001; ARC-001, ARC-002, ARC-003, ARC-005.

OUT-002: The React addendum places providers, shells and page templates

Architecture: OUT-002; ARC-002, ARC-009.

OUT-003: Agents and consumer skills follow the new model

Architecture: OUT-003; ARC-009, ARC-010, FLOW-002.

OUT-004: HI installs the react-frontend-layers lint asset in React Software Scopes

Architecture: OUT-004; ARC-006, FLOW-001-STEP-001.

OUT-005: The frontend-layers plugin enforces the layer model

Architecture: OUT-005; ARC-004, ARC-006, ARC-007, FLOW-001.

OUT-006: The skill rule list and the plugin rules cannot drift

Architecture: OUT-006; ARC-008, FLOW-003.

OUT-007: Docs and release notes describe the change

Architecture: OUT-007; ARC-009.

Acceptance Criteria

  • AC-001: references/structure.md names exactly these layers in this order: app or routes, composition, features, modules, integrations, ui; states that each layer imports only lower layers; places server/ outside the layers under effect-backend-structure; and no longer contains "These labels may differ between projects".
    • Covers: OUT-001
    • Architecture: AC-001
  • AC-002: references/structure.md states that Composition owns app-wide providers, surface shells, page templates and cross-feature registries; that its first level is providers/ plus one folder per Surface; and that a Surface folder is guided as shell/ and pages/<page>/.
    • Covers: OUT-001
    • Architecture: AC-002
  • AC-003: references/structure.md states that a Feature never imports another Feature and the nearest composition connects them through props, slots or callbacks; that consumable shell parts are modules and the shell assembly is composition; and that mock data, demo data and fake runtimes are integrations, with no production UI in a folder named "prototype".
    • Covers: OUT-001
    • Architecture: AC-003
  • AC-004: references/structure.md defines a domain as the first folder under a layer with index.ts or index.tsx as its only cross-domain entrypoint (ui/ exempt); the layer root as src/ else the package root; proxy.ts, middleware.ts and instrumentation.ts as route-layer files; ui/ as the shared UI package only in a monorepo and src/ui/ in a single-package repository; and server/ as importable only from integrations/ (through server public entrypoints) and app/api/ handlers.
    • Covers: OUT-001
    • Architecture: AC-004
  • AC-005: references/structure.md contains a ## Lint Rules table whose rule ids are exactly layer-order, route-imports, no-peer-feature, public-entrypoint, no-prototype-folder, known-top-level, ui-placement.
    • Covers: OUT-001
    • Architecture: AC-005
  • AC-006: references/react/structure.md places app-wide providers in composition/providers/, shells and page templates in composition/<surface>/, states that a page template exports its component plus optional generateMetadata and loader functions, and states that route files only connect them.
    • Covers: OUT-002
    • Architecture: AC-006
  • AC-007: SKILL.md tells the agent to run the frontend-layers lint rules and to apply the pattern only to the scope of the implementation that invoked it, and states that test and story files follow the same rules.
    • Covers: OUT-003
    • Architecture: AC-007
  • AC-008: agents/openai.yaml, create-plan references/architecture-convergence.md, implement-spec references/architecture-conformance.md, ask-hi references/discovery-and-docs.md and references/baseline.md, and hi-cli references/managed-lint.md describe the composition layer and the react-frontend-layers asset consistently with structure.md; the skills repository contract tests pass.
    • Covers: OUT-003
    • Architecture: AC-008
  • AC-009: the HI lint catalog contains asset react-frontend-layers with JS plugin frontend-layers at specifier ./tools/oxlint/frontend-layers/index.mjs; the react Pack lists it in lintAssets; the frontend Pack lintAssets is unchanged.
    • Covers: OUT-004
    • Architecture: AC-009
  • AC-010: registry materialization copies the plugin byte-identically to <scope>/tools/oxlint/frontend-layers/index.mjs only in Software Scopes where the react Pack applies.
    • Covers: OUT-004
    • Architecture: AC-010
  • AC-011: for each of the seven rules, oxlint 1.86.0 run on that rule's failing fixture tree reports at least one error named frontend-layers/<rule>, and run on its passing fixture tree reports none.
    • Covers: OUT-005
    • Architecture: AC-011
  • AC-012: a React package whose layer root has neither app/ nor routes/ produces no frontend-layers diagnostic.
    • Covers: OUT-005
    • Architecture: AC-012
  • AC-013: the plugin uses src/ as layer root when present, else the package root; resolves relative specifiers against the absolute context.filename and @/ against the layer root; ignores every other specifier; and checks static imports, export … from, import("…") and require("…") with string literals.
    • Covers: OUT-005
    • Architecture: AC-013
  • AC-014: ui-placement reports an app-local ui/ folder only when a pnpm-workspace.yaml or a package.json with workspaces exists at or above the package root; in a single-package repository src/ui/ produces no diagnostic and is the lowest layer.
    • Covers: OUT-005
    • Architecture: AC-014
  • AC-015: a *.test.* or *.stories.* file that breaks a rule produces the same error as any other file.
    • Covers: OUT-005
    • Architecture: AC-015
  • AC-016: every violation has severity error with no baseline; a rule set to off in the scope's oxlint.local.ts produces no diagnostic.
    • Covers: OUT-005
    • Architecture: AC-016
  • AC-017: an HI test reads the ## Lint Rules table in apps/cli/skills/agnostic/frontend/frontend-domain-structure/references/structure.md, passes when its ids equal the plugin's rule names, and fails when they differ.
    • Covers: OUT-006
    • Architecture: AC-017
  • AC-018: the wiki skills, Packs and managed lint pages describe the layer model and the react-frontend-layers asset, and BASELINE_CHANGELOG.md Unreleased has a non-empty entry for the change.
    • Covers: OUT-007
    • Architecture: AC-018

Constraints

  • The skill reference is the authority; the plugin implements its Lint Rules table exactly (Q21).
  • Layer names and the route-folder enum are fixed; the plugin takes no project option (Q8, Q23, Q26).
  • Asset applicability follows owner-local evidence through the react Pack (Q19; issue-224 Q8).
  • Shared skills change only on main in /home/stefan/repos/skills, then bun run sync:skills brings them into HI (root AGENTS.md).
  • A changed BASELINE_CHANGELOG.md selects the baseline release product (root AGENTS.md release classification).

Dependency Readiness

No Stack Required.

Branch/Base Intent

  • HI work: branch t3/frontend-domain-structure-layers from main (906e72726), which holds this spec.
  • Skills work: commits on main of wearedevpunks/skills only, per root AGENTS.md; HI consumes them through bun run sync:skills with the exact receipt SHA.

Architecture Source

Accepted Technical Decisions

  • Layer order app or routes → composition → features → modules → integrations → ui; each layer imports only lower layers (Q1, Q12, Q23; ARC-001).
  • Routes import only composition/; app/api/ handlers import only server/; only integrations/ imports server public entrypoints (Q2, Q13; ARC-005).
  • Composition first level: providers/ plus one folder per Surface (Q4, Q29; ARC-002).
  • Domain = first folder under a layer; entrypoint index.ts or index.tsx; ui/ exempt (Q28; ARC-003).
  • Unknown top-level folders under the layer root are errors; allowed: app, routes, composition, features, modules, integrations, ui, server; root files proxy.ts, middleware.ts, instrumentation.ts are route layer (Q22; ARC-006).
  • Asset react-frontend-layers on the react Pack; plugin frontend-layers; source apps/cli/src/data/lint/frontend-layers/index.mjs; installed <scope>/tools/oxlint/frontend-layers/index.mjs; seven rules (Q19, Q31; ARC-006).
  • Import resolution: relative against absolute context.filename, @/ against layer root, others ignored; @oxlint/plugins@1.86.0 has no resolver (Q32; ARC-007).
  • Monorepo probe: walk up from the package root for pnpm-workspace.yaml or package.json workspaces, once per run (Q33; ARC-004).
  • Skill file layout: structure.md rewritten as authority with a ## Lint Rules table; react/structure.md React placement; SKILL.md adds lint and scoped application (Q27; ARC-009).

Accepted Testing Decisions

  • Vitest tests in apps/cli run the real oxlint binary on a passing and a failing fixture tree per rule, beside the existing byte-identical packaging test (Q34).
  • An HI parity test compares the synced skill's Lint Rules ids with the plugin's rule names (Q35).
  • Test and story files get no exemption (Q30).
  • The skills repository contract test for frontend-domain-structure is updated to the new wording (Q18).

Verification Seams

  • oxlint CLI output on fixture trees (rule name and severity).
  • Registry materialization of the lint-react-frontend-layers item.
  • The parity test over apps/cli/skills/agnostic/frontend/frontend-domain-structure/references/structure.md and the plugin's exported rules.
  • node --test contract tests in wearedevpunks/skills.

Decision Log

DecisionEvidenceRationale
Top layer named composition/Q1Matches ci-app backend and effect skill terminology
Asset on react Pack, not frontend PackQ19frontend Pack has no detection data; owner-local evidence required
Plain errors, no baselineQ16User: "we just have lint error to flag it"
Skill is authority; parity test in HIQ21, Q35, Q35-R5HI sees both the synced Registry skill copy and the plugin
Monorepo keeps primitives only in packages/uiQ24User direction

On this page