Operational context for coding-agent sessions in this repo. This file is a short map and guardrail list, not a framework spec. When behavior details matter, defer to the source code and the docs below.
aharness is a TypeScript/XState framework for making Codex coding workflows executable as finite state machines. Codex performs the language, code, and tool work; aharness owns the workflow around it: states, typed submissions, approval routing, hooks, run artifacts, and verification.
The repo is a pnpm + Node >=20 TypeScript monorepo:
packages/core—@aharness/coreSDK andaharnessCLI.packages/web-ui— private React/Vite browser UI. Its production build is generated into ignoredpackages/web-ui/dist/and copied intopackages/core/dist/ui/static/during the core build.packages/test-support— deterministic fixtures and integration-test helpers.examples— runnable examples and workflow references.docs— public guides, reference material, architecture notes, and archival plans/specs.
Use current docs as the source of truth. Do not rely on stale memory or archived plans unless the task explicitly asks for historical context.
README.md— project overview, install path, examples, package map.CONTRIBUTING.md— contribution expectations and documentation maintenance.docs/authoring.md— how to design and write aharness FSMs.docs/reference.md— public SDK and CLI reference.docs/architecture.md— runtime shape, browser UI, run artifacts, package boundaries.docs/run-event-visibility.md— ground truth for browser event/transcript visibility policy.docs/troubleshooting.md— common runtime and install failures.packages/core/SUPPORTED_CODEX.md— Codex CLI compatibility gate.
- Installed skills cannot rely on this repository's docs being present. Any
repo-owned skill that teaches aharness behavior must be self-contained through
its
SKILL.mdand bundledreferences/files. - When public aharness docs change behavior, public API, commands, package facts, runtime semantics, or user-facing workflows, update affected repo-owned skills in the same workflow. Do not leave installed-skill guidance depending on external repo docs or stale copied facts.
- Mechanisms belong in the framework; workflow opinions belong in user FSMs,
examples, or docs. If behavior could plausibly vary between teams or workflows,
do not bake that policy into
@aharness/core. - Verification gates execution. Invalid machines must fail before Codex starts.
- Codex produces work and structured data; aharness decides state transitions. Transitions must come through the active state's typed exits and framework validation, not through model convention.
- A live run owns one Codex
app-serverand one aharness WebSocket client. Do not assume mirror sessions or alternate clients are part of the runtime. - Run logs are sensitive.
.aharness/runs/**/events.jsonlis canonical runtime evidence and can contain raw owner input, browser replies, tool arguments and results, command output, file diffs, approval data, token usage, and sub-thread activity.events.jsonlcan also contain public workflow context snapshots recorded ascontext.initializedandcontext.changedevents. Treat run directories as sensitive even when the browser transcript does not display those context values by default. - Recorded-run UI inspection is the public foreground
aharness view [run-id]command. It selects the newest recorded run when no run id is provided, accepts a run id only, projects recorded canonical JSONL through the same run-scoped browser APIs as live runs, and does not start Codex, an app-server, or a live thread. View mode is read-only; crafted replies are rejected. Topology recovery imports the recorded FSM source on a best-effort basis using recordedrepoRoot/fsmFilemetadata when present, warns and continues with empty topology on failure, and has the same import-time trust boundary asverifyandrun. docs/run-event-visibility.mdis the ground truth for event/transcript visibility decisions. Any event/transcript visibility policy change must update that document in the same workflow, and policy-content changes to that document require explicit user acceptance before implementation or commit.
Avoid hand-editing generated or local runtime artifacts unless the task is explicitly about those files:
.aharness/dist/*.tsbuildinfonode_modules/.pnpm-store/- coverage and
.vitest/ - vendored checkouts and generated vendored assets
Never stage or commit files under these local planning and follow-up areas:
docs/plans/docs/specs/docs/ideas/docs/strategies/docs/followups/
- Keep changes scoped to the requested behavior.
- Update relevant docs in the same change when behavior, public API, commands, package facts, or user-facing workflows change.
- Never add FSM tests. When changing FSM behavior, verify with
aharness verifyand direct inspection instead of adding or extending FSM test files. - When running visual Playwright tests that start
aharness run, pass--no-openso aharness serves and prints the UI URL without launching a separate system browser window. - Release prep uses
commit-and-tag-version; generatedCHANGELOG.mdand GitHub release notes only show visible Conventional Commit types:feat,fix,perf, andrefactor.docs,chore,test,style,ci, andbuildare hidden, so use a visible type for user-facing release-note-worthy changes. - Treat
examples/workflow-references/as workflow-opinion material that users may encode in FSMs, not as framework policy. - On or after 2026-06-12, revisit the temporary
react-doctor@0.2.14pin and try bumping the repo back toreact-doctor@0.4.0under the global 7-day pnpm release-age policy. - For runtime architecture questions, inspect
packages/core/src/runtime,packages/core/src/transport,packages/core/src/protocol,packages/core/src/runEvents, anddocs/architecture.mdbefore changing code.
- Add real-Codex E2E tests only when they increase confidence in production runtime paths that mocked seams cannot prove. Use the fewest and simplest tests that cover the risk; prefer one happy path plus one focused edge case over a broad scenario matrix.
- Follow the existing gate: require
codexonPATHandAHARNESS_E2E_REAL_CODEX=1, then wrap the suite indescribe.skipIf(!E2E_ENABLED). Defaultpnpm run verifymust stay usable without real Codex E2E prerequisites. - Use
@aharness/test-supporthelpers such asstartMockModel()so the app-server and protocol path are real while model output stays deterministic. - Keep fixtures tiny: write the FSM source into a temp repo, stub unrelated
preflight seams such as static verification or auth only when the test is not
about those seams, and assert durable production evidence such as
events.jsonl, terminal result, JSON-RPC requests, or resource shutdown.