Contributor reference for current internals.
Related docs:
- Contributor map (start here):
docs/CONTRIBUTOR_MAP.md - User documentation:
docs/USER_GUIDE.md - Architecture overview:
docs/ARCHITECTURE.md - CI tiers (what PRs gate):
docs/CI.md - Regression test placement:
docs/REGRESSION_TESTS.md - Terminology contract:
docs/VOCABULARY.md - Historical context (not current spec):
docs/journey/README.md
- Repository Layout
- Request Lifecycle
- Orchestration Services
- Execution Surface
- Config and Environment
- Testing and Validation
- Adding Features Safely
backend/
cli/ Console entrypoint, Textual TUI, non-interactive runner, slash commands
context/ Conversation memory and compaction
core/ Config, constants, app paths, logging
engine/ Prompt assembly, model interaction flow, and agent tools
evaluation/ Agent eval pack and related evaluation helpers
execution/ Runtime executor, shell/session plumbing, policy enforcement
inference/ Provider resolver and direct LLM clients
integrations/ External integrations (including MCP plumbing)
knowledge/ Retrieval and knowledge-related modules
ledger/ Actions, observations, stream, serialization
orchestration/ SessionOrchestrator and focused services
persistence/ Durable storage and state persistence helpers
playbooks/ Task playbook assets and loading logic
security/ Safety analysis and execution policies
telemetry/ Lightweight telemetry
tools/ Repo maintenance utilities (e.g. trajectory sanitization)
utils/ Shared helpers (imports, LSP client, retries, etc.)
validation/ Validation and completion guards
tests/ Unit and integration tests
Canonical local flow:
Console script
-> backend.cli.entry
-> Textual TUI or non-interactive runner
-> SessionOrchestrator step loop
-> engine decides next action
-> execution layer runs action
-> observation emitted
-> orchestrator updates state
-> finish path applies step guards plus optional completion-quality validation
The orchestrator uses service modules in backend/orchestration/services/.
Current service files:
action_execution_service.pyaction_service.pyautonomy_service.pycircuit_breaker_service.pyconfirmation_service.pyevent_router_service.pyexception_handler_service.pyguard_bus.pyiteration_guard_service.pyiteration_service.pylifecycle_service.pyobservation_service.pyorchestration_context.pypending_action_service.pyrecovery_service.pyretry_service.pysafety_service.pystate_transition_service.pystep_decision_service.pystep_guard_service.pystep_prerequisite_service.pystuck_detection_service.pytask_validation_service.py(warning-only completion-quality checks when enabled)
When adding new behavior, prefer extending an existing focused service first before creating new control-plane surfaces.
Execution internals live under backend/execution/.
Important entrypoints:
- console runtime usage through orchestrator
- runtime executor implementation in
backend.execution.server.action_execution_server - native browser helpers in
backend.execution.browser - DAP/debugger helpers in
backend.execution.dap - MCP runtime/proxy helpers in
backend.execution.mcp
settings.json is the default user-facing local config file in a source checkout. Installed CLI runs use ~/.grinta/settings.json; APP_ROOT can intentionally override the settings root.
Copy settings.template.json, run grinta init, or let first grinta launch write settings. The template matches the init wizard output shape:
| Block | Purpose |
|---|---|
llm_provider, llm_model, llm_api_key, llm_base_url |
Model routing (see SETTINGS.md) |
agent.Orchestrator.mode |
chat, plan, or agent |
agent.Orchestrator.autonomy_level |
conservative, balanced, or full |
security |
Execution profile and read-boundary policy |
mcp_config |
MCP servers (off by default) |
Full key reference: SETTINGS.md. Unknown keys are warned at load time; see backend/core/config/agent_config.py for optional agent keys.
Environment variables are supported and useful in CI/automation. Common examples:
LLM_API_KEYLLM_MODELAPP_ROOT
Runtime/session state is stored under ~/.grinta/workspaces/<id>/storage, not under the repository tree.
- TTY startup path:
launch/entry.py->backend/cli/entry.py->backend/cli/main.py->backend/cli/tui/main.py. - Non-interactive path:
backend/cli/main.py->backend/cli/repl/noninteractive.py. - Slash-command handlers live in
backend/cli/repl/slash_command_*; the Textual TUI is the interactive surface. Keep slash-command behavior consistent when changing shared handlers.
Grinta executes on local host permissions.
hardened_local adds policy constraints, but does not provide sandbox isolation.
uv run pytest backend/tests/unit/ --tb=short -qThat is the fast local loop and matches the Linux unit coverage shards. On Linux, Windows, and macOS, CI also runs integration, e2e, and stress in the platform extended gates after unit tests pass. Local mirror for coverage:
PYTHONPATH=. uv run pytest --cov=backend --cov-fail-under=75 backend/tests/unitA bare pytest or uv run pytest from the repository root follows pytest.ini and collects all of backend/tests (integration, e2e, stress, and so on)—expect a long run and possible extra services.
PYTHONPATH=. uv run pytest --tb=short -quv run pytest backend/tests/unit/orchestration -q
uv run pytest backend/tests/unit/execution -q
uv run pytest backend/tests/unit/inference -quv run ruff check backend launch scripts
uv run mypy --config-file mypy.iniIf a change touches orchestration, run at least one focused orchestration suite and one end-to-end style test path when available. Bugfixes should add a targeted regression test per docs/REGRESSION_TESTS.md; release QA follows docs/RELEASE_CHECKLIST.md.
- Define behavior first in one subsystem (orchestration, execution, inference, etc.).
- Keep interfaces explicit (typed models, clear action/observation boundaries).
- Route state-changing behavior through existing durability and validation paths.
- Add tests for happy path and one realistic failure path.
- Update docs in
docs/when behavior changes user-facing workflows.
- Config impact documented
- Safety impact reviewed
- Tests added/updated
- Docs updated
- No hidden startup dependency introduced
For current architecture and contracts, use docs/ARCHITECTURE.md and docs/ADR.md. The journey under docs/journey/ contains historical narrative — use this document for day-to-day contributor operations.