@spooky-sync/cli 1.0.0-beta.1 → 1.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -1
- package/package.json +6 -6
package/AGENTS.md
CHANGED
|
@@ -56,7 +56,7 @@ error names the flag. If you see "No terminal to ask on", that is this.
|
|
|
56
56
|
- **`spky migrate status`** — show pending vs applied vs modified-but-applied migrations.
|
|
57
57
|
- **`spky migrate fix [--fix-checksums]`** — repair schema drift / checksum mismatches.
|
|
58
58
|
- **`spky verify [--fix]`** — confirm SSP/scheduler snapshot matches upstream SurrealDB, and print the scheduler's own drift verdict (`/health/snapshot` `drift`). `--fix` re-clones the scheduler replica when its counts are off, otherwise forces every SSP to re-bootstrap. The scheduler runs the same count check itself at startup and after each snapshot drain, repairs a drifted table in place by default, and re-clones only when a repair cannot fix it (`SPKY_DRIFT_AUTO_RECLONE`). Tables added, changed or removed upstream are picked up by a running scheduler and SSP without a restart or re-clone.
|
|
59
|
-
- **`spky lint`** — validate `sp00ky.yml` and referenced files exist.
|
|
59
|
+
- **`spky lint`** — validate `sp00ky.yml` and referenced files exist, and warn about statements in the app's `DEFINE EVENT` / `DEFINE FUNCTION` bodies that SurrealDB 4.0.1 runs as table scans (`where-on-event-value`, `write-where`, `inside-param`, `composite-index`, `lookup-write-with-call`) and about `FOR select WHERE true` (write `FULL`), each with its rewrite (`src/query_lint.rs`). A `-- spky-lint: allow <rule>` comment above a DEFINE silences a rule for that definition. `spky doctor` reports the same as the `body-index-scans` warning.
|
|
60
60
|
- **`spky dev [--apply-migrations] [--clean] [--verbose]`** — boots a local SurrealDB + SSP + scheduler stack via Docker. `--clean` wipes SSP/scheduler state but preserves user data in SurrealDB. Startup renders as step lines via `src/ui.rs` (indicatif/console; plain lines when not a TTY); after "ready" only ERROR/crash-looking lines (infra and app streams) show unless `--verbose` / `SPKY_VERBOSE=1`. A bare `logLevel` is scoped to sp00ky crates by `backend::scoped_rust_log`.
|
|
61
61
|
- **`spky init`** — scaffold a new sp00ky project in the current directory. (`spky create` is a removed alias that only prints a migration hint.)
|
|
62
62
|
- **`spky bucket add`** / **`spky api add`** — append a bucket or backend definition to `sp00ky.yml`.
|
|
@@ -114,6 +114,12 @@ DEFINE TABLE audit_log SCHEMALESS;
|
|
|
114
114
|
|
|
115
115
|
A descriptor must sit directly above its statement (no blank line between). One that attaches to nothing is warned about, not silently dropped (`annotations::warn_unattached_annotations`). A descriptor is the marker alone plus at most one value token (`-- @crdt text`); a longer comment that merely starts with a marker name is prose, not an annotation, and `-- @nosync true` is refused with a warning.
|
|
116
116
|
|
|
117
|
+
## Room relay (`relay:` in `sp00ky.yml`)
|
|
118
|
+
|
|
119
|
+
`relay: true` (or `relay: { image: ... }`, on unless `enabled: false`) runs the room relay (`apps/relay`, image `mono424/spooky-relay` at the tag of this CLI's release channel) for the client's `channels.share`. It is not a service of its own in the CLI: `Sp00kyConfig::expand_relay` (`backend.rs`, called by `parse_config_with_includes`) turns the key into a `type: docker` app named `spky-relay` (`RELAY_APP`) with port 8668, `healthcheck: /health`, `deploy: { expose: true }` and, for dev, `SPKY_DB_URL=http://surrealdb:8000`. So every path that walks docker apps handles it unchanged: `spky dev` starts container `sp00ky-dev-spky-relay` with the other docker apps, `spky deploy` pulls the image and ships it as an exposed backend at `{slug}-spky-relay.<domain>`. Added on top: `SPKY_RELAY_URL` / `VITE_SPKY_RELAY_URL` (`ws://localhost:8668/room`) in the dev env of every app and a "Relay" row in the ready banner (`dev.rs`), `VITE_SPKY_RELAY_URL=wss://{slug}-spky-relay.<domain>/room` as a frontend build arg on deploy (`derive_relay_ws_endpoint` in `cloud.rs`; a user value wins), and a warning plus skip on a Cloudflare project, which runs no containers. The name is the platform's, not the project's: it was `relay` in 1.0.0-beta.9 and met a project's own stream relay, so a user app named `relay` now lives beside it. The cloud's git-linked builder does the same expansion (`spooky-cloud` `internal/linking/relay.go`): keep the two in step. Docs: `/docs/reference/config#relay`, `/docs/reference/relay`.
|
|
120
|
+
|
|
121
|
+
**Reserved app names.** Every public host of a project is `{slug}-{name}.<domain>`, the platform's own among them, so `backend.rs` keeps two kinds of name out of `apps:`. `RESERVED_APP_PREFIX` (`spky-`) is the namespace of the services sp00ky runs for a project (`spky-relay` so far): `refuse_reserved_app_names`, called by `parse_config_with_includes` before `expand_relay`, bails on any app under it, with `relay:` on or off. A new platform service takes a name there, never a plain word. `PLATFORM_HOSTS` (`db`, `admin`, `pool`: the database, the scheduler's admin plane, the pool listener) are refused by `validate_manifest` (`spky lint`, `spky deploy`) for an app that gets a public host (`AppConfig::public_on_deploy`: a deployed frontend, or `deploy.expose`); a private or `devOnly` app may use them. The control plane enforces the same in `pkg/models/appnames.go` (400 `reserved_app_name`).
|
|
122
|
+
|
|
117
123
|
## Docker dev apps (`type: docker`)
|
|
118
124
|
|
|
119
125
|
Besides `backend`/`frontend` apps, `sp00ky.yml` can declare `type: docker` apps —
|
|
@@ -237,6 +243,10 @@ is always the committed file's.
|
|
|
237
243
|
- **Migrations are checksum-tracked.** Editing a previously-applied migration file won't silently re-run; `spky migrate status` flags it. Use `--fix-checksums` only when you're sure the change is semantically a no-op.
|
|
238
244
|
- **`sp00ky.yml` is the entry point.** The CLI never crawls for `.surql`; everything is wired explicitly through the config.
|
|
239
245
|
- **Generation modes matter.** The `--mode` flag (`singlenode`, `cluster`, `surrealism`) changes what the generated client connects to. Default is `singlenode` (HTTP to a single SSP). `surrealism` embeds the WASM stream processor in-browser.
|
|
246
|
+
- **Schema downgrade guard.** `record_schema_hash` stores `cli_version` (`env!("CARGO_PKG_VERSION")`) on `_00_schema_state`, and `migrate::guard_schema_downgrade` reads it before anything is written (`Sp00kyEngine::apply` for `migrate apply`/`prod`, `apply_remote_fns_and_internal_schema` for deploy and restore, `dev.rs` for `spky dev`). A newer stored version (semver precedence, `parse_version`) refuses with both versions and the fix, unless `--allow-schema-downgrade` / `SPKY_ALLOW_SCHEMA_DOWNGRADE`; on a local URL or under `spky dev` it only warns; missing or unparsable versions allow. An older CLI's own push leaves the newer `cli_version` in place (its UPSERT sets hash and updated_at only). Why: on 2026-11-17 a canary.385 `spky` from PATH re-pushed pre-keyed ledger events to WhitePawn on 4.0.1 and pinned its DB at 300% CPU.
|
|
247
|
+
- **Internal indexes are only (re)defined when they changed, and then `CONCURRENTLY`.** `migrate::prune_unchanged_index_defines` drops a `DEFINE INDEX` whose live definition matches (an `OVERWRITE` rebuilds from scratch), and on server modes appends `CONCURRENTLY` to the rest: SurrealDB 4.0.1 makes a blocking build wait up to 60 s for every older write transaction (`WRITE_BARRIER_WAIT`), which held `spky migrate apply` past its 120 s HTTP timeout on a busy database. The apply then polls `INFO FOR INDEX` (`wait_for_index_builds`) and records the schema hash only once every build is `ready`: a failed build (UNIQUE over duplicates) fails the apply, one still running at `SPKY_INDEX_BUILD_TIMEOUT_SECS` (600) warns and leaves the hash unrecorded, and the prune treats an index whose build is in `error` as changed.
|
|
248
|
+
- **Generated event and function bodies must pass `query_lint`.** `cargo test -p sp00ky-cli sp00kys_own_schema_passes` lints everything sp00ky deploys. Inside a body, bind event values with `LET` first, write through `UPDATE / DELETE (SELECT VALUE id FROM t WHERE ...)`, never `INSIDE $list`, give every body lookup a single-column index (4.0.1 uses no composite index for a parameter in a body), keep a function's lookups and writes in helpers that call no other `fn::` (`fn::feature::put` and friends), and write select rules as `FULL`, not `WHERE true` (4.0.1 drops indexes for record users otherwise). A legacy-ledger lookup uses the correlated form `sp00ky::LEDGER_LOOKUP_ROWS`, the only shape 4.0.1 plans as an index read when a record user's write fires the event. Cost tests: `cargo test -p sp00ky-cli body_scan`.
|
|
249
|
+
- **Ledger accesses in generated events are key accesses.** `_00_version` rows are keyed by their record (`type::record('_00_version', [$after.id])`, see `docs/version-ledger.md`). Never add a `WHERE record_id = $after.id` (or any `UPDATE`/`DELETE ... WHERE` on a parameter) to an event body: SurrealDB 4.0.1 scans the table for it inside an event. `cargo test -p sp00ky-cli version_ledger` (plus `-- --include-ignored --test-threads=1` for the Docker 3.3.5/4.0.1 runs) fails if a write's cost grows with the ledger.
|
|
240
250
|
- **Don't commit the bin output.** The Rust binary is built per-platform and shipped via the npm tarball under `dist/`.
|
|
241
251
|
|
|
242
252
|
## Pointers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spooky-sync/cli",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"description": "Generate TypeScript/Dart types from SurrealDB schema files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/syncgen.cjs",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"vitest": "^1.0.0"
|
|
63
63
|
},
|
|
64
64
|
"optionalDependencies": {
|
|
65
|
-
"@spooky-sync/cli-darwin-arm64": "1.0.0-beta.
|
|
66
|
-
"@spooky-sync/cli-darwin-x64": "1.0.0-beta.
|
|
67
|
-
"@spooky-sync/cli-linux-arm64": "1.0.0-beta.
|
|
68
|
-
"@spooky-sync/cli-linux-x64": "1.0.0-beta.
|
|
69
|
-
"@spooky-sync/cli-win32-x64": "1.0.0-beta.
|
|
65
|
+
"@spooky-sync/cli-darwin-arm64": "1.0.0-beta.11",
|
|
66
|
+
"@spooky-sync/cli-darwin-x64": "1.0.0-beta.11",
|
|
67
|
+
"@spooky-sync/cli-linux-arm64": "1.0.0-beta.11",
|
|
68
|
+
"@spooky-sync/cli-linux-x64": "1.0.0-beta.11",
|
|
69
|
+
"@spooky-sync/cli-win32-x64": "1.0.0-beta.11"
|
|
70
70
|
}
|
|
71
71
|
}
|