@segmentstream/ontology 0.170.2 → 0.171.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.171.0
4
+
5
+ A deployment that changes the ontology no longer refuses file operations or workflow actions
6
+ while it switches over. Before, once the deployment had migrated the catalog, the running version
7
+ answered every file download, upload and action that takes a file with the retryable 503
8
+ `ontology_updating` until the new version was promoted, about a minute and a half. Pipeline
9
+ worker actions were refused in that window too. A workflow run that the earlier deployment had
10
+ started was refused at every action, even after the promotion, and a workflow step fails on that
11
+ refusal, so those runs died at their next action. Now the running version serves files as it serves
12
+ every other request, waiting only while the migration's transaction holds the catalog. A run in
13
+ flight keeps acting with the code that started it against the new catalog, as the SDK's
14
+ deployment notes describe.
15
+
16
+ An upload stays tied to the version that started it: one started before the switch and saved
17
+ after it is refused, and the client starts it again.
18
+
19
+ The service no longer answers `ontology_updating`, and `PermissionDenied` no longer carries
20
+ `updating`. A workspace that retries `ontology_updating` itself can drop that retry after
21
+ upgrading.
22
+
3
23
  ## 0.170.2
4
24
 
5
25
  Workspace apps and ontology services call the production API at segmentstream.com. Existing signed token issuers, OAuth registrations and custom API origins continue to work.
package/README.md CHANGED
@@ -1744,9 +1744,8 @@ action takes several uploads of the entity, `record_id` when it changes an exist
1744
1744
  `transfer.headers`, calls `files_upload_complete` with `upload.id` for `upload.ticket`, then
1745
1745
  calls the action tool with the ticket in its upload field and `_options` set to `options`. Both
1746
1746
  tools run the REST upload sessions above, with the same checks, limits and permissions. A
1747
- failure of the storage provider answers `storage_unavailable`, and a request made while a
1748
- deployment migrates the catalog answers `ontology_updating`; both are 503s with
1749
- `retryable: true`, so the client repeats the same call, ideally with its own `idempotency_key`.
1747
+ failure of the storage provider answers `storage_unavailable`, a 503 with `retryable: true`, so
1748
+ the client repeats the same call, ideally with its own `idempotency_key`.
1750
1749
  While a failed attempt still holds an upload, a retry answers 409 `conflict` with
1751
1750
  `retryable: true` and `retry_after` seconds; a conflict without `retryable` cannot resume.
1752
1751
 
package/dist/errors.d.ts CHANGED
@@ -85,11 +85,6 @@ declare const PermissionDenied_base: Schema.Class<PermissionDenied, Schema.Tagge
85
85
  readonly message: Schema.String;
86
86
  /** The permission that is missing, for example `lead:changeStatus`. */
87
87
  readonly permission: Schema.optionalKey<Schema.String>;
88
- /**
89
- * Refused only because the running ontology and the database catalog differ, as while a
90
- * deployment migrates. The caller retries the same request.
91
- */
92
- readonly updating: Schema.optionalKey<Schema.Literal<true>>;
93
88
  }>, import("effect/Cause").YieldableError>;
94
89
  /**
95
90
  * The principal's roles do not grant a permission the request requires. The service answers 403
package/dist/errors.js CHANGED
@@ -61,11 +61,6 @@ export class PermissionDenied extends Schema.TaggedError()("PermissionDenied", {
61
61
  message: Schema.String,
62
62
  /** The permission that is missing, for example `lead:changeStatus`. */
63
63
  permission: Schema.optionalKey(Schema.String),
64
- /**
65
- * Refused only because the running ontology and the database catalog differ, as while a
66
- * deployment migrates. The caller retries the same request.
67
- */
68
- updating: Schema.optionalKey(Schema.Literal(true)),
69
64
  }) {
70
65
  }
71
66
  // @legacy ontology.workflow-cutover-artifacts
@@ -506,19 +506,7 @@ export function expectedFailure(error, requestId) {
506
506
  };
507
507
  }
508
508
  if (Predicate.isTagged(error, "PermissionDenied")) {
509
- const { permission, updating } = error;
510
- if (updating === true) {
511
- return {
512
- status: 503,
513
- body: {
514
- error: "ontology_updating",
515
- detail: "The app is being updated. Retry the same request shortly.",
516
- requestId,
517
- retryable: true,
518
- },
519
- headers: { "retry-after": "5" },
520
- };
521
- }
509
+ const { permission } = error;
522
510
  return {
523
511
  status: 403,
524
512
  body: {
@@ -620,7 +620,9 @@ export const ErrorSchemas = {
620
620
  rateLimited: errorBody("RateLimited", 429, ["rate_limited"]),
621
621
  internal: errorBody("InternalError", 500, ["internal_error"]),
622
622
  unavailable: errorBody("ServiceUnavailable", 503, ["service_unavailable"]),
623
- storageUnavailable: errorBody("StorageUnavailable", 503, ["storage_unavailable", "ontology_updating"], { retryable: Schema.Boolean }),
623
+ storageUnavailable: errorBody("StorageUnavailable", 503, ["storage_unavailable"], {
624
+ retryable: Schema.Boolean,
625
+ }),
624
626
  invalidMetricQuery: errorBody("InvalidMetricQuery", 400, ["invalid_aggregate_query"]),
625
627
  readForbidden: errorBody("ReadForbidden", 403, ["forbidden", "scoped_aggregate_unavailable"], {
626
628
  permissions: Schema.optionalKey(Schema.Array(Schema.String)),
@@ -11,17 +11,10 @@ export function authorizeBlobOperation(ontology, sql, principalId, required, exe
11
11
  /** The workflow a workflow user's principal acts for, with its subject in this workspace. */
12
12
  workflowPrincipal) {
13
13
  return Effect.gen(function* () {
14
- const [catalog] = yield* sql.unsafe(`SELECT hash FROM "_ontology" WHERE id = true FOR SHARE`, []);
15
- if (catalog?.hash !== ontology.manifest.hash) {
16
- yield* Effect.logWarning("ontology.storage.catalog_mismatch", {
17
- servedHash: ontology.manifest.hash,
18
- appliedHash: catalog?.hash ?? null,
19
- });
20
- return yield* new PermissionDenied({
21
- message: "The deployed ontology no longer matches the database catalog.",
22
- updating: true,
23
- });
24
- }
14
+ // Lock the catalog first, in the order a migration takes it, so this operation waits for a
15
+ // migration in progress rather than deadlocking with it. A catalog that differs from the one
16
+ // this version serves is not refused: the version keeps serving until the next is promoted.
17
+ yield* sql.unsafe(`SELECT 1 FROM "_ontology" WHERE id = true FOR SHARE`, []);
25
18
  const users = yield* sql.unsafe(`SELECT kind::text, active, identity_provider, identity_subject FROM "user" WHERE id = $1::uuid FOR SHARE`, [principalId]);
26
19
  const user = users[0];
27
20
  const roles = yield* sql.unsafe(`SELECT role FROM "_user_roles" WHERE user_id = $1::uuid FOR SHARE`, [principalId]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.170.2",
3
+ "version": "0.171.0",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",