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
152 changes: 152 additions & 0 deletions .github/workflows/upgrade-source-gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Upgrade-source gate — the v18 → v19 SOURCE upgrade, walked the way a real
# 18.x user walks it, against this checkout's packed tarballs, with no model key.
#
# Every upgrade-path defect found on the GA path passed its own unit tests and
# was caught only by a hand-run acceptance: the migration tool's tests use
# stacks written as literals, while a user's project is the template's
# `exportsOf(…)` wiring over barrels, with a database an 18.x install wrote.
# The two neighbouring gates cover other ground: `scaffold-e2e.yml` builds and
# boots a NEW scaffold, and `upgrade-harness-optin.yml` boots an 18.0 DATABASE
# on main; neither runs the source migration.
#
# The job and its assertions live in `packages/qa/upgrade-source/run.mjs`
# (header: what is walked, and how an assertion that waits on an open card is
# reported); the committed 18.6.0 project and the database the PUBLISHED 18.6.0
# CLI wrote for it sit beside it, with their provenance. The install step is
# scaffold-e2e.yml's: this checkout's publishable packages packed with
# `scripts/publish-smoke-pack.mjs`, and the project's `@objectstack/*` pins
# moved to that version and resolved through the project's own pnpm overrides.
#
# NOT a required check, and green: no assertion waits on an open card. A red
# reads UNEXPECTED unless its `waitsOn` card is open and the red is that card's
# own failure (run.mjs header). It joins the required set only by a later,
# deliberate edit of `scripts/check-required-contexts.mjs`.
#
# Every step below is part of an install/build/migrate/boot pipeline, not a
# named local verification script a dev pre-runs with `pnpm check:x` — there is
# no check family here to discover, deliberately (the scaffold-e2e.yml shape):
# dispatch-gates: no-check-families -- steps are an e2e pipeline, not named local checks

name: Upgrade Source Gate

on:
pull_request:
# Every input the walk runs through, by the step that reads it. A step's
# code missing here lets a PR change what the walk asserts without the walk
# running on it.
paths:
# `os migrate meta` (--write, --stored), `os migrate apply`, `os migrate
# protocol`, the source writer, and the schema migration they share.
- 'packages/cli/**/migrate*'
- 'packages/cli/**/migrate*/**'
- 'packages/cli/src/utils/authored-source-*'
- 'packages/cli/src/utils/schema-migrate.ts'
# `os validate` / `os build`, and the protocol-range check both run.
- 'packages/cli/src/commands/validate.ts'
- 'packages/cli/src/commands/build.ts'
- 'packages/cli/src/commands/compile.ts'
- 'packages/cli/src/utils/protocol-version-gap.ts'
# T2: the dry run's own-field-row list (`ownFieldRowNarrowing`).
- 'packages/cli/src/utils/own-field-row-narrowing.ts'
# The ADR-0087 conversion table (its entries, `conversions/entries/NN/*`)
# and the migration chain and registry that replay it.
- 'packages/spec/src/conversions/**'
- 'packages/spec/src/**/migrations/**'
# The stored-row conversion `--stored` and the boot apply to sys_metadata.
- 'packages/metadata-protocol/src/stored-migration.ts'
- 'packages/metadata-protocol/src/protocol-stored-*'
# B5 and B6: the runtime field axis the boot's reads and writes go through
# (the set's own field row against viewAllFields / Modify All).
- 'packages/plugins/plugin-security/src/permission-evaluator.ts'
- 'packages/plugins/plugin-security/src/field-masker.ts'
- 'packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts'
- 'packages/core/src/security/effective-object-permissions.ts'
# The template a user's project starts from.
- 'packages/cli/src/commands/init.ts'
- 'packages/create-objectstack/**'
# How the walk installs this checkout: the packer and the workspace setup.
- 'scripts/publish-smoke-pack.mjs'
- '.github/actions/setup-workspace/**'
# The gate itself.
- 'packages/qa/upgrade-source/**'
- '.github/workflows/upgrade-source-gate.yml'
schedule:
- cron: '41 4 * * *'
workflow_dispatch:

permissions:
contents: read

# A newer run for the same pull request supersedes this one; the schedule and
# dispatch runs share a group keyed on their own event and wait for each other
# (scaffold-e2e.yml's shape).
concurrency:
group: upgrade-source-gate-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.after || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
upgrade-source:
name: v18 → v19 source upgrade
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Setup workspace
uses: ./.github/actions/setup-workspace

- name: Setup turbo cache
uses: actions/cache@v6
with:
path: .turbo/cache
key: ${{ runner.os }}-turbo-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-${{ github.job }}-
${{ runner.os }}-turbo-

# The runner's pure judgements, on fixtures, before anything is built.
- name: Self-test the runner
run: node packages/qa/upgrade-source/run.mjs --self-test

# The build set is read off the fixture's own package.json, never a hand
# list: each `@objectstack/*` dependency it declares, with turbo's
# `^build` bringing that package's workspace dependencies along.
- name: Build the framework the fixture depends on
run: |
FILTERS=$(node -p '
const pkg = require("./packages/qa/upgrade-source/fixture-18.6.0/package.json");
const names = [pkg.dependencies, pkg.devDependencies]
.flatMap((deps) => Object.keys(deps ?? {}))
.filter((name) => name.startsWith("@objectstack/"));
if (names.length === 0) throw new Error("the fixture declares no @objectstack/* dependency");
names.map((name) => "--filter=" + name).join(" ");
')
echo "turbo run build $FILTERS"
# shellcheck disable=SC2086 # FILTERS is a word list on purpose.
pnpm exec turbo run build $FILTERS

- name: Pack this checkout's publishable packages
run: node scripts/publish-smoke-pack.mjs "$RUNNER_TEMP/tarballs"

# Template wiring (migrate meta --write, re-run, range, validate, build),
# the 18.6.0 database (migrate apply, the protocol-19 switch, --stored),
# the boot and its reads, then the helper-built wiring. The summary lists
# every assertion, and names the card each red waits on.
# GITHUB_TOKEN reads (only) the state of each card an expected red waits
# on: a red is excused only while its card reads open.
- name: Walk the v18 → v19 upgrade
env:
GITHUB_TOKEN: ${{ github.token }}
run: node packages/qa/upgrade-source/run.mjs --tarballs "$RUNNER_TEMP/tarballs" --work "$RUNNER_TEMP/upgrade-source"

- name: Upload the walk's logs
if: always()
uses: actions/upload-artifact@v7
with:
name: upgrade-source-logs
path: |
${{ runner.temp }}/upgrade-source/logs
${{ runner.temp }}/upgrade-source/results.json
if-no-files-found: ignore
retention-days: 14
72 changes: 72 additions & 0 deletions packages/qa/upgrade-source/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Upgrade-source gate (v18 → v19)

The source-upgrade path a real 18.x user takes, walked end to end against this
checkout by `.github/workflows/upgrade-source-gate.yml`. No model key is used
anywhere.

| Path | What it is |
|---|---|
| `fixture-18.6.0/` | An 18.6.0 project shaped like a user's (see below). Never edited to suit 19: it is the "before". |
| `fixture-db-18.6.0/` | The SQLite database the **published** 18.6.0 CLI wrote for that project, as SQL text, with `manifest.json` (what was put in it, and what 18.6.0 served) and `provenance.json` (the command, the versions, the hashes). |
| `generate-fixture-db.mjs` | The generator behind `fixture-db-18.6.0/`. Run it again rather than editing its output. |
| `helper-wiring/` | The second wiring: the same sources behind `composeStacks(createCrmStack(…))`, the shape a larger app (HotCRM) takes. It is an overlay laid over a copy of the fixture (its `package.json` is the fixture's under another name). |
| `run.mjs` | The walk and its assertions (`--self-test` covers its pure judgements). The header lists every step. |

## Why here, and why the object files are not named `*.object.ts`

The fixture's `.ts` files are 18.6.0 sources, and this checkout's 19 spec
refuses them (`view.list.bulkActions`), which is the point. So nothing in this
repository may type-check or import them:

- `packages/` is outside the root type-check program (`tsconfig.json` excludes
it), and this directory has no `package.json`, so it is not a workspace member.
`fixture-18.6.0/` and `helper-wiring/` each carry a `package.json` (the
helper's is the fixture's under another name): the type-check coverage walk
skips a directory with one as another project's, which is what each of them is.
- Two `platform-objects` sweeps import every `*.object.ts` under `packages/` as
code this repository ships; only the scaffolding templates are excluded, by
name. So the fixture's object files are `src/objects/account.ts`, `contact.ts`
and `note.ts`, and the barrel imports them by those names. `os migrate meta`
never reads a file name: the wiring and every metadata shape are as 18.6.0
wrote them. ⛔ Do not use a dot-directory instead: `check-affected-docs` pins
that no tracked `.ts` under `packages/**` lives in one.

`fixture-18.6.0/package.json` pins `18.6.0`, and the runner moves those pins to
the checkout's version, as a user's upgrade does.

## The fixture

It was scaffolded with `npx create-objectstack@18.6.0 crm18 --skip-skills`, and
its metadata was written with that install's own `os generate` and then edited
by hand. `os validate` and `os build` pass on 18.6.0. It holds:

- the blank template's `objectstack.config.ts`, with its `exportsOf(…)` wiring unchanged;
- `crm18_account`, and `crm18_contact` with a master-detail and a lookup to it;
- list views carrying `list.bulkActions`, and three actions;
- `crm18_auditor`: View All and Modify All on contacts, plus its own row hiding `crm18_contact.salary`;
- `crm18_member`, with a field row hiding the account notes;
- a validation rule, a record-triggered flow, a dataset and a dashboard;
- a committed `access-matrix.json` (written by 18.6.0's `os build --update-access-matrix`).

The sample `note` object from the template stays, because a user's project
usually still has it. The template's Dockerfile, docs and starter test are left
out: the gate does not use them.

## The database

`node packages/qa/upgrade-source/generate-fixture-db.mjs` (needs the npm
registry, pnpm and Node 22.13 or later) does the following:

1. Installs the fixture from the registry at its 18.6.0 pins.
2. Builds it and boots it with that install's own `os start` on a new SQLite file.
3. Signs up the owner. On 18.6.0 self-registration then closes, so the owner
creates the member and the auditor, and each sets their own password.
4. Assigns the two permission sets and creates three accounts and four contacts.
5. Saves the contact list view the way Studio does: GET, drop a column, PUT. The
save is stored as an overlay row that still carries `bulkActions`.
6. Records what 18.6.0 served for the reads the gate asserts on 19, then stops
the server and dumps the database.

`OS_AUTH_SECRET` and `OS_SECRET_KEY` are fixed, published values (see
`FIXTURE_ENV`). They protect nothing; they let any runner open what 18.6.0
sealed.
7 changes: 7 additions & 0 deletions packages/qa/upgrade-source/fixture-18.6.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
dist
.objectstack/
*.log
.DS_Store
.env
.env.*
51 changes: 51 additions & 0 deletions packages/qa/upgrade-source/fixture-18.6.0/access-matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"version": 1,
"entries": [
{
"permissionSet": "crm18_auditor",
"object": "crm18_account",
"create": false,
"read": true,
"edit": false,
"delete": false,
"viewAllRecords": true,
"modifyAllRecords": false,
"sharingModel": "private"
},
{
"permissionSet": "crm18_auditor",
"object": "crm18_contact",
"create": false,
"read": true,
"edit": true,
"delete": true,
"viewAllRecords": true,
"modifyAllRecords": true,
"sharingModel": "private"
},
{
"permissionSet": "crm18_member",
"object": "crm18_account",
"create": false,
"read": true,
"edit": false,
"delete": false,
"viewAllRecords": false,
"modifyAllRecords": false,
"readScope": "org",
"sharingModel": "private"
},
{
"permissionSet": "crm18_member",
"object": "crm18_contact",
"create": true,
"read": true,
"edit": true,
"delete": false,
"viewAllRecords": false,
"modifyAllRecords": false,
"readScope": "own",
"sharingModel": "private"
}
]
}
85 changes: 85 additions & 0 deletions packages/qa/upgrade-source/fixture-18.6.0/objectstack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { defineStack } from '@objectstack/spec';
import { ConnectorRestPlugin } from '@objectstack/connector-rest';
import { ConnectorOpenApiPlugin } from '@objectstack/connector-openapi';
import { ConnectorMcpPlugin } from '@objectstack/connector-mcp';
import * as objects from './src/objects';
import * as views from './src/views';
import * as actions from './src/actions';
import * as flows from './src/flows';
import * as dashboards from './src/dashboards';
import * as apps from './src/apps';
import * as skills from './src/skills';
import * as picklists from './src/picklists';
import * as permissions from './src/security';
import * as datasets from './src/datasets';

// Every value a barrel exports, as the list a stack key takes: typed by what
// the barrel exports, and an empty list while it exports nothing yet.
const exportsOf = <M extends object>(barrel: M): M[keyof M][] => Object.values(barrel);

// This file is a MODULE, and the whole module is the stack: the default
// export below is the base, and every NAMED export is merged onto it as a
// top-level stack key under its own name. A helper exported from here is
// therefore read as a stack key and the build refuses it — keep helpers in a
// sibling module and import them. Only names the stack schema declares
// (onEnable, functions, the collections) belong here as named exports.
export default defineStack({
manifest: {
id: 'com.example.crm18',
namespace: 'crm18',
version: '0.1.0',
type: 'app',
name: 'Crm18',
// Protocol compatibility range: the metadata-protocol major this app is
// authored against. The runtime checks it before it loads anything, so a
// runtime outside the range refuses this app at the boundary with the exact
// migration command instead of crashing later. Scaffolding stamped it to
// match the ObjectStack version you installed — change it when you
// deliberately move to a new protocol major, not to silence a mismatch.
// Guide: https://objectstack.ai/docs/upgrading
engines: { protocol: '^18' },
},

// `automation` backs flow execution and materializes any declarative
// `connectors:` entry into a live, dispatchable connector at boot. The
// connector executors below register their provider factories with it —
// without `automation` loaded they have nowhere to register and boot fails,
// so keep this capability whenever `plugins:` lists a connector.
//
// `triggers` fires a flow that starts on a record change, the kind
// `objectstack generate flow NAME` writes: without it this config stops
// loading once it holds such a flow. It can go if this project will never
// hold one.
requires: ['automation', 'triggers'],

// Generic connector executors, default-present so you can add a `connectors:`
// entry naming `provider: 'rest' | 'openapi' | 'mcp'` and have it materialize
// with zero host code. Zero-arg = contribute the provider factory only. Brand
// connectors (Slack, …) stay marketplace/opt-in.
// Security: a declarative `mcp` stdio transport spawns a local process from
// metadata, so it is denied by default — opt in per host with
// `new ConnectorMcpPlugin({ declarativeStdio: ['<trusted-command>'] })`.
// Authoring guide: https://objectstack.ai/docs/automation/connectors
plugins: [
new ConnectorRestPlugin(),
new ConnectorOpenApiPlugin(),
new ConnectorMcpPlugin(),
],

// Every directory `objectstack generate` writes into is wired here: its
// index.ts exports what the directory holds, and each list below hands
// those exports to the stack. `objectstack generate view NAME` adds a file
// and one export line, and the view is part of this stack with no edit to
// this file. A directory that is not wired here is never loaded, and
// `objectstack validate` neither counts nor checks what it holds.
objects: exportsOf(objects),
views: exportsOf(views),
actions: exportsOf(actions),
flows: exportsOf(flows),
dashboards: exportsOf(dashboards),
apps: exportsOf(apps),
skills: exportsOf(skills),
picklists: exportsOf(picklists),
permissions: exportsOf(permissions),
datasets: exportsOf(datasets),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://schemas.objectstack.dev/template-manifest.json",
"namespace": "crm18",
"displayName": "Crm18",
"readmePath": "README.md"
}
Loading
Loading