diff --git a/.changeset/34770-project-skill-router.md b/.changeset/34770-project-skill-router.md new file mode 100644 index 00000000000..08a5b7f4d41 --- /dev/null +++ b/.changeset/34770-project-skill-router.md @@ -0,0 +1,22 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): the objectstack-project entry file becomes a router + +Clause-②: no +Metadata-protocol: none + +`skills/objectstack-project/SKILL.md` goes from 12.0 KB to 9.0 KB (214 lines to 184). It keeps its numbered sections under the same headings: the three questions asked before any work (app or platform, own use or product, does the platform ship it), what is written at each stage, the four checks with what each platform command covers and one `bootStack` test, the platform-gap rules, the customer changeset and release rules, the bump steps with the backfill rules, and the list of which skill teaches which kind of change. No rule's teaching changes. This skill has no hand-written reference file (its one reference, the platform catalog, is generated), so no text moved: what left the entry was cut, and this entry says what now answers it. + +**What the entry keeps.** Every ⛔ of the old entry: an own-use app is not asked for a requirement record, a design note or a changeset; `os verify` is not one of the four checks and not in the scaffold's CI; a check the platform makes is not hand-written; a platform defect is never worked around in the app; a new rule that reports existing metadata is never silenced. Beside them, the facts that pass every check and go wrong later: only errors fail `validate` and `lint`, so a warning (label case, an unresolved navigation target) passes without `--strict`; `--rls` proves consistency, not what the business intends; a Studio change stays in that environment's database and never ships; a blocked issue unblocks when the fix is in an installable version, not when the upstream change merges; `manifest.version` is set by hand because `os package publish` ships that one; the skills are re-synced with `--copy` after a bump; removing a field puts its values out of reach once the new metadata is installed, so the backfill runs first, on the old release. One sentence is new: where the installed `@objectstack/cli` differs from the `compatibility` line, the installed command is right. + +**What left, and what answers it now.** + +- The per-command check lists, now behind https://objectstack.ai/docs/deployment/cli. `os validate` keeps its rule families in one sentence; the kinds of reference it resolves, dataset members, package docs and the capability-provider check are on that page. `os lint` keeps "naming, label and translation-coverage style"; `--i18n-strict` is there too, and its rule on hook bodies that stop lowering is no longer listed (the rule reports itself when it fires). `os verify` keeps the round-trip and `--rls`; its other opt-in proofs and the advisory reading of `os validate`'s capability findings are there too. The `pnpm typecheck` row said only what the command's name says. +- The rest of the `bootStack` handle: that `flows.run` needs `{ automation: true }` unless the app requires `automation` is in the README that `@objectstack/verify` ships, which the entry names. The entry now says which call tests which kind of fact (`stack.hooks.run`, `stack.flows.run`, `stack.actions.run`, `stack.rows`), and keeps inline that `stack.rows` reads as a user only when the call passes `as`: without it the read is the system's, past sharing and row-level security. A plugin's `LiteKernel` tests are no longer named; the routing list sends a plugin's tests to objectstack-platform. The pointer to the scaffold's starter test is cut (the old entry called it `note.test.ts`; the template's file is `starter.test.ts`). +- Which schema changes apply on boot and which take `renamedFrom` or `os migrate`: objectstack-data `rules/field-types.md` § Changing a field that has data, which the entry names with the two commands and `--allow-destructive` for a drop. +- Restated inside the entry, so cut once: the stage rows that only named a later section (Test, Release, Upgrade); the sentence that the release note names the backfill script (the breaking-change bullet orders the administrator's steps, a backfill first); what each item of the bump's sweep step does (§3, §2 and the catalog question say it); the opening sentence that the domain skills teach the metadata, and the objectstack-upgrade row of the routing list (the frontmatter description and bump step 2 say both); that package docs are objectstack-ui's (its routing row says so); that `os package publish` is taught by objectstack-platform (its routing row lists the CLI and deployment); "no issue numbers, no internal names" in a customer changeset (the same bullet says it is written for the customer's administrator, in their words). The objectstack-ask and objectui rows are cut too: answering a question from the app's records and rendering the metadata in React are not changes to the metadata project, and each of those skills is still found by its own description. +- Cut with no other home. Each is a convention, an example or a reason, and none passes a check and fails later: the requirement-file template (`# REQ-NNNN`, asked by, their words, a user can, out of scope, status) and that it is created the first time one is needed; "the locale or device when it matters" in the acceptance line; that a product's design note "always answers" installed data and upgrade steps (the two are starred items of the design list, and the breaking-change and backfill rules require both); "if a stale bot runs, exempt that label"; "an older scaffold may lack the `pnpm test` step" (the entry says to run the four in CI); that `npx os explain` lists only the rules that carry an explanation; that `os verify` can also run as a CI step (the entry says to run it before a release); the changesets set-up command; that a Studio change's rule is in the project's `AGENTS.md`; the examples of a breaking change (a field, object, view, permission or behaviour), of a consistency question (labels are translated), of a hand-written check ("every reference resolves") and of a business judgement (how a case is routed); the qualifier "and the app pays for it" on a platform gap; "a workaround outlives the fix"; that a REST-only backfill "works on any installed metadata". + +**Anchors.** No section anchor left `SKILL.md`: the title and every section heading are unchanged. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 16a3b73ca8e..8cf082bdea8 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -2916,7 +2916,28 @@ export const CEILINGS = new Map([ // pinned AT the measurement. Raise path: the standing ruling (2026-10-27, // verbatim and untranslated) 「A:先削重复,余额按实测提高」, recognised per // ruling record 6513306068. - ['skills/objectstack-project/SKILL.md', 2990], + // 2990 -> 2244 (#34770): the entry becomes a router. It keeps the three questions asked + // before any work (app or platform, own use or product, does the platform ship it), what is + // written at each stage, the four checks with what each platform command covers, one + // `bootStack` test, the platform-gap rules, the customer changeset and release rules, the + // bump steps, the backfill rules and the list of which skill teaches which kind of change. + // This skill has no hand-authored reference file (its one reference, the platform catalog, + // is generator-owned), so nothing MOVED: the rest is CUT. Behind a pointer: the per-command + // check lists (the published CLI page), the rest of the + // `bootStack` handle (the README `@objectstack/verify` ships), the schema-change table + // (objectstack-data `rules/field-types.md`). Restated inside the entry or by its own + // frontmatter: the stage-table rows that only named a later section, the sweep step's + // parentheticals, the objectstack-upgrade routing row. With no other home, each a convention, + // an example or a rationale and none a trap: the requirement-file template, the stale-bot + // note, the changesets set-up command, the `os explain` caveat; and the two routing rows for + // work outside the metadata project (objectstack-ask, objectui), which each skill's own + // description still routes. No row rises and no row is added. The file is + // 11987 bytes (11960 priced) -> 9000 (8973 priced) -> 2244 tokens, pinned AT the + // measurement; the sum of all ceilings falls by the same 746. + // Authority: the ruling of record that orders the entry file down to router size, decision + // record #34691 S3 = A. + // ceil(($(wc -c < skills/objectstack-project/SKILL.md) - 27) / 4) == ceil(8973 / 4) + ['skills/objectstack-project/SKILL.md', 2244], ]); /** diff --git a/skills/objectstack-project/SKILL.md b/skills/objectstack-project/SKILL.md index d07d33a9897..74c04d0efe1 100644 --- a/skills/objectstack-project/SKILL.md +++ b/skills/objectstack-project/SKILL.md @@ -20,23 +20,24 @@ metadata: # Running an ObjectStack metadata-app project -The domain skills teach how to write metadata. This one teaches how a change -moves through the project. +Where the installed `@objectstack/cli` differs from the `compatibility` line, +the installed command is right. ## 0 · Three questions before any work **1. App or platform?** Could someone who has only the metadata, and knows nothing of this business, have written the change? -| Answer | Where it goes | -|:--|:--| -| No: it encodes this business's judgement (a discount ceiling, who approves what, how a case is routed) | the app | -| Yes: it only asks whether the metadata is consistent (references resolve, labels are translated, a write round-trips) | the platform: check the table in §2 before writing anything | -| Platform behaviour is missing or wrong, and the app pays for it | the platform, and a **gap** until it ships (§3) | +- No, it encodes this business's judgement (a discount ceiling, who approves + what): the app. +- Yes, it only asks whether the metadata is consistent (references resolve, a + write round-trips): the platform; read §2 first. +- Platform behaviour is missing or wrong: a platform **gap** until it ships + (§3). -**2. Own use or product?** Ask the owner once: is the app used by its own team, -or installed and upgraded by customers? Record the answer as one line in the -project's `AGENTS.md` (`Project kind: own use` or `Project kind: product`). +**2. Own use or product?** Ask the owner once whether the app is used by its +own team or installed and upgraded by customers, and record it as one line in +the project's `AGENTS.md`: `Project kind: own use` or `Project kind: product`. Steps marked ★ apply only to a product. Default to own use, and keep it light: a one-person app changing a label needs @@ -47,168 +48,137 @@ record, a design note or a changeset. read [the platform catalog](./references/platform-catalog.md); use what it lists. Absent, and a second app would copy it: file a platform card at `objectstack-ai/objectstack`, and build the app's own meanwhile, marked -`// PLATFORM-CANDIDATE: `. Not §3: a defect is never worked around; a -missing capability may be built and marked. +`// PLATFORM-CANDIDATE: `. A defect is different: never worked around (§3). Building through MCP with no repository: only §0 and §3 apply. ## 1 · What to write at each stage -| Stage | Own use | ★ Product adds | -|:--|:--|:--| -| Requirement | Feature: who asked, their words, one acceptance sentence ("A user can …"), on the issue. Bug: steps, expected, actual. | A file in `docs/requirements/` for a feature customers will see (template below) | -| Design | On the issue. A short note only when the change spans two packages or adds an object; it covers the checklist below | The note always answers "installed data" and "upgrade steps" | -| Issue | One issue, one PR | | -| Build | Change `src/` only. A Studio change stays in that environment's database and never ships (the project's `AGENTS.md`) | | -| Test | §2 | | -| Acceptance | The PR says which path was walked and as which user; the locale or device when it matters | | -| User docs | The same PR updates the docs a user reads (package docs: objectstack-ui) | | -| Release | | A changeset written for the customer (§4) | -| Upgrade | §5 | The release note lists the customer's steps | - -Design checklist: objects and fields touched · who may read and edit them · -which automation fires · which screens change · translations · -★ what happens to data already installed · ★ the steps an upgrading customer takes. - -★ Requirement template, created the first time one is needed: -```markdown -# REQ-NNNN
" -- A user can:-- Out of scope: -- Status: proposed | accepted | shipped in -``` +- **Requirement**, on the issue. Feature: who asked, their words, one + acceptance sentence ("A user can …"). Bug: steps, expected, actual. ★ A + feature customers will see also gets a file in `docs/requirements/`. +- **Design**, on the issue; a short note only when the change spans two + packages or adds an object: objects and fields, access, automation, + screens, translations, ★ data already installed, ★ the customer's upgrade + steps. +- **Build**: one issue, one PR. Change `src/` only: a Studio change stays in + that environment's database and never ships. +- **Acceptance**: the PR says which path was walked and as which user, and + updates the docs a user reads. ## 2 · Testing: what the app pins, what the platform checks -The platform checks consistency. The app tests its own business facts. Run all -four before calling a change done; a scaffolded project's CI runs them (an -older scaffold may lack the `pnpm test` step: add it). Add vitest, the `test` -script and `@objectstack/verify` (for `bootStack`) where missing. -Only errors fail `validate` and `lint`; a warning, such as label case or an -unresolved navigation target, passes. `--strict` on either makes warnings fail: -use it instead of re-checking them in a test. +Run all four before calling a change done, and in CI: ```bash pnpm validate && pnpm lint && pnpm typecheck && pnpm test ``` -What the platform checks at 18.x: - -| Tool | Checks | -|:--|:--| -| `os validate` (the same rules `os build` runs) | Protocol schema; CEL expressions and their `record. ` paths; references between metadata (fields, objects, views, actions, picklists, capabilities, approvers); dashboard widget bindings and dataset members; view, form and page shape; flow trigger readiness and undeclared flow cycles; sharing and row-level security enforceability; seed rows against state machines; package docs; a provider for every required capability | -| `os lint` | The shared author-time rules again, plus its own: naming and label style, hook bodies that stop lowering to metadata-only bodies, and translation coverage (a missing non-source locale is an error only with `--i18n-strict`) | -| `os verify` | Boots the app and writes over REST: every field type round-trips. `--rls`: a user who cannot read a record cannot write it. Also opt-in: `--reference-shapes`, `--delete-behaviors`, `--unique-scopes`, `--parent-write-reach`, `--dashboard-windows`, `--multi-tenant`. `os validate`'s capability findings: advisory here (`--json`: `capabilities`) | -| `pnpm typecheck` | Types against `@objectstack/spec` | - -⛔ `os verify` is not one of the four and not in the scaffold's CI: run -`npx os verify --rls` before a release, or as a CI step. -`npx os explain` lists only the rules that carry an explanation, not every -check. - -What the app tests, with `bootStack` from `@objectstack/verify` on the real -engine (the scaffold's `note.test.ts` is the shape): the numbers in its rules, -who approves which amount, what a flow writes, what an action does, and who sees -which records **as this business intends** (`--rls` proves -consistency, not intent). +Only errors fail `validate` and `lint`: a warning (label case, an unresolved +navigation target) passes. `--strict` on either fails warnings; use it +instead of re-checking them in a test. + +What the platform checks (in full: https://objectstack.ai/docs/deployment/cli): + +- `os validate`, the rules `os build` runs: the protocol schema, CEL + expressions and their `record. ` paths, references between metadata, + widget bindings, view, form and page shape, and flows, sharing rules and + seed rows that cannot work as declared. +- `os lint`: the shared author-time rules again, plus naming, label and + translation-coverage style. +- `os verify` boots the app and writes over REST: every field type + round-trips, and with `--rls` a user who cannot read a record cannot write + it. ⛔ It is not one of the four, nor in the scaffold's CI: run + `npx os verify --rls` before a release. + +⛔ Do not hand-write one of those checks ("every view names real fields"). +Asked to write one, run the command that already checks it and show its output +instead. A consistency check the platform does **not** make is a gap (§3): +until the rule ships, the app may carry the test, marked +`// PLATFORM-GAP: `. When it lands, inject the same defect, confirm the +platform command fails on it, then replace the test with +`// RETIRED: , checked by os `. + +The app tests its own business facts, with `bootStack` from +`@objectstack/verify` on the real engine: the numbers in its rules +(`stack.hooks.run`: one real write as a user), who approves what and what a +flow or an action does (`stack.flows.run`, `stack.actions.run`), and who sees +which records **as this business intends** (`stack.rows` with `as`: without +it the read is the system's; `--rls` proves consistency, not intent). Add +vitest, a `test` script and `@objectstack/verify` if missing. ```ts -const stack = await bootStack(config); // the default export of objectstack.config.ts -const admin = await stack.signIn(); // the seeded admin; signUp(email) is a plain member +const stack = await bootStack(config); // objectstack.config.ts's default export +const admin = await stack.signIn(); // the seeded admin; signUp(email): a plain member await expect( stack.hooks.run('crm_quote', 'insert', { name: 'Q-1', discount: 0.35 }, { as: admin }), ).rejects.toMatchObject({ code: 'VALIDATION_FAILED' }); await stack.stop(); ``` -The handle also has `stack.flows.run` (boot with `{ automation: true }` unless -the app requires `automation`), `stack.actions.run`, `stack.seed` and -`stack.rows` (read as a user); the README in `node_modules/@objectstack/verify` -documents each. A plugin's own tests use `LiteKernel` (objectstack-platform). - -⛔ Do not hand-write a check the table lists, such as "every reference -resolves" or "every view names real fields". Asked to write one, run the -command that already checks it and show its output instead. - -A consistency check the table does **not** list is a platform gap (§3). Until it -ships, the app may carry the test, marked `// PLATFORM-GAP: `. When -the platform rule lands, retire it: inject the same defect, confirm the platform -command fails on it, then replace the test with a one-line -`// RETIRED: , checked by os lint` (or validate, or verify). +`stack.seed` and each option: the package's README. ## 3 · Platform gaps - ⛔ Never work around a platform defect in the app: no duplicate route, no hook that patches the engine's answer, no hand-rolled permission check, no - metadata reshaped to dodge a bug. A workaround outlives the fix. + metadata reshaped to dodge a bug. - File it at `objectstack-ai/objectstack`: the platform version, the smallest metadata that shows it, expected and actual. - Mark the app's issue blocked (a `blocked` label and a `Blocked by: ` - line) and keep its priority. If a stale bot runs, exempt that label. + line) and keep its priority. - It unblocks when the fix is in a version the app can install, not when the upstream PR merges: `npm view @objectstack/ version`, then its `CHANGELOG.md`. -- Relief for customers before the fix ships: the owner decides, on the issue. +- Customer relief before the fix ships: the owner decides, on the issue. ## 4 · ★ Describing a change for customers -- Set up changesets once (`pnpm add -D @changesets/cli && pnpm changeset init`); - every PR that changes what ships adds one (`pnpm changeset`). -- Write it for the customer's administrator: what they can do now, in their - words. No issue numbers, no internal names. -- A breaking change (a field, object, view, permission or behaviour removed, - renamed or changed in meaning) is `major` and states: FROM → TO, the minimum - `@objectstack/*` version, and the administrator's steps in order, a backfill - (§5) first. -- To release: `pnpm changeset version` writes `CHANGELOG.md`, the notes - customers read, and bumps `package.json`. Set `manifest.version` in - `objectstack.config.ts` to match by hand: `os package publish` ships that - one. Then `os build` and `os package publish` (objectstack-platform). +- Every PR that changes what ships adds a changeset (`pnpm changeset`), written + for the customer's administrator: what they can do now, in their words. +- A breaking change (anything removed, renamed or changed in meaning) is + `major` and states: FROM → TO, the minimum `@objectstack/*` version, and the + administrator's steps in order, a backfill (§5) first. +- To release: `pnpm changeset version` writes `CHANGELOG.md` and bumps + `package.json`. Set `manifest.version` in `objectstack.config.ts` to match + by hand: `os package publish` ships that one. Then `os build` and + `os package publish`. ## 5 · Bumping the platform, and customer data on upgrade Bump: 1. Move every `@objectstack/*` package to one version, `@objectstack/skills` included, then re-sync the skills and commit them: - `npx skills@1.7.2 experimental_sync --agent claude-code --copy -y` (name your - own runtime after `--agent`). + `npx skills@1.7.2 experimental_sync --agent claude-code --copy -y` + (`--agent`: your runtime). 2. Read each package's `CHANGELOG.md` between the versions for breaking entries. Crossing a protocol major: objectstack-upgrade. 3. Run the four checks. A new rule that reports existing metadata is fixed in the metadata, ⛔ never silenced. -4. Sweep the blocked issues (unblock each whose fix is now installed), the - `PLATFORM-GAP` tests (retire each one the platform now checks, §2) and the - `PLATFORM-CANDIDATE` markers (replace each the catalog now lists, §0). +4. Sweep the blocked issues (§3), the `PLATFORM-GAP` tests (§2) and the + `PLATFORM-CANDIDATE` markers (§0). Data already installed: -- Added objects, fields and indexes apply on boot. A rename carries - `renamedFrom`. A type change, a drop or a relaxed `NOT NULL` takes - `os migrate plan` then `os migrate apply` (`--allow-destructive` for a drop). - Detail: objectstack-data `rules/field-types.md` § Changing a field that has data. +- Schema changes (`renamedFrom`; `os migrate plan` then `os migrate apply`, + `--allow-destructive` for a drop): objectstack-data `rules/field-types.md` + § Changing a field that has data. - Removing a field or object, or changing what its value means, puts the old values out of reach once the new metadata is installed. Copy them first with a backfill script in `scripts/`: - run it on each deployment while still on the old release; - - REST API only, no import from `src/`, so it works on any installed metadata; - - report by default, write only with `--apply`; - - touch only rows that need it; a second run reports zero; + - REST API only, no import from `src/`; + - report by default, write only with `--apply`; touch only rows that need + it, so a second run reports zero; - sign in as an administrator named on the command line; the password or token comes from the environment or a prompt, never an argument. -- ★ The release note names the script and when to run it. ## 6 · Where each kind of change is taught -| Change | Skill | -|:--|:--| -| Objects, fields, validations, hooks, permissions, seed data | objectstack-data | -| Queries, filters, aggregation | objectstack-query | -| Views, apps, dashboards, reports, actions, pages, package docs | objectstack-ui | -| Flows, triggers, approvals, jobs, webhooks | objectstack-automation | -| Agents, tools, knowledge, the MCP server | objectstack-ai | -| CEL formulas and predicates | objectstack-formula | -| Translations | objectstack-i18n | -| REST endpoints, auth, realtime | objectstack-api | -| Project setup, plugins and their tests, the CLI, deployment | objectstack-platform | -| Crossing a protocol major | objectstack-upgrade | -| Answering a question from the app's records | objectstack-ask | -| Rendering the metadata in React | objectui | +- objectstack-data: objects, fields, validations, hooks, permissions, seed data +- objectstack-query: queries, filters, aggregation +- objectstack-ui: views, apps, dashboards, reports, actions, pages, package docs +- objectstack-automation: flows, triggers, approvals, jobs, webhooks +- objectstack-ai: agents, tools, knowledge, the MCP server +- objectstack-formula: CEL formulas and predicates +- objectstack-i18n: translations +- objectstack-api: REST endpoints, auth, realtime +- objectstack-platform: project setup, plugins and their tests, the CLI, deployment