| 1 | # Architecture |
| 2 | |
| 3 | The-valley separates repository hosting, verification, integration, automation, and project |
| 4 | knowledge into components with explicit contracts. This document explains those choices and the |
| 5 | [requirements](./requirements.md) they serve. Detailed formats and algorithms belong in |
| 6 | [verification](./verification.md) and [integration](./integration.md). |
| 7 | |
| 8 | The repository implements hosting, event projection, local attestations, policy derivation, an |
| 9 | integrator, and an identity compiler. The broader automation, product interface, and trust system |
| 10 | are still being developed. A decision in the graph records an adopted design; it does not establish |
| 11 | that every part has shipped. |
| 12 | |
| 13 | ## Responsibilities |
| 14 | |
| 15 | | Concern | Responsibility | Current implementation or proposed direction | |
| 16 | | ------------------- | --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | |
| 17 | | Hosting | Keep repositories available and recoverable | Bare Git over SSH, publication mirrors, and offsite backup | |
| 18 | | Identity and access | Identify principals and enforce their permissions | A valley registry compiled into boundary-specific files; finer project permissions remain to be implemented | |
| 19 | | Verification | Establish which checks passed over which inputs | Local runners produce signed attestations; Nix is the reference runner | |
| 20 | | Artifacts | Preserve identifiable build results | Nix outputs and caches; retention policy remains open | |
| 21 | | Integration | Apply policy and update protected history | A controller evaluates requests stored as Git refs | |
| 22 | | Automation | Perform and record consequences of changes | Independent controllers; a shared event history is the proposed coordination mechanism | |
| 23 | | Feedback | Make discussion, approvals, and problems accessible | Views over recorded work, with attention routing still to be designed | |
| 24 | | Project knowledge | Preserve requirements, reasoning, and work state | Typed Markdown nodes stored with the code | |
| 25 | |
| 26 | A component can use another component's records without owning its workflow. For example, a build |
| 27 | controller can observe an integrated change without controlling how contributors submit changes. |
| 28 | |
| 29 | ## Events and reconciliation |
| 30 | |
| 31 | Git records repository state. Hooks project ref updates onto the event bus so other components can |
| 32 | observe them. The bus currently uses NATS JetStream. |
| 33 | |
| 34 | The automation design aims to connect a change, its build, its deployment, and its notifications in |
| 35 | one queryable history. Each controller owns its reaction and lifecycle. Adding a reaction should not |
| 36 | require editing every other reaction or a central workflow. |
| 37 | |
| 38 | Events and reconciliation have different jobs. An event can tell a controller that something may |
| 39 | have changed. Reconciliation reads the current authoritative state and decides what remains to be |
| 40 | done. The current integrator polls request refs directly and publishes outcomes; it does not consume |
| 41 | bus events. |
| 42 | |
| 43 | ```mermaid |
| 44 | flowchart LR |
| 45 | contributor["Contributor"] -->|"topic, evidence, request"| git["Git repository"] |
| 46 | git -->|"ref-update projection"| bus["Event bus"] |
| 47 | git -->|"requests and current state"| integrator["Integrator"] |
| 48 | integrator -->|"protected history and evidence"| git |
| 49 | integrator -->|"outcome projection"| bus |
| 50 | bus -.->|"planned authenticated consumers"| reactions["Build, deploy, notify, dispatch"] |
| 51 | ``` |
| 52 | |
| 53 | Current refs can be projected onto a new bus. That reconstructs a view of current state, not every |
| 54 | event that occurred. Deleted branches, overwritten refs, and external effects need their own |
| 55 | retained history. Replaying an effectful reaction also requires rules for avoiding repeated |
| 56 | deployments or notifications. Replay alone does not supply those rules. |
| 57 | |
| 58 | The [signal contract](../.the-valley/decisions/dcr-62ecc36-signal-contracts.md) defines the existing |
| 59 | projection. [Open questions](./openquestions.md#storage-retention-and-evolution) records the |
| 60 | remaining durability requirements. Bus |
| 61 | [authentication](../.the-valley/bugs/bd-d853d9c-bus-unauthenticated.md) and |
| 62 | [service isolation](../.the-valley/bugs/bd-500adf7-bus-shares-git-user.md) must be addressed before |
| 63 | the relevant consumers or wider access are enabled. |
| 64 | |
| 65 | ## Verification during authorship |
| 66 | |
| 67 | A contributor runs the required checks where the change is authored and publishes signed statements |
| 68 | of their results. Each statement identifies the checked tree and the computation or observation |
| 69 | being claimed. The integrator can use this evidence without running every check again. |
| 70 | |
| 71 | This serves the requirement for prompt integration. It also gives a human and an agent the same |
| 72 | submission contract. Both must provide evidence that satisfies policy. |
| 73 | |
| 74 | The trust assumption is explicit: a valid signature establishes who made a claim, not whether that |
| 75 | claim is true. A recognized signer can make a false claim. Independent re-verification, transparency |
| 76 | publication, and trust adjustment are planned ways to detect and respond to that failure. They are |
| 77 | not part of the current local-attestation guarantee. |
| 78 | |
| 79 | This choice trades the delay of verification before every landing for the risk that a false claim |
| 80 | may be discovered after a change lands. Whether that trade is acceptable depends on the project and |
| 81 | the consequences of a bad change. Revocation can restrict future work; recovery from work already |
| 82 | accepted is a separate problem. |
| 83 | |
| 84 | [Verification](./verification.md) defines the evidence and its limits. The |
| 85 | [post-landing recovery risk](../.the-valley/bugs/bd-e63bac8-cascading-revocation-on-divergence.md) |
| 86 | keeps the unresolved consequences visible. |
| 87 | |
| 88 | ## Integration through a controller |
| 89 | |
| 90 | A contributor requests integration by publishing a ref that names a change and its target. A |
| 91 | controller reads the request, evaluates it against governing policy, and updates the protected |
| 92 | branch when it can. |
| 93 | |
| 94 | Using a controller separates submission from the integration decision. A contributor can publish |
| 95 | work before it is ready to land. The controller can report missing evidence, reconsider a request |
| 96 | when the target changes, and retry an operational failure without holding a receive hook open. |
| 97 | |
| 98 | Requests targeting the same protected ref must serialize at the ref update. The integrator checks |
| 99 | whether the proposed delta applies and whether each required check's evidence remains valid for the |
| 100 | resulting tree. It uses a compare-and-swap update so a concurrent change cannot invalidate the |
| 101 | decision unnoticed. |
| 102 | |
| 103 | Evidence can be stale, missing, or invalid. Stale evidence names work that needs refreshing. Invalid |
| 104 | signatures, malformed statements, and incompatible claim types are rejected. These are different |
| 105 | outcomes because they require different responses from a contributor. |
| 106 | |
| 107 | The integrator evaluates and compares evidence; it does not execute checks. That removes check |
| 108 | execution from the serialized integration step. It does not prove adequate throughput or fairness |
| 109 | under contention. The |
| 110 | [starvation risk](../.the-valley/bugs/bd-c324184-occ-starvation-under-contention.md) remains open. |
| 111 | |
| 112 | ### Protected refs |
| 113 | |
| 114 | Only the integrator is intended to write protected refs. Contributors can create attestation refs |
| 115 | but cannot rewrite or delete existing ones through the receive boundary. Complex verification policy |
| 116 | belongs in the integrator. |
| 117 | |
| 118 | The host schema can declare additional protected-ref writers, so deployment must preserve this |
| 119 | restriction. The |
| 120 | [access decision](../.the-valley/decisions/dcr-e544f20-access-is-verbs-on-projects.md) treats |
| 121 | integrator authority as part of the machinery, not a permission to grant to ordinary contributors. |
| 122 | Host root access remains outside this enforcement boundary. |
| 123 | |
| 124 | Today, the remaining ref namespaces are available to callers with push access. The decided |
| 125 | project-scoped `push`, `fetch`, `request`, and `observe` permissions require further enforcement |
| 126 | work. A declaration is not a permission boundary until a component checks it. |
| 127 | |
| 128 | ## Review, approval, and feedback |
| 129 | |
| 130 | A pull request commonly combines four needs: |
| 131 | |
| 132 | | Need | What must be available | |
| 133 | | ------------ | ------------------------------------------------------------ | |
| 134 | | Coordination | Discussion connected to the relevant change or outcome | |
| 135 | | Gating | Evidence and approvals required before integration | |
| 136 | | Record | A durable account of what was decided and why | |
| 137 | | Notification | A way to reach the person or agent whose attention is needed | |
| 138 | |
| 139 | These needs can share records without depending on a single pull-request object. A view can show the |
| 140 | discussion, evidence, approval, and outcome associated with a change. The underlying records remain |
| 141 | accessible to other views and to agents. |
| 142 | |
| 143 | Discussion and approval are distinct. An approval that authorizes a change must be a signed act with |
| 144 | an identifiable subject. The |
| 145 | [core approval decision](../.the-valley/decisions/dcr-9c75283-substrate-adoption-and-the-core.md) |
| 146 | requires physical human approval by default. Policy may exempt ordinary work, such as implementation |
| 147 | under previously approved intent. Changes to policy itself still require physical approval. The |
| 148 | approval mechanism must ship before that requirement is activated. |
| 149 | |
| 150 | The [interface proposal](../.the-valley/ideas/ida-23aa413-project-surfaces-are-derived-views.md) |
| 151 | explores a product interface over these records. Attention routing remains separate: it must decide |
| 152 | what a person needs to see and when, without requiring them to watch every event. |
| 153 | |
| 154 | ## Project knowledge |
| 155 | |
| 156 | The graph stores outcomes, bugs, ideas, and decisions as Markdown files with typed metadata. It |
| 157 | clones, changes, and receives backup with the code. Humans can read it directly, and agents can use |
| 158 | the same files. |
| 159 | |
| 160 | The [graph conventions](../.the-valley/README.md) define the four implemented node types and their |
| 161 | relationships. Earlier proposals also describe discussion, principles, and configuration as nodes. |
| 162 | Those extensions are not in the current schema. In particular, a proposed principle does not become |
| 163 | an enforced requirement merely by appearing in the graph. |
| 164 | |
| 165 | The graph's purpose extends beyond tracking tasks. It preserves the reasons behind decisions so a |
| 166 | later contributor can reconstruct the design and assess a proposed change. Keeping that reasoning |
| 167 | readable matters as much as keeping the metadata valid. |
| 168 | |
| 169 | ## Work from outcomes and dependencies |
| 170 | |
| 171 | An outcome describes something someone wants to exist. Dependencies record what must be resolved |
| 172 | before work on it can finish. |
| 173 | |
| 174 | The scheduling proposal uses this graph to choose work. A requested outcome supplies demand. Its |
| 175 | priority influences the work needed to satisfy it. Open outcomes whose blockers have cleared form |
| 176 | the set available for dispatch. An agent can then work on one of those outcomes and update the |
| 177 | record as it proceeds. |
| 178 | |
| 179 | The current schema supports `blocked_by` and defines when each kind of blocker clears. Priority |
| 180 | propagation, dispatch policy, completion links, and concurrency controls are further design work. |
| 181 | The [outcome proposal](../.the-valley/ideas/ida-eac723e-outcome-dag.md) contains the full reasoning. |
| 182 | |
| 183 | Choosing work and requesting human attention are separate decisions. One asks what can make progress |
| 184 | toward a requested outcome. The other asks which uncertainty or stalled decision needs a person. |
| 185 | Continuing demand also requires limits on retries and total spending; the |
| 186 | [unbounded-work risk](../.the-valley/bugs/bd-5cb2034-unbounded-loops-under-demand-pressure.md) |
| 187 | describes the failure to avoid. |
| 188 | |
| 189 | ## Valleys, projects, and hosts |
| 190 | |
| 191 | A **valley** is a set of people, machines, services, and projects governed together. It has a |
| 192 | repository containing its identity registry and shared policy. A project belongs to one valley and |
| 193 | currently has one Git repository. |
| 194 | |
| 195 | A host provides the machinery serving those repositories. It does not define the valley's policy. |
| 196 | The design allows several valleys on a host while requiring separate access and service state. A |
| 197 | valley spanning several hosts is deferred. |
| 198 | |
| 199 | The-valley supplies common software, schemas, and policy templates. A valley adopts policy by |
| 200 | integrating it into its own repository. An update to supplied templates does not silently change |
| 201 | what a valley has adopted. The small deployed core is the explicit exception described by the |
| 202 | [adoption decision](../.the-valley/decisions/dcr-9c75283-substrate-adoption-and-the-core.md). |
| 203 | |
| 204 | ### Policy and identity |
| 205 | |
| 206 | The valley's shared verification policy is called its **floor**. A project can add requirements and |
| 207 | choose optional defaults; it cannot remove mandatory floor requirements. Required checks come from |
| 208 | every path class touched by the change. |
| 209 | |
| 210 | The integrator reads the floor from the valley's integrated state and the project's policy from the |
| 211 | target branch's integrated state. A proposed policy change is therefore judged under the rules that |
| 212 | precede it. |
| 213 | [Policy composition](../.the-valley/decisions/dcr-f41f718-declared-verification-policy.md) defines |
| 214 | this contract. Supplying trusted implementations of mandated checks remains a |
| 215 | [separate gap](../.the-valley/bugs/bd-eaefe82-check-definitions-come-from-the-branch.md). |
| 216 | |
| 217 | The identity registry declares principals, their keys, and grants. Its compiler produces the files |
| 218 | checked at enforcement boundaries. A human, machine, or service may be recognized by several |
| 219 | valleys, each independently granting authority. |
| 220 | |
| 221 | An agent run acts under delegated authority and has no registry key of its own. Host-signed |
| 222 | provenance attributes the work to the run. Recording a delegation chain does not yet verify that |
| 223 | chain. |
| 224 | |
| 225 | ### Relationships and counts |
| 226 | |
| 227 | These counts describe the adopted model. The remaining work for sharing hosts is recorded in the |
| 228 | [host isolation decision](../.the-valley/decisions/dcr-9b5da04-hosts-serve-isolated-valleys.md). |
| 229 | |
| 230 | | Relationship | Model | |
| 231 | | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- | |
| 232 | | Valley to governing repository | One repository per valley | |
| 233 | | Valley to registry and floor | One registry and one adopted floor; operation under the core alone is decided but not enabled by current tooling | |
| 234 | | Valley to projects | A valley governs several projects; each project has one owning valley | |
| 235 | | Project to stores and policy | One Git store today, with other stores possible; project policy is optional | |
| 236 | | Host to valleys | Several valleys may share a host; one valley across several hosts is deferred | |
| 237 | | Valley to push access | One separate Unix push user per valley on a serving host | |
| 238 | | Principal to valleys | A principal may be recognized independently by several valleys | |
| 239 | | Principal to keys | A principal may have several keys, each with its own lifetime | |
| 240 | | Grant to enforcement | Each grant needs a boundary that checks the permitted action and scope | |
| 241 | | Valley to integrator identity | One integrator principal; several controllers may sign as it | |
| 242 | | Controller to protected history | A controller serves a protected project or target; writes to the same target must be ordered | |
| 243 | | Agent run to authority | The run uses delegated authority and records its provenance; it is not a new registry principal | |
| 244 | | Statement to signatures | Several signatures may cover the same statement text | |
| 245 | | Signing name to verifier key | The name and public key jointly identify a verifier key; one raw key under two names produces two verifier identities | |
| 246 | | Project to mirrors | Zero or more publication mirrors; the schema already permits a list | |
| 247 | | Request to landing | A pending request may land or remain unresolved; a landed request is consumed | |
| 248 | |
| 249 | Valleys sharing a host must not receive one another's credentials or events by default. The bus |
| 250 | could be separated per valley or use authenticated subjects scoped to each valley; that choice is |
| 251 | open. Host administrators retain root access, so independence from an administrator requires a |
| 252 | separate hosting boundary. |
| 253 | |
| 254 | ### Bootstrap and recovery |
| 255 | |
| 256 | Several parts of the system govern their own changes: the registry controls who can amend it, policy |
| 257 | determines how its amendments land, and a host may serve the repository that declares its |
| 258 | configuration. |
| 259 | |
| 260 | Ordinary updates use the previous accepted state to judge the next state. The integrator records the |
| 261 | policy used in its transfer statement. A new rule begins governing subsequent changes after its own |
| 262 | adoption has passed the existing rules. |
| 263 | |
| 264 | The first state is different. It must be established before these mechanisms can enforce it. |
| 265 | Recovery must also remain possible when the mechanism being repaired cannot operate. |
| 266 | |
| 267 | | Governed component | Initial setup | Recovery boundary | |
| 268 | | ------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | |
| 269 | | Registry | Seed recognized principals before enabling compilation | Host administration; recovery after compromise of the initial governing identity remains open | |
| 270 | | Verification policy | Seed the governing repository before its integrator depends on it | Host administration and a recorded recovery procedure | |
| 271 | | Repository access | Supply initial keys until the registry can compile them | Retain the last valid artifacts after a failed compile; reject a render with no unexpired governing key | |
| 272 | | Host configuration | Install the first host manually | Restore from offsite backup and reapply configuration | |
| 273 | |
| 274 | Retaining old compiled credentials has its own cost: a failed convergence can retain a credential |
| 275 | that has since expired. Recovery availability and timely revocation need to be considered together. |
| 276 | |
| 277 | Introducing the integrator's own key is another bootstrap case. The intended anchor is approval by |
| 278 | an already authorized human, rather than relying only on the new key's signature. The complete |
| 279 | approval and recovery procedures remain part of the open |
| 280 | [self-transparency proposal](./self-transparency.md). |
| 281 | |
| 282 | ## Components |
| 283 | |
| 284 | | Component | Role and status | |
| 285 | | ------------------------------- | -------------------------------------------------------------------------------------------------------- | |
| 286 | | Bare Git and SSH | Current repository transport and storage | |
| 287 | | NATS JetStream | Current ref-event projection and inspection | |
| 288 | | Nix | Reference build and verification runner | |
| 289 | | CUE | Shared schemas for hosts, events, nodes, evidence, identity, and policy | |
| 290 | | Integrator | Current request reconciliation and protected-ref updates | |
| 291 | | Tessera-backed transparency log | Proposed external publication and inclusion proofs for Phase 6 | |
| 292 | | Armstrong | Proposed controller for builds and external effects | |
| 293 | | Klaus | Existing agent orchestrator to adapt to valley outcomes and integration | |
| 294 | | Repository and graph interface | Product work proposed in the graph; browsing, editing, and review should use the same underlying records | |
| 295 | |
| 296 | These choices can be revised as the [roadmap](./roadmap.md) tests them. The schemas and observable |
| 297 | contracts are intended to outlast any one implementation. |