diff --git a/.changeset/38926-upgrade-skill-18-to-19.md b/.changeset/38926-upgrade-skill-18-to-19.md new file mode 100644 index 00000000000..3a1375d87b0 --- /dev/null +++ b/.changeset/38926-upgrade-skill-18-to-19.md @@ -0,0 +1,27 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): the objectstack-upgrade skill replays from the project's own floor, shows the 18 → 19 run, and names the steps that run adds + +Clause-②: no +Metadata-protocol: none + +`skills/objectstack-upgrade/SKILL.md`: the quickstart and the floor-reading check show the current move. `--from` is still the floor of `manifest.engines.protocol`, never guessed from the installed spec; the worked example is now `'^18'` → `os migrate meta --from 18`, replayed with `os migrate meta --from 18 --to 19 --json` (`applied` `[]`, no `replayedNothing`), where it was `--from 16` and `--to 18`. A fourth quickstart step names what an 18 → 19 run also owes. Each line is safe to run and its comment names the write: `os build`, then `--update-access-matrix` only on "Access matrix drift", with the owner reviewing the matrix diff; and per deployment `os migrate plan` then `os migrate apply --yes`, `os migrate protocol --to 19` then `--apply --yes` before a 19 `os serve`, and `os migrate meta --stored` then `--stored --apply --yes`. The control (`os validate` on the un-upgraded source) is taken in preflight, before the pins move, because the target's CLI only refuses the old range. The acceptance step names the reverse check. The spec-changes harvest is one `cp` from `node_modules/@objectstack/spec/`. + +`references/examples-upgrade.md` gains "The 18 → 19 run, as it ships", and `SKILL.md`'s "Where to go" table names it. It holds the protocol handshake that refuses `'^18'` (`OS_PROTOCOL_INCOMPATIBLE`, from `os validate` and `os build` too after `19.0.0-next.3`), what `--write` writes on `19.0.0-next.3` (nothing in a scaffolded project, each edit listed `not written [helper]`, exit `0`) and after it (the edits that stand alone, `Wrote N of M mechanical change(s)`, exit `1` while an edit or the range is left), the access-matrix gate that `os build` and `os compile` run and `os validate` does not, `os migrate apply --yes` in a non-interactive shell, the `os migrate protocol --to 19` switch a 19 `os serve` waits for on an older database, and the stored pass with the 19 CLI. It also says what that pass never does: a stored permission set holding View All or Modify All and no `viewAllFields` is only listed, under `viewAllFieldsReview`, the pass still exits `0`, and its holders already read no field another set hides; the owner decides each entry, adding `viewAllFields: true` through the metadata API to keep the reads. It links the v19 release page for each step in full. + +Two sentences of that file were no longer true and are corrected. `--write` no longer restores every file whenever its re-run disagrees: after `19.0.0-next.3` it keeps the edits that stand alone, and restores every file only for a disagreement it cannot tie to one edit. And the build does ship a migration-chain-only conversion: protocol 19's `permission-view-all-fields-beside-record-bypass`, where View All with no `viewAllFields` still parses and no longer reads every field. The R2 search uses `--from 18`, the branch is `upgrade/protocol-19`, and the report template's range is ` → `. "Arriving several majors late" keeps `--from 16`: its subject is the multi-major replay, and 16 is the chain's support floor. + +`skills/objectstack-data/rules/indexing.md`: the note on the retired `type` and `partial` says `os migrate meta --from N`, N the floor of `engines.protocol`, where it said `--from 16`. + +The eval cases move with the text. Case 1 is a `'^18'` project moving to 19, and also expects `--update-access-matrix`, `--stored` and `os migrate protocol --to 19`; case 4 is an 18 → 19 bump whose expected answer names the protocol-19 default flip, and it also expects `viewAllFields`. + +No token ceiling moves: each file's additions are paid by deleting restatement in the same file. What left, and what answers it now: + +- `SKILL.md`, trap 7 (prove the parse gate once, with a plain data literal, no `define*` call): `references/examples-upgrade.md` 3.5. The quickstart's acceptance step and the "Where to go" row both tell the reader to run that reverse check. Trap 2 no longer repeats the replay command and its criterion: the quickstart's step 3 holds both. First check 4 no longer names the lock entry's `sourceType: github`: the reference's "Re-install the skills" section says which entries the sync skips. +- `references/examples-upgrade.md`, 2.4: the "One target", "Two or more real targets" and "Observable without a test failing" bullets, "How to ask" and "While you wait, do not stall the upgrade" restated `SKILL.md`'s "Decide alone, or ask", which keeps each rule. +- 2.5, "the fix is never a tolerant read of the old one": `SKILL.md`'s boundary. 2.6, why the AI conventions file matters most: trap 6. 2.1, "measure each number again in the report": first check 3. +- Failure modes, the row "`validate` green, but a feature silently stopped working": trap 5 holds the cause and the search; the row's "exercise the path for real" is cut. +- 3.6, "valid only on the release you are leaving": trap 3 says a release that dropped the conversions answers 0 whatever the row holds. +- Shortened with no rule lost: the data-migration paragraph, 2.1's opening and two of its table cells, 2.3's two asides, 2.5's opening, 3.1, 3.4's opening, 3.6's opening, the list of `.upgrade/` file names, the note on `objectstack-pm-dispatch` in the skills re-install, and the sentence that listed `os migrate meta --help`. diff --git a/skills/objectstack-data/rules/indexing.md b/skills/objectstack-data/rules/indexing.md index 9b9c8d56951..577230f21c5 100644 --- a/skills/objectstack-data/rules/indexing.md +++ b/skills/objectstack-data/rules/indexing.md @@ -28,9 +28,9 @@ and it is the whole surface *because* it is all the driver materializes: > selected no access method, and an authored `partial` produced a **full** > index with the predicate silently discarded. Writing either is now a `tsc` > error and a parse error carrying the migration prescription; run -> `os migrate meta --from 16` to list the mechanical edits; `--write` applies -> the ones it can prove, and you apply the rest by hand. What to do instead is -> the subject of "Access methods and partial indexes" below. +> `os migrate meta --from N`, N the floor of `engines.protocol`, to list the +> edits; `--write` applies the ones it can prove, and you apply the rest by +> hand. Instead, see "Access methods and partial indexes" below. ## Syntax diff --git a/skills/objectstack-upgrade/SKILL.md b/skills/objectstack-upgrade/SKILL.md index 12ed4b41fd6..1e30b7ad402 100644 --- a/skills/objectstack-upgrade/SKILL.md +++ b/skills/objectstack-upgrade/SKILL.md @@ -48,41 +48,47 @@ metadata: 1. **`--from` is the major the metadata was authored against, not the one installed.** Read `manifest.engines.protocol`, a range, and take its floor: - `'^17'` → `--from 17`, `'>=15 <18'` → `--from 15`, never the upper bound. + `'^18'` → `--from 18`, `'>=16 <19'` → `--from 16`, never the upper bound. Else read the lockfile's history. If the two disagree, ask — ⛔ never default to the lower one. 2. **Keep a control**: `os validate` on the un-upgraded source, in - `.upgrade/`. A rule finding already in it is pre-existing, not upgrade residue. + `.upgrade/`, taken before the pins move. A rule finding already in it is + pre-existing, not upgrade residue. 3. **Read the prescriptions from the install, never from memory**: the chain's `--json` result, and the `spec-changes.json`, tombstone `[REMOVED] …` text and `CHANGELOG.md` inside `@objectstack/spec`. ⛔ Every count you report is a reading of *this* install. -4. **Re-install the skills.** A lock entry reading `sourceType: github` (from - `skills add`) is skipped by the sync, exit 0, and the agent keeps reading the - old major's skill text. +4. **Re-install the skills**: the sync skips a `skills add` install, exit 0, + and the agent keeps the old major's skill text. ## Quickstart ```bash -# 0 · preflight — the authored major, the installed one +# 0 · preflight — the authored major (the floor: '^18' → 18), the control grep -rn "protocol" objectstack.config.ts package.json | head -node -p "require('@objectstack/spec/package.json').version" - -# 1 · mechanical — replay the chain (trap 1) mkdir -p .upgrade -os validate > .upgrade/validate-before.txt 2>&1 || true # the control, kept -os migrate meta --from 16 --step -os migrate meta --from 16 --json > .upgrade/migrate.json -os migrate meta --from 16 --out .upgrade/migrated.stack.json +os validate > .upgrade/validate-before.txt 2>&1 || true # before the pins move + +# 1 · mechanical — the pins moved; replay from your floor (trap 1); 18 → 19 shown +node -p "require('@objectstack/spec/package.json').version" +os migrate meta --from 18 --step +os migrate meta --from 18 --json > .upgrade/migrate.json +os migrate meta --from 18 --out .upgrade/migrated.stack.json # 2 · semantic residue — harvest the prescriptions, then work each item -node -e "console.log(require('fs').readFileSync(require.resolve('@objectstack/spec/package.json').replace('package.json','spec-changes.json'),'utf8'))" > .upgrade/spec-changes.json +cp node_modules/@objectstack/spec/spec-changes.json .upgrade/ -# 3 · acceptance — all four, not three +# 3 · acceptance — all four, then the reverse check (reference 3.5) os validate # green (compare against validate-before.txt) tsc --noEmit # tombstones type the retired keys as `never` -os migrate meta --from 16 --to 18 --json # `applied` [] and no `replayedNothing` (trap 2) +os migrate meta --from 18 --to 19 --json # `applied` [] and no `replayedNothing` (trap 2) # → write .upgrade/REPORT.md (template: §3.4) + +# 4 · 18 → 19 also owes (the last three per deployment) +os build # on "Access matrix drift": --update-access-matrix; the owner reviews the diff +os migrate plan # then os migrate apply --yes +os migrate protocol --to 19 # before a 19 `os serve`; then --apply --yes +os migrate meta --stored # then --stored --apply --yes ``` ## Traps @@ -90,15 +96,12 @@ os migrate meta --from 16 --to 18 --json # `applied` [] and no `replayedNothing 1. **By default `os migrate meta` rewrites no source file.** It prints each edit as `path: from → to (conversionId)` and writes only `--out`. `--write` rewrites an edit it can trace to one literal in one project file, lists every - other with the reason, and never writes a semantic change. Port the printed - edits by hand, or pass `--write` and port those it only lists; then replay - (trap 2). + other with the reason, and never writes a semantic change. Port by hand + the edits it prints, or only lists; then replay (trap 2). 2. **A green `validate` does not mean the chain has nothing left.** A migration-chain-only conversion (a default flip) has no tombstone, so the old - shape validates. Replay the range you ported, - `os migrate meta --from --to --json`: - `applied` must be `[]` and `replayedNothing` absent. `--from ` - names an empty range and proves nothing. + shape validates. Replay the range you ported (Quickstart, step 3). + `--from ` names an empty range and proves nothing. 3. **Stored `sys_metadata` rows are rewritten only at read**, by `applyConversionsToStoredItem`, and only while the installed release carries their conversions: 18.3 drops those retired at or below 16.x. ⛔ Before you @@ -111,15 +114,12 @@ os migrate meta --from 16 --to 18 --json # `applied` [] and no `replayedNothing per-deployment gate; nothing in the upgrade observes whether it ran. ⛔ Carry every gate it printed into the report as `pending`, by name. 5. **R2, code on a retired API, can keep compiling while it reads `undefined`.** - Grep the project's source for each `todos[].surface` of the `--json` result, - and read the entry's `reason` before its `replacement`: if the old read was - wrong, a rename migrates the defect. + Grep the project for each `--json` `todos[].surface`, and read the entry's + `reason` before its `replacement`: if the old read was wrong, a rename + migrates the defect. 6. **R3, prose that still teaches the old shape, fails nothing**: the next agent re-authors it from a README, a comment, a seed fixture or the AI conventions file. Sweep the whole repo last. -7. **Prove the parse gate once, with a plain data literal** — ⛔ no `define*` - call, which throws inside the load and never reaches the gate. A retired key - that still parses is stripped or in a load-path window: find which. ## Decide alone, or ask @@ -147,8 +147,9 @@ report as `AWAITING DECISION` and keep the mechanical layer moving. |:--|:--| | [0 · Preflight](./references/examples-upgrade.md#0--preflight) | the FROM major's sources, `.upgrade/`, the skills re-install | | [1 · Mechanical layer](./references/examples-upgrade.md#1--mechanical-layer) | what a run does and prints, stored rows, data gates | +| [The 18 → 19 run](./references/examples-upgrade.md#the-18--19-run-as-it-ships) | each step this crossing adds, as it ships | | [2 · Semantic residue](./references/examples-upgrade.md#2--semantic-residue) | where the prescriptions ship, a worked R1 (`transform`), the R2 and R3 searches | -| [3 · Acceptance](./references/examples-upgrade.md#3--acceptance) | the four artifacts, the `REPORT.md` template, the reverse check's outcomes | +| [3 · Acceptance](./references/examples-upgrade.md#3--acceptance) | the four artifacts, the `REPORT.md` template; run the reverse check (3.5) | | [Failure modes](./references/examples-upgrade.md#failure-modes) | symptom → cause → fix, the `--json` error codes | | [The v17-canonical shapes](./references/examples-upgrade.md#the-v17-canonical-shapes-compiled) | the examples after the upgrade, type-checked | diff --git a/skills/objectstack-upgrade/evals/protocol-major-upgrade.json b/skills/objectstack-upgrade/evals/protocol-major-upgrade.json index 3d5788f3c5f..edc39d8911c 100644 --- a/skills/objectstack-upgrade/evals/protocol-major-upgrade.json +++ b/skills/objectstack-upgrade/evals/protocol-major-upgrade.json @@ -3,12 +3,12 @@ "evals": [ { "id": 1, - "prompt": "把这个项目升级到 v17。objectstack.config.ts 的 manifest 里写着 engines: { protocol: '^16' }。当前目录里没有这个项目的文件:请直接给出你要运行的命令、每一步要检查什么,以及最后交付什么。", - "expected_output": "Preflight: `--from 16` read off `manifest.engines.protocol` (the floor of the range, never guessed from the installed spec); keep `os validate > .upgrade/validate-before.txt` as the control. Mechanical: `os migrate meta --from 16 --step`, `--json`, and `--out .upgrade/migrated.stack.json` — the command rewrites nothing on disk, so port the printed `path: from → to (conversionId)` edits into the sources, one `conversionId` per commit, then replay the ported hop, `os migrate meta --from 16 --to 17 --json`, until `applied` is `[]` with no `replayedNothing` (`--from 17` names an empty range and checks nothing). Acceptance: `os validate` green, `tsc --noEmit` green, and `.upgrade/REPORT.md` with the mechanical table, decided residue, open decisions and pending per-deployment gates.", + "prompt": "把这个项目升级到 v19。objectstack.config.ts 的 manifest 里写着 engines: { protocol: '^18' }。当前目录里没有这个项目的文件:请直接给出你要运行的命令、每一步要检查什么,以及最后交付什么。", + "expected_output": "Preflight: `--from 18` read off `manifest.engines.protocol` (the floor of the range, never guessed from the installed spec); keep `os validate > .upgrade/validate-before.txt` as the control, taken before the pins move (a 19 CLI only refuses a `'^18'` range). Mechanical: `os migrate meta --from 18 --step`, `--json`, and `--out .upgrade/migrated.stack.json` — by default the command rewrites nothing on disk, so port the printed `path: from → to (conversionId)` edits into the sources, one `conversionId` per commit (`--write` writes the ones it can trace and lists the rest), then replay the ported hop, `os migrate meta --from 18 --to 19 --json`, until `applied` is `[]` with no `replayedNothing` (`--from 19` names an empty range and checks nothing). Acceptance: `os validate` green, `tsc --noEmit` green, the reverse check once, and `.upgrade/REPORT.md` with the mechanical table, decided residue, open decisions and pending per-deployment gates. The 19 crossing also owes: `os build --update-access-matrix` only when `os build` stops on \"Access matrix drift\", with the owner reviewing the matrix diff, and per deployment `os migrate apply --yes` after `os migrate plan`, `os migrate protocol --to 19` (a preview, then `--apply --yes`) before a 19 `os serve`, then `os migrate meta --stored` (a dry run) and `os migrate meta --stored --apply --yes`.", "files": [], "assertions": { - "must_contain": ["os migrate meta --from 16", "--out", "tsc --noEmit", "REPORT.md", "applied"], - "must_not_contain": ["sed -i", "--from 17 --apply"] + "must_contain": ["os migrate meta --from 18", "--out", "tsc --noEmit", "REPORT.md", "applied", "--update-access-matrix", "--stored", "os migrate protocol --to 19"], + "must_not_contain": ["sed -i", "--from 19 --apply"] } }, { @@ -33,12 +33,12 @@ }, { "id": 4, - "prompt": "We bumped @objectstack/spec 16 → 17 and `os validate` is green, so there was nothing to upgrade, right? Production also has `sys_metadata` rows written under 16.", - "expected_output": "No: `validate` green is necessary, not sufficient — migration-chain-only conversions reject nothing at parse (this build ships none, but the chain, not the parse, is the authority). Replays the ported hop, `os migrate meta --from 16 --to 17 --json`, and reads `applied` (must be `[]`) with `replayedNothing` absent — `--from 17` alone names an empty range, so its `applied: []` proves nothing. Stored rows rehydrate through `applyConversionsToStoredItem` only while the installed release carries their conversions (18.3 drops those retired at or below 16.x), so before moving past 18.2 it runs `os migrate meta --stored` (read-only) then `os migrate meta --stored --apply --yes` (`--yes` is mandatory in a non-TTY), and never hand-edits `sys_metadata`. Any per-deployment data-migration gates the run prints go into the report as pending, by name.", + "prompt": "We bumped @objectstack/spec 18 → 19, moved `engines.protocol` to '^19', and `os validate` is green, so there was nothing to upgrade, right? Production also has `sys_metadata` rows written under 18.", + "expected_output": "No: `validate` green is necessary, not sufficient — a migration-chain-only conversion rejects nothing at parse, and protocol 19 ships one (View All or Modify All with no `viewAllFields` still parses and no longer reads every field), so the chain, not the parse, is the authority. Replays the ported hop, `os migrate meta --from 18 --to 19 --json`, and reads `applied` (must be `[]`) with `replayedNothing` absent — `--from 19` alone names an empty range, so its `applied: []` proves nothing. Stored rows are not the sources: they rehydrate through `applyConversionsToStoredItem` at read, only while the installed release carries their conversions, so per deployment it runs `os migrate meta --stored` (read-only) with the 19 CLI, then `os migrate meta --stored --apply --yes` (`--yes` is mandatory in a non-TTY), and never hand-edits `sys_metadata`. That pass does not rewrite a stored permission set: it only lists, under `viewAllFieldsReview`, an entry with View All or Modify All and no `viewAllFields`, and still exits 0, while its holders already read fewer fields on 19; the owner decides each entry, adding `viewAllFields: true` through the metadata API to keep the reads. Any per-deployment data-migration gates the run prints go into the report as pending, by name.", "files": [], "assertions": { "must_contain": ["applied", "replayedNothing", "--stored", "--yes"], - "must_contain_any": [["applyConversionsToStoredItem", "at read", "18.3"]], + "must_contain_any": [["applyConversionsToStoredItem", "at read", "18.3"], ["viewAllFields"]], "must_not_contain": ["UPDATE sys_metadata"] } }, diff --git a/skills/objectstack-upgrade/references/examples-upgrade.md b/skills/objectstack-upgrade/references/examples-upgrade.md index f440442943a..039de17d6d1 100644 --- a/skills/objectstack-upgrade/references/examples-upgrade.md +++ b/skills/objectstack-upgrade/references/examples-upgrade.md @@ -27,21 +27,19 @@ down to the chain's support floor, 16 today. ### Make the work reviewable before you change anything ```bash -git checkout -b upgrade/protocol-17 +git checkout -b upgrade/protocol-19 mkdir -p .upgrade ``` The `.upgrade/` directory is the deliverable's workspace: the machine outputs -(`migrate.json`, `migrated.stack.json`, `spec-changes.json`, `retired-names.txt`) -and the human output (`REPORT.md`). Keeping them in the repo for the review, and -deleting them on merge, is the usual arrangement — decide it with the owner. +and the human output (`REPORT.md`). Keeping them in the repo for the review and +deleting them on merge is usual; decide it with the owner. ### Re-install the skills from the moved catalog A 17.x project's skills came from `skills add`; their `skills-lock.json` entries are the ones the sync skips. Remove them (a missing name is -skipped; `objectstack-pm-dispatch` is not in the 18 catalog, only an older -install has it), add `@objectstack/skills` at the installed spec's version with +skipped), add `@objectstack/skills` at the installed spec's version with the manager that installed the project, copy it: ```bash @@ -57,24 +55,55 @@ npx skills@1.7.2 experimental_sync --agent claude-code --copy -y ### What `os migrate meta` actually does -`os migrate meta --help` lists every flag and form; the Quickstart shows the -ones a run needs. - It loads the stack config, normalizes it **without** applying the load-time conversion pass, replays each major's conversions as a chain hop, and then parses the result against the current schema to prove the output is valid. What it prints: -- **`Applied N mechanical change(s)`** — one line per rewritten site. This is - the diff, already attributed. +- **`Applied N mechanical change(s)`** — one line per rewritten site. - **`N manual change(s) require your judgment`** — the chain's semantic entries - for the majors you crossed, each with a `why` and a `verify` line. These are - Layer 2's input, not a warning to dismiss. + for the majors you crossed, each with a `why` and a `verify` line: Layer + 2's input. - **`Migrated stack is schema-valid`** — or the warning that it is not yet, which means a residue item is still blocking the parse. -`--write` checks itself: if re-running the chain over the written files -disagrees, it restores every file and exits 1. +### The 18 → 19 run, as it ships + +"After `next.3`" is the cut that follows `19.0.0-next.3`. In full: +[Coming from 18.x](https://objectstack.ai/docs/releases/v19#coming-from-18x). + +- **The handshake.** A 19 runtime refuses `engines: { protocol: '^18' }` before + it loads anything, `OS_PROTOCOL_INCOMPATIBLE`. After `next.3`, `os validate` + and `os build` refuse it too, so a control taken with the 19 CLI is that one + refusal: take it with the 18 CLI, before the pins move. Move the range with + the pins (an 18.x runtime refuses `'^19'`): `--write` rewrites a root + `defineStack` manifest's; in a `composeStacks` project, change each package + manifest by hand. +- **`--write`.** On `19.0.0-next.3` it does not follow the `exportsOf(…)` call + a `create-objectstack` project wires its collections through: it writes none + of that project's edits, lists each `not written [helper]`, and exits `0`. + After `next.3` it follows that wiring, keeps each edit that stands on its + own, says `Wrote N of M mechanical change(s)`, and exits `1` while it leaves + an edit or the range to you; a disagreement its re-run cannot tie to one + edit still restores every file. +- **The access matrix.** `os build` and `os compile` run this gate; + `os validate` does not. The protocol-19 edits add `viewAllFields: true` + beside View All and Modify All, so a project that commits + `access-matrix.json` stops on "Access matrix drift". Run `os build --update-access-matrix`; the owner reviews and + commits the matrix diff, the review of who can do what. +- **`os migrate apply --yes`**, per deployment, after `os migrate plan`: + without `--yes` a non-interactive shell applies nothing and exits `1`. +- **`os migrate protocol --to 19`**, per deployment: a preview, then + `--apply --yes`. Until that switch is recorded, a 19 `os serve`, `os dev` or + `os start` refuses to start on a database an earlier release created. +- **Stored rows**, per deployment, with the 19 CLI: the stored pass below, a + dry run, then `--apply --yes`. After `next.3` it exits `1` while a row would + be served invalid, naming each row's fix. +- **Stored permission sets are never rewritten.** The stored pass only lists, + under `viewAllFieldsReview`, each entry holding View All or Modify All and + no `viewAllFields`, and still exits `0`: on 19 its holders already read no + field another set hides. The owner decides each entry; to keep the reads, + add `viewAllFields: true` to it through the metadata API. ### Stored rows: rehydration replays what the release carries @@ -83,8 +112,7 @@ metadata loader and the ObjectQL plugin pass each stored row through `applyConversionsToStoredItem`, which replays every conversion the release still carries, **including entries retired from the load path**. -Rehydration is a read-time projection: the rows on disk keep their old shape. -The stored pass is read-only by default: +The rows on disk keep their old shape. The stored pass is read-only by default: ```bash os migrate meta --stored # preview, writes nothing @@ -97,11 +125,9 @@ pass replays the whole chain. ### Data migrations are not metadata migrations -When the chain crosses into a major carrying per-deployment data gates, the run -ends by naming each one, what staying un-run costs, and that `--apply` is the -only writing mode. Read that output rather than re-deriving it. The gates run -against each deployment's own database. A gate nobody was told about is served -by nobody. +The run ends by naming each per-deployment data gate, what staying un-run +costs, and that `--apply` is the only writing mode: read that output, do not +re-derive it. Each runs against a deployment's own database. ## 2 · Semantic residue @@ -110,17 +136,16 @@ declared block. It cannot make a decision. Everything it cannot do lands here. ### 2.1 Harvest the instruction sources — all of them ship -The prescriptions are not on a docs site you have to be online for. They ship -inside the installed package. **Measured** against the published -`@objectstack/spec` file list: +The prescriptions ship inside the installed package, offline. **Measured** +against the published `@objectstack/spec` file list: | Source | Where, in a consumer project | Carries | |:--|:--|:--| -| **Chain result** | `os migrate meta --from N --json` → `.specChanges` | The conversions + semantic entries for exactly the majors you cross. **Start here** — it is computed from the installed spec, so it can never be stale. | +| **Chain result** | `os migrate meta --from N --json` → `.specChanges` | The conversions + semantic entries for exactly the majors you cross. **Start here**: computed from the installed spec, so never stale. | | **D4 projection** | `node_modules/@objectstack/spec/spec-changes.json` | The same data for every major, offline: `perMajor[].converted` and `perMajor[].migrated`. | | **Tombstone prescriptions** | `node_modules/@objectstack/spec/json-schema/**` and `src/**/*.zod.ts` | Every retired key's `[REMOVED] …` fix-it text, greppable. | -| **FROM → TO tables** | `node_modules/@objectstack/spec/CHANGELOG.md` | The per-retirement narrative, including the "what to write instead" table. This is why the package ships its changelog. | -| **The error itself** | Your parse / `tsc` output | The same prescription string, delivered at the moment you hit it. | +| **FROM → TO tables** | `node_modules/@objectstack/spec/CHANGELOG.md` | The per-retirement narrative, including the "what to write instead" table. | +| **The error itself** | Your parse / `tsc` output | The same prescription string, when you hit it. | ```bash # every tombstone prescription the installed spec carries, deduped (`| wc -l` sizes it) @@ -140,9 +165,6 @@ node -e " grep -n -B4 -A20 'transform' node_modules/@objectstack/spec/CHANGELOG.md | less ``` -Measure each number at the start of the upgrade and again in the report; a -pinned table is not a reading. - > **Not reachable from a consumer project**, so do not send anyone there: the > conversion and migration registries (`src/conversions/registry.ts`, > `src/migrations/registry.ts`) and the platform repo's generated upgrade guide @@ -176,8 +198,7 @@ The shape in a protocol-16 project: The chain deletes the key (`field-mapping-transform-removed`), then all of `fieldMappings` (`connector-sync-keys-removed`), whose tombstone *is* the -prescription: **nothing ever ran any connector field mapping**. The customer -wrote it because they wanted a transformation, and that need is real regardless. +prescription: **nothing ever ran any connector field mapping**. The prescription names one live target; the rest is the business decision: @@ -189,37 +210,24 @@ The prescription names one live target; the rest is the business decision: That third row is frequently the truth: no connector sync ever ran, so no value ever passed through this mapping. Where the data really comes from, and whether -it is right, only the owner can answer — exactly the kind of finding the report -exists to surface. +it is right, only the owner can answer. ### 2.4 Decide alone, or ask the owner The rule is in `SKILL.md`. What each condition looks like: -- **One target**: the tombstone or conversion summary gives a single FROM → TO. - **Evidence in the project**: the skill that already owns the tool, the import that already exists, the field the predicate already references. -- **Two or more real targets**: the `transform` case above. -- **Observable without a test failing**: security posture, row visibility - (an access predicate). A wrong call here ships silently and is discovered by - an auditor. - **Capability re-declared somewhere new**: agent tooling that has to move inside a specific skill is the canonical shape. -**How to ask.** Never a bare "how should I handle `transform`?" — that hands -the reading work back to the person with the least context about the diff. - -**While you wait, do not stall the upgrade.** A project can be schema-valid -with open residue items; it just is not *done*. - ### 2.5 Working an R2 — retired APIs in the project's own code -The chain's semantic entries are the search list. For each one, the surface it -names is a string you grep for in the project's own source: +Grep the project's own source for each surface the chain's semantic entries name: ```bash # from the chain's own output — the surfaces it says it cannot fix for you -os migrate meta --from 16 --json | node -e " +os migrate meta --from 18 --json | node -e " let s=''; process.stdin.on('data',d=>s+=d).on('end',()=>{ for (const t of JSON.parse(s).todos) console.log(t.surface); })" @@ -227,9 +235,6 @@ os migrate meta --from 16 --json | node -e " grep -rn "" src/ app/ --include='*.ts' --include='*.tsx' ``` -A key was retired because nothing enforced it or because exactly one spelling -survives, so the fix in that code is never a tolerant read of the old one. - ### 2.6 Working an R3 — the prose sweep Run it once the shapes are settled: @@ -241,9 +246,7 @@ grep -rho '\[REMOVED\] `[^`]*`' node_modules/@objectstack/spec/json-schema/ \ ``` Then sweep the project's `*.md` (READMEs, ADRs), comments, seed fixtures, and -its AI conventions file. The conventions file matters most: it is what the next agent loads before -it writes anything, so a retired shape left there re-enters the codebase on the -next feature, long after the upgrade closed. +its AI conventions file, which the next agent loads before it writes anything. ## 3 · Acceptance @@ -251,10 +254,9 @@ Four artifacts. Three are machine-checked; the fourth is the one a human reads. ### 3.1 Typed -A retired key is not merely absent from the schema — it is declared as a -tombstone whose input type is `never`. Assigning anything to it fails to -compile, at the authoring site, before anything runs. A green `tsc --noEmit` is -therefore positive evidence that no retired key survives in typed sources. +A retired key is a tombstone whose input type is `never`: assigning to it fails +to compile at the authoring site. A green `tsc --noEmit` is therefore positive +evidence that no retired key survives in typed sources. ### 3.2 Parse-gated @@ -278,12 +280,13 @@ the author-time rule set. Read the two separately — a rule finding about a missing sharing model or an options-less choice field is a project-quality issue the control already shows. -Some conversions are **migration-chain-only**: the loader deliberately does not -apply them and no tombstone rejects the old shape, because the change is a -default flip rather than a rename — auto-applying it would stamp a constraint -onto sources that deliberately omit it. This build ships none (every conversion -it carries is tombstoned, so the parse refuses the old shape too), but a later -one can, and the chain, not the parse, is what knows. +Some conversions are **migration-chain-only**: the loader does not apply them +and no tombstone rejects the old shape, because the change is a default flip, +not a rename: auto-applying it would stamp a constraint onto sources that +deliberately omit it. Protocol 19 ships such a flip, +`permission-view-all-fields-beside-record-bypass`: View All with no +`viewAllFields` still parses, and no longer reads every field. The chain, not +the parse, knows. Why `--from ` proves nothing: `--to` defaults to the highest major this build carries a step for, so the range is empty — no step runs, `applied` @@ -294,16 +297,15 @@ semantic residue, Layer 2's business, not a failure. ### 3.4 The report — the human half -The upgrade is not finished by a passing command; it is finished by a document a -maintainer can read in five minutes and a year from now. Write -`.upgrade/REPORT.md`: +Write `.upgrade/REPORT.md`, a document a maintainer can read in five minutes +and a year from now: ```markdown -# Protocol 16 → 17 upgrade — +# Protocol → upgrade — **Status:** complete | complete with N open decisions -**Spec:** · **Chain:** 16 → 18 -**Verified:** `os validate` green · `tsc --noEmit` green · replay 16 → 18 applies 0 mechanical changes +**Spec:** · **Chain:** → +**Verified:** `os validate` green · `tsc --noEmit` green · replay → applies 0 mechanical changes ## 1 · Mechanical (applied by the chain) @@ -368,16 +370,15 @@ got — "it passed" is a different fact in every row: ### 3.6 Stored rows: assert them, do not believe them -The four artifacts above cover the authored sources. For a **deployment**, the -stored pass is itself the assertion — run it read-only and branch on the exit -code: +For a **deployment**, the stored pass is the assertion: run it read-only and +branch on the exit code: ```bash -os migrate meta --stored --json # 0 = every row canonical, 1 = work left +os migrate meta --stored --json # 0 = nothing left to rewrite, 1 = work left ``` -That is what makes "this deployment is on protocol N" a CI check, valid only on -the release you are leaving. Nothing gates on it having run. +That is what makes "this deployment is on protocol N" a CI check. Nothing gates +on it having run, and `0` does not cover the permission sets it only lists. ## The v17-canonical shapes, compiled @@ -419,12 +420,10 @@ export const SupportBot = defineAgent({ | Symptom | What it actually is | Fix | |:--|:--|:--| | The acceptance replay still applies changes | The port is incomplete, or a source builds metadata at runtime from a shape the chain never saw. | Diff against `--out`; grep for the `conversionId`'s surface in code that constructs metadata dynamically. | -| `validate` green, but a feature silently stopped working | An R2 residue item: code reading a renamed key now reads `undefined`. | Exercise the path for real. A green parse says nothing about a `??` chain in the project's own code. | | A retired key round-trips without error | The schema carrying it is not strict and the key is being stripped, or the key still has a live load-path window. | Determine which — the two need different acceptance evidence. See [the reverse check](#reverse-check). | | `--apply` refused / stored-only flag rejected | `--apply`, `--yes`, `--force`, `--type`, `--database-url` mean something only with `--stored`. | Add `--stored`, or drop the flag; the authored-source chain writes only `--out` and, with `--write`, the sources. | | `MigrationFloorError` | `--from` is older than the chain's support floor. | Upgrade to the floor by an older route first; the floor is a release-policy boundary, not an oversight. | -Scripting the run instead of reading it? Every `--json` failure above carries a -stable `error` code to branch on — `stored_only_flag`, `missing_from_major`, -`unsupported_from_major`, `confirmation_required`, `database_busy` — and the -prose row is the same fact for a human. +Every `--json` failure above carries a stable `error` code to branch on: +`stored_only_flag`, `missing_from_major`, `unsupported_from_major`, +`confirmation_required`, `database_busy`.