oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Housekeeping slice 1 progress: the smallest useful loop
2
3Branch `thin-v1-hk1` from `thin-v1-conn1` (fa3860a, then staging's line
4`thin-v1-ux1` at f2602d3 merged: final Connections fixes, thinking-word
5themes; no migration clash, housekeeping stays 0052;
6with UX1's reversible combine cceab55), with `design-housekeeping`
7merged (3aa3fb4, rev 3 accepted). Spec:
8`docs/superpowers/specs/2026-11-08-equipo-housekeeping.md` §7 slice 1,
9plus the controller's brief: budget reservation with Paul's defaults
10(4 turns, 150,000 tokens, 3 retries per person per day, stand down at
110.8 on the selected connection, unknown is stand down) and the API v1
12resources. Not in this slice: automatic retries, judgement turns,
13suggestions (the Suggestions lane is not drawn). Conventions as in
14`SLICE1-PROGRESS.md` to `CONN1-PROGRESS.md` and `UX1-PROGRESS.md`.
15
16## Done
17
181. Registry (`internal/equipo/housekeeping`, pure): a detector declares
19 id, subject kind, class (`act`, `link`, `propose`, `ask`), triggers,
20 judgement, rate, cost and `Detect(View) []Finding`. `New` refuses a
21 judgement detector that is not `propose`, an unknown class, a missing
22 trigger or Detect, a repeated id. `Default()` is slice 1:
23 `duplicate_same_creator` (act: combine) and `duplicate_possible`
24 (link: "Possible duplicate of"), over record_task's similarity
25 (`Significant`, `Overlap` moved here; chat uses them) and UX1's
26 thresholds as constants beside the detectors. Findings carry subject,
27 owner, subject revision, key (`duplicate:tkA:tkB`,
28 `possible:tkB:tkA`), structured evidence and the proposal. Policy:
29 `Limits`, `JudgementTurn`, `AutoRetry`, `Fits`, `StandDown`,
30 `VisibleAt` (22:00 to 08:00), `DayStart`, ceilings. Team-scoped
31 throughout: a team subject has no owner and keys on `(team, "",
32 detector, key)`.
33
342. Ledger (`chat_housekeeping`, migration 0052; `chat/housekeeping.go`):
35 rows only move forward (`claimed`, `held`, `done`, `undone`,
36 `refused`, `failed`, `vetoed`, `expired`), unique on `(team, person,
37 detector, finding_key)`. A key that exists is a no-op unless held,
38 failed once, vetoed past 30 days with its one recurrence left, or
39 expired because its subject moved. A free deterministic action claims
40 and acts in one transaction, the action in a savepoint: a refusal or
41 an error takes back everything it wrote and leaves only the row. A
42 spending action commits `claimed` with its reservation first (nothing
43 in slice 1 spends). Held: the day's ceiling (ten actions), the budget
44 or stand-down; at most twenty held per person, the oldest expire.
45 `hkSettle` keeps a reservation `releasing` until termination and the
46 charge are in; no figure charges the whole reservation.
47
483. Principal: `Principal{Team, Person, Detector, FindingID, Reserved}`
49 built from the ledger row, carried on the transaction (`txn.hk`) into
50 the shared store functions, which check it inside the transaction:
51 `foldable` (both tasks, the destination too, are the person's and the
52 person is a current member), `saveTask` (own task, no ending, no
53 merging, no `merge_eligible`, `ready_sha`, `merge_asked`, merged
54 fields or cancel), `saveStep`, `dispatchStep` and turn `dispatch`
55 (only within a reservation, on a selected connection that is healthy,
56 reported, fresh and below 0.8), `startMerge`, `askMerge`,
57 `answerMerge`, `cancelTask`, `removeProject` (split out of
58 `RemoveProject`), `writeSetting`, `saveNotebook` (never another
59 person's). Failure is `housekeeping_forbidden` and a `refused` row.
60
614. Budget reservation: the claim sums today's rows for the person in
62 its own transaction (an open reservation in full, else its charge)
63 and holds a claim that would exceed any limit; SQLite serialises the
64 write transactions, so two claims racing the last room cannot both
65 pass. Stand-down reads the connection the choice selects on the
66 instance: the one that answered the person's last turn, else their
67 only one; anything else is unknown and stands down, and no other
68 connection is tried. A combine spends nothing and carries on.
69
705. Control (`chat/housekeeping_control.go`): Pause (`chat_housekeeping_
71 settings`; paused: no detector runs, no sweep, no digest; undispatched
72 claims go back to held, dispatched ones keep releasing; Undo stays).
73 Failures (`chat_housekeeping_failures`) are written after the
74 transaction ends, committed or not; two within seven days (an Undo
75 counts) switch the detector off for the person, said once in the
76 digest; only the person switches it back on, which clears the count.
77 Quiet hours: a receipt made 22:00 to 08:00 (UTC until a zone is
78 known) is held (`chat_cards.held`, `visible_at`): on the view at
79 once, in the conversation at 08:00 or at the person's first message.
80 The digest: one card a day from 08:00 when something happened
81 ("Tidied 2 things." plus a switched-off detector or a stand-down),
82 linking to the view. Recovery: at start-up, and for claims older than
83 ten minutes on the minute tick, a claim with nothing dispatched goes
84 to held if its subject is unchanged, else expires `subject_moved`
85 with its reservation released; a dispatched one waits for sync. The
86 minute tick (`HousekeepingTick`): quiet hours end, recovery, the
87 03:00 sweep (and again while findings are held), the digests.
88
896. Duplicates through the loop: `TidyDuplicates` (start and sweep) and
90 `record_task` run `housekeepingPass`, which re-reads the project
91 after each action. Undo from the view, the receipt and the task page
92 is one path (`unfold`): within seven days, restores the task exactly
93 (stage, thread, findings, its earlier "Possible duplicate of" link
94 from the action's snapshot), removes the fold from the destination,
95 keeps the pair apart and makes the key a retained veto.
96
977. API v1 (`chat/housekeeping_http.go`): `GET /api/v1/housekeeping`,
98 `PUT /api/v1/housekeeping {paused, revision}`, `PUT
99 /api/v1/housekeeping/detectors/{id} {enabled, revision}`, `GET
100 /api/v1/housekeeping/actions?before=&limit=`, `POST
101 /api/v1/housekeeping/actions/{id}/undo` (409 `not_undoable` with the
102 action). Event `housekeeping` (resource `action` or `housekeeping`).
103 `Snapshot.housekeeping_summary`. `Card.action_id`, `Card.visible_at`
104 (omitted when empty), card kind `housekeeping` state `digest`.
105 `TurnHousekeeping` and the queue order (person, then move-in and
106 explore, then housekeeping). Fixtures: `api/housekeeping.json`,
107 `housekeeping-paused.json`, `action-combined.json`,
108 `action-undone.json`, `action-refused.json`,
109 `housekeeping-actions.json`, `housekeeping-request.json`,
110 `detector-request.json`, `action-conflict.json`,
111 `event-housekeeping.json`, `event-housekeeping-summary.json`,
112 `card-housekeeping.json`, `card-digest.json`; `snapshot.json` gains
113 the summary. The secret-shape guard covers the new types and
114 fixtures.
115
1168. The Housekeeping view (`/housekeeping`, the list-checks button beside
117 Notebook in the conversation header; scriptless): a quiet link to
118 Settings for Pause and quiet hours, today's three budgets as quiet meters (reserved and charged), what
119 Equipo did newest first with its evidence ("100% alike, 3 words in
120 common") and Undo while it can ("Undo until 15 Nov"), refusals and
121 failures, the detectors with On/Off and the switch. The digest line
122 in the conversation with its link. Live (Paul dislikes reloads): the
123 view is a work region, nav-stream.js hears `housekeeping` events and
124 work-stream.js swaps it in place; Undo and the switches post in the
125 background (`static/housekeeping.js`), plain posts without scripts.
126
1279. Settings' Housekeeping section (coordinator, 2026-11-08: Pause, the
128 quiet-hours controls and the link to the activity view go in the
129 Settings page's Housekeeping section; nothing in the profile menu).
130 A partial (`templates/housekeeping_settings.html`, `{{template
131 "housekeeping-settings" .HousekeepingSettings}}`) with Pause or
132 Resume, quiet hours (on, from, until in whole hours, UTC until a zone
133 is known) and "See what Equipo did"; posts to
134 `/settings/housekeeping/pause` and `/settings/housekeeping/quiet`. It
135 stands in the Housekeeping section of UX1's Settings page
136 (`/conversation/settings#housekeeping`, merged at 99b19e8), in its
137 row style; the old section at the end of `/settings` is gone. Quiet hours are per
138 person now (`chat_housekeeping_settings.quiet_from`, `quiet_until`,
139 null for 22:00 to 08:00, equal for none; `Housekeeping.quiet`,
140 `SetHousekeeping.quiet`, fixture `housekeeping-quiet-request.json`);
141 the digest waits for the window's end.
142
143## Tests
144
145- Unit (`housekeeping`): `TestDetectorFixtures` (a fixture per
146 detector, `testdata/<id>.json`, thirteen and nine cases with every
147 threshold edge), `TestRegistryModelMeansPropose`, `TestRateTable`,
148 `TestFitsAndStandDown`, `TestQuietHours`.
149- Store (`chat/housekeeping_store_test.go`, the chat tables on a copied
150 template database): `TestHousekeepingPrincipal` (a fold into another
151 person's task, the other way round, a person removed from the roster,
152 a link on another's task: refused, nothing changed),
153 `TestHousekeepingNever` (delete, cancel, end, merge eligibility, Ready
154 SHA, merge, merge card, a setting, another's notebook and task,
155 dispatch without a reservation or on a limited connection; then the
156 same through the ledger as refused rows), `TestHousekeepingReservation`
157 (exhaustion, two claims racing the last room, tokens binding at the
158 third judgement turn, turns at the fifth, settle with unknown and
159 complete usage, Pause releasing), `TestHousekeepingStandsDown` (unknown,
160 0.8, 16 minutes, limited, none selected; no other connection tried; a
161 combine still acts), `TestHousekeepingLedger` (one transaction with
162 the caller, a replayed pass, restart with nothing dispatched, moved,
163 dispatched, the eleventh action held then claimed the next day, veto
164 then one recurrence then none, a team key raised twice, the held cap),
165 `TestHousekeepingAutoDisable` (mixed kinds, rows survive the caller's
166 rollback, nothing re-enables on its own, re-enable clears the count),
167 `TestHousekeepingPreempts` (queue order).
168- Contract (`thintest/housekeeping_contract_test.go`): H1 as
169 `TestContractHousekeepingCombine` (a recorded task's pass combines a
170 pair; view, action, page and summary against the fixtures; a teammate
171 sees none of it and cannot undo it, from the view or the receipt; the
172 seven-day window), `TestContractHousekeepingUndoRoundTrips` (both
173 tasks byte for byte after Undo, destination included; 409 with the
174 action; the veto holds; the view's Undo racing the receipt's: one
175 commits), `TestContractHousekeepingPause`,
176 `TestContractHousekeepingAutoDisable` (two Undos, the digest says it
177 once, re-enable), `TestContractHousekeepingQuietHours` (02:00 action
178 on the view at once and in the conversation at 08:00; 23:00 shown by
179 the person's message; the person's own 12:00 to 14:00 window; none), `TestContractHousekeepingRestartWhileClaimed`
180 (a real restart).
181- Browser (`-tags browser`): `TestBrowserHousekeeping` at 1280 (mouse)
182 and 390 (touch): the header link, the digest line and its link, the
183 view with evidence, three meters, detectors and Undo in reach (44 px on
184 touch), no sideways scrolling; Undo from the view; Settings' section at
185 both sizes, quiet hours saved and shown again, Pause from Settings and
186 the view saying so; live: a new combine, Undo, a switch and a change
187 made from another device land with no reload (the last failed with
188 nav-stream's housekeeping listener removed). It failed
189 first: the page template was not registered (500).
190- Mutations, each observed failing a test (script and output kept under
191 `~/.cache/tmp/equipo-hk1/` while working): the fold destination's owner
192 check (Principal), saveTask's guard (Never), the budget fit (Reservation),
193 the stand-down (StandsDown), recovery's revision compare (Restart), the
194 undone veto (UndoRoundTrips), the seven-day window (Combine), Pause
195 (Pause), the two-failure threshold (AutoDisable), quiet hours on the
196 receipt (QuietHours), release on the person's message (QuietHours), the
197 digest's once (AutoDisable), failures after rollback (AutoDisable,
198 store), the queue order (Preempts), the combine threshold (fixtures),
199 Undo's exact restore (UndoRoundTrips), the day's ceiling (Ledger), the
200 refused row (Principal), the Undo guards together (UndoRoundTrips), and
201 receipts ignoring the person's own window (QuietHours).
202 The secret guard failed first on `copy_key` (allowed by name).
203
204## Decisions
205
206- Thresholds are UX1's as shipped on staging (title 0.75 with three
207 words, or title and brief 0.7 with five; a match at 0.6 with two, or
208 0.5 with three), kept by the controller; the spec's table now says so.
209 They are pinned in the fixtures.
210- The combined receipt keeps its card kind `combined` (native apps and
211 pages already draw it) and gains `action_id` and `visible_at`; the
212 new card kind `housekeeping` is the digest line.
213- `expired` with `subject_moved` is a fresh finding on the new revision
214 (the spec's recovery says "re-run as a fresh finding" for unchanged
215 claims; a moved subject is new facts). Refused keys never act again.
216- The eleventh action of the day is `held` (§4 rate limits), not
217 `refused` (§6's Never list says refused); it acts the next day.
218- `checked_at` for headroom is the connection record's update time (the
219 runner reports headroom at most once a minute).
220- A judgement turn reserves its share of the day's tokens, 150,000 / 4
221 = 37,500 (Paul: four turns must fit), derived from the limits, not a
222 fixed 40,000; the token budget stays the binding total. The spec's
223 §4 says so.
224- `duplicate_possible` links count as actions in the ledger (class
225 `link`) but not toward the ten-a-day ceiling and are not listed on the
226 view; refusals are.
227- A receipt held through quiet hours stands in the conversation at the
228 time it showed. Undone while held, it shows at 08:00 as undone.
229- Pause also suspends the digest; the view and Undo stay.
230- Undo's seven-day window applies to the receipt and the task page's
231 Undo too (409), for folds the ledger made; older UX1 folds keep their
232 open Undo.
233
234## Open issues
235
236- H1 is at contract level (fake runner frames). In a real conversation a
237 same-person look-alike is answered by record_task's similar result or
238 recorded `separate` (kept apart), so the combine acts on pairs filed
239 before Equipo looked or after an Undo's pair is forgotten; the headless
240 bwrap form of H1 is not built.
241- Person's zone is UTC everywhere (quiet hours, the day, 03:00, 08:00).
242- Version skew as before: an old runner is unaffected (no new frames).
243
244## Round: Astra round 1 (on 220a27a), REQUEST CHANGES
245
246Six Important and one Minor (`~/.cache/tmp/equipo/hk1rev-final.md`),
247each with a test that failed first:
2481. `saveTask` under the principal authorizes against the stored task's
249 creator and refuses a changed creator (TestHousekeepingNever: a
250 forged creator on another's task).
2512. The principal never writes a notebook (its own neither cleared nor
252 replaced) and never saves a card, so `withdrawMergeCards` refuses
253 (TestHousekeepingNever: own notes, a merge card withdrawn or
254 resolved).
2553. Housekeeping dispatches nothing in slice 1: `hkSpend` refuses
256 outright; the reservation boundary (live claim, person, membership,
257 tier, no reuse) is slice 2's (TestHousekeepingNever: dispatch within a
258 reservation on a healthy connection, a housekeeping turn).
2594. The executor checks class against proposal before anything runs:
260 act combines, link links, propose and ask carry out nothing yet; a
261 mismatch is a refused row (TestHousekeepingClassActions).
2625. Held receipts are not published for a paused person, by the tick or
263 their message; Resume lets them show
264 (TestContractHousekeepingPauseHoldsReceipts).
2656. The digest is scheduled as receipts are: due in quiet hours, it waits
266 for their end (TestContractHousekeepingDigestSchedule).
2677. An empty digest does not use up the day: `LastDigestAt` moves only
268 when a digest is posted or scheduled (same test).
269
270## Copy for review
271
272Accepted for now with the existing marker in `copy.go` and listed in the
273plan 3 inventory ("Housekeeping slice 1"):
274- Conversation: `chat.housekeeping.link` "Housekeeping",
275 `.digest_one` "Tidied 1 thing.", `.digest` "Tidied %d things.",
276 `.digest_disabled` "Stopped %s after two Undos or failures this week.",
277 `.detector.duplicate_same_creator` "combining duplicate tasks",
278 `.detector.duplicate_possible` "naming possible duplicates",
279 `.stood_down_budget` "Housekeeping stood down: today's budget is
280 used.", `.stood_down_limit` "Housekeeping stood down: the connection is
281 near its limit."
282- View: `housekeeping.title` "Housekeeping", `.lede` "Equipo tidies your
283 work on its own. Everything it does is listed here, and you can undo
284 it.", `.pause` "Pause", `.resume` "Resume", `.paused` "Paused. Nothing
285 is tidied until you resume.", `.today` "Today", `.meter.turns`
286 "Judgement turns", `.meter.tokens` "Tokens", `.meter.retries`
287 "Automatic retries", `.meter.used` "%s of %s", `.meter.held` "%s
288 held", `.actions` "What Equipo did", `.actions_empty` "Nothing yet.
289 When Equipo tidies something, it shows here.", `.action.combine`
290 "Combined “%s” into “%s”", `.action.link` "Named “%s” a possible
291 duplicate of “%s”", `.evidence` "%d%% alike, %d words in common",
292 `.state.undone` "Undone", `.state.refused` "Refused: not Equipo's to
293 change", `.state.failed` "Failed", `.held.ceiling` "Waiting: ten things
294 tidied today already", `.held.budget` "Waiting: today's budget is
295 used", `.held.stand_down` "Waiting: the connection is near its limit",
296 `.held.held_overflow` "Dropped: too many waiting", `.until` "Undo until
297 %s", `.undo` "Undo", `.refusals` "Refused and failed", `.detectors`
298 "What Equipo looks for", `.detector.duplicate_same_creator` "Combine
299 duplicate tasks", `.detector.duplicate_possible` "Name possible
300 duplicates", `.detector.failures` "Off after two Undos or failures this
301 week.", `.on` "On", `.off` "Off", `.turn_on` "Turn on", `.turn_off`
302 "Turn off"
303- Settings: `housekeeping.settings.lede` "Equipo tidies your work on
304 its own. Pause it, or choose when its receipts wait.", `.quiet` "Quiet
305 hours", `.quiet_hint` "Receipts made in these hours wait until they
306 end, or until you next write. Times are UTC.", `.quiet_on` "Hold
307 receipts during quiet hours", `.from` "From", `.until` "Until",
308 `.activity` "See what Equipo did"; on the view
309 `housekeeping.settings_link` "Pause and quiet hours are in Settings"
310- API: `api.not_undoable` "This can no longer be undone."
311- Logs: `copyHousekeepingTick` "Could not run housekeeping.",
312 `copyHousekeepingClaims` "Revalidated housekeeping claims."
313
314## Staging
315
316Not restaged (the controller sequences it). No live provider runs: slice
3171 spends nothing.
318
319## Blockers
320
321None.
322