GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(queue): batch claim (--count N) + per-item dedicated sub-task dispatch · Issue #8217 · developing-today/code

feat(queue): batch claim (--count N) + per-item dedicated sub-task dispatch #8217

New issue
Copy link
New issue
Copy link
Closed
Closed
feat(queue): batch claim (--count N) + per-item dedicated sub-task dispatch#8217
Copy link
Labels
status:done

Description

@dezren39
dezren39
opened on Nov 10, 2026
Issue body actions

feat(queue): batch claim (--count N) + per-item dedicated sub-task dispatch

Drew's orders (verbatim, 2026-11-10)

  • "why does it pull multiple items can it hand off each item to a dedicated sub task? can claim take a number of items to claim?"
  • Approval: "Build batch claim + per-item dedicated sub-tasks"
  • Platform limitation rule: "if something has to be it could be limited to muse or oc but better be good reason" — a task may be limited to one platform family only with a good reason recorded on it; default is open to either platform.

Builds on

  • fix(queue): single-session by default — launch-on-handoff, lane works, inline triage (reverses #8097 Rule 3) #8187 (single-session redesign, closed): claim pick is one atomic pick, ORDER BY priority ASC (nulls last), created_at ASC, LIMIT 1; assignment decided after claim, default direct, opencode only with a recorded reason; platform is a mark, never a filter; events table is the append-only audit trail.
  • feat(queue): Muse→opencode push — claim-by-id transfer verb (--from-session) + one-call send with notes and worktree #8210 (IN FLIGHT — dependency): Muse→opencode push: claim-by-id transfer verb (--from-session) + one-call send with notes and worktree. THIS issue lands second: no work on turso_queue.rs claim paths or launch_one.py until feat(queue): Muse→opencode push — claim-by-id transfer verb (--from-session) + one-call send with notes and worktree #8210's PR is merged to main; this build rebases cleanly on top of it and reuses its launcher/transfer mechanism (no third launcher).
  • opencode-claimant: handed-off tasks are never launched — executed_lane/session_id stay null across repeated claim→handed_off→park cycles #6533 (claimant binding history).

What to build

1. Batch claim: fleet queue claim --count N

  • Runs the existing atomic pick N times: same eligibility (queued-due under attempts cap, expired timed parks, parked recorded-handoff sink with no not_before gate), same priority/age order, same per-claim audit events and marks (platform/lane/model/session).
  • Hard cap: N ≤ BATCH_CLAIM_MAX = 5 (named constant; reasoning: a dispatcher can launch+verify ~5 dedicated sessions inside one touch without leases ageing; larger batches recreate the claimed-and-idle pile this design forbids).
  • Partial success is normal: fewer eligible than N returns what exists; zero eligible returns the usual no-task verdict.
  • Per-item attempts/lease semantics unchanged (queued +1, parked +0; each item its own lease).

2. Dispatch pairing — no idle holding

A batch claim is only legitimate paired with immediate dispatch in the same touch (a --dispatch mode on claim or a sibling dispatch verb — design call recorded here when made):

  • Each claimed item goes to a DEDICATED sub-task session within the same operation: an opencode session launched+bound via the claimant machinery (reuse launch_one / the feat(queue): Muse→opencode push — claim-by-id transfer verb (--from-session) + one-call send with notes and worktree #8210 send-path launcher), or a Muse sub-session via the feat(queue): Muse→opencode push — claim-by-id transfer verb (--from-session) + one-call send with notes and worktree #8210 transfer mechanism.
  • Each item carries: the dispatch reason (batch dispatch is the lane's stated mode, recorded once per batch on each item's lane_assigned/claim event), the lane's notes, and its worktree dir (worktrees only, one per item, never the main checkout, no two sub-tasks share a worktree).
  • Platform limitation: if a task carries a recorded platform limitation + reason, batch pick/dispatch must respect it (never dispatch it to the limited-out platform); the batch machinery never creates a limitation without a reason.

3. Supervision + failure

  • The dispatching lane verifies every item bound (session_id present) before its touch ends; the batch operation reports per-item outcomes (bound session id, or released-with-reason).
  • Any item that fails to launch/bind returns to the pool immediately (release to queued / flip to direct for serial work by the lane) — never left claimed-idle.

4. Runbook

Lane instructions gain a dispatch mode: a lane MAY batch-claim up to the cap for part of a bundle, dispatch each item, supervise completions/heartbeats, and work serially itself whatever comes back. Serial single-session work stays the default mode; dispatch is an allowed stated mode, not a replacement.

5. Tests

  • Broker: --count order preserved across the batch, partial batch, cap enforcement, per-item events/marks, recorded platform limitation respected by the pick.
  • Dispatch: claimant-suite-style tests for launch+bind per item and failure-returns-to-pool.
  • Full fleet-queue suite + claimant suites green.

Live acceptance (receipts required)

  • One real batch claim of ≥3 items; pick order across the batch matches priority/age.
  • Each item bound to its own dedicated session (distinct session ids, distinct worktrees), verified from live queue state + the sessions themselves.
  • One forced bind failure: the item returns to the pool immediately, not held.
  • A platform-limited item (limitation + reason recorded) excluded from the wrong platform's batch; an unlimited item flows to either platform.

Deploy

Like #8189: both broker binaries (~/.local/bin/fleet + libexec copy), old binary kept as .bak, queue-broker.service restart, health smoke test.

Activity

  1. developing-today commented on Nov 10, 2026

    @developing-today
    developing-todayBot
    on Nov 10, 2026 – with developing.today
    Contributor
    More actions

    CODE-2435

  2. dezren39 commented on Nov 10, 2026

    @dezren39
    dezren39
    on Nov 10, 2026
    MemberAuthor
    More actions

    Design record (#8217 implementation)

    Sequencing: #8210 is still in flight (issue open, no PR yet at design time). Per the build brief, nothing here touches turso_queue.rs claim paths or launch_one.py until #8210's PR is merged to main; this build rebases on top and reuses its send tool (send_to_opencode.py, already documented in the lane runbook §1b) as the opencode launcher. No third launcher.

    Broker (turso_queue.rs + client.rs)

    1. Batch claim — claim request gains count (absent/1 = today's exact behavior and response shape). count > 1 runs the existing single-claim body in a loop and returns {"rows": [...], "claimed": k, "requested": n}. Per-item events/marks/leases identical to N single claims. Cap: BATCH_CLAIM_MAX = 5 (named constant in turso_queue.rs; client enforces the same bound with a usage error). Reasoning for 5: a dispatcher must launch + verify-bind every item inside one touch before leases age; 5 dedicated launches fit that window with margin, and a bigger batch recreates the claimed-and-idle pile this design forbids. task_id (by-id) + count > 1 is a usage error. Zero eligible = the usual row: null verdict; partial batches return what exists.
    2. Platform limitation — additive columns tasks.platform_limit (NULL | muse | openchamber, the PLATFORM_FAMILIES vocabulary) + tasks.platform_limit_reason (TEXT), added in ensure_schema exactly like tasks.platform/opencode_reason were; both added to TASK_COLS. This is NOT the platform mark: the mark stays a never-filter stamp (fix(queue): single-session by default — launch-on-handoff, lane works, inline triage (reverses #8097 Rule 3) #8187); a limitation is a restriction recorded with a mandatory reason. Set/clear surfaces:
      • enqueue: --platform-limit <family> --platform-limit-reason <text> (both or neither; a limit without a reason is refused);
      • new verb /limit + CLI fleet queue limit <id> --platform <family> --reason <text> / --clear --reason <text> for existing tasks; writes platform_limited / platform_limit_cleared audit events with the reason.
        Pick enforcement: the default pick, the parked-handoff pick, and claim_by_id all gain the same clause — a row is servable only when platform_limit IS NULL OR platform_limit = <the claim's declared family>; a claim declaring no family is served only unlimited rows. The batch pick and the dispatch tool therefore respect a recorded limitation, and nothing in this build can create a limitation without a reason.
    3. Release verb — new /release + CLI fleet queue release <id> --worker <w> --reason <text>: holder-only (same claimed_by ownership check as checkpoint), claimed → queued, worker/lease cleared, lease row deleted, binding cleared, attempts NOT decremented (the claim happened; the released audit event carries the reason, and revive remains the cap-repair tool). This is the immediate pool-return path for a failed dispatch; it is not a park and has no timer.

    Dispatch (new tool: pm-stack/opencode-claimant/dispatch_batch.py)

    Sibling of launch_one.py / send_to_opencode.py, same by-path sibling loading (poll.py classifiers/fetchers reused, no duplicated queue logic):

    python3 -I dispatch_batch.py --queue <q> --count <n≤5> --to opencode|Muse \
      --worker <lane worker> --lane <lane id> --reason "<batch dispatch reason>" \
      --notes "<lane notes for every item>" [--session-id <dispatcher session>] \
      [--release-failures] [--dry-run]
    

    Flow: batch-claim with --platform <target family> (the limitation check must see the family that will WORK the items; the dispatching lane is recorded via lane id + session mark + the per-item events). Per item, in order:

    1. create its worktree on the laptop per runbook §3 (~/git/fleet/<task-id>-..., branch queue/<task-id>-<issue>-<slug>), never the main checkout, never shared;
    2. opencode: send_to_opencode.py with the batch reason as the pass-off reason, the lane's notes, and --worktree — it records the opencode assignment with the reason, transfers the claim from the dispatching session with no queued/parked stop, launches, and verifies the bind; Muse: assignment stays direct (lane verb, batch reason recorded on the event via checkpoint progress), worktree + a per-item launch packet is emitted for the lane's own sub-session, which binds with fleet queue bind when it starts;
    3. verify the bind from live queue state (progress.session_id present and equal to the launched session id) before the batch ends;
    4. any item that fails to launch/bind: the send's own rollback leaves the assignment direct — outcome held_by_lane_direct (the dispatching lane works it serially; it is not idle, its owner is present) or, with --release-failures, an immediate /release back to queued with the failure as the release reason. The tool prints one JSON record per item (bound + session_id + worktree, or the failure outcome + reason) and exits non-zero if any item failed.

    Runbook

    New §1d "Dispatch mode (batch claim + dedicated sub-tasks)" in repo-queue-worker-instruction.md (+ the per-repo lane instruction variants): serial single-session stays the default; dispatch mode is an allowed stated mode for part of a bundle — batch-claim ≤5, dispatch each item with reason + notes + worktree, verify every bind, supervise via heartbeat/checkpoint reads, work serially whatever comes back. Platform limitation rule stated: a task may be limited to muse or openchamber only with the reason recorded (fleet queue limit); lanes never work a task against its recorded limitation.

    Tests

    • Broker (turso_queue.rs tests): count preserves priority/age order across the batch; partial batch; cap refusal (>5); per-item claimed events + marks; limitation excluded from the wrong family's pick and from no-family picks, included for the matching family; by-id claim refuses a wrong-family limited row; release returns a claimed row to queued holder-only (+0 attempts, lease gone, released event with reason); limit verb refuses a limit without a reason.
    • Client (client.rs tests): --count flag plumbing + cap usage error.
    • Dispatch (test_dispatch_batch.py, claimant suite style, mocked repo-queue + send): per-item launch+verify, distinct worktrees, failure → release/held-direct outcomes, JSON report shape.
    • Full fleet-queue suite + claimant suites green before merge.
  3. dezren39 commented on Nov 10, 2026

    @dezren39
    dezren39
    on Nov 10, 2026
    MemberAuthor
    More actions

    Design addendum — platform limitation reuses #8210's mechanism (supersedes that part of the design record above)

    Reading #8210's in-flight branch (queue/8210-muse-send-transfer) before it merges, to avoid building a parallel mechanism: #8210 already implements Drew's platform-limitation rule —

    • stored on the lane ledger: repo_task_lane_ledger.platform_limit + platform_limit_reason (additive columns, same ensure_schema pattern);
    • set through the lane verb: fleet queue lane <id> --limit-platform muse|openchamber --limit-reason "<reason>" (broker refuses a limitation with no reason; --clear-platform-limit clears);
    • a stored limitation with no reason is invalid: the broker CLEARS it rather than enforcing it;
    • a valid limitation refuses a claim from any other family — and from a claim naming no family;
    • enforcement today lives in feat(queue): Muse→opencode push — claim-by-id transfer verb (--from-session) + one-call send with notes and worktree #8210's transfer claim (platform_limit_refusal).

    So this build does NOT add tasks.platform_limit columns or a /limit verb. Instead:

    1. The pick learns the same rule. The default pick, the parked-handoff pick, and the plain by-id claim gain one shared SQL predicate over the ledger: a row is unservable when a ledger row for it carries a valid limitation (limit + reason both recorded) naming a family other than the claim's declared family (a family-less claim is served only unlimited rows — the same refusal semantics as platform_limit_refusal, expressed in the pick so batch and single claims cannot sieve around it). The batch claim inherits this for free since it reuses the pick.
    2. Dispatch respects it end-to-end: dispatch_batch claims with --platform <target family>, so a wrong-family limited item never enters the batch; the limitation + reason stay visible on the item's ledger row and events.
    3. Everything else in the design record stands: --count (cap BATCH_CLAIM_MAX = 5), /release, dispatch_batch.py driving send_to_opencode.py per item, runbook §1d, tests as listed (limitation tests now target the ledger mechanism + pick clause).
  4. dezren39
    added a commit that references this issue on Nov 10, 2026

    Merge pull request #8244 from developing-today/queue/8217-batch-claim

    344b50a
  5. developing-today
    added
    status:done
    on Nov 10, 2026
  6. developing-today
    closed this as completedon Nov 10, 2026
  7. developing-today
    added
    status:in-review
    and removed
    status:done
    on Nov 10, 2026
  8. developing-today
    reopened this on Nov 10, 2026
  9. dezren39
    added a commit that references this issue on Nov 10, 2026

    Merge pull request #8274 from developing-today/queue/8217-batch-claim

    1c5d25f
  10. developing-today
    added
    status:done
    and removed
    status:in-review
    on Nov 10, 2026
  11. developing-today
    closed this as completedon Nov 10, 2026
  12. dezren39 commented on Nov 10, 2026

    @dezren39
    dezren39
    on Nov 10, 2026
    MemberAuthor
    More actions

    Implemented, deployed, and live-verified. Closing with receipts.

    What shipped

    • PR fleet queue: batch claim + per-item dispatch (#8217) #8244 (merged 344b50a3): broker batch claim + platform-limit-aware pick + /release verb; client claim --count / release; dispatch_batch.py + tests.
    • PR dispatch_batch: normalize the count==1 single-claim response (#8217) #8274 (merged 1c5d25f7): follow-up found by live acceptance — dispatch_batch --count 1 now normalizes the single-claim bare-row response (count==1 IS the single claim by design).
    • Cap: BATCH_CLAIM_MAX = 5 — one batch is one lane touch and one supervisor; the dispatcher must verify every item's bind before the touch ends, and five dedicated sessions is the most one lane can launch, verify, and answer for at once, far under the claimant session cap so a batch can never starve the pool.
    • Runbook: §1d "Dispatch mode" added to repo-queue-worker-instruction.md (serial single-session stays the default; dispatch is an allowed stated mode with the reason recorded per item).

    Tests

    • fleet-queue: 161 lib + 2 integration green at PR time (cargo test -p fleet-queue --all-features); 163 lib green on final main (with fix(queue): handoff sink gets its own status (handed_off) and the fake expiry timer is deleted #8234 merged alongside).
    • Claimant Python suites: 127 green (21 claimant + 56 poll + 26 launch_one + 14 send + 10 dispatch_batch incl. the count==1 regression).

    Live receipts (2026-11-10, deployed broker)

    Phase A — scratch queue scratch-8217-c, worker scratch-8217-worker:

    • Enqueued tasks 14730 (p50), 14731 (p10), 14732 (p30), 14733 (p30). claim --count 6 → exit 2, cap message. claim --count 4 → [14731, 14732, 14733, 14730] — priority bands ascending, age order inside the p30 pair (created 1s apart). claimed=4/requested=4.
    • All four released → each read back queued; an immediate single claim re-served 14731. Release event + reason recorded per item.
    • Limitation: task 14734 limited via the lane verb (--limit-platform muse --limit-reason "acceptance: muse-only scratch item (#8217)"). Openchamber batch (--count 2 --platform openchamber) served only limu (14735); muse batch then served [14734, 14735] in age order. All scratch tasks completed after.

    Phase B — dispatch (scratch queues backed by the code primary, real broker + real opencode server):

    • Batch claim of 3 (tasks 14737/14738/14739) via dispatch_batch.dispatch(); three distinct worktrees created (~/git/fleet/queue-14737-8217-dispatch, …-14738-8210-…, …-14739-8187-…, removed after cleanup).
    • The opencode send gate refused all three with cap_saturated: cap_room=0 (pool read live: 56→61 active root sessions vs cap 36 — the pool is oversubscribed by direct lane launches). Per design, every item was released straight back to queued in the same touch (outcome: released_to_queue), three separate attempts, never claimed-idle.
    • Forced failure (Muse path): task 14742 with its worktree path blocked → dispatch failed at the worktree phase → released_to_queue, live status read back queued immediately after.

    One receipt still owed — environmental, not a code path

    A bound opencode session from a batch could not be captured today: the session pool stayed saturated for the whole acceptance window (cap_room=0 on every read, roots 56→61 vs cap 36), so the send gate — correctly — refused before any session was created. The claim → worktree → send → verify → release chain is proven live end-to-end except the final bind, which is the #8210 send path already proven live this morning. Re-run when the pool has room:

    python3 ~/git/code/pm-stack/opencode-claimant/dispatch_batch.py \
      --queue repo-health-code-pilot --count 2 --to opencode \
      --worker repo-worker-code --session-id <lane session> \
      --reason "<batch reason>" --notes "<notes>" --release-failures
    

    Incidents during the rollout (all resolved)

    • First deploy was built from the stale primary clone and lacked the change; caught by the post-deploy smoke (--count unrecognized), rebuilt from a fresh origin/main worktree and redeployed. A concurrent fix(queue): handoff sink gets its own status (handed_off) and the fake expiry timer is deleted #8234 deploy then overwrote the binary again; final state converged once both changes were on main — the live broker now runs a main build carrying feat(queue): batch claim (--count N) + per-item dedicated sub-task dispatch #8217 (verb-verified: cap error + release both live).
    • Building from final main exposed an unrelated break: fleet-search: main build broken - server.rs initializers missing new atlas-core fields #8268 (fleet-search initializers) — filed and fixed in PR fleet-search: fill new atlas-core fields in server initializers (#8268) #8272 (merged, issue closed).
    • Observation filed as queue bind: session id format is not validated - a ghost id binds and strands the task until stuck-bound supervision #8287: the bind verb accepts an arbitrary session-id string (bound task 14741 to not-a-session live; recovered by completion) — validation hardening for a follow-up.
  13. dezren39
    added a commit that references this issue on Nov 11, 2026

    fix(queue): expire_leases fails at-cap tasks instead of stranding the…

    edee5d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.