equipo: Task 20 review 1, no charge for an empty fractional span
Allocate returns nothing when to is not after from, checked before it widens to whole seconds, so equal fractional times no longer charge a second. Assertions for fractional equal and reversed spans; budget record raised for internal/equipo/chat.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+25
−5
.rastrillo/budgets.txt+1 −1docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md+11 −0internal/equipo/chat/hosted_limits.go+5 −2internal/equipo/chat/hosted_limits_test.go+8 −2
CI failed — run details
CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/hosted-runners-2: Type Size Avail | ext4 96G 84G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type Size Avail | ext4 96G 84G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 2.4s
ci-box: codex: fetched and verified in 4.8s
ci-box: codex-code-mode-host: fetched and verified in 1.6s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.7s
ci-box: pi: installed and verified in 7.6s
ci-box: opencode: installed and verified in 2.2s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 8.6s
ci-box: clone deepened in 5.6s
ci-box: file times set from content: 3894 files, 271 directories
ci-box: ready in 20.6s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
--- FAIL: TestReleaseCopyReviewed (0.09s)
task_pages_test.go:236: COPY REVIEW REQUIRED: copy-status.py verify found copy pending review or stale bookkeeping
FAIL
rastrillo-budget/v1 ran 87ms
FAIL amadan.net/oficina/equipo/internal/equipotest 0.238s
FAIL
make: *** [Makefile:273: copy-release-check] Error 1
amadan: step copy failed: exit status 2
amadan: job failed at step copy — its output is above, not at the tail of this log
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index dd8f1b4b..4421ea13 100644 |
| --- a/.rastrillo/budgets.txt |
| +++ b/.rastrillo/budgets.txt |
| @@ -59,7 +59,7 @@ perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON |
| perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen. |
| perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen. |
| perf GET /api/v1/assistant/abilities skip Assistant person API: bearer-only JSON for Base's Settings line, not a browser screen. |
| -size internal/equipo/chat 46022 20284 File facts/diffs, previews, merges, unfinished work, CI, receipts, Assistant files, places, abilities, lookups, go-aheads, Mac work, D1, Design specialists, grants, captures; 45093/18782. Hosted slice 2 Task 15: openHostedPack (the instance's send_pack for a hosted pack) and its test; 45105/18883. Its review round 1 added the report-ingestion test for pack_incomplete; 45105/18911. Task 18: hosted_setting.go (SetHostedChecks, hostedChecks, HostedSettings; owner only, roster in the transaction, audited) and its tests; 45208/19070. Its review round 1: the audit atomicity test; 45208/19113. Task 19: hosted_jobs.go (the hosted_jobs and hosted_challenges tables, HostedJob and its lifecycle: newHostedJob, the listed moves only, ended and failed only with stop proof or never-launched evidence, settleHostedJob once, hostedJobForRunner; each move audited in its transaction) and its tests, TestMigrationAdditive included; 45658/19577. Its review round 1: the never-launched evidence contract (HostedNeverLaunched, launch_by and launching_since, hostedLaunchReturned) and tests for it, settlement of unproven terminal records and audit atomicity; 45728/19739. Task 20: hosted_limits.go (per-person hosted limits, S2-9: hostedAdmit held in the write by a per-person lock row, hostedHoldFor, Allocate, hostedSettle at 4x the baseline, SetHostedLimits owner only with the roster, revision and audit in the transaction) and its tests; 46013/20214. Its coordinator ruling: a limit counts only while its setting owner is a current owner (defaults otherwise, checked in the admission transaction) and TestOwnerRaisesLimitRevoked; 46022/20284. |
| +size internal/equipo/chat 46025 20290 File facts/diffs, previews, merges, unfinished work, CI, receipts, Assistant files, places, abilities, lookups, go-aheads, Mac work, D1, Design specialists, grants, captures; 45093/18782. Hosted slice 2 Task 15: openHostedPack (the instance's send_pack for a hosted pack) and its test; 45105/18883. Its review round 1 added the report-ingestion test for pack_incomplete; 45105/18911. Task 18: hosted_setting.go (SetHostedChecks, hostedChecks, HostedSettings; owner only, roster in the transaction, audited) and its tests; 45208/19070. Its review round 1: the audit atomicity test; 45208/19113. Task 19: hosted_jobs.go (the hosted_jobs and hosted_challenges tables, HostedJob and its lifecycle: newHostedJob, the listed moves only, ended and failed only with stop proof or never-launched evidence, settleHostedJob once, hostedJobForRunner; each move audited in its transaction) and its tests, TestMigrationAdditive included; 45658/19577. Its review round 1: the never-launched evidence contract (HostedNeverLaunched, launch_by and launching_since, hostedLaunchReturned) and tests for it, settlement of unproven terminal records and audit atomicity; 45728/19739. Task 20: hosted_limits.go (per-person hosted limits, S2-9: hostedAdmit held in the write by a per-person lock row, hostedHoldFor, Allocate, hostedSettle at 4x the baseline, SetHostedLimits owner only with the roster, revision and audit in the transaction) and its tests; 46013/20214. Its coordinator ruling: a limit counts only while its setting owner is a current owner (defaults otherwise, checked in the admission transaction) and TestOwnerRaisesLimitRevoked; 46022/20284. Its review round 1: Allocate returns nothing for an empty or reversed span before widening, and its assertions; 46025/20290. |
| perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}. |
| perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}. |
| perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections. |
diff --git a/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md b/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md| index 73fd720a..060c0ee6 100644 |
| --- a/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md |
| +++ b/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md |
| @@ -1537,3 +1537,14 @@ Green: `CGO_ENABLED=0 go test ./internal/equipo/chat -run 'TestLimits|TestHoldSp |
| Mutations (same method, `-run TestOwnerRaisesLimitRevoked`, restored and compared with `filecmp`: identical): |
| - **271** a revoked owner's limit counts: `if err := t.isOwner(r.Owner); err != nil {` became `...; false && err != nil {`. Exit 1, `hosted_limits_test.go:520: a removed owner's limit still counts: "admitted" <nil>`. Restored. |
| - **272** the setter's lookup error read as the defaults: `if errors.Is(err, ErrForbidden) {` became `if true || errors.Is(err, ErrForbidden) {`. Exit 1, `hosted_limits_test.go:529: admitted with the setter's roster lookup failing: "running"`. Restored. |
| + |
| +### Task 20 review round 1 (t20-r1.md: approved, one Minor fixed) |
| + |
| +Minor: `Allocate` widened to whole seconds before checking for an empty span, so `Allocate(t, t)` with a fractional-second `t` charged one second (345 micros for a Large settlement). It now returns empty maps when `!to.After(from)`, before widening. `TestHoldSpansMonthEnd` asserts that `Allocate` returns nothing for whole-second equal times, fractional equal times (12:00:00.5), a fractional reversed span (1 ms back) and a whole-second reversed span. It also asserts that a 1 ms span still widens to one second. |
| + |
| +Red: `CGO_ENABLED=0 go test ./internal/equipo/chat -run 'TestHoldSpansMonthEnd' -count=1`: exit 1, `hosted_limits_test.go:280: an empty span 2026-11-08 12:00:00.5 +0000 UTC to 2026-11-08 12:00:00.5 +0000 UTC: map[2026-11-08:1] map[2026-11:1]`. |
| + |
| +Green: `CGO_ENABLED=0 go test ./internal/equipo/chat -run 'TestLimits|TestHoldSpans|TestDelayedLaunch|TestSettleStays|TestNoProofKeepsHold|TestLimitCount|TestOwnerRaises' -count=1`: ok (10 tests). `make migration-check budget build vet`: exit 0 after raising the chat record to 46025/20290 with the reason. gofmt clean. |
| + |
| +Mutation: |
| +- **273** the empty-span check removed: `if !to.After(from) {` became `if false && !to.After(from) {`. `-run TestHoldSpansMonthEnd`: exit 1, `hosted_limits_test.go:280: an empty span 2026-11-08 12:00:00.5 +0000 UTC to 2026-11-08 12:00:00.5 +0000 UTC: map[2026-11-08:1] map[2026-11:1]`. Restored from a copy under `mktemp -d`; `cmp`: identical. |
diff --git a/internal/equipo/chat/hosted_limits.go b/internal/equipo/chat/hosted_limits.go| index 7c192c56..027ba7e6 100644 |
| --- a/internal/equipo/chat/hosted_limits.go |
| +++ b/internal/equipo/chat/hosted_limits.go |
| @@ -87,10 +87,13 @@ func hostedMicros(seconds, rate int64) int64 { |
| } |
| // Allocate splits [from, to), widened to whole seconds, into seconds per |
| -// UTC day ("2006-01-02") and per UTC month ("2006-01"). An empty span has |
| -// none. |
| +// UTC day ("2006-01-02") and per UTC month ("2006-01"). A span with to not |
| +// after from has none, checked before widening. |
| func Allocate(from, to time.Time) (days map[string]int64, months map[string]int64) { |
| days, months = map[string]int64{}, map[string]int64{} |
| + if !to.After(from) { |
| + return days, months |
| + } |
| from, to = from.UTC().Truncate(time.Second), to.UTC() |
| if t := to.Truncate(time.Second); t.Before(to) { |
| to = t.Add(time.Second) |
diff --git a/internal/equipo/chat/hosted_limits_test.go b/internal/equipo/chat/hosted_limits_test.go| index a3513c64..4be58eb0 100644 |
| --- a/internal/equipo/chat/hosted_limits_test.go |
| +++ b/internal/equipo/chat/hosted_limits_test.go |
| @@ -274,8 +274,14 @@ func TestHoldSpansMonthEnd(t *testing.T) { |
| if !reflect.DeepEqual(days, map[string]int64{"2026-11-30": 1800, "2026-12-01": 900}) || !reflect.DeepEqual(months, map[string]int64{"2026-11": 1800, "2026-12": 900}) { |
| t.Fatalf("Allocate: %v %v", days, months) |
| } |
| - if d, m := Allocate(at(8, 12, 0), at(8, 12, 0)); len(d) != 0 || len(m) != 0 { |
| - t.Fatalf("an empty span: %v %v", d, m) |
| + half := at(8, 12, 0).Add(500 * time.Millisecond) |
| + for _, span := range [][2]time.Time{{at(8, 12, 0), at(8, 12, 0)}, {half, half}, {half, half.Add(-time.Millisecond)}, {at(8, 12, 1), at(8, 12, 0)}} { |
| + if d, m := Allocate(span[0], span[1]); len(d) != 0 || len(m) != 0 { |
| + t.Fatalf("an empty span %s to %s: %v %v", span[0], span[1], d, m) |
| + } |
| + } |
| + if d, _ := Allocate(half, half.Add(time.Millisecond)); d["2026-11-08"] != 1 { |
| + t.Fatalf("a fractional span widened: %v", d) |
| } |
| r, _ := hostedRig(t) |
| r.setLimits(HostedLimits{Running: 5, DailySeconds: DefaultHostedLimits.DailySeconds, MonthlyMicros: 2 * 2_066_667}) |