Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .changeset/38926-upgrade-skill-18-to-19.md
Original file line number Diff line number Diff line change
@@ -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 `<from> → <to>`. "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`.
6 changes: 3 additions & 3 deletions skills/objectstack-data/rules/indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
61 changes: 31 additions & 30 deletions skills/objectstack-upgrade/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,57 +48,60 @@ 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

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 <authored-major> --to <target-major> --json`:
`applied` must be `[]` and `replayedNothing` absent. `--from <target-major>`
names an empty range and proves nothing.
shape validates. Replay the range you ported (Quickstart, step 3).
`--from <target-major>` 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
Expand All @@ -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

Expand Down Expand Up @@ -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 |

Expand Down
14 changes: 7 additions & 7 deletions skills/objectstack-upgrade/evals/protocol-major-upgrade.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
},
{
Expand All @@ -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"]
}
},
Expand Down
Loading
Loading