Skip to content

审批运行读取先查内存记录:过期的暂停记录可能让已完成的审批被判为放弃 #38674

Description

@objectstack-fleet

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

Filing gate: ② found in review. Source: seat L1 7267033432 on PR #38634 (card #37767), premise read by the #37767 card thread on the approvals trunk 37e97a8 and PR #38618 head ee8203b (byte-identical lines).
Grading: area:data · Bug · Suggested-grade: p2 · reach: approvals on a multi-process deployment (or a ring that kept a superseded paused entry) · evidence: code read, not reproduced.

维护者速读

  • 问题:读取一次自动化运行时,系统先看进程内存里的最近记录,再看数据库里的最终记录。如果另一台进程已经把审批完成写进数据库,本进程内存里还留着"暂停中"的旧记录,就可能把已完成的审批当成没完成,进而判为放弃。
  • 影响:多进程部署下的一个窄时间窗口;单进程基本碰不到。
  • 做什么:读取时优先采用数据库里的终态记录。
  • 要你做什么:无。

What (trunk claude/o5-data-approvals-trunk at 37e97a8)

packages/services/service-automation/src/run-history.ts getRun, lines 327–331: the in-process ring (executionLogs, newest entry for the id) is scanned first and if (inMem) return inMem; answers before loadTerminal is called. A strict read (options.strict, added by #38618) never reaches the ring branch's decision either: strict only rethrows store failures.

So a paused entry left in this process's ring answers even when another process has written the run's terminal row; a consumer that treats a paused run past its deadline as abandoned can abandon an approval that already finished.

Ask

  1. When the store holds a terminal row for the id, it wins over a non-terminal ring entry (at least on a strict read; the dev states whether the default read changes too and why).
  2. Pin it red first: a ring holding a paused entry, the store holding a terminal row written by "another process" (a second engine or a direct store write), getRun answers the terminal row.
  3. Name the consumers that act on a non-terminal answer (the approvals plugin's abandonment path) and confirm none reads the ring directly.

Not here

Related: #37767, #38618, #38634.

Activity

  1. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    ContributorAuthor

    triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

    Triage: lands in packages/services/service-automation/src/run-history.ts getRun (a terminal store row wins over a non-terminal ring entry) · area:data · domain:server · Bug · p2 · pm:queue · size S.
    Grade: area:data · Bug · Severe (a finished approval can be recorded as abandoned) · rare configuration (a multi-process deployment in a narrow window) · read from the code, not reproduced.
    Rationale: the North Star table gives p2 for this severity at rare reach. The area stays with its approvals family, #37767 (area:data, the approvals trunk that PR #38618 and PR #38634 ride), so the holder of that trunk reads it, although approvals as a capability are area:workflow. The fix touches the same run-history.ts lines as PR #38618, so a claim waits for that PR or rides its trunk.

  2. added
    domain:server
    pm:queue
    priority:p2
    on Nov 30, 2026
  3. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#3 · os-steve · session_01ADHkmTLwBddAv8qQwmLzdk

    2026-11-30T04:14Z · Parked: pm:queue → pm:blocked (seat repo:objectstack#3, zone o3-D · area:data, on the seat's order). Grade p2, size S unchanged; not claimed. Area:data p1/p2 intake is this seat's on the maintainer's order (verbatim 「你再开 area:data area:ux」, 2026-11-30T01:20:39Z).

    Why it waits (triage 7267554623): the fix edits the same getRun lines in packages/services/service-automation/src/run-history.ts that PR #38618 changes, and the card's ask 1 is about the strict read (options.strict) that PR #38618 adds. PR #38618 targets the approvals trunk claude/o5-data-approvals-trunk, not main; on origin/main today getRun has no strict option (the ring-first if (inMem) return inMem; is there). That trunk reaches main through PR #38497 (draft). This zone does not ride another seat's in-flight trunk, so the card is built from main once the trunk has landed.

    Blocked-by: #38497

    On release: re-read getRun on origin/main, then claim from this zone.

  4. added
    pm:blocked
    and removed
    pm:queue
    on Nov 30, 2026
  5. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Unblocked 2026-12-01T09:08Z: what this card waited on, PR #38618 (the same getRun lines in packages/services/service-automation/src/run-history.ts), merged at 2026-11-30T08:09:59Z. pm:blocked → pm:queue, grade p2 and size S unchanged, not claimed.


    Generated by Claude Code

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

    @objectstack-fleet
    ContributorAuthor

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

    2026-12-01T12:09Z · Parked: pm:queue → pm:blocked (zone osa-data of seat repo:objectstack@os-support-ai, area:data p1/p2 intake on the maintainer's words 「再开一个 area:data p1 p2」, 2026-12-01T11:58Z). Grade p2, size S unchanged; not claimed.

    Why it waits: check-handover.mjs --inflight --paths=packages/services/service-automation/src/run-history.ts --card=38674 reads OVERLAP with #38667 (claim 7300673225, seat repo:objectstack@os-justin), whose File surface holds packages/services/service-automation/src/ dir-wide for the engine split. Its in-flight PR #38889 (steps 2 and 3, draft) does not list run-history.ts today, but the claim does, and a zone never dispatches over a held claim. Serial behind it.

    Blocked-by: #38889

    Premise still holds at origin/main ac97540: getRun in run-history.ts scans the ring first and if (inMem) return inMem; (:332) answers before loadTerminal (:337); the strict read (options.strict) is on main.
    Note for the next reader: the older Blocked-by: #38497 line (7268600412) names the trunk PR that closed unmerged; its content reached main in PR #38810 (merged 440574f62c), which superseded it (7297017700). That line is spent; this line is the live block.

  8. added
    pm:blocked
    and removed
    pm:queue
    on Dec 1, 2026
  9. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

    Unblock · pm:blocked → pm:queue · 2026-12-01T12:54Z

  10. added
    pm:queue
    and removed
    pm:blocked
    on Dec 1, 2026
  11. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim: PM loop round 2 · 2026-12-01T14:54Z
    Area: osa-data
    Session: session_01WGufzhKEbEnW8pwZRgK2gJ
    Account: os-support-ai
    Branch: claude/issue-38674-terminal-row-wins
    Worktree: objectstack-issue-38674
    Domain: domain:server
    Seat: repo:objectstack@os-support-ai
    File surface: packages/services/service-automation/src/run-history.ts (getRun only: a terminal store row wins over a non-terminal ring entry), one new test file named for this card under packages/services/service-automation/src/, an existing approvals-plugin test only if a pin there reads the changed answer, one .changeset/*.md. Stop on breach; explain in the report.
    Container & model: S, mode:subagent, model: default (dispatch-gates --tier: "Model tier — no path-derived mandate"), effort: high (reason: S but not mechanical — which source answers a run read, strict and default, and which consumers act on a non-terminal answer)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: platform code, objectstack (getRun's ring-first answer in packages/services/service-automation/src/run-history.ts) | none | a multi-process deployment (or a ring holding a superseded paused entry) where another process wrote the run's terminal row; a consumer that treats a paused run past its deadline as abandoned can abandon a finished approval; reachable today, narrow window
    Thread-read: 7311830409
    Premise: holds at origin/main (fetched 2026-12-01T14:54Z): getRun scans the ring newest-first and if (inMem) return inMem; (run-history.ts:332) answers before this.store.loadTerminal (:337); options.strict only rethrows store failures (:369, :406).
    Pre-claim lane: packages/services/** ⇒ domain:server (file ownership only).
    Pre-claim deps: Blocked-by: #38889 (7310754282) — PR #38889 merged 2026-12-01T12:55Z. The older Blocked-by: #38497 line (7268600412) is spent: that trunk PR closed unmerged and its content reached main in PR #38810 (7297017700).
    Prior rulings read: the maintainer's 「全部同意」 (2026-12-01T12:51Z, triage unblock 7311830409): a split yields to p1/p2 work on the same files, so this card is not parked on a split claim's surface; check-prior-rulings.mjs --card 38674: no ruling on the card thread. Card's own fence: "#38618's strict contract stays as landed; this card amends it in its own PR and changeset."
    Serial constraints cleared: check-handover.mjs --inflight --paths=packages/services/service-automation/src/run-history.ts --card=38674: no overlap read (one unread surface, #38415, a seat reading stroke naming no path). #38691 (same family, other files: approvals plugin, engine-run-log, suspended-run-store) is not folded: another defect shape (fold gate ①). overlap-check.mjs before every push.

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

    @objectstack-fleet
    ContributorAuthor

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

    {
     "issue": 38674,
     "status": "done",
     "branch": "claude/issue-38674-terminal-row-wins",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/38969",
     "head_sha": "7ae89013",
     "session": "session_01WGufzhKEbEnW8pwZRgK2gJ",
     "premise_still_valid": true,
     "summary": "getRun (run-history.ts) no longer answers a NON-terminal ring entry before the store. When this process's newest ring entry for the id is non-terminal, loadTerminal is asked, and the terminal row wins unless the store also holds a live pause for the run (store.load), which keeps the ring entry the answer. A terminal ring entry still answers with no store read. Default and strict reads change together: which source answers is not what strict decides, and strict decides only what a store failure becomes. On a failure of either added read, the default read answers the ring entry with a warn, and the strict read rethrows. The live-pause exception is a measured deviation from Ask 1's literal wording. The literal rule turned consumed-suspension-restore.test.ts 'records the run as paused again, so the repair is not invisible' red (expected 'failed' to be 'paused'): restoreConsumedSuspension writes a NEWER paused ring entry beside the run's old failed row. Every case the card names (a second engine finished the run, or a terminal row with no live pause) answers the terminal row. Ask 3, consumers acting on a non-terminal answer: plugin-approvals placeApprovalRun via readApprovalRun (strict; the abandonment path, where paused plus no pause found reads pause_gone and then stopped), runsReadAtOpening (strict), the dead-run sweep and inspectStrandedRequests (default), runHasEnded (display), runtime run-detail and MCP reads, flow-slot-view, and engine-internal restoreConsumedSuspension and continuePastCancelledMapItem. No ring reader outside the engine package: git grep executionLogs outside packages/services/service-automation = 0 hits at 645e6b15. Cost: one loadTerminal only for a non-terminal ring entry, plus one load only when a terminal row is found. The dead-run sweep and stranded scan (one getRun per pending request) pay one indexed read per request whose run is paused in this ring, which is what an empty-ring process already pays. The Runs list (listRunsPage) does not call getRun.",
     "tests": "New run-history-terminal-row-wins.test.ts, 14 tests: 10 pass at 6cddeb32. Red first plus ablation of the fix (scripts/ablation-replace.mjs, restore verified blob == HEAD 00e5fc8dcd6b, git diff HEAD empty): ablation 1 restores origin/main 'if (inMem) return inMem;' and gives 12 failed / 26 passed over the new file plus consumed-suspension-restore.test.ts ('expected paused to be completed', 'expected paused to be cancelled'); the 2 'terminal ring entry: 0 store reads' tests stay green by design. Ablation 2 replaces the live-pause discriminator with the literal rule and gives 3 failed / 35 passed: both 'beside a live pause' tests plus the restore test. Full package suite at 6cddeb32 (literal rule): 1 failed / 4477 passed, the restore test, which led to 9300337a. After the fix: new file + consumed-suspension-restore + run-history + engine-residual-log-cause + multi-replica-resume-staleness = 5 files, 97 passed. service-automation build + typecheck at 7ae89013: exit 0, check:test-typecheck OK, 0 errors. Not run locally: the full service-automation suite after 9300337a (CI Test Core 12/12 shards green at 7ae89013), plugin-approvals tests (public types byte-unchanged; CI), test:repo (CI).",
     "gates": "Local, at 7ae89013: dispatch-gates --commands derived 70. 68 exit 0; 2 NOT MEASURED, PREREQUISITE NOT MET: node scripts/check-plugin-teardown-shape.mjs --self-test (exit 3, shallow clone cannot read pinned commit 621a4876) and pnpm check:dual-build-cjs-loads (exit 3, 44 packages without dist/). --ran: '70 derived famil(ies) accounted for, 68 run, 2 NOT-MEASURED', exit 0. overlap-check before each of 3 pushes: 'VERDICT clean exit 0'. CI at head 7ae89013: 39 success, 18 skipped, 0 failure, including Lint & Repo Gates, TypeScript Type Check, Test Core (12/12 shards), Build Core, Governed Surface Queue Guard, Test UI, Live E2E UI, Dogfood Regression Gate, Check Changeset, PR-body guards, all Lint and Type Check lanes. The 18 skipped are opt-in or schedule lanes.",
     "line_budget": "361 changed lines (+354 / -7, 3 files) vs the 3000 human-merge threshold: under",
     "files_changed": [
      "packages/services/service-automation/src/run-history.ts",
      "packages/services/service-automation/src/run-history-terminal-row-wins.test.ts",
      ".changeset/38674-getrun-terminal-row-wins.md"
     ],
     "ci_verdicts": "head 7ae89013: success 39, skipped 18, failure 0",
     "deviations": [
      "Ask 1 (ruling zone) implemented with a live-pause exception: a terminal row does not win when the store also holds a live pause. Evidence: the literal rule regressed a landed, pinned behaviour (consumed-suspension-restore.test.ts, restoreConsumedSuspension), and would have made a restored approval run read 'failed' to the approvals strict read. Raised in open_questions for the seat to confirm.",
      "The derived gate loop ran past the 10-minute foreground cap, and the harness moved it to the background on its own. I did not request background. All 70 results were read once it finished.",
      "The published getRun docblock in engine.ts still states the old order ('the in-memory entry, else its terminal history row, else its suspension row'). It sits outside the claim's file surface (run-history.ts only), so it is not edited. The precedence is documented on the body's docblock in run-history.ts."
     ],
     "mcp_calls": "0",
     "api_writes": "2: fleet-write relay pr_create (POST /repos/objectstack-ai/objectstack/pulls draft, plus the assignees leg POST /issues/38969/assignees), and the post-stamped os-dev-report comment on #38674 (POST /issues/38674/comments). Plus git push x4 (probe + 3 commits), which is not REST.",
     "classifier_refusals": [],
     "open_questions": [
      {
       "question": "Confirm the live-pause exception to Ask 1 ('a terminal store row wins over a non-terminal ring entry').",
       "options": [
        "A: keep it. The terminal row wins unless the store holds a live pause, and the restore contract and its pin stay green.",
        "B: literal rule. The terminal row always wins, restoreConsumedSuspension's 'paused again' pin is rewritten, and a restored approval run reads 'failed' to approvals."
       ],
       "recommendation": "A. B breaks a landed operator repair and moves the same wrong-ending harm onto restored runs."
      },
      {
       "question": "Authorize a one-line correction of AutomationEngine.getRun's docblock in engine.ts (outside this claim's surface) on PR #38969?",
       "options": [
        "A: yes, add one commit to this PR",
        "B: leave it to the split work on engine.ts"
       ],
       "recommendation": "A. The published .d.ts docblock now under-describes the precedence."
      }
     ],
     "security_findings": "none",
     "out_of_scope_findings": [
      "carrier: none · noted, not filed · a run parked here, resumed by another process and parked again at a later node, still answers this ring's older paused entry (status right, step log stale); store's newer suspension row is not read when no terminal row exists. Code read, not reproduced. Dedupe words: getRun stale paused steps, multi-replica re-pause, ring entry step log",
      "carrier: none · noted, not filed · a terminal row beside a suspension row whose completion delete was lost answers the ring's paused, which is today's behaviour unchanged."
     ]
    }
  14. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Premise corrected · 2026-12-01T16:02Z · zone osa-data, on dev report 7316868896 (PR #38969)

    • Original Ask 1: "When the store holds a terminal row for the id, it wins over a non-terminal ring entry."
    • Reading: the literal rule turned consumed-suspension-restore.test.ts red ("records the run as paused again, so the repair is not invisible"): restoreConsumedSuspension writes a NEWER paused ring entry beside the run's old failed row, and the literal rule would read that restored approval run as failed to the approvals strict read, which is the same wrong-ending harm this card fixes, moved onto restored runs.
    • Correction (target unchanged, narrowed to what the reading proves): a terminal store row wins over a non-terminal ring entry unless the store also holds a live pause for the run (store.load), which keeps the ring entry the answer. Every case the card names (another process finished the run; a terminal row with no live pause) answers the terminal row. Default and strict reads change together; strict decides only what a store failure becomes. The zone takes the dev's option A; option B (literal rule, rewrite the restore pin) is not taken. L1 may weigh it.
    • The published AutomationEngine.getRun docblock in engine.ts still states the old order. engine.ts is named by 37767 后续:审批读取的 fan-out 判断与引擎注释收尾(N14–N17、N23、stopOf) #38691's claim (7316360810), which also edits engine docblocks, so the one-line correction is handed to that claim, not added here.
  15. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim amendment 1 to claim 7315040666 · 2026-12-01T16:06Z
    Area: osa-data
    Session: session_01WGufzhKEbEnW8pwZRgK2gJ
    Branch: claude/issue-38674-terminal-row-wins (PR #38969, head 7ae89013)
    Adds to File surface: packages/services/service-automation/src/engine.ts (reason: the published AutomationEngine.getRun docblock only — it still states the old read order; the one-line correction describes this PR's new order, so it lands here; nothing else in the file).
    Serial constraints cleared: check-handover.mjs --inflight --paths=packages/services/service-automation/src/engine.ts --card=38674 reads OVERLAP with #38691's claim 7316360810 only through a bare-name mention ("the card's engine.ts is stale"); that claim edits engine-run-log.ts, not engine.ts. Seat ruling (2026-12-01T16:05Z, seat thread): #38969 makes this edit. This supersedes the hand-off line in premise correction 7316956240.

  16. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

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

    2026-12-01T19:09Z · Done: PR #38969 merged at 2026-12-01T19:09Z and closed this card (L1 delta ACCEPT 7319793452). Clearing pm:dispatched and the assignee: nothing is in flight here.

  17. removed
    pm:dispatched
    on Dec 1, 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:datadomain:serverpriority:p2

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions