Skip to content

fix(runtime): honor app-declared default profile on the artifact-serve path (ADR-0056 D7) - #2132

Closed
xuyushun441-sys wants to merge 3 commits into
mainfrom
fix/dev-app-default-profile
Closed

xuyushun441-sys wants to merge 3 commits into
mainfrom
fix/dev-app-default-profile

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Collaborator

问题

objectstack dev/serve/start 从编译产物(dist/objectstack.json,无 host objectstack.config.ts)启动时,不会应用 app 声明的默认权限集 profile(isProfile: true, isDefault: true),而带 config 启动时会。表现:一个默认 profile 携带 readScope(如 ADR-0057 unit_and_below)的 app,在 artifact 启动路径下被忽略,所有用户回退到内置仅 owner 的 member_default,层级 scope fail-closed。

根因

dev 没有独立启动路径,它把 serve --dev 当子进程拉起;无 config 时走 artifact 启动路径。产物本身保留了 permissions/isDefault,但 createStandaloneStack(packages/runtime)只把 objects/requires/manifest 浮到顶层,漏掉了 permissions[] 和 roles[]。于是 serve.ts 的 appDefaultProfileName(config.permissions) 拿到 undefined,SecurityPlugin 回退到 member_default。config 加载路径未受影响,仅因 originalConfig.permissions 在展开时幸存。

修复

在 createStandaloneStack 中把产物 bundle 的 permissions[] 和 roles[] 一并浮到顶层,与现有 objects/requires/manifest 处理方式一致。这样 artifact 启动路径对 app 默认 profile 的处理与 config 路径完全相同(也修复了 artifact 模式下 app org roles 未注册到 Better-Auth 的同类缺口)。

验证

  • 新增 runtime 回归测试 packages/runtime/src/standalone-stack.test.ts(5/5):artifact 路径现在浮出 permissions/roles(含 readScope),并驱动 appDefaultProfileName。
  • 新增 dogfood 端到端 packages/dogfood/test/showcase-scope-depth-fallback.dogfood.test.ts(4/4):profile 按名字作为 fallbackPermissionSet 解析(正是修复所喂入的 CLI 接线),可见性矩阵按 unit_and_below 放宽(配合参考层级 resolver),无 resolver 时 fail-closed 退回 owner-only。对齐参考用例 showcase-scope-depth.dogfood.test.ts 的矩阵。
  • 全量:runtime 401 通过,dogfood 145 通过;CLI 冒烟确认 artifact-fallback 启动加载 permissions/roles 且 Security 正常注册。

🤖 Generated with Claude Code

…e path (ADR-0056 D7)

`createStandaloneStack` (the boot path used by `objectstack dev`/`serve`/`start`
when serving a compiled `dist/objectstack.json` with no host
`objectstack.config.ts`) surfaced `objects`/`requires`/`manifest` from the
artifact bundle but dropped `permissions[]` and `roles[]`. So the CLI's
`appDefaultProfileName(config.permissions)` saw `undefined` and SecurityPlugin
fell back to the built-in owner-only `member_default` — an app `isDefault`
profile carrying e.g. `readScope: 'unit_and_below'` was silently ignored. The
config-load path was unaffected (the app's `permissions` survived via the
original stack object).

Surface `permissions[]` and `roles[]` from the artifact bundle, mirroring the
existing `objects`/`requires`/`manifest` handling, so the artifact-serve path
applies the app default profile exactly like the config-load path.

Tests:
- packages/runtime/src/standalone-stack.test.ts — the artifact-serve path now
  surfaces permissions/roles (incl. readScope) and drives appDefaultProfileName.
- packages/dogfood/test/showcase-scope-depth-fallback.dogfood.test.ts — a
  profile resolved by name as fallbackPermissionSet widens the visibility matrix
  (unit_and_below) with the reference hierarchy resolver, and fails closed
  without it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 21, 2026 3:08pm

Request Review

@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 size/m labels Jun 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/dogfood, @objectstack/runtime.

17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/cloud-artifact-api.mdx (via packages/runtime)
  • content/docs/concepts/implementation-status.mdx (via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/concepts/packages.mdx (via @objectstack/runtime)
  • content/docs/guides/api-reference.mdx (via @objectstack/runtime)
  • content/docs/guides/authentication.mdx (via @objectstack/runtime)
  • content/docs/guides/cloud-deployment.mdx (via @objectstack/runtime)
  • content/docs/guides/deployment-vercel.mdx (via @objectstack/runtime)
  • content/docs/guides/driver-configuration.mdx (via @objectstack/runtime)
  • content/docs/guides/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/guides/packages.mdx (via @objectstack/runtime)
  • content/docs/guides/plugin-chatbot-integration.mdx (via @objectstack/runtime)
  • content/docs/guides/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/guides/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/index.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/lifecycle.mdx (via @objectstack/runtime)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

The first createStandaloneStack call cold-loads heavy deps (objectql/metadata/
driver-memory) via dynamic import, which on a cold CI worker (Node 20) exceeded
vitest's default 5s test timeout — failing only the first case. Move the
one-time boot into a beforeAll with a 60s timeout and have the assertion cases
read the shared result (also removes 4 redundant boots).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@xuyushun441-sys

Copy link
Copy Markdown
Collaborator Author

核心修复已随 #2133 合入 main,配套的测试超时修复已由 #2145 合入。本 PR 是 CI 触发故障期间产生的重复,关闭清理。

This branch was successfully deployed

1 active deployment
Preview — 0713d86c Deployed Jun 21, 2026 by vercel[bot]
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.

2 participants