Skip to content

feat(approvals): the check when an approval opens, and the between-two-steps stamp (ADR-0162 item 7, slice B) - #38496

Closed
objectstack-fleet[bot] wants to merge 8 commits into
claude/project-thread-yxhepsfrom
claude/project-thread-fkdrk9
Closed

objectstack-fleet[bot] wants to merge 8 commits into
claude/project-thread-yxhepsfrom
claude/project-thread-fkdrk9

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Part of #37766

Clause-②: yes
Metadata-protocol: none

维护者速读

What changes

ADR-0162 Execution item 7 "The check", as revised on 2026-11-27, in @objectstack/plugin-approvals only. This is slice B; slice A (root run and record run) is on main via #37820, slice C (the mirror on an abandoned request) and slice D (the guide) are separate.

  • approval-opening-check.ts (new). A pure read of the approval whole over an OpeningCheckSource: the root run's flow and every flow a subflow or map names (by package slot where a name is shared), to any depth. It propagates the objects each flow's steps can act on (a subflow body acts on its caller's record; a map body on its items' object where an item may be a record, on the caller's where an item may not be), then builds one graph of the whole approval (containers and calls as entry/exit pairs; loop and map bodies repeat or run zero times; parallel branches interleave; a try region fails into catch and to the exit) and answers: whether a step touches an object that declares closedStates, the between-two-steps set, and the gaps.
  • ApprovalService.judgeOpening, called in openNodeRequest before the row is written. Placement by root run: no root run, not judged; a later request of the approval is not judged and copies the first request's set; a request on the record since the root run started that records no root run makes the request unplaceable, not judged. Nothing is read in an application where no object declares the key (registry.getAllObjects). Refusal: VALIDATION_FAILED: with a lead sentence and one sentence per gap, in the run's locale (AutomationContext.locale, threaded from the node).
  • sys_approval_request.between_steps_json (new, engine-written, read-only, searchable like node_config_json): a JSON list of { flow, node }, null where the approval touches no closing object or the request could not be placed. Label and help in all 11 locales.
  • The host check. ApprovalService.noteSweepClockScheduled(), called by the plugin once its sweeps are scheduled on the host's job service; until then an approval touching a closing object is refused at its first request.
  • approval-opening-refusal.ts (new) and twelve approvalOpening* sentences in all 11 catalog packs.
  • status-mirror-closing-field-refusal.integration.test.ts (piece 2 of Approval status mirror: a write that does not land, a run that ends between two steps, and a decision whose run cannot resume must not leave a document closed on an unfinished approval (ADR-0162 item 8) #37767) now notes the sweeps on its hand-built service, since its object declares closedStates.

Why

ADR-0162 D5: an approval on an object that closes on its approval field must be able to show itself in progress there, or the record closes on an unfinished approval. The maintainer chose that the platform refuses such a configuration (7205949718 on #36253). #37767 pieces 3–5 read the stamp (design note 7210179412, question 3, T2).

Readings

  • The between set (T2). A node other than a step is in the set where a step can come before it and a step can follow it. A step is in the set where a later step can follow it, so a run that stops on a decided step with no later step logged reads "between" exactly when it was. The last step is not in the set, so a stop after it reads as finished. A map or loop whose body holds a step is in the set where it is entered before a step and left after one (between one item's or pass's step and the next, the run is parked at or back on it); a subflow is not, since its body runs once. The read is context-insensitive and errs one way: a node that could stand between two steps on some path counts.
  • The writing-node condition is withdrawn (ADR as revised). Pinned: an update_record between two steps of a runAs: 'user' flow is not refused.
  • N43, a node type with no descriptor. Counts as one that can pause, as does a type the engine cannot be asked about; start and end cannot pause, so the end of a map or subflow body refuses nothing (pinned: a map with written-out items whose body ends in end). aliasOf is followed to the canonical descriptor, as the engine's pause gate does. The revise window (approval_revise) is excepted; subflow and map are read by their bodies; region containers carry descriptors without supportsPause and their regions' nodes are judged themselves.
  • N44, the map rule is of the parent's object. A map with an approval step in its body is refused where the parent's object is one a concerned step acts on, unless its items are written out and none is a record (an object with a string id). Pinned as not refused: an item object that closes on the body step's field under a parent whose object does not; a parent run with no record (the batch sign-off shape).
  • N45, error or notice at authoring. An error: this slice refuses at the approval's first request, where the object and every flow are certainly in view together. On the seat's reading (relayed 2026-11-29 05:24Z), a refusal at publish as well rides 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 as its own slice PR on the same trunk after this one, with the claim re-posted first; the ADR line goes on the weekly ADR card ADR revisions, week of 2026-11-29: rolling checklist of ADR text out of step with main (one governed PR) #38438 when it lands.
  • A failed read of the request store opens the request unjudged (logged at warn), never refused: refusing a later request on a guess would end its approval between two steps.

Verification

  • approval-opening-check.test.ts: 45 arms over fixtures, each D5 condition, own-value closing (also with a state_machine keeping one final), no declaration, no closing field (stamped, not refused), other/no field ahead of and after, a step two levels down, two child runs side by side under parallel, try_catch, a loop body, the map arms (expression items ahead/between/after, with itemObject, written-out items none/one record, parent not concerned, batch with no record), the stamp for a linear flow, a branch passing over a step, a subflow, a map body with its only step, wait and screen in both flow kinds, a type with no descriptor, aliases, the revise window, visibleWhen on each status option, an unreadable flow, the host.
  • approval-opening-check-37766.integration.test.ts: 7 tests on the real kernel, ObjectQL (SQLite) and automation engine: opens and stamps, later request copies the stamp, refused with the sentence and no row, the locale (zh-CN), a later request of an approval opened before the declaration not judged, a later request whose earlier request records no root run not judged (reverse-verified: removing the rule turns it red), the no-job host.
  • pnpm --filter @objectstack/plugin-approvals exec vitest run: 2054 tests, 1 failed on the first run (the search-set ledger, fixed by adding the column to searchableFields), that test re-run green.
  • pnpm --filter @objectstack/plugin-approvals run typecheck (test layer held in its debt ledger); node scripts/check-i18n-bundles.mjs: in sync.
  • dispatch-gates.mjs --commands: 117 repo-level check:* and node scripts/* gates run at the head, 115 green. 2 NOT MEASURED (prerequisite exit 3, not a finding): check-plugin-teardown-shape --self-test needs an unshallow clone; check:dual-build-cjs-loads needs dist/ of packages this diff does not touch. The spec / metadata gates the list also names belong to files already on the trunk, not to this diff.
  • overlap-check.mjs --base=origin/claude/project-thread-yxheps: clean against the trunk, fix(approvals): an abandoned approval never writes a closed value on its status mirror (ADR-0162 item 7, slice C) #38485 and feat(objectql): a record in a closed state, and its lines, are closed to change (closedStates, ADR-0162 D1-D7, D10) #38421.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5nzgcVrZ8Neqqd1AFi

…ts status mirror

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2
…n its status mirror

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2
…o request can hold

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2
… trunk (ADR-0162 item 7)

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2
…o-steps stamp (slice B)

ADR-0162 Execution item 7 "The check", as revised on 2026-11-27. At an
approval's first request the plugin reads the approval whole (the root
run's flow and every subflow/map body, to any depth) and:

- stamps the between-two-steps set on the request (new engine-written
  column between_steps_json); later requests of the approval copy it;
- refuses the opening, VALIDATION_FAILED with one sentence per gap in
  the run's locale, where a step mirrors onto a field its object closes
  on at a request status and a D5 condition fails, where a flow cannot
  be read, or where the host runs no job service.

Not judged: no object declares closedStates; no root run; a later
request; a request that cannot be placed. The writing-node condition
is withdrawn and pinned as not refused.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5nzgcVrZ8Neqqd1AFi
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-approvals, touching 118 documentable anchor(s).

36 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json bfe2df88b98a725c13166a98b3a2b6b382ca5ba1.

⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: created_at (literal, 49 pages)
  • 20 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 253 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 125 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json bfe2df88b98a725c13166a98b3a2b6b382ca5ba1 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 89d126702ebc4ffab4e9e9fe2c12d790c967e34a — the merge of head c84dfff49ef07cffde7a510304874735dc4b4ea1 into base bfe2df88b98a725c13166a98b3a2b6b382ca5ba1, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older claude/project-thread-yxheps holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 89d126702ebc4ffab4e9e9fe2c12d790c967e34a && git checkout 89d126702ebc4ffab4e9e9fe2c12d790c967e34a
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin bfe2df88b98a725c13166a98b3a2b6b382ca5ba1 c84dfff49ef07cffde7a510304874735dc4b4ea1 && git checkout -B drift-repro bfe2df88b98a725c13166a98b3a2b6b382ca5ba1 && git merge --no-ff c84dfff49ef07cffde7a510304874735dc4b4ea1

node scripts/docs-audit/affected-docs.mjs --json bfe2df88b98a725c13166a98b3a2b6b382ca5ba1

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs bfe2df88b98a725c13166a98b3a2b6b382ca5ba1 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…e changeset is patch

The abandoned-request status-mirror tests (merged from the trunk) now note
the plugin's sweeps on their hand-built service, as a host with a job
service does, and open the no-pending arm before the object declares
closedStates, the case the opening check does not judge. The changeset is
graded patch: the metadata protocol is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5nzgcVrZ8Neqqd1AFi
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-project-manager · session_01FEkQ5nzgcVrZ8Neqqd1AFi

Superseded by #38499 at 2026-11-29T06:05Z: the approvals trunk moved to claude/o5-data-approvals-trunk (the area's revision of the trunk rule), and the relay has no op that changes a pull's base, so the same head branch is reopened there as #38499. This pull is closed unmerged; nothing is lost, its commits are #38499's.

The Check Changeset failure here (the entry graded minor under Metadata-protocol: none) is fixed on the branch: the entry is patch.

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

Labels

documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants