Astra round 1, findings 5 to 7: Pause holds receipts; digest schedule
5. Held receipts are not published for a paused person, by the tick or their own message; Resume lets them show. 6. The digest is scheduled through the person's quiet hours as receipts are: one due inside them waits for their end. 7. An empty digest no longer uses up the day: LastDigestAt moves only when a digest is posted or scheduled. Tests that failed first: TestContractHousekeepingPauseHoldsReceipts and TestContractHousekeepingDigestSchedule. HK1-PROGRESS records the round.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+150
−8
docs/superpowers/plans/HK1-PROGRESS.md+26 −0internal/equipo/chat/housekeeping_control.go+28 −8internal/thintest/housekeeping_contract_test.go+96 −0
CI passed — run details
diff --git a/docs/superpowers/plans/HK1-PROGRESS.md b/docs/superpowers/plans/HK1-PROGRESS.md| index b8d672b0..21368422 100644 |
| --- a/docs/superpowers/plans/HK1-PROGRESS.md |
| +++ b/docs/superpowers/plans/HK1-PROGRESS.md |
| @@ -242,6 +242,32 @@ suggestions (the Suggestions lane is not drawn). Conventions as in |
| - Person's zone is UTC everywhere (quiet hours, the day, 03:00, 08:00). |
| - Version skew as before: an old runner is unaffected (no new frames). |
| +## Round: Astra round 1 (on 220a27a), REQUEST CHANGES |
| + |
| +Six Important and one Minor (`~/.cache/tmp/equipo/hk1rev-final.md`), |
| +each with a test that failed first: |
| +1. `saveTask` under the principal authorizes against the stored task's |
| + creator and refuses a changed creator (TestHousekeepingNever: a |
| + forged creator on another's task). |
| +2. The principal never writes a notebook (its own neither cleared nor |
| + replaced) and never saves a card, so `withdrawMergeCards` refuses |
| + (TestHousekeepingNever: own notes, a merge card withdrawn or |
| + resolved). |
| +3. Housekeeping dispatches nothing in slice 1: `hkSpend` refuses |
| + outright; the reservation boundary (live claim, person, membership, |
| + tier, no reuse) is slice 2's (TestHousekeepingNever: dispatch within a |
| + reservation on a healthy connection, a housekeeping turn). |
| +4. The executor checks class against proposal before anything runs: |
| + act combines, link links, propose and ask carry out nothing yet; a |
| + mismatch is a refused row (TestHousekeepingClassActions). |
| +5. Held receipts are not published for a paused person, by the tick or |
| + their message; Resume lets them show |
| + (TestContractHousekeepingPauseHoldsReceipts). |
| +6. The digest is scheduled as receipts are: due in quiet hours, it waits |
| + for their end (TestContractHousekeepingDigestSchedule). |
| +7. An empty digest does not use up the day: `LastDigestAt` moves only |
| + when a digest is posted or scheduled (same test). |
| + |
| ## Copy for review |
| Accepted for now with the existing marker in `copy.go` and listed in the |
diff --git a/internal/equipo/chat/housekeeping_control.go b/internal/equipo/chat/housekeeping_control.go| index aea6f3fb..713b5759 100644 |
| --- a/internal/equipo/chat/housekeeping_control.go |
| +++ b/internal/equipo/chat/housekeeping_control.go |
| @@ -243,8 +243,9 @@ func (t *txn) hkUndone(r *hkRecord) error { |
| // --- Quiet hours. |
| -// hkRelease shows a person's held receipts now: their first message ends |
| -// quiet hours for them. |
| +// hkRelease shows held receipts: a person's now (their first message |
| +// ends quiet hours for them), or everyone's whose time has come. Nothing |
| +// is published for a person who is paused; Resume lets it show. |
| func (t *txn) hkRelease(person string, now time.Time) error { |
| var cards []cardRecord |
| q := t.db.Where("held = ?", true) |
| @@ -256,8 +257,20 @@ func (t *txn) hkRelease(person string, now time.Time) error { |
| if err := q.Order("created_at, id").Find(&cards).Error; err != nil { |
| return err |
| } |
| + paused := map[string]bool{} |
| for i := range cards { |
| c := &cards[i] |
| + p, seen := paused[c.Person] |
| + if !seen { |
| + set, err := t.hkSettings(c.Person) |
| + if err != nil { |
| + return err |
| + } |
| + p, paused[c.Person] = set.Paused, set.Paused |
| + } |
| + if p { |
| + continue |
| + } |
| if c.VisibleAt == nil || c.VisibleAt.After(now) { |
| c.VisibleAt = &now |
| } |
| @@ -516,9 +529,10 @@ func (s *Store) sweepDue(ctx context.Context) (due bool, err error) { |
| return due, err |
| } |
| -// digest writes the person's one line a day, from 08:00 in their zone, |
| -// when something happened since the last: what was tidied, a detector |
| -// switched off, a stand-down. Never while paused. |
| +// digest writes the person's one line a day, from the end of their quiet |
| +// hours, when something happened since the last: what was tidied, a |
| +// detector switched off, a stand-down. Never while paused; one due inside |
| +// quiet hours waits for their end, as receipts do. |
| func (t *txn) digest(person string) error { |
| set, err := t.hkSettings(person) |
| if err != nil || set.Paused { |
| @@ -563,14 +577,20 @@ func (t *txn) digest(person string) error { |
| } else if slices.Contains(stood, wire.ReasonHeldStandDown) { |
| parts = append(parts, t.words("chat.housekeeping.stood_down_limit")) |
| } |
| + // Nothing to say keeps the day's digest for later. |
| + if len(parts) == 0 { |
| + return nil |
| + } |
| set.LastDigestAt = &now |
| if err := t.saveSettings(&set); err != nil { |
| return err |
| } |
| - if len(parts) == 0 { |
| - return nil |
| + // Scheduled as receipts are: in quiet hours it waits for their end. |
| + visible, held := &now, false |
| + if at := set.quiet().VisibleAt(now, loc); at != nil { |
| + visible, held = at, true |
| } |
| - c := cardRecord{ID: newID("c_"), Person: person, Kind: wire.CardHousekeeping, State: wire.CardDigest, Question: strings.Join(parts, " "), Options: "[]", Revision: 1, CreatedAt: now, UpdatedAt: now, VisibleAt: &now} |
| + c := cardRecord{ID: newID("c_"), Person: person, Kind: wire.CardHousekeeping, State: wire.CardDigest, Question: strings.Join(parts, " "), Options: "[]", Revision: 1, CreatedAt: now, UpdatedAt: now, VisibleAt: visible, Held: held} |
| if err := t.db.Create(&c).Error; err != nil { |
| return err |
| } |
diff --git a/internal/thintest/housekeeping_contract_test.go b/internal/thintest/housekeeping_contract_test.go| index 6740b56a..4d538ece 100644 |
| --- a/internal/thintest/housekeeping_contract_test.go |
| +++ b/internal/thintest/housekeeping_contract_test.go |
| @@ -533,3 +533,99 @@ func TestContractHousekeepingRestartWhileClaimed(t *testing.T) { |
| t.Fatalf("dispatched claim: %s", s) |
| } |
| } |
| + |
| +// digests are the digest lines in the person's conversation. |
| +func (r *toolRig) digests() []wire.Card { |
| + r.t.Helper() |
| + var out []wire.Card |
| + for _, c := range r.snapshotCards() { |
| + if c.Kind == wire.CardHousekeeping { |
| + out = append(out, c) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// TestContractHousekeepingPauseHoldsReceipts (Astra round 1, finding 5): |
| +// a receipt held through quiet hours stays held while its person is |
| +// paused, at 08:00 and when they write; Resume lets it show. |
| +func TestContractHousekeepingPauseHoldsReceipts(t *testing.T) { |
| + r := newToolRig(t) |
| + day := time.Now().UTC().Truncate(24 * time.Hour) |
| + r.clock(day.Add(2 * time.Hour)) |
| + _, fold := r.pair("ph", "Swipe back from the edge doesn't work") |
| + if n := r.tidy(); n != 1 { |
| + t.Fatalf("combined %d", n) |
| + } |
| + a := r.action(fold) |
| + shown := func() bool { |
| + for _, c := range r.snapshotCards() { |
| + if c.ActionID == a.ID { |
| + return true |
| + } |
| + } |
| + return false |
| + } |
| + r.clock(day.Add(3 * time.Hour)) |
| + h, err := r.client.SetHousekeeping(r.ctx, true, r.housekeeping().Revision) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + r.clock(day.Add(8 * time.Hour)) |
| + r.tick() |
| + if shown() { |
| + t.Fatal("published at 08:00 while paused") |
| + } |
| + if _, err := r.client.Send(r.ctx, "Morning", "ph-msg"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if shown() { |
| + t.Fatal("published by the person's message while paused") |
| + } |
| + if _, err := r.client.SetHousekeeping(r.ctx, false, h.Revision); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.tick() |
| + if !shown() { |
| + t.Fatal("not shown after Resume") |
| + } |
| +} |
| + |
| +// TestContractHousekeepingDigestSchedule (Astra round 1, findings 6 and |
| +// 7): an empty morning does not use up the day's digest, so a later |
| +// action still gets one that day; a digest due in quiet hours waits for |
| +// them to end, as receipts do, and is posted once. |
| +func TestContractHousekeepingDigestSchedule(t *testing.T) { |
| + r := newToolRig(t) |
| + day := time.Now().UTC().Truncate(24 * time.Hour) |
| + r.clock(day.Add(8*time.Hour + 30*time.Minute)) |
| + r.tick() |
| + if d := r.digests(); len(d) != 0 { |
| + t.Fatalf("a digest with nothing to say: %+v", d) |
| + } |
| + r.clock(day.Add(9 * time.Hour)) |
| + r.pair("d1", "Swipe back from the edge doesn't work") |
| + r.tidy() |
| + r.clock(day.Add(9*time.Hour + 30*time.Minute)) |
| + r.tick() |
| + if d := r.digests(); len(d) != 1 || !strings.Contains(d[0].Question, "Tidied 1 thing.") { |
| + t.Fatalf("the empty morning used up the day: %+v", d) |
| + } |
| + // The next day, nothing ticks until 23:00, after an action at 22:30: |
| + // the digest waits for 08:00. |
| + r.clock(day.Add(46*time.Hour + 30*time.Minute)) |
| + r.pair("d2", "Timeline jumps when images load") |
| + r.tidy() |
| + r.clock(day.Add(47 * time.Hour)) |
| + r.tick() |
| + if d := r.digests(); len(d) != 1 { |
| + t.Fatalf("a digest in quiet hours: %+v", d) |
| + } |
| + r.clock(day.Add(56 * time.Hour)) |
| + r.tick() |
| + r.tick() |
| + d := r.digests() |
| + if len(d) != 2 || d[1].VisibleAt == nil || !d[1].VisibleAt.Equal(day.Add(56*time.Hour)) { |
| + t.Fatalf("the held digest at 08:00: %+v", d) |
| + } |
| +} |