@substrat-run/kernel 0.218.0 → 0.220.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.
Files changed (70) hide show
  1. package/dist/app-environments.d.ts +62 -0
  2. package/dist/app-environments.d.ts.map +1 -0
  3. package/dist/app-environments.js +116 -0
  4. package/dist/app-environments.js.map +1 -0
  5. package/dist/attachment-text.d.ts +89 -0
  6. package/dist/attachment-text.d.ts.map +1 -1
  7. package/dist/attachment-text.js +134 -1
  8. package/dist/attachment-text.js.map +1 -1
  9. package/dist/broker-relay-scope.d.ts +53 -0
  10. package/dist/broker-relay-scope.d.ts.map +1 -0
  11. package/dist/broker-relay-scope.js +77 -0
  12. package/dist/broker-relay-scope.js.map +1 -0
  13. package/dist/broker-relay.d.ts +5 -1
  14. package/dist/broker-relay.d.ts.map +1 -1
  15. package/dist/broker-relay.js.map +1 -1
  16. package/dist/broker-schema.d.ts.map +1 -1
  17. package/dist/broker-schema.js +12 -0
  18. package/dist/broker-schema.js.map +1 -1
  19. package/dist/connect-intent.d.ts +24 -0
  20. package/dist/connect-intent.d.ts.map +1 -0
  21. package/dist/connect-intent.js +25 -0
  22. package/dist/connect-intent.js.map +1 -0
  23. package/dist/connection-context.d.ts +30 -0
  24. package/dist/connection-context.d.ts.map +1 -1
  25. package/dist/connection-context.js.map +1 -1
  26. package/dist/delivery-broker.d.ts +77 -1
  27. package/dist/delivery-broker.d.ts.map +1 -1
  28. package/dist/delivery-broker.js +112 -8
  29. package/dist/delivery-broker.js.map +1 -1
  30. package/dist/delivery-contract.d.ts +36 -0
  31. package/dist/delivery-contract.d.ts.map +1 -0
  32. package/dist/delivery-contract.js +84 -0
  33. package/dist/delivery-contract.js.map +1 -0
  34. package/dist/directory-lake-keep.d.ts.map +1 -1
  35. package/dist/directory-lake-keep.js +4 -0
  36. package/dist/directory-lake-keep.js.map +1 -1
  37. package/dist/email-intent.d.ts +32 -0
  38. package/dist/email-intent.d.ts.map +1 -1
  39. package/dist/email-intent.js +66 -1
  40. package/dist/email-intent.js.map +1 -1
  41. package/dist/entity-trash.d.ts +45 -0
  42. package/dist/entity-trash.d.ts.map +1 -1
  43. package/dist/entity-trash.js +52 -0
  44. package/dist/entity-trash.js.map +1 -1
  45. package/dist/index.d.ts +15 -8
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +15 -4
  48. package/dist/index.js.map +1 -1
  49. package/dist/release-within-major.d.ts +173 -0
  50. package/dist/release-within-major.d.ts.map +1 -0
  51. package/dist/release-within-major.js +283 -0
  52. package/dist/release-within-major.js.map +1 -0
  53. package/dist/reserved-roles.d.ts +6 -0
  54. package/dist/reserved-roles.d.ts.map +1 -1
  55. package/dist/reserved-roles.js.map +1 -1
  56. package/dist/scope-copy.d.ts.map +1 -1
  57. package/dist/scope-copy.js +6 -0
  58. package/dist/scope-copy.js.map +1 -1
  59. package/dist/scope-host.d.ts +66 -2
  60. package/dist/scope-host.d.ts.map +1 -1
  61. package/dist/scope-host.js.map +1 -1
  62. package/dist/scope-identity.d.ts +10 -1
  63. package/dist/scope-identity.d.ts.map +1 -1
  64. package/dist/scope-identity.js +12 -3
  65. package/dist/scope-identity.js.map +1 -1
  66. package/dist/scope-types.d.ts +57 -0
  67. package/dist/scope-types.d.ts.map +1 -0
  68. package/dist/scope-types.js +76 -0
  69. package/dist/scope-types.js.map +1 -0
  70. package/package.json +3 -3
@@ -0,0 +1,62 @@
1
+ /**
2
+ * An app's environments (D-83, #3530 step 3), written once so both adapters' directories cannot
3
+ * disagree about any of it.
4
+ *
5
+ * **Production is never stored.** It is what runs: the tenant's installs of the app, the serving
6
+ * script and the channel `prod`. `environmentsOf` answers it first, read off the scopes, so an app
7
+ * that runs today reads as production with no row, no backfill and no step by anyone.
8
+ *
9
+ * **A named environment is a row over a tagged, pinned preview.** `app_environments` holds the name
10
+ * per (tenant, app). Its scope is the preview whose slug is `<app>--<name>` (`previewScopeSlug`, the
11
+ * rule the preview routes look a tag up by), resolved at read, not stored: a `--refresh` reaps the
12
+ * old preview and mints a new scope id under the same tag, and the environment follows it. A row is
13
+ * written only over a preview that exists, is active and is pinned (no expiry), so an environment is
14
+ * never a pointer without scopes, which is what `dev` and `staging` were when #509 retired them.
15
+ *
16
+ * What is deliberately not here: a serving script of the environment's own, edges, connections and
17
+ * a broker per environment (D-83 steps 4 to 6). A named environment is a preview, so it is inert.
18
+ */
19
+ import { type AppEnvironment, type ScopeId, type TenantId } from '@substrat-run/contracts';
20
+ import type { SwitchSql } from './system-switch.js';
21
+ /** Directory-owned, on both adapters. One row per named environment; production has none. */
22
+ export declare const APP_ENVIRONMENTS_DDL = "\n CREATE TABLE IF NOT EXISTS app_environments (\n tenant_id TEXT NOT NULL,\n vertical TEXT NOT NULL,\n name TEXT NOT NULL,\n created_at TEXT NOT NULL,\n created_by TEXT NOT NULL,\n PRIMARY KEY (tenant_id, vertical, name)\n );\n";
23
+ /**
24
+ * A preview's scope slug: `<app>--<tag>`, the app's last path segment (`t-acme/crm` → `crm`). The
25
+ * preview routes find a tag by it, and an environment finds its preview by it.
26
+ */
27
+ export declare const previewScopeSlug: (vertical: string, tag: string) => string;
28
+ /**
29
+ * The app's environments in the tenant: production first, always, then each named one by name.
30
+ * A tenant with no install of the app still has production, with no scopes.
31
+ */
32
+ export declare function environmentsOf(sql: SwitchSql, tenantId: TenantId, vertical: string): AppEnvironment[];
33
+ /** Whether `tag` names one of the app's environments in the tenant: the preview routes keep it pinned. */
34
+ export declare function isEnvironmentTag(sql: SwitchSql, tenantId: string, vertical: string, tag: string): boolean;
35
+ export interface DefineEnvironmentInput {
36
+ tenantId: TenantId;
37
+ vertical: string;
38
+ name: string;
39
+ }
40
+ /**
41
+ * Name the app's preview tagged `name` an environment. Read, decided and written in the caller's
42
+ * one directory transaction. Refuses a name that is not a label or is `prod`, a preview that does
43
+ * not exist, is not active, or expires. Defining a name that is already an environment changes
44
+ * nothing (`created: false`).
45
+ */
46
+ export declare function defineEnvironmentIn(sql: SwitchSql, input: DefineEnvironmentInput, stamp: {
47
+ at: string;
48
+ by: string;
49
+ }): {
50
+ environment: AppEnvironment;
51
+ created: boolean;
52
+ scopeId: ScopeId;
53
+ };
54
+ /**
55
+ * Take the name off: the row goes, and the preview stays, an ordinary pinned preview again. Removing
56
+ * production is refused; a name that is no environment is `removed: false`.
57
+ */
58
+ export declare function removeEnvironmentIn(sql: SwitchSql, input: DefineEnvironmentInput): {
59
+ removed: boolean;
60
+ scopeId: ScopeId | null;
61
+ };
62
+ //# sourceMappingURL=app-environments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-environments.d.ts","sourceRoot":"","sources":["../src/app-environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAA0D,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnJ,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,6PAShC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,aAAc,MAAM,OAAO,MAAM,KAAG,MAAiD,CAAC;AAwBnH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CAsBrG;AAED,0GAA0G;AAC1G,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAEzG;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,WAAW,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAwBrE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,sBAAsB,GAC5B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAS/C"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * An app's environments (D-83, #3530 step 3), written once so both adapters' directories cannot
3
+ * disagree about any of it.
4
+ *
5
+ * **Production is never stored.** It is what runs: the tenant's installs of the app, the serving
6
+ * script and the channel `prod`. `environmentsOf` answers it first, read off the scopes, so an app
7
+ * that runs today reads as production with no row, no backfill and no step by anyone.
8
+ *
9
+ * **A named environment is a row over a tagged, pinned preview.** `app_environments` holds the name
10
+ * per (tenant, app). Its scope is the preview whose slug is `<app>--<name>` (`previewScopeSlug`, the
11
+ * rule the preview routes look a tag up by), resolved at read, not stored: a `--refresh` reaps the
12
+ * old preview and mints a new scope id under the same tag, and the environment follows it. A row is
13
+ * written only over a preview that exists, is active and is pinned (no expiry), so an environment is
14
+ * never a pointer without scopes, which is what `dev` and `staging` were when #509 retired them.
15
+ *
16
+ * What is deliberately not here: a serving script of the environment's own, edges, connections and
17
+ * a broker per environment (D-83 steps 4 to 6). A named environment is a preview, so it is inert.
18
+ */
19
+ import { PRODUCTION_ENVIRONMENT, environmentName, substratError } from '@substrat-run/contracts';
20
+ import { isPrimaryScopeRow } from './scope-identity.js';
21
+ /** Directory-owned, on both adapters. One row per named environment; production has none. */
22
+ export const APP_ENVIRONMENTS_DDL = `
23
+ CREATE TABLE IF NOT EXISTS app_environments (
24
+ tenant_id TEXT NOT NULL,
25
+ vertical TEXT NOT NULL,
26
+ name TEXT NOT NULL,
27
+ created_at TEXT NOT NULL,
28
+ created_by TEXT NOT NULL,
29
+ PRIMARY KEY (tenant_id, vertical, name)
30
+ );
31
+ `;
32
+ /**
33
+ * A preview's scope slug: `<app>--<tag>`, the app's last path segment (`t-acme/crm` → `crm`). The
34
+ * preview routes find a tag by it, and an environment finds its preview by it.
35
+ */
36
+ export const previewScopeSlug = (vertical, tag) => `${vertical.split('/').at(-1)}--${tag}`;
37
+ /** Every scope of the app in the tenant that is not archived or reaped, oldest first. */
38
+ function liveScopesOf(sql, tenantId, vertical) {
39
+ return sql.all(`SELECT scope_id, kind, slug, forked_from, status, expires_at FROM scopes
40
+ WHERE tenant_id = ? AND vertical = ? AND status NOT IN ('archived', 'reaped')
41
+ ORDER BY scope_id`, tenantId, vertical);
42
+ }
43
+ const previewOf = (scopes, vertical, name) => scopes.find((s) => s.kind === 'preview' && s.slug === previewScopeSlug(vertical, name));
44
+ /**
45
+ * The app's environments in the tenant: production first, always, then each named one by name.
46
+ * A tenant with no install of the app still has production, with no scopes.
47
+ */
48
+ export function environmentsOf(sql, tenantId, vertical) {
49
+ const scopes = liveScopesOf(sql, tenantId, vertical);
50
+ const production = {
51
+ tenantId, vertical, name: PRODUCTION_ENVIRONMENT, production: true,
52
+ scopeIds: scopes.filter((s) => isPrimaryScopeRow(s)).map((s) => s.scope_id),
53
+ createdAt: null, createdBy: null,
54
+ };
55
+ const rows = sql.all('SELECT name, created_at, created_by FROM app_environments WHERE tenant_id = ? AND vertical = ? ORDER BY name', tenantId, vertical);
56
+ return [
57
+ production,
58
+ ...rows.map((r) => {
59
+ const preview = previewOf(scopes, vertical, r.name);
60
+ return {
61
+ tenantId, vertical, name: r.name, production: false,
62
+ scopeIds: preview ? [preview.scope_id] : [],
63
+ createdAt: r.created_at, createdBy: r.created_by,
64
+ };
65
+ }),
66
+ ];
67
+ }
68
+ /** Whether `tag` names one of the app's environments in the tenant: the preview routes keep it pinned. */
69
+ export function isEnvironmentTag(sql, tenantId, vertical, tag) {
70
+ return sql.all('SELECT 1 FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?', tenantId, vertical, tag).length > 0;
71
+ }
72
+ /**
73
+ * Name the app's preview tagged `name` an environment. Read, decided and written in the caller's
74
+ * one directory transaction. Refuses a name that is not a label or is `prod`, a preview that does
75
+ * not exist, is not active, or expires. Defining a name that is already an environment changes
76
+ * nothing (`created: false`).
77
+ */
78
+ export function defineEnvironmentIn(sql, input, stamp) {
79
+ const parsed = environmentName.safeParse(input.name);
80
+ if (!parsed.success)
81
+ throw substratError('validation_failed', parsed.error.issues[0]?.message ?? 'invalid environment name');
82
+ const { tenantId, vertical, name } = input;
83
+ const preview = previewOf(liveScopesOf(sql, tenantId, vertical), vertical, name);
84
+ const create = `substrat preview create --tag ${name} --ttl none`;
85
+ if (!preview) {
86
+ throw substratError('not_found', `no preview tagged '${name}' for '${vertical}': an environment is built on one, so create it first (${create})`);
87
+ }
88
+ if (preview.status !== 'active') {
89
+ throw substratError('conflict', `the preview tagged '${name}' is ${preview.status}, not active: wait for its create to finish, then try again`);
90
+ }
91
+ if (preview.expires_at !== null) {
92
+ throw substratError('conflict', `the preview tagged '${name}' expires at ${preview.expires_at}: an environment is pinned, so pin it first (${create})`);
93
+ }
94
+ const created = !isEnvironmentTag(sql, tenantId, vertical, name);
95
+ if (created) {
96
+ sql.run('INSERT INTO app_environments (tenant_id, vertical, name, created_at, created_by) VALUES (?, ?, ?, ?, ?)', tenantId, vertical, name, stamp.at, stamp.by);
97
+ }
98
+ const environment = environmentsOf(sql, tenantId, vertical).find((e) => !e.production && e.name === name);
99
+ return { environment, created, scopeId: preview.scope_id };
100
+ }
101
+ /**
102
+ * Take the name off: the row goes, and the preview stays, an ordinary pinned preview again. Removing
103
+ * production is refused; a name that is no environment is `removed: false`.
104
+ */
105
+ export function removeEnvironmentIn(sql, input) {
106
+ if (input.name === PRODUCTION_ENVIRONMENT) {
107
+ throw substratError('conflict', `'${PRODUCTION_ENVIRONMENT}' is the production environment, which every app has: it cannot be removed`);
108
+ }
109
+ const { tenantId, vertical, name } = input;
110
+ if (!isEnvironmentTag(sql, tenantId, vertical, name))
111
+ return { removed: false, scopeId: null };
112
+ const preview = previewOf(liveScopesOf(sql, tenantId, vertical), vertical, name);
113
+ sql.run('DELETE FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?', tenantId, vertical, name);
114
+ return { removed: true, scopeId: preview?.scope_id ?? null };
115
+ }
116
+ //# sourceMappingURL=app-environments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-environments.js","sourceRoot":"","sources":["../src/app-environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,aAAa,EAAoD,MAAM,yBAAyB,CAAC;AACnJ,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;CASnC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAE,GAAW,EAAU,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;AAWnH,yFAAyF;AACzF,SAAS,YAAY,CAAC,GAAc,EAAE,QAAgB,EAAE,QAAgB;IACtE,OAAO,GAAG,CAAC,GAAG,CACZ;;wBAEoB,EACpB,QAAQ,EAAE,QAAQ,CACM,CAAC;AAC7B,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,MAA2B,EAAE,QAAgB,EAAE,IAAY,EAAwB,EAAE,CACtG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB,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AO,EAAE,QAAgC,IAAI,IAAI,EAAE,CAAC;AACxF,CAAC"}
@@ -86,10 +86,16 @@ export declare const ATTACHMENT_TEXT_MODULE: ModuleId;
86
86
  export declare const ATTACHMENT_TEXT_JOB = "attachment-text";
87
87
  /** The backfill's job name: queues extraction for attachments that predate it. */
88
88
  export declare const ATTACHMENT_TEXT_BACKFILL_JOB = "attachment-text-backfill";
89
+ /**
90
+ * The recheck's job name: queues extraction again for attachments recorded `unsupported`
91
+ * that an extractor the host has now reads. One run per scope per extractor set.
92
+ */
93
+ export declare const ATTACHMENT_TEXT_RECHECK_JOB = "attachment-text-recheck";
89
94
  /** The kernel's own jobs, each bound by the adapter to the scope it is driving. */
90
95
  export interface KernelJobHandlers {
91
96
  readonly [ATTACHMENT_TEXT_JOB]: JobHandler;
92
97
  readonly [ATTACHMENT_TEXT_BACKFILL_JOB]: JobHandler;
98
+ readonly [ATTACHMENT_TEXT_RECHECK_JOB]: JobHandler;
93
99
  }
94
100
  /**
95
101
  * The kernel's handler for a run, or undefined for a run that is not the kernel's — which the
@@ -231,6 +237,89 @@ export declare function queueAttachmentTextBackfill(sql: ScopedSql, after: strin
231
237
  export declare function attachmentTextBackfillJob(source: {
232
238
  queueBatch(after: string | null): Promise<AttachmentTextBackfillBatch>;
233
239
  }): JobHandler;
240
+ /**
241
+ * The extractor set a recheck run is keyed by: the host's extractor names, sorted and
242
+ * comma-joined (`docx,html,pdf,pptx,text,xlsx`). Empty for a host with none.
243
+ *
244
+ * `unsupported` is a fact about the HOST, not about the file: it says no extractor that host
245
+ * had read the type. A host that gains one — a release that adds PDF to its parsers — would
246
+ * otherwise leave every attachment recorded before it unsearchable for good, since nothing
247
+ * ever queues an attachment that already has a text row. The name stands for what an
248
+ * extractor reads; a change to what one extractor accepts under the same name is not seen.
249
+ */
250
+ export declare function attachmentExtractorSetKey(extractors: readonly AttachmentExtractor[]): string;
251
+ /**
252
+ * Start the scope's recheck for this extractor set, unless the scope's newest recheck is for
253
+ * this set already, or it holds no attachments, or the host has no extractor at all.
254
+ *
255
+ * **The newest recheck run is the marker**, as the run row is for the backfill
256
+ * (`startAttachmentTextBackfill`), but compared by set: its instance is the set's key. A
257
+ * deployment that keeps its extractors walks nothing again, and one whose extractors change
258
+ * starts one walk in each scope it drives. That includes a change BACK: a release rolled
259
+ * back to a set without some extractor records what it cannot read `unsupported`, and the
260
+ * release rolled forward again must read those, so "this set has walked once" is not the
261
+ * test — "this set is the last one that walked" is. Alternating two sets costs a walk per
262
+ * change, and one script drives a scope with one set, so a change is a deploy.
263
+ *
264
+ * A host whose set is empty starts nothing: it reads nothing, so there is nothing to queue.
265
+ * Its window is not covered — a release that drops every extractor and one that restores the
266
+ * same set leave what was uploaded between them `unsupported`.
267
+ *
268
+ * Read before it writes, so the drive that calls it on every pass writes nothing once the
269
+ * scope is marked: two index reads. Returns whether it started a run (a live run for the
270
+ * set already, which `startKernelRun` coalesces with, is not a start).
271
+ */
272
+ export declare function startAttachmentTextRecheck(sql: ScopedSql, extractorSet: string, runId: string, at: string): boolean;
273
+ /** An attachment recorded `unsupported`, with what an extractor's `accepts` is asked about. */
274
+ export interface UnsupportedAttachment {
275
+ readonly id: string;
276
+ readonly contentType: string;
277
+ readonly filename: string;
278
+ }
279
+ /** One page of the recheck's walk. `last` is the cursor the next page resumes after. */
280
+ export interface AttachmentTextRecheckPage {
281
+ readonly scanned: number;
282
+ readonly unsupported: readonly UnsupportedAttachment[];
283
+ readonly last: string | null;
284
+ /** True when the page reached the end of the text rows. */
285
+ readonly done: boolean;
286
+ }
287
+ /**
288
+ * One page of the recheck: the next `batch` text rows after `after`, by attachment id, and
289
+ * those of them recorded `unsupported`. Bounded by what it LOOKS AT, like the backfill's
290
+ * batch, so a scope with no `unsupported` row costs the same pass as one full of them. Only
291
+ * reads: which of them an extractor now reads is the host's to decide (`accepts` is code),
292
+ * and the queueing is `requeueUnsupportedAttachmentText`.
293
+ */
294
+ export declare function readAttachmentTextRecheckPage(sql: ScopedSql, after: string | null, batch?: number): AttachmentTextRecheckPage;
295
+ /**
296
+ * Queue extraction again for these attachments, inside the caller's transaction — each only
297
+ * while its row is still `unsupported` and no extraction run for it is live. The page was
298
+ * read in an earlier call, so by now an attachment may be gone (its trigger took the row),
299
+ * re-uploaded or already re-queued: none of those is touched, which also makes a replayed
300
+ * page queue nothing twice. A live run is left to write its own outcome: re-queueing under
301
+ * it would coalesce with it, and a run that had already written `unsupported` would then end
302
+ * `done` over a `pending` row nothing is coming for. The row goes back to `pending` — it had
303
+ * no body to keep searchable — and gets a run of its own. Returns how many were queued.
304
+ */
305
+ export declare function requeueUnsupportedAttachmentText(sql: ScopedSql, attachmentIds: readonly string[], mintId: () => string, at: string): number;
306
+ /**
307
+ * The recheck job: one page per pass, the cursor the last attachment id it looked at. Of the
308
+ * page's `unsupported` rows it re-queues the ones an extractor of this host now accepts
309
+ * (`chooseAttachmentExtractor`, the choice the extraction run makes), and leaves the rest:
310
+ * an image no extractor reads stays `unsupported`, with no run spent on finding that out
311
+ * again. Replays like the backfill: the page is re-read and the re-queue is guarded.
312
+ *
313
+ * **A run keyed to another set ends on its first pass here, having walked nothing.** The
314
+ * handler is found by job name, so after a deploy changes the set, this host is handed the
315
+ * walk the last one began. Finishing it with these extractors would mark that set walked over
316
+ * rows it never judged, and a roll back to it would read them as done. This host's own walk
317
+ * is the one `startAttachmentTextRecheck` starts for its set.
318
+ */
319
+ export declare function attachmentTextRecheckJob(source: {
320
+ page(after: string | null): Promise<AttachmentTextRecheckPage>;
321
+ requeue(attachmentIds: readonly string[]): Promise<number>;
322
+ }, extractors: readonly AttachmentExtractor[]): JobHandler;
234
323
  /**
235
324
  * An attachment's extraction state, or null when none was ever recorded — an attachment
236
325
  * uploaded before extraction existed, or one a fork carried without its text.
@@ -1 +1 @@
1
- {"version":3,"file":"attachment-text.d.ts","sourceRoot":"","sources":["../src/attachment-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC5D,yEAAyE;IACzE,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3E;AAUD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,SAAS,mBAAmB,EAAE,EAC1C,MAAM,GAAE,oBAAqD,GAC5D,UAAU,CAgCZ"}
@@ -86,6 +86,11 @@ export const ATTACHMENT_TEXT_MODULE = '@substrat-run/kernel';
86
86
  export const ATTACHMENT_TEXT_JOB = 'attachment-text';
87
87
  /** The backfill's job name: queues extraction for attachments that predate it. */
88
88
  export const ATTACHMENT_TEXT_BACKFILL_JOB = 'attachment-text-backfill';
89
+ /**
90
+ * The recheck's job name: queues extraction again for attachments recorded `unsupported`
91
+ * that an extractor the host has now reads. One run per scope per extractor set.
92
+ */
93
+ export const ATTACHMENT_TEXT_RECHECK_JOB = 'attachment-text-recheck';
89
94
  /**
90
95
  * The kernel's handler for a run, or undefined for a run that is not the kernel's — which the
91
96
  * adapter's own registry answers. The one place a kernel job is dispatched, so a new one is
@@ -193,7 +198,7 @@ const RUN_PAYLOAD_KEY = 'attachmentId';
193
198
  * rather than racing it.
194
199
  */
195
200
  function startKernelRun(sql, job, instance, payload, runId, at) {
196
- sql.exec(`INSERT INTO _substrat_job_runs
201
+ const { changes } = sql.exec(`INSERT INTO _substrat_job_runs
197
202
  (id, module_id, job, instance, payload, subject_id, status, cursor, counters, attempts,
198
203
  last_error, started_at, updated_at, next_attempt_at, ended_at)
199
204
  SELECT ?, ?, ?, ?, ?, NULL, 'running', NULL, '{}', 0, NULL, ?, ?, NULL, NULL
@@ -201,6 +206,7 @@ function startKernelRun(sql, job, instance, payload, runId, at) {
201
206
  SELECT 1 FROM _substrat_job_runs
202
207
  WHERE module_id = ? AND job = ? AND instance = ? AND status = 'running'
203
208
  )`, [runId, ATTACHMENT_TEXT_MODULE, job, instance, JSON.stringify(payload), at, at, ATTACHMENT_TEXT_MODULE, job, instance]);
209
+ return changes > 0;
204
210
  }
205
211
  /** Start one attachment's extraction run, coalesced with a live one. */
206
212
  function startAttachmentTextRun(sql, attachmentId, runId, at) {
@@ -340,6 +346,133 @@ export function attachmentTextBackfillJob(source) {
340
346
  return { cursor: last, done };
341
347
  };
342
348
  }
349
+ // -- the recheck: `unsupported` read again once an extractor reads the type ------------
350
+ /**
351
+ * The extractor set a recheck run is keyed by: the host's extractor names, sorted and
352
+ * comma-joined (`docx,html,pdf,pptx,text,xlsx`). Empty for a host with none.
353
+ *
354
+ * `unsupported` is a fact about the HOST, not about the file: it says no extractor that host
355
+ * had read the type. A host that gains one — a release that adds PDF to its parsers — would
356
+ * otherwise leave every attachment recorded before it unsearchable for good, since nothing
357
+ * ever queues an attachment that already has a text row. The name stands for what an
358
+ * extractor reads; a change to what one extractor accepts under the same name is not seen.
359
+ */
360
+ export function attachmentExtractorSetKey(extractors) {
361
+ return extractors
362
+ .map((e) => e.name)
363
+ .sort()
364
+ .join(',');
365
+ }
366
+ /**
367
+ * Start the scope's recheck for this extractor set, unless the scope's newest recheck is for
368
+ * this set already, or it holds no attachments, or the host has no extractor at all.
369
+ *
370
+ * **The newest recheck run is the marker**, as the run row is for the backfill
371
+ * (`startAttachmentTextBackfill`), but compared by set: its instance is the set's key. A
372
+ * deployment that keeps its extractors walks nothing again, and one whose extractors change
373
+ * starts one walk in each scope it drives. That includes a change BACK: a release rolled
374
+ * back to a set without some extractor records what it cannot read `unsupported`, and the
375
+ * release rolled forward again must read those, so "this set has walked once" is not the
376
+ * test — "this set is the last one that walked" is. Alternating two sets costs a walk per
377
+ * change, and one script drives a scope with one set, so a change is a deploy.
378
+ *
379
+ * A host whose set is empty starts nothing: it reads nothing, so there is nothing to queue.
380
+ * Its window is not covered — a release that drops every extractor and one that restores the
381
+ * same set leave what was uploaded between them `unsupported`.
382
+ *
383
+ * Read before it writes, so the drive that calls it on every pass writes nothing once the
384
+ * scope is marked: two index reads. Returns whether it started a run (a live run for the
385
+ * set already, which `startKernelRun` coalesces with, is not a start).
386
+ */
387
+ export function startAttachmentTextRecheck(sql, extractorSet, runId, at) {
388
+ if (extractorSet === '')
389
+ return false;
390
+ const [row] = sql.query(`SELECT EXISTS (SELECT 1 FROM _substrat_attachments) AS has,
391
+ (SELECT instance FROM _substrat_job_runs WHERE module_id = ? AND job = ? ORDER BY id DESC LIMIT 1) AS latest`, [ATTACHMENT_TEXT_MODULE, ATTACHMENT_TEXT_RECHECK_JOB]);
392
+ if (!row || Number(row.has) !== 1 || row.latest === extractorSet)
393
+ return false;
394
+ return startKernelRun(sql, ATTACHMENT_TEXT_RECHECK_JOB, extractorSet, {}, runId, at);
395
+ }
396
+ /**
397
+ * One page of the recheck: the next `batch` text rows after `after`, by attachment id, and
398
+ * those of them recorded `unsupported`. Bounded by what it LOOKS AT, like the backfill's
399
+ * batch, so a scope with no `unsupported` row costs the same pass as one full of them. Only
400
+ * reads: which of them an extractor now reads is the host's to decide (`accepts` is code),
401
+ * and the queueing is `requeueUnsupportedAttachmentText`.
402
+ */
403
+ export function readAttachmentTextRecheckPage(sql, after, batch = ATTACHMENT_TEXT_BACKFILL_BATCH) {
404
+ const rows = sql.query(`SELECT t.attachment_id, t.status, a.content_type, a.filename
405
+ FROM _substrat_search__attachment_text t
406
+ LEFT JOIN _substrat_attachments a ON a.id = t.attachment_id
407
+ WHERE t.attachment_id > ?
408
+ ORDER BY t.attachment_id
409
+ LIMIT ?`, [after ?? '', batch]);
410
+ const unsupported = [];
411
+ for (const r of rows) {
412
+ if (r.status !== 'unsupported' || r.content_type === null || r.filename === null)
413
+ continue;
414
+ unsupported.push({ id: r.attachment_id, contentType: r.content_type, filename: r.filename });
415
+ }
416
+ return { scanned: rows.length, unsupported, last: rows.at(-1)?.attachment_id ?? after, done: rows.length < batch };
417
+ }
418
+ /**
419
+ * Queue extraction again for these attachments, inside the caller's transaction — each only
420
+ * while its row is still `unsupported` and no extraction run for it is live. The page was
421
+ * read in an earlier call, so by now an attachment may be gone (its trigger took the row),
422
+ * re-uploaded or already re-queued: none of those is touched, which also makes a replayed
423
+ * page queue nothing twice. A live run is left to write its own outcome: re-queueing under
424
+ * it would coalesce with it, and a run that had already written `unsupported` would then end
425
+ * `done` over a `pending` row nothing is coming for. The row goes back to `pending` — it had
426
+ * no body to keep searchable — and gets a run of its own. Returns how many were queued.
427
+ */
428
+ export function requeueUnsupportedAttachmentText(sql, attachmentIds, mintId, at) {
429
+ let queued = 0;
430
+ for (const id of attachmentIds) {
431
+ const { changes } = sql.exec(`UPDATE _substrat_search__attachment_text
432
+ SET status = 'pending', extractor = NULL, detail = NULL, updated_at = ?
433
+ WHERE attachment_id = ? AND status = 'unsupported'
434
+ AND NOT EXISTS (
435
+ SELECT 1 FROM _substrat_job_runs
436
+ WHERE module_id = ? AND job = ? AND instance = ? AND status = 'running'
437
+ )`, [at, id, ATTACHMENT_TEXT_MODULE, ATTACHMENT_TEXT_JOB, id]);
438
+ if (changes === 0)
439
+ continue;
440
+ startAttachmentTextRun(sql, id, mintId(), at);
441
+ queued += 1;
442
+ }
443
+ return queued;
444
+ }
445
+ /**
446
+ * The recheck job: one page per pass, the cursor the last attachment id it looked at. Of the
447
+ * page's `unsupported` rows it re-queues the ones an extractor of this host now accepts
448
+ * (`chooseAttachmentExtractor`, the choice the extraction run makes), and leaves the rest:
449
+ * an image no extractor reads stays `unsupported`, with no run spent on finding that out
450
+ * again. Replays like the backfill: the page is re-read and the re-queue is guarded.
451
+ *
452
+ * **A run keyed to another set ends on its first pass here, having walked nothing.** The
453
+ * handler is found by job name, so after a deploy changes the set, this host is handed the
454
+ * walk the last one began. Finishing it with these extractors would mark that set walked over
455
+ * rows it never judged, and a roll back to it would read them as done. This host's own walk
456
+ * is the one `startAttachmentTextRecheck` starts for its set.
457
+ */
458
+ export function attachmentTextRecheckJob(source, extractors) {
459
+ const extractorSet = attachmentExtractorSetKey(extractors);
460
+ return async (pass) => {
461
+ if (pass.run.instance !== extractorSet) {
462
+ pass.count('superseded', 1);
463
+ return { done: true };
464
+ }
465
+ const after = typeof pass.cursor === 'string' ? pass.cursor : null;
466
+ const { scanned, unsupported, last, done } = await source.page(after);
467
+ const readable = unsupported
468
+ .filter((a) => chooseAttachmentExtractor(extractors, a.contentType, a.filename) !== undefined)
469
+ .map((a) => a.id);
470
+ const queued = readable.length > 0 ? await source.requeue(readable) : 0;
471
+ pass.count('scanned', scanned);
472
+ pass.count('queued', queued);
473
+ return { cursor: last, done };
474
+ };
475
+ }
343
476
  /**
344
477
  * An attachment's extraction state, or null when none was ever recorded — an attachment
345
478
  * uploaded before extraction existed, or one a fork carried without its text.
@@ -1 +1 @@
1
- {"version":3,"file":"attachment-text.js","sourceRoot":"","sources":["../src/attachment-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AACH,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,UAAU,GAMX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,sBAAsB,GAIvB,MAAM,2BAA2B,CAAC;AAEnC,yFAAyF;AACzF,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAAkC,CAAC;AAEzE,qFAAqF;AACrF,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,kFAAkF;AAClF,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAQ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AC;QACzC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The relay's scope ends, over a host's own doors (K-74, #3492, following #3469).
3
+ *
4
+ * `BrokerRelay` takes three seams, and this is each of them over the real scopes of the app whose
5
+ * broker it is. Every one is a door the host already keeps, so what a pushed message may do in a
6
+ * scope is decided by the same code that decides it for a pulled one:
7
+ *
8
+ * - **Export** (`RelayExports`): the producer scope's own export read (#1705, `readExportedEvents`),
9
+ * for the one row, through `exportOneVia`. The same `exports`, `readPermission`, classification,
10
+ * version and cascade rules decide a pushed event as decide a pulled batch.
11
+ * - **Import** (`RelayLocal`): the receiving scope's pushed import door (`deliverPushedToPeer`).
12
+ * It admits the producer as a peer and runs its handlers as the pull path's door does, journals
13
+ * by event id in `_substrat_imports` and `_substrat_deliveries`, and leaves the producer's
14
+ * watermark where it is. Pushed ahead of an earlier event, it would otherwise make the pull path
15
+ * skip that one. The pull path then finds a pushed event journaled and counts it a duplicate.
16
+ * The producer is the caller the router verified (K-66's lines), never a field of the message.
17
+ * - **Resume** (`RelayResume`): a K-62 attempt's record operation, invoked as the system of the
18
+ * module the target names, in the waiting scope, with the reply or the expiry
19
+ * (`relayResumeInput`). One idempotency key per request, so a hand-over repeated after a lost
20
+ * acknowledgement replays the recorded answer instead of recording twice.
21
+ *
22
+ * A refusal that can change is a throw, which the relay retries: a paused export, a producer the
23
+ * receiving scope does not admit yet. A handler that fails is the scope's own dead letter, as on
24
+ * the pull path, and the relay's delivery is done.
25
+ */
26
+ import { type ExportedBatch, type ExportReadInput, type ImportResult, type PushedImport, type RelayEnvelope, type RelayResumeInput } from '@substrat-run/contracts';
27
+ import { type BrokerRelayOptions } from './broker-relay.js';
28
+ /** The doors of one app's host the relay's ends go through. Each adapter's host provides them. */
29
+ export interface RelayScopeDoors {
30
+ /** The producer scope's export read (#1705), as the pull path reads it. */
31
+ readExports(tenantId: string, scopeId: string, input: ExportReadInput): Promise<ExportedBatch>;
32
+ /** The receiving scope's pushed import: journals by event id and moves no watermark. */
33
+ importPushed(tenantId: string, scopeId: string, pushed: PushedImport): Promise<ImportResult>;
34
+ /** Invoke `operation` as `system:<module>` in the scope, under `idempotencyKey`. */
35
+ invokeAsSystem(input: {
36
+ module: string;
37
+ tenantId: string;
38
+ scopeId: string;
39
+ operation: string;
40
+ input: RelayResumeInput;
41
+ idempotencyKey: string;
42
+ }): Promise<unknown>;
43
+ /**
44
+ * What the app's host code does with a request another app sent it. Absent, a request is not
45
+ * taken: its delivery fails and is retried, and the requester's deadline ends the wait.
46
+ */
47
+ requests?: (envelope: RelayEnvelope) => Promise<void>;
48
+ }
49
+ /** The idempotency key a request's outcome is handed over under: one per request. */
50
+ export declare const relayResumeKey: (requestId: string) => string;
51
+ /** `exports`, `local` and `resume` for a `BrokerRelay`, over one app's host. */
52
+ export declare function relayScopeEnds(doors: RelayScopeDoors): Pick<BrokerRelayOptions, 'exports' | 'local' | 'resume'>;
53
+ //# sourceMappingURL=broker-relay-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-relay-scope.d.ts","sourceRoot":"","sources":["../src/broker-relay-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,kGAAkG;AACl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