Skip to content

fix(runtime)!: a member removed from an environment is refused on their next request - #32919

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-2hf9jm
Nov 13, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-2hf9jm

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #32230

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no published skill teaches the environment-membership check (git grep over skills/ for the check, its error code and the member object: 0 hits)

维护者速读

  • 改了什么:多环境部署中,环境成员检查对每一次请求都按成员表的当前状态判断,不再沿用之前请求的放行结果;一个人被移出环境后,他的下一次请求即被拒绝,所有副本一致。
  • 为什么改:被移出环境的人不应在移出之后还能继续访问该环境。
  • 风险与回滚:收紧方向。每个环境内请求多一次按唯一键的成员查询;成员表所在存储不可用期间,环境内请求得到可重试的 503。匿名请求、系统环境、关闭检查的部署不变。回滚即 revert 本 PR。
  • 先看:packages/runtime/src/http-dispatcher.ts(judgeMembershipOf 开头与成员判定处)、packages/runtime/src/http-dispatcher-membership-revocation.test.ts、.changeset/environment-membership-removal-next-request.md
  • 两分钟验证:pnpm --filter @objectstack/runtime exec vitest run src/http-dispatcher-membership-revocation.test.ts,预期 7 个用例全部通过。
  • 需要你做的:无,席位落地。

What changes

The rule: a membership change takes effect on the next request. On a host that enforces environment membership, the check judges every scoped request against the membership store as it stands and carries no admission from one request to the next. So a member removed from an environment is refused on their next request, on every replica serving it, and a request whose membership the store cannot answer is the outage (AuthzStoreUnavailableError, 503 SERVICE_UNAVAILABLE), never "allowed", whoever was admitted a moment before.

  • packages/runtime/src/http-dispatcher.ts: judgeMembershipOf reads sys_environment_member for every judged request and keeps no admission between requests. Both doors that share the judgment (dispatch() and the declarative-endpoint step environmentMembershipRefusal) follow the rule.
  • Unchanged: anonymous requests, the well-known system environment, members of the platform organization, hosts with enforceProjectMembership: false, compositions that register no environment-member object, the 403 PROJECT_MEMBERSHIP_REQUIRED answer and the fail-closed read (finding(runtime, plugin-auth): two access guards fail open when their own read faults — the environment-membership gate and the organization slug guard #21941).
  • packages/runtime/src/http-dispatcher.test.ts: a case that pinned the earlier behaviour now pins the rule (a member removed between two calls is refused on the second).
  • packages/runtime/src/domains/meta-list-projection-parity.test.ts: one comment no longer names a membership answer kept between requests, and a side-effect import the test-source alias lint requires. No assertion changes.
  • .changeset/environment-membership-removal-next-request.md: patch on @objectstack/runtime, ! summary, BREAKING paragraph with "Who moves", ADR-0087 not-required (no-migration-prescription) marker.

Tests

packages/runtime/src/http-dispatcher-membership-revocation.test.ts (new, 7 cases, named by the rule):

  • a member admitted on one request and then removed is refused on the very next request;
  • every replica serving the environment refuses the removed member on its next request (two dispatchers over one membership store);
  • the declarative-endpoint step applies the same rule;
  • a member admitted a moment ago is answered 503 when the membership store cannot answer, never admitted;
  • a member removed and added back is admitted again on the next request;
  • CONTROL: a member who stays a member is admitted on consecutive requests; the system environment stays open to a signed-in caller who holds no membership row.

Ablation (one-shot, not kept): with the rule removed from the committed fix, 4 of the 7 cases go red, the four the rule decides; the re-add case and both CONTROL cases stay green. Restored: blob equal to HEAD, git diff HEAD empty.

Acceptance notes

  • Ruling: the maintainer chose option A on the card's release question on 2026-11-12 22:56Z, in the maintainer's own words 「A 去掉缓存,进 18.4.0」 (drop the cache, ship in 18.4.0), accepting one membership lookup per judged request and the retriable 503 while the membership store is unreachable. The seat's relay of it is claim comment 6838259317 on runtime: 环境成员缓存(60 秒)在成员变更时不失效,被撤权的用户最长还能访问一分钟 #32230.
  • A future reuse of membership answers would have to meet the authorization-cache rule resolve-authz-context.ts states (cache a success only behind seams that observe the writes it depends on, with a TTL as the residual bound); the code comment at the read says so.

Verification

Readings name their tree. Head of this PR: dd756258. It is 26651cce (the fix 99d1a01b, the changeset 97fe2d48, and one merge of origin/main touching neither packages/runtime, packages/core nor packages/objectql) plus 1bf1aeb3 (the dispatcher suite's pin rewritten to the rule), b7b373fd (one comment in a test file) and dd756258 (a side-effect import '@objectstack/metadata'; at the top of meta-list-projection-parity.test.ts, which the test-source alias lint requires).

Before the fix (the new suite, ablated tree)

The new suite with the rule removed from the committed fix (97fe2d48, mutation via scripts/ablation-replace.mjs, anchor hit 1 -> 0, blob changed on disk): Tests 4 failed | 3 passed (7). The four the rule decides go red. Restored: blob equal to HEAD, git diff HEAD empty. A first attempt was refused by the tool before any run (its replacement contained the anchor, so the anchor count could not fall); nothing ran on that attempt.

After the fix: the membership suites

At 97fe2d48, pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 over the new suite, http-dispatcher-membership-session-principal, http-dispatcher-membership-resolved-principal, http-dispatcher-membership-vetted-organization, http-dispatcher.membership-system-context, http-dispatcher.membership-skip-boundary and dispatcher-plugin.endpoint-environment-membership.integration: Test Files 7 passed (7), Tests 68 passed (68).

@objectstack/runtime typecheck and full test

At 26651cce, under the verification lock: typecheck ok; Test Files 1 failed | 592 passed (593), Tests 1 failed | 11612 passed | 19 skipped (11632). The one failure was the http-dispatcher.test.ts case that pinned the earlier behaviour. After 1bf1aeb3 rewrote it to the rule: http-dispatcher.test.ts Tests 254 passed (254).

Derived gate union and dogfood battery

node scripts/pm/dispatch-gates.mjs --commands at dd756258: 68 derived, 66 exit 0, 2 NOT MEASURED locally (check:dual-build-cjs-loads and the type-check debt ledger: prerequisite not met in the build box; CI runs both, and CI's Type Check · debt ledger is success on this head). Dogfood battery at dd756258: VERDICT exit 0, Test Files 456 passed | 3 skipped (459), Tests 3831 passed | 42 skipped (3873). CI on dd756258: every check-run complete, none failed.


Generated by Claude Code

…r next request

The environment-membership gate judges every request against the membership
store as it stands; no admission is carried from one request to the next.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czRj9LhJRdzK77xHSP
…their next request

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czRj9LhJRdzK77xHSP
…econd

The dispatcher suite pinned the reuse of an admission across calls; it now
pins the rule that replaces it.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czRj9LhJRdzK77xHSP
…pt between requests

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czRj9LhJRdzK77xHSP
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

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

  • content/docs/api/environment-routing.mdx (via HttpDispatcher (symbol, a top-level class))
  • content/docs/automation/webhooks.mdx (via HttpDispatcher (symbol, a top-level class))
  • content/docs/kernel/cluster.mdx (via HttpDispatcher (symbol, a top-level class))
  • content/docs/plugins/packages.mdx (via HttpDispatcher (symbol, a top-level class))

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

  • content/docs/releases/v17/17-5.mdx (via HttpDispatcher (symbol, a top-level class))

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

What this run could not see
  • 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 — 29 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 1a6c330945dac00bb42fccd09f42e39ce510d8e1 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 1a6c330945dac00bb42fccd09f42e39ce510d8e1

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

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 12, 2026
check-test-source-alias judges the test files a change edits, and this one
now reaches the dispatcher's dynamic metadata import; the module-top import
is the gate's prescription.

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

Copy link
Copy Markdown
Contributor Author

security#1 · os-elon-musk · session_016WV4cx5nHfga3Hm9BzikGw

Contract-review-claim: session_016WV4cx5nHfga3Hm9BzikGw · head dd75625 · 2026-11-13T00:04Z

The implementing thread may not review its own fix; the lane seat takes it (narrowing face, CONTRACT_REVIEW_TIER).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-elon-musk · session_016WV4cx5nHfga3Hm9BzikGw

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: dd7562583d436be54100a980276c45e67e130510
Local-runs: none
Scope: packages/runtime/src/http-dispatcher.ts, packages/runtime/src/http-dispatcher-membership-revocation.test.ts, packages/runtime/src/http-dispatcher.test.ts, packages/runtime/src/domains/meta-list-projection-parity.test.ts + packages/core/src/security/resolve-authz-context.ts, packages/core/src/security/authz-store-unavailable.ts, packages/runtime/src/api-endpoint-step.ts, packages/runtime/src/dispatcher-plugin.ts, packages/runtime/src/http-dispatcher.membership-skip-boundary.test.ts, packages/spec/src/stack.zod.ts

Read: card #32230 (body and all 5 comments), PR #32919 (body, 2 comments, 5 files), the net diff against main (merge-base 474f7dbc; main has not moved a scoped file since), and the 51 check-runs on this head: 35 success, 16 skipped, none failed, none pending.

① Derived judgments

Accept-set, at the environment-membership check (judgeMembershipOf, reached from dispatch() and from environmentMembershipRefusal):

  1. A principal with no sys_environment_member row for the resolved environment is answered 403 PROJECT_MEMBERSHIP_REQUIRED on every request, the first one after the row is removed included. On main a positive verdict stood for its 60 s TTL, per dispatcher instance. Narrowing. Right: it is the card's Expected and ruling A.
  2. A principal whose membership read cannot be made, or throws, is answered the outage (AuthzStoreUnavailableError, 503 SERVICE_UNAVAILABLE) on every request; a verdict from an earlier request no longer stands in for the read. Narrowing. Right: it carries the fail-closed read of finding(runtime, plugin-auth): two access guards fail open when their own read faults — the environment-membership gate and the organization slug guard #21941 to every caller, and the claim comment records the ruling as accepting it.
  3. Nothing widens. The removed field held positive verdicts only, so no path that answered 403 or threw now answers null. A member who is added is admitted on the next request, as before.
  4. Unchanged: enforcement off, no resolved environment, the system environment, the platform organization, the path skips of enforceProjectMembership, a composition that registers no member object, and the no-principal fallback.
  5. Role change, which the card's Expected also names: the check reads row presence only. The dispatcher is the only non-test reader of the member object in this tree and it does not read role, so no role verdict exists here to go stale.
  6. Cost: one find (limit: 1) per gated request for a member, where it was at most one per TTL per instance. The claim comment records the ruling as accepting it.

Public surface: none moves. No export, option, config key, wire shape or error code is added or removed; both answers above already exist. Two private members leave the HttpDispatcher class, and no other file in the tree names them.

② Semver level

  • patch on @objectstack/runtime, the one package whose published source moves: right. Metadata-protocol: none is right (nothing a metadata author writes changes), and AGENTS.md step 3 ships a non-protocol breaking change as patch with its BREAKING banner and its ADR-0087 disposition. Both are in the changeset (not-required (no-migration-prescription): nothing authorable is removed, so no FROM/TO mapping is owed).
  • Clause-②: no (narrowing): right, line-initial on the PR body and on the changeset body. Judgments 1 to 3: a narrowing, no widening, no public surface.
  • Skills-docs: none: holds. No file under skills/ names the check, its error code or the member object, and no page under content/docs or docs/ states a reuse window.
  • Check Changeset and the lint gates are green on this head.
  • nit (prose face, for the seat's sentence check): "reads the membership store for every scoped request" and "once per scoped request" are wider than the code. The platform-organization bypass and the path skips of enforceProjectMembership answer before the read.

③ Boundary flags

  • Ruling A, escalated to the lane seat. The card carries the ruling as the seat's relay (claim comments 6838259317 and 6838313925), not in the maintainer's own words, and the card body proposed invalidation instead. The diff implements the ruling as relayed and as this review's brief names it. The seat confirms the verbatim ruling is on record before landing.
  • Dogfood battery, escalated to the lane seat. A ! / (narrowing) PR owes a dogfood battery pinned to its head. The PR body says its readings "go to the card's seat report and into this body when they land"; neither carries them. On this head the dogfood shard matrix and Dogfood Verify CLI concluded skipped, and the aggregate Dogfood Regression Gate is success. This is the seat's pre-queue check, not a contract finding.
  • The PR body names its head as b7b373fd and describes the parity suite as changed by "one comment". The reviewed head is one commit later and also adds a side-effect import to that file; ④ judges it. nit, PR body only.
  • The two gates the dev could not complete locally (check:dual-build-cjs-loads, check-plugin-teardown-shape --self-test): answered by the head's check-runs, all green or skipped.
  • The ablation the body reports (4 of 7 red) was not re-run. Read statically it agrees: cases 1 to 4 each need a second read to see the store change, and cases 5 to 7 pass either way.
  • The card's cross-replica invalidation channel is moot: no per-instance state is left to invalidate.
  • No open_questions entry is in the input set. The PR author is objectstack-fleet[bot], so no author note is owed.

④ Design judgment

Against the published spec on main: api.enforceProjectMembership is declared as the per-environment membership 403 gate, and the dispatcher plugin's option says it returns 403 for non-members. Neither declares a reuse window. The narrowing takes no declared capability away; it makes the declared refusal hold from the first request after a removal.

  • packages/runtime/src/http-dispatcher.ts — holds. The field, its TTL constant, the read, the write and the expiry delete are all gone. judgeMembershipOf reaches the registry probe and ql.find on every call, and both doors end in it. The class keeps no other verdict between requests (its two remaining memos are the /ready probes), and the engine keeps no find-result cache. Each comment sentence agrees with the code: the outage arms are the two AuthzStoreUnavailableError throws below the comment, and the cited rule is stated in resolve-authz-context.ts in those terms (a success is cached only where the engine exposes the write epoch and the middleware seam; the TTL is the residual bound). The rule reaches as far as the engine's read: the dispatcher adds no staleness of its own.
    • nit: the JSDoc block that now carries the rule sentence is detached from enforceProjectMembership; a second JSDoc block follows it, above enforceAuthGate. It is detached on main already.
  • packages/runtime/src/http-dispatcher-membership-revocation.test.ts — holds. Cases 1 to 4 fail under any reuse of a verdict. The 503 case pins the brand, the code, the status and object: 'sys_environment_member', so no other read's outage can satisfy it. Two dispatchers over one store stand for two replicas.
    • nit: "admitted" is asserted as the absence of the membership 403, not as a served answer. The endpoint-door case pins the 403 arm only; the outage arm on that door rests on the shared function.
  • packages/runtime/src/http-dispatcher.test.ts — holds. The fixture hands back opts.memberRows by reference on each read, so the second call sees the truncation. The retired call-count assertion pinned the reuse itself.
  • packages/runtime/src/domains/meta-list-projection-parity.test.ts — holds. The rewritten sentence is true of the dispatcher at this head. The side-effect import is the package's established collection-time pattern and moves no assertion.
  • Cited, outside the diff: packages/runtime/src/http-dispatcher.membership-skip-boundary.test.ts:35 still lists "a cached membership" among the ways the check answers null. nit, comment only: a follow-up card or a prose-only edit.

Findings: 0 must-fix, 0 should-fix, 5 nits. Nits alone end the round.

Implemented-by: claude/project-thread-2hf9jm
Reviewed-by: session_016WV4cx5nHfga3Hm9BzikGw

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-elon-musk · session_016WV4cx5nHfga3Hm9BzikGw

席位核对 — ACCEPT · security#1 · head dd7562583d436be54100a980276c45e67e130510

  • 形态: card runtime: 环境成员缓存(60 秒)在成员变更时不失效,被撤权的用户最长还能访问一分钟 #32230 (security · p0, 18.4.0 blocker), Fixes #32230. Not governed (check-governed-merges --pr 32919: 0 of 5 paths; 268 changed lines ≤ 3000) ⇒ ordinary queue landing. Clause-②: no (narrowing) · Metadata-protocol: none · Skills-docs: none. 7 commits behind main (< 15): no merge.
  • 前提实测: ruling A is quoted in the body in the maintainer's own words. Card thread readings at dd756258: new suite 7/7, membership suites 68/68, runtime typecheck ok, full runtime test green after the pin rewrite (254/254), ablation 4 red / 3 green restored clean, 66/68 derived gates exit 0 (2 prerequisite-not-met, both green in CI), dogfood battery VERDICT exit 0 (456 files / 3831 tests passed).
  • 契约复核: PASS (record above, CONTRACT_REVIEW_TIER, narrowing face, isolated reviewer run by this seat because the implementing thread may not review its own fix), no must-fix or should-fix. Its two escalations are answered in the body: the ruling's own words, and the dogfood reading for this head.
  • 门禁 check-runs: every check-run on this head complete, none failed.
  • 接受的偏差: the review's five nits. The changeset says "every scoped request" where the platform-organization bypass and the path skips answer first (the body lists both as unchanged). The JSDoc carrying the rule sentence sits apart from enforceProjectMembership, as it already did on main. The new suite reads "admitted" as the absence of the 403, and the endpoint-door case pins only the 403 arm. A comment in http-dispatcher.membership-skip-boundary.test.ts, outside this diff, still names a cached membership. The body's account of the head is now refreshed.
  • 范围外去向: nothing filed; the nits are accepted above.
  • 落地条款: pr_ready + auto-merge through the queue; runtime: 环境成员缓存(60 秒)在成员变更时不失效,被撤权的用户最长还能访问一分钟 #32230 closes on merge (Fixes); the seat then tells triage the 18.4.0 blocker is in.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-elon-musk · session_016WV4cx5nHfga3Hm9BzikGw

Landing: contract review PASS 6839864260 and seat ACCEPT 6839866031 on dd7562583d, every check-run green. Marked ready and queued with auto-merge. 18.4.0 blocker (#32230).

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime: 环境成员缓存(60 秒)在成员变更时不失效,被撤权的用户最长还能访问一分钟

2 participants