@@ -375,7 +375,45 @@ developer runs objectstack publish
375375Studio is intentionally a viewer here. If a user sees bad metadata in Studio,
376376the fix is to edit the local TS files and publish again.
377377
378- ### 6.3 Runtime Request
378+ ### 6.3 Runtime Inputs
379+
380+ ObjectOS 的运行时输入分两类,** 缺一不可** 。把两类混在一起就破坏了 §2「Centralized Metadata, Stateless Runtime」与 §8「ObjectOS 只通过 Artifact API 接触控制面」的边界。
381+
382+ ** A. Artifact** (不可变、可缓存、随 metadata 变更而变更)
383+
384+ ` ProjectArtifactSchema ` envelope,定义在 [ packages/spec/src/cloud/project-artifact.zod.ts] ( packages/spec/src/cloud/project-artifact.zod.ts ) :
385+
386+ ```
387+ { schemaVersion, projectId, commitId, checksum, builtAt, builtWith, metadata }
388+ ```
389+
390+ ` metadata ` 字段就是 ` objectstack compile ` 产出的 ` dist/objectstack.json ` 整体。承载所有声明性元数据(objects、views、flows、agents、插件清单等)+ 内联函数代码。Envelope 在外面包一层 ` commitId ` / ` checksum ` ,让 ObjectOS 能做 ETag 校验和缓存失效。
391+
392+ ** B. Deployment Config** (可变、不进 artifact、与元数据正交)
393+
394+ ObjectOS 启动时必须从外部注入:
395+
396+ 1 . 业务 DB 坐标(URL / driver / 凭据)
397+ 2 . 项目身份(` projectId ` / ` organizationId ` / ` hostname ` )
398+ 3 . 控制面 URL(用于拉 artifact、上报 audit)
399+ 4 . 进程级密钥(` AUTH_SECRET ` 、KMS 密钥)
400+
401+ ** 云端模式** 下,B 来自控制面 ` sys_project ` + ` sys_project_credential ` + 进程 env。** 本地单 project 模式** (一个 ObjectOS 进程对应一个 project,不是多租户网关)下退化为扁平 env:
402+
403+ | Env | 用途 | 备注 |
404+ | :---| :---| :---|
405+ | ` OBJECTSTACK_PROJECT_ID ` | 项目身份 | 本地可固定为 ` proj_local ` |
406+ | ` OBJECTSTACK_DATABASE_URL ` | 业务 DB URL | 例:` file:./.data/app.db ` |
407+ | ` OBJECTSTACK_DATABASE_DRIVER ` | 业务 DB driver | ` turso ` / ` sqlite ` / ` memory ` |
408+ | ` OBJECTSTACK_ARTIFACT_PATH ` | 本地 artifact 路径 | 默认 ` ./dist/objectstack.json ` ;填了即跳过 Artifact API |
409+ | ` OBJECTSTACK_CLOUD_URL ` | 控制面 URL | 留空即「纯本地离线」;填了即「本地 ObjectOS + 远端控制面」 |
410+ | ` AUTH_SECRET ` | 进程级密钥 | |
411+
412+ 本地模式可以用磁盘 ` dist/objectstack.json ` 直接喂内核(用 ` commitId: 'local-dev' ` 之类的占位 envelope),不需要控制面在场。
413+
414+ ** 结论** :` objectstack.json ` 是元数据(A)的充分输入,但** 不是** 运行时的充分输入。任何把业务 DB 连接、密钥、租户身份塞进 ` objectstack.json ` 的尝试都是反模式(见 §8)。
415+
416+ ### 6.4 Runtime Request
379417
380418```
381419GET https://proj.app/api/v1/data/customer
@@ -448,6 +486,11 @@ reduce Drift, and advance Missing.
448486 it POSTs a "package" payload ([ packages/cli/src/commands/publish.ts] ( packages/cli/src/commands/publish.ts ) )
449487 which is not the Phase 1 project metadata endpoint. It needs to become
450488 ` POST /api/v1/apps/:projectId/metadata ` .
489+ - ** ` ProjectKernelFactory ` 直连控制面 DB 读 ` sys_project ` / ` sys_project_credential ` ,绕过 Artifact API。**
490+ [ packages/runtime/src/project-kernel-factory.ts] ( packages/runtime/src/project-kernel-factory.ts )
491+ 在 boot 时直接查控制面表拿业务 DB 坐标和凭据,破坏了 §8「ObjectOS 只通过
492+ Artifact API 接触控制面」的边界。修复方向:业务 DB 坐标和凭据归 Deployment
493+ Config(§6.3 B),通过启动时注入而非控制面 DB 直连。
451494
452495### <Globe className = " inline" /> Missing (Not Started)
453496
@@ -479,6 +522,7 @@ without explicit project-level buy-in.
479522
480523- <AlertTriangle className = " inline" /> ** ObjectOS runtimes don't talk to the control-plane DB.** The only coupling surface is the Artifact API (HTTP). Runtimes never open a connection to the control-plane database, even for "just a quick lookup."
481524- <AlertTriangle className = " inline" /> ** Project business data is not metadata.** Business rows live in the per-project business DB. Metadata lives in the control plane.
525+ - <AlertTriangle className = " inline" /> ** Deployment Config 不进 artifact。** 业务 DB 坐标、凭据、进程密钥、租户身份等可变运行配置必须从启动环境(云端模式:控制面 ` sys_project ` + env;本地模式:扁平 env)注入,** 绝不** 写入 ` objectstack.json ` 。把可缓存的不可变内容和易变的部署配置混在一起会同时破坏 §2 和 §8。详见 §6.3。
482526
483527### Representation-form boundaries
484528
@@ -503,10 +547,11 @@ design docs before building.
5035471 . ** Artifact content format details.** Phase 1 chooses a single JSON document,
504548 but the exact envelope, manifest fields, function-code packaging, and driver
505549 requirement declaration still need a Zod schema.
506- 2 . ** Business DB connection config ownership.** Does the Artifact include the
507- business DB connection string (simple but mixes environment into artifact),
508- or is it injected into ObjectOS at boot time (artifact stays clean, but
509- requires per-deployment config)?
550+ 2 . ~~ ** Business DB connection config ownership.** ~~ ** Resolved (2026-04-25):**
551+ Business DB coordinates and credentials are ** Deployment Config** , never
552+ part of the Artifact. See §6.3 Runtime Inputs. Cloud mode sources them from
553+ control-plane ` sys_project ` / ` sys_project_credential ` + process env;
554+ local single-project mode sources them from flat ` OBJECTSTACK_* ` env vars.
5105553 . ** Artifact cache invalidation.** Control-plane push notification?
511556 Periodic polling from ObjectOS? HTTP ETag on every request? Each has
512557 latency / chattiness / outage-resilience trade-offs.
0 commit comments