Skip to content

Approvals: refuse an approval that cannot show itself on a closing field when it opens, and never write a closed value for an abandoned request (ADR-0162 item 7) #37766

Description

@objectstack-fleet

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Filing gate: ③ maintainer-directed · Source: ADR-0162 Execution item 7 (accepted by merge 972114d)

维护者速读

  • 做什么:对象在审批状态字段上声明了「已关闭」时,平台在发起审批那一刻检查配置;配置会让单据停在一个没走完的审批结果上的,直接拒绝发起并说明缺什么。审批被撤回时,平台不再把状态写回已关闭的值。
  • 用户会看到什么:配置不合格时,提交人发起审批会失败并看到原因,作者在编写时会先收到提示;撤回一张原本已批准又被重新送审的单据后,单据保持打开,需要重新审批。
  • 不做会怎样:多步审批中途撤回或卡住,单据可能显示「已批准」并锁死,而实际上后面的审批没走完。
  • 顺序:和「声明与执行」那张卡同一次发布;声明不能在这张卡之前对外可用。

What happens

The approval status mirror writes a request's status onto the field its step names (packages/plugins/plugin-approvals/src/approval-service.ts#mirrorStatusField). Once an object can close on that field (item 1), three things on main would leave a document reading a decision its approval did not finish, and closed:

  • A request that is abandoned, by its submitter's recall, by an administrator's override or by the sweep of a dead run, has the value the field held at submit put back. Where that value is a closed one, the document is closed again over edits no approval has seen.
  • An approval of several steps can stop between two of them with the earlier step's outcome on the field: a later step that mirrors onto another field or none, a write or a pause between two steps, a pending the field cannot show.
  • A request does not know which approval it belongs to. A child run knows only its immediate parent, and the two stamps a request carries live in its config snapshot, which the store cannot filter on.

The maintainer ruled both rules on 2026-11-26, on #36253: 「平台堵住:撤回不恢复关闭值」 (ruling record 7201405662, with the chosen option's text on 7202242844) and 「平台拒绝这种配置」 (ruling record 7205949718). ADR-0162 D5 carries them. The conditions below spell the second ruling out further than its option's words do; the record says so and the maintainer's merge adopted it.

Expected

Four slices, released with item 1.

A. The root run.

  • The automation service hands every run of a tree, to any depth, its root run: that run's id, the flow it was started on, the object of its record and when it started.
  • The approval node passes it to the plugin, and each request records its root run as it opens, in a column of its own that the store can be asked for.
  • A run started before this change gets its root run when the service resumes it, derived from the run's links to its parents, so that every request opened after the release records one.
  • This slice changes the automation service as well as the plugin, and owes its own semver judgement.

B. The check when an approval opens (D5, "An approval opens on a closing field only where the field can show it in progress").

  • At an approval's first request the node reads every approval step of the root run's flow and of each flow a subflow or a map in it names, to any depth, with each step's own mirror field and each object the step can act on, a map's item object included.
  • Where the object closes on a step's field at pending, returned, approved or rejected, the request is refused unless all of this holds:
    1. the field declares pending, and the object closes on neither pending nor returned;
    2. a state_machine rule on the field that declares the moves out of a closed approved or rejected has pending among them;
    3. the field carries no readonlyWhen, and none of its options for a request's status carries a visibleWhen;
    4. every approval step that can act on a record of the object names that field, a step in a map body counting as one that can act on the parent's record;
    5. no flow of the approval that runs as the user holds a node that can write the record or a line of it between two steps;
    6. no flow of the approval holds a node there that can pause the run, and the approval holds no map with an approval step in its body, at any depth, unless the node shows that none of its items is a record.
  • Between two steps is after one step's closed outcome and before the next step opens. The next step can be the same step opened again, so a node after the last step of a map body stands between two steps. The revise window of a returned request is not such a pause.
  • A node whose writes the check cannot read counts as one that writes. A node it cannot place counts as standing between two steps. An approval it cannot read whole is refused.
  • A later request of the same approval is not judged again. A request the plugin cannot place as first or later is not judged.
  • An object that closes on the field only on values of its own is asked nothing. In an application with no declaration nothing is read.
  • The refusal names what is missing. The same conditions are reported at authoring wherever the parts are in view together.

C. The mirror on an abandoned request (D5, "An abandoned approval never writes a closed value").

  • On every transition that abandons a request the mirror reads the object's closed values for the mirror field and never writes one, recalled included.
  • Where there is no recalled value it may write, it goes down the order: the value held at submit, the field's declared default, empty. A closed value is passed over at each step, and on a required field an empty value at submit is passed over for the default.
  • A closed value the approval did not write is left alone. The mirror places the abandoned request by its root run and asks its own table, in one probe, whether a request of the same approval on the same record had the value the field holds. Where it cannot tell, it goes down the order.
  • Every other write of the mirror is unchanged, and so is every write on an object that closes on no value of the mirror field.

D. The approvals guide.

  • What an abandoned approval leaves; what a field and a flow owe an approval on an object that closes on its outcome; what a refused opening is for the person who submitted.
  • It names the one mirror field for every step and the pause that may not stand between two steps, says that an approval of each item under a map runs as an approval of its own, and that an approval which does not mirror onto the closing field does not open a closed document.
  • It keeps the word "round" for the resubmissions of ADR-0044.

Carried from the contract reviews of ADR-0162

These are review notes the reviews sent to this card. Each is answered in the PR.

  • A node type with no descriptor (N43). "Counts as one that can pause" means a type that has an executor and publishes no descriptor. The two structural types, start and end, have no executor and cannot pause, so the end of a map body or of a subflow body refuses nothing. A test pins a map whose items are written out and whose body ends in end. The docs tell the author that a node type without a descriptor between two approval steps is refused.
  • The map rule is meant of the parent's object (N44). A map is refused where the parent's object closes on the field of a step that can act on its record. Two arms are pinned as not refused: an item's object that closes on the body step's field under a parent whose object does not; and a parent run that carries no record, the batch sign-off shape the showcase ships.
  • Error or notice at authoring (N45). The record says the conditions are "reported" at authoring. The option the maintainer chose says 报错, an error. This card states which it is where the object and the flow are in view together, and gives the reason. A refusal at publish as well, where the pair is in view, is the reading nearest the option's words, and ADR-0162's Alternatives does not list it: the card takes it or says why not.
  • An empty put-back on both kinds of field (N17). The record validator refuses an update that empties a required field only when the field is not readonly. It does not make that refusal for a readonly field, for a system column, or for a field that is required only when shown. The approval node's schema advises a readonly mirror field. The tests run the put-back on each configuration and pin the value the field keeps.
  • Tests counted by transition (N20). The override arm of recall admits a system context as well as an administrator. The abandonment tests are counted by the transition that abandons a request, not by who acts.
  • A trace when the mirror withholds a value (N21). The mirror warns today when it leaves a status unwritten because the field does not declare it. It also logs when it withholds a declared recalled or passes over a closed value, so that an author who closed on recalled can find why the field reads the default.

Done when

  • Slice A: a child run that was started before the release and opens a request after it records its root run. The automation-service change carries its own changeset and semver line.
  • Slice B: a test for each missing condition, and for each arm ADR-0162 Execution item 7 lists under "Its tests cover", among them: an object that closes only on values of its own; an application with no declaration; a step that names no mirror field or another field, ahead of and after a step the conditions concern; a map with an approval step in its body ahead of the parent's steps, between two of them and after the last, with its items read from an expression and written out in the node; a step two levels down; two child runs side by side; a flow the node cannot read; a writing node between two steps in a flow that runs as the user and in one that runs as system; a wait and a screen between two steps; the revise window; a visibleWhen on each status option; a later request of an approval that opened before the declaration; a later request whose earlier requests record no root run.
  • Slice C: the tests ADR-0162 Execution item 7 lists under "The mirror", across the three writers that abandon a request, among them: a field that declares recalled as an open value, as a closed value and not at all; a value at submit that is closed, open, empty on a required field, empty on a field that is not required, and not carried by the request; a field that holds a closed value the approval did not write; an earlier step's outcome with that step in the same run, in a child run and in the parent; a map in which only another item's request had the value; a request that records no root run; a default that is usable, closed or absent.
  • The six carried notes above are each answered, with the test or the sentence named.
  • Slice D is in the approvals guide.
  • A refused opening reaches the person who submitted as a failed run whose message says what is missing, in every locale the plugin carries.
  • The release rule holds: the key (item 1) is not published before slices A, B and C are in the same release.

Category ③: maintainer-directed. A build card of ADR-0162, child of #36253.
Grade: area:data · Feature · n/a (not a defect on main; it becomes one the day the key ships without it) · reach: every approval on an object that closes on its approval field · evidence: read (ADR-0162 D5 and its Readings; eleven contract reviews of PR #37606)
Suggested-grade: p2 · it gates the release of #36253's key, so it takes the grade of the card it blocks
Size: L (the automation service, the approvals plugin, a new column, the authoring report, the guide). Split along slices A to D before dispatch; A goes first and can land on main alone.
Business reason: carried from #36253 and the two rulings quoted above. A document must not read a decision, and be closed on it, when its approval did not finish.
Reader: seat 2 (repo:objectstack#2), one card thread per slice, effort high.
Release-order: slices B and C read the object's closed values, so they need item 1's key on the same trunk branch; they are not blocked on main. Slice A is blocked by nothing.
Clause-②: yes (widening) for slice A: a new member on what the automation service hands a node, and a new column on the request. No for B, C and D taken alone.
Metadata-protocol: none while the key is unpublished. The release that publishes the key carries added, and the conditions are part of what that key means; the seat confirms the line at the claim.
Dedupe: searched mirrorStatusField (open issues): 0 hits. Searched closedStates (all issues): 1 hit, #36253 itself.
Related: #36253, PR #37606 (ADR-0162), ADR-0044 (rounds of a request), the card for item 8 (what the check cannot read ahead).

Dispatch note: the card thread also reads the seat's private memo for this card before it starts.

Activity

  1. added
    priority:p2
    domain:server
    on Nov 27, 2026
  2. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:data · domain:server · Feature · priority:p2 · pm:queue · size M; rationale: closedStates (ADR-0162, topic #36253). An approval that cannot show itself on a closing field is refused when it opens, and never writes past a closed state. It ships with the key (#37768), so it is ordered beside it. p2.

  3. added
    pm:queue
    on Nov 27, 2026
  4. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

    Claim: PM loop round 1 · 2026-11-27T03:39Z
    Session: session_01L6bhgV6i8jfWwSXjpWJrjA
    Thread session: session_01L6bhgTqdjy64HwGVb7fwhM
    Account: os-sales
    Branch: claude/project-thread-3091w8
    Domain: domain:server
    Seat: repo:objectstack#2
    Area: s2-data
    File surface: slice A only (the root run): the automation service's run context handed to a node, the approval node and the approval plugin's request store (a root-run column), resume-time derivation for runs started before the change, their tests, one changeset per touched package; the thread names the files in its first report. Slices B, C and D are not in this claim.
    Container & model: M, mode:thread (card thread implements, no os-dev), model: default — no path-derived mandate, effort: high
    Clause-②: yes
    Metadata-protocol: none
    Responsibility: n/a — not a defect card
    Thread-read: 7208015907
    Premise: holds — ADR-0162 merged (PR #37606); slice A depends on nothing (card's Blocked-by line)
    Serial constraints cleared: none known; slices B and C wait for item 1 (#37768) on a trunk branch; the thread re-runs overlap-check before its first push

    The PR says Part of #37766; the card stays open for slices B to D.

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

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

    Seat ruling on slice A: the run that carries the record · 2026-11-27T05:30Z

    Recorded here so slices B and C can rely on it (contract review 7210688247, S1). It came from the design note of #37767, where the maintainer's two rulings are also posted.

    • What slice A records. Each approval request records its root run (the top of its run tree) and also the run that carries its record (record_run_id): the topmost run in the tree whose record is the same as the request's own, compared by object and record id. A map item that is not a record inherits its parent's record run.
    • Why. Item 8 (shape P) decides when an approval is over for a record. A subflow child that works on the same document belongs to the same approval of that record, while a map over line items opens approvals on other records.
    • Pins slice A carries. The root run itself; a map item child whose item is a record (its own record run); a subflow child that inherits its parent's record (the parent's record run).
    • A run placed before the release. Where the tree cannot be read whole, for example a parent that is no longer parked, the request opens with the root-run and record-run columns null, as the older-engine arm does. It is not refused. Slice B leaves a request it cannot place not judged, and slice C sends an abandoned request with no root run down the order, so slice A does not refuse that population either. That keeps Clause-②: yes (widening) true.
    • The set of between-two-steps stops stamped on requests belongs to slice B's opening check, not to slice A.
  7. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

    Released · 2026-11-27T21:20Z — answering triage 7228343677 on the seat mailbox.

    Slice A landed (PR #37820, merged 2026-11-27T06:38Z). Slices B, C and D are not in flight: no thread, branch or PR. The maintainer closed the seat's data area for new work at 2026-11-27T15:43Z, so the card goes back to pm:queue, unassigned.

    Resume-from: 7210700837 (the seat's ruling on slice A, the root run that B and C rely on). B and C need item 1's closing-state key on the same trunk branch (the card's Release-order line); the release rule stands: the key is not published before A, B and C share a release.

  8. added
    pm:queue
    and removed
    pm:dispatched
    on Nov 27, 2026
  9. 29 remaining items

  10. added
    pm:queue
    and removed
    pm:dispatched
    on Nov 30, 2026
  11. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

    Claim: PM loop round (seat, delivery only) · handover from repo:objectstack#2 (release 7272911282)
    Provenance: the maintainer (Warren, os-warren), verbatim 「审批专题第 5 块 以及后续让 3号座位接手」, os-warren's fleet project timeline, 2026-11-30T08:23Z; released to this seat in 7272911282 (full state in 7272899889 on #37767).
    Session: session_01ADHkmSAjFEZHRpRq3WCj6z
    Account: os-steve
    Branch: claude/o5-data-approvals-trunk (this card's slices are on it; it reaches main by PR #38497)
    Domain: domain:server
    Seat: repo:objectstack#3
    Area: o3-D
    File surface: delivery only, no edit in this round: the card's own files on the trunk, packages/lint/src/validate-approval-closed-states.ts, packages/lint/src/validate-approval-closed-states.user-text.ts, packages/metadata-core/src/approval-opening.ts and their tests, reach main by the trunk → main PR #38497. Shared barrels and suites that PR also touches are resolved there, under #37767's claim (7273042270) by amendment, after piece 5 and #38601.
    Container & model: XS, mode:none (no dev in this round), model: default, effort: medium
    Clause-②: yes (widening), as the slices on the trunk declared (the judge's exports on @objectstack/metadata-core, and a new rule id); nothing new in this claim
    Metadata-protocol: graded at the PR as the trunk slices declared (none)
    Responsibility: n/a — not a defect card
    Thread-read: 7272911282
    Premise: holds as handed over; nothing is built on this card until #38497 is taken up.
    Prior rulings read: as recorded on the card's earlier claims (7264936984 / 7264915982) and on #37767's release 7272899889. No conflict.

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

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

    2026-12-01T02:35Z · Seat repo:objectstack#3 closes this card as completed. Every Done-when line is on main, released with the key in PR #38810 (merged, 440574f62c):

  14. 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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions