@spooky-sync/cli 1.0.0-beta.4 → 1.0.0-beta.5

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.
Files changed (2) hide show
  1. package/AGENTS.md +4 -1
  2. 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`.
@@ -237,6 +237,9 @@ is always the committed file's.
237
237
  - **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
238
  - **`sp00ky.yml` is the entry point.** The CLI never crawls for `.surql`; everything is wired explicitly through the config.
239
239
  - **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.
240
+ - **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.
241
+ - **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.
242
+ - **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`.
240
243
  - **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.
241
244
  - **Don't commit the bin output.** The Rust binary is built per-platform and shipped via the npm tarball under `dist/`.
242
245
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spooky-sync/cli",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.5",
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.4",
66
- "@spooky-sync/cli-darwin-x64": "1.0.0-beta.4",
67
- "@spooky-sync/cli-linux-arm64": "1.0.0-beta.4",
68
- "@spooky-sync/cli-linux-x64": "1.0.0-beta.4",
69
- "@spooky-sync/cli-win32-x64": "1.0.0-beta.4"
65
+ "@spooky-sync/cli-darwin-arm64": "1.0.0-beta.5",
66
+ "@spooky-sync/cli-darwin-x64": "1.0.0-beta.5",
67
+ "@spooky-sync/cli-linux-arm64": "1.0.0-beta.5",
68
+ "@spooky-sync/cli-linux-x64": "1.0.0-beta.5",
69
+ "@spooky-sync/cli-win32-x64": "1.0.0-beta.5"
70
70
  }
71
71
  }