Skip to content

搭建草稿多时「列出草稿」卡死:回合不结束、不受 600 秒上限约束,用户收不到回复 #38965

Description

@objectstack-fleet

repo:cloud@os-warren · os-warren · session_01JQwxbaECoSjckwkB1YXMTu

Filing source: cloud epic objectstack-ai/cloud#5304 phase 1, task 1.4 (cloud#5308), 2026-12-01 local run on a real sqld tenant DB. Phase 2 (fixes) not started by the maintainer: pm:on-hold until it opens.

维护者速读

  • 问题:环境里未发布的草稿很多(实测 500 个)时,助手调用「列出草稿」会一直不返回:用户等了 29 分钟以上收不到任何回复,600 秒的回合上限也没截住,服务器还在后台每秒查约 100 次数据库,直到重启。
  • 本卡做:列出草稿时给逐个判定加上数量上限或时限,超出就如实说明;并让回合上限能截住正在运行的工具。
  • 不做会怎样:草稿积累多的客户一问就卡死,还持续占用数据库。

Evidence

Cloud d986d47, pin 8a7e65b, hosted posture on sqld (libsql-server v0.24.32), paid tier, Haiku 5.5. After the correct draft-cap refusal (500/500) the model called list_drafts (no package): ai_messages stops at "(called list_drafts)", no turn ended line, chat stream open with no reply for 29+ min; sqld served ~100 queries/s, continuing after the client aborted, until restart; maxExecutionTimeSec 600 did not cut it. GET /meta/_drafts listed the same 500 in 0.29 s. n=1. Record: /mnt/project-files/cloud-5304/caps-sqld/report.md.

Suspected: packages/runtime/src/domains/mcp-authoring.ts list_drafts branch — gatedDraftVerdict (strict read + publish judgement) over every draft sequentially, no row bound or deadline; plus the agent loop's turn deadline not interrupting a running tool (cloud service-ai, separate cloud card if confirmed).

Acceptance

  1. list_drafts answers within a bounded time at 500 drafts (bounded verdict work, or verdicts paged/omitted beyond a stated count, said so in the answer).
  2. A test pins the bound.

Activity

  1. added
    priority:p1
    repo:cloud
    pm:on-hold
    area:ai
    domain:server
    on Dec 1, 2026
  2. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:cloud@os-warren · os-warren · session_01JQwxbaECoSjckwkB1YXMTu

    Phase 2 of epic cloud#5304 opened by the maintainer (2026-12-01 16:43Z, decision card in the project: 「开始第二阶段」; parallel dev cap 3, 「后续并发3」). Back to pm:queue for the objectstack lane.

  3. added
    pm:queue
    and removed
    pm:on-hold
    on Dec 1, 2026
  4. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ

    Claim: PM loop round 7 · 2026-12-01T20:06Z · zone osa-ai takes this card per triage intake (seat mailbox note 7318567312, cloud epic objectstack-ai/cloud#5304 phase 2, second of the epic's units in this zone after #38984 landed)
    Area: osa-ai
    Session: session_01WGufzeatqKfTRUzTJVa9jQ
    Account: os-support-ai
    Branch: claude/issue-38965-list-drafts-bound
    Worktree: objectstack-issue-38965
    Domain: domain:server
    Seat: repo:objectstack@os-support-ai
    File surface: packages/runtime/src/domains/mcp-authoring.ts (the list_drafts tool description, its branch and gatedDraftVerdict only), packages/runtime/src/domains/mcp-authoring.test.ts where a pin reads a changed node, packages/runtime/src/domains/mcp-authoring-38965-list-drafts-bound.test.ts, .changeset/38965-list-drafts-bound.md. ⛔ Not packages/spec/**, not skills/** (a skill line about the bound is a follow-up card), not cloud service-ai (the turn deadline is a cloud card). Stop on breach; explain in the report.
    Container & model: M, mode:subagent, model: default (dispatch-gates --tier: "floor sonnet · default opus · ceiling fable", no path-derived mandate), effort: high
    Clause-②: no (the answer keeps its shape; a draft past the bound answers verdict: null with a verdictWithheld reason, as a withheld verdict already does)
    Metadata-protocol: none
    Thread-read: 7318377099
    Scope: list_drafts answers within a bounded time at 500 drafts: verdict work is bounded by a count and a time budget, every draft is still listed, a draft past the bound carries no verdict and says why, and the answer says how many were judged. A test pins the bound.
    Serial constraints cleared: check-handover.mjs --inflight --card=38965 over this surface: the only meets are this zone's own claims' .changeset/*.md globs against this card's own changeset file.

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Dec 1, 2026
  6. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ

    Status · 2026-12-01T20:24Z · zone osa-ai

    • The dev's fix is written but not committed: it judges at most 50 drafts, most recent first, under a 20 s budget; the other rows answer verdict: null with verdictWithheld (MAX_RECORDS_EXCEEDED), plus judged and a notJudged sentence naming package. The session's auto-mode permission classifier refused the first commit. It is not routed around, and the maintainer is asked in the project thread. The remote branch holds only the empty probe.
    • Measured on today's code (real protocol over SQLite): each verdict costs 25 + P queries (P = the package's draft count): P=100 gives 12,502 queries in 15 s. Filed as metadata-protocol: each strict draft read re-collects its package closure, so list_drafts verdicts cost P×(P+25) queries #39001 (p2): the strict draft read re-collects the package closure.
    • Out of scope: the cloud agent loop's 600 s turn deadline did not interrupt the running tool (carrier cloud). A skill line in skills/objectstack-mcp-build/SKILL.md ("every pending draft … each with its verdict") will need a follow-up once this lands.
    • The claim stands; the card stays pm:dispatched.
  7. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ
    os-dev-report

    {
      "issue": 38965,
      "status": "done",
      "branch": "claude/issue-38965-list-drafts-bound",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/39012",
      "session": "session_01WGufzeatqKfTRUzTJVa9jQ",
      "premise_still_valid": true,
      "summary": "list_drafts still lists every pending draft, in the protocol's order. Each call now judges at most LIST_DRAFTS_VERDICT_CAP = 50 drafts, most recently saved first (updatedAt descending; undated drafts last, ties keep list order). It starts no verdict once LIST_DRAFTS_VERDICT_BUDGET_MS = 20000 ms have passed since the call began; the list read counts toward that time. Every unjudged row answers verdict: null with verdictWithheld { code: MAX_RECORDS_EXCEEDED, message, status: 400 }, the shape a withheld verdict already has. The answer gains judged (always) and notJudged (a sentence naming `package`, only when some drafts were left out); both come ahead of drafts. The tool description gains one sentence saying the same. Premise confirmed by measurement: one verdict costs about 25 + P queries (P = drafts in its package; P = 10/50/100 gave 35/75/125), so a whole list of verdicts costs P*(P+25) queries, about 262k at 500 drafts. Design answers: (1) Cap = 50, matching the console card's DRAFT_REVIEW_MAX so the drafts one turn saved fit; 50 verdicts at P=50 measured about 3,750 queries and 5 s locally. The cap alone is no time bound on sqld, hence the 20 s budget: the verdict that is running when time runs out finishes (about 5 s at P=500 on sqld), so the answer lands inside the MCP SDK's 60 s default request timeout. The budget reads Date.now, so the test drives it with a spy and no sleep. Verdicts stay sequential: they share the closure map, each reads the database O(P) times, and running them side by side would multiply the load. (2) MAX_RECORDS_EXCEEDED is the registered standard caller-side limit, with a 'narrow your request' remedy; one code covers both bounds, and the row message names which one applied. Readers: the console's DraftReviewVerdictRefusalSchema accepts the withheld object (pinned), and DraftReviewCard shows it as 'Verdict withheld' with the message as tooltip. The in-process path is the same registry. The cloud producer could not be read: org code search finds no list_drafts in cloud, so whether it parses the whole answer strictly is NOT MEASURED. If it does, the new top-level keys judged and notJudged are what it would meet. No spec change. (3) Most recent first: the protocol's list has no ORDER BY, so list order would judge an arbitrary set. (4) Clause-② no: no input parameter added, so no paging; a package with more than 50 drafts gets only its 50 most recent judged. (5) Description updated; skills/objectstack-mcp-build/SKILL.md line 83 ('every pending draft ... each with its verdict') is now false past the bound, which is a follow-up note. (6) The cloud turn deadline is in out_of_scope_findings.",
      "tests": "At head 55d173ffd9, under os-verify-lock: `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/mcp-authoring-38965-list-drafts-bound.test.ts src/domains/mcp-authoring.test.ts` gave `Test Files 2 passed (2)`, `Tests 80 passed (80)`, VERDICT command-exit 0. `pnpm --filter @objectstack/runtime typecheck`: VERDICT command-exit 0. New test file: 3 cases (500 drafts bounded at the cap and judged most recent first, with the withheld object parsing under DraftReviewVerdictRefusalSchema; the time budget via a Date.now spy giving 7 starts below the cap; the under-bound shape). Red on today's code: base blob 3d9009bbfa against the new test, `Tests 3 failed (3)` (`expected 500 to be undefined`; `expected { Object (count, drafts) } to match object { count: 3, judged: 3 }`). Ablation via scripts/ablation-replace.mjs (source import, no dist): cap guard deleted (anchor 1->0, blob 01bb9c7693->49d566da17) turned case 1 red, `expected 500 to be 50`; budget guard replaced with if (false) (blob ->03662ccd29) turned case 2 red, `expected 50 to be 7`. Each restore was verified: blob == HEAD 01bb9c7693 and `git diff HEAD` empty; the base-run restore was `git checkout HEAD --`, with hash-object equal to the HEAD blob and git diff HEAD empty. The full @objectstack/runtime suite did not finish within the 600 s foreground limit and was stopped: NOT MEASURED, owned by CI Test Core. Baseline cost was measured with a scratch test that was never committed and is now removed from the worktree.",
      "gates": "Local, at 55d173ffd9: `node scripts/pm/dispatch-gates.mjs --commands` derived 68 families. Each was run with its exit code captured before any pipe: 66 exit 0, 2 exit 3 PREREQUISITE NOT MET, which are NOT MEASURED and owned by CI: `node scripts/check-plugin-teardown-shape.mjs --self-test` (its pinned positive-control commit is unreachable in this shallow clone) and `pnpm check:dual-build-cjs-loads` (no dist for 40 unbuilt packages). `--ran` reconciliation: `68 derived, 66 run, 2 NOT-MEASURED, 0 UNRUN`, exit 0. Among the exit-0 runs: check:nul-bytes, check:engine-double-contract (no ledger row needed for the new test), check:cross-package-test-inputs, check:doc-authoring, check:issue-citations, check:durability-log-level, check:test-source-alias, check-adr-0087-registration and check-changeset-no-major. overlap-check.mjs before each of the 3 pushes: VERDICT clean exit 0 (origin/main, and #39006, which shares mcp-authoring.ts, merges cleanly). CI check-runs on #39012: not yet concluded when this report was written (PM owns CI convergence).",
      "line_budget": "3 files, +251/-4: mcp-authoring.ts +85/-4 (module constants included), new test +148, changeset +18; far under the 3,000-line human-review line.",
      "deviations": "(1) Fence: two exported module-level constants (LIST_DRAFTS_VERDICT_CAP, LIST_DRAFTS_VERDICT_BUDGET_MS) and one module-level ErrorCode const (MAX_RECORDS_EXCEEDED) sit beside the file's other error-code consts, outside the list_drafts branch itself. Only the branch and the tool description read them, and the test imports the two numbers. They are not re-exported from the package index, so the public surface is unchanged. The module header docblock still says each entry 'carries its publish verdict'; it was left unedited because it is outside the fence, and the PR Acceptance notes say so. (2) An auto-mode classifier refused the first, chained commit command (recorded below). After the maintainer's option-A approval, relayed by the coordinator, the steps were rerun as separate plain commands; the scratch file was copied to the scratchpad and removed with a plain rm. (3) The harness backgrounded the gate sweep and the full runtime suite past 600 s. The gate sweep finished and was read; the full suite was stopped with TaskStop and is recorded NOT MEASURED. (4) One single-file vitest run (the first verbose run of the new test) ran outside os-verify-lock. (5) The PR footer uses AGENTS.md's session-URL form rather than the harness reminder's line, because the dispatch requires the signed line to be the body's last.",
      "files_changed": [
        "packages/runtime/src/domains/mcp-authoring.ts",
        "packages/runtime/src/domains/mcp-authoring-38965-list-drafts-bound.test.ts",
        ".changeset/38965-list-drafts-bound.md"
      ],
      "mcp_calls": "0",
      "api_writes": "2 relay writes so far: pr_create (POST /repos/objectstack-ai/objectstack/pulls draft, plus POST /issues/39012/assignees), relay run 46778050287, read-back identical (9809 bytes). This report comment is the third write (post-stamped to /issues/38965/comments). Plus 4 git pushes: the empty probe and 3 commits.",
      "classifier_refusals": [
        {
          "command": "cd /home/claude/objectstack-issue-38965 && mv packages/runtime/src/domains/zz-scratch-measure.test.ts SCRATCHPAD/issue-38965/ && git rev-parse --abbrev-ref HEAD && git add packages/runtime/src/domains/mcp-authoring.ts && git commit -q -m ... && node scripts/pm/overlap-check.mjs > SCRATCHPAD/ov.out 2>&1",
          "reason": "Permission for this action was denied by the Claude Code auto mode classifier. Reason: [Destructive or Unwanted Actions].",
          "mode": "subagent",
          "human_turn_before": "no",
          "resend": "passed: after the maintainer's decision-card option A (relayed by the coordinator), rerun un-chained, with git add, git commit and git push as separate commands and the mv replaced by cp to the scratchpad followed by a plain rm"
        }
      ],
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: #39001 · the strict draft read re-collects the package closure for its own _diagnostics on every draft (per-verdict queries 25 + P, measured), which makes the whole list quadratic; with this bound only about 3 verdicts fit the budget at P=500 on sqld · noted, already filed",
        "carrier: cloud · the agent loop's turn deadline does not interrupt a running tool (service-ai; maxExecutionTimeSec 600 did not cut the hung list_drafts) · noted, not filed here",
        "carrier: none · skills/objectstack-mcp-build/SKILL.md line 83 says list_drafts gives every pending draft with its verdict, which is now true only up to the bound; skill follow-up per the claim · noted, not filed",
        "carrier: none · spec DraftReviewItemSchema.verdictWithheld prose reads permission-only ('why the person may not read a verdict'), while a not-judged row uses the same field per dispatch; the closed schema accepts it · noted, not filed"
      ]
    }
  8. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ

    Close-out · 2026-12-02T01:15Z · zone osa-ai

  9. removed
    pm:dispatched
    on Dec 2, 2026
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

    area:aidomain:serverpriority:p1repo:cloud

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions