d26f20c316
Root Child DOX Index assembled, plus a per-module AGENTS.md across the tree (core/*, infrastructure/*, apps/*, testing/*, and docs/examples/frontend/etc), each following the DOX section shape: Purpose, Ownership, Local Contracts, Work Guidance, Verification, Child DOX Index.
4.7 KiB
4.7 KiB
core/ — AGENTS.md
Purpose
Pure domain logic for CORREX: event sourcing primitives, session orchestration, inference routing, tool management, workflow graph execution, and all supporting domain services. No I/O, no external adapters.
Ownership
All modules under core/ are owned by the CORREX kernel team. Changes to shared event types (in core:events) require review for downstream impact across all modules.
Local Contracts
- Dependency direction:
apps → core → infrastructure. No cross-core imports. No sibling module dependencies withincore/. - Shared vocabulary types belong in
core:eventsonly. - Constructor parameters use interfaces wherever an interface exists. Concrete classes are never instantiated inside another class.
- All state is rebuilt from events. State is never persisted independently.
- Every new
EventPayloadsubclass must be registered incore/events/.../serialization/Serialization.ktinside theeventModulepolymorphic block. Missing registration causes silent runtime deserialization failure.
Work Guidance
Follow the standard domain module pattern for every module in this subtree:
- Events —
@Serializable data classimplementingEventPayload, defined incore:events. - State — module-local
@Serializable data classwith sensible empty defaults. Always rebuilt from events. - Reducer —
interface ThingReducer+DefaultThingReducer. Onlystate.copy(...)logic, no domain decisions. - Projector —
class ThingProjector(reducer)implementingProjection<ThingState>. - Repository —
DefaultThingRepository(replayer: EventReplayer<ThingState>). Wired asDefaultEventReplayer(store, ThingProjector(DefaultThingReducer())).
Hard Invariants (all apply here):
- Event log is the only source of truth.
- Projections are bounded-context owned — no shared global state, no cross-projection mutation.
- LLMs propose; core decides. LLM outputs are untrusted until validated.
- Policy layer is absolute — approvals cannot override policy denial.
- All tools declare execution tier. All tool side effects captured in events.
- Compression is non-authoritative — derived representations must not replace original events.
- Replay is environment-independent — no external service calls, no live LLM required.
- Environment observations are recorded as events at the moment they occur, never re-queried during replay.
Kotlin rules:
runCatching { }over bare try/catch.- Scope functions (
?.let,?:) over null-branchingif/else. suspend+delay(), neverThread.sleep(). Blocking I/O inwithContext(Dispatchers.IO).- Never swallow
CancellationException. - Verify all imports are used before finalizing any file.
Verification
./gradlew check # full suite: tests + detekt + koverVerify
./gradlew :core:<module>:test --rerun-tasks # single module, bypass cache
Many tests live in testing/ submodules (approvals, contracts, deterministic, kernel, projections, replay, transitions) — check there before concluding a module has no tests.
Child DOX Index
- approvals/ — approval gate engine: grants, modes, policy enforcement
- artifacts/ — structured output model: artifact kinds, lineage, relationships
- artifacts-store/ — artifact persistence interface
- config/ — TOML config loading, operator/project profile, agent instructions
- context/ — context synthesis, compression, token budgeting
- critique/ — critic calibration state and projector
- events/ — event primitives, serialization registry, replay infrastructure
- inference/ — provider abstraction, routing, prompt rendering, embedder
- journal/ — decision journal projection and memory distillation
- kernel/ — top-level orchestration: SessionOrchestrator, retry, replay
- risk/ — risk assessment and tier mapping
- router/ — router facade, context building, L3 memory, idea capture
- sessions/ — session lifecycle, state, approval mode binding
- tasks/ — task graph, board, markdown, git sync, context assembly
- toolintent/ — plane-2 tool-call intent validation and workspace policy
- tools/ — tool contract, registry, executor, output compression
- transitions/ — FSM/workflow graph, stage execution, cycle detection
- validation/ — layered validation pipeline: graph, semantic, session, JSON schema