This document describes the architectural bets and system model of the-valley.
Like a natural valley that collects mountain streams without forcing their path, the architecture favors natural data flow: content-addressed stores, durable append-only event logs, and decoupled reactive controllers.
bare git (Tailscale) ──┐ ┌──► nix build (pure derivations)
build outputs ───┤ │
agent runs (klaus) ───┼──► event bus ──► subscribers ──► armstrong (effectful reactions)
deploy state ───┤ (NATS JS) │
external signals ──┘ └──► integrator (per-repo integration)
attestations published to a transparency log on every push
Monolithic platforms bundle disparate development concerns into a single hosted environment.
the-valley unbundles these concerns into modular, sovereign primitives:
| Concern | Monolithic Status Quo | The Valley Direction |
|---|---|---|
| Hosting | Centralized web forge; vendor lock-in. | Bare git repositories served over SSH and Tailscale on owned hardware. |
| Identity & Access | Platform accounts, web sessions, RBAC matrices. | Cryptographic SSH keys and declarative CUE identity registries. |
| Verification | Slow, brittle YAML CI pipelines on remote runners. | Hermetic local Nix derivations generating signed attestations in seconds. |
| Artifacts | Ephemeral, proprietary CI artifact stores. | Content-addressed, reproducible Nix derivations stored in binary caches. |
| Automation | Push-based webhooks and monolithic workflow files. | Independent reactive controllers subscribing to a durable NATS event log. |
| Integration | Monolithic web UI merge buttons and branch protections. | Pull-based integrator controllers evaluating cryptographic evidence. |
| Feedback & Review | Rigid PR pages conflating chat, gating, and record. | Continuous event streams, derived discussion threads, and attention routing. |
| Project Knowledge | Fragmented across issues, wikis, and chat channels. | A typed markdown graph (.the-valley/) versioned directly in the repository. |
Serves: Automation and Observability.
Traditional CI/CD systems rely on push-based pipelines: an external event fires, an ephemeral runner executes a procedural script, and the only persistent record is an unstructured text log.
the-valley uses an event-sourced architecture:
commit -> check -> deploy -> notification is
preserved as a queryable causal chain rather than scattered across dashboard tabs.Serves: Instant Verification and Agent Autonomy.
Instead of forcing code to wait in a queue for remote CI machines to re-run identical builds, verification runs locally where the work is authored (on the developer's workstation or agent sandbox).
When checks pass, the authoring environment signs a structured attestation containing the tree digest, the check definition, and the result. The integrator checks the attestation signature and merges immediately. Background re-verifiers cross-check attestations asynchronously. If an attestation is ever found to diverge, trust in the signer is revoked.
This trades two failure modes:
Serves: Integration Reliability and Uniform Failure Semantics.
Rather than blocking git pushes synchronously with a complex pre-receive script, the-valley uses
a pull-based integrator controller:
refs/the-valley/integration-requests/<target>/<change>.The bare git repository enforces only one structural invariant: only the integrator's key may write to protected branches, and attestation refs are create-only. All complex merge policies live in the integrator process.
Serves: Human-Agent Collaboration and Attention Management.
The traditional "pull request" conflates four distinct functions:
the-valley unbundles these functions:
Serves: Shared Memory for Humans and AI Agents.
All project knowledge—outcomes, decisions, bug reports, ideas, and principles—lives inside the
repository under .the-valley/ as markdown files with structured YAML frontmatter.
grep, and git log.Serves: The Autonomous Outcome Engine.
Knowledge nodes define explicit dependency relationships (blocked_by). By treating outcomes
(declarations of desired future state) as the primary units of work:
klaus) are automatically dispatched against frontier nodes to implement
changes and submit integration requests.erDiagram
valley ||--|| valley-repository : "sovereign home"
valley-repository ||--|| identity-registry : holds
valley-repository ||--|| valley-floor : holds
valley-repository ||--o| host-declaration : holds
identity-registry ||--|{ principal : declares
principal ||--|{ key : holds
principal ||--o{ grant : carries
grant }|--|| enforcement-boundary : "checked at"
principal ||..o{ agent-run : "delegates to"
flowchart TD
substrate["substrate: schema, module, floor"]
valley["valley: one repository, one floor, one registry"]
project["project: one git repository"]
policy["project policy"]
host["host"]
controller["integrator controller: a process, not an identity"]
principal["integrator principal"]
bus["bus: NATS JetStream"]
backup["offsite backup"]
substrate -->|"floor mandates over, 1 : N"| valley
valley -->|"owns and governs, 1 : N"| project
valley -->|"declares, 1 : 1"| principal
project -->|"carries, 1 : 1"| policy
host -->|"serves, N : M"| valley
host -->|"runs one per protected project, 1 : N"| controller
host -->|"backed up, periodic"| backup
controller -->|"writes protected refs of, 1 : 1"| project
controller -->|"signs as"| principal
Because system policies, identity registries, and host definitions are stored in repositories
governed by the-valley, the system unrolls bootstrap cycles as an induction over git history:
flowchart LR
genesis["Genesis Commit\n(Created manually)"] -->|"Judged by genesis rules"| tipN["Tip N\n(Active Policy)"]
tipN -->|"Judged by policy at Tip N"| tipNext["Tip N+1\n(New Policy)"]
tipNext -->|"Judged by policy at Tip N+1"| onward["..."]
classic-laddie).nix flake check) and signed attestations.klaus for headless multi-agent runs in isolated git worktrees.