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-structureActors: 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
tsconfigpathsaliases 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.mdnames exactly these layers in this order:apporroutes,composition,features,modules,integrations,ui; states that each layer imports only lower layers; placesserver/outside the layers undereffect-backend-structure; and no longer contains "These labels may differ between projects".- Covers: OUT-001
- Architecture: AC-001
- AC-002:
references/structure.mdstates that Composition owns app-wide providers, surface shells, page templates and cross-feature registries; that its first level isproviders/plus one folder per Surface; and that a Surface folder is guided asshell/andpages/<page>/.- Covers: OUT-001
- Architecture: AC-002
- AC-003:
references/structure.mdstates 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.mddefines a domain as the first folder under a layer withindex.tsorindex.tsxas its only cross-domain entrypoint (ui/exempt); the layer root assrc/else the package root;proxy.ts,middleware.tsandinstrumentation.tsas route-layer files;ui/as the shared UI package only in a monorepo andsrc/ui/in a single-package repository; andserver/as importable only fromintegrations/(through server public entrypoints) andapp/api/handlers.- Covers: OUT-001
- Architecture: AC-004
- AC-005:
references/structure.mdcontains a## Lint Rulestable whose rule ids are exactlylayer-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.mdplaces app-wide providers incomposition/providers/, shells and page templates incomposition/<surface>/, states that a page template exports its component plus optionalgenerateMetadataand loader functions, and states that route files only connect them.- Covers: OUT-002
- Architecture: AC-006
- AC-007:
SKILL.mdtells the agent to run thefrontend-layerslint 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-planreferences/architecture-convergence.md,implement-specreferences/architecture-conformance.md,ask-hireferences/discovery-and-docs.mdandreferences/baseline.md, andhi-clireferences/managed-lint.mddescribe the composition layer and thereact-frontend-layersasset consistently withstructure.md; the skills repository contract tests pass.- Covers: OUT-003
- Architecture: AC-008
- AC-009: the HI lint catalog contains asset
react-frontend-layerswith JS pluginfrontend-layersat specifier./tools/oxlint/frontend-layers/index.mjs; thereactPack lists it inlintAssets; thefrontendPacklintAssetsis unchanged.- Covers: OUT-004
- Architecture: AC-009
- AC-010: registry materialization copies the plugin byte-identically to
<scope>/tools/oxlint/frontend-layers/index.mjsonly in Software Scopes where thereactPack 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/norroutes/produces nofrontend-layersdiagnostic.- 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 absolutecontext.filenameand@/against the layer root; ignores every other specifier; and checks static imports,export … from,import("…")andrequire("…")with string literals.- Covers: OUT-005
- Architecture: AC-013
- AC-014:
ui-placementreports an app-localui/folder only when apnpm-workspace.yamlor apackage.jsonwithworkspacesexists at or above the package root; in a single-package repositorysrc/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
offin the scope'soxlint.local.tsproduces no diagnostic.- Covers: OUT-005
- Architecture: AC-016
- AC-017: an HI test reads the
## Lint Rulestable inapps/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-layersasset, andBASELINE_CHANGELOG.mdUnreleasedhas 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
reactPack (Q19; issue-224 Q8). - Shared skills change only on
mainin/home/stefan/repos/skills, thenbun run sync:skillsbrings them into HI (rootAGENTS.md). - A changed
BASELINE_CHANGELOG.mdselects the baseline release product (rootAGENTS.mdrelease classification).
Dependency Readiness
No Stack Required.
Branch/Base Intent
- HI work: branch
t3/frontend-domain-structure-layersfrommain(906e72726), which holds this spec. - Skills work: commits on
mainofwearedevpunks/skillsonly, per rootAGENTS.md; HI consumes them throughbun run sync:skillswith the exact receipt SHA.
Architecture Source
- URL: https://github.com/wearedevpunks/harness-intelligence/blob/f5991916037d649b6a77081a7bbf57e0747233de/apps/wiki/content/docs/project/specs/cli/frontend-composition-layer/ARCHITECTURE.md
- Commit:
f5991916037d649b6a77081a7bbf57e0747233de - Path:
apps/wiki/content/docs/project/specs/cli/frontend-composition-layer/ARCHITECTURE.md - Content sha256:
ca84ba32d9520cc9eefeaa6ff8cd019312ace80b41f884452b18af75d9297fe6
Accepted Technical Decisions
- Layer order
apporroutes→composition→features→modules→integrations→ui; each layer imports only lower layers (Q1, Q12, Q23; ARC-001). - Routes import only
composition/;app/api/handlers import onlyserver/; onlyintegrations/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.tsorindex.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 filesproxy.ts,middleware.ts,instrumentation.tsare route layer (Q22; ARC-006). - Asset
react-frontend-layerson thereactPack; pluginfrontend-layers; sourceapps/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.0has no resolver (Q32; ARC-007). - Monorepo probe: walk up from the package root for
pnpm-workspace.yamlorpackage.jsonworkspaces, once per run (Q33; ARC-004). - Skill file layout:
structure.mdrewritten as authority with a## Lint Rulestable;react/structure.mdReact placement;SKILL.mdadds lint and scoped application (Q27; ARC-009).
Accepted Testing Decisions
- Vitest tests in
apps/clirun 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-structureis updated to the new wording (Q18).
Verification Seams
oxlintCLI output on fixture trees (rule name and severity).- Registry materialization of the
lint-react-frontend-layersitem. - The parity test over
apps/cli/skills/agnostic/frontend/frontend-domain-structure/references/structure.mdand the plugin's exported rules. node --testcontract tests inwearedevpunks/skills.
Decision Log
| Decision | Evidence | Rationale |
|---|---|---|
Top layer named composition/ | Q1 | Matches ci-app backend and effect skill terminology |
Asset on react Pack, not frontend Pack | Q19 | frontend Pack has no detection data; owner-local evidence required |
| Plain errors, no baseline | Q16 | User: "we just have lint error to flag it" |
| Skill is authority; parity test in HI | Q21, Q35, Q35-R5 | HI sees both the synced Registry skill copy and the plugin |
Monorepo keeps primitives only in packages/ui | Q24 | User direction |