@smthrs/control 0.0.0-stage → 1.0.0-rc.4
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 +194 -0
- package/LICENSE +21 -0
- package/README.md +168 -2
- package/dist/cjs/ApprovalAuthority.d.ts +73 -0
- package/dist/cjs/ApprovalAuthority.d.ts.map +1 -0
- package/dist/cjs/ApprovalAuthority.js +62 -0
- package/dist/cjs/ApprovalAuthority.js.map +7 -0
- package/dist/cjs/Cancellation.d.ts +107 -0
- package/dist/cjs/Cancellation.d.ts.map +1 -0
- package/dist/cjs/Cancellation.js +72 -0
- package/dist/cjs/Cancellation.js.map +7 -0
- package/dist/cjs/Channels.d.ts +170 -0
- package/dist/cjs/Channels.d.ts.map +1 -0
- package/dist/cjs/Channels.js +278 -0
- package/dist/cjs/Channels.js.map +7 -0
- package/dist/cjs/Control.d.ts +202 -0
- package/dist/cjs/Control.d.ts.map +1 -0
- package/dist/cjs/Control.js +47 -0
- package/dist/cjs/Control.js.map +7 -0
- package/dist/cjs/ControlClient.d.ts +52 -0
- package/dist/cjs/ControlClient.d.ts.map +1 -0
- package/dist/cjs/ControlClient.js +191 -0
- package/dist/cjs/ControlClient.js.map +7 -0
- package/dist/cjs/ControlError.d.ts +318 -0
- package/dist/cjs/ControlError.d.ts.map +1 -0
- package/dist/cjs/ControlError.js +249 -0
- package/dist/cjs/ControlError.js.map +7 -0
- package/dist/cjs/ControlExecutor.d.ts +372 -0
- package/dist/cjs/ControlExecutor.d.ts.map +1 -0
- package/dist/cjs/ControlExecutor.js +123 -0
- package/dist/cjs/ControlExecutor.js.map +7 -0
- package/dist/cjs/ControlFacts.d.ts +454 -0
- package/dist/cjs/ControlFacts.d.ts.map +1 -0
- package/dist/cjs/ControlFacts.js +261 -0
- package/dist/cjs/ControlFacts.js.map +7 -0
- package/dist/cjs/ControlLive.d.ts +23 -0
- package/dist/cjs/ControlLive.d.ts.map +1 -0
- package/dist/cjs/ControlLive.js +1293 -0
- package/dist/cjs/ControlLive.js.map +7 -0
- package/dist/cjs/ControlRpcs.d.ts +1204 -0
- package/dist/cjs/ControlRpcs.d.ts.map +1 -0
- package/dist/cjs/ControlRpcs.js +247 -0
- package/dist/cjs/ControlRpcs.js.map +7 -0
- package/dist/cjs/ControlRuntime.d.ts +635 -0
- package/dist/cjs/ControlRuntime.d.ts.map +1 -0
- package/dist/cjs/ControlRuntime.js +744 -0
- package/dist/cjs/ControlRuntime.js.map +7 -0
- package/dist/cjs/ControlSchema.d.ts +2642 -0
- package/dist/cjs/ControlSchema.d.ts.map +1 -0
- package/dist/cjs/ControlSchema.js +634 -0
- package/dist/cjs/ControlSchema.js.map +7 -0
- package/dist/cjs/ControlServer.d.ts +51 -0
- package/dist/cjs/ControlServer.d.ts.map +1 -0
- package/dist/cjs/ControlServer.js +121 -0
- package/dist/cjs/ControlServer.js.map +7 -0
- package/dist/cjs/Credential.d.ts +136 -0
- package/dist/cjs/Credential.d.ts.map +1 -0
- package/dist/cjs/Credential.js +168 -0
- package/dist/cjs/Credential.js.map +7 -0
- package/dist/cjs/CredentialCipher.d.ts +90 -0
- package/dist/cjs/CredentialCipher.d.ts.map +1 -0
- package/dist/cjs/CredentialCipher.js +45 -0
- package/dist/cjs/CredentialCipher.js.map +7 -0
- package/dist/cjs/CredentialStore.d.ts +97 -0
- package/dist/cjs/CredentialStore.d.ts.map +1 -0
- package/dist/cjs/CredentialStore.js +81 -0
- package/dist/cjs/CredentialStore.js.map +7 -0
- package/dist/cjs/DispatchReader.d.ts +112 -0
- package/dist/cjs/DispatchReader.d.ts.map +1 -0
- package/dist/cjs/DispatchReader.js +45 -0
- package/dist/cjs/DispatchReader.js.map +7 -0
- package/dist/cjs/Health.d.ts +333 -0
- package/dist/cjs/Health.d.ts.map +1 -0
- package/dist/cjs/Health.js +311 -0
- package/dist/cjs/Health.js.map +7 -0
- package/dist/cjs/JevSessionChecker.d.ts +57 -0
- package/dist/cjs/JevSessionChecker.d.ts.map +1 -0
- package/dist/cjs/JevSessionChecker.js +113 -0
- package/dist/cjs/JevSessionChecker.js.map +7 -0
- package/dist/cjs/Lineage.d.ts +131 -0
- package/dist/cjs/Lineage.d.ts.map +1 -0
- package/dist/cjs/Lineage.js +81 -0
- package/dist/cjs/Lineage.js.map +7 -0
- package/dist/cjs/Migrations.d.ts +34 -0
- package/dist/cjs/Migrations.d.ts.map +1 -0
- package/dist/cjs/Migrations.js +60 -0
- package/dist/cjs/Migrations.js.map +7 -0
- package/dist/cjs/Monitor.d.ts +282 -0
- package/dist/cjs/Monitor.d.ts.map +1 -0
- package/dist/cjs/Monitor.js +283 -0
- package/dist/cjs/Monitor.js.map +7 -0
- package/dist/cjs/ScopedToken.d.ts +193 -0
- package/dist/cjs/ScopedToken.d.ts.map +1 -0
- package/dist/cjs/ScopedToken.js +135 -0
- package/dist/cjs/ScopedToken.js.map +7 -0
- package/dist/cjs/SqlControlRuntime.d.ts +161 -0
- package/dist/cjs/SqlControlRuntime.d.ts.map +1 -0
- package/dist/cjs/SqlControlRuntime.js +1522 -0
- package/dist/cjs/SqlControlRuntime.js.map +7 -0
- package/dist/cjs/SqlCredentialStore.d.ts +43 -0
- package/dist/cjs/SqlCredentialStore.d.ts.map +1 -0
- package/dist/cjs/SqlCredentialStore.js +113 -0
- package/dist/cjs/SqlCredentialStore.js.map +7 -0
- package/dist/cjs/Steering.d.ts +69 -0
- package/dist/cjs/Steering.d.ts.map +1 -0
- package/dist/cjs/Steering.js +49 -0
- package/dist/cjs/Steering.js.map +7 -0
- package/dist/cjs/SystemFlows.d.ts +223 -0
- package/dist/cjs/SystemFlows.d.ts.map +1 -0
- package/dist/cjs/SystemFlows.js +195 -0
- package/dist/cjs/SystemFlows.js.map +7 -0
- package/dist/cjs/WebCryptoCipher.d.ts +49 -0
- package/dist/cjs/WebCryptoCipher.d.ts.map +1 -0
- package/dist/cjs/WebCryptoCipher.js +129 -0
- package/dist/cjs/WebCryptoCipher.js.map +7 -0
- package/dist/cjs/WebhookChannel.d.ts +113 -0
- package/dist/cjs/WebhookChannel.d.ts.map +1 -0
- package/dist/cjs/WebhookChannel.js +98 -0
- package/dist/cjs/WebhookChannel.js.map +7 -0
- package/dist/cjs/index.d.ts +160 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +91 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/MutationBoundary.d.ts +27 -0
- package/dist/cjs/internal/MutationBoundary.d.ts.map +1 -0
- package/dist/cjs/internal/MutationBoundary.js +50 -0
- package/dist/cjs/internal/MutationBoundary.js.map +7 -0
- package/dist/cjs/internal/activeFibers.d.ts +12 -0
- package/dist/cjs/internal/activeFibers.d.ts.map +1 -0
- package/dist/cjs/internal/activeFibers.js +30 -0
- package/dist/cjs/internal/activeFibers.js.map +7 -0
- package/dist/cjs/internal/issues.d.ts +28 -0
- package/dist/cjs/internal/issues.d.ts.map +1 -0
- package/dist/cjs/internal/issues.js +34 -0
- package/dist/cjs/internal/issues.js.map +7 -0
- package/dist/cjs/internal/planning.d.ts +347 -0
- package/dist/cjs/internal/planning.d.ts.map +1 -0
- package/dist/cjs/internal/planning.js +137 -0
- package/dist/cjs/internal/planning.js.map +7 -0
- package/dist/cjs/internal/sqlSchemaErrors.d.ts +18 -0
- package/dist/cjs/internal/sqlSchemaErrors.d.ts.map +1 -0
- package/dist/cjs/internal/sqlSchemaErrors.js +40 -0
- package/dist/cjs/internal/sqlSchemaErrors.js.map +7 -0
- package/dist/cjs/migrations/0001_control_tables.d.ts +18 -0
- package/dist/cjs/migrations/0001_control_tables.d.ts.map +1 -0
- package/dist/cjs/migrations/0001_control_tables.js +115 -0
- package/dist/cjs/migrations/0001_control_tables.js.map +7 -0
- package/dist/cjs/migrations/0002_run_keys.d.ts +15 -0
- package/dist/cjs/migrations/0002_run_keys.d.ts.map +1 -0
- package/dist/cjs/migrations/0002_run_keys.js +44 -0
- package/dist/cjs/migrations/0002_run_keys.js.map +7 -0
- package/dist/cjs/migrations/0003_signal_commands.d.ts +13 -0
- package/dist/cjs/migrations/0003_signal_commands.d.ts.map +1 -0
- package/dist/cjs/migrations/0003_signal_commands.js +50 -0
- package/dist/cjs/migrations/0003_signal_commands.js.map +7 -0
- package/dist/cjs/migrations/0004_approval_decisions.d.ts +13 -0
- package/dist/cjs/migrations/0004_approval_decisions.d.ts.map +1 -0
- package/dist/cjs/migrations/0004_approval_decisions.js +45 -0
- package/dist/cjs/migrations/0004_approval_decisions.js.map +7 -0
- package/dist/cjs/migrations/0005_signal_principals.d.ts +18 -0
- package/dist/cjs/migrations/0005_signal_principals.d.ts.map +1 -0
- package/dist/cjs/migrations/0005_signal_principals.js +45 -0
- package/dist/cjs/migrations/0005_signal_principals.js.map +7 -0
- package/dist/cjs/migrations/0006_run_principals.d.ts +18 -0
- package/dist/cjs/migrations/0006_run_principals.d.ts.map +1 -0
- package/dist/cjs/migrations/0006_run_principals.js +49 -0
- package/dist/cjs/migrations/0006_run_principals.js.map +7 -0
- package/dist/cjs/migrations/0007_resume_consent.d.ts +18 -0
- package/dist/cjs/migrations/0007_resume_consent.d.ts.map +1 -0
- package/dist/cjs/migrations/0007_resume_consent.js +46 -0
- package/dist/cjs/migrations/0007_resume_consent.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/TestControl.d.ts +19 -0
- package/dist/cjs/test/TestControl.d.ts.map +1 -0
- package/dist/cjs/test/TestControl.js +62 -0
- package/dist/cjs/test/TestControl.js.map +7 -0
- package/dist/esm/ApprovalAuthority.d.ts +73 -0
- package/dist/esm/ApprovalAuthority.d.ts.map +1 -0
- package/dist/esm/ApprovalAuthority.js +72 -0
- package/dist/esm/ApprovalAuthority.js.map +1 -0
- package/dist/esm/Cancellation.d.ts +107 -0
- package/dist/esm/Cancellation.d.ts.map +1 -0
- package/dist/esm/Cancellation.js +116 -0
- package/dist/esm/Cancellation.js.map +1 -0
- package/dist/esm/Channels.d.ts +170 -0
- package/dist/esm/Channels.d.ts.map +1 -0
- package/dist/esm/Channels.js +312 -0
- package/dist/esm/Channels.js.map +1 -0
- package/dist/esm/Control.d.ts +202 -0
- package/dist/esm/Control.d.ts.map +1 -0
- package/dist/esm/Control.js +42 -0
- package/dist/esm/Control.js.map +1 -0
- package/dist/esm/ControlClient.d.ts +52 -0
- package/dist/esm/ControlClient.d.ts.map +1 -0
- package/dist/esm/ControlClient.js +217 -0
- package/dist/esm/ControlClient.js.map +1 -0
- package/dist/esm/ControlError.d.ts +318 -0
- package/dist/esm/ControlError.d.ts.map +1 -0
- package/dist/esm/ControlError.js +359 -0
- package/dist/esm/ControlError.js.map +1 -0
- package/dist/esm/ControlExecutor.d.ts +372 -0
- package/dist/esm/ControlExecutor.d.ts.map +1 -0
- package/dist/esm/ControlExecutor.js +212 -0
- package/dist/esm/ControlExecutor.js.map +1 -0
- package/dist/esm/ControlFacts.d.ts +454 -0
- package/dist/esm/ControlFacts.d.ts.map +1 -0
- package/dist/esm/ControlFacts.js +324 -0
- package/dist/esm/ControlFacts.js.map +1 -0
- package/dist/esm/ControlLive.d.ts +23 -0
- package/dist/esm/ControlLive.d.ts.map +1 -0
- package/dist/esm/ControlLive.js +1589 -0
- package/dist/esm/ControlLive.js.map +1 -0
- package/dist/esm/ControlRpcs.d.ts +1204 -0
- package/dist/esm/ControlRpcs.d.ts.map +1 -0
- package/dist/esm/ControlRpcs.js +299 -0
- package/dist/esm/ControlRpcs.js.map +1 -0
- package/dist/esm/ControlRuntime.d.ts +635 -0
- package/dist/esm/ControlRuntime.d.ts.map +1 -0
- package/dist/esm/ControlRuntime.js +808 -0
- package/dist/esm/ControlRuntime.js.map +1 -0
- package/dist/esm/ControlSchema.d.ts +2642 -0
- package/dist/esm/ControlSchema.d.ts.map +1 -0
- package/dist/esm/ControlSchema.js +1030 -0
- package/dist/esm/ControlSchema.js.map +1 -0
- package/dist/esm/ControlServer.d.ts +51 -0
- package/dist/esm/ControlServer.d.ts.map +1 -0
- package/dist/esm/ControlServer.js +145 -0
- package/dist/esm/ControlServer.js.map +1 -0
- package/dist/esm/Credential.d.ts +136 -0
- package/dist/esm/Credential.d.ts.map +1 -0
- package/dist/esm/Credential.js +190 -0
- package/dist/esm/Credential.js.map +1 -0
- package/dist/esm/CredentialCipher.d.ts +90 -0
- package/dist/esm/CredentialCipher.d.ts.map +1 -0
- package/dist/esm/CredentialCipher.js +56 -0
- package/dist/esm/CredentialCipher.js.map +1 -0
- package/dist/esm/CredentialStore.d.ts +97 -0
- package/dist/esm/CredentialStore.d.ts.map +1 -0
- package/dist/esm/CredentialStore.js +101 -0
- package/dist/esm/CredentialStore.js.map +1 -0
- package/dist/esm/DispatchReader.d.ts +112 -0
- package/dist/esm/DispatchReader.d.ts.map +1 -0
- package/dist/esm/DispatchReader.js +76 -0
- package/dist/esm/DispatchReader.js.map +1 -0
- package/dist/esm/Health.d.ts +333 -0
- package/dist/esm/Health.d.ts.map +1 -0
- package/dist/esm/Health.js +400 -0
- package/dist/esm/Health.js.map +1 -0
- package/dist/esm/JevSessionChecker.d.ts +57 -0
- package/dist/esm/JevSessionChecker.d.ts.map +1 -0
- package/dist/esm/JevSessionChecker.js +108 -0
- package/dist/esm/JevSessionChecker.js.map +1 -0
- package/dist/esm/Lineage.d.ts +131 -0
- package/dist/esm/Lineage.d.ts.map +1 -0
- package/dist/esm/Lineage.js +174 -0
- package/dist/esm/Lineage.js.map +1 -0
- package/dist/esm/Migrations.d.ts +34 -0
- package/dist/esm/Migrations.d.ts.map +1 -0
- package/dist/esm/Migrations.js +53 -0
- package/dist/esm/Migrations.js.map +1 -0
- package/dist/esm/Monitor.d.ts +282 -0
- package/dist/esm/Monitor.d.ts.map +1 -0
- package/dist/esm/Monitor.js +415 -0
- package/dist/esm/Monitor.js.map +1 -0
- package/dist/esm/ScopedToken.d.ts +193 -0
- package/dist/esm/ScopedToken.d.ts.map +1 -0
- package/dist/esm/ScopedToken.js +224 -0
- package/dist/esm/ScopedToken.js.map +1 -0
- package/dist/esm/SqlControlRuntime.d.ts +161 -0
- package/dist/esm/SqlControlRuntime.d.ts.map +1 -0
- package/dist/esm/SqlControlRuntime.js +1756 -0
- package/dist/esm/SqlControlRuntime.js.map +1 -0
- package/dist/esm/SqlCredentialStore.d.ts +43 -0
- package/dist/esm/SqlCredentialStore.d.ts.map +1 -0
- package/dist/esm/SqlCredentialStore.js +97 -0
- package/dist/esm/SqlCredentialStore.js.map +1 -0
- package/dist/esm/Steering.d.ts +69 -0
- package/dist/esm/Steering.d.ts.map +1 -0
- package/dist/esm/Steering.js +89 -0
- package/dist/esm/Steering.js.map +1 -0
- package/dist/esm/SystemFlows.d.ts +223 -0
- package/dist/esm/SystemFlows.d.ts.map +1 -0
- package/dist/esm/SystemFlows.js +198 -0
- package/dist/esm/SystemFlows.js.map +1 -0
- package/dist/esm/WebCryptoCipher.d.ts +49 -0
- package/dist/esm/WebCryptoCipher.d.ts.map +1 -0
- package/dist/esm/WebCryptoCipher.js +123 -0
- package/dist/esm/WebCryptoCipher.js.map +1 -0
- package/dist/esm/WebhookChannel.d.ts +113 -0
- package/dist/esm/WebhookChannel.d.ts.map +1 -0
- package/dist/esm/WebhookChannel.js +109 -0
- package/dist/esm/WebhookChannel.js.map +1 -0
- package/dist/esm/index.d.ts +160 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +160 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/MutationBoundary.d.ts +27 -0
- package/dist/esm/internal/MutationBoundary.d.ts.map +1 -0
- package/dist/esm/internal/MutationBoundary.js +40 -0
- package/dist/esm/internal/MutationBoundary.js.map +1 -0
- package/dist/esm/internal/activeFibers.d.ts +12 -0
- package/dist/esm/internal/activeFibers.d.ts.map +1 -0
- package/dist/esm/internal/activeFibers.js +17 -0
- package/dist/esm/internal/activeFibers.js.map +1 -0
- package/dist/esm/internal/issues.d.ts +28 -0
- package/dist/esm/internal/issues.d.ts.map +1 -0
- package/dist/esm/internal/issues.js +35 -0
- package/dist/esm/internal/issues.js.map +1 -0
- package/dist/esm/internal/planning.d.ts +347 -0
- package/dist/esm/internal/planning.d.ts.map +1 -0
- package/dist/esm/internal/planning.js +199 -0
- package/dist/esm/internal/planning.js.map +1 -0
- package/dist/esm/internal/sqlSchemaErrors.d.ts +18 -0
- package/dist/esm/internal/sqlSchemaErrors.d.ts.map +1 -0
- package/dist/esm/internal/sqlSchemaErrors.js +38 -0
- package/dist/esm/internal/sqlSchemaErrors.js.map +1 -0
- package/dist/esm/migrations/0001_control_tables.d.ts +18 -0
- package/dist/esm/migrations/0001_control_tables.d.ts.map +1 -0
- package/dist/esm/migrations/0001_control_tables.js +96 -0
- package/dist/esm/migrations/0001_control_tables.js.map +1 -0
- package/dist/esm/migrations/0002_run_keys.d.ts +15 -0
- package/dist/esm/migrations/0002_run_keys.d.ts.map +1 -0
- package/dist/esm/migrations/0002_run_keys.js +22 -0
- package/dist/esm/migrations/0002_run_keys.js.map +1 -0
- package/dist/esm/migrations/0003_signal_commands.d.ts +13 -0
- package/dist/esm/migrations/0003_signal_commands.d.ts.map +1 -0
- package/dist/esm/migrations/0003_signal_commands.js +26 -0
- package/dist/esm/migrations/0003_signal_commands.js.map +1 -0
- package/dist/esm/migrations/0004_approval_decisions.d.ts +13 -0
- package/dist/esm/migrations/0004_approval_decisions.d.ts.map +1 -0
- package/dist/esm/migrations/0004_approval_decisions.js +25 -0
- package/dist/esm/migrations/0004_approval_decisions.js.map +1 -0
- package/dist/esm/migrations/0005_signal_principals.d.ts +18 -0
- package/dist/esm/migrations/0005_signal_principals.d.ts.map +1 -0
- package/dist/esm/migrations/0005_signal_principals.js +27 -0
- package/dist/esm/migrations/0005_signal_principals.js.map +1 -0
- package/dist/esm/migrations/0006_run_principals.d.ts +18 -0
- package/dist/esm/migrations/0006_run_principals.d.ts.map +1 -0
- package/dist/esm/migrations/0006_run_principals.js +30 -0
- package/dist/esm/migrations/0006_run_principals.js.map +1 -0
- package/dist/esm/migrations/0007_resume_consent.d.ts +18 -0
- package/dist/esm/migrations/0007_resume_consent.d.ts.map +1 -0
- package/dist/esm/migrations/0007_resume_consent.js +27 -0
- package/dist/esm/migrations/0007_resume_consent.js.map +1 -0
- package/dist/esm/test/TestControl.d.ts +19 -0
- package/dist/esm/test/TestControl.d.ts.map +1 -0
- package/dist/esm/test/TestControl.js +30 -0
- package/dist/esm/test/TestControl.js.map +1 -0
- package/docs/README.md +189 -0
- package/docs/api.md +982 -0
- package/docs/concepts/authority.md +109 -0
- package/docs/concepts/cancellation.md +129 -0
- package/docs/concepts/lineage.md +132 -0
- package/docs/concepts/ownership.md +139 -0
- package/docs/concepts/projections.md +203 -0
- package/docs/concepts/receipts.md +128 -0
- package/docs/guides/approvals.md +284 -0
- package/docs/guides/cancel-and-resume.md +162 -0
- package/docs/guides/durable-storage.md +147 -0
- package/docs/guides/implement-an-executor.md +173 -0
- package/docs/guides/ingest-a-webhook.md +177 -0
- package/docs/guides/list-runs.md +160 -0
- package/docs/guides/monitor-runs.md +176 -0
- package/docs/guides/observe-health.md +147 -0
- package/docs/guides/postgres-tests.md +7 -0
- package/docs/guides/serve-over-rpc.md +220 -0
- package/docs/guides/signal-a-run.md +53 -0
- package/docs/guides/steer-a-run.md +138 -0
- package/docs/guides/store-credentials.md +164 -0
- package/docs/guides/testing.md +139 -0
- package/docs/guides/watch-a-run.md +154 -0
- package/docs/installation.md +106 -0
- package/docs/quickstart.md +163 -0
- package/docs/troubleshooting.md +208 -0
- package/package.json +405 -3
- package/src/ApprovalAuthority.ts +114 -0
- package/src/Cancellation.ts +172 -0
- package/src/Channels.ts +493 -0
- package/src/Control.ts +337 -0
- package/src/ControlClient.ts +319 -0
- package/src/ControlError.ts +378 -0
- package/src/ControlExecutor.ts +490 -0
- package/src/ControlFacts.ts +383 -0
- package/src/ControlLive.ts +2127 -0
- package/src/ControlRpcs.ts +443 -0
- package/src/ControlRuntime.ts +1601 -0
- package/src/ControlSchema.ts +1380 -0
- package/src/ControlServer.ts +182 -0
- package/src/Credential.ts +310 -0
- package/src/CredentialCipher.ts +110 -0
- package/src/CredentialStore.ts +152 -0
- package/src/DispatchReader.ts +122 -0
- package/src/Health.ts +591 -0
- package/src/JevSessionChecker.ts +127 -0
- package/src/Lineage.ts +203 -0
- package/src/Migrations.ts +56 -0
- package/src/Monitor.ts +600 -0
- package/src/ScopedToken.ts +306 -0
- package/src/SqlControlRuntime.ts +2478 -0
- package/src/SqlCredentialStore.ts +148 -0
- package/src/Steering.ts +96 -0
- package/src/SystemFlows.ts +225 -0
- package/src/WebCryptoCipher.ts +169 -0
- package/src/WebhookChannel.ts +166 -0
- package/src/index.ts +188 -0
- package/src/internal/MutationBoundary.ts +46 -0
- package/src/internal/activeFibers.ts +22 -0
- package/src/internal/issues.ts +40 -0
- package/src/internal/planning.ts +262 -0
- package/src/internal/sqlSchemaErrors.ts +37 -0
- package/src/migrations/0001_control_tables.ts +99 -0
- package/src/migrations/0002_run_keys.ts +23 -0
- package/src/migrations/0003_signal_commands.ts +27 -0
- package/src/migrations/0004_approval_decisions.ts +25 -0
- package/src/migrations/0005_signal_principals.ts +27 -0
- package/src/migrations/0006_run_principals.ts +31 -0
- package/src/migrations/0007_resume_consent.ts +28 -0
- package/src/test/TestControl.ts +47 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run ancestry as the control plane reads it.
|
|
3
|
+
*
|
|
4
|
+
* A run's ancestry is recorded by whoever created the run, in four different
|
|
5
|
+
* places: the run row's `parent_run_id`, `lineage_id`, and `round_ordinal`
|
|
6
|
+
* columns; the `flows_run_parents` edge a spawn writes; the `created` and
|
|
7
|
+
* `handed-off` run decisions the engine journals; and the `fork-created`
|
|
8
|
+
* marker time travel writes on a forked child. This module owns the one
|
|
9
|
+
* vocabulary they all project onto — {@link Origin} — and the pure functions
|
|
10
|
+
* that do the projecting, so the durable runtime and the watch stream cannot
|
|
11
|
+
* disagree about what a run's ancestry means.
|
|
12
|
+
*
|
|
13
|
+
* The two event types named here are produced by `@smthrs/engine-store` and
|
|
14
|
+
* `@smthrs/time-travel`. They are named as strings rather than imported
|
|
15
|
+
* because the control plane reads journals, not engines: a control plane that
|
|
16
|
+
* depended on the engine could not project a journal written by a different
|
|
17
|
+
* one.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*/
|
|
21
|
+
import { Schema } from "effect";
|
|
22
|
+
import type { ControlEvent } from "./ControlSchema.ts";
|
|
23
|
+
/**
|
|
24
|
+
* How a run came to exist.
|
|
25
|
+
*
|
|
26
|
+
* The three values are the lineage-edge kinds of
|
|
27
|
+
* `docs/pages/concepts/time-travel.md`: a `child` is a run its parent spawned, a
|
|
28
|
+
* `fork` is a run branched off a parent frame, and a `continuation` is a later
|
|
29
|
+
* round of one trampoline lineage. A rewind is deliberately absent — it
|
|
30
|
+
* truncates a run in place and creates none — and a run with no ancestor has
|
|
31
|
+
* no origin at all.
|
|
32
|
+
*
|
|
33
|
+
* @category models
|
|
34
|
+
* @since 0.1.0
|
|
35
|
+
*/
|
|
36
|
+
export declare const Origin: Schema.Literals<readonly ["child", "fork", "continuation"]>;
|
|
37
|
+
/**
|
|
38
|
+
* How a run came to exist.
|
|
39
|
+
*
|
|
40
|
+
* @category models
|
|
41
|
+
* @since 0.1.0
|
|
42
|
+
*/
|
|
43
|
+
export type Origin = typeof Origin.Type;
|
|
44
|
+
/**
|
|
45
|
+
* The ancestry facts an origin is decided from.
|
|
46
|
+
*
|
|
47
|
+
* @category models
|
|
48
|
+
* @since 0.1.0
|
|
49
|
+
*/
|
|
50
|
+
export interface Ancestry {
|
|
51
|
+
readonly parentRunId?: string | undefined;
|
|
52
|
+
readonly roundOrdinal?: number | undefined;
|
|
53
|
+
/** Whether a `fork-created` marker names this run. */
|
|
54
|
+
readonly forked?: boolean | undefined;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The journal event type carrying an engine run decision.
|
|
58
|
+
*
|
|
59
|
+
* @category constants
|
|
60
|
+
* @since 0.1.0
|
|
61
|
+
*/
|
|
62
|
+
export declare const runDecisionEventType = "flows.engine.run-decision";
|
|
63
|
+
/**
|
|
64
|
+
* The journal event type time travel writes on a forked child.
|
|
65
|
+
*
|
|
66
|
+
* @category constants
|
|
67
|
+
* @since 0.1.0
|
|
68
|
+
*/
|
|
69
|
+
export declare const forkCreatedEventType = "flows.time-travel.fork-created";
|
|
70
|
+
/**
|
|
71
|
+
* The kind `watch` reports a derived ancestry delta under.
|
|
72
|
+
*
|
|
73
|
+
* @category constants
|
|
74
|
+
* @since 0.1.0
|
|
75
|
+
*/
|
|
76
|
+
export declare const lineageEventType = "control.run.lineage";
|
|
77
|
+
/**
|
|
78
|
+
* Decides how a run came to exist from its ancestry facts.
|
|
79
|
+
*
|
|
80
|
+
* A fork wins over a plain child because a fork records `parent_run_id` too:
|
|
81
|
+
* without the marker every fork would be reported as an ordinary child.
|
|
82
|
+
*
|
|
83
|
+
* @param ancestry the run's recorded ancestry
|
|
84
|
+
* @category projections
|
|
85
|
+
* @since 0.1.0
|
|
86
|
+
*/
|
|
87
|
+
export declare const originOf: (ancestry: Ancestry) => Origin | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Derives the ancestry edge one journal entry discloses, if it discloses one.
|
|
90
|
+
*
|
|
91
|
+
* Three entries do, and each names a different pair:
|
|
92
|
+
*
|
|
93
|
+
* | Entry | Ancestor | Descendant |
|
|
94
|
+
* | --- | --- | --- |
|
|
95
|
+
* | `created` naming `parentExecutionId`, at round 0 or with no round | the spawning run | the entry's run |
|
|
96
|
+
* | `handed-off` naming `nextExecutionId` | the entry's run | the next round |
|
|
97
|
+
* | `fork-created` | the forked-from run | the entry's run |
|
|
98
|
+
*
|
|
99
|
+
* The handoff is what carries a trampoline, and a continuation round's own
|
|
100
|
+
* `created` decision is deliberately skipped. The engine journals BOTH in one
|
|
101
|
+
* transaction: `RunDriver` creates the next round with
|
|
102
|
+
* `{decision: "created", lineageId, roundOrdinal, parentExecutionId}` and then
|
|
103
|
+
* records `{decision: "handed-off", nextExecutionId}` on the round that
|
|
104
|
+
* finished. Both name the same pair, so deriving from both would report one
|
|
105
|
+
* run as a `child` of its predecessor on one entry and a `continuation` of it
|
|
106
|
+
* on the other. The handoff is the one kept, because it reaches a consumer
|
|
107
|
+
* watching the run that hands off — which is the run an operator is already
|
|
108
|
+
* following when a trampoline advances.
|
|
109
|
+
*
|
|
110
|
+
* A `created` decision at round 0, or with no round at all, is an ordinary
|
|
111
|
+
* spawn and derives a `child` edge.
|
|
112
|
+
*
|
|
113
|
+
* Everything else derives nothing. This is a projection over entries the
|
|
114
|
+
* control plane did not write, so an entry it does not recognize is not an
|
|
115
|
+
* error.
|
|
116
|
+
*
|
|
117
|
+
* @param event the projected journal entry
|
|
118
|
+
* @category projections
|
|
119
|
+
* @since 0.1.0
|
|
120
|
+
*/
|
|
121
|
+
export declare const derive: (event: ControlEvent) => ControlEvent | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Expands one projected entry into itself plus any ancestry delta it
|
|
124
|
+
* discloses.
|
|
125
|
+
*
|
|
126
|
+
* @param event the projected journal entry
|
|
127
|
+
* @category projections
|
|
128
|
+
* @since 0.1.0
|
|
129
|
+
*/
|
|
130
|
+
export declare const expand: (event: ControlEvent) => ReadonlyArray<ControlEvent>;
|
|
131
|
+
//# sourceMappingURL=Lineage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lineage.d.ts","sourceRoot":"","sources":["../../src/Lineage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,6DAAqD,CAAA;AAExE;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1C,sDAAsD;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACtC;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,8BAA8B,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,mCAAmC,CAAA;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,wBAAwB,CAAA;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,GAAI,UAAU,QAAQ,KAAG,MAAM,GAAG,SAItD,CAAA;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,YAAY,KAAG,YAAY,GAAG,SA8C3D,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,YAAY,KAAG,aAAa,CAAC,YAAY,CAGtE,CAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Lineage_exports = {};
|
|
20
|
+
__export(Lineage_exports, {
|
|
21
|
+
Origin: () => Origin,
|
|
22
|
+
derive: () => derive,
|
|
23
|
+
expand: () => expand,
|
|
24
|
+
forkCreatedEventType: () => forkCreatedEventType,
|
|
25
|
+
lineageEventType: () => lineageEventType,
|
|
26
|
+
originOf: () => originOf,
|
|
27
|
+
runDecisionEventType: () => runDecisionEventType
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Lineage_exports);
|
|
30
|
+
var import_effect = require("effect");
|
|
31
|
+
const Origin = import_effect.Schema.Literals(["child", "fork", "continuation"]);
|
|
32
|
+
const runDecisionEventType = "flows.engine.run-decision";
|
|
33
|
+
const forkCreatedEventType = "flows.time-travel.fork-created";
|
|
34
|
+
const lineageEventType = "control.run.lineage";
|
|
35
|
+
const originOf = (ancestry) => {
|
|
36
|
+
if (ancestry.forked === true) return "fork";
|
|
37
|
+
if (ancestry.roundOrdinal !== void 0 && ancestry.roundOrdinal > 0) return "continuation";
|
|
38
|
+
return ancestry.parentRunId === void 0 ? void 0 : "child";
|
|
39
|
+
};
|
|
40
|
+
const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
41
|
+
const text = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
42
|
+
const ordinal = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
43
|
+
const derive = (event) => {
|
|
44
|
+
if (event.runId === void 0) return void 0;
|
|
45
|
+
const payload = record(event.payload);
|
|
46
|
+
if (payload === void 0) return void 0;
|
|
47
|
+
const edge = event.kind === forkCreatedEventType ? { runId: event.runId, parentRunId: text(payload["parentRunId"]), forked: true } : event.kind !== runDecisionEventType ? void 0 : payload["decision"] === "created" ? (ordinal(payload["roundOrdinal"]) ?? 0) > 0 ? void 0 : { runId: event.runId, parentRunId: text(payload["parentExecutionId"]), forked: false } : payload["decision"] === "handed-off" ? {
|
|
48
|
+
runId: text(payload["nextExecutionId"]),
|
|
49
|
+
parentRunId: event.runId,
|
|
50
|
+
forked: false,
|
|
51
|
+
lineageId: text(payload["lineageId"]),
|
|
52
|
+
roundOrdinal: ordinal(payload["roundOrdinal"])
|
|
53
|
+
} : void 0;
|
|
54
|
+
if (edge === void 0 || edge.runId === void 0 || edge.parentRunId === void 0) return void 0;
|
|
55
|
+
const lineageId = "lineageId" in edge ? edge.lineageId : void 0;
|
|
56
|
+
const roundOrdinal = "roundOrdinal" in edge ? edge.roundOrdinal : void 0;
|
|
57
|
+
const origin = originOf({
|
|
58
|
+
parentRunId: edge.parentRunId,
|
|
59
|
+
...roundOrdinal === void 0 ? {} : { roundOrdinal },
|
|
60
|
+
forked: edge.forked
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
sequence: event.sequence,
|
|
64
|
+
kind: lineageEventType,
|
|
65
|
+
runId: event.runId,
|
|
66
|
+
occurredAt: event.occurredAt,
|
|
67
|
+
payload: {
|
|
68
|
+
runId: edge.runId,
|
|
69
|
+
parentRunId: edge.parentRunId,
|
|
70
|
+
...lineageId === void 0 ? {} : { lineageId },
|
|
71
|
+
...roundOrdinal === void 0 ? {} : { roundOrdinal },
|
|
72
|
+
/* v8 ignore next -- `originOf` answers nothing only without a parent, and the guard above already refused an edge with no parent */
|
|
73
|
+
...origin === void 0 ? {} : { origin }
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
const expand = (event) => {
|
|
78
|
+
const derived = derive(event);
|
|
79
|
+
return derived === void 0 ? [event] : [event, derived];
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=Lineage.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Lineage.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Run ancestry as the control plane reads it.\n *\n * A run's ancestry is recorded by whoever created the run, in four different\n * places: the run row's `parent_run_id`, `lineage_id`, and `round_ordinal`\n * columns; the `flows_run_parents` edge a spawn writes; the `created` and\n * `handed-off` run decisions the engine journals; and the `fork-created`\n * marker time travel writes on a forked child. This module owns the one\n * vocabulary they all project onto \u2014 {@link Origin} \u2014 and the pure functions\n * that do the projecting, so the durable runtime and the watch stream cannot\n * disagree about what a run's ancestry means.\n *\n * The two event types named here are produced by `@smthrs/engine-store` and\n * `@smthrs/time-travel`. They are named as strings rather than imported\n * because the control plane reads journals, not engines: a control plane that\n * depended on the engine could not project a journal written by a different\n * one.\n *\n * @since 0.1.0\n */\n\nimport { Schema } from \"effect\"\nimport type { ControlEvent } from \"./ControlSchema.ts\"\n\n/**\n * How a run came to exist.\n *\n * The three values are the lineage-edge kinds of\n * `docs/pages/concepts/time-travel.md`: a `child` is a run its parent spawned, a\n * `fork` is a run branched off a parent frame, and a `continuation` is a later\n * round of one trampoline lineage. A rewind is deliberately absent \u2014 it\n * truncates a run in place and creates none \u2014 and a run with no ancestor has\n * no origin at all.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Origin = Schema.Literals([\"child\", \"fork\", \"continuation\"])\n\n/**\n * How a run came to exist.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Origin = typeof Origin.Type\n\n/**\n * The ancestry facts an origin is decided from.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Ancestry {\n readonly parentRunId?: string | undefined\n readonly roundOrdinal?: number | undefined\n /** Whether a `fork-created` marker names this run. */\n readonly forked?: boolean | undefined\n}\n\n/**\n * The journal event type carrying an engine run decision.\n *\n * @category constants\n * @since 0.1.0\n */\nexport const runDecisionEventType = \"flows.engine.run-decision\"\n\n/**\n * The journal event type time travel writes on a forked child.\n *\n * @category constants\n * @since 0.1.0\n */\nexport const forkCreatedEventType = \"flows.time-travel.fork-created\"\n\n/**\n * The kind `watch` reports a derived ancestry delta under.\n *\n * @category constants\n * @since 0.1.0\n */\nexport const lineageEventType = \"control.run.lineage\"\n\n/**\n * Decides how a run came to exist from its ancestry facts.\n *\n * A fork wins over a plain child because a fork records `parent_run_id` too:\n * without the marker every fork would be reported as an ordinary child.\n *\n * @param ancestry the run's recorded ancestry\n * @category projections\n * @since 0.1.0\n */\nexport const originOf = (ancestry: Ancestry): Origin | undefined => {\n if (ancestry.forked === true) return \"fork\"\n if (ancestry.roundOrdinal !== undefined && ancestry.roundOrdinal > 0) return \"continuation\"\n return ancestry.parentRunId === undefined ? undefined : \"child\"\n}\n\nconst record = (value: unknown): Readonly<Record<string, unknown>> | undefined =>\n typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? value as Readonly<Record<string, unknown>>\n : undefined\n\nconst text = (value: unknown): string | undefined => typeof value === \"string\" && value.length > 0 ? value : undefined\n\nconst ordinal = (value: unknown): number | undefined =>\n typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0 ? value : undefined\n\n/**\n * Derives the ancestry edge one journal entry discloses, if it discloses one.\n *\n * Three entries do, and each names a different pair:\n *\n * | Entry | Ancestor | Descendant |\n * | --- | --- | --- |\n * | `created` naming `parentExecutionId`, at round 0 or with no round | the spawning run | the entry's run |\n * | `handed-off` naming `nextExecutionId` | the entry's run | the next round |\n * | `fork-created` | the forked-from run | the entry's run |\n *\n * The handoff is what carries a trampoline, and a continuation round's own\n * `created` decision is deliberately skipped. The engine journals BOTH in one\n * transaction: `RunDriver` creates the next round with\n * `{decision: \"created\", lineageId, roundOrdinal, parentExecutionId}` and then\n * records `{decision: \"handed-off\", nextExecutionId}` on the round that\n * finished. Both name the same pair, so deriving from both would report one\n * run as a `child` of its predecessor on one entry and a `continuation` of it\n * on the other. The handoff is the one kept, because it reaches a consumer\n * watching the run that hands off \u2014 which is the run an operator is already\n * following when a trampoline advances.\n *\n * A `created` decision at round 0, or with no round at all, is an ordinary\n * spawn and derives a `child` edge.\n *\n * Everything else derives nothing. This is a projection over entries the\n * control plane did not write, so an entry it does not recognize is not an\n * error.\n *\n * @param event the projected journal entry\n * @category projections\n * @since 0.1.0\n */\nexport const derive = (event: ControlEvent): ControlEvent | undefined => {\n if (event.runId === undefined) return undefined\n const payload = record(event.payload)\n if (payload === undefined) return undefined\n const edge = event.kind === forkCreatedEventType\n ? { runId: event.runId, parentRunId: text(payload[\"parentRunId\"]), forked: true }\n : event.kind !== runDecisionEventType\n ? undefined\n : payload[\"decision\"] === \"created\"\n // A continuation round's `created` names its predecessor too. The handoff\n // the previous round journals in the SAME transaction already discloses\n // that edge, so deriving here as well would contradict it.\n ? (ordinal(payload[\"roundOrdinal\"]) ?? 0) > 0\n ? undefined\n : { runId: event.runId, parentRunId: text(payload[\"parentExecutionId\"]), forked: false }\n : payload[\"decision\"] === \"handed-off\"\n ? {\n runId: text(payload[\"nextExecutionId\"]),\n parentRunId: event.runId,\n forked: false,\n lineageId: text(payload[\"lineageId\"]),\n roundOrdinal: ordinal(payload[\"roundOrdinal\"])\n }\n : undefined\n if (edge === undefined || edge.runId === undefined || edge.parentRunId === undefined) return undefined\n const lineageId = \"lineageId\" in edge ? edge.lineageId : undefined\n const roundOrdinal = \"roundOrdinal\" in edge ? edge.roundOrdinal : undefined\n const origin = originOf({\n parentRunId: edge.parentRunId,\n ...(roundOrdinal === undefined ? {} : { roundOrdinal }),\n forked: edge.forked\n })\n return {\n sequence: event.sequence,\n kind: lineageEventType,\n runId: event.runId,\n occurredAt: event.occurredAt,\n payload: {\n runId: edge.runId,\n parentRunId: edge.parentRunId,\n ...(lineageId === undefined ? {} : { lineageId }),\n ...(roundOrdinal === undefined ? {} : { roundOrdinal }),\n /* v8 ignore next -- `originOf` answers nothing only without a parent, and the guard above already refused an edge with no parent */\n ...(origin === undefined ? {} : { origin })\n }\n }\n}\n\n/**\n * Expands one projected entry into itself plus any ancestry delta it\n * discloses.\n *\n * @param event the projected journal entry\n * @category projections\n * @since 0.1.0\n */\nexport const expand = (event: ControlE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,IACA,OAAO,KAAK,QAAQ,iBAAiB,CAAC;AAAA,IACtC,aAAa,MAAM;AAAA,IACnB,QAAQ;AAAA,IACR,WAAW,KAAK,QAAQ,WAAW,CAAC;AAAA,IACpC,cAAc,QAAQ,QAAQ,cAAc,CAAC;AAAA,EAC/C,IACE;AACJ,MAAI,SAAS,UAAa,KAAK,UAAU,UAAa,KAAK,gBAAgB,OAAW,QAAO;AAC7F,QAAM,YAAY,eAAe,OAAO,KAAK,YAAY;AACzD,QAAM,eAAe,kBAAkB,OAAO,KAAK,eAAe;AAClE,QAAM,SAAS,SAAS;AAAA,IACtB,aAAa,KAAK;AAAA,IAClB,GAAI,iBAAiB,SAAY,CAAC,IAAI,EAAE,aAAa;AAAA,IACrD,QAAQ,KAAK;AAAA,EACf,CAAC;AACD,SAAO;AAAA,IACL,UAAU,MAAM;AAAA,IAChB,MAAM;AAAA,IACN,OAAO,MAAM;AAAA,IACb,YAAY,MAAM;AAAA,IAClB,SAAS;AAAA,MACP,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,GAAI,cAAc,SAAY,CAAC,IAAI,EAAE,UAAU;AAAA,MAC/C,GAAI,iBAAiB,SAAY,CAAC,IAAI,EAAE,aAAa;AAAA;AAAA,MAErD,GAAI,WAAW,SAAY,CAAC,IAAI,EAAE,OAAO;AAAA,IAC3C;AAAA,EACF;AACF;AAUO,MAAM,SAAS,CAAC,UAAqD;AAC1E,QAAM,UAAU,OAAO,KAAK;AAC5B,SAAO,YAAY,SAAY,CAAC,KAAK,IAAI,CAAC,OAAO,OAAO;AAC1D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Control-plane and credential schema migrations.
|
|
3
|
+
*
|
|
4
|
+
* This package reserves the migration block immediately after time travel.
|
|
5
|
+
* Hosts compose this set with the journal and run-store sets before opening a
|
|
6
|
+
* shared control database.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.1.0
|
|
9
|
+
*/
|
|
10
|
+
import * as DatabaseMigrations from "@smthrs/database/Migrations";
|
|
11
|
+
import * as Layer from "effect/Layer";
|
|
12
|
+
/**
|
|
13
|
+
* The control package's namespaced migration set.
|
|
14
|
+
*
|
|
15
|
+
* @category migrations
|
|
16
|
+
* @since 0.1.0
|
|
17
|
+
*/
|
|
18
|
+
export declare const set: DatabaseMigrations.MigrationSet;
|
|
19
|
+
/**
|
|
20
|
+
* Creates every durable control-plane and credential table.
|
|
21
|
+
*
|
|
22
|
+
* @category migrations
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
*/
|
|
25
|
+
export declare const run: import("effect/Effect").Effect<readonly (readonly [id: number, name: string])[], import("effect/unstable/sql/SqlError").SqlError | import("effect/unstable/sql/Migrator").MigrationError, import("effect/unstable/sql/SqlClient").SqlClient>;
|
|
26
|
+
/**
|
|
27
|
+
* Layer that runs control migrations before exposing the database to control
|
|
28
|
+
* services.
|
|
29
|
+
*
|
|
30
|
+
* @category layers
|
|
31
|
+
* @since 0.1.0
|
|
32
|
+
*/
|
|
33
|
+
export declare const layer: Layer.Layer<never, import("effect/unstable/sql/SqlError").SqlError | import("effect/unstable/sql/Migrator").MigrationError, import("effect/unstable/sql/SqlClient").SqlClient>;
|
|
34
|
+
//# sourceMappingURL=Migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migrations.d.ts","sourceRoot":"","sources":["../../src/Migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,kBAAkB,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AASrC;;;;;GAKG;AACH,eAAO,MAAM,GAAG,EAAE,kBAAkB,CAAC,YAYpC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,GAAG,8OAAgC,CAAA;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,gLAA2B,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Migrations_exports = {};
|
|
30
|
+
__export(Migrations_exports, {
|
|
31
|
+
layer: () => layer,
|
|
32
|
+
run: () => run,
|
|
33
|
+
set: () => set
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(Migrations_exports);
|
|
36
|
+
var DatabaseMigrations = __toESM(require("@smthrs/database/Migrations"), 1);
|
|
37
|
+
var Layer = __toESM(require("effect/Layer"), 1);
|
|
38
|
+
var import_control_tables = require("./migrations/0001_control_tables.js");
|
|
39
|
+
var import_run_keys = require("./migrations/0002_run_keys.js");
|
|
40
|
+
var import_signal_commands = require("./migrations/0003_signal_commands.js");
|
|
41
|
+
var import_approval_decisions = require("./migrations/0004_approval_decisions.js");
|
|
42
|
+
var import_signal_principals = require("./migrations/0005_signal_principals.js");
|
|
43
|
+
var import_run_principals = require("./migrations/0006_run_principals.js");
|
|
44
|
+
var import_resume_consent = require("./migrations/0007_resume_consent.js");
|
|
45
|
+
const set = {
|
|
46
|
+
namespace: "control",
|
|
47
|
+
idOffset: DatabaseMigrations.idBlock * 6,
|
|
48
|
+
migrations: {
|
|
49
|
+
"0001_control_tables": import_control_tables.initial,
|
|
50
|
+
"0002_run_keys": import_run_keys.runKeys,
|
|
51
|
+
"0003_signal_commands": import_signal_commands.signalCommands,
|
|
52
|
+
"0004_approval_decisions": import_approval_decisions.approvalDecisions,
|
|
53
|
+
"0005_signal_principals": import_signal_principals.signalPrincipals,
|
|
54
|
+
"0006_run_principals": import_run_principals.runPrincipals,
|
|
55
|
+
"0007_resume_consent": import_resume_consent.resumeConsent
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const run = DatabaseMigrations.run([set]);
|
|
59
|
+
const layer = Layer.effectDiscard(run);
|
|
60
|
+
//# sourceMappingURL=Migrations.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Migrations.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Control-plane and credential schema migrations.\n *\n * This package reserves the migration block immediately after time travel.\n * Hosts compose this set with the journal and run-store sets before opening a\n * shared control database.\n *\n * @since 0.1.0\n */\n\nimport * as DatabaseMigrations from \"@smthrs/database/Migrations\"\nimport * as Layer from \"effect/Layer\"\nimport { initial } from \"./migrations/0001_control_tables.ts\"\nimport { runKeys } from \"./migrations/0002_run_keys.ts\"\nimport { signalCommands } from \"./migrations/0003_signal_commands.ts\"\nimport { approvalDecisions } from \"./migrations/0004_approval_decisions.ts\"\nimport { signalPrincipals } from \"./migrations/0005_signal_principals.ts\"\nimport { runPrincipals } from \"./migrations/0006_run_principals.ts\"\nimport { resumeConsent } from \"./migrations/0007_resume_consent.ts\"\n\n/**\n * The control package's namespaced migration set.\n *\n * @category migrations\n * @since 0.1.0\n */\nexport const set: DatabaseMigrations.MigrationSet = {\n namespace: \"control\",\n idOffset: DatabaseMigrations.idBlock * 6,\n migrations: {\n \"0001_control_tables\": initial,\n \"0002_run_keys\": runKeys,\n \"0003_signal_commands\": signalCommands,\n \"0004_approval_decisions\": approvalDecisions,\n \"0005_signal_principals\": signalPrincipals,\n \"0006_run_principals\": runPrincipals,\n \"0007_resume_consent\": resumeConsent\n }\n}\n\n/**\n * Creates every durable control-plane and credential table.\n *\n * @category migrations\n * @since 0.1.0\n */\nexport const run = DatabaseMigrations.run([set])\n\n/**\n * Layer that runs control migrations before exposing the database to control\n * services.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer = Layer.effectDiscard(run)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,yBAAoC;AACpC,YAAuB;AACvB,4BAAwB;AACxB,sBAAwB;AACxB,6BAA+B;AAC/B,gCAAkC;AAClC,+BAAiC;AACjC,4BAA8B;AAC9B,4BAA8B;AAQvB,MAAM,MAAuC;AAAA,EAClD,WAAW;AAAA,EACX,UAAU,mBAAmB,UAAU;AAAA,EACvC,YAAY;AAAA,IACV,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,IACjB,wBAAwB;AAAA,IACxB,2BAA2B;AAAA,IAC3B,0BAA0B;AAAA,IAC1B,uBAAuB;AAAA,IACvB,uBAAuB;AAAA,EACzB;AACF;AAQO,MAAM,MAAM,mBAAmB,IAAI,CAAC,GAAG,CAAC;AASxC,MAAM,QAAQ,MAAM,cAAc,GAAG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run health over the control plane: what a run's state means, and what to do
|
|
3
|
+
* about it.
|
|
4
|
+
*
|
|
5
|
+
* A control plane answers "what is this run doing". A monitor answers the
|
|
6
|
+
* question after it — "is that all right, and if not, what now" — and the two
|
|
7
|
+
* are deliberately separate modules. {@link classify} is a pure function of
|
|
8
|
+
* one observation, so the vocabulary an operator reads on a dashboard is the
|
|
9
|
+
* same one a heal loop branches on and the same one a test can enumerate.
|
|
10
|
+
* {@link run} is the loop that beats over `Control` and journals what it saw.
|
|
11
|
+
*
|
|
12
|
+
* The classification is decided from durable evidence only: the run summary
|
|
13
|
+
* the control plane projects, and the journal entries `watch` replays. Nothing
|
|
14
|
+
* here reads an in-process fiber, which is what makes a monitor able to watch
|
|
15
|
+
* a run in another process at all.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
*/
|
|
19
|
+
import { Journal } from "@smthrs/journal";
|
|
20
|
+
import { Effect } from "effect";
|
|
21
|
+
import { Control } from "./Control.ts";
|
|
22
|
+
import type { ControlError } from "./ControlError.ts";
|
|
23
|
+
import type { ControlEvent, Receipt, RunId, RunSummary } from "./ControlSchema.ts";
|
|
24
|
+
import * as SubjectHealth from "./Health.ts";
|
|
25
|
+
/**
|
|
26
|
+
* The journal event type the engine records when an action attempt starts.
|
|
27
|
+
*
|
|
28
|
+
* Named as a string rather than imported, exactly as in `Lineage`: a monitor
|
|
29
|
+
* reads journals, not engines.
|
|
30
|
+
*
|
|
31
|
+
* @category constants
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
*/
|
|
34
|
+
export declare const attemptStartedEventType = "flows.engine.attempt-started";
|
|
35
|
+
/**
|
|
36
|
+
* The journal event type the engine records when an action attempt settles.
|
|
37
|
+
*
|
|
38
|
+
* @category constants
|
|
39
|
+
* @since 0.1.0
|
|
40
|
+
*/
|
|
41
|
+
export declare const attemptFinishedEventType = "flows.engine.attempt-finished";
|
|
42
|
+
/**
|
|
43
|
+
* The journal event type one monitor beat is recorded under.
|
|
44
|
+
*
|
|
45
|
+
* @category constants
|
|
46
|
+
* @since 0.1.0
|
|
47
|
+
*/
|
|
48
|
+
export declare const beatEventType = "control.monitor.beat";
|
|
49
|
+
/**
|
|
50
|
+
* The journal event type one applied remedy is recorded under.
|
|
51
|
+
*
|
|
52
|
+
* A beat and a heal are two records because they are two facts, and only one
|
|
53
|
+
* of them is true before the remedy runs. A single record carrying `healed`
|
|
54
|
+
* has to be written either before the remedy — leaving durable evidence of a
|
|
55
|
+
* heal that a crash one instruction later never performed — or after it, which
|
|
56
|
+
* loses the evidence of what a monitor decided when the remedy is what killed
|
|
57
|
+
* it. Splitting them keeps both.
|
|
58
|
+
*
|
|
59
|
+
* @category constants
|
|
60
|
+
* @since 0.1.0
|
|
61
|
+
*/
|
|
62
|
+
export declare const healedEventType = "control.monitor.healed";
|
|
63
|
+
/**
|
|
64
|
+
* What a run looks like to a monitor.
|
|
65
|
+
*
|
|
66
|
+
* `healthy` covers both "moving" and "finished": a completed run needs nothing
|
|
67
|
+
* done to it, and neither does one that is making progress. The other six name
|
|
68
|
+
* a specific thing that is wrong, because a heal that cannot tell them apart
|
|
69
|
+
* would resume a run that is waiting for a human.
|
|
70
|
+
*
|
|
71
|
+
* @category models
|
|
72
|
+
* @since 0.1.0
|
|
73
|
+
*/
|
|
74
|
+
export declare const Health: import("effect/Schema").Literals<readonly ["healthy", "stalled", "wedged-node", "runaway-loop", "awaiting-human", "failing", "unknown"]>;
|
|
75
|
+
/**
|
|
76
|
+
* What a run looks like to a monitor.
|
|
77
|
+
*
|
|
78
|
+
* @category models
|
|
79
|
+
* @since 0.1.0
|
|
80
|
+
*/
|
|
81
|
+
export type Health = typeof Health.Type;
|
|
82
|
+
/**
|
|
83
|
+
* Everything one classification is decided from.
|
|
84
|
+
*
|
|
85
|
+
* `events` is the run's journal as `watch` projects it, oldest first.
|
|
86
|
+
* `beatsWithoutProgress` counts consecutive beats that added no entry, and
|
|
87
|
+
* `stallBeats` is how many of those make a stall. Splitting the count from the
|
|
88
|
+
* threshold is what lets the same pure function serve a monitor that beats
|
|
89
|
+
* every second and one that beats every hour.
|
|
90
|
+
*
|
|
91
|
+
* @category models
|
|
92
|
+
* @since 0.1.0
|
|
93
|
+
*/
|
|
94
|
+
export interface Observation {
|
|
95
|
+
/** The run's projection, or nothing when the control plane has no such run. */
|
|
96
|
+
readonly summary?: RunSummary | undefined;
|
|
97
|
+
readonly events: ReadonlyArray<ControlEvent>;
|
|
98
|
+
readonly beatsWithoutProgress: number;
|
|
99
|
+
readonly stallBeats: number;
|
|
100
|
+
/**
|
|
101
|
+
* The trampoline round at which a lineage stops being a loop and starts
|
|
102
|
+
* being a runaway. A run past it is looping without converging.
|
|
103
|
+
*/
|
|
104
|
+
readonly roundBound?: number | undefined;
|
|
105
|
+
/** Fresh, explicitly reported semantic work; never inferred from bytes or monitor events. */
|
|
106
|
+
readonly semanticProgress?: boolean | undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Decides what a run's state means.
|
|
110
|
+
*
|
|
111
|
+
* The order is the order an operator would read it in, and each rule earns its
|
|
112
|
+
* place by naming a different response:
|
|
113
|
+
*
|
|
114
|
+
* | Condition | Health | Because |
|
|
115
|
+
* | --- | --- | --- |
|
|
116
|
+
* | No summary | `unknown` | Nothing to say, and nothing to do. |
|
|
117
|
+
* | `failed` | `failing` | The run itself reported the failure. |
|
|
118
|
+
* | `completed`, `cancelled` | `healthy` | A finished run needs nothing. |
|
|
119
|
+
* | `waiting-approval`, or parked on `approval` | `awaiting-human` | A human owes it an answer; no machine can supply one. |
|
|
120
|
+
* | Parked with no waiting reason | `awaiting-human` | Only an operator's own park writes no waiting reason, so a person stopped it and a person restarts it. |
|
|
121
|
+
* | `roundOrdinal` at or past the bound | `runaway-loop` | The lineage is looping without converging. |
|
|
122
|
+
* | The last settled attempt failed | `failing` | The run is still alive but its work is not landing. |
|
|
123
|
+
* | No progress for `stallBeats`, an attempt open | `wedged-node` | One attempt started and never settled: the work is stuck, not the run. |
|
|
124
|
+
* | No progress for `stallBeats` | `stalled` | Nothing is happening and nothing is in flight. |
|
|
125
|
+
* | Anything else | `healthy` | Entries are still arriving. |
|
|
126
|
+
*
|
|
127
|
+
* `awaiting-human` deliberately outranks `failing`: a run parked for approval
|
|
128
|
+
* after a failed attempt is waiting for a person, and resuming or cancelling
|
|
129
|
+
* it would take the decision away from them.
|
|
130
|
+
*
|
|
131
|
+
* A park with no reason is the same case. The engine names every park it makes
|
|
132
|
+
* — `event`, `approval`, `timer`, `quota`, `released` — so a parked run whose
|
|
133
|
+
* `waitingReason` is absent was parked by an operator through
|
|
134
|
+
* `ControlRuntime.writeStatus`. Calling that a stall and resuming it would undo
|
|
135
|
+
* a deliberate act, which is the worst thing an unattended heal loop can do.
|
|
136
|
+
*
|
|
137
|
+
* @param observation what the beat saw
|
|
138
|
+
* @category projections
|
|
139
|
+
* @since 0.1.0
|
|
140
|
+
*/
|
|
141
|
+
export declare const classify: (observation: Observation) => Health;
|
|
142
|
+
/**
|
|
143
|
+
* What a monitor does about one unhealthy run.
|
|
144
|
+
*
|
|
145
|
+
* @category models
|
|
146
|
+
* @since 0.1.0
|
|
147
|
+
*/
|
|
148
|
+
export type Remedy = "resume" | "cancel" | "none";
|
|
149
|
+
/**
|
|
150
|
+
* The remedy a health warrants, before `autoHeal` decides whether to apply it.
|
|
151
|
+
*
|
|
152
|
+
* A stalled or wedged run is one nobody is driving, and a resume claims it. A
|
|
153
|
+
* failing or runaway run is one that will not get better by being driven
|
|
154
|
+
* harder. Everything else is left alone.
|
|
155
|
+
*
|
|
156
|
+
* @param health what the beat classified
|
|
157
|
+
* @category projections
|
|
158
|
+
* @since 0.1.0
|
|
159
|
+
*/
|
|
160
|
+
export declare const remedyFor: (health: Health) => Remedy;
|
|
161
|
+
/**
|
|
162
|
+
* One beat of a monitor.
|
|
163
|
+
*
|
|
164
|
+
* @category models
|
|
165
|
+
* @since 0.1.0
|
|
166
|
+
*/
|
|
167
|
+
export interface Beat {
|
|
168
|
+
/** Which beat this was, counting from zero. */
|
|
169
|
+
readonly beat: number;
|
|
170
|
+
readonly health: Health;
|
|
171
|
+
/** The newest journal sequence the run had, ignoring the monitor's own records. */
|
|
172
|
+
readonly sequence: number;
|
|
173
|
+
/**
|
|
174
|
+
* The remedy that ran and returned, absent when none did.
|
|
175
|
+
*
|
|
176
|
+
* Present only after the heal succeeded, which is also when
|
|
177
|
+
* `control.monitor.healed` is journaled. A beat that decided on a remedy the
|
|
178
|
+
* monitor never got to apply reports nothing here.
|
|
179
|
+
*/
|
|
180
|
+
readonly healed?: Remedy | undefined;
|
|
181
|
+
/** The receipt the remedy returned, absent when none was applied. */
|
|
182
|
+
readonly receipt?: Receipt | undefined;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* What a monitor found.
|
|
186
|
+
*
|
|
187
|
+
* @category models
|
|
188
|
+
* @since 0.1.0
|
|
189
|
+
*/
|
|
190
|
+
export interface Report {
|
|
191
|
+
readonly runId: RunId;
|
|
192
|
+
readonly beats: ReadonlyArray<Beat>;
|
|
193
|
+
/** The last beat's health, or `unknown` when no beat ran. */
|
|
194
|
+
readonly health: Health;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* How a monitor beats.
|
|
198
|
+
*
|
|
199
|
+
* @category models
|
|
200
|
+
* @since 0.1.0
|
|
201
|
+
*/
|
|
202
|
+
export interface Options {
|
|
203
|
+
readonly runId: RunId;
|
|
204
|
+
/** Optional configured observational checker; checker results never authorize a remedy. */
|
|
205
|
+
readonly healthCheck?: SubjectHealth.ResolvedCheck | undefined;
|
|
206
|
+
/** Shared host admission limit around probes. */
|
|
207
|
+
readonly withProbePermit?: (<A>(effect: Effect.Effect<A>) => Effect.Effect<A>) | undefined;
|
|
208
|
+
/** Bounded retained beat history for long-lived host monitoring. */
|
|
209
|
+
readonly retainBeats?: number | undefined;
|
|
210
|
+
/** Hosts with structured status observations omit redundant legacy heartbeat records. */
|
|
211
|
+
readonly recordBeats?: boolean | undefined;
|
|
212
|
+
/**
|
|
213
|
+
* Who is watching. Defaults to `default`.
|
|
214
|
+
*
|
|
215
|
+
* It reaches the journal twice: as the source of every record this monitor
|
|
216
|
+
* writes, and as `monitorId` in each payload. Two monitors pointed at one
|
|
217
|
+
* run both beat and both remedy — nothing on the control plane leases a run
|
|
218
|
+
* to one watcher — so the identity is what makes their evidence tellable
|
|
219
|
+
* apart, and what keeps their remedies on separate idempotency keys.
|
|
220
|
+
*/
|
|
221
|
+
readonly monitorId?: string | undefined;
|
|
222
|
+
/** How long to wait between beats. Defaults to one second. */
|
|
223
|
+
readonly intervalMs?: number | undefined;
|
|
224
|
+
/** How many beats to take before reporting. Defaults to ten. */
|
|
225
|
+
readonly maxChecks?: number | undefined;
|
|
226
|
+
/** How many beats without progress make a stall. Defaults to three. */
|
|
227
|
+
readonly stallBeats?: number | undefined;
|
|
228
|
+
/** The round at which a trampoline is a runaway. Defaults to 32. */
|
|
229
|
+
readonly roundBound?: number | undefined;
|
|
230
|
+
/** Which healths the monitor is allowed to act on. Defaults to none. */
|
|
231
|
+
readonly autoHeal?: ReadonlyArray<Health> | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* What to do about an unhealthy run. Defaults to `Control.resume` and
|
|
234
|
+
* `Control.cancel` per {@link remedyFor}.
|
|
235
|
+
*
|
|
236
|
+
* A heal that fails does not abort the monitor: the failure is logged, the
|
|
237
|
+
* beat is recorded without `healed` or `receipt`, and the loop moves to the
|
|
238
|
+
* next beat, where the stall evidence still stands and the remedy is
|
|
239
|
+
* retried under that beat's own idempotency key.
|
|
240
|
+
*/
|
|
241
|
+
readonly heal?: (input: {
|
|
242
|
+
readonly runId: RunId;
|
|
243
|
+
readonly health: Health;
|
|
244
|
+
readonly remedy: Remedy;
|
|
245
|
+
readonly beat: number;
|
|
246
|
+
}) => Effect.Effect<Receipt, ControlError>;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Watches one run and, when told to, heals it.
|
|
250
|
+
*
|
|
251
|
+
* The loop stops early on a terminal run, because a finished run has nothing
|
|
252
|
+
* left to observe and beating at it would fill its journal with heartbeats.
|
|
253
|
+
* Otherwise it takes `maxChecks` beats and reports what it saw.
|
|
254
|
+
*
|
|
255
|
+
* Every beat is journaled as `control.monitor.beat` before any remedy is
|
|
256
|
+
* applied, carrying the `remedy` it is about to attempt, so a monitor that
|
|
257
|
+
* crashes mid-heal leaves the evidence of what it decided. The remedy itself
|
|
258
|
+
* is journaled separately as `control.monitor.healed`, and only once the heal
|
|
259
|
+
* returned a receipt: a heal that failed, or a process that died running one,
|
|
260
|
+
* must not leave a durable record saying the run was healed.
|
|
261
|
+
*
|
|
262
|
+
* `autoHeal` is empty by default. A monitor that healed by default would be a
|
|
263
|
+
* monitor that cancels a run the first time it looks at one, which is the
|
|
264
|
+
* wrong default for a thing an operator points at production.
|
|
265
|
+
*
|
|
266
|
+
* Nothing here leases the run. Two monitors on one run both beat and both
|
|
267
|
+
* remedy, so a remedy has to be idempotent on the control plane — which the
|
|
268
|
+
* two defaults are, through `Control.resume` and `Control.cancel`
|
|
269
|
+
* idempotency keys that name the monitor, the run, and the beat. A custom
|
|
270
|
+
* `heal` owes the same property.
|
|
271
|
+
*
|
|
272
|
+
* @param options how to beat and what to heal
|
|
273
|
+
* @category constructors
|
|
274
|
+
* @since 0.1.0
|
|
275
|
+
*/
|
|
276
|
+
export declare const run: (options: Options) => Effect.Effect<Report, ControlError, Control | Journal.Journal>;
|
|
277
|
+
/** Observer and notification bookkeeping is never execution progress.
|
|
278
|
+
* @category predicates
|
|
279
|
+
* @since 1.0.0
|
|
280
|
+
*/
|
|
281
|
+
export declare const isBookkeepingEvent: (kind: string) => boolean;
|
|
282
|
+
//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