gunk-dev/the-valley

scenarios.md

sourcee1a293f6bde4main's published tip history
9.5 KiB · Rendered
1# Scenarios
2
3End-to-end walk-throughs of how the architecture handles real situations. Forces the design to be
4honest, and surfaces gaps that the abstract docs miss. These are solution-space — architecture
5walk-throughs in event notation; the problem-space counterpart, what a user needs with no
6mechanisms, is [user-scenarios.md](./user-scenarios.md).
7
8Conventions used in the flows below:
9
10- `▶` is a contributor or external actor doing something.
11- `→` is an event landing on the bus.
12- `↺` is a controller reacting to an event.
13- `✓` / `✗` is an integration outcome.
14
15---
16
17## 1. Solo dev: edit → integrate → deploy
18
19The everyday case. A human edits code, runs local checks, and ships a change.
20
21```
22▶ edit, save
23▶ git push --integrate topic/x (atomic: refs/heads/topic/x + refs/attestations/<sha>)
24 → ref-updated topic/x, <sha>
25 → integration-requested { repo, branch=topic/x, target=main, attestations=[A1, A2] }
26↺ integrator verify signature, attestation contents, signer trust score
27↺ integrator topic/x merges cleanly into main, fast-forward
28✓ → integration-succeeded { commit=<sha>, target=main }
29↺ deploy controller build artifact derivation D from <sha>
30 → derivation-built { commit, D, hash }
31↺ deploy controller deploy D to staging
32 → deployed { commit, env=staging, D }
33↺ witness re-derive A1's pure check
34 → attestation-confirmed { commit, attestation=A1 }
35↺ trust controller bump signer's confirm rate
36```
37
38**Stress points:**
39
40- Whether the integrator waits for witness confirmation before integrating is policy, not
41 architecture — but the policy needs to exist (trusted signer: probably not; new signer: probably
42 yes).
43- The "local checks are sufficient" assumption is load-bearing. Environment drift from canonical
44 surfaces as witness rejections and trust-score drift; the system should make that debuggable.
45
46---
47
48## 2. klaus-style agent change
49
50An agent dispatched by klaus does the work. Same flow as a human, but identity and trust live in
51different places.
52
53```
54▶ klaus launch "fix the auth bug ..."
55 → agent-dispatched { run_id, repo, prompt, agent_key=<key> }
56↺ agent (in worktree) edits, runs local checks, signs attestation with agent_key
57▶ agent push --integrate
58 → integration-requested { repo, branch, attestations, signer=agent_key }
59↺ integrator verify signature, look up agent_key trust policy
60↺ integrator policy says "agent changes auto-integrate if attestations re-derive cleanly OR a witness pre-confirms"
61↺ integrator either: (a) wait for witness confirm event, or (b) integrate now and accept the risk
62✓ → integration-succeeded ...
63```
64
65**Stress points:**
66
67- **Agent identity is unresolved.** Ephemeral per-run key, long-lived per-agent key, or delegated
68 from the dispatching human — the architecture supports any; the trust controller cares only about
69 confirm/deny rates per signer.
70- **The "PR" concept dissolves.** What klaus today calls "PR created" is just
71 `integration-requested` with the agent as signer.
72- **Agent loops.** An agent reacting to a regression event (Scenario 3) dispatches another agent
73 run; the architecture needs a cap (klaus's existing run-budget mechanism extends naturally).
74
75---
76
77## 3. Post-deploy regression
78
79A change makes it to production. Some time later, runtime signals indicate something is wrong. The
80system closes the loop back to the change.
81
82```
83↺ monitoring error rate on /api/foo crosses threshold
84 → regression-suspected { service, indicator, severity, observed_at, attributed_commits=[<sha-1>, <sha-2>, <sha-3>] }
85↺ rollback controller policy: severity >= P1 AND attributed deploy < 30min ago
86↺ rollback controller revert to previous artifact
87 → deployed { commit=<previous-sha>, env=prod, reason=rollback, evidence=regression-suspected }
88↺ thread router open/update threads for each attributed commit
89 → thread-event { thread, kind=regression-attributed, evidence }
90↺ priority router thread now has high-severity event; promote to human attention
91↺ agent dispatcher spawn klaus run: "investigate regression Z, propose fix"
92 → agent-dispatched ...
93```
94
95**Stress points:**
96
97- **Attribution.** Monitoring rarely _knows_ which commit caused a regression; `attributed_commits`
98 is a lead with a confidence, not a verdict.
99- **Auto-rollback vs human-in-the-loop** is per-environment policy — but the policy must be
100 expressible and observable, with the controller emitting its reasoning as events.
101- **Trust implications.** A regression alone doesn't lower a signer's trust score (regressions ≠
102 forgery); a _correlation_ of regressions per signer is a separate signal, surfaced to humans
103 rather than auto-acted.
104
105---
106
107## 4. Untrusted contributor
108
109A new contributor wants to land a change. They have no attestation history, so the trust controller
110has no signal on them.
111
112```
113▶ alice (new) git push --integrate topic/welcome-fix
114 → integration-requested { signer=alice, attestations, ... }
115↺ integrator alice has no trust score, policy says "do not auto-integrate"
116↺ integrator create a thread, surface the request as needing review
117 → thread-event { thread, kind=integration-pending, signer=alice }
118↺ priority router surfaces thread to maintainer attention
119▶ maintainer reviews diff in the thread view
120▶ maintainer approves (signed approval event)
121 → approval { thread, by=maintainer, target=alice's integration-request }
122↺ integrator sees approval from someone with integration-approval authority; integrates
123✓ → integration-succeeded { signer=alice, approved_by=maintainer }
124↺ trust controller alice now has 1 successful integration co-signed by a trusted party
125 (policy: after N co-signed integrations, alice's attestations can auto-integrate)
126```
127
128**Stress points:**
129
130- **The trust state machine.** "Co-signed by trusted party" → "trusted enough to auto-integrate" is
131 a discrete transition needing concrete policy: how many, which changes count, does trust decay.
132- **Threads subsume the PR.** Request, diff, attestations, comments, approval, and outcome are one
133 chronology in one thread.
134- **Approval authority.** The maintainer's key being on a known list is itself policy needing
135 versioning, audit, and grant/revoke.
136
137---
138
139## 5. Cross-repo schema change (sketch)
140
141armstrong's CUE schema changes. Multiple downstream repos depend on it.
142
143```
144✓ integration-succeeded { repo=armstrong, schema-updated=yes, prev_hash, new_hash }
145↺ schema-watcher (in each consumer repo) notices a dependency's schema changed
146↺ schema-watcher runs validation: does my current usage compile against the new schema?
147 → schema-compatibility { consumer, schema, status=ok|broken }
148↺ schema-rollout coordinator (if present) aggregates compatibility events
149↺ schema-rollout coordinator if all known consumers ok: cut a versioned release of the schema
150↺ schema-rollout coordinator if some broken: open threads in those repos with a fix-suggestion
151```
152
153**Stress points:**
154
155- Tests that events flow across repo boundaries on the same bus, with per-repo controllers consuming
156 cross-repo events.
157- How a consumer _declares_ interest in another repo's events is open — probably explicit config;
158 implicit discovery is too magical.
159
160---
161
162## 6. Scheduled task (sketch)
163
164A weekly dependency bump.
165
166```
167↺ time source weekly tick
168 → scheduled-tick { name="weekly-deps", at=... }
169↺ dep-updater controller runs `nix flake update` in worktrees for repos it watches
170↺ dep-updater controller for each repo: generate change, sign attestation, push, request integration
171 → integration-requested { signer=dep-updater, ... }
172```
173
174**Stress points:**
175
176- From the integrator's perspective, indistinguishable from a human or agent contribution; the
177 dep-updater has its own key and trust score.
178- Time is just another event source — no "scheduled workflows" subsystem, only a controller emitting
179 `scheduled-tick` events.
180
181---
182
183## What these scenarios collectively prove (or fail to prove)
184
185| Architectural claim | Tested by | Result |
186| -------------------------------------------- | --------- | ------------------------------------------------------------------------- |
187| Local attestations replace CI gates | 1, 2 | Works if reproducibility policy holds and witnesses are present |
188| Integrator pattern handles real cases | 1, 2, 4 | Works; policy variation per-signer is essential |
189| Feedback closes the loop post-merge | 3 | Works; attribution is the weakest link |
190| Threads subsume PR review | 4 | Works; the "approval has authority" claim needs concrete policy mechanism |
191| Cross-repo flows on one bus | 5 | Plausible; subscription/discovery is unsolved |
192| Time integrates as just another event source | 6 | Clean fit |
193| Agents are first-class contributors | 2 | Architecturally yes; agent identity model unresolved |
194
195## What's still uncovered
196
197- **Forensic walk-back.** Replaying the log to debug "why did this happen?" The architecture
198 promises it works; nothing here exercises it as a workflow.
199- **Multi-author / stacked changes.** A chain of dependent commits with multiple signers.
200- **Recovery from bus loss.** Per-repo request refs in git provide some durability for in-flight
201 integrations, but a deeper story is needed.