Skip to content

fix(service-automation): a runAs:'user' run carries its user's posture rung, so a platform administrator's flow is served the ledger's deployment-level rows - #28098

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-sl17ka
Oct 30, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-sl17ka

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #28070

Clause-②: yes (widening) — RunIdentityContext (barrel-exported), and so the data context resolveRunDataContext answers, gains an optional posture member, and FlowUserGrants gains one; a runAs: 'user' run seeded with PLATFORM_ADMIN is served the rows that rung admits.
Metadata-protocol: none
Skills-docs: updated here (content/docs/permissions/record-view-auditing.mdx, one sentence beside #26750's). grep -rn -i "posture" skills/objectstack-automation and grep -n -i "runAs" content/docs/automation/flows.mdx: no text states which facts a runAs: 'user' run carries beyond positions / permissions / tenant, so nothing else to change.

维护者速读

  • 改了什么:runAs: 'user' 的自动化运行现在带上运行用户的姿态等级(posture rung),取自请求路径同一次 resolveUserAuthzGrants 解析,本包不做第二次推导。以平台管理员身份运行的流程,能读到审计账本里的部署级记录(tenant_id 为空),和他本人的请求一致。
  • 为什么改:[Decision] Under the single posture, does an organization-scoped audit-ledger reader also read deployment-level ledger rows, or are those for the platform administrator only? #26750 之后部署级记录只给 PLATFORM_ADMIN,而运行上下文没有 rung,平台管理员的流程只看到组织行(收窄,不是泄露)。分诊裁定:走同一推导、不另起一套。
  • 风险与回滚:rung 只和推导出它的 grants 一起种下;门把已解析的 positions/permissions 带进来(含 agent 收窄上限)时不补 rung,不会放大。审批切换到裁决人时删掉提交人的 rung。runAs: 'system' 不变。回滚即 revert,无数据迁移。
  • 先看:packages/services/service-automation/src/run-resume.ts(seedRunGrants 与裁决切换各一处)、runtime-identity.ts(resolveRunDataContext 的 user 分支)、新测试 runas-user-posture-rung.integration.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/service-automation exec vitest run --maxWorkers=2 src/runas-user-posture-rung.integration.test.ts,预期 12 条全绿。
  • 需要你做的:无,席位落地。

What changes

  • The bridge (plugin.ts). The grants bridge the automation plugin wires already calls @objectstack/core's resolveUserAuthzGrants for the run's user; it now forwards that resolution's own posture beside the positions, permission sets, peers and email. Nothing in this package derives a rung.
  • The seed (run-resume.ts, seedRunGrants). The rung is seeded exactly when the run's positions and permission sets are resolved at setup (the needsGrants branch), so it always stands beside the grants it was derived from. A context that brought its own grants (a door's pre-resolved envelope, an agent's narrowed ceiling) gains no rung from a re-resolution, though it still gains its peers and email as before.
  • The decision switch (run-resume.ts, deciderSegmentContext). The submitter's rung is deleted with their other facts; the decider's segment is seeded with the decider's own. Without the delete, a decider the resolver answers nothing for would have kept a platform administrator's rung.
  • The data context (runtime-identity.ts). SeededRunContext.posture and RunIdentityContext.posture (both typed AuthzPosture from @objectstack/spec/security); resolveRunDataContext's user arm carries the seeded rung through runPosture, which drops a value that names no rung. The system arm is untouched.
  • Types (engine.ts, two small hunks). FlowUserGrants.posture, typed as SeededRunContext['posture'] so no import hunk; the seedRunGrants docblock (its contract) names the rung.

Why

Triage 6522159967: a runAs: 'user' run derives its rung through the same derivation a request uses, for the user it runs as, with no second derivation. Re-measured on main @ 549203d0: grep -n posture packages/services/service-automation/src/run-resume.ts hit only two unrelated comments (lines 314, 820; tenancy posture), and the control test below shows the administrator's request without the rung (the shape a run carried) served the organization row only.

Verification

Head cfd3bf44.

  • runas-user-posture-rung.integration.test.ts, 12 tests, two layers. Envelope (bare engine, recording node, resolver stub): the rung rides the data context for a user-only trigger, for a member, after an approval decision (the decider's), and is absent for carried grants, for a value that is not a rung, for a decider the resolver answers nothing for, and on runAs: 'system'. Real stack (ObjectKernel, ObjectQLPlugin, driver-sql on better-sqlite3, identity objects, SecurityPlugin, AuditPlugin's ledger read gate, the plugin's own bridge, single posture): the platform administrator's run is served every deployment-level platform_admin_standing_change row plus the organization's one; an organization holder of view_all_audit_log is served the organization row only, by run and by request, with or without the rung; a runAs: 'system' run is served all, as before.
  • Ablation 1, if (posture) out.posture = posture; disabled in runtime-identity.ts: 4 red (the card's reproduction, plus three envelope cells); the member and system pins stay green (unchanged).
  • Ablation 2, delete switched.posture; removed in run-resume.ts: 1 red (the unresolved decider keeps the submitter's rung).
  • pnpm --filter @objectstack/service-automation typecheck: exit 0. pnpm --filter @objectstack/service-automation test: 228 files, 2888 tests, exit 0.
  • dispatch-gates --commands derived 93 families; they and pnpm lint are running locally. The reconciled --ran result goes in the os-dev report on the card; CI runs every family here too.

Acceptance notes

  • Out of scope, card it: the REST automation door (packages/runtime/src/domains/automation.ts:204-205) and the action door (packages/runtime/src/action-execution.ts:2077-2078) forward the request's positions / permissions but not ec.posture, so a flow started there carries grants and no rung, and still fails closed for the rung's readers. Forwarding it touches AutomationContext (packages/spec/src/contracts/automation-service.ts) or the door's extra-key shape. The changeset and the docs sentence say so.
  • Request parity for the other readers of ExecutionContext.posture on a run (plugin-sharing hasPlatformAuthority, plugin-approvals' platform arm, observability's timing exposure): a platform administrator's run now answers as their request does. plugin-security's tenant-wall exemption already enforced the narrower of the carried rung and its capability probe, so a seeded rung never widens it.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (No packages/spec change.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes. (Running locally with the gates; CI reads it.)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (Not touched.)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English. (The 维护者速读 block is the maintainer's summary, as on the lane's other PRs.)
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cwHfcrFZ8RzH1TiP48

…e rung

Run setup takes the rung off the resolution it already makes for the run's
user (resolveUserAuthzGrants' own posture, forwarded by the grants bridge),
seeds it beside the positions and permission sets it was derived from, and
every data node carries it to the data engine. A context that brought its
own grants gains no rung; the decision switch drops the submitter's rung.
A flow run as the platform administrator is now served the ledger's
deployment-level rows, as their request is.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwHfcrFZ8RzH1TiP48
@github-actions github-actions Bot added size/m 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 Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/service-automation, touching 8 documentable anchor(s).

⛔ 3 release-owned page(s) name something this change touched. These are read-only:

  • content/docs/releases/v16.mdx (via AutomationEngine (symbol, a top-level class))
  • content/docs/releases/v17/17-0.mdx (via AutomationEngine (symbol, a top-level class))
  • content/docs/releases/v17/17-6.mdx (via AutomationEngine (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 58 of 210 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 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 — 10 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 6410029d1bb550a13429ec83f22eff523300de26 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from bfcd6c872b87cd732869de14fa88b3f8b04c6aec — the merge of head cfd3bf44b48c50445029fb6b65e90b4015e49025 into base 6410029d1bb550a13429ec83f22eff523300de26, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main 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 bfcd6c872b87cd732869de14fa88b3f8b04c6aec && git checkout bfcd6c872b87cd732869de14fa88b3f8b04c6aec
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 6410029d1bb550a13429ec83f22eff523300de26 cfd3bf44b48c50445029fb6b65e90b4015e49025 && git checkout -B drift-repro 6410029d1bb550a13429ec83f22eff523300de26 && git merge --no-ff cfd3bf44b48c50445029fb6b65e90b4015e49025

node scripts/docs-audit/affected-docs.mjs --json 6410029d1bb550a13429ec83f22eff523300de26

⚠️ 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 6410029d1bb550a13429ec83f22eff523300de26 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia

Contract-review-claim: session_016WV4czuTWNgKR22fKv7jia · head cfd3bf44b48c50445029fb6b65e90b4015e49025 · 2026-10-30T12:44Z

The lane seat writes the TIER_DEFAULT review record this PR owes (Clause-②: yes (widening), declaration face only; no packages/spec/src/** or governed path in the diff).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia

Contract review

Served-tier: TIER_DEFAULT
Head-sha: cfd3bf44b48c50445029fb6b65e90b4015e49025
Local-runs: none
Scope: packages/services/service-automation/src/runtime-identity.ts, packages/services/service-automation/src/run-resume.ts, packages/services/service-automation/src/plugin.ts, packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/runas-user-posture-rung.integration.test.ts + packages/services/service-automation/src/index.ts (exports), packages/runtime/src/domains/automation.ts (buildAutomationContext), packages/runtime/src/action-execution.ts (the flow action's automation.execute context), packages/spec/src/contracts/automation-service.ts (AutomationContext) (.changeset/28070-runas-user-posture-rung.md and content/docs/permissions/record-view-auditing.mdx are prose faces: the lane seat's ACCEPT)

Owed on the declaration face alone (Clause-②: yes (widening)); the diff touches no packages/spec/src/** and no governed path, so the tier is TIER_DEFAULT, written by the lane seat.

① Derived judgments

  • Published surface. service-automation/src/index.ts:205 re-exports the types RunDataContext / RunIdentityContext; RunIdentityContext gains optional posture?: AuthzPosture, so resolveRunDataContext's answer can carry it. FlowUserGrants (engine.ts) gains optional posture. Additive optional members: yes (widening) is right, and the claim (6520476174's sibling, 6522620080) was amended to match before the push.
  • One derivation. The rung is resolveUserAuthzGrants' own posture, forwarded by the plugin's grants bridge (plugin.ts); nothing in this package derives one. runPosture only validates the carried value against AuthzPostureSchema and drops anything else (fail closed).
  • Seeded only with the grants it came from. seedRunGrants sets posture inside the needsGrants branch, beside positions / permissions from the same resolution. A context that carried its own grants (a door's envelope, an agent's narrowed ceiling) gets no rung from a re-resolution. Pinned.
  • Decision switch. deciderSegmentContext deletes the submitter's posture with their positions, permissions, peers and email; the decider's segment is seeded for the decider. Pinned (ablation: delete off → red).
  • No injection path from a caller. Read on the head tree: the REST door's buildAutomationContext and the flow action's automation.execute context build the context key by key; a caller's body lands in params, never at the top level, so a request cannot set posture on a run. The remaining setters are in-process.
  • runAs: 'system' unchanged: no rung is resolved or carried; isSystem short-circuits first.
  • Direction. A run gains, at most, exactly what its user's own request is served; a rung below PLATFORM_ADMIN admits nothing a missing one did not. The measured case (a platform admin's flow reading the ledger's tenant_id NULL rows) is pinned red on main, green here.
  • Wrong: none found.

② Semver level

  • .changeset: @objectstack/service-automation patch, Clause-②: yes (widening) — … and Metadata-protocol: none, line-initial; the PR body carries the same. A non-protocol widening ships patch (AGENTS.md Post-Task Checklist step 3). Metadata-protocol: none: nothing an author writes changes.

③ Boundary flags

  • Out of scope, carded by the seat: the REST door (packages/runtime/src/domains/automation.ts:204-205) and the action door (packages/runtime/src/action-execution.ts:2077-2078) forward ec.positions / ec.permissions but not ec.posture, so a run started there still has no rung (fails closed). Forwarding it reaches AutomationContext (packages/spec) or the door's extra-key shape, so it is not this PR's. The changeset and the docs sentence both say so.
  • Docs: one sentence in record-view-auditing.mdx states which runs carry the rung and that door-started runs do not yet; it matches the diff.
  • Check-runs at this head: not complete when read. Landing waits for all green.

④ Design judgment

  • Carrying the rung the way org_user_ids and email already ride the run context, sourced from the one resolver the request path uses, is the right altitude: no second derivation, fail closed when absent or malformed, and it moves with the grants it came from. The decider switch treats it as the trigger user's fact, which it is.
  • Tests: the new integration file (12 cases) covers the platform-admin ledger read, a member's run unchanged, runAs: 'system', carried grants with no rung, a malformed rung, and the decision switch; ablations bite as reported.

Implemented-by: claude/project-thread-sl17ka
Reviewed-by: session_016WV4czuTWNgKR22fKv7jia (lane seat)

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia

Seat ACCEPT · PR #28098 · head cfd3bf44b48c50445029fb6b65e90b4015e49025 · 2026-10-30T13:03Z

维护者速读

  • 改了什么: 以「用户身份」(runAs: 'user')运行的自动化流程,现在带上该用户的权限档位(posture rung),与该用户自己发请求时一致。平台管理员身份运行的流程因此能读到合规台账里「不属于任何组织」的部署级记录(automation: a runAs:'user' run carries no posture rung, so a platform administrator's flow is served organization ledger rows only #28070)。
  • 为什么改: 以前流程运行只带了岗位和权限集,没带档位,所有按档位判断的读取都按「低一档」处理;平台管理员的流程只看到组织内记录(少读,不是多读)。
  • 风险与回滚: 档位只取自请求路径同一个解析器(resolveUserAuthzGrants),本包不另行推导;只在同一次解析出岗位/权限集时一起写入;审批换人时随提交人的其他身份信息一并清除;调用方无法通过请求体注入。回滚即还原 service-automation 四个文件。
  • 先看: packages/services/service-automation/src/run-resume.ts 的 seedRunGrants,和 runtime-identity.ts 的 runPosture。
  • 两分钟验证: 跑 runas-user-posture-rung.integration.test.ts(12 例)。
  • 需要你做的: 无(Tier S;契约复核 PASS,按本期落地授权由席位落地)。经 REST/动作按钮手动启动的流程仍不带档位,另立 automation: a flow started through the REST or action door carries the caller's positions and permission sets but not their posture rung #28099 交分诊。

席位核对

  • Shape: draft → main, Fixes #28070. 7 files (+415/−4): service-automation run-resume.ts, runtime-identity.ts, plugin.ts (grants bridge), engine.ts (two small hunks: FlowUserGrants.posture and the seedRunGrants docblock), a new integration test, one changeset, one docs sentence in content/docs/permissions/record-view-auditing.mdx. check-governed-merges --pr 28098: NOT governed.
  • Premise: re-measured on main by the thread: seedRunGrants seeded no posture; a platform admin's runAs: 'user' flow was served organization ledger rows only.
  • File surface: amended in the claim before the push (6522620080): four service-automation files; no edit to packages/core, packages/spec or ui/.
  • Contract review: Clause-②: yes (widening) on the PR body, the changeset and the claim (RunIdentityContext / FlowUserGrants gain optional posture). TIER_DEFAULT record by the lane seat, PASS, comment 6523187496, at this head.
  • Declarations: Metadata-protocol: none; @objectstack/service-automation patch. The docs sentence matches the diff, including that door-started runs carry no rung yet.
  • Out of scope: the REST door and the action door forward positions and permissions but not the rung → automation: a flow started through the REST or action door carries the caller's positions and permission sets but not their posture rung #28099 (p2, pm:retriage; route reaches AutomationContext).
  • Local (card thread): package tests 228 files / 2888 green; the new file's 12 cases green; ablations bite (posture carry off → 4 red incl. the card's repro; decider delete off → 1 red); typecheck exit 0.
  • Gate check-runs on this head: 50 total, 38 success, 12 skipped by the path filter, 0 failed. mergeable_state: clean.
  • Landing: Tier S, under the maintainer's landing grant for this term (2026-10-29 22:05Z, seat thread). Ready + auto-merge through the relay.

ACCEPT

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 30, 2026 13:04
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit cbb6df1 Oct 30, 2026
51 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-sl17ka branch October 30, 2026 13:21
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/m 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.

automation: a runAs:'user' run carries no posture rung, so a platform administrator's flow is served organization ledger rows only

1 participant