@substrat-run/kernel 0.139.0 → 0.140.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 (140) hide show
  1. package/dist/admin-log-ddl.d.ts +21 -0
  2. package/dist/admin-log-ddl.d.ts.map +1 -0
  3. package/dist/admin-log-ddl.js +32 -0
  4. package/dist/admin-log-ddl.js.map +1 -0
  5. package/dist/attachment-extractor.d.ts +12 -1
  6. package/dist/attachment-extractor.d.ts.map +1 -1
  7. package/dist/attachment-extractor.js +10 -5
  8. package/dist/attachment-extractor.js.map +1 -1
  9. package/dist/audit-outcome.d.ts +149 -0
  10. package/dist/audit-outcome.d.ts.map +1 -0
  11. package/dist/audit-outcome.js +233 -0
  12. package/dist/audit-outcome.js.map +1 -0
  13. package/dist/connect-links.d.ts +91 -0
  14. package/dist/connect-links.d.ts.map +1 -0
  15. package/dist/connect-links.js +189 -0
  16. package/dist/connect-links.js.map +1 -0
  17. package/dist/connect-state.d.ts +12 -3
  18. package/dist/connect-state.d.ts.map +1 -1
  19. package/dist/connect-state.js +8 -3
  20. package/dist/connect-state.js.map +1 -1
  21. package/dist/derived-object.d.ts +14 -0
  22. package/dist/derived-object.d.ts.map +1 -0
  23. package/dist/derived-object.js +2 -0
  24. package/dist/derived-object.js.map +1 -0
  25. package/dist/derived-objects.d.ts +108 -0
  26. package/dist/derived-objects.d.ts.map +1 -0
  27. package/dist/derived-objects.js +199 -0
  28. package/dist/derived-objects.js.map +1 -0
  29. package/dist/email-intent.d.ts +56 -0
  30. package/dist/email-intent.d.ts.map +1 -0
  31. package/dist/email-intent.js +71 -0
  32. package/dist/email-intent.js.map +1 -0
  33. package/dist/entity-edges.d.ts +6 -1
  34. package/dist/entity-edges.d.ts.map +1 -1
  35. package/dist/entity-edges.js +13 -0
  36. package/dist/entity-edges.js.map +1 -1
  37. package/dist/entity-grant-shape.d.ts +94 -0
  38. package/dist/entity-grant-shape.d.ts.map +1 -0
  39. package/dist/entity-grant-shape.js +329 -0
  40. package/dist/entity-grant-shape.js.map +1 -0
  41. package/dist/entity-grant.d.ts +45 -0
  42. package/dist/entity-grant.d.ts.map +1 -0
  43. package/dist/entity-grant.js +71 -0
  44. package/dist/entity-grant.js.map +1 -0
  45. package/dist/entity-state-reads.d.ts +4 -7
  46. package/dist/entity-state-reads.d.ts.map +1 -1
  47. package/dist/entity-state-reads.js +13 -57
  48. package/dist/entity-state-reads.js.map +1 -1
  49. package/dist/entity-state.d.ts +37 -10
  50. package/dist/entity-state.d.ts.map +1 -1
  51. package/dist/entity-state.js +80 -69
  52. package/dist/entity-state.js.map +1 -1
  53. package/dist/entity-trash.d.ts +245 -0
  54. package/dist/entity-trash.d.ts.map +1 -0
  55. package/dist/entity-trash.js +380 -0
  56. package/dist/entity-trash.js.map +1 -0
  57. package/dist/grant-scoped-read.d.ts +41 -0
  58. package/dist/grant-scoped-read.d.ts.map +1 -0
  59. package/dist/grant-scoped-read.js +100 -0
  60. package/dist/grant-scoped-read.js.map +1 -0
  61. package/dist/index.d.ts +31 -5
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +20 -4
  64. package/dist/index.js.map +1 -1
  65. package/dist/kernel-outbox.d.ts +14 -0
  66. package/dist/kernel-outbox.d.ts.map +1 -0
  67. package/dist/kernel-outbox.js +37 -0
  68. package/dist/kernel-outbox.js.map +1 -0
  69. package/dist/list-index.d.ts +11 -2
  70. package/dist/list-index.d.ts.map +1 -1
  71. package/dist/list-index.js +29 -21
  72. package/dist/list-index.js.map +1 -1
  73. package/dist/mail-sender.d.ts +78 -0
  74. package/dist/mail-sender.d.ts.map +1 -0
  75. package/dist/mail-sender.js +2 -0
  76. package/dist/mail-sender.js.map +1 -0
  77. package/dist/membership-executor.d.ts +0 -52
  78. package/dist/membership-executor.d.ts.map +1 -1
  79. package/dist/membership-executor.js +19 -59
  80. package/dist/membership-executor.js.map +1 -1
  81. package/dist/migration-digest.d.ts +161 -0
  82. package/dist/migration-digest.d.ts.map +1 -0
  83. package/dist/migration-digest.js +237 -0
  84. package/dist/migration-digest.js.map +1 -0
  85. package/dist/module-erasure.d.ts +156 -0
  86. package/dist/module-erasure.d.ts.map +1 -0
  87. package/dist/module-erasure.js +440 -0
  88. package/dist/module-erasure.js.map +1 -0
  89. package/dist/peer.d.ts +9 -1
  90. package/dist/peer.d.ts.map +1 -1
  91. package/dist/peer.js +29 -0
  92. package/dist/peer.js.map +1 -1
  93. package/dist/permission-checker.d.ts +6 -0
  94. package/dist/permission-checker.d.ts.map +1 -1
  95. package/dist/permission-checker.js.map +1 -1
  96. package/dist/permission-eval.d.ts +10 -1
  97. package/dist/permission-eval.d.ts.map +1 -1
  98. package/dist/permission-eval.js +51 -2
  99. package/dist/permission-eval.js.map +1 -1
  100. package/dist/platform-sweep.d.ts +1 -1
  101. package/dist/platform-sweep.d.ts.map +1 -1
  102. package/dist/platform-sweep.js +5 -0
  103. package/dist/platform-sweep.js.map +1 -1
  104. package/dist/scope-host.d.ts +301 -22
  105. package/dist/scope-host.d.ts.map +1 -1
  106. package/dist/scope-host.js +72 -5
  107. package/dist/scope-host.js.map +1 -1
  108. package/dist/search-index.d.ts +8 -0
  109. package/dist/search-index.d.ts.map +1 -1
  110. package/dist/search-index.js +51 -21
  111. package/dist/search-index.js.map +1 -1
  112. package/dist/spine-guard.d.ts +7 -0
  113. package/dist/spine-guard.d.ts.map +1 -1
  114. package/dist/spine-guard.js +54 -6
  115. package/dist/spine-guard.js.map +1 -1
  116. package/dist/spine-restore.d.ts.map +1 -1
  117. package/dist/spine-restore.js +5 -0
  118. package/dist/spine-restore.js.map +1 -1
  119. package/dist/sql-statements.d.ts +71 -0
  120. package/dist/sql-statements.d.ts.map +1 -0
  121. package/dist/sql-statements.js +191 -0
  122. package/dist/sql-statements.js.map +1 -0
  123. package/dist/subject-redaction.d.ts +9 -1
  124. package/dist/subject-redaction.d.ts.map +1 -1
  125. package/dist/subject-redaction.js.map +1 -1
  126. package/dist/system-switch-record.d.ts +3 -0
  127. package/dist/system-switch-record.d.ts.map +1 -1
  128. package/dist/system-switch-record.js +2 -0
  129. package/dist/system-switch-record.js.map +1 -1
  130. package/dist/table-ownership.d.ts +103 -0
  131. package/dist/table-ownership.d.ts.map +1 -0
  132. package/dist/table-ownership.js +285 -0
  133. package/dist/table-ownership.js.map +1 -0
  134. package/dist/timeline.d.ts +4 -4
  135. package/dist/timeline.js +4 -4
  136. package/dist/visible-continuation.d.ts +38 -0
  137. package/dist/visible-continuation.d.ts.map +1 -0
  138. package/dist/visible-continuation.js +162 -0
  139. package/dist/visible-continuation.js.map +1 -0
  140. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"entity-state-reads.js","sourceRoot":"","sources":["../src/entity-state-reads.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,WAAW,EACX,aAAa,GAId,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAyC,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAsB,MAAM,iBAAiB,CAAC;AAEvF,OAAO,EACL,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,WAAW,GAGZ,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,UAAkB,EAAE,IAAwB;IACtF,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAmC,CAAC;IACnE,MAAM,aAAa,CACjB,mBAAmB,EACnB,GAAG,IAAI,mBAAmB,UAAU,kBAAkB,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,IAAI;QACrH,kDAAkD,EACpD,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC,EAAE,CAC9E,CAAC;AACJ,CAAC;AAED;;;GAGG;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,UAAU,EAAE,MAAM,CAAC;aACtD,CACsB,CAAC;QAC5B,CAAC;QAED,KAAK,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO;YAC3C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YACnG,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC9C,IAAI,CAAC,IAAI;gBAAE,MAAM,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;YAC/C,MAAM,CAAC,GAAG,WAAW,CACnB,IAAI,EACJ,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAC3C,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,EAC3B,gBAAgB,CAAC,UAAU,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,CACtE,CAAC;YACF,MAAM,IAAI,GAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAoC,CAAC,GAAG,CAC9E,CAAC,GAAG,EAAa,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CACjE,CAAC;YACF,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -39,6 +39,7 @@
39
39
  */
40
40
  import { type DomainEventInput, type EntityStateDeclaration, type EntityStateName, type Instant, type PermissionKey } from '@substrat-run/contracts';
41
41
  import type { OperationContext, ScopedSql, SqlMigration } from './scope-host.js';
42
+ import type { DerivedObject } from './derived-object.js';
42
43
  /** A resolved declaration: everything the DDL, the reads and the verbs need. */
43
44
  export interface EntityStatePlan {
44
45
  readonly moduleId: string;
@@ -49,6 +50,8 @@ export interface EntityStatePlan {
49
50
  readonly archivePermission?: PermissionKey;
50
51
  /** Present when the entity can be trashed. */
51
52
  readonly trashPermission?: PermissionKey;
53
+ /** Present when a trashed entity is purged after this many days (`entity-trash.ts`). */
54
+ readonly purgeAfterDays?: number;
52
55
  }
53
56
  /** The operation's own check — a pass is recorded as one of its authorizations (K-34). */
54
57
  export type StateCheck = OperationContext['check'];
@@ -71,6 +74,31 @@ export declare function entityStatePlans(moduleId: string, declarations: readonl
71
74
  * indexes (their partial `WHERE` names these columns) — `moduleMigrations` writes that order.
72
75
  */
73
76
  export declare function entityStateMigrations(moduleId: string, declarations: readonly EntityStateDeclaration[] | undefined): SqlMigration[];
77
+ /** The column migrations' versions, and the column each adds — what the journal says a table holds. */
78
+ export declare const stateColumnVersionsOf: (plan: EntityStatePlan) => {
79
+ version: string;
80
+ column: string;
81
+ }[];
82
+ /** The purge index's migration version (#119) — present only on a plan with a purge horizon. */
83
+ export declare const purgeIndexVersion: (plan: EntityStatePlan) => string;
84
+ /**
85
+ * The partial index the purge sweep walks (#119): trashed rows only, oldest trash first, so a
86
+ * sweep reads the due rows and nothing else. Its name is kernel-prefixed, so the reserved
87
+ * namespace. Empty for a plan without a purge horizon.
88
+ */
89
+ export declare function purgeIndexObjects(plan: EntityStatePlan): DerivedObject[];
90
+ /**
91
+ * The purge index's DDL. `IF NOT EXISTS` because a dump load runs it again after the rows are
92
+ * in; a repair that finds it wrong drops it first (`purgeIndexRepairDdl`).
93
+ */
94
+ export declare function purgeIndexDdl(plan: EntityStatePlan): string;
95
+ /** Drop-then-create, for a purge index the catalogue holds under its name but not as emitted. */
96
+ export declare function purgeIndexRepairDdl(plan: EntityStatePlan): string;
97
+ /**
98
+ * The guard triggers' version. By which columns they guard, so declaring a trash on an
99
+ * archivable entity rebuilds them to guard both.
100
+ */
101
+ export declare const entityStateGuardVersion: (plan: EntityStatePlan) => string;
74
102
  /** The prefix of every trigger this module derives — kernel-owned, so the reserved one. */
75
103
  export declare const ENTITY_STATE_TRIGGER_PREFIX = "_substrat_state_";
76
104
  /**
@@ -104,6 +132,8 @@ export declare const ENTITY_STATE_MOVES_DDL = "\n CREATE TABLE IF NOT EXISTS _s
104
132
  * legitimately born trashed, so the triggers are put back only after them.
105
133
  */
106
134
  export declare function entityStateTriggerDdl(plan: EntityStatePlan): string;
135
+ /** The two guard triggers `entityStateTriggerDdl` creates, each with its CREATE statement. */
136
+ export declare function entityStateTriggerObjects(plan: EntityStatePlan): DerivedObject[];
107
137
  /**
108
138
  * Add one module's plans to a scope's registry, refusing a second declaration of a type — the
109
139
  * table is one module's, and two answers to "who may trash it" is no answer — and a key the
@@ -138,6 +168,13 @@ export declare function viewsOf(columns: StateColumns): EntityStateName[];
138
168
  */
139
169
  export declare function entityStateWhere(entityType: string, columns: StateColumns, view: EntityStateName, alias?: string): string;
140
170
  export declare function entityStateWhere(entityType: string, columns: StateColumns | undefined, view: EntityStateName | undefined, alias?: string): string | undefined;
171
+ /** The two columns as one row holds them. */
172
+ export interface StateRow {
173
+ readonly archived_at: string | null;
174
+ readonly trashed_at: string | null;
175
+ }
176
+ /** One row's two columns, or `undefined` when the row does not exist. */
177
+ export declare function readStateRow(sql: ScopedSql, plan: EntityStatePlan, entityId: string): StateRow | undefined;
141
178
  /**
142
179
  * The plan for `entityType`, and the key one of its states is gated on — or `validation_failed`
143
180
  * naming what the entity does not declare. Shared by the verbs and the trashed readers, so
@@ -164,14 +201,4 @@ export interface EntityStateDeps {
164
201
  /** The verbs, as `OperationContext` carries them. */
165
202
  export type EntityStateVerbs = Pick<OperationContext, 'archive' | 'unarchive' | 'trash' | 'restore' | 'entityState'>;
166
203
  export declare function createEntityStateVerbs(deps: EntityStateDeps): EntityStateVerbs;
167
- /**
168
- * After runtime DDL (#119, Codex r3): does every stateful table still carry what the kernel
169
- * derived for it? The guard refuses the DDL known to take it away; this is the check that does not
170
- * depend on having known. Read from `main`'s own catalogue, so a same-named temp object cannot
171
- * stand in for the real table. Throws — the operation and its DDL roll back — rather than
172
- * re-deriving: a schema the kernel did not expect is not one to repair silently.
173
- *
174
- * `indexes` names the derived list indexes each stateful table must keep, by table.
175
- */
176
- export declare function assertEntityStateIntact(sql: ScopedSql, plans: ReadonlyMap<string, EntityStatePlan>, indexes?: ReadonlyMap<string, readonly string[]>): void;
177
204
  //# sourceMappingURL=entity-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entity-state.d.ts","sourceRoot":"","sources":["../src/entity-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EASL,KAAK,gBAAgB,EAErB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGjF,gFAAgF;AAChF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC;IAC3C,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC;CAC1C;AAED,0FAA0F;AAC1F,MAAM,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,YAA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ED,4CAA4C;AAC5C,MAAM,WAAW,eAAe;IAC9B,uGAAuG;IACvG,GAAG,EAAE,SAAS,CAAC;IACf,2DAA2D;IAC3D,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC5C,kEAAkE;IAClE,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,gGAAgG;IAChG,IAAI,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACxC,yDAAyD;IACzD,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC,CAAC;AAsBrH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,eAAe,GAAG,gBAAgB,CAgE9E"}
@@ -62,6 +62,9 @@ export function entityStatePlans(moduleId, declarations) {
62
62
  if (!decl.archivePermission && !decl.trashPermission) {
63
63
  throw new Error(`entity state: ${where} declares neither an archive nor a trash permission`);
64
64
  }
65
+ if (decl.purgeAfterDays !== undefined && !decl.trashPermission) {
66
+ throw new Error(`entity state: ${where} declares a purge horizon and no trash — only a trashed entity is purged`);
67
+ }
65
68
  plans.push({
66
69
  moduleId,
67
70
  entityType: decl.entityType,
@@ -69,6 +72,7 @@ export function entityStatePlans(moduleId, declarations) {
69
72
  idColumn: assertSqlIdentifier('entity state', 'an id column', decl.idColumn ?? 'id', where),
70
73
  ...(decl.archivePermission ? { archivePermission: decl.archivePermission } : {}),
71
74
  ...(decl.trashPermission ? { trashPermission: decl.trashPermission } : {}),
75
+ ...(decl.purgeAfterDays !== undefined ? { purgeAfterDays: decl.purgeAfterDays } : {}),
72
76
  });
73
77
  }
74
78
  return plans;
@@ -88,28 +92,66 @@ export function entityStatePlans(moduleId, declarations) {
88
92
  export function entityStateMigrations(moduleId, declarations) {
89
93
  const out = [];
90
94
  for (const plan of entityStatePlans(moduleId, declarations)) {
91
- if (plan.archivePermission) {
92
- out.push({
93
- version: `state/${plan.entityType}:archive`,
94
- sql: `ALTER TABLE ${plan.table} ADD COLUMN ${ARCHIVED_AT_COLUMN} TEXT;`,
95
- });
96
- }
97
- if (plan.trashPermission) {
98
- out.push({
99
- version: `state/${plan.entityType}:trash`,
100
- sql: `ALTER TABLE ${plan.table} ADD COLUMN ${TRASHED_AT_COLUMN} TEXT;`,
101
- });
95
+ for (const { version, column } of stateColumnVersionsOf(plan)) {
96
+ out.push({ version, sql: `ALTER TABLE ${plan.table} ADD COLUMN ${column} TEXT;` });
102
97
  }
103
- // After the columns they name. Versioned by which columns they guard, so declaring a trash
104
- // on an archivable entity rebuilds them to guard both.
105
- out.push({ version: `state/${plan.entityType}:guard:${columnNamesOf(plan).join('+')}`, sql: entityStateTriggerDdl(plan) });
98
+ // After the columns they name.
99
+ out.push({ version: entityStateGuardVersion(plan), sql: entityStateTriggerDdl(plan) });
100
+ // The purge sweep's walk (#119): the oldest trashed rows first, without reading the rest of
101
+ // the bin. Its own version, so declaring a horizon later adds it and re-runs nothing.
102
+ if (plan.purgeAfterDays !== undefined)
103
+ out.push({ version: purgeIndexVersion(plan), sql: purgeIndexDdl(plan) });
106
104
  }
107
105
  return out;
108
106
  }
109
- const columnNamesOf = (plan) => [
110
- ...(plan.archivePermission ? ['archive'] : []),
111
- ...(plan.trashPermission ? ['trash'] : []),
107
+ /** The column migrations' versions, and the column each adds — what the journal says a table holds. */
108
+ export const stateColumnVersionsOf = (plan) => [
109
+ ...(plan.archivePermission ? [{ version: `state/${plan.entityType}:archive`, column: ARCHIVED_AT_COLUMN }] : []),
110
+ ...(plan.trashPermission ? [{ version: `state/${plan.entityType}:trash`, column: TRASHED_AT_COLUMN }] : []),
112
111
  ];
112
+ /** The purge index's migration version (#119) — present only on a plan with a purge horizon. */
113
+ export const purgeIndexVersion = (plan) => `state/${plan.entityType}:purge`;
114
+ /**
115
+ * The partial index the purge sweep walks (#119): trashed rows only, oldest trash first, so a
116
+ * sweep reads the due rows and nothing else. Its name is kernel-prefixed, so the reserved
117
+ * namespace. Empty for a plan without a purge horizon.
118
+ */
119
+ export function purgeIndexObjects(plan) {
120
+ if (plan.purgeAfterDays === undefined)
121
+ return [];
122
+ const name = `_substrat_purge_${plan.table}`;
123
+ return [
124
+ {
125
+ name,
126
+ type: 'index',
127
+ table: plan.table,
128
+ sql: `CREATE INDEX ${name} ON ${plan.table} (${TRASHED_AT_COLUMN}, ${plan.idColumn}) WHERE ${TRASHED_AT_COLUMN} IS NOT NULL`,
129
+ },
130
+ ];
131
+ }
132
+ /**
133
+ * The purge index's DDL. `IF NOT EXISTS` because a dump load runs it again after the rows are
134
+ * in; a repair that finds it wrong drops it first (`purgeIndexRepairDdl`).
135
+ */
136
+ export function purgeIndexDdl(plan) {
137
+ return purgeIndexObjects(plan)
138
+ .map((idx) => `${idx.sql.replace(/^CREATE INDEX /, 'CREATE INDEX IF NOT EXISTS ')};`)
139
+ .join('\n');
140
+ }
141
+ /** Drop-then-create, for a purge index the catalogue holds under its name but not as emitted. */
142
+ export function purgeIndexRepairDdl(plan) {
143
+ return purgeIndexObjects(plan)
144
+ .flatMap((idx) => [`DROP INDEX IF EXISTS ${idx.name};`, `${idx.sql};`])
145
+ .join('\n');
146
+ }
147
+ /**
148
+ * The guard triggers' version. By which columns they guard, so declaring a trash on an
149
+ * archivable entity rebuilds them to guard both.
150
+ */
151
+ export const entityStateGuardVersion = (plan) => {
152
+ const { archive, trash } = stateColumnsOf(plan);
153
+ return `state/${plan.entityType}:guard:${[...(archive ? ['archive'] : []), ...(trash ? ['trash'] : [])].join('+')}`;
154
+ };
113
155
  /** The prefix of every trigger this module derives — kernel-owned, so the reserved one. */
114
156
  export const ENTITY_STATE_TRIGGER_PREFIX = '_substrat_state_';
115
157
  /**
@@ -151,23 +193,29 @@ const literal = (value) => `'${value.replace(/'/g, "''")}'`;
151
193
  * legitimately born trashed, so the triggers are put back only after them.
152
194
  */
153
195
  export function entityStateTriggerDdl(plan) {
196
+ return entityStateTriggerObjects(plan)
197
+ .flatMap((t) => [`DROP TRIGGER IF EXISTS ${t.name};`, `${t.sql};`])
198
+ .join('\n');
199
+ }
200
+ /** The two guard triggers `entityStateTriggerDdl` creates, each with its CREATE statement. */
201
+ export function entityStateTriggerObjects(plan) {
154
202
  const born = `${ENTITY_STATE_TRIGGER_PREFIX}${plan.table}_born`;
155
203
  const moved = `${ENTITY_STATE_TRIGGER_PREFIX}${plan.table}_moved`;
156
- const columns = [
157
- ...(plan.archivePermission ? [ARCHIVED_AT_COLUMN] : []),
158
- ...(plan.trashPermission ? [TRASHED_AT_COLUMN] : []),
159
- ];
204
+ const columns = stateColumnVersionsOf(plan).map((c) => c.column);
205
+ const trigger = (name, lines) => ({ name, type: 'trigger', table: plan.table, sql: lines.join('\n') });
160
206
  return [
161
- `DROP TRIGGER IF EXISTS ${born};`,
162
- `CREATE TRIGGER ${born} BEFORE INSERT ON ${plan.table} WHEN ${columns.map((c) => `NEW.${c} IS NOT NULL`).join(' OR ')} BEGIN`,
163
- ` SELECT RAISE(ABORT, 'a row is never inserted archived or trashed - ctx.archive and ctx.trash move it (#119)');`,
164
- `END;`,
165
- `DROP TRIGGER IF EXISTS ${moved};`,
166
- `CREATE TRIGGER ${moved} BEFORE UPDATE OF ${columns.join(', ')} ON ${plan.table}`,
167
- `WHEN NOT EXISTS (SELECT 1 FROM ${ENTITY_STATE_MOVES_TABLE} WHERE entity_type = ${literal(plan.entityType)} AND entity_id = OLD.${plan.idColumn}) BEGIN`,
168
- ` SELECT RAISE(ABORT, 'archive and trash state moves only through ctx.archive, ctx.trash and ctx.restore (#119)');`,
169
- `END;`,
170
- ].join('\n');
207
+ trigger(born, [
208
+ `CREATE TRIGGER ${born} BEFORE INSERT ON ${plan.table} WHEN ${columns.map((c) => `NEW.${c} IS NOT NULL`).join(' OR ')} BEGIN`,
209
+ ` SELECT RAISE(ABORT, 'a row is never inserted archived or trashed - ctx.archive and ctx.trash move it (#119)');`,
210
+ `END`,
211
+ ]),
212
+ trigger(moved, [
213
+ `CREATE TRIGGER ${moved} BEFORE UPDATE OF ${columns.join(', ')} ON ${plan.table}`,
214
+ `WHEN NOT EXISTS (SELECT 1 FROM ${ENTITY_STATE_MOVES_TABLE} WHERE entity_type = ${literal(plan.entityType)} AND entity_id = OLD.${plan.idColumn}) BEGIN`,
215
+ ` SELECT RAISE(ABORT, 'archive and trash state moves only through ctx.archive, ctx.trash and ctx.restore (#119)');`,
216
+ `END`,
217
+ ]),
218
+ ];
171
219
  }
172
220
  /**
173
221
  * Add one module's plans to a scope's registry, refusing a second declaration of a type — the
@@ -220,7 +268,7 @@ export function entityStateWhere(entityType, columns, view, alias) {
220
268
  }
221
269
  const stateOf = (row) => row.trashed_at !== null ? 'trashed' : row.archived_at !== null ? 'archived' : 'active';
222
270
  /** One row's two columns, or `undefined` when the row does not exist. */
223
- function readStateRow(sql, plan, entityId) {
271
+ export function readStateRow(sql, plan, entityId) {
224
272
  const columns = stateColumnsOf(plan);
225
273
  return sql.query(`SELECT ${columns.archive ? ARCHIVED_AT_COLUMN : 'NULL'} AS archived_at, ` +
226
274
  `${columns.trash ? TRASHED_AT_COLUMN : 'NULL'} AS trashed_at ` +
@@ -305,41 +353,4 @@ export function createEntityStateVerbs(deps) {
305
353
  },
306
354
  };
307
355
  }
308
- /**
309
- * After runtime DDL (#119, Codex r3): does every stateful table still carry what the kernel
310
- * derived for it? The guard refuses the DDL known to take it away; this is the check that does not
311
- * depend on having known. Read from `main`'s own catalogue, so a same-named temp object cannot
312
- * stand in for the real table. Throws — the operation and its DDL roll back — rather than
313
- * re-deriving: a schema the kernel did not expect is not one to repair silently.
314
- *
315
- * `indexes` names the derived list indexes each stateful table must keep, by table.
316
- */
317
- export function assertEntityStateIntact(sql, plans, indexes = new Map()) {
318
- for (const plan of plans.values()) {
319
- const fail = (what) => {
320
- throw substratError('internal', `runtime DDL left '${plan.table}' without ${what} — its archive/trash guarantees depend on it; nothing was changed`);
321
- };
322
- const objects = new Map(sql
323
- .query(`SELECT type, name FROM main.sqlite_master WHERE tbl_name = ? COLLATE NOCASE`, [plan.table])
324
- .map((r) => [r.name.toLowerCase(), r.type]));
325
- if (objects.get(plan.table.toLowerCase()) !== 'table')
326
- fail('its table');
327
- const columns = new Set(sql
328
- .query(`SELECT name FROM pragma_table_info(?, 'main')`, [plan.table])
329
- .map((r) => r.name.toLowerCase()));
330
- if (plan.archivePermission && !columns.has(ARCHIVED_AT_COLUMN))
331
- fail(ARCHIVED_AT_COLUMN);
332
- if (plan.trashPermission && !columns.has(TRASHED_AT_COLUMN))
333
- fail(TRASHED_AT_COLUMN);
334
- for (const suffix of ['born', 'moved']) {
335
- const trigger = `${ENTITY_STATE_TRIGGER_PREFIX}${plan.table}_${suffix}`.toLowerCase();
336
- if (objects.get(trigger) !== 'trigger')
337
- fail(`its ${suffix} trigger`);
338
- }
339
- for (const index of indexes.get(plan.table) ?? []) {
340
- if (objects.get(index.toLowerCase()) !== 'index')
341
- fail(`its list index ${index}`);
342
- }
343
- }
344
- }
345
356
  //# sourceMappingURL=entity-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entity-state.js","sourceRoot":"","sources":["../src/entity-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,aAAa,GAOd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAiB1D;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAgB,EAChB,YAA2D;IAE3D,IAAI,CAAC,YAAY,EAAE,MAAM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AI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC;QAChD,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC;QACpD,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC;QAC5C,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC;QAChD,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE;YACtB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC/C,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,aAAa,CACjB,mBAAmB,EACnB,qBAAqB,MAAM,CAAC,UAAU,4DAA4D,CACnG,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1D,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,245 @@
1
+ /**
2
+ * The trash, held by the host (#119 PR 2) — the half of K-45 a handler used to have to remember.
3
+ *
4
+ * Three things, written once for both adapters, the way `entity-state.ts` is:
5
+ *
6
+ * 1. **The refusal.** An operation that addresses an entity by id (`permission: { entity,
7
+ * idFrom }`) is refused on a TRASHED one before its guards and handler run, unless it
8
+ * declares `trashed: 'admits'` or `'purges'`. PR 1's review found handlers forgetting the
9
+ * per-handler check (`list-shares`, `revoke-share`); this makes it a mechanism.
10
+ * 2. **The purge horizon.** An entity declaring `trash.purgeAfterDays` is permanently deleted
11
+ * once it has been in the bin that long, by the sweep running the module's own
12
+ * `trashed: 'purges'` operation as a derived schedule (`purgeSchedulesOf` in contracts), one
13
+ * entity per transaction.
14
+ * 3. **Registration.** The checks that make both of those true of a module rather than of the
15
+ * modules that remembered a line.
16
+ *
17
+ * ## What the refusal does not reach, stated
18
+ *
19
+ * An operation whose check is `resolved` in the handler, narrowed by `refFrom`, or a `narrows`
20
+ * walk has no entity the host can read off its input, so it is not refused here and keeps its
21
+ * own `ctx.entityState` check. `trashRefusalGapsOf` names them and `lint:model` prints them.
22
+ */
23
+ import { type EntityRef, type EntityStateDeclaration, type OperationTarget, type ScheduleSpec } from '@substrat-run/contracts';
24
+ import { type EntityStatePlan, type StateCheck } from './entity-state.js';
25
+ import type { ScopedSql } from './scope-host.js';
26
+ import type { SystemScheduleState } from './system-switch.js';
27
+ /** How many entities one purge pass deletes per entity type. A full batch leaves the schedule due. */
28
+ export declare const PURGE_BATCH = 50;
29
+ /**
30
+ * Is `entity` out of reach as a parent (#119): its type declares trash, and it is in the trash or
31
+ * does not exist. The two answer as ONE, so `ctx.link` cannot be used to tell a binned entity from
32
+ * a missing one. `false` for a type that declares no trash — the kernel never read those rows
33
+ * before, and linking to one is unchanged.
34
+ */
35
+ export declare function isUnreachableParent(sql: ScopedSql, plans: ReadonlyMap<string, EntityStatePlan>, entity: EntityRef): boolean;
36
+ /** What the refusal needs from the adapter, inside the operation's own transaction. */
37
+ export interface TrashRefusalDeps {
38
+ /** RAW access — the state columns are read, never written, but the guarded seam is module code's. */
39
+ readonly sql: ScopedSql;
40
+ readonly plans: ReadonlyMap<string, EntityStatePlan>;
41
+ /** The operation's own check, so a pass is one of its authorizations and a denial is recorded as its own. */
42
+ readonly check: StateCheck;
43
+ }
44
+ /**
45
+ * Refuse an operation reaching a trashed entity it did not declare it reaches (#119).
46
+ *
47
+ * Runs after `BEGIN` and before the guards and the handler, for every caller and every door.
48
+ *
49
+ * **The order is the security property.** On a trashed entity the operation's DECLARED key is
50
+ * checked first, exactly as the handler's first line would have: a caller without it gets the
51
+ * `forbidden` an active entity would have given them, so the bin is not something they can
52
+ * probe. Only a caller who holds the key learns it is gone — `not_found`, the answer the
53
+ * per-handler check gave. An active entity is never checked here; the handler does it, as
54
+ * always, so a pass is never recorded twice.
55
+ *
56
+ * `purge` is set only by the host's own purge sweep (`InvokeOptions` carries no such field, and an
57
+ * adapter refuses a call that tries to supply one). The CUTOFF is computed here, from `now` — the
58
+ * host's clock — and the entity's declared horizon, never taken from a caller: the entity must
59
+ * still be trashed at or before it, or the purge is `conflict` (`purge_not_due`). So a restore
60
+ * that landed between the sweep's selection and this turn wins, and nothing can purge early.
61
+ */
62
+ export declare function refuseTrashedTarget(deps: TrashRefusalDeps, operation: string, target: OperationTarget | undefined, input: unknown, purge?: {
63
+ readonly now: string;
64
+ readonly gate: PurgeGateFacts;
65
+ }): Promise<void>;
66
+ /**
67
+ * The keys a system principal's checks refuse on this call (#119): its module's purge-only keys,
68
+ * unless the call is the host's own purge sweep invoking the purge operation. `undefined` —
69
+ * nothing withheld — for any other subject, and for a module with no purge-only key.
70
+ */
71
+ export declare function withheldKeysFor(purgeOnlyKeys: ReadonlySet<string> | undefined, target: OperationTarget | undefined, purging: boolean): ReadonlySet<string> | undefined;
72
+ /**
73
+ * Refuse an invoke that tries to supply a purge from outside (#119). Purge authority comes only from
74
+ * the host's own sweep, through a path no caller can construct; an options object carrying the
75
+ * field is somebody trying, and is told so rather than silently ignored.
76
+ */
77
+ export declare function assertNoCallerPurge(options: object | undefined): void;
78
+ /** The latest trash instant still due for purge at `now` — `now` minus the horizon. */
79
+ export declare function purgeCutoffOf(now: string, days: number): string;
80
+ /** A position in the purge walk's order: the trash instant and the id of the last entity tried. */
81
+ export interface PurgeKey {
82
+ readonly at: string;
83
+ readonly id: string;
84
+ }
85
+ /**
86
+ * The ids due for purge: trashed at or before `cutoff`, oldest trash first, at most `limit` —
87
+ * and, given `after`, only those strictly after it in that order (#2096). The predicate leads with
88
+ * the purge index's own `WHERE`, so the walk reads only the bin; `after` is compared as a VALUE,
89
+ * so a key whose entity has since been purged or restored still places the walk correctly.
90
+ */
91
+ export declare function purgeCandidates(sql: ScopedSql, plan: EntityStatePlan, cutoff: string, limit?: number, after?: PurgeKey | null): PurgeKey[];
92
+ /**
93
+ * A purge LAP in progress (#2096) — what a schedule's cadence row holds in `purge_cursor` between
94
+ * passes. A lap walks the whole due bin, oldest first, `PURGE_BATCH` at a time; each pass resumes
95
+ * after the last entity the one before it tried, whatever became of that entity. So entities that
96
+ * keep failing cannot hold the head of the walk: the walk moves past them, reaches everything due
97
+ * behind them in the same lap, and tries them again in the next.
98
+ *
99
+ * `failed` counts the purges that failed in the lap's earlier passes, so the pass that closes the
100
+ * lap — the one that writes the cadence row — records the lap `failed` even when its own batch
101
+ * succeeded.
102
+ */
103
+ export interface PurgeLap {
104
+ /** Where the next pass resumes, or null at the start of a lap. */
105
+ readonly after: PurgeKey | null;
106
+ readonly failed: number;
107
+ }
108
+ /**
109
+ * The lap a stored `purge_cursor` holds. NULL — no lap in progress, a row written before the
110
+ * column, or no row at all — is the start of a lap, and so is a value this code cannot read: the
111
+ * worst a lost cursor costs is walking from the oldest again.
112
+ */
113
+ export declare function purgeLapOf(stored: string | null | undefined): PurgeLap;
114
+ /** Read the purge schedule's lap from its cadence row (`kind = 'schedule'`, keyed by the operation). */
115
+ export declare function readPurgeLap(sql: ScopedSql, operation: string): PurgeLap;
116
+ /** One purge horizon's due work on a scope, for one pass of its lap. */
117
+ export interface PurgeDue {
118
+ readonly cutoff: string;
119
+ /** The purge operation's input field carrying the id. */
120
+ readonly idFrom: string;
121
+ /** The ids this pass tries, in the walk's order. */
122
+ readonly ids: string[];
123
+ /** The lap as this pass found it. */
124
+ readonly lap: PurgeLap;
125
+ /** Where the next pass resumes when more is due after these ids — or null: this pass closes the lap. */
126
+ readonly next: PurgeKey | null;
127
+ }
128
+ /**
129
+ * One purge horizon's due work on a scope (#119, #2096): the cutoff, the input field carrying the
130
+ * id, and the next `limit` due ids of the lap the cadence row records — read one past the batch, so
131
+ * `more` is known rather than guessed from a full batch. Registration has tied the schedule to a
132
+ * declared horizon and the entity's purge operation, so a miss here is a wiring fault.
133
+ */
134
+ export declare function purgeDueOf(sql: ScopedSql, plans: ReadonlyMap<string, EntityStatePlan>, targets: ReadonlyMap<string, OperationTarget>, operation: string, entityType: string, now: string, limit?: number): PurgeDue;
135
+ /**
136
+ * What the purge sweep's gate reads (#119), each fact from the scope's OWN state as the adapter
137
+ * holds it — never from the caller. The adapter reads them before the sweep selects anything and
138
+ * again inside each purge's transaction, and both go through `purgeHeldBy`.
139
+ */
140
+ export interface PurgeGateFacts {
141
+ /** The module's kill switch on this scope (`systemScheduleState`). */
142
+ readonly switched: SystemScheduleState;
143
+ /** The scope's lifecycle refusal (`lifecycleRefusal`), or null when it may run or none is held. */
144
+ readonly lifecycle: string | null;
145
+ /** Whether the scope is a copy — a fork, a snapshot or a preview — rather than the primary install. */
146
+ readonly copy: boolean;
147
+ /** Whether the tenant the sweep names is foreign to the scope's own record (`tenantVerdict`). */
148
+ readonly foreignTenant: boolean;
149
+ }
150
+ /**
151
+ * THE purge sweep's gate (#119): why this scope may purge nothing now, or null when it may. The
152
+ * same holds the coordinator applies before any schedule fires, applied by the scope itself from
153
+ * whatever of them it records (below: on a directory-backed host, the kill switch). A tenant foreign to the scope is a REFUSAL (`not_found`,
154
+ * the doors' answer for a pair that does not hold), not a hold: nothing about it is "not yet".
155
+ *
156
+ * On a directory-backed host the scope DO enforces the kill switch; tenant, lifecycle, copy and
157
+ * rewind holds are enforced by the coordinator. The scope holds no tenant receipt, lifecycle or copy
158
+ * classification of its own there (the directory is their authority), so those facts read clear —
159
+ * an unrecorded tenant is `unknown`, which passes as at every door.
160
+ */
161
+ export declare function purgeHeldBy(facts: PurgeGateFacts): string | null;
162
+ /** What one purge schedule did on one scope in one pass. */
163
+ export interface PurgePass {
164
+ /** Entities the operation deleted. */
165
+ purged: number;
166
+ /** Entities restored or already gone by their turn — not failures. */
167
+ skipped: number;
168
+ /** One entry per entity whose purge threw for any other reason; it stays in the bin and is retried. */
169
+ errors: {
170
+ entityId: string;
171
+ error: string;
172
+ }[];
173
+ /** More is due after this batch: the lap continues, and the schedule stays due (`purgeStillDue`). */
174
+ more: boolean;
175
+ /**
176
+ * Purges that failed in the EARLIER passes of the lap this pass closed (#2096) — so the cadence
177
+ * row this pass writes says the lap failed, even when this batch did not. 0 while the lap goes on.
178
+ * Absent, like `more`, from a scope running code older than the lap, which ran no lap.
179
+ */
180
+ lapFailed?: number;
181
+ /** Why the scope ran no purge at all this pass (`purgeHeldBy`), when its gate held it. */
182
+ held?: string;
183
+ }
184
+ /** A pass the scope's gate held: nothing selected, nothing tried, the lap where it was. */
185
+ export declare function heldPurgePass(held: string): PurgePass;
186
+ /**
187
+ * Run one pass of a purge schedule over the ids the adapter selected (`purgeDueOf`), then record
188
+ * what it did to its lap (#2096). One invoke per entity, each its own transaction, so a crash or a
189
+ * failure loses nothing already committed and the next pass simply selects what is left. An entity
190
+ * that was restored (`purge_not_due`) or is already gone (`not_found`) is skipped, never a failure —
191
+ * the purge is idempotent by state.
192
+ *
193
+ * Then the lap moves on WHATEVER its purges did — that is the whole of #2096: resume after this
194
+ * batch with its failures added while more is due, or close the lap. After the pass, so a pass cut
195
+ * short repeats its batch rather than skipping it. `inScope` runs the write against the scope's
196
+ * spine, in the turn the adapter's storage needs.
197
+ */
198
+ export declare function runPurgePass(operation: string, due: PurgeDue, purgeOne: (entityId: string) => Promise<void>, inScope: (write: (sql: ScopedSql) => void) => unknown): Promise<PurgePass>;
199
+ /**
200
+ * Whether a purge pass leaves its schedule due, so the next sweep pass continues its lap rather
201
+ * than waiting the cadence: more is due after its batch (#2096). It cannot spin (#2087): every pass
202
+ * moves the lap strictly forward, whatever its purges did, and the pass that runs out of due
203
+ * entities closes the lap and records the run — so a cadence window holds one lap, and an entity
204
+ * that keeps failing is tried once per window, not once per sweep tick. A scope running code older
205
+ * than the lap answers no `more`, and its pass waits its cadence.
206
+ */
207
+ export declare function purgeStillDue(pass: PurgePass): boolean;
208
+ /**
209
+ * The keys a module's system principal holds ONLY for its purge schedules (#119): declared by a
210
+ * purge schedule and by no other. Withheld from every system-principal check except the purge
211
+ * sweep's own invoke of the purge operation, so the scope-wide grant seated for a purge cannot
212
+ * run anything else — another operation checking the same key, a job step, a host-level call.
213
+ */
214
+ export declare function purgeOnlyKeysOf(schedules: readonly ScheduleSpec[]): ReadonlySet<string> | undefined;
215
+ /**
216
+ * A purge pass, as the schedule run reports it: one error row per entity that failed (labelled
217
+ * with its id), and the error that marks the schedule's run `failed` when any did — in this pass,
218
+ * or in an earlier pass of the lap this one closed (#2096), so the cadence row keeps the failure.
219
+ */
220
+ export declare function purgeReportOf(operation: string, entityType: string, pass: PurgePass): {
221
+ errors: {
222
+ operation: string;
223
+ error: string;
224
+ }[];
225
+ failure?: Error;
226
+ };
227
+ /**
228
+ * Hold one module's registration to the trash rules (#119), and answer the targets the host
229
+ * keeps. Refuses, never skips — each of these is a binned entity reachable while the module
230
+ * believes it is not:
231
+ *
232
+ * The targets are DERIVED, never handed over: `operationInputsOf(ops)` records the declared
233
+ * surface of the frozen map it returns (`declaredSurfaceOf`, which nothing else can write), and the
234
+ * host reads each operation's target off the same declaration it parses with. A module with a trashable entity must therefore
235
+ * - pass `operationInputs` built by `operationInputsOf`, so there is a declared surface to read;
236
+ * - declare every operation it binds there — an undeclared one could address a binned entity and
237
+ * the host could not see which;
238
+ * - declare a `trashed: 'purges'` operation whose input is a strict object holding the id and nothing else.
239
+ *
240
+ * Also refused: an opt-in on an entity that declares no trash here, a purge horizon without
241
+ * exactly the schedule `purgeSchedulesOf` derives for it, and a purge schedule that does not run
242
+ * the entity's `trashed: 'purges'` operation.
243
+ */
244
+ export declare function registerTrashTargets(moduleId: string, ownOps: ReadonlySet<string>, operationInputs: Readonly<Record<string, unknown>> | undefined, entityStates: readonly EntityStateDeclaration[] | undefined, schedules: readonly ScheduleSpec[] | undefined): Map<string, OperationTarget>;
245
+ //# sourceMappingURL=entity-trash.d.ts.map