Skip to content

fix(plugin-security): a record an action body inserts is owned by the user who ran the action - #34957

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-34885-action-insert-owner-stamp
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-34885-action-insert-owner-stamp

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread
Fixes #34885
Clause-②: yes
Metadata-protocol: none

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

维护者速读

  • 改了什么:动作(action)脚本里用 ctx.api.object(X).insert 新建的记录,现在会把执行动作的用户写进 owner_id,和用户直接新建记录时一样。
  • 为什么改:以前这类记录的 owner_id 是空的;在私有对象上,普通用户运行动作后看不到、也改不了自己刚建的记录(qa 在差旅报销和服务台场景里都撞到了)。
  • 风险与回滚:只影响动作脚本里的新建,且只填空的 owner_id;flow、hook、种子数据和其它系统写入不变。回滚就是 revert 本 PR;已存的旧记录不会被改。 分派规则(assignment rules)此前会路由动作脚本建的无主记录,现在与直接新建一致归执行人、不再被路由。
  • 先看:packages/plugins/plugin-security/src/owner-anchor-stamp.ts(新规则全文);security-plugin-authz-middleware.ts 里 isSystem 放行前新增的那段,和 3.5 步改成共用函数的那几行;action-body-insert-owner-stamp.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/plugin-security exec vitest run src/action-body-insert-owner-stamp.test.ts,预期 23 个用例全部通过。
  • 需要你做的:无,席位落地。

What changes

An action body's ctx.api and ctx.engine run the invoker's envelope elevated: { ...envelope, isSystem: true } plus the 'action' app-automation elevation mark (buildActionExecutionContext, packages/runtime/src/action-execution.ts). The authz middleware's isSystem bypass returned before step 3.5, the empty-owner stamp. So the body's insert landed with owner_id null while created_by named the invoker, and on a private object the invoker could neither read nor update the row.

  • New packages/plugins/plugin-security/src/owner-anchor-stamp.ts. It holds the insert stamp step 3.5 applies (hasEmptyOwner, stampEmptyOwner, writesOwner), the predicate isActionBodyElevation (isSystem, the 'action' mark, no flowRunId), and stampActionBodyInsertOwners.
  • security-plugin-authz-middleware.ts: ahead of the isSystem bypass, beside the existing app-automation checks, an insert under an action body's elevation on an object that carries owner_id has every EMPTY owner stamped. Step 3.5 now calls the same stampEmptyOwner, so there is one owner rule, not two copies. Step 3.5's behaviour is byte-for-byte the same.
  • The stamp follows step 3.5 exactly:
    • The guest is stamped with nothing (ADR-0138 D1).
    • Under delegation the stamp is the envelope's userId, the principal a direct create is stamped with (ADR-0090 D10).
    • Every row of a batch is stamped.
    • An owner_id the body sets itself is kept, another user's included. The body is trusted code, so the forge/transfer guard is not run on it.
  • Queue (ADR-0142 D3): the body is treated as step 3.5 treats a trusted writer (the grant holder).
    • owner_id supplied empty beside a supplied queue parks the row unowned.
    • An absent owner is stamped, and the queue becomes the row's home queue.
    • The queue is not resolved here, as it was not before (system bypass).
  • What the mark covers: every handler an action door dispatches, not only a script body's ctx.api. A host code action handler and an action reached through ObjectRepository.execute carry the same 'action' mark, so their inserts are stamped the same way.
  • Assignment rules (ADR-0142 D5) route only a row whose owner_id and queue are both still empty, after beforeInsert hooks. Seat ruling 6959099293: an action-body insert is owned exactly as the invoker's direct create of the same row would be. Measured on a routed object:
    • The invoker's direct create is stamped by step 3.5 before the rule runs, so it is not routed.
    • An action-body insert is now owned the same way, so assignment rules route neither.
    • Before this change, an action body's unowned, queue-less insert on such an object was routed by the rule. It now goes to the invoker.
    • A body has no spelling today that asks a rule to route its row (owner_id: null is stamped too).
    • Metadata-protocol stays none: no authored meaning changes, and the action path joins the existing direct-create behaviour.
  • Unchanged: a flow run (a flowRunId wins over the mark, as elevationSource reads it), a hook's runAs: 'system' ('hook' mark), seed/boot/import writes, and a bare isSystem. An unowned, queue-less insert from any of them is still routed.
  • content/docs/permissions/system-context.mdx: row 2 ("owner_id is not auto-stamped on INSERT") would be false after this change. It now names the action-body exception, keyed isActionBodyElevation, the routing consequence and the mark's reach, and the site register was regenerated with --write. check:system-context-census required this.
  • packages/core/src/security/app-automation-elevation.ts: the module header said the mark's "only reader narrows (it refuses; it admits nothing)". It now names the owner stamp as a second reader: the stamp gives ownership of an empty owner_id to the context's own userId, never to another principal, and admits no operation. The header ships in @objectstack/core's dist/index.d.ts, so the changeset adds a @objectstack/core patch line.

Who sets the stamp cannot be steered by a client. The mark is a symbol key: APP_AUTOMATION_ELEVATION = Symbol.for(...) in packages/core/src/security/app-automation-elevation.ts. Only server derivation sites set it:

  • packages/runtime/src/action-execution.ts buildActionExecutionContext;
  • packages/objectql/src/engine-object-repository.ts execute;
  • the hook sites in engine-scoped-context.ts.

A request body, a query string or a stored row has no spelling for a symbol. The sandbox boundary is JSON in both directions (packages/runtime/src/sandbox/body-runner.ts, the entry-snapshot note). ObjectRepository.insert(data) takes no context, so the repository's own context is used. The stamped id is the envelope's userId, never a payload value.

Tests

packages/plugins/plugin-security/src/action-body-insert-owner-stamp.test.ts uses the real SecurityPlugin, a real ObjectQL over better-sqlite3, and the real SharingService with its middleware. The two private objects rely on the registry-injected owner_id and queue columns. One of them (abo_ticket) is routed by a declared assignment rule to a member of the organization. The body's ctx.api is engine.createContext(markAppAutomationElevation({ ...envelope, isSystem: true }, 'action')), which is what buildActionApi builds. The suite has 23 cases:

  • the repro: owner is the invoker, who can read the row by id and update it; a direct create is the control; an owner supplied as null or '' is stamped;
  • an owner the body sets is kept (another user's, and the invoker's own);
  • a guest invoker gets no stamp;
  • delegation: the stamp equals a direct create under the same envelope (the agent);
  • forge: a context spelled through JSON with isSystem and the mark's name as a string is not stamped; a payload created_by does not move the stamp;
  • controls that still land owner null: a flow run, a flow reaching an action, a hook's runAs: 'system', a bare isSystem with a user, and a bare isSystem;
  • a batch from a body;
  • queue park, and queue with an absent owner;
  • routed object (ADR-0142 D5):
    • the rule routes on this rig (a system insert and a flow run's insert go to the rule's user);
    • the invoker's direct create is stamped and not routed;
    • an action body's insert is owned exactly as that direct create (the invoker, no queue, readable by the invoker);
    • a body's owner_id: null is stamped too.
Results
  • At 6cacf68, pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/action-body-insert-owner-stamp.test.ts (closure rebuilt): Test Files 1 passed (1), Tests 23 passed (23); lock VERDICT command-exit 0.
  • At 6cacf68, pnpm --filter @objectstack/plugin-security typecheck && pnpm --filter @objectstack/core typecheck: VERDICT command-exit 0.
  • At 6cacf68, pnpm --filter @objectstack/core exec vitest run src/security/app-automation-elevation.test.ts: 6 of 6 passed.
  • At 330df04, the full plugin-security suite: Test Files 275 passed (275), Tests 6913 passed, 45 skipped; exit 0.
Ablation (one-shot, committed tree, restored to HEAD by blob hash)

All runs used node scripts/ablation-replace.mjs. The suite imports the package's src relatively, so no dist rebuild is involved.

  1. Remove the action-body stamp call (origin/main's behaviour for the action path), at 6cacf68. The mutation landed (anchor 1 to 0, blob e083bd07bac8 to fa951e5c9ebc). Result: 9 failed and 14 passed. The two routed-object body cases failed with "expected 'usr_abo_lead' to be 'usr_abo_invoker'", so before this change the rule routed the body's row. Restored: blob equals HEAD and git diff HEAD is empty.
  2. Widen isActionBodyElevation to !!context?.isSystem, at 330df04. The mutation landed (blob 02233ccc6dd3 to f5b51e91341e). Result: 5 failed. The failures were the JSON-spelt context, the flow run, the flow reaching an action, the hook runAs: 'system', and the bare isSystem with a user. Restored to HEAD.

Acceptance notes

  • Assignment routing (ADR-0142 D5) is disclosed, per seat ruling 6959099293.
    • An action-body insert is now owned like a direct create, so assignment rules route neither; this is pinned on a routed object.
    • An action body's unowned, queue-less insert that a rule used to route now goes to the invoker.
    • A body has no spelling today that asks a rule to route its row.
  • Rows stored before this change keep owner_id null. An administrator holding the transfer grant can assign their owners. This PR does not include a backfill.
  • The mark rides every spread of the body's context, as its module header states. So a write a body's insert sets off under the same context is also stamped when its owner is empty: a hook that inherits the context (not runAs: 'system', which re-marks 'hook'), or a sudo() taken inside the body. That is the invoker's own action.
  • created_by (objectql plugin.ts, from session.userId) and the new stamp both read the envelope's userId, so they name the same user for an ordinary invoker. This was established by reading the code, not measured. The rig boots a bare ObjectQL without the audit hook.
  • The claimed file surface was amended to include content/docs/permissions/system-context.mdx (6958279133) and packages/core/src/security/app-automation-elevation.ts, where only header text changed (this round).

Verification

Local gate subset (dispatch-gates --commands, re-run on the final head 6cacf68)
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack gave 104 commands, each run with its exit code captured before any pipe (two more than at b413fd2: check-dev-prereqs --self-test and check:kernel-hook-pairs).
  • 100 exited 0, including check:system-context-census, check:doc-authoring, check:kernel-hook-pairs, check:adr-anchors and the changeset gates.
  • 4 are NOT MEASURED (exit 3, prerequisite not met; CI owns them): check-plugin-teardown-shape.mjs --self-test (history the shallow clone lacks), and spec check:skill-examples, check:dual-build-cjs-loads and check:i18n (they need a whole-workspace build). check:dual-build-cjs-loads and check:i18n exited 0 at b413fd2, and this round's only published-code change is a core header comment.
  • dispatch-gates --ran: "104 derived famil(ies) accounted for — 100 run, 4 NOT-MEASURED (4 DERIVED from a recorded exit 3)".
  • Families CI runs (Test Core, Build Core, Lint & Repo Gates, TypeScript Type Check and the rest) are left to this PR's check-runs, which are green at 6cacf68.

overlap-check before the push of 6cacf68: ✓ origin/main: merges cleanly, ✓ #34817 (shares content/docs/permissions/system-context.mdx): merges cleanly, VERDICT clean exit 0. Earlier runs also listed ✓ #34811 (shares security-plugin-authz-middleware.ts): merges cleanly.


Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH

@github-actions github-actions Bot added size/l 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 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/core, @objectstack/plugin-security, touching 9 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/core/src/security/app-automation-elevation.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

25 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 fff0ad0c180c08ac8de7db8499863bdfb69842e2.

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

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/core/src/security/app-automation-elevation.ts) — pages documenting those are invisible to this run
  • 1 cross-cutting symbol(s) contributed no route anchor: userId (5 routes)
  • 1 anchor(s) matched too much of the corpus to be a work list: owner_id (literal, 43 pages)
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 — 48 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 fff0ad0c180c08ac8de7db8499863bdfb69842e2 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from a6dbd8c4389d59c6e56cab8fcbc7f927e92e4c32 — the merge of head 6cacf68c50645caa3d6d48817d03b877468e8d4a into base fff0ad0c180c08ac8de7db8499863bdfb69842e2, 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 a6dbd8c4389d59c6e56cab8fcbc7f927e92e4c32 && git checkout a6dbd8c4389d59c6e56cab8fcbc7f927e92e4c32
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin fff0ad0c180c08ac8de7db8499863bdfb69842e2 6cacf68c50645caa3d6d48817d03b877468e8d4a && git checkout -B drift-repro fff0ad0c180c08ac8de7db8499863bdfb69842e2 && git merge --no-ff 6cacf68c50645caa3d6d48817d03b877468e8d4a

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

⚠️ 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 fff0ad0c180c08ac8de7db8499863bdfb69842e2 → 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

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

L1 review (L1-d) · 2026-11-17T19:39Z

L1: ACCEPT
Head-sha: b413fd243d02076c558002fa2a895b263f17f614

Read against claim 6955512353 (seat route A) with its file-surface amendment 6958279133, and os-dev report 6958229650 on #34885.

  • Size: 5 files, +519/-17.
  • Not governed: check-governed-merges --branch pr-34957 reports 0 of 5 paths and 536 lines.
  • CI at this head: 40 success, 15 skipped, 0 failed, all concluded.
  • Claim surface: the middleware, the new helper owner-anchor-stamp.ts beside it, a new card-named test, the changeset, and system-context.mdx (amended). All 5 files are inside it.

What holds

  • Closing keyword. Fixes #34885 is right. The card's repro (a private object, a non-admin action-body insert, then a 404 on get) is the first pinned case, with the same envelope's direct create as its control.
  • Where the stamp sits. It runs ahead of the isSystem short-circuit. It is gated on operation === 'insert' plus isActionBodyElevation (isSystem, no flowRunId, and the 'action' symbol mark from @objectstack/core) plus an object that carries owner_id. So a flow run (the flow wins over the mark, as in the identity-write refusal), a hook's runAs: 'system', seed, boot and import, and a bare isSystem are all unchanged. The second ablation, which widens the predicate to isSystem, turns exactly those 5 cases red.
  • Same principal as a direct create.
    • The stamp reads opCtx.context.userId, which is step 3.5's own userId (:1839). So under ADR-0090 D10 delegation it names the same principal, and that is pinned.
    • The guest is stamped with nothing (isGuestEnvelope), with '' normalised to unset (ADR-0138 D1 item 5).
    • No payload value steers the stamp: a payload created_by is ignored. A client-spelt context has no symbol mark, so it is not the body's elevation, and that is pinned.
  • One rule in two places. Step 3.5's inline writesOwner and the empty-owner stamp move into owner-anchor-stamp.ts unchanged: the own-property test, and park, then user, then guest normalisation. Step 3.5 now calls them, so the two readings cannot drift.
  • Seat rulings applied.
    • An owner_id the body sets is kept, including another user's id, with no forge refusal. The body is trusted code, as before.
    • The queue rule follows the seat's confirmation. The row parks only when the body supplies owner_id empty beside a queue. An absent owner beside a queue is stamped, and the queue is the home queue. Both are pinned.
    • Batch rows are each stamped.
  • Ablations. Removing the call turns 7 red (repro, control, empty, delegation, payload, batch, queue home). Widening the predicate turns 5 red. Both were restored by blob.
  • Docs. system-context.mdx row 2 no longer claims an action body's insert is never stamped. That would have been the false published text, and the census row keyed isActionBodyElevation was regenerated, so check:system-context-census is green.
  • Changeset. It is a patch on @objectstack/plugin-security, with Clause-②: yes and Metadata-protocol: none (a none kind takes patch). It names what stays unchanged and says that rows stored before this release keep owner_id null.

Must-fix

None.

Should-fix

None.

Notes

  • N1: The new path costs one getObjectFieldNames lookup per action-body insert, which is the same cached resolver step 3.5 uses. Other writes do not pay it.
  • N2: An action run with no user principal (no userId, for example a service caller) is stamped with nothing, which is the same as step 3.5. I mention it only so that L2 sees it was considered.

Landing: not governed and green on this exact head. Because of Clause-②: yes (it changes who owns a stored row), it goes to the seat's fable L2 before area o3-G lands it. A later push owes a delta read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: TIER_DEFAULT
Head-sha: b413fd243d02076c558002fa2a895b263f17f614
Local-runs: none

Inputs read: card #34885 (body; triage 6953026994; claim 6955512353; os-dev-report 6958229650; amendment 6958279133), PR #34957 (body, 5-file list, net diff against main at base fff0ad0c18), L1-d ACCEPT 6958872123, and the 55 check-runs on the head. Code outside the diff was read only to judge the diff (app-automation-elevation.ts, engine-scoped-context.ts, engine-object-repository.ts, action-execution.ts#buildActionExecutionContext, flow-system-identity-write-refusal.ts#elevationSource, security-plugin-object-inputs.ts#getObjectFieldNames, engine-insert.ts and assignment-rules.ts, ADR-0142 D5).

① Derived judgments

  • Public-surface change: an action-body insert now fills an EMPTY owner_id with the envelope's userId. Right, and it matches seat ruling A. The stamp runs ahead of the isSystem bypass and is gated on operation === 'insert', isActionBodyElevation and an object that has owner_id. isActionBodyElevation is isSystem, no flowRunId, and appAutomationElevationOf === 'action'. That is the same order elevationSource uses in the identity-write refusal (the flow wins over the mark), so the two readers do not drift. Flows, a hook's runAs: 'system' (re-marked 'hook' by withRunAs), seed, boot and import writes, and a bare isSystem are unchanged. Test cases pin each of these, and ablation 2 turns exactly those 5 cases red.
  • Accept set: no write is newly refused. Right. The new block only changes the payload and throws nothing. getObjectFieldNames catches its own errors and returns null, and a null means no stamp, so an unknown object cannot turn into a refused insert. A body-set owner_id (another user's included) is still kept without a forge guard, as before. No input that was accepted before is refused now.
  • Shared owner-anchor-stamp.ts against step 3.5: same rule, no drift. Right.
    • writesOwner moved word for word: own-property test, not an array.
    • hasEmptyOwner is exactly the old inline condition: absent, == null, or ''.
    • stampEmptyOwner keeps the old branch order: park → null, then userId → userId, then guest with '' → null.
    • Step 3.5 now calls these three, and its behaviour is the same. The action path's park (queue column present, own non-empty queue, own empty owner_id) is step 3.5's grant-holder park. The only difference is that the action path does not resolve or admit the queue, and it never did, because of the system bypass. The owner rule is not affected.
  • Forge-proofing holds.
    • The mark is Symbol.for(...) and has no JSON spelling.
    • The sandbox boundary is JSON in both directions, and ObjectRepository.insert(data) takes no context. So a body can neither forge the mark nor strip it, and a payload created_by does not steer the stamp (pinned).
    • In-process code (a code-registered hook, platform sudo()) could call the exported markAppAutomationElevation, or rebuild a context without the spread. Forging the mark only stamps the context's own userId, which is what step 3.5 stamps for that same envelope when it is not system. Stripping the mark only gives back the pre-fix null owner. Neither crosses a principal.
    • A client cannot reach isSystem at all.
  • MUST-FIX F1: the assignment-rule seam (ADR-0142 D5) is left unruled and undisclosed.
    • ObjectQL.insert runs the security middleware, then the beforeInsert hooks, then AssignmentRuleEvaluator.apply. The seam routes only rows whose owner_id AND queue are both still empty (engine-insert.ts near :1066; assignment-rules.ts header: "a middleware-stamped owner is the acting user's own record").
    • Before this head, an action body's ownerless, queue-less insert on an object that mayRoute reaches was routed by the declared or organization-authored rules. At this head the middleware stamps the invoker first, so the seam stands down. That row now goes to the invoker instead of to the queue or member the rule picks.
    • There is also no spelling left that lets a body ask for routing. owner_id: null counts as empty and is stamped, and owner_id: null beside a queue parks in that queue, which the seam also skips.
    • That is parity with a direct create, which the seat's "mirror step 3.5" reading may well intend. But the claim, the dev report, its open_questions, the PR body, the changeset, the system-context row and L1 never name it, and no test pins it. ADR-0142's first consumer is intake routing (HotCRM cases and leads), and an action that logs a case or ticket is exactly that intake.
    • It is a change to who owns a stored row on routed objects, which is the contract question this face exists for. So it needs a seat ruling before landing, see ③.
  • Nit N-a: the 'action' mark reaches more than the bodies the PR describes. buildActionExecutionContext serves every handler an action door dispatches, a host code handler included (its own jsdoc), and ObjectRepository.execute marks 'action' too. So a host code action handler's ownerless insert is now stamped with the invoker as well. The docs row is accurate (it keys on the mark), but the PR body and the changeset say only "an action body's ctx.api". This is disclosure only, and the effect is the same direct-create parity.
  • Nit N-b: a module header is now out of date. packages/core/src/security/app-automation-elevation.ts, outside the diff, still says the mark's "only reader narrows (it refuses; it admits nothing)". The new reader gives ownership. The header has no effect on correctness. Fix it in the push F1 already needs.

② Semver level

  • Changeset: '@objectstack/plugin-security': patch. That is the only package the diff publishes. content/docs is not a package, and owner-anchor-stamp.ts is internal to the package: it is not added to index.ts exports in the diff.
  • Metadata-protocol: none: right on its own terms. No spec key, accepted value or metadata type changes, and none takes patch. ⚠ This depends on F1. If the seat rules that declared or authored assignment rules no longer reaching action-body inserts is a changed meaning for the assignment_rule metadata type, the kind becomes semantic and the level minor. The seat should say which, on F1's ruling.
  • Clause-②: yes (no arm) is the right word. The change widens what the invoker ends up owning (read and update on rows that used to be unowned). It does not narrow the accept set: no caller's write that was accepted before is refused now. The queue-claim corner below does not change that.
    • A queue member's ADR-0142 D4 claim of a body-queued row with an absent owner was admitted before, because the row was unowned. It is not admitted now, because the row is the invoker's.
    • What changed there is the stored state the body produces, not the gate's verdict on the same input and state. The body keeps an explicit park spelling (owner_id: null beside the queue), and the seat confirmed this reading.
    • So this is not a (narrowing) declaration needing CONTRACT_REVIEW_TIER. F1 is the item that still has to be ruled.
  • Changeset body: it names what stays unchanged and that there is no backfill. It does not name F1, and per N-a it says less than the mark reaches.

③ Boundary flags

  • open_questions[0] (body-named queue, owner absent: stamp or park). Answered: the seat confirmed option A (stamp; park only when owner_id is written empty beside the queue). The code and two pinned cases implement that. It still has to be re-read together with F1, because the queue reading and assignment routing interact. The seam skips a row with queue set either way, so A versus B does not change F1.
  • PR note 1 (no backfill). Acceptable. A backfill cannot tell an action body's null-owned rows from guest, form or seed rows, which ADR-0138 D1 requires to stay unowned. created_by alone does not separate them. An administrator with the transfer grant can reassign. The changeset discloses it.
  • PR note 2 (an inherited hook context and sudo() inside the body are stamped too). Acceptable.
    • The mark rides the spread by design (the core header, system-context row 1b).
    • appAuthoredHookApi and sudo() keep an existing 'action' mark. Only withRunAs('system') re-marks it 'hook', which is not stamped.
    • A hook that inherits the context under a direct create is stamped by step 3.5 the same way, so this is parity.
    • The one asymmetry is platform sudo() code that runs under a body: stamped here, not under a direct create. It only fills an empty owner, and only with the invoker. Noted, not a finding.
  • L1 N1 (one cached getObjectFieldNames per action-body insert). Accepted. A null result is not cached, so an unknown object re-reads each time. That is negligible and the same resolver step 3.5 uses.
  • L1 N2 (no userId means no stamp). Accepted. Same as step 3.5.
  • Docs row (system-context.mdx row 2 and the regenerated register line owner-anchor-stamp.ts#isActionBodyElevation | 1 | 2). Correct as far as it goes. It covers the key, the guest, a body-set owner and the queue park, and the census gate is green on the head. It needs F1's disclosure if the seat takes parity.
  • Out-of-surface edit (system-context.mdx). It was declared and the claim was amended (6958279133). Fine.
  • SQL push-down: no finding. The diff adds no query, no id materialisation and no in-app join. The stamp is an in-memory write to the payload, and the only lookup is the cached schema read.
  • Escalation (F1) to the seat. Rule one of:
    • (a) Parity with a direct create: action-body inserts are not routed by assignment rules. Then disclose it in the changeset, system-context row 2 and the PR body; pin a test with a routed object showing the seam stands down; and state the Metadata-protocol judgment (none or semantic) on the ruling.
    • (b) Leave rows an assignment rule may route to the seam, and stamp the invoker only when no rule claims the row. That needs an engine-side change outside the claimed surface.
    • Either way it is a new head, which owes a delta read.
  • CI on this head, polled to completion: 55 check-runs, 40 success, 15 skipped, 0 failure, 0 pending.
    • Passed: Test Core 1–10, Build Core, TypeScript Type Check (all four lanes), Lint & Repo Gates (all lanes), Check Changeset, Governed Surface Queue Guard, Spec property liveness, Build Docs, Test UI, Live E2E UI, Dogfood Regression Gate, and the PR-body guards.
    • The skipped runs are opt-in, UI-lane or schedule-gated.
    • The queued suites from the claude, vercel, cloudflare, fly-io and objectstack-fleet apps have 0 check-runs and carry no verdict.
  • Merge standard (only nits may stay open): not met. F1 is must-fix. N-a and N-b are nits and can go in the same push.

Implemented-by: claude/issue-34885-action-insert-owner-stamp
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: FAIL

…ither an action-body insert nor a direct create

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

Copy link
Copy Markdown
Contributor Author

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

L1 review (L1-d) · 2026-11-17T20:36Z

L1: ACCEPT
Head-sha: 6cacf68c50645caa3d6d48817d03b877468e8d4a

This is a delta read from my ACCEPT at b413fd24 (6958872123). It covers the fix round on seat L2 FAIL 6959079731 under seat ruling 6959099293, with claim amendment 2 (6959130385) and report 6960222056.

  • The delta: one commit, 6cacf68c, with 4 files and +93/-5. The PR is now 6 files and 626 lines.
  • Not governed: 0 of 6 paths on the register.
  • CI at this head: 61 success, 12 skipped, 1 in progress (Check Changeset), 0 failed.
  • Claim surface: the new path packages/core/src/security/app-automation-elevation.ts (header text only) is in amendment 2. The other three files were already claimed.

I owe the record one admission: my first read missed the assignment-rule seam that L2 F1 found. The ruling settles it, and this delta answers it.

What holds

  • F1, measured first as the ruling asked. The new describe uses a private abo_ticket with a declared assignment rule that sends every unowned, queue-less insert to an org member:
    • Positive controls: a system insert and a flow run's insert (isSystem plus flowRunId) are both routed to the rule's user. So the rule really routes on this rig, and a flow is unchanged.
    • The invoker's direct create is stamped by step 3.5 with the invoker and not routed. This is the measurement that puts the ruling on branch 3 (keep the order).
    • An action body's insert is owned exactly as that direct create is: the invoker's, with no queue, and readable by the invoker.
    • A body's owner_id: null is stamped too, so a body has no spelling that asks for routing. This is pinned and disclosed.
    • The stamp-removal ablation turns 9 red, both routed body cases included (the body row went to the rule's user before the fix).
  • Disclosure, as the ruling's branch 3 requires.
    • The changeset, system-context.mdx row 2 and the PR body each state that an action-body insert is the invoker's own record, like a direct create, so assignment rules route neither.
    • The changeset names the before-and-after (before, the rule routed the body's row; now it goes to the invoker), and says that flows, runAs: 'system' hooks and other system inserts are still routed.
  • N-a. The changeset and row 2 now say the mark covers every handler an action door dispatches, a host code handler included, and ObjectRepository.execute.
  • N-b. The core header now names two readers: the refusals, which narrow, and the owner stamp, which fills only an empty owner_id with the context's own userId. That header ships in core's .d.ts, so the '@objectstack/core': patch line is right.
  • Declarations. Metadata-protocol: none follows the seat ruling: assignment rules never routed a middleware-stamped owner, so their authored meaning does not move. Clause-②: yes is unchanged.

Must-fix

None.

Should-fix

None.

Notes

  • N1: A body that wants a rule to route its row has no spelling today. The changeset says so. If an app needs it, that is a new card (for example, an explicit routing request), not this one.

Landing: not governed. The seat's delta L2 comes next, then area o3-G lands it once CI is fully green on this exact head. Check Changeset was still in progress when I read it. A later push owes a delta read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head 6cacf68 · 2026-11-17T20:38Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 6cacf68c50645caa3d6d48817d03b877468e8d4a
Local-runs: none

This is a DELTA review over the seat's L2 FAIL record 6959079731 at head b413fd24, to head 6cacf68c. It covers card #34885 (body and every comment: triage 6953026994, claim 6955512353, os-dev-report 6958229650, amendment 6958279133, seat ruling 6959099293, amendment 2 6959130385, fix-round report 6960222056), PR #34957 (body, 6-file list, net diff against main), L1-d ACCEPT 6958872123 and L1-d delta ACCEPT 6960315176, and the 74 check-runs on this head.

  • The delta: git diff b413fd24..6cacf68c is one commit, 6cacf68c (parent b413fd24), with no main merge in it. It has 4 files and +93/-5: the changeset, system-context.mdx row 2, the app-automation-elevation.ts header, and the test.
  • Unchanged since the FAIL record: owner-anchor-stamp.ts and security-plugin-authz-middleware.ts.
  • Merge check: git merge-tree --write-tree origin/main 6cacf68c (main at 0465f4aa) merges cleanly. Main's 8 commits since the merge base c81f498b touch the middleware and action-execution.ts only through fix(spec, core, plugin-security, plugin-approvals, plugin-audit, service-analytics): platform refusals carry a userMessage in the caller's language #34811's userMessage caller threading, which does not affect the mark, the bypass or step 3.5.
  • Code read outside the diff, only to judge it: engine-insert.ts (the D5 seam near :1066), assignment-rules.ts, engine-object-repository.ts execute, engine-scoped-context.ts, action-execution.ts#buildActionExecutionContext and body-doors.ts.

① Derived judgments

  • F1 (must-fix at b413fd24): CLOSED by ruling (a), parity.
    • What the seam does. The seam runs after beforeInsert hooks and before the write, whatever isSystem is. It writes owner_id/queue only on a row whose owner and queue are both still empty. So the outcome depends only on the row's state when it reaches the seam.
    • Positive controls (the rule really routes on this rig). The new describe runs on abo_ticket, a private object. A declared rule abo_ticket_intake sends every unowned, queue-less row to usr_abo_lead, an active member of org_abo. Two inserts reach the seam unowned and go to the rule's user:
      • a system insert under org_abo;
      • a flow run's insert under the invoker's own envelope ({ ...INVOKER, isSystem, flowRunId }).
    • Parity, measured and pinned on that routed object. Both cases below run under the same envelope (memberOf(ME), tenant org_abo) as the flow-run control.
      • The invoker's direct create is stamped usr_abo_invoker, with no queue, so it is not routed.
      • An action body's insert (markAppAutomationElevation({ ...INVOKER, isSystem: true }, 'action'), the context buildActionExecutionContext builds) is owned the same way: the invoker, no queue. The invoker can read it by id.
      • Together these are the measurement the ruling's branch 3 asked for.
    • Body owner_id: null. It is stamped too, so a body has no way to ask for routing. This is pinned and disclosed.
    • The pins are load-bearing. The dev's stamp-removal ablation turns 9 cases red, and both routed body cases fail with expected 'usr_abo_lead' to be 'usr_abo_invoker'. So before this change the rule did route the body's row. I did not re-run this (read-only shape); the report and the PR body agree on it.
    • Direct-create path. The direct create goes through engine.insert under the user's context rather than the REST door. That is the same middleware chain and seam that REST's data door reaches, so it measures what the ruling asked.
    • Disclosed truly, in all three places the ruling named:
      • The changeset says assignment rules route neither, gives the before (the rule routed the body's unowned, queue-less row) and the after (it goes to the invoker), says a body has no spelling to request routing, and says flows, runAs: 'system' hooks and other system inserts are still routed.
      • system-context.mdx row 2 carries the same parity sentence, the ADR-0142 D5 condition, the no-spelling note, and "an unowned, queue-less one is still routed" for the other system contexts.
      • The PR body's What changes, Tests and Acceptance notes all state it, citing ruling 6959099293.
      • Each statement matches the code read above.
  • Accept set: still no write newly refused. Right. The delta adds no code path; it changes text and tests only. The judgment in 6959079731 stands: the stamp throws nothing, and getObjectFieldNames returning null means no stamp.
  • N-a (nit): CLOSED. The changeset and row 2 now say the mark covers every handler an action door dispatches, a host code action handler included, and ObjectRepository.execute. The PR body says the same. This matches the code:
    • buildActionExecutionContext marks 'action' (action-execution.ts:3851);
    • engine-object-repository.ts:137 marks 'action'.
  • N-b (nit): CLOSED. The header no longer says the mark's "only reader narrows (it refuses; it admits nothing)". It now names two readers: the identity-write and append-only refusals, which narrow, and the owner stamp, which fills only an EMPTY owner_id with the context's own userId. Neither admits an operation, and that is true of the code.
  • Nothing else moved. All 4 delta files are inside the claim surface: amendment 2 (6959130385) added the core header. Test cases 1–7 are unchanged, and only the rig gained the ticket object, the rule, the lead user and the lead's membership. The writer set gained abo_ticket grants, which is needed for the direct create and for the invoker's read.
  • Nit N-c (new, open): the PR body's Verification section is stale.
    • It still says the local gate subset was "re-run on the final head b413fd2": 102 commands, 101 run, 1 NOT-MEASURED. It also says the overlap-check last ran at b413fd243d.
    • Fix-round report 6960222056 records the run at 6cacf68c50 instead: 104 commands, 100 run, 4 NOT-MEASURED (exit 3, CI-owned), and the overlap-check clean before the push.
    • This is disclosure only. CI on this head answers every CI-owned family (see ③). Refresh the section at landing.
  • Nit N-d (new, open): the app-automation-elevation.ts header still has two inaccuracies.
    • Its "Where it is set" list still names only withRunAs and buildActionExecutionContext. It leaves out ObjectRepository.execute and the hook binder's appAuthoredHookApi/sudo() marking, which row 1b names.
    • "two readers, both in plugin-security" passes over objectql's read in engine-scoped-context.ts:97/117. That read does not gate anything: it only decides whether to add a 'hook' mark.
    • Most of this is pre-existing and sits outside the sentence N-b asked to fix. It has no effect on correctness or the contract, so it can go in a later header tidy.

② Semver level

  • '@objectstack/plugin-security': patch. Unchanged and right. Metadata-protocol: none takes patch.
  • '@objectstack/core': patch (new). It is the right level, and it is the minimum.
    • The delta's only change to core is the module header of app-automation-elevation.ts. That module is re-exported from core's index (security/index.ts:619–621), so the header ships in the type declarations.
    • Nothing in core's runtime or exported types changes, so nothing higher is owed.
    • Check Changeset is green on this head.
  • Metadata-protocol: none. It holds under the seat ruling, which settles the question 6959079731 left open (none versus semantic).
    • The assignment_rule type's authored meaning does not change. It routes only a row whose owner and queue are both empty, and assignment-rules.ts already treats a middleware-stamped owner as the acting user's own record.
    • What changes is the state the action path's row arrives in, and that now matches a direct create.
    • The changeset, the claim, amendment 2 and the PR body all carry none.
  • Clause-②: yes
    • It stays the right word, with no (narrowing) arm. The change widens what the invoker ends up owning, and no write that was accepted before is now refused.
    • The rows that used to be routed and now go to the invoker are a change in stored state, not a refusal. The changeset discloses them per the ruling.
    • The PR body and the changeset both carry the line.

③ Boundary flags

  • open_questions. The fix-round report has none. The first round's queue question (option A) was answered in 6959079731 and is unchanged.
  • Out-of-scope finding (no way for a body to request routing). Answered: it is disclosed, not filed, per the ruling and L1 N1. A new opt-in routing request would be new authorable behaviour, and so a new card.
  • Out-of-surface edit. The app-automation-elevation.ts header is declared in amendment 2 (6959130385) and changes text only.
  • SQL push-down: no finding. The delta adds no runtime query, no id materialisation and no in-app join. The new test reads go through engine.findOne by id.
  • CI on this head, polled until complete: 74 check-runs, 62 success, 12 skipped, 0 failure, 0 pending.
    • Passed:
      • Test Core 1–10 and Test UI 1–16;
      • Build Core, Build Docs, and TypeScript Type Check (workspace, debt ledger, consumer gates, source gates);
      • Lint & Repo Gates (all lanes) and Check Changeset;
      • Governed Surface Queue Guard and Spec property liveness;
      • Dogfood Regression Gate and Flag docs affected by code changes.
    • Skipped: opt-in, UI-lane, schedule-gated or queue-verdict runs (Lint UI, Dogfood Verify CLI, the Dogfood shard matrix template, Temporal Conformance, UI Published Artifacts, the Schedule gate, Queue verdict, Borrowed queue verdict, Packed-tarball smoke, 18.x upgrade harness, Auto Label, Check PR Size).
    • No verdict: the vercel, fly-io, claude, cloudflare and objectstack-fleet suites are queued with 0 check-runs. There are no legacy commit statuses.
  • Merge standard (only nits may stay open): MET.
    • F1, N-a and N-b are closed.
    • N-c (the stale Verification text in the PR body) and N-d (the header's set-site list and its count of readers) are nits and may stay open.

Implemented-by: claude/issue-34885-action-insert-owner-stamp
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Landing · 2026-11-17T20:45Z

Probe Reading
L1 ACCEPT 6958872123 (L1-d) at b413fd243; delta ACCEPT 6960315176 at 6cacf68c50645caa3d6d48817d03b877468e8d4a, no must-fix or should-fix
L2 Seat contract review FAIL 6959079731 (F1, assignment-rule seam) → seat ruling 6959099293 (a, parity; Metadata-protocol: none) → delta PASS 6960447766 at 6cacf68c5. Open nits only: N-c (PR body Verification section, refreshed in this landing), N-d (the core header's marker-site list, which predates this PR; the seat ruled it be left)
Governed check-governed-merges.mjs --pr 34957: NOT governed, 626 lines ≤ 3000; Clause-②: yes reviewed by the seat
CI at head 74 check runs: 62 success, 12 skipped, 0 failed (seat L2 poll)
K behind main 8 first-parent commits since merge-base c81f498b (< 15); main's #34811 touches the middleware only through userMessage threading (L2 merge-tree check clean)
Overlap overlap-check.mjs: VERDICT clean exit 0

Ready + auto-merge into the queue. Area o3-G (repo:objectstack#3) watches it to MERGED and closes out #34885.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 20:46
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 44172785743 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test UI (13/16) — 失败步骤: Fetch this commit's history and the base branch(日志不可读,点进 job 看)

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • ⚠️ 本次没有可用的聚合签名(日志里没有能解析出测试文件名的 FAIL 行)—— 这不是「没有同签名的其他 PR」,是这一轮没测到。跨 PR 聚合本次不可用,请手工比对其他 PR 的同类评论。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 32 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

Merged via the queue into main with commit bb169c3 Nov 17, 2026
79 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34885-action-insert-owner-stamp branch November 17, 2026 21:45
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/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants