oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1# Equipo housekeeping: a tidying loop that stays under control
2
3Status: design for Paul's review, 2026-11-08, revision 3 after Astra's
4rounds 1 and 2 (NOT READY at cc6ca41; READY AFTER FIXES at f94fad0). Drafted by Claude (Fable 5.1) on
5`design-housekeeping` from `thin-v1-conn1` (7946111). Builds on thin v1
6(`2026-11-06-equipo-thin-v1.md`), Connections rev 3
7(`2026-11-08-equipo-connections.md`, §§3, 4, 6) and the progress logs
8for slices 2b, 3, 4, 4c, CONN1 and UX1. Paul's rulings of 2026-11-08
9are folded in (§9). Not implemented.
10
11## 0. Why, and the shape of the answer
12
13Paul, on the duplicate tasks the coordinator kept filing: "Can Equipo
14itself tidy up the duplicates? This is where I guess we need to start
15thinking about loops where it pro-actively tries to keep everything tidy
16and to spot things to improve (whilst not going out of control)." And
17later: the loop is the basis of continual improvement that Equipo should
18suggest and manage "across the whole business / organisation / family".
19
20Equipo already has the pieces of a loop without the loop. Move-in and
21explore turns run with no person message and only read and note tools.
22The notebook holds what the coordinator has learned. The runner checks
23reach every minute and watches merged branches. The merge policy is
24deterministic and runs in `advance`. Duplicate detection is being built
25on `thin-v1-ux1`: same-creator, high-similarity pairs are combined with
26an Undo receipt (`Task.folded`, `CardCombined`,
27`POST /tasks/{id}/uncombine`); weaker matches get a "Possible duplicate
28of" link. The mutation ledger makes writes idempotent across attempts.
29Usage records every attempt.
30
31Housekeeping is the rule that joins them: **deterministic detectors
32notice things; a policy table says what each class of thing may become;
33a reserved budget, a ledger with a state machine and one Pause switch
34keep it bounded; everything it does leaves a receipt with Undo; and
35anything that depends on a model's judgement becomes a suggestion, never
36an action, until a person taps.** No setup: the loop is on from the
37first message, with defaults, and the only control a person needs is
38Pause.
39
40Two invariants hold everywhere below and are tested as such. **No
41forbidden effect is reachable**: every write the loop makes goes through
42the shared store functions under a server-derived housekeeping principal
43that checks current membership and the owner of every affected resource
44inside the transaction. **Model judgement is never an action**: a model
45may shape the words of a suggestion and nothing else.
46
47## 1. Scope: teams, subjects, who sees what
48
49Everything in this spec belongs to a **team**: the roster that shares a
50conversation server today, which in time may be a business, an
51organisation or a family. Within a team, every finding, action and
52suggestion has a **subject**: `{kind, id}` where kind is `task`,
53`project`, `connection`, `notebook_entry`, `person` (a person's own area)
54or `team`. The subject decides authority and visibility by one rule:
55**a subject owned by one person is that person's business; a subject
56owned by the team is everyone's to see and the owner's to act on.**
57
58A task's subject owner is its creator ("only a task's creator acts on
59it" stands, and it applies to the *destination* of a fold as well as the
60source). A connection's owner is its person. A notebook entry's owner is
61the coordinator's person. A project and the team itself are team
62subjects. The loop runs **per person**: each person's coordinator keeps
63that person's own subjects tidy, draws on that person's connections and
64budget, and posts receipts into that person's conversation. Team
65subjects produce suggestions visible to the whole roster and nothing
66more until slice 4, which adds acting on team subjects by the owner. A
67person sees a suggestion if its audience is them or the team; a person
68may accept a suggestion if they could create the task it describes (any
69member for team subjects, the owner for personal ones); dismissing is
70per person for team suggestions and final for personal ones.
71
72**The housekeeping principal.** Every loop write runs as
73`housekeeping{team, person, detector, finding_id}`, built by the
74instance from the ledger row, never from a frame or a tool argument. It
75is passed into the same store functions a person's request uses
76(`foldTask`, `retryStep`, `recordSuggestion`), and those functions
77check, inside the write transaction: the person is a current member; for
78every task touched, including a fold's destination and any task a
79suggestion is linked to, the creator is the principal's person; for a
80notebook entry, its person; for a team subject, that the class permits
81it (propose only before slice 4). A principal that fails any check gets
82`housekeeping_forbidden`, the ledger row becomes `refused`, and nothing
83else in the transaction survives. Handlers are not the only gate: the
84detectors run inside `advance`, so the gate is in the store.
85
86## 2. Detectors: a registry of small declared units
87
88A **detector** is a declared, data-driven unit in a registry
89(`internal/equipo/housekeeping`), never free code in a handler. Each
90declares: `id`; subject kind; `class` (§3); `triggers` (event types from
91the stream, plus `sweep`); `judgement` (`none` or `model`); `rate` (at
92most N findings per subject and per team per period); and `Detect`, a
93pure function from a read-only view of the store to zero or more
94**findings** `{detector, subject, subject_revision, key, evidence,
95proposal}`. The key is the finding's identity (`duplicate:tkA:tkB`,
96`retry:tkA:chain2`); the ledger (§4) decides whether it may act.
97Evidence is structured fields the receipt and the page render, never
98model prose. A detector with `judgement: model` may only have class
99Propose: the registry refuses any other combination at start-up
100(`TestRegistryModelMeansPropose`). Adding a detector is a registry entry
101and a fixture; nothing else changes, which is what lets the non-code
102detectors of §8 arrive later.
103
104| Detector | Fires on | Class | Judgement |
105|---|---|---|---|
106| `duplicate_same_creator` | `record_task` (or the sweep) where two of one creator's open tasks in the same project overlap at or above 0.75 with three shared title words, or 0.7 with five across title and brief (UX1's thresholds as shipped; kept by the controller 2026-11-08), both tasks owned by that creator and checked again in the transaction. The one furthest along is kept (stage, then not stopped, then the older); the other closes. Only a pending decision on the task that closes (an open card other than its task card) or a step at work on it blocks the combine; an open card on the task kept, a merge card included, does not, and stays open on it (coordinator's ruling 2026-11-11, on Paul's "combine automatically with Undo": staging's Woodstar pair keeps `tkf6dufnbzcg` at Ready to merge and closes the stopped `tks6kwzzdngr`) | Act and tell: combine, receipt with Undo (built on `thin-v1-ux1`) | none |
107| `duplicate_possible` | overlap at or above 0.6 with two shared title words, or 0.5 with three across title and brief, or any such overlap across creators | Link only: "Possible duplicate of" on the new task, `Task.duplicate_of` as UX1 | none |
108| `retry_transient` | a step that **never pushed a candidate** stopped with `runner_restarted`, `interrupted`, `provider_failed`, `clone_failed`, `candidate_unavailable`, `checks_timeout` or `no_runner`, termination proven, no earlier automatic retry in this failure chain | Act and tell: one retry per chain, Undo until the retried step starts (slice 2) | none |
109| `ready_waiting` | a task at Ready to merge with an open card or no card for over 24 h | Digest mention only, never a new card | none |
110| `branch_gone` | the merge watch finds the task branch deleted on the forge without a merge | Needs you `branch_moved`, as today; digest line | none |
111| `stale_project` | no task, message or push in 60 days | Propose: "Archive <project>?" (team subject, slice 4) | none |
112| `flaky_check` | the same gate fails then passes on the same SHA (a Retry of checks), twice in 30 days | Propose, with both tails as evidence | model, slice 3, to name the test |
113| `findings_unaddressed` | Review findings on a merged task naming files the fix rounds never touched | Propose | model |
114| `notebook_stale` | an entry whose `repo` source file changed since it was written, or an `own` entry older than 90 days | Propose: "This note may be out of date" with a one-tap Mark stale | model for "contradicted", words only |
115| `repo_reach` | hello catalog gains or loses a repository | Digest line; a lost repository with open tasks: the existing access card | none |
116| `connection_health` | `limited` with a reset over 48 h away, `sign_in_again`, a key expiring within 7 days | The existing Needs you once; digest line otherwise | none |
117| `improvement_noticed` | a specialist calls `note_improvement{text, repo, path}` during a step | Propose: one suggestion per note | model, to merge near-identical notes |
118
119`notebook_stale` never hides an entry on its own; the tap does, as a
120person's action with the ordinary Undo. Cross-creator duplicates are
121links in every slice of this spec. Thresholds are constants beside the
122detector and appear in its fixture; the similarity function is
123`record_task`'s.
124
125## 3. Action classes and the policy table
126
127Four classes, named in the registry, enforced in the store under the
128principal of §1, never by detector code or a model.
129
130**Act and tell.** Deterministic only, within the person's own subjects,
131no model spend, undoable for seven days or until a later change makes
132the undo impossible (409 with the reason, as the home card's Undo). The
133action, its receipt card and its `housekeeping` event are written in one
134transaction with the ledger transition (§4); the card appears on the
135Housekeeping view at once and in the conversation at its `visible_at`
136(§4, quiet hours). Undo restores the prior state through the same store
137functions a person's Undo uses (`uncombine`, which restores the folded
138task and its thread exactly and removes the fold from the destination)
139and moves the ledger row to `undone`, a retained veto.
140
141**Automatic retry, its Undo and its fencing** (slice 2). The action is
142the ordinary `RetryTask` path under the principal, so it does what a
143person's Retry does: the step goes `queued`, `attempt` becomes n+1, and
144`reason`, `pushed`, `terminated`, `summary`, `headline`, `log_tail`,
145`activity`, `started_at`, `finished_at` are cleared; for Engineering
146without a republish `candidate_sha` and `from_attempt` are cleared too;
147the task's `stage` returns to `in_progress` and its `needs_you` is
148recomputed. The ledger row's `result` therefore stores the **complete
149snapshot** of every one of those fields, on the step and on the task,
150plus both revisions, before the call. Undo is offered only while the
151retried step is still `queued` on the instance and no `step{running,
152attempt: n+1}` report has been accepted. Undo writes, in one
153transaction: a durable `cancel_step` for attempt n+1; the snapshot's
154fields back onto the step and task; and `undone_attempt = n+1` on the
155step. **Attempts never go backwards**: the step keeps `attempt` n+1 and
156the snapshot's `state`, `reason` and Needs you, so a later report for
157attempt n+1 is accepted only if it is the termination (the instance
158already drops reports for attempts below the current one; this adds
159dropping non-terminal reports for an `undone_attempt`). A person's Retry
160after an Undo gives attempt n+2 as usual. If a `running` report for n+1
161commits first, the Undo gets 409 with the current action and the person
162is pointed at the ordinary Cancel. Nothing about merge eligibility is
163special here: the retried task earns `merge_eligible`, `ready_sha` and
164its cards through the slice 4c policy as any task does; what housekeeping
165may never do is write those fields or a merge card directly, and the
166principal's store functions refuse those writes.
167
168**Propose.** Creates a **suggestion** (§5), never a task, and writes to
169no other resource. De-duplication against tasks records
170`Suggestion.related_task` on the suggestion; it never appends to the
171task. Costs nothing unless `judgement: model`, in which case one
172reserved housekeeping turn.
173
174**Ask once.** Shared, irreversible or costly; a Needs you card asked
175once per key, answered by the subject's owner only. In this spec it is
176used only by `stale_project` in slice 4. Automatic retries of pushed
177work are not asked: the existing Needs you `retry` card already covers
178them and is unchanged.
179
180**Never.** Delete tasks, projects, branches, notes or usage rows; merge,
181or alter `merge_eligible`, `merge_asked`, an open merge card or the
182checks-exception decision (combining another task into one with an open
183merge card is allowed and leaves that card, its SHA and its answer
184exactly as they were; closing a task that has a decision still open is
185not); touch another person's task or notebook,
186including as a fold's destination; create or start a task from a
187suggestion without a tap; dispatch past the reservation or on a
188connection that is `limited` or of unknown tier; post more than receipts
189and one digest line a day; change a setting. Refused in the store, a
190`refused` ledger row, shown on the view.
191
192| Class | Needs | Costs | Reversal | Tells the person |
193|---|---|---|---|---|
194| Act and tell | own subject, deterministic, reversible | 0, or one reserved step (retry) | Undo, 7 days (retry: until the step starts) | receipt card, digest |
195| Propose | any subject | 0 or one reserved turn | dismiss | Suggestions lane, digest |
196| Ask once | shared or irreversible, owner answers | 0 | the answer | one Needs you card |
197| Never | | | | refused, on the view |
198
199## 4. Control
200
201**Budget by reservation.** Per person per day (Paul's ruling): 4
202judgement turns, 150,000 tokens and 3 automatic retries. A ledger row
203that will spend holds a **reservation** written in its `claimed`
204transaction: the claim sums today's reserved and charged figures for the
205person and refuses the claim (`held`, §4 ledger) if the new reservation
206would exceed any limit, so two concurrent claims cannot both pass. A
207judgement turn reserves one turn and its share of the day's tokens,
208150,000 / 4 = 37,500, so all four turns fit (Paul, 2026-11-08; the
209token budget stays the binding total). A retry reserves one
210retry and 100,000 tokens, covering the retried Engineering step and the
211review and checks that follow it, and an execution cap: the retried step
212runs under the ordinary `step_timeout`, at most the ordinary two fix
213rounds, and every step it causes carries `caused_by: <action_id>` on
214dispatch and on its usage rows. If today's remaining tokens are below a
215reservation, the claim is `held`.
216
217**One cap across attempts.** Every frame the reservation pays for
218carries `max_tokens` = reserved minus charged so far, so a failover or
219a second attempt inherits the remainder, never a fresh cap; below a
220floor of 5,000 the turn or step ends `failed` with reason `budget`, and
221the harness's own limit enforces the figure. Usage rows are charged to
222the action as each attempt's row arrives; when a step overruns its
223share, the overrun is charged and the day's remaining tokens shrink by
224it (person turns are never budgeted, so nothing of theirs is taken).
225
226**Release only after reconciling.** A reservation is released only when
227the attempt's termination proof has arrived **and** its usage has been
228charged: the row's figure when `complete: true`, the harness's partial
229figures when `complete: false`, and the **whole reservation** when no
230figure came at all (unknown is charged in full, never zero). Until then
231the row is `releasing` and still counts against the day. Yield, Pause
232and cancel all go through this path.
233
234**Stand-down.** Housekeeping dispatches nothing that spends when any
235limit is reached, and the headroom test applies to the **connection the
236choice function actually selected**, never to the fleet: the selected
237pair's headroom must be reported, checked within the last fifteen
238minutes (`checked_at`, re-probed if older by the §2.7 probe of
239Connections), and below 0.8 utilization; otherwise the claim is `held`
240and no other connection is tried in its place. Unknown headroom means
241stand down, not proceed. Deterministic actions that spend nothing
242(combine, digest lines) carry on. The digest says "Housekeeping stood
243down: today's budget is used" or "... Claude is near its limit".
244
245**Tier at selection.** A housekeeping turn asks the choice function for
246role `housekeeping` with a **tier ceiling** of `cheap`: pairs above the
247ceiling are filtered out before stickiness or preference apply, and if
248none remains the turn is `held`. Tiers come from Connections slice 3;
249until that lands, no pair has a tier, so judgement turns do not run and
250slice 3 of this spec waits on it.
251
252**Person turns pre-empt**, in three places. In the queue: `dispatchNext`
253takes person turns first, then move-in and explore, then housekeeping.
254On yield: a person's message cancels a running housekeeping turn as it
255does a move-in (`yielded`), its reservation goes to `releasing` until
256termination and the charge are in, and the finding returns to `held`.
257On steps: a retry dispatched by housekeeping is
258deferred behind any step a person started and never runs beside one; a
259person's own Retry on the same task supersedes it, and the housekeeping
260attempt is dropped as `superseded`.
261
262**Cadence.** Event-driven first: each detector lists its event types
263and `advance` runs the registry for the affected subject inside the
264transaction that wrote the event. Plus one **daily sweep** per person at
26503:00 in the person's zone (UTC until known) for the time-based
266detectors; one pass, never a loop.
267
268**Rate limits** are in the registry: `retry_transient` one per failure
269chain; `duplicate_same_creator` unbounded; `flaky_check` once per gate
270per week; `improvement_noticed` five per task; and a ceiling of ten
271actions and five new suggestions per person per day, after which
272findings are held.
273
274**The ledger state machine.** `chat_housekeeping` (§6) is the loop's
275memory, unique on `(team, detector, key)` for team subjects and
276`(team, person, detector, key)` for personal ones, and every row moves
277only forward:
278
279- `claimed`: inserted with `claimed_at`, the reservation and the
280 subject's `subject_revision`. A key that already exists is a no-op
281 unless it is `held`, `failed` with no recovery yet, or `vetoed` past
282 its window with a recurrence left (below).
283- A deterministic action that spends nothing claims and acts in **one
284 transaction** (`claimed → done` never commits separately). A spending
285 action commits `claimed` first, dispatches, and moves to `done` on the
286 report.
287- `claimed → done`: the action, its receipt and its event, in one
288 transaction. `claimed → refused`: the principal check failed.
289 `claimed → failed`: the action errored; the sweep may re-claim a
290 `failed` row once, then it stays.
291- **Recovery.** A row found in `claimed` at start-up, or older than ten
292 minutes at any sweep, is revalidated: the subject is read and its
293 revision compared with `subject_revision`. Unchanged and nothing
294 dispatched (no attempt recorded): the claim is **released** to `held`
295 and re-run as a fresh finding. Unchanged and dispatched: the row waits
296 for the runner's `sync` to settle the attempt, as steps do, then
297 advances to `done` or `failed`. Changed: `expired` with reason
298 `subject_moved`, the reservation reconciled as in §4 and released.
299 A row never silently stays `claimed`.
300- `done → undone`: a retained veto; the key never acts again.
301- `held`: capacity or budget was lacking, or the turn yielded; a held
302 row is claimed when the next sweep or event finds room. At most 20
303 held rows per person; beyond that the oldest is dropped as `expired`.
304- `vetoed`: a dismissed suggestion's key. Within 30 days the key is a
305 no-op. After 30 days, while `recurrences` is 0, the next finding
306 re-claims the row and sets `recurrences` to 1; once it is 1 the key is
307 a no-op for ever, whatever the window.
308
309**Verdicts through the mutation ledger.** `housekeeping_verdict` is a
310designated mutation (`MutationKinds` gains `verdict`), target the
311finding id, idempotent per finding across the turn's attempts like any
312kind. The instance accepts a verdict only if its `finding_id`, `subject`
313and `subject_revision` match a finding it issued in that turn's frame
314and the subject has not moved; anything else is refused, recorded as an
315error for the detector, and the finding stays `held` for one more turn.
316A yielded or failed turn leaves its findings `held`; a replayed verdict
317after failover is answered from the ledger with `replayed: true`.
318
319**Quiet hours.** 22:00 to 08:00 in the person's zone: the loop may act
320and claim, but every receipt and digest line gets `visible_at` 08:00 or
321the person's first message, whichever is first. The Housekeeping view
322shows them at once.
323
324**Pause.** One switch, `PUT /api/v1/housekeeping {paused}`. Paused: no
325detector runs, no sweep, nothing posted; running housekeeping turns and
326retries are cancelled and their reservations reconciled and released
327through the path above; existing Undo stays.
328
329**The digest.** Once a day when something happened, one instance-written
330line: "Tidied 2 things, suggested 1. [Housekeeping]".
331
332**The Housekeeping view** (`/housekeeping`, beside Notebook in the
333header): Pause; today's three budgets as quiet meters, reserved and
334charged; actions newest first with evidence and Undo while possible;
335suggestions; refusals and errors; detectors with state, reason and the
336re-enable switch.
337
338**Failure containment.** Failures are counted in
339`chat_housekeeping_failures` written in its **own transaction after the
340action's rollback**, so an error cannot erase its own record. A detector
341is auto-disabled for a person when, within seven days, it accumulates
342two of: an action undone, an action `failed`, a judgement turn `failed`
343or refused for a forged verdict, or a retried step that failed again. It
344says so once in the digest and the view offers the switch
345(`PUT /housekeeping/detectors/{id} {enabled}`); re-enabling clears the
346count. Nothing re-enables on its own.
347
348## 5. Suggestions
349
350A suggestion is a row (§6) with a title, a short text, structured
351evidence, a subject, an optional `related_task` and an audience. Paul's
352ruling: it shows as a **folded "Suggestions (3)" group at the bottom of
353the Tasks page**, collapsed by default, rows muted with no track, and in
354full on the Housekeeping view. No sidebar count.
355
356Two quiet actions per row. **Make it a task** calls `record_task` as
357the tapper, with the suggestion as brief and its project, through the
358ordinary path including the duplicate check; the suggestion becomes
359`accepted` with the task id. **Dismiss** marks it `dismissed` and vetoes
360its key for 30 days.
361
362Suggestions **decay**: 14 days open becomes `expired`; expired and
363dismissed rows are kept 30 days for the view, then deleted by the
364retention sweep that trims usage rows.
365
366**De-duplication**, in order: by key against open and recent
367suggestions (no-op); against open tasks in the same project by
368`record_task`'s similarity, in which case the suggestion is still
369created but `related_task` is set and the row reads "Related to [task]"
370(the task is not written to); within a judgement turn, where the model
371may merge near-identical `improvement_noticed` findings into one
372verdict, binding every merged finding id. **At most five open per
373person** (ten team-wide); a sixth is `held`.
374
375## 6. Data model, API v1, wire, tests
376
377**Tables** (migration 0050):
378
379- `chat_housekeeping`: `id`, `team`, `person` (null for team subjects),
380 `detector`, `subject_kind`, `subject_id`, `subject_revision`, `key`,
381 `class`, `state` (`claimed`, `held`, `done`, `undone`, `refused`,
382 `failed`, `vetoed`, `expired`), `claimed_at`, `attempt` (the dispatch
383 it made, null before), `reserved {turns, tokens, retries}`, `charged
384 {turns, tokens, retries, complete}`, `releasing` (bool), `evidence`,
385 `result` (the full undo snapshot of §3), `visible_at`, `undo_until`,
386 `recurrences`, `expired_reason`, `at`, `undone_at`, `revision`; unique
387 indexes as in §4.
388- `chat_housekeeping_failures`: `person`, `detector`, `kind`, `at`.
389- `chat_suggestions`: `id`, `team`, `audience_person`, `detector`,
390 `subject_kind`, `subject_id`, `project`, `key`, `title`, `text`,
391 `evidence`, `related_task`, `state` (`open`, `held`, `accepted`,
392 `dismissed`, `expired`), `task_id`, `created_at`, `expires_at`,
393 `revision`; `chat_suggestion_dismissals (suggestion, person)`.
394- `chat_housekeeping_settings`: `person`, `paused`, `disabled` (JSON:
395 detector to reason and time), `last_digest_at`, `revision`.
396- `chat_turns.kind` gains `housekeeping`; `chat_usage` gains `role`
397 value `housekeeping` and `caused_by`; `chat_steps` gains `caused_by`
398 and `undone_attempt`.
399
400**Resources.** `GET /api/v1/housekeeping` returns `Housekeeping {paused,
401budget {turns {reserved, charged, limit}, tokens {...}, retries {...}},
402detectors[{id, class, enabled, disabled_reason}], actions[], refusals[],
403revision}`; `PUT /api/v1/housekeeping {paused, revision}`;
404`PUT /api/v1/housekeeping/detectors/{id} {enabled, revision}`;
405`GET /api/v1/housekeeping/actions?before=&limit=`;
406`POST /api/v1/housekeeping/actions/{id}/undo` (409 with the current
407action when no longer undoable); `GET /api/v1/suggestions`;
408`POST /api/v1/suggestions/{id}/accept` returns `TaskAccepted`;
409`POST /api/v1/suggestions/{id}/dismiss`. Events `housekeeping` and
410`suggestion`. `Snapshot` gains `suggestions` and `housekeeping_summary
411{open_suggestions, paused, disabled}`. `Card` gains kind `housekeeping`
412with `action_id`, `visible_at` and `ChoiceUndo`; the combined card is
413its first instance. `Step` and `Task` gain `caused_by`.
414
415**Wire.** Instance to runner: `message{kind: housekeeping, max_tokens,
416findings[{id, subject, subject_revision, evidence}]}`; the proxy mounts
417**only** `status`, `read_task`, `find`, `search_code`, `read_file`,
418`read_notes` and `housekeeping_verdict` for this kind, and the runner's
419launcher policy (`policy.go`, `TestConversePolicyCoversEveryTool`)
420carries the same allowlist, so a frame or a model asking for anything
421else is refused at both ends; 24 calls as explore. `dispatch` gains
422`caused_by`, `not_before_person_steps: true`. Runner to instance: `step`
423reports gain `noticed[{text, repo, path}]` from the pinned
424`note_improvement` tool (five per step, 280 bytes each); the merge watch
425reports `branch_gone{task, branch}`. Fixtures under
426`internal/wire/wiretest/testdata`: `api/housekeeping.json`,
427`api/housekeeping-paused.json`, `api/action-combined.json`,
428`api/action-retry.json`, `api/action-undone.json`,
429`api/action-refused.json`, `api/suggestions.json`,
430`api/suggestion-related.json`, `api/event-housekeeping.json`,
431`api/event-suggestion.json`, `api/card-housekeeping.json`,
432`frames/message-housekeeping.json`, `frames/step-noticed.json`,
433`frames/branch-gone.json`, `frames/dispatch-caused-by.json`. The
434secret-shape guard covers the new types.
435
436**Tests.** Unit: a deterministic fixture per detector (store snapshot
437in, exact findings out, threshold edges included), the rate table, and
438`TestRegistryModelMeansPropose`. Contract, each with a mutation observed
439failing: `TestHousekeepingPrincipal` (a fold whose destination belongs to
440another creator, a suggestion related to another's task, a retry on
441another's step, and a detector running inside `advance` for a person
442removed from the roster mid-turn: every one `refused`, nothing changed);
443`TestHousekeepingReservation` (two claims racing the last turn: one
444`claimed`, one `held`; a retry reserves 100,000 and its fix round is
445charged to it; a failover attempt's `max_tokens` is the remainder, and
446the floor ends it `budget`; an attempt with no usage figure charges the
447whole reservation; a yield, a Pause and a cancel each keep the row
448`releasing` until termination and the charge, then release);
449`TestHousekeepingStandsDown` (the selected pair's headroom unknown, at
4500.8, or checked over fifteen minutes ago: `held`, no other connection
451tried; combine still acts); `TestHousekeepingTier` (a `standard` pair
452alone: `held`; no tiers at all: no turn); `TestHousekeepingPreempts` (a
453person's message yields the turn; a person's Retry supersedes the
454automatic one; a person step dispatched first);
455`TestHousekeepingUndoRoundTrips` (combine then Undo: both tasks and
456threads equal their prior fixture byte for byte, destination included,
457key `undone`, a second finding a no-op; retry then Undo: every field
458`RetryTask` cleared equals the snapshot on step and task, `attempt` stays
459n+1, `undone_attempt` set, a late `running` report for n+1 dropped and
460its termination accepted, a person's Retry then gives n+2; Undo racing
461the `running` report: exactly one commits, the other 409);
462`TestHousekeepingRetryChain` (one automatic retry per chain, termination
463proof required, a pushed step never retried, the second failure is
464Needs you `retry`; the retried task later earns `merge_eligible`,
465`ready_sha` and its merge card through the ordinary policy, while a
466housekeeping principal writing any of them directly is refused);
467`TestHousekeepingNever` (the principal attempting delete, merge, a
468`limited` connection, the eleventh action: refused at the store, a
469`refused` row); `TestHousekeepingLedger` (replayed event; a crash after
470`claimed` with nothing dispatched: released to `held` at restart; a
471crash after dispatch: settled by `sync`; the subject moved meanwhile:
472`expired` with `subject_moved` and the reservation released; a
473deterministic action's claim and effect in one transaction; held then
474claimed; veto then one recurrence then none; team-scoped key raised by
475two people once);
476`TestHousekeepingVerdicts` (a verdict with a forged finding id, a stale
477`subject_revision`, a subject that moved: refused and counted; a replay
478after failover `replayed: true`; a yielded turn leaves findings held);
479`TestHousekeepingHostile` (a repository file and a notebook entry
480containing instructions to combine, cancel, merge or call other tools:
481the turn's only effect is verdicts, and only on issued findings);
482`TestHousekeepingAutoDisable` (two failures of mixed kinds within seven
483days: disabled, one digest line, failure rows survive the action's
484rollback, re-enable clears); `TestSuggestionsLane` (five open, sixth
485held, accept through `record_task`, dismiss vetoes, related task
486untouched, decay); `TestHousekeepingQuietHours` (an action at 02:00
487shows on the view at once and in the conversation at 08:00). Headless:
488`H1` two similar tasks in one message, combined, Undo from the receipt
489restores both; `H2` (slice 2) the runner killed before any push,
490restarted, one automatic retry with a receipt, a second kill is Needs
491you; `H3` (slice 3) a judgement turn with the fake CLI produces one
492suggestion and charges one turn. Browser: the view and the lane at 1280
493and 390.
494
495## 7. Slices
496
497| Slice | Content | Gate | Size |
498|---|---|---|---|
499| 1 The smallest useful loop | Registry; `chat_housekeeping` with the state machine and reservations; the housekeeping principal in the store functions; `duplicate_same_creator` as the first detector, its action the reversible combine from `thin-v1-ux1` (same creator, both tasks checked in the transaction, Undo restores both); `duplicate_possible` as links; Pause; quiet hours; the digest line; the Housekeeping view with Undo and refusals; `chat_housekeeping_failures` and auto-disable. No spend, no model turns, no suggestions | `thin-v1-ux1`'s combine merged first; `TestHousekeepingPrincipal`, `Ledger` (including claim recovery at restart and `subject_moved`), `UndoRoundTrips` (combine), `Never`, `AutoDisable`, `QuietHours`; H1 | 3 days |
500| 2 Retries and suggestions | `retry_transient` (pre-push only, one per chain, Undo until the step starts, `caused_by` charging); `chat_suggestions`, the lane, accept and dismiss, decay, de-duplication by `related_task`, the cap; `ready_waiting`, `branch_gone`, `repo_reach`, `connection_health` digest lines; `flaky_check` without the model | Automatic retries ship only after `Reservation` (caps, remainder, unknown charged in full, releasing), `StandsDown` (selected pair), `Preempts`, `RetryChain`, `UndoRoundTrips` (snapshot, fencing and the race), `Principal` (foreign owner), the dispatched-claim recovery in `Ledger` and `AutoDisable` are green; H2 | 2.5 days |
501| 3 Judgement | turn kind `housekeeping`, tier ceiling, `max_tokens`, the two-ended allowlist, `housekeeping_verdict` as a mutation kind, the sweep; `note_improvement` and `improvement_noticed`; `findings_unaddressed`; `notebook_stale` as a proposal; model naming for `flaky_check` | **Depends on Connections slice 3 (tiers)**; `Tier`, `Verdicts`, `Hostile`, `StandsDown`; H3 | 2 days |
502| 4 Team scope | team suggestions with per-person dismissal, `stale_project` with its ask-once, the owner's team budget and team Pause, acting on team subjects by the owner | team-keyed `Ledger` cases | 1.5 days |
503
504Each slice lands headless first, then staging with the real CLI, then
505UI, as thin v1 §8. Slice 1 is on by default with Pause as the exit; it
506spends nothing and can only combine and undo.
507
508## 8. Beyond code
509
510The same loop serves a business or a family when three things change
511and nothing in §§3 to 5 does. **Subjects** widen: a person's area, a
512shared responsibility, a recurring obligation, a decision. **Detectors**
513are added to the registry over new facts: a recurring chore with no
514completion since its period (`chore_overdue`, propose a reminder), a
515notebook decision whose review date has passed (`decision_stale`,
516propose revisiting it), a question with no owner after N days
517(`unowned_followup`, ask once who takes it), spend drifting from its
518usual level on a connected ledger (`spending_drift`, propose a look).
519**Data sources** become connections of new kinds (a calendar, a shared
520list, an accounts export, a mailbox) with the same consent model as
521model connections: added by the person who owns them, readable by that
522person's housekeeping, shared with the team only by an explicit grant,
523never a secret on the instance. For a family the owner role matters
524more than for a one-person team: the owner sets the team Pause and the
525team budget, and personal subjects stay personal even from the owner.
526Before any of it is built: a typed fact store the detectors read instead
527of the chat tables, a consent record per source and per audience, and
528copy a non-developer reads without flinching. None of that is designed
529here.
530
531## 9. Rulings and decisions
532
533Paul, 2026-11-08: **budget defaults** 4 judgement turns, 150,000 tokens
534and 3 automatic retries per person per day, standing down at 80%;
535**suggestions** as a folded group at the bottom of Tasks plus the
536Housekeeping view, five open per person. Both are folded in above.
537
538Taken here, for review rather than decision: automatic retry acts only
539on steps that never pushed and is otherwise the existing Needs you card;
540cross-creator duplicates are links only in every slice; model judgement
541produces suggestions only. No decision is open for Paul in this
542revision.
543
544## 10. Risks
545
546Headroom is best effort, so the stand-down rule is conservative by
547design (unknown means stop), and on a week when Claude reports no figure
548judgement turns simply do not run. A deterministic detector that is
549wrong on real data acts before it is undone twice; the seven-day Undo,
550the retained veto and auto-disable bound that. Slice 1 depends on the
551combine landing on `thin-v1-ux1` first. Slice 3 depends on Connections
552slice 3 for tiers and until then has nothing cheap to run on. The
553judgement turn reads code and notes that may be hostile; its only effect
554is a verdict bound to a server-issued finding, enforced at the proxy and
555the launcher, and `TestHousekeepingHostile` is the regression guard.
556