oficina / equipo Public

specs: housekeeping rev 2 after Astra round 1

Store-level housekeeping principal checking membership and every
affected resource, fold destinations included; cross-creator duplicates
are links only; suggestion de-duplication records related_task instead
of writing to tasks. Model judgement is propose-only (registry refuses
other classes), notebook_stale proposes, verdicts bound to issued
findings and revisions through the mutation ledger, allowlist at proxy
and launcher, hostile-content tests. Budgets by atomic reservation with
caused_by charging, unknown headroom stands down, tier ceiling at
selection, person turns pre-empt in queue, yield and retries. Retry is
pre-push only, one per chain, Undo until the step starts, moved to
slice 2 behind its tests. Ledger state machine, team-keyed uniqueness,
durable failure accounting. Paul's rulings folded in; slice 1 trimmed.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
claude f94fad04d9a8acc728e53bc6a46e02743eb1bc04 parent cc6ca41
1 file changed, +389 −304
  • docs/superpowers/specs/2026-11-08-equipo-housekeeping.md +389 −304

CI passed — run details

diff --git a/docs/superpowers/specs/2026-11-08-equipo-housekeeping.md b/docs/superpowers/specs/2026-11-08-equipo-housekeeping.md
index 32cf84ab..5af6f2a0 100644
--- a/docs/superpowers/specs/2026-11-08-equipo-housekeeping.md
+++ b/docs/superpowers/specs/2026-11-08-equipo-housekeeping.md
@@ -1,10 +1,12 @@
# Equipo housekeeping: a tidying loop that stays under control
-Status: design for Paul's review, 2026-11-08. Drafted by Claude (Fable
-5.1) on `design-housekeeping` from `thin-v1-conn1` (7946111). Builds on
-thin v1 (`2026-11-06-equipo-thin-v1.md`), Connections rev 3
-(`2026-11-08-equipo-connections.md`, §§3, 6) and the progress logs for
-slices 2b, 3, 4, 4c, CONN1 and UX1. Not implemented.
+Status: design for Paul's review, 2026-11-08, revision 2 after Astra's
+round 1 (NOT READY at cc6ca41). Drafted by Claude (Fable 5.1) on
+`design-housekeeping` from `thin-v1-conn1` (7946111). Builds on thin v1
+(`2026-11-06-equipo-thin-v1.md`), Connections rev 3
+(`2026-11-08-equipo-connections.md`, §§3, 4, 6) and the progress logs
+for slices 2b, 3, 4, 4c, CONN1 and UX1. Paul's rulings of 2026-11-08
+are folded in (§9). Not implemented.
## 0. Why, and the shape of the answer
@@ -19,256 +21,313 @@ Equipo already has the pieces of a loop without the loop. Move-in and
explore turns run with no person message and only read and note tools.
The notebook holds what the coordinator has learned. The runner checks
reach every minute and watches merged branches. The merge policy is
-deterministic and runs in `advance`. Duplicate detection is being built:
-same-creator, high-similarity pairs are combined with an Undo receipt
-(`Task.folded`, `CardCombined`, `POST /tasks/{id}/uncombine`), weaker
-matches get a "Possible duplicate of" link. The mutation ledger makes
-writes idempotent across attempts. Usage records every attempt.
+deterministic and runs in `advance`. Duplicate detection is being built
+on `thin-v1-ux1`: same-creator, high-similarity pairs are combined with
+an Undo receipt (`Task.folded`, `CardCombined`,
+`POST /tasks/{id}/uncombine`); weaker matches get a "Possible duplicate
+of" link. The mutation ledger makes writes idempotent across attempts.
+Usage records every attempt.
Housekeeping is the rule that joins them: **deterministic detectors
notice things; a policy table says what each class of thing may become;
-a budget, a ledger and one Pause switch keep it bounded; everything it
-does leaves a receipt with Undo; everything it only thinks of becomes a
-suggestion, never a task, until a person taps.** A model is consulted
-only when a detector has already fired and the question is one of
-judgement, and that consultation is a cheap read-only turn like explore.
-No setup: the loop is on from the first message, with defaults, and the
-only control a person needs is Pause.
+a reserved budget, a ledger with a state machine and one Pause switch
+keep it bounded; everything it does leaves a receipt with Undo; and
+anything that depends on a model's judgement becomes a suggestion, never
+an action, until a person taps.** No setup: the loop is on from the
+first message, with defaults, and the only control a person needs is
+Pause.
+
+Two invariants hold everywhere below and are tested as such. **No
+forbidden effect is reachable**: every write the loop makes goes through
+the shared store functions under a server-derived housekeeping principal
+that checks current membership and the owner of every affected resource
+inside the transaction. **Model judgement is never an action**: a model
+may shape the words of a suggestion and nothing else.
## 1. Scope: teams, subjects, who sees what
Everything in this spec belongs to a **team**: the roster that shares a
conversation server today, which in time may be a business, an
-organisation or a family. Within a team, every detector finding, action
-and suggestion has a **subject**: `{kind, id}` where kind is `task`,
+organisation or a family. Within a team, every finding, action and
+suggestion has a **subject**: `{kind, id}` where kind is `task`,
`project`, `connection`, `notebook_entry`, `person` (a person's own area)
or `team`. The subject decides authority and visibility by one rule:
**a subject owned by one person is that person's business; a subject
owned by the team is everyone's to see and the owner's to act on.**
-Concretely, a task's subject owner is its creator ("only a task's
-creator acts on it" stands). A connection's owner is its person. A
-notebook entry's owner is the coordinator's person. A project and the
-team itself are team subjects. The loop runs **per person**: each
-person's coordinator keeps that person's own subjects tidy, draws on
-that person's connections and budget, and posts receipts into that
-person's conversation. Team subjects produce suggestions visible to the
-whole roster, and in v1 nothing more; acting on a team subject is slice
-4 and needs the owner's say. A person sees a suggestion if its audience
-is them or the team; a person may accept a suggestion if they could
-create the task it describes (any member for team subjects, the owner
-for personal ones); dismissing is per person for team suggestions and
-final for personal ones. Budgets are per person in slices 1 to 3; a team
-budget, spent by the owner's housekeeping on team subjects, arrives with
-slice 4.
+A task's subject owner is its creator ("only a task's creator acts on
+it" stands, and it applies to the *destination* of a fold as well as the
+source). A connection's owner is its person. A notebook entry's owner is
+the coordinator's person. A project and the team itself are team
+subjects. The loop runs **per person**: each person's coordinator keeps
+that person's own subjects tidy, draws on that person's connections and
+budget, and posts receipts into that person's conversation. Team
+subjects produce suggestions visible to the whole roster and nothing
+more until slice 4, which adds acting on team subjects by the owner. A
+person sees a suggestion if its audience is them or the team; a person
+may accept a suggestion if they could create the task it describes (any
+member for team subjects, the owner for personal ones); dismissing is
+per person for team suggestions and final for personal ones.
+
+**The housekeeping principal.** Every loop write runs as
+`housekeeping{team, person, detector, finding_id}`, built by the
+instance from the ledger row, never from a frame or a tool argument. It
+is passed into the same store functions a person's request uses
+(`foldTask`, `retryStep`, `recordSuggestion`), and those functions
+check, inside the write transaction: the person is a current member; for
+every task touched, including a fold's destination and any task a
+suggestion is linked to, the creator is the principal's person; for a
+notebook entry, its person; for a team subject, that the class permits
+it (propose only before slice 4). A principal that fails any check gets
+`housekeeping_forbidden`, the ledger row becomes `refused`, and nothing
+else in the transaction survives. Handlers are not the only gate: the
+detectors run inside `advance`, so the gate is in the store.
## 2. Detectors: a registry of small declared units
A **detector** is a declared, data-driven unit in a registry
(`internal/equipo/housekeeping`), never free code in a handler. Each
-declares: `id`; subject kind; `class` (the action class of §3);
-`triggers` (event types from the stream, plus `sweep`); `judgement`
-(`none` or `model`); `rate` (at most N findings per subject and per team
-per period); `undo` (whether its action can be reversed); and `Detect`, a
+declares: `id`; subject kind; `class` (§3); `triggers` (event types from
+the stream, plus `sweep`); `judgement` (`none` or `model`); `rate` (at
+most N findings per subject and per team per period); and `Detect`, a
pure function from a read-only view of the store to zero or more
-**findings** `{detector, subject, key, evidence, proposal}`. The `key` is
-the finding's identity (`duplicate:tkA:tkB`, `retry:tkA:attempt3`): the
-same key never acts twice (§4). Evidence is structured fields the receipt
-and the page can render, never model prose. Adding a detector is a
-registry entry and a fixture; nothing else changes, which is what lets
-the non-code detectors of §8 arrive later.
-
-Deterministic first. Every detector in v1 fires on data the instance
-already holds or the runner already reports; a model is called only when
-`judgement: model`, and only to answer "should this finding become a
-suggestion, and in what words" with a verdict tool, never to decide an
-action. The candidate detectors, with the class each lands in:
+**findings** `{detector, subject, subject_revision, key, evidence,
+proposal}`. The key is the finding's identity (`duplicate:tkA:tkB`,
+`retry:tkA:chain2`); the ledger (§4) decides whether it may act.
+Evidence is structured fields the receipt and the page render, never
+model prose. A detector with `judgement: model` may only have class
+Propose: the registry refuses any other combination at start-up
+(`TestRegistryModelMeansPropose`). Adding a detector is a registry entry
+and a fixture; nothing else changes, which is what lets the non-code
+detectors of §8 arrive later.
| Detector | Fires on | Class | Judgement |
|---|---|---|---|
-| `duplicate_same_creator` | `record_task` by the same creator, title overlap at or above 0.8 with three shared words, both open, neither started | Act and tell: combine, receipt with Undo (the work being built) | none |
-| `duplicate_possible` | overlap at or above 0.6 or a different creator | Link "Possible duplicate of"; different creators: Ask once, to the newer task's creator | none |
-| `retry_transient` | a step stopped with `runner_restarted`, `provider_failed`, `interrupted`, `checks_timeout`, `candidate_unavailable`, `clone_failed`, `push_failed` (republish), `no_runner` once a runner is back | Act and tell: one retry per task per day, receipt with Undo | none |
-| `ready_waiting` | a task at Ready to merge with an open card or no card for over 24 h | Digest mention only ("2 ready tasks are waiting on you"), never a new card | none |
-| `merged_outside` | the merge watch sees the candidate on the default branch without a merge step, or a `branch_gone` report with no merge | Act and tell: mark Done "Merged on Amadan" (reversible); a branch gone unmerged: Needs you `branch_moved` as today | none |
-| `stale_project` | no task, message or push in 60 days | Propose: "Archive <project>?" (team subject) | none |
-| `flaky_check` | the same gate fails then passes on the same SHA (a Retry of checks), twice in 30 days | Propose: "Checks flaked twice on <gate>" with the tails | model, to name the test |
-| `findings_unaddressed` | Review findings on a merged task whose files were not touched by the fix rounds | Propose: "Review raised N points that were not addressed" | model |
-| `notebook_stale` | an entry whose `repo` source file changed, or an `own` entry older than 90 days contradicted by a newer one | Act and tell: mark the entry stale (hidden from context, kept, Undo) | model for "contradicted" |
-| `repo_reach` | hello catalog gains or loses a repository | Quiet line in the digest; a lost repo with open tasks: Needs you (exists) | none |
-| `connection_health` | `limited` with a reset over 48 h away, `sign_in_again`, a key whose `expires_at` is within 7 days | Needs you (exists) once; digest line otherwise | none |
-| `improvement_noticed` | a specialist calls `note_improvement{text, repo, path}` during a step (bounded, pinned) | Propose: one suggestion per note, deduplicated | model, to merge near-identical notes |
-
-The thresholds are constants beside the detector and appear in its
-fixture; the similarity function is `record_task`'s existing one.
+| `duplicate_same_creator` | `record_task` by a creator whose open, unstarted task in the same project overlaps the new one at or above 0.8 with three shared words, both tasks owned by that creator and checked again in the transaction | Act and tell: combine, receipt with Undo (built on `thin-v1-ux1`) | none |
+| `duplicate_possible` | overlap at or above 0.6, or any overlap across creators | Link only: "Possible duplicate of" on the new task, `Task.duplicate_of` as UX1 | none |
+| `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 |
+| `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 |
+| `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 |
+| `stale_project` | no task, message or push in 60 days | Propose: "Archive <project>?" (team subject, slice 4) | none |
+| `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 |
+| `findings_unaddressed` | Review findings on a merged task naming files the fix rounds never touched | Propose | model |
+| `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 |
+| `repo_reach` | hello catalog gains or loses a repository | Digest line; a lost repository with open tasks: the existing access card | none |
+| `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 |
+| `improvement_noticed` | a specialist calls `note_improvement{text, repo, path}` during a step | Propose: one suggestion per note | model, to merge near-identical notes |
+
+`notebook_stale` never hides an entry on its own; the tap does, as a
+person's action with the ordinary Undo. Cross-creator duplicates are
+links in every slice of this spec. Thresholds are constants beside the
+detector and appear in its fixture; the similarity function is
+`record_task`'s.
## 3. Action classes and the policy table
-Four classes, decided by the registry entry, enforced by the instance in
-the write transaction, never by the detector's own code or a model.
-
-**Act and tell.** Reversible, within the person's own subjects, no model
-spend beyond the person's cheap tier, and undoable for seven days or
-until a later change makes the undo impossible (409 with the reason, as
-the home card's Undo today). The action is written, its receipt card
-posted in the person's conversation ("Combined [A] into [B] · Undo",
-"Retried Engineering on [A] after the runner restarted · Undo", "Marked
-a note stale · Undo") and the `housekeeping` event emitted, in one
-transaction. Undo restores the exact prior state through the same
-resource APIs a person would use (`uncombine`, cancel of the retried
-attempt plus the step's prior reason, the entry's prior state) and marks
-the key `undone`, which vetoes it: the detector never fires that key
-again, and the person's veto is the containment signal of §4.
-
-**Propose.** Creates a **suggestion**, not a task (§5). Costs nothing
-unless `judgement: model`, in which case one housekeeping turn from the
-budget. A suggestion never changes a task, a branch, a project or a
-note. Examples: flaky checks, unaddressed findings, improvements noticed,
-stale projects.
-
-**Ask once.** Shared, irreversible or costly, and the question is a
-**Needs you** card with one tap, asked once per key and never repeated:
-a cross-creator duplicate ("Is [A] the same as Nora's [B]? Fold into it
-/ Keep separate"), a retry that would run a `strong` tier step, a stale
-project's archive. "Ask once" reuses the card kinds and the creator-only
-answer path from slice 4c.
-
-**Never.** Delete data (tasks, projects, branches, notes, usage rows);
-merge without checks, or merge at all outside the slice 4c policy; act
-on another person's task or notebook; create or start a task from a
-suggestion without a tap; spend past the budget or on a `limited`
-connection; post more than receipts and one digest line a day; change a
-setting. These are refused **server side** by a `housekeeping` principal
-check in the handlers, so a detector or a judgement turn that tries gets
-403 `housekeeping_forbidden` and the refusal is logged on the view.
+Four classes, named in the registry, enforced in the store under the
+principal of §1, never by detector code or a model.
+
+**Act and tell.** Deterministic only, within the person's own subjects,
+no model spend, undoable for seven days or until a later change makes
+the undo impossible (409 with the reason, as the home card's Undo). The
+action, its receipt card and its `housekeeping` event are written in one
+transaction with the ledger transition (§4); the card appears on the
+Housekeeping view at once and in the conversation at its `visible_at`
+(§4, quiet hours). Undo restores the prior state through the same store
+functions a person's Undo uses (`uncombine`, which restores the folded
+task and its thread exactly and removes the fold from the destination)
+and moves the ledger row to `undone`, a retained veto.
+
+**Propose.** Creates a **suggestion** (§5), never a task, and writes to
+no other resource. De-duplication against tasks records
+`Suggestion.related_task` on the suggestion; it never appends to the
+task. Costs nothing unless `judgement: model`, in which case one
+reserved housekeeping turn.
+
+**Ask once.** Shared, irreversible or costly; a Needs you card asked
+once per key, answered by the subject's owner only. In this spec it is
+used only by `stale_project` in slice 4. Automatic retries of pushed
+work are not asked: the existing Needs you `retry` card already covers
+them and is unchanged.
+
+**Never.** Delete tasks, projects, branches, notes or usage rows; merge,
+or alter `merge_eligible`, `merge_asked`, an open merge card or the
+checks-exception decision; touch another person's task or notebook,
+including as a fold's destination; create or start a task from a
+suggestion without a tap; dispatch past the reservation or on a
+connection that is `limited` or of unknown tier; post more than receipts
+and one digest line a day; change a setting. Refused in the store, a
+`refused` ledger row, shown on the view.
| Class | Needs | Costs | Reversal | Tells the person |
|---|---|---|---|---|
-| Act and tell | own subject, reversible, no model | 0 or one cheap step | Undo, 7 days | receipt card, digest |
-| Propose | any subject | 0 or one cheap turn | dismiss | Suggestions lane, digest |
-| Ask once | shared, irreversible or strong tier | 0 | the answer | one Needs you card |
-| Never | | | | refused, shown on the view |
+| Act and tell | own subject, deterministic, reversible | 0, or one reserved step (retry) | Undo, 7 days (retry: until the step starts) | receipt card, digest |
+| Propose | any subject | 0 or one reserved turn | dismiss | Suggestions lane, digest |
+| Ask once | shared or irreversible, owner answers | 0 | the answer | one Needs you card |
+| Never | | | | refused, on the view |
## 4. Control
-**Budget.** Per person per day: `judgement_turns` (default 4) and
-`tokens` (default 150,000) for housekeeping turns, and `retries`
-(default 3) for act-and-tell steps. Spent rows are ordinary `usage` rows
-with role `housekeeping`, so the budget is computed, not stored, and
-shows on the Usage page like any role. Housekeeping runs on the
-**cheapest healthy connection**: the choice function of Connections §3
-with the tier floor `cheap` and role `housekeeping`, never a `limited`
-connection, and it **stands down** when every healthy connection reports
-utilization at or above 0.8 or when only limited connections remain, so
-Paul's week-limited Claude is never nudged over by a tidy-up. A
-housekeeping turn is dispatched after every person turn, as move-in is,
-and yields to a person's message exactly as move-in yields. Deterministic
-detectors cost no budget and keep running when the budget is spent; only
-judgement turns and retries stop, and the digest says so ("Housekeeping
-paused until tomorrow: today's budget is used").
-
-**Cadence.** Event-driven first: each detector lists the event types it
-cares about (`task`, `step`, `card`, `connection`, `project`,
-`notebook`), and `advance` runs the registry for the affected subject
-in the same transaction that wrote the event, so a duplicate is noticed
-as the second task is recorded and a transient stop as its report lands.
-Plus one **daily sweep** per person over all their subjects, at 03:00 in
-the person's zone (UTC until the zone is known), for the detectors that
-depend on time (`ready_waiting`, `stale_project`, `notebook_stale`,
-`connection_health`). The sweep is a single pass; it never loops.
-
-**Rate limits** are in the registry: `retry_transient` once per task per
-day; `duplicate_same_creator` unbounded (free and undoable);
-`flaky_check` once per gate per week; `improvement_noticed` five per
-task; a hard ceiling of **ten actions and five suggestions per person
-per day** across all detectors, after which findings are held for the
-next day.
-
-**Idempotency.** `chat_housekeeping` (§6) is the loop's ledger, keyed
-`(team, person, detector, key)`; a finding whose key exists in any state
-is a no-op, so a replayed event, a restart or a second sweep cannot act
-twice. Actions that run through the coordinator's tools also enter the
-turn's mutation ledger as today.
-
-**Quiet hours.** Between 22:00 and 08:00 in the person's zone the loop
-may act (a retry at 02:00 is welcome) but posts nothing; receipts and
-the digest wait for 08:00 or the person's first message, whichever comes
-first.
-
-**Pause.** One switch, `PUT /api/v1/housekeeping {paused}`, on the
-Housekeeping view and in Settings. Paused: no detector runs, no sweep,
-nothing posted; existing receipts keep their Undo. Nothing else to set.
-
-**The digest.** Once a day, only when something happened, one line in
-the conversation written by the instance (no model): "Tidied 2 things,
-suggested 1. [Housekeeping]" linking to the view. Receipts posted during
-the day are not repeated in it.
-
-**The Housekeeping view** (`/housekeeping`, linked from the conversation
-header beside Notebook and from the digest): Pause; today's budget as
-three quiet meters; actions newest first, each with its evidence and
-Undo while possible; suggestions; refusals; and the detector list with
-its state and reason when disabled.
-
-**Failure containment.** A detector is **auto-disabled for that person**
-when, within seven days, two of its actions are undone, or two of its
-runs error, or two of its judgement turns end `failed`. It says so once
-in the digest ("Stopped combining duplicates after two undos. Turn it
-back on in Housekeeping.") and the view offers the switch
-(`PUT /housekeeping/detectors/{id} {enabled}`). Disabling is per person
-and per detector; the rest of the loop goes on.
+**Budget by reservation.** Per person per day (Paul's ruling): 4
+judgement turns, 150,000 tokens and 3 automatic retries. A ledger row
+that will spend holds a **reservation** written in its `claimed`
+transaction: the claim sums today's reserved and charged figures for the
+person and refuses the claim (`held`, §4 ledger) if the new reservation
+would exceed any limit, so two concurrent claims cannot both pass. A
+judgement turn reserves one turn and a per-turn token cap (40,000,
+passed to the runner as `max_tokens` on the frame and enforced by the
+harness's own limit; the attempt is cancelled at the cap). A retry
+reserves one retry and every attempt and step it causes: the retried
+step, and the checks, review and fix rounds that follow it, carry
+`caused_by: <action_id>` on dispatch, their usage rows carry it, and the
+sum is charged to the action as they complete. A failover attempt within
+a housekeeping turn is charged to the same reservation. When the charge
+is known the reservation is released and the row records `charged`.
+
+**Stand-down.** Housekeeping dispatches nothing that spends when: any
+limit is reached; no connection is `healthy` with a reported utilization
+below 0.8; or the best candidate's headroom is **unknown** (no figure
+from the provider means stand down, not proceed). Deterministic actions
+that spend nothing (combine, digest lines) carry on. The digest says
+"Housekeeping stood down: today's budget is used" or "... Claude is near
+its limit".
+
+**Tier at selection.** A housekeeping turn asks the choice function for
+role `housekeeping` with a **tier ceiling** of `cheap`: pairs above the
+ceiling are filtered out before stickiness or preference apply, and if
+none remains the turn is `held`. Tiers come from Connections slice 3;
+until that lands, no pair has a tier, so judgement turns do not run and
+slice 3 of this spec waits on it.
+
+**Person turns pre-empt**, in three places. In the queue: `dispatchNext`
+takes person turns first, then move-in and explore, then housekeeping.
+On yield: a person's message cancels a running housekeeping turn as it
+does a move-in (`yielded`), its reservation is released, the finding
+returns to `held`. On steps: a retry dispatched by housekeeping is
+deferred behind any step a person started and never runs beside one; a
+person's own Retry on the same task supersedes it, and the housekeeping
+attempt is dropped as `superseded`.
+
+**Cadence.** Event-driven first: each detector lists its event types
+and `advance` runs the registry for the affected subject inside the
+transaction that wrote the event. Plus one **daily sweep** per person at
+03:00 in the person's zone (UTC until known) for the time-based
+detectors; one pass, never a loop.
+
+**Rate limits** are in the registry: `retry_transient` one per failure
+chain; `duplicate_same_creator` unbounded; `flaky_check` once per gate
+per week; `improvement_noticed` five per task; and a ceiling of ten
+actions and five new suggestions per person per day, after which
+findings are held.
+
+**The ledger state machine.** `chat_housekeeping` (§6) is the loop's
+memory, unique on `(team, detector, key)` for team subjects and
+`(team, person, detector, key)` for personal ones, and every row moves
+only forward:
+
+- `claimed`: inserted atomically with the reservation and the subject's
+ revision; a key that already exists in any state other than `held` or
+ `failed` makes the finding a no-op.
+- `claimed → done`: the action, its receipt and its event, in one
+ transaction. `claimed → refused`: the principal check failed.
+ `claimed → failed`: the action errored; the sweep may retry a `failed`
+ row once, then it stays.
+- `done → undone`: a retained veto; the key never acts again.
+- `held`: capacity or budget was lacking, or the turn yielded; a held
+ row is claimed when the next sweep or event finds room. At most 20
+ held rows per person; beyond that the oldest is dropped as `expired`.
+- `vetoed`: a dismissed suggestion's key, 30 days; after that the key
+ may recur **once** (`recurrences` counter), then never.
+
+**Verdicts through the mutation ledger.** `housekeeping_verdict` is a
+designated mutation (`MutationKinds` gains `verdict`), target the
+finding id, idempotent per finding across the turn's attempts like any
+kind. The instance accepts a verdict only if its `finding_id`, `subject`
+and `subject_revision` match a finding it issued in that turn's frame
+and the subject has not moved; anything else is refused, recorded as an
+error for the detector, and the finding stays `held` for one more turn.
+A yielded or failed turn leaves its findings `held`; a replayed verdict
+after failover is answered from the ledger with `replayed: true`.
+
+**Quiet hours.** 22:00 to 08:00 in the person's zone: the loop may act
+and claim, but every receipt and digest line gets `visible_at` 08:00 or
+the person's first message, whichever is first. The Housekeeping view
+shows them at once.
+
+**Pause.** One switch, `PUT /api/v1/housekeeping {paused}`. Paused: no
+detector runs, no sweep, nothing posted, reservations released; existing
+Undo stays.
+
+**The digest.** Once a day when something happened, one instance-written
+line: "Tidied 2 things, suggested 1. [Housekeeping]".
+
+**The Housekeeping view** (`/housekeeping`, beside Notebook in the
+header): Pause; today's three budgets as quiet meters, reserved and
+charged; actions newest first with evidence and Undo while possible;
+suggestions; refusals and errors; detectors with state, reason and the
+re-enable switch.
+
+**Failure containment.** Failures are counted in
+`chat_housekeeping_failures` written in its **own transaction after the
+action's rollback**, so an error cannot erase its own record. A detector
+is auto-disabled for a person when, within seven days, it accumulates
+two of: an action undone, an action `failed`, a judgement turn `failed`
+or refused for a forged verdict, or a retried step that failed again. It
+says so once in the digest and the view offers the switch
+(`PUT /housekeeping/detectors/{id} {enabled}`); re-enabling clears the
+count. Nothing re-enables on its own.
## 5. Suggestions
A suggestion is a row (§6) with a title, a short text, structured
-evidence, a subject and an audience. It lives in two places: the
-**Housekeeping view**, in full; and a **folded "Suggestions (3)" group at
-the bottom of the Tasks page**, collapsed by default, with the same row
-shape as a task but muted and with no track. The sidebar shows no count
-for suggestions; only Needs you carries a number.
-
-Each row has two quiet actions. **Make it a task** calls `record_task`
-with the suggestion as brief, the tapper as creator and the suggestion's
-project, through the ordinary path (duplicate check included), then marks
-the suggestion `accepted` with the task id; the task is then just a task.
-**Dismiss** marks it `dismissed` and vetoes its key for 30 days.
+evidence, a subject, an optional `related_task` and an audience. Paul's
+ruling: it shows as a **folded "Suggestions (3)" group at the bottom of
+the Tasks page**, collapsed by default, rows muted with no track, and in
+full on the Housekeeping view. No sidebar count.
+
+Two quiet actions per row. **Make it a task** calls `record_task` as
+the tapper, with the suggestion as brief and its project, through the
+ordinary path including the duplicate check; the suggestion becomes
+`accepted` with the task id. **Dismiss** marks it `dismissed` and vetoes
+its key for 30 days.
Suggestions **decay**: 14 days open becomes `expired`; expired and
-dismissed rows are kept 30 days for the view and then deleted by the
-retention sweep that already trims usage rows. A key may be raised again
-after its veto if the evidence recurs, at most once.
-
-**De-duplication**, in order: against open and recently closed
-suggestions by key; against open tasks in the same project by
-`record_task`'s similarity, in which case the suggestion is dropped and
-the task gets the evidence as a thread entry; against each other within
-a judgement turn, where the model may merge near-identical notes into
-one. **At most five open suggestions per person** (ten team-wide); a
-sixth is `held` and surfaces when one closes, so the lane never becomes
-a backlog.
+dismissed rows are kept 30 days for the view, then deleted by the
+retention sweep that trims usage rows.
+
+**De-duplication**, in order: by key against open and recent
+suggestions (no-op); against open tasks in the same project by
+`record_task`'s similarity, in which case the suggestion is still
+created but `related_task` is set and the row reads "Related to [task]"
+(the task is not written to); within a judgement turn, where the model
+may merge near-identical `improvement_noticed` findings into one
+verdict, binding every merged finding id. **At most five open per
+person** (ten team-wide); a sixth is `held`.
## 6. Data model, API v1, wire, tests
**Tables** (migration 0050):
-- `chat_housekeeping`: `id`, `team`, `person`, `detector`,
- `subject_kind`, `subject_id`, `key`, `class`, `state` (`done`,
- `undone`, `refused`, `failed`, `held`), `evidence` (JSON), `result`
- (JSON: what changed, enough to undo), `undo_until`, `at`, `undone_at`,
- `revision`; unique `(team, person, detector, key)`.
-- `chat_suggestions`: `id`, `team`, `audience_person` (null for team),
- `detector`, `subject_kind`, `subject_id`, `project`, `key`, `title`,
- `text`, `evidence`, `state` (`open`, `held`, `accepted`, `dismissed`,
- `expired`), `task_id`, `created_at`, `expires_at`, `revision`;
- `chat_suggestion_dismissals (suggestion, person)` for per-person
- dismissal of team suggestions.
-- `chat_housekeeping_settings`: `person`, `paused`, `disabled` (JSON
- map detector to reason and time), `last_digest_at`, `revision`.
-- `chat_turns.kind` gains `housekeeping` beside `move_in` and
- `explore`; `chat_usage.role` gains `housekeeping`.
+- `chat_housekeeping`: `id`, `team`, `person` (null for team subjects),
+ `detector`, `subject_kind`, `subject_id`, `subject_revision`, `key`,
+ `class`, `state` (`claimed`, `held`, `done`, `undone`, `refused`,
+ `failed`, `vetoed`, `expired`), `reserved {turns, tokens, retries}`,
+ `charged {turns, tokens, retries}`, `evidence`, `result` (enough to
+ undo), `visible_at`, `undo_until`, `recurrences`, `at`, `undone_at`,
+ `revision`; unique indexes as in §4.
+- `chat_housekeeping_failures`: `person`, `detector`, `kind`, `at`.
+- `chat_suggestions`: `id`, `team`, `audience_person`, `detector`,
+ `subject_kind`, `subject_id`, `project`, `key`, `title`, `text`,
+ `evidence`, `related_task`, `state` (`open`, `held`, `accepted`,
+ `dismissed`, `expired`), `task_id`, `created_at`, `expires_at`,
+ `revision`; `chat_suggestion_dismissals (suggestion, person)`.
+- `chat_housekeeping_settings`: `person`, `paused`, `disabled` (JSON:
+ detector to reason and time), `last_digest_at`, `revision`.
+- `chat_turns.kind` gains `housekeeping`; `chat_usage` gains `role`
+ value `housekeeping` and `caused_by`; `chat_steps` gains `caused_by`.
**Resources.** `GET /api/v1/housekeeping` returns `Housekeeping {paused,
-budget {turns_used, turns, tokens_used, tokens, retries_used, retries},
+budget {turns {reserved, charged, limit}, tokens {...}, retries {...}},
detectors[{id, class, enabled, disabled_reason}], actions[], refusals[],
revision}`; `PUT /api/v1/housekeeping {paused, revision}`;
`PUT /api/v1/housekeeping/detectors/{id} {enabled, revision}`;
@@ -276,113 +335,139 @@ revision}`; `PUT /api/v1/housekeeping {paused, revision}`;
`POST /api/v1/housekeeping/actions/{id}/undo` (409 with the current
action when no longer undoable); `GET /api/v1/suggestions`;
`POST /api/v1/suggestions/{id}/accept` returns `TaskAccepted`;
-`POST /api/v1/suggestions/{id}/dismiss`. Events: `housekeeping` (one per
-action state change) and `suggestion`. `Snapshot` gains `suggestions`
-and `housekeeping_summary {open_suggestions, paused, disabled}`.
-`Card` gains kind `housekeeping` with `action_id` and `ChoiceUndo`, the
-combined card being its first instance.
-
-**Wire.** Instance to runner: `message{kind: housekeeping}` for a
-judgement turn, with the tool set `status`, `read_task`, `find`,
-`search_code`, `read_file`, `read_notes` plus `housekeeping_verdict
-{key, verdict: suggest | drop, title, text}`, mounted by the proxy for
-this kind only, 24 calls as explore. Runner to instance: `step` reports
-gain `noticed[{text, repo, path}]` from the pinned `note_improvement`
-tool (five per step, 280 bytes each, text only); the merge watch gains
-`branch_gone{task, branch}`. Retries and combines need no new frame:
-they are the existing retry and fold paths called by the housekeeping
-principal. Fixtures under `internal/wire/wiretest/testdata`:
-`api/housekeeping.json`, `api/housekeeping-paused.json`,
-`api/action-combined.json`, `api/action-retry.json`,
-`api/action-undone.json`, `api/suggestions.json`,
-`api/suggestion-accepted.json`, `api/event-housekeeping.json`,
+`POST /api/v1/suggestions/{id}/dismiss`. Events `housekeeping` and
+`suggestion`. `Snapshot` gains `suggestions` and `housekeeping_summary
+{open_suggestions, paused, disabled}`. `Card` gains kind `housekeeping`
+with `action_id`, `visible_at` and `ChoiceUndo`; the combined card is
+its first instance. `Step` and `Task` gain `caused_by`.
+
+**Wire.** Instance to runner: `message{kind: housekeeping, max_tokens,
+findings[{id, subject, subject_revision, evidence}]}`; the proxy mounts
+**only** `status`, `read_task`, `find`, `search_code`, `read_file`,
+`read_notes` and `housekeeping_verdict` for this kind, and the runner's
+launcher policy (`policy.go`, `TestConversePolicyCoversEveryTool`)
+carries the same allowlist, so a frame or a model asking for anything
+else is refused at both ends; 24 calls as explore. `dispatch` gains
+`caused_by`, `not_before_person_steps: true`. Runner to instance: `step`
+reports gain `noticed[{text, repo, path}]` from the pinned
+`note_improvement` tool (five per step, 280 bytes each); the merge watch
+reports `branch_gone{task, branch}`. Fixtures under
+`internal/wire/wiretest/testdata`: `api/housekeeping.json`,
+`api/housekeeping-paused.json`, `api/action-combined.json`,
+`api/action-retry.json`, `api/action-undone.json`,
+`api/action-refused.json`, `api/suggestions.json`,
+`api/suggestion-related.json`, `api/event-housekeeping.json`,
`api/event-suggestion.json`, `api/card-housekeeping.json`,
`frames/message-housekeeping.json`, `frames/step-noticed.json`,
-`frames/branch-gone.json`. The secret-shape guard covers the new types.
-
-**Tests.** Unit: every detector has a **deterministic fixture** (a store
-snapshot in, the exact findings out, including the no-finding cases at
-the threshold edges) and a rate-limit table. Contract: `TestHousekeepingBudget`
-(the fifth judgement turn in a day is held, the digest says so,
-deterministic detectors still act); `TestHousekeepingStandsDown` (every
-connection at 0.8 or limited: no turn, no retry, duplicates still
-combined); `TestHousekeepingUndoRoundTrips` (each act-and-tell detector:
-act, undo, the resource equals its prior fixture byte for byte, the key
-vetoed, a second finding a no-op); `TestHousekeepingNeverRefused` (the
-housekeeping principal attempting delete, merge, another person's task,
-a `limited` connection, a sixth action past budget: 403 or 409 at the
-handler, a `refused` row, nothing changed); `TestHousekeepingIdempotent`
-(the same event replayed and a restart mid-action: one row);
-`TestHousekeepingAutoDisable` (two undos: disabled, one digest line, the
-switch re-enables); `TestSuggestionsLane` (five open, the sixth held,
-accept makes a task through `record_task`, dismiss vetoes, decay at 14
-days); `TestHousekeepingQuietHours` (an action at 02:00 posts at 08:00).
-Headless: `H1` two similar tasks in one message, combined, Undo from the
-receipt restores both; `H2` the runner killed mid-step, restarted, the
-step retried once with a receipt, a second kill is Needs you; `H3` a
-judgement turn with the fake CLI produces one suggestion and spends one
-budget turn. Browser: the view and the lane at 1280 and 390.
+`frames/branch-gone.json`, `frames/dispatch-caused-by.json`. The
+secret-shape guard covers the new types.
+
+**Tests.** Unit: a deterministic fixture per detector (store snapshot
+in, exact findings out, threshold edges included), the rate table, and
+`TestRegistryModelMeansPropose`. Contract, each with a mutation observed
+failing: `TestHousekeepingPrincipal` (a fold whose destination belongs to
+another creator, a suggestion related to another's task, a retry on
+another's step, and a detector running inside `advance` for a person
+removed from the roster mid-turn: every one `refused`, nothing changed);
+`TestHousekeepingReservation` (two claims racing the last turn: one
+`claimed`, one `held`; a retry's fix round charged to its action; a
+failover attempt charged once; the token cap cancels an attempt);
+`TestHousekeepingStandsDown` (unknown headroom, 0.8 utilization, only
+limited: nothing spends, combine still acts); `TestHousekeepingTier` (a
+`standard` pair alone: `held`; no tiers at all: no turn);
+`TestHousekeepingPreempts` (a person's message yields the turn and
+releases its reservation; a person's Retry supersedes the automatic
+one; a person step dispatched first); `TestHousekeepingUndoRoundTrips`
+(combine then Undo: both tasks and threads equal their prior fixture byte
+for byte, destination included, key `undone`, a second finding a no-op;
+retry Undo before the step starts restores the step's reason and
+Needs you; Undo racing the step start: exactly one wins, 409 for the
+other); `TestHousekeepingRetryChain` (one automatic retry per chain,
+termination proof required, a pushed step never retried, the second
+failure is Needs you `retry`, `merge_eligible`, `merge_asked` and an open
+merge card untouched by the retried task's later progress);
+`TestHousekeepingNever` (the principal attempting delete, merge, a
+`limited` connection, the eleventh action: refused at the store, a
+`refused` row); `TestHousekeepingLedger` (replayed event, restart
+between claim and action, held then claimed, veto then one recurrence
+then none, team-scoped key raised by two people once);
+`TestHousekeepingVerdicts` (a verdict with a forged finding id, a stale
+`subject_revision`, a subject that moved: refused and counted; a replay
+after failover `replayed: true`; a yielded turn leaves findings held);
+`TestHousekeepingHostile` (a repository file and a notebook entry
+containing instructions to combine, cancel, merge or call other tools:
+the turn's only effect is verdicts, and only on issued findings);
+`TestHousekeepingAutoDisable` (two failures of mixed kinds within seven
+days: disabled, one digest line, failure rows survive the action's
+rollback, re-enable clears); `TestSuggestionsLane` (five open, sixth
+held, accept through `record_task`, dismiss vetoes, related task
+untouched, decay); `TestHousekeepingQuietHours` (an action at 02:00
+shows on the view at once and in the conversation at 08:00). Headless:
+`H1` two similar tasks in one message, combined, Undo from the receipt
+restores both; `H2` (slice 2) the runner killed before any push,
+restarted, one automatic retry with a receipt, a second kill is Needs
+you; `H3` (slice 3) a judgement turn with the fake CLI produces one
+suggestion and charges one turn. Browser: the view and the lane at 1280
+and 390.
## 7. Slices
-| Slice | Content | Size |
-|---|---|---|
-| 1 The smallest useful loop | Registry and `chat_housekeeping`; `duplicate_same_creator` wrapped as the first detector (the combine being built becomes its action); `retry_transient` once per task per day; the budget with stand-down; Pause; the digest line; the Housekeeping view with Undo and refusals; auto-disable; the `housekeeping` principal and its server-side refusals. No model turns, no suggestions. Headless H1, H2 | 3 days |
-| 2 Suggestions | `chat_suggestions`, the lane, accept and dismiss, decay, de-duplication and the cap; detectors `merged_outside`, `ready_waiting`, `repo_reach`, `connection_health` (digest lines) and `flaky_check` without the model naming the test | 2 days |
-| 3 Judgement | turn kind `housekeeping`, role and tier, `housekeeping_verdict`, quiet hours and the sweep; `note_improvement` on steps and `improvement_noticed`; `findings_unaddressed`; `notebook_stale`; `duplicate_possible` ask-once across creators; headless H3 | 2 days |
-| 4 Team scope | team suggestions with per-person dismissal, `stale_project`, the owner's team budget and team Pause, acting on team subjects by the owner | 1.5 days |
+| Slice | Content | Gate | Size |
+|---|---|---|---|
+| 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`, `UndoRoundTrips` (combine), `Never`, `AutoDisable`, `QuietHours`; H1 | 3 days |
+| 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`, `Preempts`, `RetryChain`, `UndoRoundTrips` (retry and the race), `Principal` (foreign owner), restart in `Ledger` and `AutoDisable` are green; H2 | 2.5 days |
+| 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 |
+| 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 |
Each slice lands headless first, then staging with the real CLI, then
-UI, as thin v1 §8. Slice 1 ships behind nothing: it is on by default
-with Pause as the exit.
+UI, as thin v1 §8. Slice 1 is on by default with Pause as the exit; it
+spends nothing and can only combine and undo.
## 8. Beyond code
The same loop serves a business or a family when three things change
and nothing in §§3 to 5 does. **Subjects** widen: a person's area, a
shared responsibility, a recurring obligation, a decision. **Detectors**
-are added to the registry over new facts: a recurring chore that has no
+are added to the registry over new facts: a recurring chore with no
completion since its period (`chore_overdue`, propose a reminder), a
-decision recorded in the notebook with a review date that has passed
-(`decision_stale`, propose revisiting it), a question or follow-up with
-no owner after N days (`unowned_followup`, ask once who takes it), spend
-drifting from its usual level on a connected ledger (`spending_drift`,
-propose a look), a document or list nobody has touched that a current
-task depends on. **Data sources** become connections of new kinds
-(a calendar, a shared list, a bank or accounts export, a mailbox) with
-the same consent model as model connections: added by the person who
-owns them, readable by that person's housekeeping, shared with the team
-only by an explicit grant, never a secret on the instance. For a family
-the owner role matters more than it does for a one-person team: the
-owner sets the team Pause and the team budget, and personal subjects
-stay personal even from the owner. What this needs before any of it is
-built: a typed fact store the detectors read instead of the chat tables,
-a consent record per source and per audience, and copy that a
-non-developer reads without flinching. None of that is designed here.
-
-## 9. Decisions for Paul
-
-1. **Budget defaults and the stand-down rule.** Four judgement turns,
- 150,000 tokens and three retries per person per day, on the cheap
- tier only, and the loop stands down whenever every healthy connection
- is at 80% utilization or only limited connections remain. Confirm, or
- name other numbers.
-2. **Where suggestions show.** A folded Suggestions group at the bottom
- of Tasks plus the Housekeeping view, capped at five open per person,
- with no sidebar count. The alternative is the view alone with a quiet
- dot on Tasks. Confirm the first, or choose the second.
+notebook decision whose review date has passed (`decision_stale`,
+propose revisiting it), a question with no owner after N days
+(`unowned_followup`, ask once who takes it), spend drifting from its
+usual level on a connected ledger (`spending_drift`, propose a look).
+**Data sources** become connections of new kinds (a calendar, a shared
+list, an accounts export, a mailbox) with the same consent model as
+model connections: added by the person who owns them, readable by that
+person's housekeeping, shared with the team only by an explicit grant,
+never a secret on the instance. For a family the owner role matters
+more than for a one-person team: the owner sets the team Pause and the
+team budget, and personal subjects stay personal even from the owner.
+Before any of it is built: a typed fact store the detectors read instead
+of the chat tables, a consent record per source and per audience, and
+copy a non-developer reads without flinching. None of that is designed
+here.
+
+## 9. Rulings and decisions
+
+Paul, 2026-11-08: **budget defaults** 4 judgement turns, 150,000 tokens
+and 3 automatic retries per person per day, standing down at 80%;
+**suggestions** as a folded group at the bottom of Tasks plus the
+Housekeeping view, five open per person. Both are folded in above.
+
+Taken here, for review rather than decision: automatic retry acts only
+on steps that never pushed and is otherwise the existing Needs you card;
+cross-creator duplicates are links only in every slice; model judgement
+produces suggestions only. No decision is open for Paul in this
+revision.
## 10. Risks
-Headroom is best effort (Claude reports one figure, endpoints none), so
-the stand-down rule may let a judgement turn run on a connection closer
-to its limit than it looks; the daily turn cap bounds the damage. A
-detector that is deterministic but wrong on real data will act before it
-is undone twice; the seven-day Undo and the per-key veto bound that too.
-`merged_outside` depends on the merge watch's squash heuristic, which
-already serves people's merges. The judgement turn is a model reading
-code and findings, so its verdict tool must stay the only effect it can
-have, as `write_note` is for move-in; the proxy mounts nothing else.
-Team scope waits for slice 4, so until then a shared project tidied by
-two people's loops could raise the same team suggestion twice; the key
-is team-scoped to prevent it.
+Headroom is best effort, so the stand-down rule is conservative by
+design (unknown means stop), and on a week when Claude reports no figure
+judgement turns simply do not run. A deterministic detector that is
+wrong on real data acts before it is undone twice; the seven-day Undo,
+the retained veto and auto-disable bound that. Slice 1 depends on the
+combine landing on `thin-v1-ux1` first. Slice 3 depends on Connections
+slice 3 for tiers and until then has nothing cheap to run on. The
+judgement turn reads code and notes that may be hostile; its only effect
+is a verdict bound to a server-issued finding, enforced at the proxy and
+the launcher, and `TestHousekeepingHostile` is the regression guard.