How talibilat/zentra works
Purpose and entry points
Zentra is a local-first TypeScript orchestration kernel for bounded software-development tasks against configured Git projects. It owns lifecycle, durable evidence, recovery, isolated worktrees, validation, review, and serialized integration; projects retain source, commands, and policy. CLI entry point: src/cli/main.ts; public library surface: src/index.ts. Primary commands include deterministic task run, installed milestone run, configuration validation, status, recovery, and capsule conformance.
Durable domain model and state
Append-only SQLite events are the system of record; projections rebuild task/milestone state and support read-only recovery classification. Contracts define typed identities, task/milestone state, artifacts, authority, costs, and uncertain effects. Core paths: src/journal/sqlite-journal.ts, src/journal/projecting-journal.ts, src/contracts/event.ts, src/tasks/task-projection.ts, src/milestones/milestone-projection.ts. Agent Tail is a non-authoritative JSONL projection for live/saved observability: src/observability/agent-tail-file-sink.ts.
Milestone admission, policy, and replanning
Milestone registration binds plan, security/model policy, ownership, budgets, capabilities, and stop conditions before execution. Admission is fail-closed and records readiness or durable attention; plan replacement/revision is constrained by identity, evidence, and execution state. Core paths: src/milestones/milestone-registry.ts, src/milestones/plan-readiness.ts, src/milestones/path-ownership.ts, src/policy/model-sheet.ts, src/policy/security-sheet.ts.
Orchestration workflow
The installed workflow is fixed planner → researcher → host OpenCode writer → independent reviewer → validation → disposable candidate integration. Schedulers coordinate one bounded local workflow, resource governors constrain writer execution, and recovery refuses automatic retries after uncertain effects. Core paths: src/orchestration/multi-agent-milestone.ts, src/orchestration/multi-writer-scheduler.ts, src/orchestration/writer-worktree-capsule.ts, src/orchestration/recovery.ts, src/reviews/review-gate.ts. The deterministic tracer-bullet path remains a separate conformance workflow: src/orchestration/tracer-bullet.ts.
Workspace, validation, and integration boundaries
Each writer receives an isolated Git worktree with owned-file restrictions. Validations execute configured direct argument arrays under bounded timeouts; successful work is reviewed and integrated through serialized branch preparation/queue/lease control. Important paths: src/workspaces/worktree-manager.ts, src/workspaces/git-client.ts, src/capabilities/validation-runner.ts, src/integration/integration-queue.ts, src/orchestration/integration-branch-preparation.ts. Git mutations are guarded by canonical repository identity and durable intent/effect evidence.
Agents, capsules, and model transport
Read-only planner/researcher/reviewer roles run attested OpenCode in short-lived Docker capsules over sanitized repository views; model turns cross to a trusted host broker. The writer instead runs the operator-attested OpenCode executable on the host with minimal environment and explicit worktree authority. Core paths: src/agents/opencode-read-only-program.ts, src/capsule/docker-capsule.ts, src/capsule/opencode-read-only-capsule.ts, src/providers/azure-openai-model-broker.ts, src/agents/opencode-worker-event-adapter.ts. Azure OpenAI is the supported provider, with strict endpoint/DNS/TLS/SSE/budget controls; Docker and Git are material runtime dependencies.
External-effect and release boundaries
GitHub operations are brokered, grant-bound, serialized, and always treated as uncertain until separate reconciliation; credentials stay in host environment boundaries. Local release preparation is optional, runs trusted project commands in an exact-commit worktree, and stops before remote release actions. Core paths: src/capsule/github-broker.ts, src/integration/integration-lease.ts, src/release/local-release-coordinator.ts, src/release/local-release-runner.ts. The MVP supports one user and one local machine, specifically macOS arm64 with Node 24–26; it is not a distributed, multi-tenant, or hostile-repository sandbox.
Main entry points: multi-agent-milestone.ts Installed milestone workflow · milestone-registry.ts Milestone admission · projecting-journal.ts Projecting journal · sqlite-journal.ts SQLite event journal
Components 25
Entry Surfaces
- CLI commands · Run, recovery, status, configuration, and conformance commands.
src/cli/main.ts - Public library
src/index.ts
Durable State & Policy
- SQLite event journal · Append-only system of record for durable facts and effects.
src/journal/sqlite-journal.ts - Projecting journal
src/journal/projecting-journal.ts - Task projection
src/tasks/task-projection.ts - Milestone projection
src/milestones/milestone-projection.ts - Agent Tail · Non-authoritative live and saved agent-event projection.
src/observability/agent-tail-file-sink.ts - Milestone admission · Binds plans, budgets, capabilities, ownership, and stop conditions.
src/milestones/milestone-registry.ts - Plan readiness · Fail-closed readiness and durable-attention decisions.
src/milestones/plan-readiness.ts - Path ownership
src/milestones/path-ownership.ts - Security & model policy
src/policy/security-sheet.ts
Orchestration
- Installed milestone workflow · Fixed planner → researcher → writer → reviewer → validation → candidate integration flow.
src/orchestration/multi-agent-milestone.ts - Writer scheduler · Coordinates one bounded local writer workflow.
src/orchestration/multi-writer-scheduler.ts - Recovery controller · Refuses automatic retry after uncertain effects.
src/orchestration/recovery.ts - Tracer-bullet workflow · Separate deterministic task-run path.
src/orchestration/tracer-bullet.ts - Host writer capsule · Operator-attested OpenCode with minimal environment and explicit authority.
src/orchestration/writer-worktree-capsule.ts - Review gate
src/reviews/review-gate.ts
Execution Boundaries
- Read-only OpenCode roles · Attested roles operating over sanitized repository views.
src/agents/opencode-read-only-program.ts - Docker read-only capsules
src/capsule/opencode-read-only-capsule.ts - Azure OpenAI broker · Enforces endpoint, DNS, TLS, SSE, and budget controls.
src/providers/azure-openai-model-broker.ts - Git worktree manager · Creates isolated worktrees and enforces owned-file restrictions.
src/workspaces/worktree-manager.ts - Validation runner · Runs configured direct argument arrays with bounded timeouts.
src/capabilities/validation-runner.ts
Integration & Release
- Integration queue & lease · Prepares candidate branches and controls serialized integration authority.
src/integration/integration-queue.ts - GitHub broker · Grant-bound operations remain uncertain until reconciled.
src/capsule/github-broker.ts - Local release coordinator · Runs trusted commands in an exact-commit worktree; stops before remote release.
src/release/local-release-coordinator.ts
Connections 27
- CLI commands → Milestone admission: registers and admits
- Public library → Installed milestone workflow: exposes
- Milestone admission → Plan readiness: checks
- Milestone admission → Path ownership: binds
- Milestone admission → Security & model policy: applies
- Milestone admission → SQLite event journal: records admission
- SQLite event journal → Projecting journal: projects events
- Projecting journal → Task projection: builds
- Projecting journal → Milestone projection: builds
- Projecting journal → Agent Tail: publishes
- CLI commands → Installed milestone workflow: runs milestone
- CLI commands → Tracer-bullet workflow: runs deterministic task
- Installed milestone workflow → Writer scheduler: coordinates
- Installed milestone workflow → Read-only OpenCode roles: plans, researches, reviews
- Read-only OpenCode roles → Docker read-only capsules: runs in
- Docker read-only capsules → Azure OpenAI broker: model turns
- Writer scheduler → Host writer capsule: authorizes writer
- Host writer capsule → Git worktree manager: writes isolated workspace
- Git worktree manager → Validation runner: validates candidate
- Validation runner → Review gate: successful candidate
- Review gate → Integration queue & lease: approved candidate
- Integration queue & lease → GitHub broker: brokers GitHub effects
- Integration queue & lease → Local release coordinator: exact commit
- Recovery controller → Milestone projection: classifies state
- Recovery controller → SQLite event journal: inspects effects
- Installed milestone workflow → Recovery controller: uncertain effects
- Installed milestone workflow → SQLite event journal: records lifecycle