@sequenceholdings/studio-cli 0.9.19 → 0.9.21

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 (55) hide show
  1. package/README.md +131 -11
  2. package/dist/app/commands.js +2 -0
  3. package/dist/app/deploy.js +2 -0
  4. package/dist/app/lockfile-preflight.d.ts +31 -0
  5. package/dist/app/lockfile-preflight.js +47 -0
  6. package/dist/app/repository-index.d.ts +5 -1
  7. package/dist/app/repository-index.js +9 -3
  8. package/dist/auth.d.ts +13 -9
  9. package/dist/auth.js +98 -20
  10. package/dist/cli-errors.js +6 -1
  11. package/dist/command-contract.d.ts +13 -1
  12. package/dist/command-contract.js +3 -1
  13. package/dist/command-help.d.ts +1 -1
  14. package/dist/command-help.js +8 -1
  15. package/dist/config.d.ts +14 -0
  16. package/dist/config.js +29 -3
  17. package/dist/docs/commands.d.ts +16 -0
  18. package/dist/docs/commands.js +168 -0
  19. package/dist/docs/help.d.ts +2 -0
  20. package/dist/docs/help.js +12 -0
  21. package/dist/envs/commands.js +10 -2
  22. package/dist/host-token.d.ts +19 -4
  23. package/dist/host-token.js +50 -10
  24. package/dist/main.d.ts +1 -0
  25. package/dist/main.js +20 -2
  26. package/dist/orm/discover-operations.d.ts +1 -1
  27. package/dist/orm/discover-operations.js +3 -3
  28. package/dist/orm/discover-schema.d.ts +0 -5
  29. package/dist/orm/discover-schema.js +0 -3
  30. package/dist/pipeline/commands.d.ts +0 -7
  31. package/dist/pipeline/commands.js +16 -67
  32. package/dist/pipeline/discovery.d.ts +1 -1
  33. package/dist/pipeline/discovery.js +6 -6
  34. package/dist/process/build.d.ts +2 -5
  35. package/dist/process/build.js +4 -49
  36. package/dist/repos/commands.d.ts +11 -1
  37. package/dist/repos/commands.js +78 -11
  38. package/dist/repos/git-credential.d.ts +12 -5
  39. package/dist/repos/git-credential.js +63 -36
  40. package/dist/repos/github-connect-command.d.ts +35 -0
  41. package/dist/repos/github-connect-command.js +250 -0
  42. package/dist/repos/github-init-command.d.ts +5 -0
  43. package/dist/repos/github-init-command.js +106 -0
  44. package/dist/repos/github-init.d.ts +133 -0
  45. package/dist/repos/github-init.js +265 -0
  46. package/dist/scaffold-guidance.d.ts +10 -2
  47. package/dist/scaffold-guidance.js +27 -2
  48. package/dist/templates/guidance/AGENTS.md +15 -8
  49. package/package.json +10 -10
  50. package/release-summary.json +3 -1
  51. package/templates/guidance/AGENTS.md +15 -8
  52. package/dist/pipeline/active-orm-contracts.d.ts +0 -16
  53. package/dist/pipeline/active-orm-contracts.js +0 -36
  54. package/dist/pipeline/repin-orm.d.ts +0 -2
  55. package/dist/pipeline/repin-orm.js +0 -207
package/README.md CHANGED
@@ -379,8 +379,13 @@ versioned packages and depend on registry versions.
379
379
 
380
380
  Scaffolds write no `.npmrc` (CLI **0.9.2**+ also drops the `functions init`
381
381
  one), so `pnpm install` resolves from the registry your user configuration
382
- selects, `@sequenceholdings` packages included. Commit `pnpm-lock.yaml`:
383
- repository CI installs from the registry the lockfile was resolved against.
382
+ selects, `@sequenceholdings` packages included. Commit `pnpm-lock.yaml`.
383
+ Hosted repository CI installs only from Chainguard Libraries
384
+ (`https://libraries.cgr.dev/javascript/`), so a lockfile resolved against
385
+ another registry fails its frozen install. `init` (after installing) and
386
+ `deploy` name any such lockfile and the command that regenerates it:
387
+ `pnpm install --registry=https://libraries.cgr.dev/javascript/` with Chainguard
388
+ credentials in `~/.npmrc`.
384
389
 
385
390
  Workspace deployments outside `local` require the root lockfile. Staging keeps
386
391
  its registry resolutions and overrides; the existing Managed Functions registry
@@ -926,7 +931,7 @@ compiled to canonical SQL before registration.
926
931
  | `seq-studio orm generate [dir]` | Generate `schema.graphql`, `operations.manifest.json`, `typePolicies.gen.ts`, `namespace.contract.json`, `sql-operations.gen.ts`, and consumer codegen when `codegen.ts` is present. |
927
932
  | `seq-studio orm generate [dir] --migration-export [--check]` | Export `orm.migration.json` after validating the committed ORM migration. Pipeline migration planning recompiles these declarative inputs. `--check` compares against the current source and operations without writing; use it in CI. |
928
933
  | `seq-studio orm validate [dir]` | Parse and compile the namespace, then verify its committed migration chain is current. |
929
- | `seq-studio orm plan [dir] -e <env>` | Compare the compiled namespace with registry state without applying database changes; when available, print the live activation's source and provenance. |
934
+ | `seq-studio orm plan [dir] -e <env>` | Print fresh-schema DDL using current names, including tables with retained rename hints, and compare registry versions without writes. This is not an incremental live migration diff; when available, print the live activation's source and provenance. |
930
935
  | `seq-studio orm diff [dir] [--check]` | Author the next committed migration, or verify the migration/snapshot chain offline for CI. |
931
936
  | `seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"] [--source-env <env>]` | Author a migration if needed, register/apply the namespace, activate its operation set, publish its declared capabilities, and refresh generated outputs. Waits until the new version is live (prints `live:`; default up to 20m); `--no-wait` returns once queued. `--source-env` verifies a checkout of another registered environment's Git Service; sign in there first. |
932
937
  | `seq-studio orm history <namespace> -e <env> [--limit N] [--json]` | List every change to the namespace's live schema and operations, newest first, with the actor and the Git Service source. `apply` from a clone of the target environment's Git Service (or `--repo`) sends its commit and package path; Atlas checks it and records `verified`, `ci`, `break_glass` or `reported`. Environments with `ORM_REQUIRE_VERIFIED_SOURCE=1`, and namespaces pinned with `--mode source`, refuse unverified applies; a namespace admin can override with `orm apply --unverified-source "<reason>"`. |
@@ -1880,6 +1885,29 @@ server, `artifactWorkspaceId(name)` from `@sequenceholdings/artifact-studio/serv
1880
1885
  returns the environment's ID for a declared workspace, instead of a hardcoded
1881
1886
  per-environment map; `artifact dev` does not set it.
1882
1887
 
1888
+ Name another artifact by its project slug in a per-artifact API capability, so
1889
+ the same manifest targets each environment's copy of it:
1890
+
1891
+ ```yaml
1892
+ server:
1893
+ capabilities:
1894
+ api:
1895
+ read:
1896
+ - /api/custom-roles/artifact/relationships-migration/current-scope
1897
+ - /api/custom-roles/artifact/relationships-migration/reporting-scope
1898
+ ```
1899
+
1900
+ This applies to `/api/custom-roles/artifact/<target>/resolve`, `current-scope`
1901
+ and `reporting-scope` in `server.capabilities.api` and an ingress's
1902
+ `capabilities.api`. A UUID-shaped target is a project ID; any other is a
1903
+ project slug. Atlas resolves each slug when it admits the deployment and records
1904
+ the ID-keyed path, so the broker and rollbacks see IDs. The slug must belong to
1905
+ exactly one deployed project in that environment: none, or more than one (slugs
1906
+ are unique per owner), fails admission with a 409, because the target decides
1907
+ the caller's authority. On a deployed Next.js server,
1908
+ `artifactReferenceId(slug)` from `@sequenceholdings/artifact-studio/server`
1909
+ returns the ID to call; `artifact dev` does not set it.
1910
+
1883
1911
  `pull` writes the **active deployment's** source files (default out dir:
1884
1912
  `./<project-id>`) and errors when the project has no active deployment.
1885
1913
  `promote` and `rollback` resolve the target project from the current
@@ -2006,7 +2034,7 @@ Browser ORM admission controls are planned for Studio CLI 0.4.7 and Artifact
2006
2034
  Studio 0.6.7, together with matching platform support. Confirm package
2007
2035
  publication and environment rollout before using them; this remains part of
2008
2036
  the internal Next.js pilot. In a schema-v2 manifest, browser
2009
- `capabilities.data.operations` optionally lists up to 256 exact
2037
+ `capabilities.data.operations` optionally lists up to 512 exact
2010
2038
  `namespace/ops/Operation` references. Omission retains table-based admission;
2011
2039
  an explicit empty list denies all browser ORM operations. Browser `data.read`
2012
2040
  and `data.write` declarations still bound table and mutation reach.
@@ -2202,7 +2230,11 @@ git push
2202
2230
  No PAT is required. `repos clone` configures a repository-local credential helper
2203
2231
  that reads your current login token for that exact environment and repository.
2204
2232
  It never stores the token in the remote URL or Git config, and does not pass it
2205
- to inherited credential stores. Keep `seq-studio` installed on your `PATH`.
2233
+ to inherited credential stores. The helper runs the `seq-studio` that cloned
2234
+ (an installed launcher, `SEQ_STUDIO_LAUNCHER`, or `node <path>/bin.js`); if a
2235
+ clone fails, nothing is left behind. For a checkout made with plain `git clone`,
2236
+ or after an upgrade moved `seq-studio`, run
2237
+ `seq-studio repos attach-login [dir] -e <env>` to bind the helper to it.
2206
2238
  Once your session expires, run `seq-studio login --env <env>` and retry;
2207
2239
  Git itself does not open a browser or silently switch to a machine identity.
2208
2240
  Repository grants and protected-branch rules still apply.
@@ -2232,6 +2264,60 @@ a human identity or extend a human login's expiry.
2232
2264
  Add `--help` to a repo command to read its usage offline, without an
2233
2265
  environment or credentials.
2234
2266
 
2267
+ ### Set up a GitHub repository (`repo init`)
2268
+
2269
+ `seq-studio repo init --org <org>` makes a GitHub checkout a Sequence repository. It writes, and afterwards manages:
2270
+
2271
+ | File | Purpose |
2272
+ |---|---|
2273
+ | `.seq/github.yml` | The repository's org, dev and release branches (default `staging` and `main`) and the exact `seq-ci` release |
2274
+ | `.github/workflows/seq.yml` | Checks on pull requests and deploys from the dev and release branches, through `sequenceholdings/seq-ci` |
2275
+ | `.github/workflows/seq-promote.yml` | The Promote button that fast-forwards the release branch |
2276
+ | `renovate.json` | Keeps the `seq-ci` release and CLI pin current |
2277
+ | `.claude/skills/sequence-platform/SKILL.md` | Points agents at the platform docs; `AGENTS.md` gets a one-line pointer |
2278
+
2279
+ It writes only what's missing or stale and never overwrites a file it doesn't manage. `--check` reports the same and writes nothing (exit 3 when anything is missing or stale). Rerunning keeps the existing org and branches. Branch rulesets (`seq / checks` required on the dev branch; the release branch updatable only by the Sequence CI GitHub App, which Promote pushes as) and secret scanning need admin rights on the repository, which its creator has; no org owner is needed. `--apply-github` applies them with `gh` and confirms the repository can read seq-ci's `SEQ_CI_*` org secrets (`SEQ_CI_IMAGE_PULL_KEY`, the read-only key that pulls seq-ci's images, and `SEQ_CI_REGISTRY_AUTH`, a read-only dependency-registry pull token). Both are visible to every private repository in the org, as the Sequence CI App is installed on every repository. If an org owner has narrowed either to selected repositories, an owner's `--apply-github` (`gh auth refresh -s admin:org`) adds the repository. Anyone else gets an error naming the secret, and exit 1. Otherwise the ruleset commands are printed for an admin. Commit and push the files yourself.
2280
+
2281
+ ### Deploy a GitHub repository (`repo connect`, `repo status`)
2282
+
2283
+ `seq-studio repo connect -e <env> --stage staging|prod` lets the checkout's GitHub repository deploy to one stage of
2284
+ that Atlas: the dev branch to staging, the release branch to prod (from `.seq/github.yml`). Each plan uses the images
2285
+ pinned by the repository's `seq-ci` release, so a new release needs no reconnect. Connect each Atlas once, for example a BankSouth repository to `staging.banksouth` with `--stage
2286
+ staging` and to `banksouth` with `--stage prod`. release group (Sequence Staff) only.
2287
+
2288
+ Moving a repository from git-service: `--adopt <namespace>/<repo>:<branch>` hands that branch's deployments to the
2289
+ GitHub branch in the same step. Its bindings and every resource it controls move, and it drops to checks-only so it
2290
+ can't deploy them again. Needs merge rights on the git-service repository.
2291
+
2292
+ Resources deployed by hand before the repository deployed from CI: run `seq-studio repo bind -e <env> --stage
2293
+ staging|prod` after `connect` and before the first deploy. It binds each target to the one existing, ready resource of
2294
+ exactly its name that you may deploy (`--dry-run` previews); otherwise every existing resource plans as a new create.
2295
+ Only targets that stage's plan deploys are bound: a target scoped to other stages, by its own `stages` or its
2296
+ Application's in `.seq/repository.yml`, is skipped and reported (`Skipped <key> (stages: staging)`), so the branch
2297
+ never becomes the controller of a resource its CI does not deploy to that stage.
2298
+ A `kind: process` resource whose folder holds several processes (`<path>/<dir>/process.ts`), with no process of exactly
2299
+ its name, binds as a process group: each deploy registers its bundle once and promotes every process it defines,
2300
+ after checking editor on each existing one and Can create on Lattice for new ones; nothing is promoted if any is
2301
+ refused. A process belongs to one target: a group refuses one another target already deploys.
2302
+ Managed Pipelines are released under a name, set with `seq-studio repo init --release-repository <namespace>/<name>`
2303
+ before `connect`. A git-service repository of that name on the Atlas keeps releasing them (its identity receipt and
2304
+ merge rights are checked); with none, `connect` claims the name for this GitHub repository, so no git-service
2305
+ repository is needed.
2306
+
2307
+ `seq-studio repo status -e <env> [--stage staging|prod]` lists the repository's releases there, newest first, with each
2308
+ target's deployment state. `seq-studio repo disconnect -e <env>` stops every GitHub deploy of it to that Atlas,
2309
+ including queued and retried ones.
2310
+
2311
+ Deploys run in GitHub Actions: a push to the dev branch deploys staging; Promote moves the release branch and deploys
2312
+ prod. Prod deploys only through Promote.
2313
+
2314
+ Reusing pull-request builds: with `pull_request_builds: reuse` in `.seq/github.yml` (`repo init`'s default; `repo init
2315
+ --pull-request-builds rebuild` turns it off), `connect --stage staging` lets the dev branch's deploys reuse what a
2316
+ same-repository pull request's CI built and checked, instead of building and checking again, when the deployed tree
2317
+ carries every change that pull request's run tested (merges since then may change other files). The deploy log says per target whether it was built or reused
2318
+ from a pull request. Prod never reuses them. This is sound only while the dev branch requires no approvals, as `repo
2319
+ init`'s ruleset sets it: once it requires reviews, set `rebuild` and rerun `connect`.
2320
+
2235
2321
  ### Scaffold into a repository (`--repo`)
2236
2322
 
2237
2323
  Source you build belongs in a platform git-service repository, not only on one
@@ -2414,6 +2500,7 @@ JSON API — the same repos `--repo <ns>/<name>` sources build from.
2414
2500
  | `seq-studio repos identity <ns>/<name> -e <env> [--write --dir .]` | inspect the server-issued identity; `--write` restores its receipt at the matching clone's Git worktree root; admin-only `--adopt --write --yes` binds a legacy repository once |
2415
2501
  | `seq-studio repos create <ns>/<name> -e <env> [--default-branch <b>] [--git-backend walgit]` | create a repo, seeded with a README on `main`. The server picks the backend (walgit wherever it is configured). `--git-backend walgit` creates it empty, for pushing existing history. Needs namespace write. Returns once the repo resolves by name (the lookup `clone`, `show`, and `pull` use), so `repos clone` can follow at once. |
2416
2502
  | `seq-studio repos clone <ns>/<name> \| --url <clone-url> \| --id <uuid> -e <env> [--ref <r>] [--output <dir>] [--force] [--full] [--transport auto\|git\|json]` | smart-HTTP `git clone --depth 1` using login (`--full` fetches history; a commit SHA stays full). Configures login for subsequent Git commands. Use files-only `--transport json` for `<ns>/<name>`. `--out` remains an alias for `--output`. |
2503
+ | `seq-studio repos attach-login [<dir>] -e <env> [--remote origin]` | bind the login credential helper to an existing checkout whose remote is a git-service clone URL on `<env>` |
2417
2504
  | `seq-studio repos pull <ns>/<name> -e <env> [--ref <r>] [--out <dir>] [--force]` | always materialize via JSON API (no `.git` dir); refuses a non-empty destination unless `--force` |
2418
2505
  | `seq-studio repos delete <ns>/<name> -e <env> [--yes]` | delete a repo — interactive confirm unless `--yes` |
2419
2506
  | `seq-studio repos ci init [--dir <repository>]` | create `.seq/pipeline.yml` with native defaults; offline, preserves existing configuration |
@@ -2602,13 +2689,12 @@ root, stage identities, deployment admission or rollback provenance.
2602
2689
  | `seq-studio pipeline search <text> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--limit <count>] [--offset <count>] [--json]` | Search deployed asset and column names/descriptions without contacting Databricks; default 20 assets, maximum 100 |
2603
2690
  | `seq-studio pipeline describe <assetId> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--json]` | Read an active deployment's table description, documented/declared columns, and source provenance without contacting Databricks |
2604
2691
  | `seq-studio pipeline assets -e <env> [--repo <namespace>/<slug>] [--json]` | Export assets from the latest registered declarations for contract inspection; an asset need not be deployed |
2605
- | `seq-studio pipeline schema <assetId> -e <env> [--target <id>] [--json]` | Inspect the deployed asset's columns, types, nullability, and table/column descriptions when returned by the server |
2606
- | `seq-studio pipeline sample <assetId> -e <env> [--target <id>] [--limit <rows>] [--json]` | Preview rows from the deployed asset; default 25, capped at 100 by the server |
2607
- | `seq-studio pipeline query <assetId> --sql <sql> -e <env> [--target <id>] [--limit <rows>] [--json]` | Run a read-only query against the virtual relation `asset`; default and maximum 1,000 result rows |
2692
+ | `seq-studio pipeline schema <assetId> -e <env> [--target <id>] [--repo <namespace>/<name>] [--json]` | Inspect the deployed asset's columns, types, nullability, and table/column descriptions when returned by the server |
2693
+ | `seq-studio pipeline sample <assetId> -e <env> [--target <id>] [--repo <namespace>/<name>] [--limit <rows>] [--json]` | Preview rows from the deployed asset; default 25, capped at 100 by the server |
2694
+ | `seq-studio pipeline query <assetId> --sql <sql> -e <env> [--target <id>] [--repo <namespace>/<name>] [--limit <rows>] [--json]` | Run a read-only query against the virtual relation `asset`; default and maximum 1,000 result rows |
2608
2695
  | `seq-studio pipeline init --type ingestion\|transformation\|serving <name> [--dir <dir>]` | Scaffold `<name>.stage.yml` in the first configured stage directory (or package root without config), plus a package-root-relative `src/` Databricks-notebook entrypoint stub (begins with `# Databricks notebook source`; serving stages are declarative — no stub). Refuses to overwrite an existing spec |
2609
2696
  | `seq-studio pipeline codegen tables [--from <authoring.ts>] [--dir <dir>] [--dry-run] [--force]` | Generate one ingestion stage spec per table from a `PerTableIngestionAuthoring` TypeScript module. `--from` defaults to `authoring.tables.ts`; `--dir` defaults to the current package root and writes into its first configured stage directory (or the root without config). `--dry-run` lists output files without writing; existing files are preserved unless `--force` is supplied |
2610
- | `seq-studio pipeline validate [dir] [--assets <file\|url>] [--orm-contracts <file\|url>] [--json]` | Run the full offline spec gate: envelope + body validation, `schema_ref` resolution, repo-level graph validation, and optional `pipeline.yml` native workflow validation (DAG dependencies and manual stage membership). Auto-loads `orm-contracts.json` from the pipeline dir when present. Exit 0/1 |
2611
- | `seq-studio pipeline repin-orm [dir] -e <env> [--target <id>] [--dry-run]` | Resolve the environment's pipeline target (or use `--target` when ambiguous), fetch its active ORM v2 contracts, verify those serving projections remain compatible, then update `orm-contracts.json` and their `satisfies.content_hash` pins. Refuses to write when compatibility fails |
2697
+ | `seq-studio pipeline validate [dir] [--assets <file\|url>] [--json]` | Run the full offline spec gate: envelope + body validation, `schema_ref` resolution, repo-level graph validation, and optional `pipeline.yml` native workflow validation (DAG dependencies and manual stage membership). Ignores legacy `orm-contracts.json`; no ORM version or contract is required. Exit 0/1 |
2612
2698
  | `seq-studio pipeline plan --repo <namespace>/<slug> --ref <sha\|branch> [--source-env <env>] [--root <directory>] -e <env> [--target <id>] [--json]` | Enqueue and poll a durable Pipeline plan (materialize → SDK/`validateSpecGraph` → compile → live-diff → provision findings). `<namespace>` is `pipelines`, `apps`, or your own namespace. Fails closed listing **every** missing target binding (alert channels, workspace, Databricks `source.credential`) plus Data Sync edge-worker machine/operation/`credEnvFamilies` mismatches before registry writes. Does **not** run Databricks `bundle validate` (that is a Trigger deploy-path hard gate). Exit 1 on destructive findings (CI-safe). `--json` emits the completed stable plan envelope |
2613
2699
  | `seq-studio pipeline deploy --repo <namespace>/<slug> --ref <sha\|branch> [--source-env <env>] [--root <directory>] -e <env> [--target <id>] [--approved-by <sub>] [--allow-destructive <resource-key> ...] [--run-now] [--wait-timeout <duration>] [--no-wait] [--json]` | Plan then enqueue deploy; Trigger runs `bundle validate` then `bundle deploy` against reviewed bytes. `<namespace>` is `pipelines`, `apps`, or your own namespace. Default is plant-only (jobs are created, not run). `--run-now` runs in-unit producer roots after bundle deploy; serving refresh provisioning completes before producer trigger.after tasks can run. If a producer fails, the terminal status includes the remote Databricks task/event error when available. `--allow-destructive` is repeatable and must exactly name every deletion/recreation finding in the immutable plan; only authenticated `@seqholdings.com` users may authorize it; permission, ownership, schedule-drift, and provisioning blockers cannot be overridden. Polls to terminal unless `--no-wait`. Targets that require approval need `--approved-by` naming the authenticated caller. |
2614
2700
 
@@ -3470,6 +3556,22 @@ merged and closed Pulls, and prints the updated Pull like `show` (with `url`).
3470
3556
  `close` needs authorship or repository write and is idempotent.
3471
3557
  `repos pull` remains the singular source-snapshot command.
3472
3558
 
3559
+ ## Developer docs
3560
+
3561
+ Read the developer docs published by an environment from the terminal. Each
3562
+ environment serves the docs for the platform version it runs:
3563
+
3564
+ ```bash
3565
+ seq-studio docs search "deploy a managed function" -e <env> [--limit N] [--json]
3566
+ seq-studio docs read <slug> -e <env> [--json] # full page as Markdown; `index` is the homepage
3567
+ seq-studio docs list -e <env> [--json]
3568
+ ```
3569
+
3570
+ A cached login is sent when present; the command never opens a browser.
3571
+ `init` commands and `repos clone` add an `AGENTS.md` (plus a `CLAUDE.md` that
3572
+ imports it) telling coding agents to use these commands. Neither overwrites an
3573
+ existing `AGENTS.md`.
3574
+
3473
3575
  ## Agent feedback
3474
3576
 
3475
3577
  Report errors, confusing behavior, missing docs or capabilities, repeated retries, and
@@ -3582,10 +3684,28 @@ and delegated agent sessions are separate from human users. These are API
3582
3684
  activity observations, **not command counts**.
3583
3685
 
3584
3686
  Coverage includes the native Atlas client, its operator SDK adapter, and
3585
- pipeline assets/contracts fetches to authenticated configured Atlas origins.
3687
+ pipeline assets fetches to authenticated configured Atlas origins.
3586
3688
  Delegated Artifact Studio and ORM CLI transports, Git subprocess traffic,
3587
3689
  third-party storage transfers, login/discovery, and offline commands are not
3588
3690
  instrumented by this change. The Artifact Studio deployment `cliVersion` field
3589
3691
  continues to identify that SDK, not seq-studio. Versions released before this
3590
3692
  instrumentation cannot be identified retroactively. A claimed client/version
3591
3693
  is descriptive telemetry, never proof of which software made a request.
3694
+
3695
+ ### Isolated pipeline release validation
3696
+
3697
+ `seq-studio pipeline validate <directory>` uses the SDK release-contract gate.
3698
+ It automatically reads `<directory>/external-assets.json`; an explicit `--assets`
3699
+ flag takes precedence. Parent-directory files are not a fallback. External
3700
+ serving sources and typed transformation inputs must include full producer
3701
+ columns, not an asset name reconstructed from the consumer projection.
3702
+
3703
+ Pipeline validation never reads ORM contracts. Legacy `orm-contracts.json` and
3704
+ `satisfies` metadata do not gate publication. The `--orm-contracts`,
3705
+ `--scoped-orm-contracts` and `pipeline repin-orm` interfaces have been removed.
3706
+ Publish the backing schema first; the ORM validates its consumer definition
3707
+ when it activates.
3708
+
3709
+ This offline check does not prove existing view shape, backing availability,
3710
+ runtime permissions, or a successful publication. Use hosted plans/rehearsals and
3711
+ actual caller reads to qualify those boundaries.
@@ -15,6 +15,7 @@ import { planRepositoryDeclaration, REPOSITORY_INDEX_PATH, writeRepositoryDeclar
15
15
  import { addSharedPackageToApp } from './workspace-scaffold.js';
16
16
  import { APP_MANIFEST_FILENAME, isPrimitiveKind, PRIMITIVE_KINDS, slugifyAppId, } from './manifest.js';
17
17
  import { addPrimitiveToApp, defaultScaffoldNames, initAppMonorepo, printInitNextSteps, printOrmPreparation, } from './scaffold.js';
18
+ import { warnOnLockfilesOffHostedRegistry } from './lockfile-preflight.js';
18
19
  const LOG = '[seq-studio]';
19
20
  export const APP_INIT_USAGE = `usage:
20
21
  seq-studio init <dir> [options]
@@ -326,6 +327,7 @@ async function initApp({ args, intoCheckout }) {
326
327
  async function prepareApp({ appRoot, manifest }) {
327
328
  try {
328
329
  await prepareScaffoldedApp({ appRoot, manifest });
330
+ await warnOnLockfilesOffHostedRegistry({ rootDir: appRoot, manifest });
329
331
  return true;
330
332
  }
331
333
  catch (error) {
@@ -25,6 +25,7 @@ import { defaultDeployOrder, loadAppManifest, usesAppGraph, } from './manifest.j
25
25
  import { warnOnManifestRoles } from '../manifest-roles-notice.js';
26
26
  import { assertAppEnvironmentBindings } from './env-bindings.js';
27
27
  import { assertAppRepositoryAdmission } from './repository-admission.js';
28
+ import { warnOnLockfilesOffHostedRegistry } from './lockfile-preflight.js';
28
29
  const LOG = '[seq-studio]';
29
30
  const APP_MANIFEST_HINT = 'sequence.app.yml';
30
31
  /**
@@ -124,6 +125,7 @@ async function runDeployApp(options) {
124
125
  console.log(`${LOG} - ${entry.kind.padEnd(9)} ${entry.id} (${entry.path})`);
125
126
  }
126
127
  assertAppDeploymentSource({ manifest, options, rootDir, entries });
128
+ await warnOnLockfilesOffHostedRegistry({ rootDir, manifest, env: options.env });
127
129
  try {
128
130
  await assertAppEnvironmentBindings({
129
131
  manifest,
@@ -0,0 +1,31 @@
1
+ import { type LockfileOrigin } from '../functions/lockfile-origin.js';
2
+ import type { AppManifest } from './manifest.js';
3
+ /**
4
+ * The registry hosted repository CI installs from. Its sandbox reaches only
5
+ * Chainguard Libraries, so a frozen install of a lockfile resolved elsewhere
6
+ * fails there (missing hosts, or integrity mismatches on rebuilt packages).
7
+ */
8
+ export declare const HOSTED_CI_NPM_REGISTRY = "https://libraries.cgr.dev/javascript/";
9
+ export interface LockfileRegistryFinding {
10
+ /** Lockfile path relative to the app root. */
11
+ path: string;
12
+ origin: Exclude<LockfileOrigin, 'chainguard'>;
13
+ }
14
+ /**
15
+ * Every committed-to-be lockfile in an app (the root one and each primitive's
16
+ * own, such as a standalone Next.js artifact) that was not resolved against
17
+ * Chainguard. Mirrors the hosted install gate: only a lockfile carrying a
18
+ * Chainguard tarball pin counts as resolved there.
19
+ */
20
+ export declare function findLockfilesOffHostedRegistry({ rootDir, manifest }: {
21
+ rootDir: string;
22
+ manifest: Pick<AppManifest, 'primitives'>;
23
+ }): Promise<LockfileRegistryFinding[]>;
24
+ /** Copy explaining which lockfiles hosted CI would reject and how to regenerate them. */
25
+ export declare function describeLockfileFindings(findings: readonly LockfileRegistryFinding[]): string[];
26
+ /** Print the findings for an app as warnings; a deployment to `local` never reaches hosted CI. */
27
+ export declare function warnOnLockfilesOffHostedRegistry({ rootDir, manifest, env }: {
28
+ rootDir: string;
29
+ manifest: Pick<AppManifest, 'primitives'>;
30
+ env?: string;
31
+ }): Promise<void>;
@@ -0,0 +1,47 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { join, relative } from 'node:path';
4
+ import { classifyLockfileOrigin } from '../functions/lockfile-origin.js';
5
+ /**
6
+ * The registry hosted repository CI installs from. Its sandbox reaches only
7
+ * Chainguard Libraries, so a frozen install of a lockfile resolved elsewhere
8
+ * fails there (missing hosts, or integrity mismatches on rebuilt packages).
9
+ */
10
+ export const HOSTED_CI_NPM_REGISTRY = 'https://libraries.cgr.dev/javascript/';
11
+ /**
12
+ * Every committed-to-be lockfile in an app (the root one and each primitive's
13
+ * own, such as a standalone Next.js artifact) that was not resolved against
14
+ * Chainguard. Mirrors the hosted install gate: only a lockfile carrying a
15
+ * Chainguard tarball pin counts as resolved there.
16
+ */
17
+ export async function findLockfilesOffHostedRegistry({ rootDir, manifest }) {
18
+ const candidates = [join(rootDir, 'pnpm-lock.yaml'), ...manifest.primitives.map((entry) => join(rootDir, entry.path, 'pnpm-lock.yaml'))];
19
+ const findings = [];
20
+ for (const path of new Set(candidates)) {
21
+ if (!existsSync(path))
22
+ continue;
23
+ const origin = classifyLockfileOrigin(await readFile(path, 'utf8'));
24
+ if (origin !== 'chainguard')
25
+ findings.push({ path: relative(rootDir, path) || 'pnpm-lock.yaml', origin });
26
+ }
27
+ return findings;
28
+ }
29
+ /** Copy explaining which lockfiles hosted CI would reject and how to regenerate them. */
30
+ export function describeLockfileFindings(findings) {
31
+ if (findings.length === 0)
32
+ return [];
33
+ return [
34
+ `hosted repository CI installs only from Chainguard (${HOSTED_CI_NPM_REGISTRY}); these lockfiles were resolved elsewhere and its frozen install would fail:`,
35
+ ...findings.map(({ path, origin }) => ` ${path} (${origin === 'npm' ? 'pins registry.npmjs.org tarballs' : 'no Chainguard resolutions'})`),
36
+ 'Regenerate each in its directory with Chainguard credentials in ~/.npmrc, then commit it:',
37
+ ` rm pnpm-lock.yaml && pnpm install --registry=${HOSTED_CI_NPM_REGISTRY}`,
38
+ ];
39
+ }
40
+ /** Print the findings for an app as warnings; a deployment to `local` never reaches hosted CI. */
41
+ export async function warnOnLockfilesOffHostedRegistry({ rootDir, manifest, env }) {
42
+ if (env === 'local')
43
+ return;
44
+ for (const line of describeLockfileFindings(await findLockfilesOffHostedRegistry({ rootDir, manifest }))) {
45
+ console.warn(`[seq-studio] ${line}`);
46
+ }
47
+ }
@@ -6,7 +6,11 @@ export interface RepositoryDeclaration {
6
6
  content: string;
7
7
  created: boolean;
8
8
  }
9
- export declare function findGitRoot(start: string): string | null;
9
+ /**
10
+ * The nearest directory at or above `start` holding `.git`. Honors Git's
11
+ * `GIT_CEILING_DIRECTORIES`: the search never moves up into a listed directory.
12
+ */
13
+ export declare function findGitRoot(start: string, env?: NodeJS.ProcessEnv): string | null;
10
14
  /** Same containment rule as repository CI: equal, or a descendant of a non-root path. */
11
15
  export declare function under({ path, root }: {
12
16
  path: string;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { existsSync } from 'node:fs';
8
8
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
9
- import { dirname, join, relative, resolve, sep } from 'node:path';
9
+ import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
10
10
  import { isSeq, parseDocument } from 'yaml';
11
11
  import { z } from 'zod';
12
12
  import { APP_MANIFEST_FILENAME } from './manifest.js';
@@ -16,11 +16,17 @@ const indexSchema = z.looseObject({
16
16
  applications: z.array(z.looseObject({ path: z.string().min(1) })).nullish(),
17
17
  ignore: z.array(z.string().min(1)).nullish(),
18
18
  });
19
- export function findGitRoot(start) {
19
+ /**
20
+ * The nearest directory at or above `start` holding `.git`. Honors Git's
21
+ * `GIT_CEILING_DIRECTORIES`: the search never moves up into a listed directory.
22
+ */
23
+ export function findGitRoot(start, env = process.env) {
24
+ const ceilings = new Set((env.GIT_CEILING_DIRECTORIES ?? '').split(delimiter).filter(isAbsolute).map((path) => resolve(path)));
20
25
  for (let directory = resolve(start);; directory = dirname(directory)) {
21
26
  if (existsSync(join(directory, '.git')))
22
27
  return directory;
23
- if (dirname(directory) === directory)
28
+ const parent = dirname(directory);
29
+ if (parent === directory || ceilings.has(parent))
24
30
  return null;
25
31
  }
26
32
  }
package/dist/auth.d.ts CHANGED
@@ -102,16 +102,20 @@ export declare class NotLoggedInError extends Error {
102
102
  constructor(realmName?: string, reason?: string);
103
103
  }
104
104
  /**
105
- * Return a valid access token for an environment's auth realm.
106
- *
107
- * Precedence (default `SEQAPI_AUTH_MODE=auto`), matching seqapi:
108
- * 1. Valid cached user access token
109
- * 2. M2M client-credentials when the realm's secret env var is set
110
- * 3. Bounded PKCE login when browser auto-login is enabled
111
- *
112
- * Set `SEQAPI_AUTH_MODE=m2m` to skip the user token. No `env` (or a built-in
113
- * Sequence env) means the shared Sequence realm.
105
+ * A devbox that receives owner tokens has no live one for this hosted
106
+ * deployment, and no live login of the user's own stood in for it (absent or
107
+ * expired alike). Raised instead of falling back to the shared M2M service
108
+ * account, which would silently act as an admin machine identity rather than
109
+ * the box owner.
114
110
  */
111
+ export declare class DevboxOwnerTokenMissingError extends NotLoggedInError {
112
+ constructor({ realmName, envName, host, tokenFile, }: {
113
+ realmName: string;
114
+ envName: string;
115
+ host: string | null;
116
+ tokenFile: string | null;
117
+ });
118
+ }
115
119
  export declare class UnsafeAuthTargetError extends Error {
116
120
  }
117
121
  /**
package/dist/auth.js CHANGED
@@ -6,7 +6,7 @@ import { join } from 'node:path';
6
6
  import { validateDeploymentAudience, validateDeploymentBaseUrl, } from '@sequenceholdings/artifact-studio/deployment-validation';
7
7
  import { withCrossProcessFileLock } from './file-lock.js';
8
8
  import { isSandboxOrigin, readSandboxToken, SandboxAuthError, sandboxTarget } from './sandbox-auth.js';
9
- import { devboxHostToken } from './host-token.js';
9
+ import { DEVBOX_TOKEN_DIR_ENV, devboxHostToken, devboxTokenFile, devboxTokenHost, isLoopbackUrl } from './host-token.js';
10
10
  function hasErrorCode(error, code) {
11
11
  return error instanceof Error && Reflect.get(error, 'code') === code;
12
12
  }
@@ -407,26 +407,46 @@ export class NotLoggedInError extends Error {
407
407
  }
408
408
  }
409
409
  /**
410
- * Return a valid access token for an environment's auth realm.
411
- *
412
- * Precedence (default `SEQAPI_AUTH_MODE=auto`), matching seqapi:
413
- * 1. Valid cached user access token
414
- * 2. M2M client-credentials when the realm's secret env var is set
415
- * 3. Bounded PKCE login when browser auto-login is enabled
416
- *
417
- * Set `SEQAPI_AUTH_MODE=m2m` to skip the user token. No `env` (or a built-in
418
- * Sequence env) means the shared Sequence realm.
410
+ * A devbox that receives owner tokens has no live one for this hosted
411
+ * deployment, and no live login of the user's own stood in for it (absent or
412
+ * expired alike). Raised instead of falling back to the shared M2M service
413
+ * account, which would silently act as an admin machine identity rather than
414
+ * the box owner.
419
415
  */
416
+ export class DevboxOwnerTokenMissingError extends NotLoggedInError {
417
+ constructor({ realmName, envName, host, tokenFile, }) {
418
+ super(realmName);
419
+ const target = host ? `'${envName}' (${host})` : `'${envName}'`;
420
+ const where = tokenFile ? `${tokenFile} is missing or expired` : `$${DEVBOX_TOKEN_DIR_ENV} has no token for it`;
421
+ this.message =
422
+ `This devbox has no accepted owner token for ${target}: ${where}. ` +
423
+ 'Not falling back to the shared M2M service account.\n' +
424
+ 'For a deployment that should get an owner token, check `ls "$' + DEVBOX_TOKEN_DIR_ENV + '"` after the next refresh (about every 10 minutes). ' +
425
+ 'Set SEQAPI_AUTH_MODE=m2m only if you deliberately want the machine identity.';
426
+ }
427
+ }
420
428
  export class UnsafeAuthTargetError extends Error {
421
429
  }
422
430
  const AUTO_LOGIN_TIMEOUT_MS = 120_000;
423
431
  let autoLoginSuppressed = 0;
432
+ /**
433
+ * Browser auto-login needs someone to finish it. Without a terminal on stdin
434
+ * or stderr (an agent's tool shell, CI) it would only wait out its timeout, so
435
+ * it is skipped unless SEQAPI_AUTO_LOGIN is set to an explicit on value.
436
+ */
424
437
  function autoLoginEnabled() {
425
438
  if (autoLoginSuppressed > 0)
426
439
  return false;
427
- const value = process.env.SEQAPI_AUTO_LOGIN?.trim().toLowerCase() ?? '1';
428
- return !['0', 'false', 'no', 'off'].includes(value);
440
+ const value = process.env.SEQAPI_AUTO_LOGIN?.trim().toLowerCase();
441
+ if (value !== undefined && value !== '')
442
+ return !['0', 'false', 'no', 'off'].includes(value);
443
+ return hasInteractiveTerminal();
444
+ }
445
+ function hasInteractiveTerminal() {
446
+ return Boolean(process.stdin.isTTY || process.stderr.isTTY);
429
447
  }
448
+ const NO_TERMINAL_HINT = 'Browser sign-in was skipped because this shell has no terminal. ' +
449
+ 'Sign in from an interactive terminal, or set SEQAPI_AUTO_LOGIN=1 to open the browser login anyway.';
430
450
  /**
431
451
  * Run `fn` without opening a browser login: a missing or expired session
432
452
  * raises `NotLoggedInError` instead. For commands such as `deploy --dry-run`
@@ -450,7 +470,8 @@ function autoLoginTimeoutMs() {
450
470
  }
451
471
  async function reauthenticateOrThrow({ reason, realm, }) {
452
472
  if (!autoLoginEnabled()) {
453
- throw new NotLoggedInError(realm.name, reason);
473
+ const skippedForTerminal = autoLoginSuppressed === 0 && !process.env.SEQAPI_AUTO_LOGIN?.trim() && !hasInteractiveTerminal();
474
+ throw new NotLoggedInError(realm.name, skippedForTerminal ? `${reason} ${NO_TERMINAL_HINT}` : reason);
454
475
  }
455
476
  try {
456
477
  const { loginWithPkce } = await import('./login.js');
@@ -495,6 +516,42 @@ async function devboxAccessToken(targetUrl) {
495
516
  const token = targetUrl ? await devboxHostToken(targetUrl) : null;
496
517
  return token ? { authMode: 'user', token } : null;
497
518
  }
519
+ /**
520
+ * Whether this box receives devbox owner tokens and the request targets a
521
+ * hosted deployment (not loopback), so an implicit M2M fallback is refused.
522
+ * An explicit SEQAPI_AUTH_MODE=m2m still selects the machine identity.
523
+ */
524
+ function devboxForbidsM2mFallback(options = {}) {
525
+ if (!process.env[DEVBOX_TOKEN_DIR_ENV]?.trim() || authModePrefersM2m())
526
+ return false;
527
+ // The box's own Atlas can hold a `localhost` owner token too, but it is not
528
+ // a hosted deployment, so it keeps the M2M fallback.
529
+ if (options.targetUrl)
530
+ return !isLoopbackUrl(options.targetUrl) && devboxTokenFile(options.targetUrl) !== null;
531
+ return !(options.env && isLoopbackEnvName(options.env));
532
+ }
533
+ /** Whether a configured M2M credential would actually be selected for this target. */
534
+ function m2mSelectable(configured, options) {
535
+ return configured && !devboxForbidsM2mFallback(options);
536
+ }
537
+ function devboxOwnerTokenMissing(options, realm) {
538
+ return new DevboxOwnerTokenMissingError({
539
+ realmName: realm.name,
540
+ envName: options.env ?? realm.name,
541
+ host: options.targetUrl ? devboxTokenHost(options.targetUrl) : null,
542
+ tokenFile: options.targetUrl ? devboxTokenFile(options.targetUrl) : null,
543
+ });
544
+ }
545
+ /**
546
+ * The M2M token for `realm`, except that a devbox with no owner token for a
547
+ * hosted target never borrows the shared machine identity: it throws
548
+ * DevboxOwnerTokenMissingError instead.
549
+ */
550
+ async function m2mTokenFor(realm, target) {
551
+ if (devboxForbidsM2mFallback(target))
552
+ throw devboxOwnerTokenMissing(target, realm);
553
+ return getM2mToken(realm);
554
+ }
498
555
  /**
499
556
  * The user's own unexpired cached login for this environment, or null. Never
500
557
  * refreshes, logs in, or throws: it only decides whether a login the user
@@ -520,9 +577,9 @@ async function liveCachedUserLogin(options) {
520
577
  /**
521
578
  * A token the environment supplies rather than a login: the sandbox bearer,
522
579
  * else a devbox owner token. A live login of the user's own for the same
523
- * deployment beats the devbox token: the user made it deliberately (the
524
- * box's sign-in page), and it keeps working on a deployment that does not
525
- * accept the box's token yet. Without one, the devbox token is used as before.
580
+ * deployment beats the devbox token: the user made it deliberately, and it
581
+ * keeps working on a deployment that does not accept the box's token.
582
+ * Without one, the devbox token is used.
526
583
  */
527
584
  async function ambientAccessToken(options) {
528
585
  const sandbox = await sandboxAccessToken(options.targetUrl);
@@ -533,10 +590,24 @@ async function ambientAccessToken(options) {
533
590
  return null;
534
591
  return (await liveCachedUserLogin(options)) ?? devbox;
535
592
  }
593
+ /**
594
+ * Return a valid access token for an environment's auth realm.
595
+ *
596
+ * Precedence (default `SEQAPI_AUTH_MODE=auto`), matching seqapi:
597
+ * 0. Sandbox bearer, else a devbox owner token for the target host
598
+ * 1. Valid cached user access token
599
+ * 2. M2M client-credentials when the realm's secret env var is set, except
600
+ * on a devbox targeting a hosted deployment (DevboxOwnerTokenMissingError)
601
+ * 3. Bounded PKCE login when browser auto-login is enabled and a terminal exists
602
+ *
603
+ * Set `SEQAPI_AUTH_MODE=m2m` to skip the user token. No `env` (or a built-in
604
+ * Sequence env) means the shared Sequence realm.
605
+ */
536
606
  async function resolveAccessTokenWithMode(options) {
607
+ const target = { env: options?.env, targetUrl: options?.targetUrl };
537
608
  // Sandbox token mode replaces every other source, before any realm lookup;
538
609
  // then a devbox owner's login for the target host.
539
- const ambient = await ambientAccessToken({ env: options?.env, targetUrl: options?.targetUrl });
610
+ const ambient = await ambientAccessToken(target);
540
611
  if (ambient)
541
612
  return ambient;
542
613
  const realm = await realmForEnv(options?.env, { targetUrl: options?.targetUrl });
@@ -551,7 +622,7 @@ async function resolveAccessTokenWithMode(options) {
551
622
  return { authMode: 'user', token: tokens.access_token };
552
623
  }
553
624
  }
554
- const m2m = await getM2mToken(realm);
625
+ const m2m = await m2mTokenFor(realm, target);
555
626
  if (m2m)
556
627
  return { authMode: 'm2m', token: m2m };
557
628
  if (forceM2m) {
@@ -612,6 +683,11 @@ export async function tryGetAccessTokenWithMode(options) {
612
683
  throw err;
613
684
  if (err instanceof SandboxAuthError)
614
685
  throw err;
686
+ // A lookup that names no deployment (offline ORM codegen and validation)
687
+ // still refuses the shared M2M identity on a devbox, but runs without a
688
+ // token rather than failing, as seqapi does for env=None.
689
+ if (err instanceof DevboxOwnerTokenMissingError && !options?.env && !options?.targetUrl)
690
+ return null;
615
691
  if (options?.failClosedForM2m) {
616
692
  // Do not replace an invalid tenant registration with the Sequence realm:
617
693
  // that could hide a rejected discovery token host or inspect the wrong
@@ -643,6 +719,8 @@ export async function inspectAuthPreflight(options) {
643
719
  const realmVerified = !(options?.offline && options.env && isLoopbackEnvName(options.env));
644
720
  const cachePath = seqapiTokenPath();
645
721
  const credentialConfigured = Boolean(realm.m2mClientId && process.env[m2mSecretEnvName(realm)]?.trim());
722
+ // A devbox refuses the implicit M2M fallback for hosted targets (see resolveAccessTokenWithMode).
723
+ const m2mUsable = m2mSelectable(credentialConfigured, options);
646
724
  let file;
647
725
  try {
648
726
  file = await readTokenFile();
@@ -668,7 +746,7 @@ export async function inspectAuthPreflight(options) {
668
746
  };
669
747
  }
670
748
  if (!file) {
671
- const selectedCredential = credentialConfigured ? 'm2m' : 'none';
749
+ const selectedCredential = m2mUsable ? 'm2m' : 'none';
672
750
  return {
673
751
  authMode,
674
752
  realm: realm.name,
@@ -699,7 +777,7 @@ export async function inspectAuthPreflight(options) {
699
777
  : 'none'
700
778
  : userState === 'valid'
701
779
  ? 'user'
702
- : credentialConfigured
780
+ : m2mUsable
703
781
  ? 'm2m'
704
782
  : 'none';
705
783
  return {