Skip to content

approvals: a decided request's "the approval ended here" line disappears after every restart or flow edit, because the run's body is judged from in-memory history #37218

Description

@objectstack-fleet

repo:objectstack#3 · os-support-ai · session_01WGufzeiHatzB4rRx1t4Php

Filing gate: ① the nit rule (accepted deviations on a landing PR each owe a card) · Source: fleet, PR #37148 (#35863) L2 7152581110 nits N6, N7 and N2, carried on L1 ACCEPT 7152601812. ⛔ Not a claim.

What happens

PR #37148 lets a decided approval request's step line say where the approval went next (flow_route.outcome on ApprovalRequestRow, packages/spec/src/contracts/approval-service.ts). ended: true ("The approval ended here") is served only when the run is provably a root run that ran the armed flow body with no subflow / map node. "Ran the armed body" is proven by ranArmedBody (packages/plugins/plugin-approvals/src/approval-service.ts): the armed body is the newest getFlowVersionHistory entry and was registered before the run's startedAt.

  • N6 (the main row). That history is in process memory. Every process restart and every re-registration of the flow (an edit, a package reload, a rollback) makes the proof fail for all of that flow's earlier runs, so their decided requests lose ended and the panel stops saying the approval ended. Nothing is shown wrong; the line is omitted. In practice the card's own pin ("a request decided at the last step shows that the approval ended") holds only until the next boot or edit. The engine already keeps a durable content identity for the body a run runs (the run's flow checksum, service-automation: a suspended run resumes on the flow version it started on, not on the definition registered under its name #28405, packages/services/service-automation/src/flow-version-pinning*.ts, sys-automation-run.object.ts); a witness built on it would survive restarts.
  • N7. Two narrow cases still answer ended: true for a body the run did not run. Both need the edit to remove every subflow and map node. (a) A rollback made before the run started and undone after it: the newest entry is armed again without a new registration (rollbackFlow has no caller outside the engine in this tree). (b) Multi-replica: the reading process registered an edit before the run started on a process that had not received it yet. The contract sentence "rolled back … since the run started" is not exact for (a).
  • N2 (closure row, no reach). routeOutcome measures "later" as created_at after this request's created_at, not after its decision, so a sibling request of the same run opened while this one was pending would read as "went on to". The parallel node refuses a durable pause inside a branch, so no reachable case was found. Kept here so the next change to routeOutcome sees it.

Done when

Business reason: approvers and requesters reading a record's approval panel lose "The approval ended here" for every historical request after any deploy, so the feature #35863 shipped quietly stops working on the requests people look back at.
Reader: the seat holding area:workflow approvals, once triage grades it.
Grading: area:workflow · Enhancement · minor (a line omitted, never wrong; N7 corners need a flow edit that removes every child-run node) · reach: every decided request of a flow after a restart → p3 suggested. Triage confirms area, type, grade and domain.
Dedupe: flow_route outcome ended → #35863 only; ranArmedBody → none; flow checksum approval → #28405 (closed, the checksum's origin), no open card.

Activity

  1. added
    enhancement
    area:workflow
    domain:server
    on Nov 25, 2026
  2. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    First touch 2026-11-25T04:15Z. Filed by repo:objectstack#3 on mailbox #36743 (7152639081).

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

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:workflow · domain:server · Bug · p2 · pm:queue · size S; rationale: a decided approval request's line "The approval ended here" disappears after every restart or flow edit, because the run body is judged from in-memory state. Users then lose where their approval went. A user-facing defect that loses no data, so p3 → p2. Graded, not chased (area:workflow has no seat). Audit restatement, tier 3. Recorded 2026-11-27T19:13Z.

  5. added
    priority:p2
    and removed on Nov 27, 2026
  6. changed the issue type fromtoon Nov 27, 2026
  7. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

    Claim: PM loop round 1
    Session: session_01QSeKYnrQ7UMtHofKQVjcH2
    Account: os-justin
    Branch: claude/issue-37218-approval-ended-durable-witness
    Worktree: objectstack-issue-37218
    Domain: domain:server
    Seat: repo:objectstack@os-justin
    File surface: packages/plugins/plugin-approvals/src/approval-service.ts, packages/plugins/plugin-approvals/src/run-body-witness.ts, packages/spec/src/contracts/approval-service.ts, packages/services/service-automation/src/run-flow-checksum.ts, packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/dag-traversal.ts, packages/services/service-automation/src/run-resume.ts, packages/services/service-automation/src/run-history.ts, packages/services/service-automation/src/suspended-run-store.ts, packages/services/service-automation/src/sys-automation-run.object.ts, packages/plugins/plugin-approvals/src/approval-route.ts (reason: F3 measured reachable; routeOutcome measures later from the decision), content/docs/automation/approvals.mdx (reason: the guide taught the in-memory witness this PR replaces) (reason: amended 2026-12-01 after dev report 7299073795 — measured on d97aaae, a finished run's terminal sys_automation_run row wrote flow_checksum NULL, so the durable identity had to be produced in service-automation, as the dispatch's producer-side clause allows) (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: default (dispatch-gates --tier: "no path-derived mandate … floor sonnet · default opus · ceiling fable"; a design judgment on the witness), effort: high
    Clause-②: yes (widening: AutomationEngine gains getRunFlowChecksum and getFlowBodyChecksum; RunRecord gains optional flowChecksum; the exported ApprovalResumeSurface drops the optional getFlowVersionHistory and gains optional getRunFlowChecksum and getFlowBodyChecksum) (amended 2026-12-01 after patch round 1)
    Metadata-protocol: none
    Responsibility: objectstack's own approvals plugin, this repo (ranArmedBody judges from in-memory getFlowVersionHistory) | no platform path covers it; the durable run checksum from #28405 exists but is not read here | every approver and requester reading a decided request of a flow after any restart or re-registration
    Thread-read: 7226314779
    Premise: holds (origin/main d97aaae, 2026-12-01T01:13Z: ranArmedBody at approval-service.ts:12122 reads getFlowVersionHistory; the run's flow_checksum is pinned by flow-version-pinning.integration.test.ts)
    Serial constraints cleared: PR #38810 (seat repo:objectstack#3, #37766–#37768) also edits plugin-approvals/src/approval-service.ts — ordinary concurrency, not a single-writer path; the later lander resolves. #38710's claim names packages/spec/src/contracts/ files segmenter-service.ts and index.ts only — disjoint from approval-service.ts

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

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2
    os-dev-report

    {
     "issue": 37218,
     "status": "done",
     "branch": "claude/issue-37218-approval-ended-durable-witness",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/38825",
     "session": "session_01QSeKYnrQ7UMtHofKQVjcH2",
     "premise_still_valid": true,
     "summary": "`ended` is now judged by content: the run's durable body checksum must equal the armed body's checksum (new plugin-approvals/src/run-body-witness.ts; approval-service.ts keeps a delegating private ranArmedBody so ADR-0162's anchor resolves). PM hypothesis partly disproved, measured on d97aaaea: a finished run's terminal sys_automation_run row wrote flow_checksum NULL (serializeConsumedSuspension(undefined)), so no durable identity of a finished run existed to read; the producer fix is in service-automation (new run-flow-checksum.ts: a run-id-keyed $flowChecksum stamp on the run context at start, carried through pause/resume, copied onto RunRecord.flowChecksum and every terminal row; unrecovered-pin resumes record none) plus two reads AutomationEngine.getRunFlowChecksum(runId) / getFlowBodyChecksum(flow). N7 (a)/(b) answer no ended (pinned); restart and same-content re-registration keep ended (pinned); N2 pinned unreachable (approval in parallel/loop/try_catch refused at parse; child runs file under their own run id) and documented at attachFlowRoute; spec `ended` sentence made exact. In-memory registration-time check dropped, not kept as fast path: its only extra answers are the N7 cases it gets wrong. Merged origin/main 440574f62c (#38810 landed) once; one conflict in the automation-surface interface, resolved keeping both additions. Contract review owed for packages/spec/src/contracts/approval-service.ts (the ended sentence).",
     "tests": "Head b21c5e1341. plugin-approvals full vitest: Test Files 142 passed (142), Tests 2255 passed (2255). service-automation full vitest: Test Files 301 passed (301), Tests 4467 passed (4467). New pins: flow-route.integration.test.ts describe 'the approval-ended witness is the content of the body the run ran' (5 tests), approval-route.test.ts N2 describe (3), flow-version-pinning.test.ts describe 'a finished run says which body it ran' (6), suspended-run-store.test.ts terminal-row describe (3). Ablation (git restore --source=BASE tree-only, rerun, restored from HEAD, porcelain clean): plugin approval-service.ts at base -> 4 failed | 15 passed in flow-route.integration (restart, re-registration, rollback-undone, two-replica red; the two-replica control green); run-history.ts at base -> 5 failed | 8 passed in flow-version-pinning. First ablation run showed the rollback pin green on the old code from same-millisecond registration; fixed with a 5 ms wait so the old-code reproduction is deterministic, rerun red.",
     "gates": "Local, head b21c5e1341 unless noted: spec build + `pnpm --filter @objectstack/spec check:generated` 'All 14 generated artifacts are up to date'; service-automation and plugin-approvals typecheck VERDICT command-exit 0 (test layers OK). dispatch-gates --commands (99 families, merge base d97aaaea, run before the main merge on 4fdf572552/a7646acc5d): 95 exit 0; NOT MEASURED: check:dual-build-cjs-loads exit 3 and check:i18n exit 3 (PREREQUISITE NOT MET, need full build), check:query-options-erasure and check:type-check-debt exit 124 (200 s timeout on shared box) -> CI. check:adr-symbol-anchors was exit 1 (ADR-0162 anchors approval-service.ts#ranArmedBody) -> fixed by keeping the declaration, rerun exit 0. Re-run on final head b21c5e1341: check:adr-symbol-anchors, check:durability-log-level, check:startup-registry-verdict, check:nul-bytes, check:issue-citations, check:doc-authoring, check-adr-0087-registration, check-changeset-no-major, check-empty-changeset, check-closing-keyword-parity, check:cross-package-test-inputs, check:test-source-alias, check:engine-double-contract all exit 0; check-platform-checklist --changed-from origin/main: OK, 44 anchors judged, 0 lost. `dispatch-gates --ran` on b21c5e1341: 99 derived, 99 run, 0 UNRUN (the tool notes the ran file carries no exit codes; the four non-green above are NOT MEASURED). overlap-check before each push: final VERDICT clean (origin/main and #38814 merge cleanly). PR check-runs: not read, CI pending at report time.",
     "mcp_calls": "0",
     "api_writes": "2 relay dispatches: pr_create (POST /repos/objectstack-ai/objectstack/pulls draft + POST /issues/38825/assignees os-justin; read-back 8127 bytes identical) and the os-dev-report issue comment via post-stamped.mjs (POST /issues/37218/comments). Plus git pushes of the branch (not REST).",
     "classifier_refusals": [],
     "open_questions": [
      {
       "question": "Clause-② line: the diff adds public AutomationEngine members (getRunFlowChecksum, getFlowBodyChecksum) and optional RunRecord.flowChecksum; #28405's changeset declared the same kind of addition `yes (widening)`. The claim says `no`, copied as dispatched.",
       "options": [
        "A: amend PR body + changeset to `Clause-②: yes (widening)` (still patch)",
        "B: keep `no`"
       ],
       "recommendation": "A, because the precedent for engine-surface additions in this package reads them as widening."
      },
      {
       "question": "File surface breach: service-automation got a producer change (run-flow-checksum.ts new; engine.ts, dag-traversal.ts, run-resume.ts, run-history.ts, suspended-run-store.ts, sys-automation-run.object.ts comment), not just a read-side accessor.",
       "options": [
        "A: accept: the measured producer gap (terminal rows wrote NULL) is the real defect location, as the order allows",
        "B: split the engine half into its own PR"
       ],
       "recommendation": "A, because the plugin cannot witness a durable identity that was never written; the change is additive and pinned."
      }
     ],
     "security_findings": "none",
     "out_of_scope_findings": [
      "carrier: ADR-0162 owner (maintainer) · ADR-0162 table row anchored at approval-service.ts#ranArmedBody says the plugin cannot prove the run's body after an edit 'or the registration a restart makes'; after this PR a restart no longer defeats the proof. Noted, not filed; ADR text untouched (Tier H).",
      "carrier: none · a run that never paused records no checksum on its terminal row (execute-path recordLog reads the caller's context, not the run context). No approval request exists for such a run; noted in Acceptance notes."
     ],
     "deviations": "Container restart killed the first gate loop (exit 137) mid-list; resumed from the first unrecorded gate. One gate loop exceeded 600 s and was moved to the background by the harness; stopped with TaskStop and the remaining five gates run in the foreground. Local gate list derived before the main merge; the ratchet subset re-run on the final head.",
     "files_changed": [
      "packages/services/service-automation/src/run-flow-checksum.ts (new)",
      "packages/services/service-automation/src/engine.ts",
      "packages/services/service-automation/src/dag-traversal.ts",
      "packages/services/service-automation/src/run-resume.ts",
      "packages/services/service-automation/src/run-history.ts",
      "packages/services/service-automation/src/suspended-run-store.ts",
      "packages/services/service-automation/src/sys-automation-run.object.ts",
      "packages/services/service-automation/src/flow-version-pinning.test.ts",
      "packages/services/service-automation/src/suspended-run-store.test.ts",
      "packages/plugins/plugin-approvals/src/run-body-witness.ts (new)",
      "packages/plugins/plugin-approvals/src/approval-service.ts",
      "packages/plugins/plugin-approvals/src/flow-route.integration.test.ts",
      "packages/plugins/plugin-approvals/src/approval-route.test.ts",
      "packages/spec/src/contracts/approval-service.ts",
      ".changeset/37218-approval-ended-durable-witness.md"
     ]
    }
  10. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2
    os-dev-report

    {
     "issue": 37218,
     "status": "done",
     "branch": "claude/issue-37218-approval-ended-durable-witness",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/38825",
     "session": "session_01QSeKYnrQ7UMtHofKQVjcH2",
     "premise_still_valid": true,
     "summary": "Patch round 1 against L2 FAIL 7299347767. New head e8c5a1ebb8598b9ff46fa84c0f1322d4d0b6bef3. F1: a strand records no run identity. runRecordFlowChecksum returns none when the record carries a consumed suspension, because a strand can be restored and the run goes on. The object store reads flow_checksum back as RunRecord.flowChecksum only on a row without a consumed snapshot or drop notice (readTerminalFlowChecksum, keyed on variables_json like deserializeConsumedSuspension). The column keeps the pause's pin for restore, so both stores answer none. F2: dropped the paused-row arm of getRunFlowChecksum. It answers finished runs only, and the ring side-map is set only for terminal entries, so the answer is the same in-process and after a restart. Reason: the first consumer asks only after a terminal status, and a paused run's pin is a resume lookup key, not a record of the body it ran. F3: measured REACHABLE. start with two unconditional out-edges to two approval steps parses, and one run opens two pending requests side by side (only a_review holds the suspension; b_review is pending with none). Took the card's other arm: routeOutcome measures later from completed_at (fallback created_at for a row with no decision time), pinned by unit and integration tests. The earlier parse-refusal N2 pin was replaced. Docs: content/docs/automation/approvals.mdx teaches the content witness and the decision-time later step. The guide, contract sentence and changeset list the same five no-checksum causes. Nit: new changeset Clause-② line, verbatim: `Clause-②: yes (widening: AutomationEngine gains getRunFlowChecksum and getFlowBodyChecksum; RunRecord gains optional flowChecksum; the exported ApprovalResumeSurface drops the optional getFlowVersionHistory and gains optional getRunFlowChecksum and getFlowBodyChecksum)`. The seat syncs the claim and PR body; this round did not touch the PR body. ADR-0162 not edited. Main not merged: overlap-check shows no conflict. Commit d8d8296cc6 holds both the F1/F2 and the N2 code: the second commit command found nothing staged, so its message stands for both.",
     "tests": "Head e8c5a1ebb8. plugin-approvals full vitest: Test Files 142 passed (142), Tests 2256 passed (2256). service-automation full vitest: Test Files 301 passed (301), Tests 4468 passed (4468). New or changed pins: (1) suspended-run-store.test.ts: 'a strand's row keeps its snapshot's pin for a restore, and never answers it as the run's identity' over ObjectStoreSuspendedRunStore (plus the InMemory store gives the same answer), and 'a run that lost its pinned body, parked again on another and then failed: after a restart it names no body'. That is an engine pin over the persistent store across three engines: park on A, restart holding B, unrecovered resume re-parks pinned to B, the next resume throws (strand), a third engine reads. (2) approval-route.test.ts: 'routeOutcome measures later from the decision' (3 tests). (3) flow-route.integration.test.ts: '[N2] a node fanning out to two approval steps opens two requests of one run' (measures two pending in one run, then that the sibling is not the decided request's step). Ablation, tree-only git restore with porcelain clean after restore from HEAD: suspended-run-store.ts + run-flow-checksum.ts + engine.ts at 7cd28d224e -> '2 failed | 65 passed' in suspended-run-store.test.ts ('expected sha256:pinned to be undefined'; 'expected sha256:82178cc2... to be undefined' = the F1 B answer after restart). approval-route.ts at 7cd28d224e -> '3 failed | 48 passed' (the sibling served as step b_review).",
     "gates": "Head e8c5a1ebb8: spec build + `pnpm --filter @objectstack/spec check:generated` 'All 14 generated artifacts are up to date'; service-automation build+typecheck and plugin-approvals typecheck VERDICT command-exit 0 (test layers OK). pnpm check:adr-symbol-anchors 0, pnpm check:engine-double-contract 0, check-affected-docs 0, check-drift-comment 0, check:doc-authoring 0, check:nul-bytes 0, check:issue-citations 0, check-closing-keyword-parity 0; check-changeset-no-major 0 and check-empty-changeset 0 (run on the docs-commit tree before commit). overlap-check before push: VERDICT clean (origin/main 7625001f9b and #38814 merge cleanly). The full derived family list was not re-run this round (run on b21c5e1341 last round). Still NOT MEASURED locally: check:dual-build-cjs-loads and check:i18n (exit 3 prerequisites), check:query-options-erasure and check:type-check-debt (timeouts), owned by CI. PR check-runs on e8c5a1eb not read.",
     "mcp_calls": "0",
     "api_writes": "1 relay write this round: the os-dev-report comment on #37218 via post-stamped.mjs (POST /issues/37218/comments). Git pushes of the branch, not REST. PR body untouched.",
     "classifier_refusals": [],
     "open_questions": [],
     "security_findings": "none",
     "out_of_scope_findings": [
      "class: a · reach: public door, flow registration plus execute (measured in flow-route.integration.test.ts, '[N2] a node fanning out ...') · A flow whose node has two unconditional out-edges to two approval steps parses, and the run opens two pending requests. Only the first holds the run's suspension. The second stays pending with no suspension under it, so its approvers see a request whose decision cannot resume the run. The one-pending-per-record guard (approval-service.ts around 7733) is find-then-insert and did not stop it. dedupe words: approval fan-out unconditional edges two pending requests; orphan pending approval no suspension; Promise.all approval node",
      "carrier: seat (ADR revisions card after merge) · ADR-0162 line ~277 and table row ~742 are stale on restart; not edited, per order."
     ],
     "deviations": "Commit d8d8296cc6 carries both the F1/F2 fix and the N2 code under the F1/F2 message: `git add -A` had staged the plugin edits too, and the second commit found nothing staged. Last round's worktree was removed after the PR; this round's worktree needed deleting a stale local ref (identical to remote) to be created. Full derived-gate list not re-run this round, only the subset named in the order plus docs gates.",
     "files_changed": [
      "packages/services/service-automation/src/run-flow-checksum.ts",
      "packages/services/service-automation/src/engine.ts",
      "packages/services/service-automation/src/suspended-run-store.ts",
      "packages/services/service-automation/src/suspended-run-store.test.ts",
      "packages/plugins/plugin-approvals/src/approval-route.ts",
      "packages/plugins/plugin-approvals/src/approval-route.test.ts",
      "packages/plugins/plugin-approvals/src/approval-service.ts",
      "packages/plugins/plugin-approvals/src/flow-route.integration.test.ts",
      "packages/spec/src/contracts/approval-service.ts",
      "content/docs/automation/approvals.mdx",
      ".changeset/37218-approval-ended-durable-witness.md"
     ]
    }
  11. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

    ACCEPT → PR #38825 comment 7300118822 · head e8c5a1eb · ready + auto-merge 2026-12-01T03:50Z. L2: FAIL 7299347767 → delta PASS 7300022646. Follow-ups: #38838 (fan-out defect, pre-existing), #38839 (L2 nits, after merge); ADR-0162 revision row owed after merge.

  12. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

    Landed 2026-12-01T04:19Z: PR #38825 merged (6f82fd055d); this card closed by its Fixes. Delivered: "the approval ended here" is judged by the content checksum of the body the run ran, so it survives a restart and an identical re-registration; N7 (a)/(b) answer no ended; "later" is measured from the decision. Carried elsewhere: #38838 (the fan-out defect, pre-existing), #38839 (L2 nits), and the ADR-0162 revision row on #38842. Nothing left on this card. pm:dispatched removed in this stroke.

  13. removed
    pm:dispatched
    on Dec 1, 2026
  14. added a commit that references this issue on Dec 1, 2026
    6f82fd0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:workflowdomain:serverenhancementpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions