@powerhousedao/reactor-workflow 6.2.3-dev.33 → 6.2.3-dev.35

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/README.md CHANGED
@@ -104,7 +104,29 @@ the cursor never passes an event that is not yet durable.
104
104
  A workflow document's `DELETE_DOCUMENT` disarms it as disabling does: its
105
105
  deliveries stop once the operation is indexed, a piece trigger's `onDisable`
106
106
  runs, and then its trigger row, its FLOW `ctx.store` partition, its webhook
107
- token and its dedupe keys are deleted. A restart finds nothing to re-arm.
107
+ token and its dedupe keys are deleted. A restart finds nothing to re-arm. Its
108
+ `PURGE_DOCUMENT` marker does the same whether or not the deletion was seen, and
109
+ also drops the trigger-test store partitions; the read model awaits it, so a
110
+ failure holds the cursor below the marker.
111
+
112
+ A document's purge (`PURGE_DOCUMENT`) deletes every run that carried it: the
113
+ runs `run_document` ties to it, the runs whose trigger payload names it as
114
+ `documentId`, `driveId` or `parentId`, the test runs whose sample (a step's
115
+ `output`, a payload or a list of them) names it the same way, a purged
116
+ workflow's own runs (`run.workflow_id`, test runs included), and every rerun
117
+ of those, transitively. Their
118
+ `step_execution` and `run_document` rows go with them; a `trigger_dedupe` row
119
+ they claimed keeps its key and loses its `run_id`. A run erased while it is
120
+ still executing journals nothing more from this process. The read model's
121
+ fence is `"skip"`: the journal lives on the relational handle, not the
122
+ reactor's, so a run the purge races can still be written after the marker was
123
+ applied; a rescan from just below the marker repairs it.
124
+
125
+ Not erased, because nothing ties it to a document: another workflow's
126
+ `trigger_state.store_state` (vestigial, but an unmigrated legacy blob may
127
+ remain), `trigger_dedupe.dedupe_key` (an operation key, which can embed a
128
+ document id) and `piece_store.value` (whatever a piece stored), and a test
129
+ run's step output that names the id anywhere but those payload fields.
108
130
 
109
131
  `runsPage` pages newest first on when a run was journaled (`enqueued_at`),
110
132
  which starting a PENDING run leaves alone, so a run keeps its place between
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as BlockResolution, C as PieceResolver, E as EgressPolicy, b as PieceWorkerResult, f as SecretStore, g as WorkflowRunResult, h as StepExecutionRecord, j as PieceOrigin, k as BlockMatch, l as ConnectionRequest, m as PropertySettingDef, n as packagePieces, o as AttachmentPort, r as CORE_PIECE_NAME, t as PieceRegistry, y as PieceWorker } from "./piece-registry-iXg2XQxp.js";
1
+ import { A as BlockResolution, C as PieceResolver, E as EgressPolicy, b as PieceWorkerResult, f as SecretStore, g as WorkflowRunResult, h as StepExecutionRecord, j as PieceOrigin, k as BlockMatch, l as ConnectionRequest, m as PropertySettingDef, n as packagePieces, o as AttachmentPort, r as CORE_PIECE_NAME, t as PieceRegistry, y as PieceWorker } from "./piece-registry-Bt1Cd3ly.js";
2
2
  import { ActionBase, TriggerBase } from "@powerhousedao/pieces-framework";
3
3
  import { ILogger, OperationWithContext } from "document-model";
4
4
  import { BlockIdentity, BlockRef } from "@powerhousedao/pieces-framework/block-type";
@@ -260,6 +260,12 @@ interface WorkflowRuntimeDB {
260
260
  trigger_dedupe: TriggerDedupeRow;
261
261
  piece_store: PieceStoreRow;
262
262
  }
263
+ interface ErasedRuns {
264
+ runs: number;
265
+ steps: number;
266
+ documents: number;
267
+ dedupeKeysUnlinked: number;
268
+ }
263
269
  interface RunKey {
264
270
  enqueuedAt: string;
265
271
  id: string;
@@ -327,6 +333,7 @@ declare class WorkflowRunStore {
327
333
  claimDedupe(workflowId: string, dedupeKey: string, ttlMs: number, nowIso: string): Promise<boolean>;
328
334
  deleteDedupe(workflowId: string): Promise<void>;
329
335
  pruneFinishedRuns(cutoffIso: string, batchSize?: number): Promise<number>;
336
+ eraseRunsForDocuments(documentIds: string[]): Promise<ErasedRuns>;
330
337
  pruneDedupe(cutoffIso: string): Promise<number>;
331
338
  getPieceStoreValue(scope: string, scopeKey: string, key: string): Promise<unknown>;
332
339
  setPieceStoreValue(scope: string, scopeKey: string, key: string, value: unknown): Promise<void>;
@@ -494,7 +501,12 @@ export declare class WorkflowRuntimeService {
494
501
  private readonly attachments?;
495
502
  private executor?;
496
503
  private pieceWorkers?;
497
- private readonly storePromise;
504
+ private storePromise;
505
+ private storeError?;
506
+ private storeOpening;
507
+ private storeReopenAt;
508
+ private storeReopenMs;
509
+ private retentionSweep?;
498
510
  private secretsPromise?;
499
511
  private oauthAttemptsPromise?;
500
512
  private tokenRefresher?;
@@ -506,6 +518,7 @@ export declare class WorkflowRuntimeService {
506
518
  private startRetention;
507
519
  private sweepRetention;
508
520
  store(): Promise<WorkflowRunStore | undefined>;
521
+ private openStore;
509
522
  secrets(): Promise<SecretStore>;
510
523
  private secretProvider;
511
524
  private oauthAttempts;
@@ -546,7 +559,10 @@ export declare class WorkflowRuntimeService {
546
559
  private readonly seenOps;
547
560
  private readonly seenOpsQueue;
548
561
  private alreadySeen;
562
+ onDocumentsPurged(markers: OperationWithContext[]): Promise<ErasedRuns>;
549
563
  onOperations(operations: OperationWithContext[]): Promise<void>;
564
+ private readonly unjournaledFires;
565
+ private fireUnjournaled;
550
566
  private enqueueFire;
551
567
  private fireFromTrigger;
552
568
  private readonly firedLifecycle;
@@ -559,6 +575,9 @@ export declare class WorkflowRuntimeService {
559
575
  private driveIdFromParent;
560
576
  private forgetDeletedWorkflow;
561
577
  private disarmDeleted;
578
+ private dropDeleted;
579
+ private releaseDeleted;
580
+ private erasePurgedWorkflow;
562
581
  private matchDocumentLifecycle;
563
582
  private matchDriveLifecycle;
564
583
  private triggerSupervisor?;
@@ -579,6 +598,7 @@ export declare class WorkflowRuntimeService {
579
598
  /** The per-document policy the service enforces before a delivery reaches this code;
580
599
  * undefined means the workflow is not armed, answered exactly as an unknown token is. */
581
600
  webhookPolicy(workflowId: string): Promise<WebhookPolicy | undefined>;
601
+ private liveWebhook;
582
602
  private policyOf;
583
603
  webhookEndpoint(workflowId: string, ctx?: WorkflowCaller, access?: WorkflowAccessOptions): Promise<WebhookEndpointRecord | null>;
584
604
  private mintWebhookEndpoint;