Skip to content

fix(runtime)!: an action's selection is read in the caller's scope before the action runs - #36132

Merged
os-zhuang merged 10 commits into
mainfrom
claude/action-selection-read-scope
Nov 22, 2026
Merged

os-zhuang merged 10 commits into
mainfrom
claude/action-selection-read-scope

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #36156

维护者速读

  • 用户能看到什么变化:批量操作一次提交多条选中记录时,若其中有调用者看不到的记录,整次操作被拒绝、什么都不执行;选中的都能看到时照常执行。
  • 为什么做:安全加固,由安全席位按无卡派发令下发。
  • 出错会怎样:自定义批量动作若依赖把调用者看不到的记录交给动作,会收到"记录不存在";撤回本次合并即恢复原行为。
  • 要你做什么:无

What changes

The rule: a call names records by id only when the caller can read them. The per-record door already reads its recordId in the caller's own scope; a record-less call that carries a selection now has it read the same way.

  • packages/runtime (the shared sequence every action door runs: REST POST /api/v1/actions/..., MCP run_action, a host's dispatchAction):
    • shape, beside the record key's check: params._selectedIds must be a list of non-empty record ids (strings or numbers), at most 5000 (the console's select-all-matching cap), on an action called on an object; otherwise 400 VALIDATION_FAILED with a located details.fields[] entry.
    • read, beside the subject load: each distinct id is read with the per-record door's own read of its record, in the caller's own execution context, as a row of the object the call names, a few at a time.
    • verdict, at the same point the subject load's verdict is consumed (and before the AI door's hand-off): one id the read does not deliver refuses the whole call with the per-record door's own 404 RECORD_NOT_FOUND. No id is dropped; the body or flow never starts.
    • not read: a declarative operation: 'update' action — exempt by seat ruling A: it writes as the caller and builds nothing elevated — a type: 'api' action (its target authorizes the caller) and the system principal.
    • param contract: on a param-less action, a near-miss spelling of a built-in (selectedIds, __selectedIds, _recordId, _objectName) is refused with the contract's own 400, naming the built-in; every other custom key still passes (ADR-0104 D2).
  • examples/app-todo: todo_mass_complete is declared execution: 'perRecord' and its handler writes ctx.record.
  • content/docs/ui/actions.mdx: the bulk dispatch contract section and "Authorization inside an action" state the rule, its refusals and the three calls that are not read.
  • .changeset/action-selection-read-scope.md: @objectstack/runtime patch, BREAKING (narrowing), with the FROM/TO and the caller's fix.

Read first, by risk:

  1. packages/runtime/src/action-dispatch.ts — the shape check in the admission, the read beside the subject load, the verdict beside the subject verdict.
  2. packages/runtime/src/action-execution.ts — actionSelectionIsRead, actionSelectionIdsOrRefuse, loadActionSelectionRecords, refuseUndeliveredActionSelection, the hand-off verdict, and the near-miss arm of enforceActionParams.
  3. packages/runtime/src/action-selection-caller-scope.pin.test.ts — the real-stack pins.

Why

Security hardening ordered by the security seat as a no-card dispatch. The mechanism is with that seat, not here.

Tests

  • packages/runtime/src/action-selection-caller-scope.pin.test.ts (new): one booted kernel (ObjectQL, sqlite, auth, security, sharing, REST, dispatcher) under the walled isolated posture, REST and MCP bridge doors. Refusal cases (rows outside the caller's read scope, alone and beside readable ones, and an id that names nothing) assert status + code, that the handler was never entered, and that each named row reads back unchanged from the store. Readable controls: the caller's own rows are written; a repeated id is handed on as sent. Read parity: on an object whose API exposes the record read but not the list, a selection the caller reads row by row runs. Shape: one id not in a list, a list carrying a non-id, an empty or whitespace-only id, a readable id beside an empty one, 5001 ids; exactly 5000 is read, not refused for size. Near-miss: four spellings refused, any other custom key still passes.
  • packages/runtime/src/action-door-record-load-denied.test.ts (shared harness, new top-level describes): the flow arm and the script arm refuse an unreadable selection on both doors with no run and no body; the readable control runs both; an object-less action key with a selection answers 400 VALIDATION_FAILED; the AI door judges the selection before a confirmation hand-off; an empty selection reads nothing; which arms are read; the read: each distinct id once, the first undelivered id named in the order sent, a throwing read delivers nothing.
  • packages/runtime/src/action-invocation-audit.test.ts: the bulk-count rig now serves the selection its caller reads (a fixture consequence of the rule; assertions unchanged).

Acceptance notes

  • Exemption stated (seat ruling A): the declarative-update arm is not read: it writes as the caller and builds nothing elevated.
  • Owed skills follow-up (governed surface, cut from this PR by the seat): the published skill rule text on actions and its eval case that teaches an aggregate body writing rows should move to the per-record form for row writes, and state that a selection is read in the caller's scope before the action runs. Rule-level wording only.
  • The near-miss predicate is a runtime-side reading of the spec's exported built-in key list; the refusal sentence is the spec's own validateActionParams text. No spec edit.
  • Contract-tier review of this PR is the security seat's.

Verification

Two-minute check: pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/action-selection-caller-scope.pin.test.ts — expect Tests 46 passed (46).

Red on the base, green on the fix
  • Base (db9e34ad, the round-one pin file alone): Tests 24 failed | 10 passed (34).
  • Read-parity pins, on the head before the read moved: Tests 2 failed | 34 passed (36).
  • Non-empty-id pins, on the head before that check: Tests 8 failed | 38 passed (46).
  • Current head: Tests 46 passed (46).
Ablation — each guard removed in turn, through scripts/ablation-replace.mjs (anchor 1 → 0 on disk, restored blob == HEAD, `git diff HEAD` empty after each)

Run over the pin file and the shared harness together, on the head each guard was last changed at:

guard removed result
the dispatch verdict 14 failed
the hand-off verdict 1 failed
the read's denial 19 failed
the list-of-ids shape 4 failed
the non-empty id 8 failed
the 5000 cap 2 failed
the object-less refusal 1 failed
the near-miss refusal 8 failed
Package checks
  • pnpm --filter @objectstack/runtime typecheck (tsc + check:test-typecheck): exit 0.
  • pnpm --filter @objectstack/runtime test on the current head: Test Files 637 passed (637). (The bulk-count rig in action-invocation-audit.test.ts was a fixture consequence of the rule, fixed in round one.)
  • pnpm --filter @objectstack/example-todo typecheck && pnpm --filter @objectstack/example-todo test: exit 0.
  • The full dogfood battery on the final head, the derived gate families and the CI check-runs are reported in the report comment on this PR.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes. (No formatter ran; pnpm lint is CI's run, read from the check-runs.)
  • 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 Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

@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 21, 2026
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/runtime, touching 17 documentable anchor(s).

6 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/error-catalog.mdx (via invalid_value (literal, a string literal in actionSelectionIdsOrRefuse), max_items (literal, a string literal in actionSelectionIdsOrRefuse))
  • content/docs/api/plugin-endpoints.mdx (via invalid_value (literal, a string literal in actionSelectionIdsOrRefuse))
  • content/docs/automation/flows.mdx (via invalid_value (literal, a string literal in actionSelectionIdsOrRefuse))
  • content/docs/data-modeling/field-types.mdx (via invalid_value (literal, a string literal in actionSelectionIdsOrRefuse))
  • content/docs/data-modeling/validation-rules.mdx (via invalid_value (literal, a string literal in actionSelectionIdsOrRefuse))
  • content/docs/permissions/system-context.mdx (via actionSelectionIsRead (symbol, a top-level function), invalid_value (literal, a string literal in actionSelectionIdsOrRefuse))

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

  • content/docs/releases/v18/18-2.mdx (via invalid_value (literal, a string literal in actionSelectionIdsOrRefuse))

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
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 67 of 249 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 — 30 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 28ba01fe6939ac40a5e72efe32ea6b7680eed33e → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 28ba01fe6939ac40a5e72efe32ea6b7680eed33e

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

…d's system bypass; pay the metadata load at collection

Claude-Session: https://claude.ai/code/session_017xRBcUJzFmCqbSKS3TpveD
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcUJzFmCqbSKS3TpveD
os-dev-report

{
 "issue": null,
 "status": "done",
 "branch": "claude/action-selection-read-scope",
 "pr": "https://github.com/objectstack-ai/objectstack/pull/36132",
 "session": "session_017xRBcUJzFmCqbSKS3TpveD",
 "premise_still_valid": true,
 "summary": "Order of record (advisory fix plan steps 1-5, 7 and the docs half of 6) implemented on claude/action-selection-read-scope after merging origin/main (fast-forward to db9e34ad). The shared action sequence (REST, MCP run_action, host dispatchAction) now shape-checks params._selectedIds beside the record key (list of ids, cap 5000, object-less key refused 400 VALIDATION_FAILED), reads the distinct ids once in the caller's own execution context beside the subject load (chunk = min(500, OS_DATA_MAX_PAGE_SIZE, OS_DATA_QUERY_ROW_BUDGET), fields id, explicit limit; any throw or row-less answer counts as not delivered), and consumes the verdict as 404 RECORD_NOT_FOUND for the whole call at the subject-verdict point and before the AI door's hand-off; exempt: declarative update (seat ruling A, stated in the PR), type api, ec.isSystem. A param-less action refuses the near-miss built-in spellings selectedIds/_recordId/_objectName through the param contract (lax env keeps its warn), other custom keys still pass. app-todo todo_mass_complete is execution: 'perRecord' and writes ctx.record; actions.mdx documents the rule. Step 0 was measured first on the base (see security_findings); the planned fix shape closes it and it has its own red-then-green pins. Draft PR #36132 opened through the relay with the first real commits; no card, no Fixes line.",
 "tests": "Real-stack pin packages/runtime/src/action-selection-caller-scope.pin.test.ts (booted kernel, isolated posture, REST + MCP bridge): base db9e34ad 'Tests 24 failed | 10 passed (34)', fix 'Tests 34 passed (34)'. Shared harness action-door-record-load-denied.test.ts: 'Tests 31 passed (31)'. action-invocation-audit.test.ts: red after the change (its rig never served the selection; 9 failures 'Record l1 not found in aud_lead'), fixture fixed, '45 passed (45)'. pnpm --filter @objectstack/runtime test at ba1920e0: '1 failed | 636 passed (637)' files, the one failure being that audit file before its fixture fix, then green alone. Ablation via scripts/ablation-replace.mjs over both pin files (65 tests), each leg anchor 1 -> 0 on disk, restored blob == HEAD and git diff HEAD empty: dispatch verdict 14 failed; hand-off verdict 1 failed; list-of-ids shape 4 failed; 5000 cap 2 failed; object-less refusal 1 failed; near-miss refusal 6 failed. No dist ablation needed: the subjects are runtime src imported by the package's own tests. app-todo: typecheck + test exit 0 (TODO-EXIT 0).",
 "gates": "Local derived set (dispatch-gates --commands, 103 families at 9abda326): 99 exit 0; exit 3 PREREQUISITE NOT MET (NOT MEASURED locally, CI runs them): check-plugin-teardown-shape --self-test (shallow clone cannot reach its pinned fixture commit), spec check:skill-examples (unbuilt declarations), check:dual-build-cjs-loads (unbuilt packages/qa/scenarios dist). First pass reds fixed in the diff: check:system-context-census (new isSystem read needed a register row: row 49 extended, --write regenerated) and check:test-source-alias (module-top import of @objectstack/metadata in the edited harness file); both exit 0 after. check:type-check-debt re-run alone exit 0 (two of my gate loops overlapped once; the clean re-run is the reading). dispatch-gates --ran: '103 derived famil(ies) accounted for - 103 run'. pnpm --filter @objectstack/runtime typecheck (tsc + check:test-typecheck) exit 0. CI on PR head 9abda326: all 55 check-runs completed, none failed: Lint & Repo Gates success, TypeScript Type Check success, Test Core success (10/10 shards success), Build Core success, Governed Surface Queue Guard success, Test UI success, Live E2E UI success, Dogfood Regression Gate success, Check Changeset success, Lint · ESLint success, Check Documentation Links success; UI jobs Lint UI / Type Check UI / Build & E2E UI skipped by path filter.",
 "dogfood_battery": "ba1920e0 (code-identical to the final head 9abda326 for every package the battery builds: the later commit changes a docs page and a test import only) · os-verify-lock: VERDICT command-exit 0 · held the lock 2532s · Test Files 483 passed | 3 skipped (486) · Tests 4101 passed | 68 skipped (4169) · no failures",
 "mcp_calls": "2 - mcp__github__pull_request_read (get_check_runs, get_status); no GitHub MCP write tool. Also claude-code-remote subscribe_pr_activity (not GitHub MCP).",
 "api_writes": "2 relay writes through scripts/pm: fleet-write pr_create (POST /repos/objectstack-ai/objectstack/pulls, draft, #36132, read-back identical) and this report comment via post-stamped.mjs (POST /repos/objectstack-ai/objectstack/issues/36132/comments). Plus 1 relay read (advisory_read). git push x3 (not REST).",
 "line_budget": "10 files, +799 / -20 (runtime src +184/-6, tests +543/-4, docs +31/-1, example +17/-9, changeset +24)",
 "files_changed": [
  ".changeset/action-selection-read-scope.md",
  "content/docs/permissions/system-context.mdx",
  "content/docs/ui/actions.mdx",
  "examples/app-todo/src/actions/task.actions.ts",
  "examples/app-todo/src/actions/task.handlers.ts",
  "packages/runtime/src/action-dispatch.ts",
  "packages/runtime/src/action-door-record-load-denied.test.ts",
  "packages/runtime/src/action-execution.ts",
  "packages/runtime/src/action-invocation-audit.test.ts",
  "packages/runtime/src/action-selection-caller-scope.pin.test.ts"
 ],
 "deviations": [
  "content/docs/permissions/system-context.mdx is outside the expected landing: check:system-context-census requires a register row to own the new isSystem read (actionSelectionIsRead); row 49 extended and the register regenerated with --write.",
  "packages/runtime/src/action-invocation-audit.test.ts fixture changed: its rig never served the selected rows, so the rule refused its bulk-count calls; the rig now serves the selection, assertions unchanged.",
  "No packages/spec edit: the near-miss predicate reads the exported ACTION_PARAM_BUILTIN_KEYS in runtime, and the refusal text is spec validateActionParams' own; builtinNearMissHint stays private.",
  "Step-0 harness enforces the isolated posture with an org-scoping service slot instead of @objectstack/organizations (runtime has no dependency on it); Layer 0 is the real plugin-security wall, rows are seeded with explicit organization_id.",
  "Worktree created from the shared checkout by detaching its HEAD (the order's branch was checked out there)."
 ],
 "open_questions": [
  {
   "question": "The near-miss check lives runtime-side over the spec's exported built-in key list, a second spelling of the spec's one-byte rule. Export a predicate from spec instead?",
   "options": [
    "A keep runtime-side (no spec export change)",
    "B export a spec predicate (published export added, api-surface regen, contract review)"
   ],
   "recommendation": "A, because the order forbids widening into spec and the refusal text is already the spec's; B is a clean follow-up if the rule ever grows."
  },
  {
   "question": "The 404 names the first undelivered id of the selection; acceptable as non-disclosing (a hidden row and a missing id answer alike, and the caller sent that id)?",
   "options": [
    "A keep naming the first undelivered id",
    "B name no id"
   ],
   "recommendation": "A, matching the per-record door's envelope, which names its id."
  },
  {
   "question": "Flow actions are read too (the exemption list names only api, declarative update and system). A flow whose runAs is user already re-derives scope; reading its selection is a narrowing for it as well.",
   "options": [
    "A keep (as ordered)",
    "B exempt runAs user flows"
   ],
   "recommendation": "A, as ordered; one rule for every elevated-capable arm."
  }
 ],
 "security_findings": "withheld",
 "out_of_scope_findings": [
  "carrier: security seat · owed skills follow-up (governed surface, cut by the seat): skills/objectstack-ui rules/actions text and the views-apps-actions-pages eval case move to the per-record form for row writes; rule-level wording only; noted in PR Acceptance notes, not filed",
  "carrier: security seat · L2 contract-tier review of PR #36132 is owed by the security seat; not knocked"
 ]
}

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

Contract-tier review (L2) and adversarial read — REWORK · head 9abda326b5b2bf07ae4602c8ac26b74c18fe8622. The reviewer was an isolated CONTRACT_REVIEW_TIER thread, read-only. It ran the PR's own pins (65 passed) and its own real-stack probes from a git archive export. The PR merges cleanly into origin/main.

Holds.

  • The narrowing is the order's steps 1–5 and 7, plus seat ruling A.
  • Both declarations are true; no new error code.
  • The exemptions are exactly the declarative update, type: 'api' and the system principal.
  • REST, MCP and the host share one sequence.
  • The verdict is consumed before the AI hand-off and again on re-admission.
  • Chunk boundaries, throws, empty, null and duplicates behave as documented.
  • Public title, body, commits and changeset are rule-level.

Owed in this PR, before the seat's delta read:

  1. content/docs/ui/actions.mdx (~669-671): the sentence says more than the door reads. The ids are read as rows of the object the call names. Scope the sentence to that, or make it true.
  2. The selection read asks the same operation the per-record door asks for its record (get, not list), so a selection the caller can read record by record is not refused whole. Pin it. If it cannot, the changeset's FROM/TO states the difference and the caller's fix.
  3. Test titles in action-selection-caller-scope.pin.test.ts (~272, ~306, ~321-322 and header item 3): state the rule only. Name no session condition.
  4. Nits:
    • the changeset and docs list every near-miss spelling refused (four, not three);
    • re-attach laxActionParams' docblock;
    • the app-todo action's AI description no longer says "one bulk operation".

Not in this PR (with the security seat): two adjacent items found at the doors, on code this PR does not change; and whether ids are handed on as sent or normalised.

…; rule-only pin titles; near-miss list and wording

Claude-Session: https://claude.ai/code/session_017xRBcUJzFmCqbSKS3TpveD
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcUJzFmCqbSKS3TpveD
os-dev-report

Delta for review record 7066277867, head 08f8b748.

{
 "issue": null,
 "status": "done",
 "branch": "claude/action-selection-read-scope",
 "pr": "https://github.com/objectstack-ai/objectstack/pull/36132",
 "session": "session_017xRBcUJzFmCqbSKS3TpveD",
 "premise_still_valid": true,
 "summary": "REWORK round on review record 7066277867 (items 1-4), head 08f8b748. (1) actions.mdx and the changeset scope the rule to rows of the object the call names (ctx.params.objectName). (2) Read parity: the selection read now asks the per-record door's own operation, callData('get') per distinct id through loadActionSubjectRecord, in windows of 16 (it was a batched list read). Pinned: on an object whose API exposes get but not list, a selection the caller reads row by row answers 200 and is written, REST and MCP; red on 9abda326 (2 failed | 34 passed (36)), green after. The batched data layer cannot ask a get-permission read, so the read moved rather than the changeset stating a difference. (3) Pin titles and header state the rule only: no session condition is named; assertions kept. (4) The near-miss list is four everywhere (selectedIds, __selectedIds, _recordId, _objectName; pinned too); laxActionParams' docblock is back above its own function; app-todo's AI description says a list selection runs it once per task. The first-round fix is unchanged otherwise (shape, verdict at dispatch and before the AI hand-off, exemptions per seat ruling A, api, system).",
 "tests": "Head 8dc46599 (runtime code identical to 08f8b748, which changes docs and the changeset only): pin file + shared harness + audit rig 'Tests 114 passed (114)'; app-todo typecheck + test '267 passed (267)'; pnpm --filter @objectstack/runtime test on 08f8b748: 'Test Files 637 passed (637) · Tests 11769 passed | 25 skipped (11794)', lock VERDICT command-exit 0. New get-only pin red on 9abda326 (find-based read): 'Tests 2 failed | 34 passed (36)', 404 RECORD_NOT_FOUND where 200 expected; green after. Ablation on 8dc46599 via scripts/ablation-replace.mjs over the pin file + shared harness (69 tests), each anchor 1 -> 0, restored blob == HEAD, git diff HEAD empty: dispatch verdict 14 failed; hand-off verdict 1 failed; the read's denial (new read) 19 failed; near-miss refusal 8 failed. Shape/cap/object-less guards unchanged since the first round (their ablations stand: 4, 2, 1 failed).",
 "gates": "Delta subset on the rework, each exit 0: check:system-context-census, check:test-source-alias, check:doc-authoring, check:doc-anchors, check:nul-bytes, check:docs-spec-enumerations, check-doc-route-spelling --advisory, check-adr-0087-registration --base origin/main, check-empty-changeset, check-changeset-no-major, check:dispatcher-error-vocabulary, check:error-status-conformance, check:route-envelope, check:issue-citations, check:examples-live-imports; runtime typecheck exit 0. The full derived set (103) ran green on 9abda326 in round one (4 exit 3 PREREQUISITE NOT MET, NOT MEASURED locally). CI: head 8dc46599 check suite completed with no failure (notification). Head 08f8b748 at report time: Lint & Repo Gates success, TypeScript Type Check success, Build Core success, Governed Surface Queue Guard success, Check Changeset success, Dogfood Regression Gate success, Test UI success, Live E2E UI success, Lint · ESLint success, Test Core shards 4/5/8/9/10 success, Test Core shards 1/2/3/6/7 in_progress (honest value; not waited on).",
 "dogfood_battery": "Round-one reading stands: ba1920e0 · VERDICT command-exit 0 · Test Files 483 passed | 3 skipped (486) · Tests 4101 passed | 68 skipped (4169). Not re-run for the rework, per the seat's order: runtime src changed only in the read operation (find -> per-id get) plus a moved docblock. A rerun I started on 8dc46599 did not complete (the turn ended on the usage limit; no VERDICT line) and is NOT MEASURED.",
 "mcp_calls": "3 total - mcp__github__pull_request_read x3 (get_check_runs x2, get_status x1); no GitHub MCP write tool.",
 "api_writes": "3 relay writes through scripts/pm: pr_create (#36132), the round-one os-dev-report comment 7065778044, and this delta os-dev-report comment. Plus 1 relay read (advisory_read). git push x5 (not REST).",
 "line_budget": "10 files, see PR file list; the rework adds the get-only pin and per-id read, and removes the chunked-list machinery",
 "files_changed": [
  ".changeset/action-selection-read-scope.md",
  "content/docs/permissions/system-context.mdx",
  "content/docs/ui/actions.mdx",
  "examples/app-todo/src/actions/task.actions.ts",
  "examples/app-todo/src/actions/task.handlers.ts",
  "packages/runtime/src/action-dispatch.ts",
  "packages/runtime/src/action-door-record-load-denied.test.ts",
  "packages/runtime/src/action-execution.ts",
  "packages/runtime/src/action-invocation-audit.test.ts",
  "packages/runtime/src/action-selection-caller-scope.pin.test.ts"
 ],
 "deviations": [
  "content/docs/permissions/system-context.mdx is outside the expected landing: check:system-context-census requires a register row to own the new isSystem read (actionSelectionIsRead); row 49 extended and the register regenerated with --write.",
  "packages/runtime/src/action-invocation-audit.test.ts fixture changed: its rig never served the selected rows, so the rule refused its bulk-count calls; the rig now serves the selection, assertions unchanged.",
  "No packages/spec edit: the near-miss predicate reads the exported ACTION_PARAM_BUILTIN_KEYS in runtime, and the refusal text is spec validateActionParams' own; builtinNearMissHint stays private.",
  "Step-0 harness enforces the isolated posture with an org-scoping service slot instead of @objectstack/organizations (runtime has no dependency on it); Layer 0 is the real plugin-security wall, rows are seeded with explicit organization_id.",
  "Worktree created from the shared checkout by detaching its HEAD (the order's branch was checked out there).",
  "The selection read was the order's batched list read (step 2); it now uses the per-record door's own per-id get, per review item 2, because a list read refused selections the per-record door admits. Cost: up to 5000 reads per call, 16 at a time.",
  "Dogfood not re-run for the rework (seat order: only if runtime src changes beyond the read operation)."
 ],
 "open_questions": [
  {
   "question": "The near-miss check lives runtime-side over the spec's exported built-in key list, a second spelling of the spec's one-byte rule. Export a predicate from spec instead?",
   "options": [
    "A keep runtime-side (no spec export change)",
    "B export a spec predicate (published export added, api-surface regen, contract review)"
   ],
   "recommendation": "A, because the order forbids widening into spec and the refusal text is already the spec's; B is a clean follow-up if the rule ever grows."
  },
  {
   "question": "The 404 names the first undelivered id of the selection; acceptable as non-disclosing (a hidden row and a missing id answer alike, and the caller sent that id)?",
   "options": [
    "A keep naming the first undelivered id",
    "B name no id"
   ],
   "recommendation": "A, matching the per-record door's envelope, which names its id."
  },
  {
   "question": "Flow actions are read too (the exemption list names only api, declarative update and system). A flow whose runAs is user already re-derives scope; reading its selection is a narrowing for it as well.",
   "options": [
    "A keep (as ordered)",
    "B exempt runAs user flows"
   ],
   "recommendation": "A, as ordered; one rule for every elevated-capable arm."
  },
  {
   "question": "The per-id read costs up to 5000 sequential-in-windows reads on a select-all-matching call. Keep it, or add a batched get-permission read to the data layer later?",
   "options": [
    "A keep per-id get (exact parity now)",
    "B data-layer batched get read as a follow-up"
   ],
   "recommendation": "A now, since parity is the rule; B only if a measured selection cost asks for it."
  }
 ],
 "security_findings": "withheld",
 "out_of_scope_findings": [
  "carrier: security seat · owed skills follow-up (governed surface, cut by the seat): skills/objectstack-ui rules/actions text and the views-apps-actions-pages eval case move to the per-record form for row writes; rule-level wording only; noted in PR Acceptance notes, not filed",
  "carrier: security seat · L2 contract-tier review of PR #36132 is owed by the security seat; not knocked"
 ]
}

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

Delta read at 08f8b748b4c116407521eb1082dc483f06447ce2: REWORK. Reviewed by an isolated CONTRACT_REVIEW_TIER thread, read-only. CI is green, the merge is clean, and pins plus harness pass 114/114 on an export of the head.

Items 1–4 of 7066277867 are closed.

  • The docs scope the read to the object the call names.
  • The selection read asks the per-record door's own operation. The new pins fail on the old head and pass now.
  • Test titles state the rule only.
  • All four near-miss spellings are listed.

Owed before the next delta read

  1. Blocking. Every element of a selection is a non-empty record id. An empty element is refused at the shape check with the existing 400 VALIDATION_FAILED, before any read runs. Pin it on both doors: a selection of only an empty id, and a selection that mixes an empty id with a readable one.
  2. PR body. It describes the current read, not the earlier batched one, and gives the current near-miss list and test counts.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcUJzFmCqbSKS3TpveD
os-dev-report

Delta for the delta read of 08f8b748, head 59428ccd.

{
 "issue": null,
 "status": "done",
 "branch": "claude/action-selection-read-scope",
 "pr": "https://github.com/objectstack-ai/objectstack/pull/36132",
 "session": "session_017xRBcUJzFmCqbSKS3TpveD",
 "premise_still_valid": true,
 "summary": "Third round on the seat's delta read of 08f8b748 (FAIL, one regression), head 59428ccd. (1) BLOCKING, closed: every element of a selection is a non-empty record id. An empty or whitespace-only element is refused at the shape check with 400 VALIDATION_FAILED (field _selectedIds, code invalid_value), before any read. Pinned on REST and MCP: [''], [''] by a caller who reads no row, ['   '], and [readable, '']. Nothing runs and nothing is written. Red on 08f8b748 (8 failed | 38 passed (46)), green after, ablated. Docs and changeset say 'non-empty record ids'. (2) PR body rewritten through the relay's issue_patch: the read is described as the per-record door's own read, the near-miss list has four spellings, test counts are current (46), the ablation table is current; the seat's Skills-docs line and signed last line are kept. Nit: the pin header no longer says 'read once, batched'. The no-protocol fallback's strict id match is left as is, per the seat.",
 "tests": "Head 59428ccd: pin file + shared harness + audit rig 'Tests 122 passed (122)' with runtime typecheck exit 0; pin file alone 'Tests 46 passed (46)'. pnpm --filter @objectstack/runtime test: 'Test Files 637 passed (637) · Tests 11777 passed | 25 skipped (11802)', lock VERDICT command-exit 0. New empty-id pins red on 08f8b748: 'Tests 8 failed | 38 passed (46)'. On that head [''] and [readable, ''] passed the read and entered the body: REST answered 400 VALIDATION_ERROR 'Update requires an ID…' from inside the handler, MCP threw the same without a status. ['   '] was refused 404 by the read. Ablation of the new check via scripts/ablation-replace.mjs over pin + harness (77 tests): anchor 1 -> 0, '8 failed | 69 passed (77)', restored blob == HEAD, git diff HEAD empty. Earlier guards unchanged; their ablations stand (dispatch verdict 14, hand-off 1, read denial 19, list shape 4, cap 2, object-less 1, near-miss 8).",
 "gates": "Delta subset at 59428ccd, each exit 0: check:system-context-census, check:test-source-alias, check:doc-authoring, check:nul-bytes, check-adr-0087-registration --base origin/main, check-empty-changeset --base origin/main, check:error-status-conformance, check:dispatcher-error-vocabulary, check:route-envelope. The full derived set (103) ran in round one (4 exit 3 PREREQUISITE NOT MET, NOT MEASURED locally). CI at 59428ccd at report time, none failed: Lint & Repo Gates success, TypeScript Type Check success, Build Core success, Governed Surface Queue Guard success, Dogfood Regression Gate success, Test UI success, Live E2E UI success, Lint · ESLint success, PR-body guards success (re-run after the body patch), Test Core shards 2/4/5/8/9/10 success, shards 1/3/6/7 in_progress, Check Changeset success on push and in_progress on its re-run after the body patch (honest values; not waited on). CI at 08f8b748: check suite completed with no failure.",
 "dogfood_battery": "Not re-run, per the seat's order: runtime src changed only at the shape check (one non-empty-id refusal in actionSelectionIdsOrRefuse). The round-one reading stands: ba1920e0 · VERDICT command-exit 0 · Test Files 483 passed | 3 skipped (486) · Tests 4101 passed | 68 skipped (4169).",
 "mcp_calls": "5 total - mcp__github__pull_request_read x5 (get_check_runs x3, get_status x1, get x1); no GitHub MCP write tool.",
 "api_writes": "5 relay writes through scripts/pm: pr_create (#36132), report comments 7065778044 and 7073507317, issue_patch of the PR body (seat-ordered; 8411 bytes sent and stored, identical), and this delta os-dev-report comment. Plus 1 relay read (advisory_read). git push x6 (not REST).",
 "line_budget": "10 files, see PR file list; the rework adds the get-only pin and per-id read, and removes the chunked-list machinery",
 "files_changed": [
  ".changeset/action-selection-read-scope.md",
  "content/docs/permissions/system-context.mdx",
  "content/docs/ui/actions.mdx",
  "examples/app-todo/src/actions/task.actions.ts",
  "examples/app-todo/src/actions/task.handlers.ts",
  "packages/runtime/src/action-dispatch.ts",
  "packages/runtime/src/action-door-record-load-denied.test.ts",
  "packages/runtime/src/action-execution.ts",
  "packages/runtime/src/action-invocation-audit.test.ts",
  "packages/runtime/src/action-selection-caller-scope.pin.test.ts"
 ],
 "deviations": [
  "content/docs/permissions/system-context.mdx is outside the expected landing: check:system-context-census requires a register row to own the new isSystem read (actionSelectionIsRead); row 49 extended and the register regenerated with --write.",
  "packages/runtime/src/action-invocation-audit.test.ts fixture changed: its rig never served the selected rows, so the rule refused its bulk-count calls; the rig now serves the selection, assertions unchanged.",
  "No packages/spec edit: the near-miss predicate reads the exported ACTION_PARAM_BUILTIN_KEYS in runtime, and the refusal text is spec validateActionParams' own; builtinNearMissHint stays private.",
  "Step-0 harness enforces the isolated posture with an org-scoping service slot instead of @objectstack/organizations (runtime has no dependency on it); Layer 0 is the real plugin-security wall, rows are seeded with explicit organization_id.",
  "Worktree created from the shared checkout by detaching its HEAD (the order's branch was checked out there).",
  "The selection read was the order's batched list read (step 2); it now uses the per-record door's own per-id get, per review item 2, because a list read refused selections the per-record door admits. Cost: up to 5000 reads per call, 16 at a time.",
  "Dogfood not re-run for the rework (seat order: only if runtime src changes beyond the read operation).",
  "PR body PATCHed after creation (issue_patch), on the seat's explicit order; the seat's Skills-docs line and signed last line are kept verbatim."
 ],
 "open_questions": [
  {
   "question": "The near-miss check lives runtime-side over the spec's exported built-in key list, a second spelling of the spec's one-byte rule. Export a predicate from spec instead?",
   "options": [
    "A keep runtime-side (no spec export change)",
    "B export a spec predicate (published export added, api-surface regen, contract review)"
   ],
   "recommendation": "A, because the order forbids widening into spec and the refusal text is already the spec's; B is a clean follow-up if the rule ever grows."
  },
  {
   "question": "The 404 names the first undelivered id of the selection; acceptable as non-disclosing (a hidden row and a missing id answer alike, and the caller sent that id)?",
   "options": [
    "A keep naming the first undelivered id",
    "B name no id"
   ],
   "recommendation": "A, matching the per-record door's envelope, which names its id."
  },
  {
   "question": "Flow actions are read too (the exemption list names only api, declarative update and system). A flow whose runAs is user already re-derives scope; reading its selection is a narrowing for it as well.",
   "options": [
    "A keep (as ordered)",
    "B exempt runAs user flows"
   ],
   "recommendation": "A, as ordered; one rule for every elevated-capable arm."
  },
  {
   "question": "The per-id read costs up to 5000 sequential-in-windows reads on a select-all-matching call. Keep it, or add a batched get-permission read to the data layer later?",
   "options": [
    "A keep per-id get (exact parity now)",
    "B data-layer batched get read as a follow-up"
   ],
   "recommendation": "A now, since parity is the rule; B only if a measured selection cost asks for it."
  }
 ],
 "security_findings": "withheld",
 "out_of_scope_findings": [
  "carrier: security seat · owed skills follow-up (governed surface, cut by the seat): skills/objectstack-ui rules/actions text and the views-apps-actions-pages eval case move to the per-record form for row writes; rule-level wording only; noted in PR Acceptance notes, not filed",
  "carrier: security seat · L2 contract-tier review of PR #36132 is owed by the security seat; not knocked"
 ]
}

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

Contract review

Head-sha: 59428ccd16bec2ea7cb9d45d4f63bd6ec9edf1ec

PASS at CONTRACT_REVIEW_TIER on the narrowing face (Clause-②: no (narrowing), ! in the title). Served-tier: CONTRACT_REVIEW_TIER. Each review below was by an isolated, read-only thread.

  • Full review plus adversarial read (comment 7066277867, at 9abda326b5): REWORK.
    • Holds: the narrowing matches the order and the seat's ruling A. The declarations are true. There is no new code. The exemptions are exactly the declarative update, type: 'api' and the system principal. REST, MCP and the host share one sequence. Chunk boundaries, throws and duplicates behave as documented.
    • Owed: the docs scope, read-operation parity, rule-only test titles, and the nits.
  • Delta (comment 7074038507, at 08f8b748b4): the four owed items closed; one regression found. An empty selection element was admitted.
  • Delta at this head: PASS.
    • Every element of a selection is a non-empty record id, checked at the shape check before any read, on both doors. Empty, whitespace-only and non-string elements are refused with 400 VALIDATION_FAILED, and nothing runs.
    • The new pins fail 8 of 46 on the previous head and pass 46/46 here. Pins, harness and audit rig pass 122/122. The ablation of the check goes red, and the blob is restored identical.
    • The PR body describes the current read, rule-level.
    • 59 check-runs, none failed. The PR merges cleanly into origin/main.

Nits, not blocking: header item 5 of the pin file omits "non-empty", and the shape cases assert "no read" only through the status code.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

席位记录 · ACCEPT · head 59428ccd16bec2ea7cb9d45d4f63bd6ec9edf1ec

维护者速读

  • 改了什么:批量动作提交一组选中记录时,平台会先按调用者自己的权限,逐条读取这些记录;只要有一条读不到,整次调用就被拒绝(404),什么都不执行。选中列表必须由非空的记录 id 组成。
  • 为什么:这是高危公告的修复,属于安全席位的无卡派单。
  • 若出错:只会多拒,不会多放;调用者能读的选择照旧执行;可以直接撤回。
  • 要你做什么:请用授权账号批准当前 head 59428ccd1(契约审核 PASS 记录:评论 7074432354)。批准后由席位翻 ready、入队、落地。

席位意见:ACCEPT。三轮审核(完整审核加对抗复读,再加两轮改动复核)的应修项已经全部关闭。

席位核对

  1. 形态: draft PR,以 main 为基,无卡。改动集中在 runtime 包(patch)、示例应用 app-todo、两个文档页和一个 changeset。技能文档的部分按文件面规则另走跟进卡 objectstack-ui actions rule and its eval teach the per-record form for a body that writes each selected row #36156。
  2. 前提实测: 第 0 步先测了「会话没有活动组织」这条边界。修前红:24 个失败、10 个通过;修后 46/46 通过。逐个撤掉守卫都会变红。改动复核里,空元素的 8 个用例在上一个 head 上全红,在当前 head 上全绿。
  3. 门禁: head 上 59 个 check-run,没有失败。landing-k 结果 OK(K = 5)。dogfood 套件在之前的 head 上已经全绿;这两轮改的是形状检查和读取所用的操作,CI 的 Test Core 已覆盖。
  4. 接受的偏差: 近似拼写的检查放在 runtime 一侧;404 会点名第一个读不到的 id;flow 类动作也一样先读。
  5. 范围外去向,Skills-docs:: Skills-docs: follow-up #36156。相邻的残留已经由安全席位另行记录,根因已另立私密公告并已裁定。
  6. 落地条款:
    • 本 PR 申报为收窄,需要两半同时在案:授权账号对当前 head 的批准,加上本 head 上的契约审核 PASS。
    • 批准后,席位做落地前检,然后执行 pr_ready 和 automerge_enable。
    • 合并后,私密公告保持草稿,直到剩下的残留由裁决处置完毕。合并本身记进台账。

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 22, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 22, 2026 05:03
@os-zhuang
os-zhuang enabled auto-merge November 22, 2026 05:03
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 22, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 59428ccd16bec2ea7cb9d45d4f63bd6ec9edf1ec
Local-runs: probe — the empty-element pins, their ablation and shape probes on both doors, run from git archive exports
Scope: examples/app-todo/src/actions/task.actions.ts, examples/app-todo/src/actions/task.handlers.ts, packages/runtime/src/action-dispatch.ts, packages/runtime/src/action-door-record-load-denied.test.ts, packages/runtime/src/action-execution.ts, packages/runtime/src/action-invocation-audit.test.ts, packages/runtime/src/action-selection-caller-scope.pin.test.ts + none

① Derived judgments

A record-less call's selection is read in the caller's scope with the per-record door's own operation before an elevated body runs; every element is a non-empty record id; any undelivered id refuses the whole call 404; exemptions are exactly the declarative update, type api and the system principal. Full review 7066277867 (REWORK), deltas 7074038507 (REWORK) and the delta at this head (PASS). Prior record: comment 7074432354.

② Semver level

patch with the BREAKING banner and ! title, as declared (Clause-②: no (narrowing), Metadata-protocol: none).

③ Boundary flags

Dev open questions 1-3 answered A (accepted). SQL push-down: the selection is read per id through the per-record door's own get, bounded at 5000 ids; no in-app join.

④ Design judgment

The narrowing holds against the published spec on main: it makes an existing refusal real and takes no declared capability away. No must-fix or should-fix is open at this head; nits only, recorded in the prior record.

Implemented-by: session_017xRBcUJzFmCqbSKS3TpveD
Reviewed-by: session_017xRBcW9L8Noz9BxEwjwiov

VERDICT: PASS

1 similar comment
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 59428ccd16bec2ea7cb9d45d4f63bd6ec9edf1ec
Local-runs: probe — the empty-element pins, their ablation and shape probes on both doors, run from git archive exports
Scope: examples/app-todo/src/actions/task.actions.ts, examples/app-todo/src/actions/task.handlers.ts, packages/runtime/src/action-dispatch.ts, packages/runtime/src/action-door-record-load-denied.test.ts, packages/runtime/src/action-execution.ts, packages/runtime/src/action-invocation-audit.test.ts, packages/runtime/src/action-selection-caller-scope.pin.test.ts + none

① Derived judgments

A record-less call's selection is read in the caller's scope with the per-record door's own operation before an elevated body runs; every element is a non-empty record id; any undelivered id refuses the whole call 404; exemptions are exactly the declarative update, type api and the system principal. Full review 7066277867 (REWORK), deltas 7074038507 (REWORK) and the delta at this head (PASS). Prior record: comment 7074432354.

② Semver level

patch with the BREAKING banner and ! title, as declared (Clause-②: no (narrowing), Metadata-protocol: none).

③ Boundary flags

Dev open questions 1-3 answered A (accepted). SQL push-down: the selection is read per id through the per-record door's own get, bounded at 5000 ids; no in-app join.

④ Design judgment

The narrowing holds against the published spec on main: it makes an existing refusal real and takes no declared capability away. No must-fix or should-fix is open at this head; nits only, recorded in the prior record.

Implemented-by: session_017xRBcUJzFmCqbSKS3TpveD
Reviewed-by: session_017xRBcW9L8Noz9BxEwjwiov

VERDICT: PASS

@os-zhuang
os-zhuang added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit c448c61 Nov 22, 2026
65 checks passed
@os-zhuang
os-zhuang deleted the claude/action-selection-read-scope branch November 22, 2026 08:09
247257110 pushed a commit to 247257110/objectstack that referenced this pull request Nov 23, 2026
…on a disabled package's object (objectstack-ai#36337)

<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCxiFE11rsKwyNffJZKYqJs)_

Part of objectstack-ai#35526

Clause-②: yes (narrowing: for a non-system caller, `callData`'s
`aggregate` arm and its `query` fallback on a host with no protocol
service refuse a nested-relation condition whose target belongs to a
disabled package with 404 `OBJECT_PACKAGE_DISABLED`, where they answered
the count or the matching rows)
Metadata-protocol: none
Skills-docs: none — the docs already teach this answer:
`content/docs/deployment/marketplace-handbook.mdx` says a disabled
module is refused on the data plane with `404 OBJECT_PACKAGE_DISABLED`
and that in-process `ctx.api` is not refused; this PR makes the `/mcp`
aggregate door match that text and leaves the system context as it is

## 维护者速读
- 用户能看到什么变化:环境里停用了某个应用包时,普通成员通过 AI 助手的统计工具(或动作)用该包对象的字段做关联条件,以前会得到 1 或 0
的计数,现在和直接读取一样被拒绝(404);系统身份的调用不变。
- 为什么做:属于"停用包在所有读取入口都不可见"这一组修复,替成员挡住统计入口这扇门,避免从计数推出停用包里的字段内容。
- 出错会怎样:只影响停用了包、且查询条件指向该包对象的成员请求;没有停用包的环境不受影响;可以直接撤回本 PR 恢复原行为。
- 要你做什么:决定系统身份调用是否也要拒绝(这一半留给你裁决,本 PR 不改它)。

## What changes

- `packages/runtime/src/action-execution.ts`
`refuseUnservedRelationTargets` (used by `callData`'s `aggregate` arm
and by the `query` fallback on a host with no protocol service) asks,
per nested-relation condition site and before the exposure check, the
engine registry's `isObjectPackageDisabled` through
`registryObjectPackageDisabled` (`@objectstack/core`, the accessor
already documented as "the predicate the data plane asks"). A disabled
target throws the protocol's own `objectPackageDisabledError(target)`
with `param: where.FIELD`: the same code, status, sentence and `object`
the protocol's relation-condition check (`refuseUnservedRelationTarget`,
objectstack-ai#35427) throws. No second copy of the predicate or the refusal.
- `@objectstack/metadata-protocol` exports `objectPackageDisabledError`
from its root, beside `recordNotFoundError` (exported for the same
`callData` fallback reason). Additive, enabling-only: no behaviour of
that package changes. This is a new published export; see Acceptance
notes.
- The system-context bypass (`exposureGated = !isSystem`) is **not**
changed. The package check rides it, so a system context is still
answered the count. That half of the card is the maintainer's open point
(ruling 6545646924 keeps in-process access served; a hook's `ctx.api` is
a system context); the docblock names it and a pin holds today's answer.
- Stdio twin (`packages/mcp/src/stdio-data-bridge.ts`
`enforceRelationTargetExposure`): measured, not changed. With a protocol
it already refuses a non-system caller 404 `OBJECT_PACKAGE_DISABLED` (it
reads the target through the protocol's by-name read). No pin added
there.

The system-identity half of objectstack-ai#35526 awaits a maintainer decision, so this
PR does not close the card.

## Tests

New file
`packages/runtime/src/action-execution-calldata-relation-disabled-package-35526.test.ts`:
a real `ObjectQL` over `SqlDriver` (in-memory SQLite), the real
`ObjectStackProtocolImplementation` where the host has one, packages
A/B/C, `dp_alpha.b_ref` into B's `dp_beta`, `dp_alpha.c_ref` into C's
`dp_gamma`.

- THE PIN, aggregate arm, with and without a protocol: member caller, B
disabled, `where { b_ref: { secret_note: VALUE } }` refused `404
OBJECT_PACKAGE_DISABLED`, `object: dp_beta`, `param: where.b_ref`, for
the stored value AND for a value nothing holds (one answer both ways: no
oracle). Code and status asserted.
- THE PIN, query fallback (no protocol): same refusal, both values.
- CONTROL: B re-enabled answers count 1 / 0 (aggregate) and the matching
record (fallback).
- CONTROL: a condition into enabled C's `dp_gamma` is served (1 / 0)
while B is disabled.
- SYSTEM (pinned as today's answer, open point named in the test):
aggregate with B disabled answers 1 / 0 on both hosts.
- The query arm through the protocol still answers 404 for the member
(the data route's own answer, unchanged).

Full dogfood battery (owed once at the final head for the narrowing
arm), run at `f26f20f54e` by seat 7 under the shared verify lock (`pnpm
--filter '@objectstack/dogfood^...' build && pnpm --filter
@objectstack/dogfood test`, no `OS_TEST_SHARD`, no path): lock `VERDICT
command-exit 1`; **Test Files 6 failed | 478 passed | 3 skipped (487);
Tests 6 failed | 4101 passed | 68 skipped (4175)**. Each of the six
failures is `Test timed out in 5000ms` on a shared box (the hold ran
1h42m beside other sessions' unlocked work), and none of the six files
reaches `callData`'s aggregate arm or a disabled package's relation
condition (grep of the six files for aggregate / OBJECT_PACKAGE_DISABLED
/ disabled package: no hit; the one `disabled` hit is a disabled-flow
refusal): `flow-name-per-namespace.dogfood.test.ts`,
`object-hook-lifecycle-showcase.dogfood.test.ts`,
`packaged-flow-write-door-parity.dogfood.test.ts`,
`permission-unknown-grant-object-refusal.dogfood.test.ts`,
`rest-route-generation-tombstones.test.ts`,
`wall-package-doors-refusal.dogfood.test.ts`. A locked re-run of those
six files alone was queued and is **NOT MEASURED** (the lock went to
another session's full battery; queue-timeout, exit 99). CI's `Dogfood
Regression Gate` runs the battery in the merge queue.

## Acceptance notes

- **New published export.** `objectPackageDisabledError` is now on
`@objectstack/metadata-protocol`'s root. Without it the no-protocol
fallback has no way to raise the data plane's refusal except a copy of
the constructor, which the file's own rule forbids. Precedent:
`recordNotFoundError`, exported for the same `callData` fallback.
Flagged for the reviewer because a published export is contract surface.
- **Read only, not measured on a public door (not filed):** on a host
that registers no protocol service, `callData` serves a disabled
package's object when it is ADDRESSED directly (the package refusal
lives in the protocol's by-name read, which that host lacks), so after
this PR such a host refuses a relation condition into the object but
still serves the object itself. The stdio bridge on a no-protocol host
serves both (measured with a temporary probe, not committed). And the
MCP multi-env query fallback can hand `callData` a raw driver with no
registry, where the predicate answers "not disabled" (a registry that
cannot answer disables nothing, as on the data route).
- **Stdio twin readings** (temporary probe over a real engine and the
real protocol, B disabled, `where { b_ref: { secret_note: VALUE } }`):
non-system + protocol: aggregate and query refused 404
`OBJECT_PACKAGE_DISABLED` for both values; non-system, no protocol:
served 1 / 0; system, either host: served 1 / 0.
- Overlap with objectstack-ai#36132 (same file, other hunks): `overlap-check` before
each push, clean every time. objectstack-ai#36132 has since merged into `main`
(c448c61, hunks near L204, L3442-3794, L4676, disjoint from this PR's
L340 and the two call sites). `overlap-check` against `origin/main`
ed33f8a: merges cleanly. The head was not re-merged with `main`: no
GitHub conflict and no main-caused red (AGENTS.md multi-agent discipline
10), and a new head would void the battery above. The merge queue builds
and tests the joint tree.
- `test:repo` (vitest `repo` project) is CI's (`Test Core`); this diff
touches none of its files.

## Verification

Read first, by risk:
1. `packages/runtime/src/action-execution.ts`, the hunk in
`refuseUnservedRelationTargets`: the predicate is read from the engine
passed in (`ql` on the fallback, `engine` on the aggregate arm).
2. `packages/metadata-protocol/src/index.ts`: the one added export line.
3. The new test file's SYSTEM pin, which holds the open point.

Two minutes: `pnpm --filter @objectstack/runtime exec vitest run
--maxWorkers=2
src/action-execution-calldata-relation-disabled-package-35526.test.ts` →
12 passed.

All readings at head `f26f20f54e` unless named.

<details><summary>Premise on origin/main a5a5312 (before the
fix)</summary>

Same pin file run before the runtime edit (in-memory driver harness at
that point): the 3 member pins red (aggregate with protocol, aggregate
without protocol, query fallback: the call resolved, nothing refused), 9
green: B re-enabled answers 1 / 0, the enabled-package condition answers
1 / 0, the system caller answers 1 / 0 with B disabled on both hosts,
and the query arm through the protocol answers 404
`OBJECT_PACKAGE_DISABLED`. This matches the card's measured 1 / 0
oracle.
</details>

<details><summary>Pins, ablation and restore</summary>

- `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2
src/action-execution-calldata-relation-disabled-package-35526.test.ts`
(lock VERDICT command-exit 0): Test Files 1 passed, Tests 12 passed.
- Ablation via `scripts/ablation-replace.mjs`, anchor `if
(isObjectPackageDisabled(site.target)) {` replaced by `if (false &&
isObjectPackageDisabled(site.target)) {`: anchor 1 to 0, blob
0ea829f to 2866cbecc099; Tests 3 failed, 9 passed (exactly the
three member pins). Restored: blob 0ea829f equals the HEAD blob,
`git diff HEAD` empty. The runtime test imports `./action-execution.js`
from source, so no build sits between the mutation and the run.
</details>

<details><summary>Package suites and typecheck</summary>

- `pnpm --filter @objectstack/metadata-protocol --filter
@objectstack/runtime typecheck`: exit 0.
- `pnpm --filter @objectstack/metadata-protocol test`: exit 0.
- `pnpm --filter @objectstack/runtime test` (local project): Test Files
636 passed of 637, the one failure being this PR's pin file caught
mid-edit while its harness moved from the frozen in-memory driver to
`SqlDriver`; the pin file alone then passed 12 / 12 at the final head.
</details>

<details><summary>Derived gate families</summary>

Seat 4, at `f26f20f54e`: 69 derived, 69 run (`check:type-check-debt`
green in its own locked run). Earlier runs caught
`check:driver-memory-census` and `check:test-source-alias`; both fixed
before this head.

Seat 7, again at `f26f20f54e` (no new commit): `node
scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--commands` derived 69 commands (its stderr warns the tree is 39 commits
behind origin/main and six scripts/pm gate files moved there; the head
was kept, see Acceptance notes). 67 exit 0. `check:plugin-teardown-shape
--self-test` first exited 3 (shallow clone could not reach its pinned
fixture commit; fetched it) and then 0; `check:dts-closure` first exited
1 (no dist yet, run beside the build) and then 0 after the build. Two
are NOT MEASURED, each exit 3 (prerequisite not met):
`check:dual-build-cjs-loads` (six packages outside the dogfood closure
have no dist: studio, client-react, embedder-openai, knowledge-memory,
knowledge-ragflow, scenarios; their locked build never got the lock) and
`check:type-check-debt` (its nested locked closure build queue-timed
out). `--ran` reconciliation: 69 derived, 67 run, 2 NOT-MEASURED
(derived from the recorded exit 3), 0 unrun, exit 0.

CI at `f26f20f54e` (check-runs read, not re-run): `Lint & Repo Gates`
success, `TypeScript Type Check` success, `Type Check · debt ledger`
success, `Test Core` success (10/10 shards), `Build Core` success,
`Governed Surface Queue Guard` success, `Test UI` success, `Live E2E UI`
success, `Dogfood Regression Gate` success (PR run; its shards run in
the queue), `Check Changeset` success; `Lint UI`, `Type Check UI`,
`Build & E2E UI` skipped (no ui path).
</details>


🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC

<!-- signed: repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jTeURPvEm465RcoYEC -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
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 pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue 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

Development

Successfully merging this pull request may close these issues.

2 participants