You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type: EngineeringScaffoldstage: draftmaturity: L1created: 2026-05-10inputs:
- "OpenAI harness engineering (2026-02) — architectural model enforced via custom linters and structural tests"
- "#14 — architectural layering and hexagonal boundaries"
- "#29 — CI workflow"related: ["#14", "#29", "#28"]
Purpose. Mechanically enforce the runtime's architectural dependency layers and taste invariants via custom linters and structural tests, with error messages that include agent-readable remediation instructions.
Context
OpenAI's harness engineering experience makes this point directly:
"We built the application around a rigid architectural model. Every business domain is divided into a fixed number of layers, with strictly checked dependency directions and a limited number of allowed edges. These constraints are enforced mechanically through custom linters (generated by Codex, naturally!) and structural tests."
"Custom linters include remediation instructions in error messages so agents can fix violations without human intervention."
"This is the kind of architecture you normally defer until you have hundreds of engineers. With coding agents, it's an early prerequisite: the constraints are what enable speed without decay or architectural drift."
The runtime's #14 already defines the layered hexagonal architecture. This issue mechanises its enforcement before the first production code lands.
What to enforce
Dependency layer ordering
Within the runtime package, code must flow in one direction only:
Types → Config → Ports → Kernel → Systems → Adapters → Public barrel
No reverse imports. No skipping layers. Enforced via import-graph analysis.
Cross-boundary rules
Public barrel (src/index.ts) must export only L2 public domain types and the RuntimeKernel façade
Internal ECS types (L3) must never appear in public exports
Capability ports must not import from kernel internals
All functions crossing a port boundary must return Result<T, E>
No implicit any
TypeScript strict: true + noImplicitAny enforced
Event payload serialisability
All RuntimeEvent subtypes must pass a JSON round-trip test (→ #17)
File size limit
No source file exceeds 400 lines
No barrel re-export of internal types
Grep check on barrel exports
Agent-friendly error messages
Per the harness engineering article, each lint failure must include a remediation instruction that an agent can act on without human clarification:
ESLint: import-layer-order — 'src/kernel/AgentTickSystem.ts' imports from 'src/adapters/WorktreeAdapter.ts'
✗ Kernel layer cannot import from Adapters layer (direction: kernel → systems → adapters → barrel)
✓ Fix: move the dependency inversion — define a port interface in 'src/ports/internal/' and inject the adapter
Docs: docs/ARCHITECTURE.md#dependency-layers
Every lint rule must have:
A violation description (what broke)
A fix instruction (what to do)
A docs reference (where to learn more)
Implementation plan
Add eslint-plugin-import or a custom ESLint plugin for layer-order enforcement
Write a structural test (src/__tests__/architecture.test.ts) that programmatically checks:
Public barrel exports only allowed types
No internal types leak through the barrel
All event payload types pass JSON round-trip
Write or configure lint rules for taste invariants
Ensure all lint errors include remediation instructions (custom messages in ESLint rule metadata)
Meta
Context
OpenAI's harness engineering experience makes this point directly:
The runtime's #14 already defines the layered hexagonal architecture. This issue mechanises its enforcement before the first production code lands.
What to enforce
Dependency layer ordering
Within the runtime package, code must flow in one direction only:
No reverse imports. No skipping layers. Enforced via import-graph analysis.
Cross-boundary rules
src/index.ts) must export onlyL2public domain types and theRuntimeKernelfaçadeL3) must never appear in public exportsWorktreePortmust not be exported from the barrel (→ Phase 1 · SAO design decision — port namespace organisation (WorktreePort / OrchestratorPort) #50)Taste invariants
console.log/console.errorin non-test codeResultdisciplineResult<T, E>anystrict: true+noImplicitAnyenforcedRuntimeEventsubtypes must pass a JSON round-trip test (→ #17)Agent-friendly error messages
Per the harness engineering article, each lint failure must include a remediation instruction that an agent can act on without human clarification:
Every lint rule must have:
Implementation plan
eslint-plugin-importor a custom ESLint plugin for layer-order enforcementsrc/__tests__/architecture.test.ts) that programmatically checks:Acceptance
docs/ARCHITECTURE.md#dependency-layerssection written as the remediation reference target