Repository navigation
Commit 1c53783
feat(cli,create-objectstack): os build says when the dev database holds Studio customizations it leaves behind; the starter docs name os package export (#30336)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgKdSU8f1JN5b9XUG5XoGicJ)_
domain:server#4 · os-bill · session_01Utp6CZMkHvuDeVYgTD73qF
Refs #30119 (server half). The Studio notice "where a customization is
saved" is the ui half and stays open on the card.
Clause-②: yes (widening) — the exported CompileCommand gains a protected
reportsLocalCustomizations flag (default false); nothing removed or
narrowed
Metadata-protocol: none
## 维护者速读
- 改了什么:`os build` 结束时,若本地开发库里有 Studio 定制(`包名.custom`
的条目),打印一次提示:几条、在哪个包、库文件在哪,用 `os package export` 带走;脚手架的 AGENTS.md 和
README 写明 Studio 改动存在数据库里、不进 `src/`,并说明代理该改 `src/`。
- 为什么改:开发者在 `os dev` 里用 Studio 调好视图,再 `os build` + Dockerfile
部署,改动丢了且无任何提示(卡上实测,本 PR 在当前 main 复测成立)。
- 风险与回滚:只读本地 SQLite、只多打印几行,不改构建产物、不改 `--json` 输出、不新增服务端接口;回滚即 revert 本
PR。
-
先看:`packages/cli/src/utils/local-customizations.ts`(读库与提示文字),`packages/cli/src/commands/compile.ts`(只在
build 上打开的那段),`packages/create-objectstack/src/templates/AGENTS.md`。
- 两分钟验证:在 examples/app-todo 跑 `os dev`,给 `todo_task.default` 存一个
`.custom` 覆盖,再跑 `os build`,结尾应看到「This build does not carry 1 Studio
customization…`os package export`」。
- 需要你做的:无,席位落地。
## What changes
**`os build` says what the artifact leaves behind.** After the artifact
is written, the text face reads the SQLite file `os dev` opens for the
project and counts the `sys_metadata` rows whose `package_id` ends in
`.custom` (ADR-0146 D2: a Studio change to a shipped item is an item of
`BASE.custom`). When there are any, it prints one warning and two dim
lines: the count per pair, the database file, and the remedy (make the
change in `src/`, or `os package export` while `os dev` runs).
- **Which database:** the one shared resolution
`resolveProjectDatabaseUrl` (`@objectstack/runtime`), over this
process's environment layered on the project's development `.env*` files
the way `os dev` loads them (dotenv-flow, process wins), without loading
them into the build's process.
- **Cheap and local:** opened read-only (`better-sqlite3`, the CLI's
optional dependency, as `sqlite-occupancy.ts` already does), one
aggregate `SELECT`. No server door, no network round trip. A database
that is not a local SQLite file (Postgres, MongoDB, libSQL, `:memory:`)
is not probed and prints nothing.
- **Never a verdict it did not reach:** a file that cannot be read, or a
missing `better-sqlite3`, prints "Could not check FILE … (reason)" plus
the remedy, never silence-as-empty. A database with no `sys_metadata`
table yet, or no `.custom` row, prints nothing. The probe never fails
the build.
- **Only on `os build`:** `Compile` gains a protected
`reportsLocalCustomizations = false`, and `Build` sets it `true`. `os
dev` compiles through `os compile` on every boot and rebuild, so the
notice never prints there. `os build --json` is unchanged: no new key.
**The starter's docs.** The generated `AGENTS.md` gains "Change the app
in `src/` — a Studio change stays in its database", and the blank
README's "Deploy" section gains "A Studio change is not in the image".
Both say:
- Studio saves into that environment's database, as an item of
`PACKAGE_ID.custom`, never into `src/`, so `build` and the `Dockerfile`
leave it behind.
- App changes are made in `src/`, never through Studio or the metadata
API of a running server. A change a person tried in Studio is made again
in `src/` when it belongs to the app. No write-back is built, as the
card asked.
- A customization that should stay one moves as a package: `os login`
and then `os package export` against the dev server, commit
`objectstack-export/`, then `os package install … --runtime URL` on the
deployment, in the numbered order.
## Tests
- `packages/cli/src/utils/local-customizations.test.ts` (unit tier): the
`.env` layering (process wins, nothing loaded), which URLs name a local
file, `not_applicable` for a remote, unbooted or refused database, the
notice text for found / unknown / none, and that `Build` turns the
notice on while `Compile` keeps it off.
- `packages/cli/src/utils/local-customizations.sqlite.test.ts`
(integration tier, because it imports `better-sqlite3` to write its
fixture): counts per `.custom` package and nothing else (a non-pair
package, a package-less row, `com.custom.tools` and
`com.example.customs` are not counted), `none` for no pair rows or no
table, the file is byte-identical after the read, `unknown` for a file
that is not a database, and `OS_DATABASE_URL` is followed.
-
`packages/create-objectstack/src/studio-customization-disclosure.test.ts`:
both docs carry the section and say `.custom`, database, `src/`,
`Dockerfile`, `os package export`, `os package install`; AGENTS.md tells
the agent to make app changes in `src/`.
<details><summary>Local runs on 0baf7e9</summary>
Head `0baf7e9a4` (after merging `origin/main` once, rebuilding the
workspace, `pnpm --filter @objectstack/spec check:generated` exit 0).
- `pnpm --filter @objectstack/cli typecheck` exit 0; `pnpm --filter
create-objectstack typecheck` exit 0.
- `pnpm --filter @objectstack/cli exec vitest run --project unit`:
385/385 files, 5435/5435 tests.
- `pnpm --filter @objectstack/cli exec vitest run
src/utils/local-customizations.sqlite.test.ts` (integration tier): 5/5.
The rest of the CLI integration tier is declared to CI.
- `pnpm --filter create-objectstack test`: 24/24 files, 369/369 tests.
- `node scripts/pm/dispatch-gates.mjs --commands`: 62 families, each run
with its exit code captured before any pipe, all exit 0; `--ran`: 62
derived, 62 run, 0 NOT-MEASURED, 0 UNRUN.
- `pnpm lint` exit 0.
- `fd70306c1` changes the changeset's `Clause-②` line only (the seat's
ruling: the exported `CompileCommand` gains a protected member). Re-run
on it: `check-adr-0087-registration`, `check-changeset-no-major`,
`check-empty-changeset`, `check:changeset-gate-self-tests`, all exit 0.
- The first unit run caught `test/validate-build-gate-parity.test.ts`
red: the closed roster of names `compile.ts` calls did not classify the
two new calls. They are now a `NOT_A_GATE` row with its reason (an
advisory about the dev database, judges no metadata, refuses nothing).
</details>
## Acceptance notes
- **Re-measured on current `main` (959c26b), app-todo, real `os dev`:**
`POST /packages/com.example.todo/ensure-customization` then `PUT
/meta/view/todo_task.default?package=com.example.todo.custom` with
`overrides: { package: 'com.example.todo', basedOn: '2.0.0' }` is served
(label changed). The row is in `sys_metadata` with `package_id =
com.example.todo.custom`, `state = active`. `src/`: 0 hits for the
change; `os build` artifact: 0; `os package export`: 1, in
`01-com.example.todo.custom/objectstack.json`. The card's premise holds.
- **The notice, measured on this branch:** `os build` on that project
printed `⚠ This build does not carry 1 Studio customization stored in
your dev database: com.example.todo.custom (1).` and the two lines under
it, both with `os dev` running (WAL, read-only open alongside the live
server) and after it stopped. `os dev`'s own boot compile printed
nothing new.
- **Scope of the read:** only a local SQLite dev database is probed. A
developer whose dev database is Postgres gets the docs, not the build
notice: reading it would be a network round trip, which the dispatch
ruled out.
- **What counts:** stored `.custom` items, all states. An ensured pair
with no item has no row and nothing to lose, so it is not counted. A
package authored wholly in Studio (not a pair) is not counted either;
`os package export` carries it, and the docs' "every package the
database holds that `src/` does not register" covers it.
- **ui residue (out of scope, ui lane paused):** the card's first
Expected bullet, Studio saying where a customization is saved and how it
moves. No `ui/**` edit here.
## Verification
1. `cd examples/app-todo && os dev`, sign in, `POST
/api/v1/packages/com.example.todo/ensure-customization`, then save any
view override into `com.example.todo.custom`.
2. `os build` in the same directory: the last block names
`com.example.todo.custom (1)`, the database file, and `os package
export`.
3. `os compile` (or `os build --json`): no such block.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CbrroXG7sXSzmQs4uj)_
<!-- signed: domain:server#4 · os-bill ·
session_01Utp6CZMkHvuDeVYgTD73qF -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ff3f83b commit 1c53783
10 files changed
Lines changed: 549 additions & 0 deletions
File tree
- .changeset
- packages
- cli
- src
- commands
- utils
- test
- create-objectstack/src
- templates
- blank
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
| |||
1447 | 1455 | | |
1448 | 1456 | | |
1449 | 1457 | | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
1450 | 1474 | | |
1451 | 1475 | | |
1452 | 1476 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
0 commit comments