@eloxiv/testing 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/Admin.d.ts +20 -0
- package/dist/Admin.d.ts.map +1 -0
- package/dist/Admin.js +61 -0
- package/dist/Admin.js.map +1 -0
- package/dist/Agent.d.ts +97 -0
- package/dist/Agent.d.ts.map +1 -0
- package/dist/Agent.js +210 -0
- package/dist/Agent.js.map +1 -0
- package/dist/AgentSurface.d.ts +20 -0
- package/dist/AgentSurface.d.ts.map +1 -0
- package/dist/AgentSurface.js +36 -0
- package/dist/AgentSurface.js.map +1 -0
- package/dist/Embedder.d.ts +21 -0
- package/dist/Embedder.d.ts.map +1 -0
- package/dist/Embedder.js +54 -0
- package/dist/Embedder.js.map +1 -0
- package/dist/EvalMain.d.ts +2 -0
- package/dist/EvalMain.d.ts.map +1 -0
- package/dist/EvalMain.js +80 -0
- package/dist/EvalMain.js.map +1 -0
- package/dist/Evals.d.ts +95 -0
- package/dist/Evals.d.ts.map +1 -0
- package/dist/Evals.js +389 -0
- package/dist/Evals.js.map +1 -0
- package/dist/Kernel.d.ts +88 -0
- package/dist/Kernel.d.ts.map +1 -0
- package/dist/Kernel.js +108 -0
- package/dist/Kernel.js.map +1 -0
- package/dist/Launch.d.ts +86 -0
- package/dist/Launch.d.ts.map +1 -0
- package/dist/Launch.js +370 -0
- package/dist/Launch.js.map +1 -0
- package/dist/Locks.d.ts +39 -0
- package/dist/Locks.d.ts.map +1 -0
- package/dist/Locks.js +94 -0
- package/dist/Locks.js.map +1 -0
- package/dist/Routes.d.ts +19 -0
- package/dist/Routes.d.ts.map +1 -0
- package/dist/Routes.js +38 -0
- package/dist/Routes.js.map +1 -0
- package/dist/ScriptedChatModel.d.ts +51 -0
- package/dist/ScriptedChatModel.d.ts.map +1 -0
- package/dist/ScriptedChatModel.js +135 -0
- package/dist/ScriptedChatModel.js.map +1 -0
- package/dist/SmtpSink.d.ts +36 -0
- package/dist/SmtpSink.d.ts.map +1 -0
- package/dist/SmtpSink.js +185 -0
- package/dist/SmtpSink.js.map +1 -0
- package/dist/System.d.ts +271 -0
- package/dist/System.d.ts.map +1 -0
- package/dist/System.js +908 -0
- package/dist/System.js.map +1 -0
- package/dist/TcpProxy.d.ts +17 -0
- package/dist/TcpProxy.d.ts.map +1 -0
- package/dist/TcpProxy.js +100 -0
- package/dist/TcpProxy.js.map +1 -0
- package/dist/auth/TrustedProxyAuth.d.ts +28 -0
- package/dist/auth/TrustedProxyAuth.d.ts.map +1 -0
- package/dist/auth/TrustedProxyAuth.js +128 -0
- package/dist/auth/TrustedProxyAuth.js.map +1 -0
- package/dist/conformance/ActionConsent.d.ts +3 -0
- package/dist/conformance/ActionConsent.d.ts.map +1 -0
- package/dist/conformance/ActionConsent.js +347 -0
- package/dist/conformance/ActionConsent.js.map +1 -0
- package/dist/conformance/ActionRegistry.d.ts +64 -0
- package/dist/conformance/ActionRegistry.d.ts.map +1 -0
- package/dist/conformance/ActionRegistry.js +136 -0
- package/dist/conformance/ActionRegistry.js.map +1 -0
- package/dist/conformance/Actor.d.ts +43 -0
- package/dist/conformance/Actor.d.ts.map +1 -0
- package/dist/conformance/Actor.js +171 -0
- package/dist/conformance/Actor.js.map +1 -0
- package/dist/conformance/AgentReference.d.ts +30 -0
- package/dist/conformance/AgentReference.d.ts.map +1 -0
- package/dist/conformance/AgentReference.js +137 -0
- package/dist/conformance/AgentReference.js.map +1 -0
- package/dist/conformance/AgentResources.d.ts +3 -0
- package/dist/conformance/AgentResources.d.ts.map +1 -0
- package/dist/conformance/AgentResources.js +454 -0
- package/dist/conformance/AgentResources.js.map +1 -0
- package/dist/conformance/AgentRuntime.d.ts +3 -0
- package/dist/conformance/AgentRuntime.d.ts.map +1 -0
- package/dist/conformance/AgentRuntime.js +302 -0
- package/dist/conformance/AgentRuntime.js.map +1 -0
- package/dist/conformance/AgentSubject.d.ts +87 -0
- package/dist/conformance/AgentSubject.d.ts.map +1 -0
- package/dist/conformance/AgentSubject.js +18 -0
- package/dist/conformance/AgentSubject.js.map +1 -0
- package/dist/conformance/Approvals.d.ts +3 -0
- package/dist/conformance/Approvals.d.ts.map +1 -0
- package/dist/conformance/Approvals.js +258 -0
- package/dist/conformance/Approvals.js.map +1 -0
- package/dist/conformance/Audit.d.ts +3 -0
- package/dist/conformance/Audit.d.ts.map +1 -0
- package/dist/conformance/Audit.js +221 -0
- package/dist/conformance/Audit.js.map +1 -0
- package/dist/conformance/CalendarProvider.d.ts +4 -0
- package/dist/conformance/CalendarProvider.d.ts.map +1 -0
- package/dist/conformance/CalendarProvider.js +108 -0
- package/dist/conformance/CalendarProvider.js.map +1 -0
- package/dist/conformance/CapabilityKit.d.ts +191 -0
- package/dist/conformance/CapabilityKit.d.ts.map +1 -0
- package/dist/conformance/CapabilityKit.js +375 -0
- package/dist/conformance/CapabilityKit.js.map +1 -0
- package/dist/conformance/ClientSDK.d.ts +78 -0
- package/dist/conformance/ClientSDK.d.ts.map +1 -0
- package/dist/conformance/ClientSDK.js +163 -0
- package/dist/conformance/ClientSDK.js.map +1 -0
- package/dist/conformance/CollabDocument.d.ts +3 -0
- package/dist/conformance/CollabDocument.d.ts.map +1 -0
- package/dist/conformance/CollabDocument.js +934 -0
- package/dist/conformance/CollabDocument.js.map +1 -0
- package/dist/conformance/CollabReference.d.ts +8 -0
- package/dist/conformance/CollabReference.d.ts.map +1 -0
- package/dist/conformance/CollabReference.js +138 -0
- package/dist/conformance/CollabReference.js.map +1 -0
- package/dist/conformance/CollabSubject.d.ts +68 -0
- package/dist/conformance/CollabSubject.d.ts.map +1 -0
- package/dist/conformance/CollabSubject.js +2 -0
- package/dist/conformance/CollabSubject.js.map +1 -0
- package/dist/conformance/Command.d.ts +3 -0
- package/dist/conformance/Command.d.ts.map +1 -0
- package/dist/conformance/Command.js +73 -0
- package/dist/conformance/Command.js.map +1 -0
- package/dist/conformance/Connections.d.ts +4 -0
- package/dist/conformance/Connections.d.ts.map +1 -0
- package/dist/conformance/Connections.js +308 -0
- package/dist/conformance/Connections.js.map +1 -0
- package/dist/conformance/ConnectionsReference.d.ts +56 -0
- package/dist/conformance/ConnectionsReference.d.ts.map +1 -0
- package/dist/conformance/ConnectionsReference.js +74 -0
- package/dist/conformance/ConnectionsReference.js.map +1 -0
- package/dist/conformance/ConnectorReference.d.ts +86 -0
- package/dist/conformance/ConnectorReference.d.ts.map +1 -0
- package/dist/conformance/ConnectorReference.js +185 -0
- package/dist/conformance/ConnectorReference.js.map +1 -0
- package/dist/conformance/ContextAccounting.d.ts +8 -0
- package/dist/conformance/ContextAccounting.d.ts.map +1 -0
- package/dist/conformance/ContextAccounting.js +125 -0
- package/dist/conformance/ContextAccounting.js.map +1 -0
- package/dist/conformance/Daemon.d.ts +150 -0
- package/dist/conformance/Daemon.d.ts.map +1 -0
- package/dist/conformance/Daemon.js +718 -0
- package/dist/conformance/Daemon.js.map +1 -0
- package/dist/conformance/DaemonReference.d.ts +15 -0
- package/dist/conformance/DaemonReference.d.ts.map +1 -0
- package/dist/conformance/DaemonReference.js +163 -0
- package/dist/conformance/DaemonReference.js.map +1 -0
- package/dist/conformance/DbTx.d.ts +17 -0
- package/dist/conformance/DbTx.d.ts.map +1 -0
- package/dist/conformance/DbTx.js +184 -0
- package/dist/conformance/DbTx.js.map +1 -0
- package/dist/conformance/DecisionTokens.d.ts +3 -0
- package/dist/conformance/DecisionTokens.d.ts.map +1 -0
- package/dist/conformance/DecisionTokens.js +551 -0
- package/dist/conformance/DecisionTokens.js.map +1 -0
- package/dist/conformance/Delegation.d.ts +3 -0
- package/dist/conformance/Delegation.d.ts.map +1 -0
- package/dist/conformance/Delegation.js +149 -0
- package/dist/conformance/Delegation.js.map +1 -0
- package/dist/conformance/DeskReference.d.ts +21 -0
- package/dist/conformance/DeskReference.d.ts.map +1 -0
- package/dist/conformance/DeskReference.js +47 -0
- package/dist/conformance/DeskReference.js.map +1 -0
- package/dist/conformance/DeviceControl.d.ts +3 -0
- package/dist/conformance/DeviceControl.d.ts.map +1 -0
- package/dist/conformance/DeviceControl.js +579 -0
- package/dist/conformance/DeviceControl.js.map +1 -0
- package/dist/conformance/Directory.d.ts +36 -0
- package/dist/conformance/Directory.d.ts.map +1 -0
- package/dist/conformance/Directory.js +253 -0
- package/dist/conformance/Directory.js.map +1 -0
- package/dist/conformance/DirectoryProvider.d.ts +4 -0
- package/dist/conformance/DirectoryProvider.d.ts.map +1 -0
- package/dist/conformance/DirectoryProvider.js +58 -0
- package/dist/conformance/DirectoryProvider.js.map +1 -0
- package/dist/conformance/DocumentSource.d.ts +4 -0
- package/dist/conformance/DocumentSource.d.ts.map +1 -0
- package/dist/conformance/DocumentSource.js +43 -0
- package/dist/conformance/DocumentSource.js.map +1 -0
- package/dist/conformance/EndpointReference.d.ts +40 -0
- package/dist/conformance/EndpointReference.d.ts.map +1 -0
- package/dist/conformance/EndpointReference.js +67 -0
- package/dist/conformance/EndpointReference.js.map +1 -0
- package/dist/conformance/Files.d.ts +40 -0
- package/dist/conformance/Files.d.ts.map +1 -0
- package/dist/conformance/Files.js +592 -0
- package/dist/conformance/Files.js.map +1 -0
- package/dist/conformance/FilesReference.d.ts +31 -0
- package/dist/conformance/FilesReference.d.ts.map +1 -0
- package/dist/conformance/FilesReference.js +116 -0
- package/dist/conformance/FilesReference.js.map +1 -0
- package/dist/conformance/FilesSubject.d.ts +46 -0
- package/dist/conformance/FilesSubject.d.ts.map +1 -0
- package/dist/conformance/FilesSubject.js +3 -0
- package/dist/conformance/FilesSubject.js.map +1 -0
- package/dist/conformance/Flags.d.ts +3 -0
- package/dist/conformance/Flags.d.ts.map +1 -0
- package/dist/conformance/Flags.js +183 -0
- package/dist/conformance/Flags.js.map +1 -0
- package/dist/conformance/Host.d.ts +64 -0
- package/dist/conformance/Host.d.ts.map +1 -0
- package/dist/conformance/Host.js +152 -0
- package/dist/conformance/Host.js.map +1 -0
- package/dist/conformance/HttpApi.d.ts +5 -0
- package/dist/conformance/HttpApi.d.ts.map +1 -0
- package/dist/conformance/HttpApi.js +131 -0
- package/dist/conformance/HttpApi.js.map +1 -0
- package/dist/conformance/InboxReference.d.ts +28 -0
- package/dist/conformance/InboxReference.d.ts.map +1 -0
- package/dist/conformance/InboxReference.js +331 -0
- package/dist/conformance/InboxReference.js.map +1 -0
- package/dist/conformance/InboxSubject.d.ts +92 -0
- package/dist/conformance/InboxSubject.d.ts.map +1 -0
- package/dist/conformance/InboxSubject.js +16 -0
- package/dist/conformance/InboxSubject.js.map +1 -0
- package/dist/conformance/Ingestion.d.ts +10 -0
- package/dist/conformance/Ingestion.d.ts.map +1 -0
- package/dist/conformance/Ingestion.js +335 -0
- package/dist/conformance/Ingestion.js.map +1 -0
- package/dist/conformance/Ingress.d.ts +62 -0
- package/dist/conformance/Ingress.d.ts.map +1 -0
- package/dist/conformance/Ingress.js +346 -0
- package/dist/conformance/Ingress.js.map +1 -0
- package/dist/conformance/Invocation.d.ts +3 -0
- package/dist/conformance/Invocation.d.ts.map +1 -0
- package/dist/conformance/Invocation.js +665 -0
- package/dist/conformance/Invocation.js.map +1 -0
- package/dist/conformance/IsolationMatrix.d.ts +60 -0
- package/dist/conformance/IsolationMatrix.d.ts.map +1 -0
- package/dist/conformance/IsolationMatrix.js +196 -0
- package/dist/conformance/IsolationMatrix.js.map +1 -0
- package/dist/conformance/LiveConnection.d.ts +72 -0
- package/dist/conformance/LiveConnection.d.ts.map +1 -0
- package/dist/conformance/LiveConnection.js +125 -0
- package/dist/conformance/LiveConnection.js.map +1 -0
- package/dist/conformance/LocalClient.d.ts +70 -0
- package/dist/conformance/LocalClient.d.ts.map +1 -0
- package/dist/conformance/LocalClient.js +576 -0
- package/dist/conformance/LocalClient.js.map +1 -0
- package/dist/conformance/Locale.d.ts +28 -0
- package/dist/conformance/Locale.d.ts.map +1 -0
- package/dist/conformance/Locale.js +115 -0
- package/dist/conformance/Locale.js.map +1 -0
- package/dist/conformance/MachineIdentity.d.ts +39 -0
- package/dist/conformance/MachineIdentity.d.ts.map +1 -0
- package/dist/conformance/MachineIdentity.js +595 -0
- package/dist/conformance/MachineIdentity.js.map +1 -0
- package/dist/conformance/MailProvider.d.ts +4 -0
- package/dist/conformance/MailProvider.d.ts.map +1 -0
- package/dist/conformance/MailProvider.js +167 -0
- package/dist/conformance/MailProvider.js.map +1 -0
- package/dist/conformance/Memory.d.ts +10 -0
- package/dist/conformance/Memory.d.ts.map +1 -0
- package/dist/conformance/Memory.js +179 -0
- package/dist/conformance/Memory.js.map +1 -0
- package/dist/conformance/Messaging.d.ts +49 -0
- package/dist/conformance/Messaging.d.ts.map +1 -0
- package/dist/conformance/Messaging.js +117 -0
- package/dist/conformance/Messaging.js.map +1 -0
- package/dist/conformance/Metering.d.ts +26 -0
- package/dist/conformance/Metering.d.ts.map +1 -0
- package/dist/conformance/Metering.js +236 -0
- package/dist/conformance/Metering.js.map +1 -0
- package/dist/conformance/ModelProvider.d.ts +32 -0
- package/dist/conformance/ModelProvider.d.ts.map +1 -0
- package/dist/conformance/ModelProvider.js +100 -0
- package/dist/conformance/ModelProvider.js.map +1 -0
- package/dist/conformance/ModuleManifest.d.ts +9 -0
- package/dist/conformance/ModuleManifest.d.ts.map +1 -0
- package/dist/conformance/ModuleManifest.js +542 -0
- package/dist/conformance/ModuleManifest.js.map +1 -0
- package/dist/conformance/NotebookAgent.d.ts +32 -0
- package/dist/conformance/NotebookAgent.d.ts.map +1 -0
- package/dist/conformance/NotebookAgent.js +31 -0
- package/dist/conformance/NotebookAgent.js.map +1 -0
- package/dist/conformance/NotificationChannel.d.ts +40 -0
- package/dist/conformance/NotificationChannel.d.ts.map +1 -0
- package/dist/conformance/NotificationChannel.js +78 -0
- package/dist/conformance/NotificationChannel.js.map +1 -0
- package/dist/conformance/Notifications.d.ts +3 -0
- package/dist/conformance/Notifications.d.ts.map +1 -0
- package/dist/conformance/Notifications.js +240 -0
- package/dist/conformance/Notifications.js.map +1 -0
- package/dist/conformance/OAuthClient.d.ts +123 -0
- package/dist/conformance/OAuthClient.d.ts.map +1 -0
- package/dist/conformance/OAuthClient.js +204 -0
- package/dist/conformance/OAuthClient.js.map +1 -0
- package/dist/conformance/Outbox.d.ts +3 -0
- package/dist/conformance/Outbox.d.ts.map +1 -0
- package/dist/conformance/Outbox.js +266 -0
- package/dist/conformance/Outbox.js.map +1 -0
- package/dist/conformance/PlatformReference.d.ts +5 -0
- package/dist/conformance/PlatformReference.d.ts.map +1 -0
- package/dist/conformance/PlatformReference.js +66 -0
- package/dist/conformance/PlatformReference.js.map +1 -0
- package/dist/conformance/PlatformSubject.d.ts +45 -0
- package/dist/conformance/PlatformSubject.d.ts.map +1 -0
- package/dist/conformance/PlatformSubject.js +3 -0
- package/dist/conformance/PlatformSubject.js.map +1 -0
- package/dist/conformance/Privacy.d.ts +3 -0
- package/dist/conformance/Privacy.d.ts.map +1 -0
- package/dist/conformance/Privacy.js +437 -0
- package/dist/conformance/Privacy.js.map +1 -0
- package/dist/conformance/Progress.d.ts +3 -0
- package/dist/conformance/Progress.d.ts.map +1 -0
- package/dist/conformance/Progress.js +153 -0
- package/dist/conformance/Progress.js.map +1 -0
- package/dist/conformance/Push.d.ts +38 -0
- package/dist/conformance/Push.d.ts.map +1 -0
- package/dist/conformance/Push.js +649 -0
- package/dist/conformance/Push.js.map +1 -0
- package/dist/conformance/PushReference.d.ts +3 -0
- package/dist/conformance/PushReference.d.ts.map +1 -0
- package/dist/conformance/PushReference.js +97 -0
- package/dist/conformance/PushReference.js.map +1 -0
- package/dist/conformance/QuerySurface.d.ts +9 -0
- package/dist/conformance/QuerySurface.d.ts.map +1 -0
- package/dist/conformance/QuerySurface.js +349 -0
- package/dist/conformance/QuerySurface.js.map +1 -0
- package/dist/conformance/Readiness.d.ts +23 -0
- package/dist/conformance/Readiness.d.ts.map +1 -0
- package/dist/conformance/Readiness.js +110 -0
- package/dist/conformance/Readiness.js.map +1 -0
- package/dist/conformance/Reference.d.ts +17 -0
- package/dist/conformance/Reference.d.ts.map +1 -0
- package/dist/conformance/Reference.js +246 -0
- package/dist/conformance/Reference.js.map +1 -0
- package/dist/conformance/Release.d.ts +73 -0
- package/dist/conformance/Release.d.ts.map +1 -0
- package/dist/conformance/Release.js +556 -0
- package/dist/conformance/Release.js.map +1 -0
- package/dist/conformance/ReleaseReference.d.ts +5 -0
- package/dist/conformance/ReleaseReference.d.ts.map +1 -0
- package/dist/conformance/ReleaseReference.js +124 -0
- package/dist/conformance/ReleaseReference.js.map +1 -0
- package/dist/conformance/ResultRendering.d.ts +3 -0
- package/dist/conformance/ResultRendering.d.ts.map +1 -0
- package/dist/conformance/ResultRendering.js +120 -0
- package/dist/conformance/ResultRendering.js.map +1 -0
- package/dist/conformance/Sandbox.d.ts +58 -0
- package/dist/conformance/Sandbox.d.ts.map +1 -0
- package/dist/conformance/Sandbox.js +213 -0
- package/dist/conformance/Sandbox.js.map +1 -0
- package/dist/conformance/SandboxReference.d.ts +3 -0
- package/dist/conformance/SandboxReference.d.ts.map +1 -0
- package/dist/conformance/SandboxReference.js +44 -0
- package/dist/conformance/SandboxReference.js.map +1 -0
- package/dist/conformance/Scheduler.d.ts +106 -0
- package/dist/conformance/Scheduler.d.ts.map +1 -0
- package/dist/conformance/Scheduler.js +576 -0
- package/dist/conformance/Scheduler.js.map +1 -0
- package/dist/conformance/ScreenContext.d.ts +84 -0
- package/dist/conformance/ScreenContext.d.ts.map +1 -0
- package/dist/conformance/ScreenContext.js +290 -0
- package/dist/conformance/ScreenContext.js.map +1 -0
- package/dist/conformance/Search.d.ts +3 -0
- package/dist/conformance/Search.d.ts.map +1 -0
- package/dist/conformance/Search.js +333 -0
- package/dist/conformance/Search.js.map +1 -0
- package/dist/conformance/Secrets.d.ts +8 -0
- package/dist/conformance/Secrets.d.ts.map +1 -0
- package/dist/conformance/Secrets.js +231 -0
- package/dist/conformance/Secrets.js.map +1 -0
- package/dist/conformance/SecretsReference.d.ts +44 -0
- package/dist/conformance/SecretsReference.d.ts.map +1 -0
- package/dist/conformance/SecretsReference.js +73 -0
- package/dist/conformance/SecretsReference.js.map +1 -0
- package/dist/conformance/ServicesReference.d.ts +8 -0
- package/dist/conformance/ServicesReference.d.ts.map +1 -0
- package/dist/conformance/ServicesReference.js +273 -0
- package/dist/conformance/ServicesReference.js.map +1 -0
- package/dist/conformance/ServicesSubject.d.ts +104 -0
- package/dist/conformance/ServicesSubject.d.ts.map +1 -0
- package/dist/conformance/ServicesSubject.js +2 -0
- package/dist/conformance/ServicesSubject.js.map +1 -0
- package/dist/conformance/Settings.d.ts +3 -0
- package/dist/conformance/Settings.d.ts.map +1 -0
- package/dist/conformance/Settings.js +177 -0
- package/dist/conformance/Settings.js.map +1 -0
- package/dist/conformance/Sharing.d.ts +3 -0
- package/dist/conformance/Sharing.d.ts.map +1 -0
- package/dist/conformance/Sharing.js +368 -0
- package/dist/conformance/Sharing.js.map +1 -0
- package/dist/conformance/ShellSubject.d.ts +29 -0
- package/dist/conformance/ShellSubject.d.ts.map +1 -0
- package/dist/conformance/ShellSubject.js +13 -0
- package/dist/conformance/ShellSubject.js.map +1 -0
- package/dist/conformance/SignOutRace.d.ts +23 -0
- package/dist/conformance/SignOutRace.d.ts.map +1 -0
- package/dist/conformance/SignOutRace.js +49 -0
- package/dist/conformance/SignOutRace.js.map +1 -0
- package/dist/conformance/Slot.d.ts +3 -0
- package/dist/conformance/Slot.d.ts.map +1 -0
- package/dist/conformance/Slot.js +79 -0
- package/dist/conformance/Slot.js.map +1 -0
- package/dist/conformance/Space.d.ts +63 -0
- package/dist/conformance/Space.d.ts.map +1 -0
- package/dist/conformance/Space.js +294 -0
- package/dist/conformance/Space.js.map +1 -0
- package/dist/conformance/StorageAdapter.d.ts +76 -0
- package/dist/conformance/StorageAdapter.d.ts.map +1 -0
- package/dist/conformance/StorageAdapter.js +181 -0
- package/dist/conformance/StorageAdapter.js.map +1 -0
- package/dist/conformance/StorageBackend.d.ts +23 -0
- package/dist/conformance/StorageBackend.d.ts.map +1 -0
- package/dist/conformance/StorageBackend.js +274 -0
- package/dist/conformance/StorageBackend.js.map +1 -0
- package/dist/conformance/Subject.d.ts +198 -0
- package/dist/conformance/Subject.d.ts.map +1 -0
- package/dist/conformance/Subject.js +26 -0
- package/dist/conformance/Subject.js.map +1 -0
- package/dist/conformance/Sync.d.ts +3 -0
- package/dist/conformance/Sync.d.ts.map +1 -0
- package/dist/conformance/Sync.js +190 -0
- package/dist/conformance/Sync.js.map +1 -0
- package/dist/conformance/Telemetry.d.ts +3 -0
- package/dist/conformance/Telemetry.d.ts.map +1 -0
- package/dist/conformance/Telemetry.js +218 -0
- package/dist/conformance/Telemetry.js.map +1 -0
- package/dist/conformance/ThemeTokens.d.ts +22 -0
- package/dist/conformance/ThemeTokens.d.ts.map +1 -0
- package/dist/conformance/ThemeTokens.js +121 -0
- package/dist/conformance/ThemeTokens.js.map +1 -0
- package/dist/conformance/ToolSource.d.ts +5 -0
- package/dist/conformance/ToolSource.d.ts.map +1 -0
- package/dist/conformance/ToolSource.js +520 -0
- package/dist/conformance/ToolSource.js.map +1 -0
- package/dist/conformance/Versioning.d.ts +3 -0
- package/dist/conformance/Versioning.d.ts.map +1 -0
- package/dist/conformance/Versioning.js +160 -0
- package/dist/conformance/Versioning.js.map +1 -0
- package/dist/conformance/View.d.ts +3 -0
- package/dist/conformance/View.d.ts.map +1 -0
- package/dist/conformance/View.js +121 -0
- package/dist/conformance/View.js.map +1 -0
- package/dist/conformance/WorkItems.d.ts +3 -0
- package/dist/conformance/WorkItems.d.ts.map +1 -0
- package/dist/conformance/WorkItems.js +152 -0
- package/dist/conformance/WorkItems.js.map +1 -0
- package/dist/conformance/Workflow.d.ts +63 -0
- package/dist/conformance/Workflow.d.ts.map +1 -0
- package/dist/conformance/Workflow.js +235 -0
- package/dist/conformance/Workflow.js.map +1 -0
- package/dist/conformance/acme/chatlog.d.ts +591 -0
- package/dist/conformance/acme/chatlog.d.ts.map +1 -0
- package/dist/conformance/acme/chatlog.js +101 -0
- package/dist/conformance/acme/chatlog.js.map +1 -0
- package/dist/conformance/acme/connector.d.ts +12 -0
- package/dist/conformance/acme/connector.d.ts.map +1 -0
- package/dist/conformance/acme/connector.js +123 -0
- package/dist/conformance/acme/connector.js.map +1 -0
- package/dist/conformance/acme/migrations/0000_messages.sql +8 -0
- package/dist/conformance/archive/app.d.ts +728 -0
- package/dist/conformance/archive/app.d.ts.map +1 -0
- package/dist/conformance/archive/app.js +30 -0
- package/dist/conformance/archive/app.js.map +1 -0
- package/dist/conformance/archive/contract.d.ts +467 -0
- package/dist/conformance/archive/contract.d.ts.map +1 -0
- package/dist/conformance/archive/contract.js +187 -0
- package/dist/conformance/archive/contract.js.map +1 -0
- package/dist/conformance/archive/memo.sync.gen.d.ts +148 -0
- package/dist/conformance/archive/memo.sync.gen.d.ts.map +1 -0
- package/dist/conformance/archive/memo.sync.gen.js +23 -0
- package/dist/conformance/archive/memo.sync.gen.js.map +1 -0
- package/dist/conformance/archive/migrations/archive/0000_archive.sql +9 -0
- package/dist/conformance/archive/migrations/memo/0000_memo.sql +6 -0
- package/dist/conformance/archive/schema.d.ts +185 -0
- package/dist/conformance/archive/schema.d.ts.map +1 -0
- package/dist/conformance/archive/schema.js +22 -0
- package/dist/conformance/archive/schema.js.map +1 -0
- package/dist/conformance/archive/server.d.ts +273 -0
- package/dist/conformance/archive/server.d.ts.map +1 -0
- package/dist/conformance/archive/server.js +127 -0
- package/dist/conformance/archive/server.js.map +1 -0
- package/dist/conformance/archive/sync.gen.d.ts +319 -0
- package/dist/conformance/archive/sync.gen.d.ts.map +1 -0
- package/dist/conformance/archive/sync.gen.js +29 -0
- package/dist/conformance/archive/sync.gen.js.map +1 -0
- package/dist/conformance/atlas/app.d.ts +3 -0
- package/dist/conformance/atlas/app.d.ts.map +1 -0
- package/dist/conformance/atlas/app.js +15 -0
- package/dist/conformance/atlas/app.js.map +1 -0
- package/dist/conformance/atlas/contract.d.ts +489 -0
- package/dist/conformance/atlas/contract.d.ts.map +1 -0
- package/dist/conformance/atlas/contract.js +114 -0
- package/dist/conformance/atlas/contract.js.map +1 -0
- package/dist/conformance/crm/app.d.ts +304 -0
- package/dist/conformance/crm/app.d.ts.map +1 -0
- package/dist/conformance/crm/app.js +95 -0
- package/dist/conformance/crm/app.js.map +1 -0
- package/dist/conformance/crm/contract.d.ts +586 -0
- package/dist/conformance/crm/contract.d.ts.map +1 -0
- package/dist/conformance/crm/contract.js +153 -0
- package/dist/conformance/crm/contract.js.map +1 -0
- package/dist/conformance/crm/migrations/crm/0000_crm.sql +18 -0
- package/dist/conformance/crm/migrations/team/0000_team.sql +6 -0
- package/dist/conformance/crm/schema.d.ts +261 -0
- package/dist/conformance/crm/schema.d.ts.map +1 -0
- package/dist/conformance/crm/schema.js +25 -0
- package/dist/conformance/crm/schema.js.map +1 -0
- package/dist/conformance/crm/sync.gen.d.ts +188 -0
- package/dist/conformance/crm/sync.gen.d.ts.map +1 -0
- package/dist/conformance/crm/sync.gen.js +25 -0
- package/dist/conformance/crm/sync.gen.js.map +1 -0
- package/dist/conformance/desk/contract.d.ts +306 -0
- package/dist/conformance/desk/contract.d.ts.map +1 -0
- package/dist/conformance/desk/contract.js +56 -0
- package/dist/conformance/desk/contract.js.map +1 -0
- package/dist/conformance/desk/migrations/0000_notes.sql +7 -0
- package/dist/conformance/desk/server.d.ts +231 -0
- package/dist/conformance/desk/server.d.ts.map +1 -0
- package/dist/conformance/desk/server.js +123 -0
- package/dist/conformance/desk/server.js.map +1 -0
- package/dist/conformance/drafts/migrations/0000_drafts.sql +8 -0
- package/dist/conformance/drafts/module.d.ts +571 -0
- package/dist/conformance/drafts/module.d.ts.map +1 -0
- package/dist/conformance/drafts/module.js +190 -0
- package/dist/conformance/drafts/module.js.map +1 -0
- package/dist/conformance/fixture/app.d.ts +24 -0
- package/dist/conformance/fixture/app.d.ts.map +1 -0
- package/dist/conformance/fixture/app.js +26 -0
- package/dist/conformance/fixture/app.js.map +1 -0
- package/dist/conformance/fixture/docs/bad-sync.d.ts +105 -0
- package/dist/conformance/fixture/docs/bad-sync.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/bad-sync.js +22 -0
- package/dist/conformance/fixture/docs/bad-sync.js.map +1 -0
- package/dist/conformance/fixture/docs/contract.d.ts +1091 -0
- package/dist/conformance/fixture/docs/contract.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/contract.js +277 -0
- package/dist/conformance/fixture/docs/contract.js.map +1 -0
- package/dist/conformance/fixture/docs/migrations/0000_docs.sql +9 -0
- package/dist/conformance/fixture/docs/migrations/0001_seen.sql +12 -0
- package/dist/conformance/fixture/docs/migrations/0002_attachment.sql +6 -0
- package/dist/conformance/fixture/docs/policy.cedar +110 -0
- package/dist/conformance/fixture/docs/schema.d.ts +308 -0
- package/dist/conformance/fixture/docs/schema.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/schema.js +36 -0
- package/dist/conformance/fixture/docs/schema.js.map +1 -0
- package/dist/conformance/fixture/docs/server.d.ts +552 -0
- package/dist/conformance/fixture/docs/server.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/server.js +192 -0
- package/dist/conformance/fixture/docs/server.js.map +1 -0
- package/dist/conformance/fixture/docs/sync.d.ts +402 -0
- package/dist/conformance/fixture/docs/sync.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/sync.gen.d.ts +574 -0
- package/dist/conformance/fixture/docs/sync.gen.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/sync.gen.js +48 -0
- package/dist/conformance/fixture/docs/sync.gen.js.map +1 -0
- package/dist/conformance/fixture/docs/sync.js +23 -0
- package/dist/conformance/fixture/docs/sync.js.map +1 -0
- package/dist/conformance/fixture/peer/migrations/0000_peer.sql +8 -0
- package/dist/conformance/fixture/peer/module.d.ts +306 -0
- package/dist/conformance/fixture/peer/module.d.ts.map +1 -0
- package/dist/conformance/fixture/peer/module.js +44 -0
- package/dist/conformance/fixture/peer/module.js.map +1 -0
- package/dist/conformance/fixture/release/blocking/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/blocking/0001_wait.sql +2 -0
- package/dist/conformance/fixture/release/blocking-renamed/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/blocking-renamed/0001_wait.sql +5 -0
- package/dist/conformance/fixture/release/broken/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/broken/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/broken/0002_label.sql +3 -0
- package/dist/conformance/fixture/release/drift/escalate/0000_item.sql +5 -0
- package/dist/conformance/fixture/release/drift/escalate/0001_escalate.sql +8 -0
- package/dist/conformance/fixture/release/drift/v1/0000_item.sql +5 -0
- package/dist/conformance/fixture/release/escape/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/escape/0001_escape.sql +5 -0
- package/dist/conformance/fixture/release/misnamed/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/misnamed/0001_misname.sql +10 -0
- package/dist/conformance/fixture/release/module.d.ts +1878 -0
- package/dist/conformance/fixture/release/module.d.ts.map +1 -0
- package/dist/conformance/fixture/release/module.js +102 -0
- package/dist/conformance/fixture/release/module.js.map +1 -0
- package/dist/conformance/fixture/release/outside/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/outside/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/outside/0002_index.sql +4 -0
- package/dist/conformance/fixture/release/outside/0003_later.sql +1 -0
- package/dist/conformance/fixture/release/renamed/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/renamed/0001_misname.sql +10 -0
- package/dist/conformance/fixture/release/renamed/0002_restore.sql +1 -0
- package/dist/conformance/fixture/release/rogue/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/rogue/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/rogue/0002_definer.sql +1 -0
- package/dist/conformance/fixture/release/slow/0000_item.sql +5 -0
- package/dist/conformance/fixture/release/undeclared/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/undeclared/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/undeclared/0002_index.sql +1 -0
- package/dist/conformance/fixture/release/v1/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/v2/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/v2/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/v2/0002_label.sql +3 -0
- package/dist/conformance/fixture/release/viewed-retyped/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/viewed-retyped/0001_retype.sql +1 -0
- package/dist/conformance/kit-hash.d.ts +8 -0
- package/dist/conformance/kit-hash.d.ts.map +1 -0
- package/dist/conformance/kit-hash.js +20 -0
- package/dist/conformance/kit-hash.js.map +1 -0
- package/dist/conformance/ledger/contract.d.ts +380 -0
- package/dist/conformance/ledger/contract.d.ts.map +1 -0
- package/dist/conformance/ledger/contract.js +81 -0
- package/dist/conformance/ledger/contract.js.map +1 -0
- package/dist/conformance/ledger/migrations/0000_entries.sql +8 -0
- package/dist/conformance/ledger/server.d.ts +312 -0
- package/dist/conformance/ledger/server.d.ts.map +1 -0
- package/dist/conformance/ledger/server.js +152 -0
- package/dist/conformance/ledger/server.js.map +1 -0
- package/dist/conformance/library/app.d.ts +616 -0
- package/dist/conformance/library/app.d.ts.map +1 -0
- package/dist/conformance/library/app.js +35 -0
- package/dist/conformance/library/app.js.map +1 -0
- package/dist/conformance/library/contract.d.ts +377 -0
- package/dist/conformance/library/contract.d.ts.map +1 -0
- package/dist/conformance/library/contract.js +63 -0
- package/dist/conformance/library/contract.js.map +1 -0
- package/dist/conformance/library/migrations/0000_library.sql +14 -0
- package/dist/conformance/library/schema.d.ts +174 -0
- package/dist/conformance/library/schema.d.ts.map +1 -0
- package/dist/conformance/library/schema.js +24 -0
- package/dist/conformance/library/schema.js.map +1 -0
- package/dist/conformance/library/server.d.ts +191 -0
- package/dist/conformance/library/server.d.ts.map +1 -0
- package/dist/conformance/library/server.js +52 -0
- package/dist/conformance/library/server.js.map +1 -0
- package/dist/conformance/library/sync.gen.d.ts +519 -0
- package/dist/conformance/library/sync.gen.d.ts.map +1 -0
- package/dist/conformance/library/sync.gen.js +42 -0
- package/dist/conformance/library/sync.gen.js.map +1 -0
- package/dist/conformance/locale/catalog.d.ts +93 -0
- package/dist/conformance/locale/catalog.d.ts.map +1 -0
- package/dist/conformance/locale/catalog.js +104 -0
- package/dist/conformance/locale/catalog.js.map +1 -0
- package/dist/conformance/notebook/app.d.ts +1039 -0
- package/dist/conformance/notebook/app.d.ts.map +1 -0
- package/dist/conformance/notebook/app.js +88 -0
- package/dist/conformance/notebook/app.js.map +1 -0
- package/dist/conformance/notebook/evals/pages.evals.json +94 -0
- package/dist/conformance/notebook/migrations/0000_notebook.sql +10 -0
- package/dist/conformance/notebook/module.d.ts +717 -0
- package/dist/conformance/notebook/module.d.ts.map +1 -0
- package/dist/conformance/notebook/module.js +188 -0
- package/dist/conformance/notebook/module.js.map +1 -0
- package/dist/conformance/pad/app.d.ts +9 -0
- package/dist/conformance/pad/app.d.ts.map +1 -0
- package/dist/conformance/pad/app.js +13 -0
- package/dist/conformance/pad/app.js.map +1 -0
- package/dist/conformance/pad/contract.d.ts +281 -0
- package/dist/conformance/pad/contract.d.ts.map +1 -0
- package/dist/conformance/pad/contract.js +66 -0
- package/dist/conformance/pad/contract.js.map +1 -0
- package/dist/conformance/pad/migrations/pad/0000_pad.sql +8 -0
- package/dist/conformance/pad/migrations/pad/0001_live_copy.sql +2 -0
- package/dist/conformance/pad/schema.d.ts +127 -0
- package/dist/conformance/pad/schema.d.ts.map +1 -0
- package/dist/conformance/pad/schema.js +17 -0
- package/dist/conformance/pad/schema.js.map +1 -0
- package/dist/conformance/pad/server.d.ts +149 -0
- package/dist/conformance/pad/server.d.ts.map +1 -0
- package/dist/conformance/pad/server.js +81 -0
- package/dist/conformance/pad/server.js.map +1 -0
- package/dist/conformance/purchases/app.d.ts +480 -0
- package/dist/conformance/purchases/app.d.ts.map +1 -0
- package/dist/conformance/purchases/app.js +32 -0
- package/dist/conformance/purchases/app.js.map +1 -0
- package/dist/conformance/purchases/contract.d.ts +720 -0
- package/dist/conformance/purchases/contract.d.ts.map +1 -0
- package/dist/conformance/purchases/contract.js +148 -0
- package/dist/conformance/purchases/contract.js.map +1 -0
- package/dist/conformance/purchases/migrations/0000_purchases.sql +17 -0
- package/dist/conformance/purchases/server.d.ts +250 -0
- package/dist/conformance/purchases/server.d.ts.map +1 -0
- package/dist/conformance/purchases/server.js +85 -0
- package/dist/conformance/purchases/server.js.map +1 -0
- package/dist/conformance/studio/app.d.ts +996 -0
- package/dist/conformance/studio/app.d.ts.map +1 -0
- package/dist/conformance/studio/app.js +251 -0
- package/dist/conformance/studio/app.js.map +1 -0
- package/dist/conformance/studio/contract.d.ts +1318 -0
- package/dist/conformance/studio/contract.d.ts.map +1 -0
- package/dist/conformance/studio/contract.js +280 -0
- package/dist/conformance/studio/contract.js.map +1 -0
- package/dist/conformance/studio/migrations/billing/0000_billing.sql +6 -0
- package/dist/conformance/studio/migrations/journal/0000_journal.sql +9 -0
- package/dist/conformance/studio/migrations/mailbox/0000_mailbox.sql +7 -0
- package/dist/conformance/studio/migrations/tasks/0000_tasks.sql +7 -0
- package/dist/conformance/workshop/app.d.ts +8 -0
- package/dist/conformance/workshop/app.d.ts.map +1 -0
- package/dist/conformance/workshop/app.js +13 -0
- package/dist/conformance/workshop/app.js.map +1 -0
- package/dist/conformance/workshop/migrations/0000_notes.sql +7 -0
- package/dist/conformance/workshop/module.d.ts +407 -0
- package/dist/conformance/workshop/module.d.ts.map +1 -0
- package/dist/conformance/workshop/module.js +71 -0
- package/dist/conformance/workshop/module.js.map +1 -0
- package/dist/fakes/AcmeFake.d.ts +46 -0
- package/dist/fakes/AcmeFake.d.ts.map +1 -0
- package/dist/fakes/AcmeFake.js +131 -0
- package/dist/fakes/AcmeFake.js.map +1 -0
- package/dist/fakes/ApnsFake.d.ts +79 -0
- package/dist/fakes/ApnsFake.d.ts.map +1 -0
- package/dist/fakes/ApnsFake.js +220 -0
- package/dist/fakes/ApnsFake.js.map +1 -0
- package/dist/fakes/FcmFake.d.ts +46 -0
- package/dist/fakes/FcmFake.d.ts.map +1 -0
- package/dist/fakes/FcmFake.js +185 -0
- package/dist/fakes/FcmFake.js.map +1 -0
- package/dist/fakes/GoogleFake.d.ts +221 -0
- package/dist/fakes/GoogleFake.d.ts.map +1 -0
- package/dist/fakes/GoogleFake.js +1035 -0
- package/dist/fakes/GoogleFake.js.map +1 -0
- package/dist/fakes/HttpApiFake.d.ts +22 -0
- package/dist/fakes/HttpApiFake.d.ts.map +1 -0
- package/dist/fakes/HttpApiFake.js +74 -0
- package/dist/fakes/HttpApiFake.js.map +1 -0
- package/dist/fakes/McpFake.d.ts +80 -0
- package/dist/fakes/McpFake.d.ts.map +1 -0
- package/dist/fakes/McpFake.js +312 -0
- package/dist/fakes/McpFake.js.map +1 -0
- package/dist/fakes/MicrosoftGraphFake.d.ts +254 -0
- package/dist/fakes/MicrosoftGraphFake.d.ts.map +1 -0
- package/dist/fakes/MicrosoftGraphFake.js +850 -0
- package/dist/fakes/MicrosoftGraphFake.js.map +1 -0
- package/dist/fakes/S3Fake.d.ts +29 -0
- package/dist/fakes/S3Fake.d.ts.map +1 -0
- package/dist/fakes/S3Fake.js +347 -0
- package/dist/fakes/S3Fake.js.map +1 -0
- package/dist/fakes/Server.d.ts +137 -0
- package/dist/fakes/Server.d.ts.map +1 -0
- package/dist/fakes/Server.js +357 -0
- package/dist/fakes/Server.js.map +1 -0
- package/dist/fakes/SignInProviderFake.d.ts +21 -0
- package/dist/fakes/SignInProviderFake.d.ts.map +1 -0
- package/dist/fakes/SignInProviderFake.js +56 -0
- package/dist/fakes/SignInProviderFake.js.map +1 -0
- package/dist/fakes/SlackFake.d.ts +136 -0
- package/dist/fakes/SlackFake.d.ts.map +1 -0
- package/dist/fakes/SlackFake.js +787 -0
- package/dist/fakes/SlackFake.js.map +1 -0
- package/dist/fakes/Store.d.ts +40 -0
- package/dist/fakes/Store.d.ts.map +1 -0
- package/dist/fakes/Store.js +82 -0
- package/dist/fakes/Store.js.map +1 -0
- package/dist/fakes/TelemetryFakes.d.ts +77 -0
- package/dist/fakes/TelemetryFakes.d.ts.map +1 -0
- package/dist/fakes/TelemetryFakes.js +121 -0
- package/dist/fakes/TelemetryFakes.js.map +1 -0
- package/dist/fakes/TestCa.d.ts +11 -0
- package/dist/fakes/TestCa.d.ts.map +1 -0
- package/dist/fakes/TestCa.js +115 -0
- package/dist/fakes/TestCa.js.map +1 -0
- package/dist/fakes/WorkOsFake.d.ts +40 -0
- package/dist/fakes/WorkOsFake.d.ts.map +1 -0
- package/dist/fakes/WorkOsFake.js +103 -0
- package/dist/fakes/WorkOsFake.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/make/reference.d.ts +520 -0
- package/dist/make/reference.d.ts.map +1 -0
- package/dist/make/reference.js +182 -0
- package/dist/make/reference.js.map +1 -0
- package/dist/make/sources.d.ts +48 -0
- package/dist/make/sources.d.ts.map +1 -0
- package/dist/make/sources.js +806 -0
- package/dist/make/sources.js.map +1 -0
- package/package.json +77 -3
- package/src/Admin.ts +82 -0
- package/src/Agent.ts +289 -0
- package/src/AgentSurface.ts +51 -0
- package/src/Embedder.ts +69 -0
- package/src/EvalMain.ts +81 -0
- package/src/Evals.ts +490 -0
- package/src/Kernel.ts +228 -0
- package/src/Launch.ts +428 -0
- package/src/Locks.ts +123 -0
- package/src/Routes.ts +65 -0
- package/src/ScriptedChatModel.ts +189 -0
- package/src/SmtpSink.ts +205 -0
- package/src/System.ts +1075 -0
- package/src/TcpProxy.ts +102 -0
- package/src/auth/TrustedProxyAuth.ts +173 -0
- package/src/conformance/ActionConsent.ts +437 -0
- package/src/conformance/ActionRegistry.ts +174 -0
- package/src/conformance/Actor.ts +216 -0
- package/src/conformance/AgentReference.ts +171 -0
- package/src/conformance/AgentResources.ts +548 -0
- package/src/conformance/AgentRuntime.ts +388 -0
- package/src/conformance/AgentSubject.ts +103 -0
- package/src/conformance/Approvals.ts +363 -0
- package/src/conformance/Audit.ts +257 -0
- package/src/conformance/CalendarProvider.ts +156 -0
- package/src/conformance/CapabilityKit.ts +564 -0
- package/src/conformance/ClientSDK.ts +233 -0
- package/src/conformance/CollabDocument.ts +1203 -0
- package/src/conformance/CollabReference.ts +152 -0
- package/src/conformance/CollabSubject.ts +64 -0
- package/src/conformance/Command.ts +75 -0
- package/src/conformance/Connections.ts +357 -0
- package/src/conformance/ConnectionsReference.ts +172 -0
- package/src/conformance/ConnectorReference.ts +280 -0
- package/src/conformance/ContextAccounting.ts +169 -0
- package/src/conformance/Daemon.ts +936 -0
- package/src/conformance/DaemonReference.ts +189 -0
- package/src/conformance/DbTx.ts +253 -0
- package/src/conformance/DecisionTokens.ts +652 -0
- package/src/conformance/Delegation.ts +177 -0
- package/src/conformance/DeskReference.ts +73 -0
- package/src/conformance/DeviceControl.ts +700 -0
- package/src/conformance/Directory.ts +315 -0
- package/src/conformance/DirectoryProvider.ts +72 -0
- package/src/conformance/DocumentSource.ts +62 -0
- package/src/conformance/EndpointReference.ts +117 -0
- package/src/conformance/Files.ts +685 -0
- package/src/conformance/FilesReference.ts +154 -0
- package/src/conformance/FilesSubject.ts +50 -0
- package/src/conformance/Flags.ts +215 -0
- package/src/conformance/Host.ts +197 -0
- package/src/conformance/HttpApi.ts +169 -0
- package/src/conformance/InboxReference.ts +401 -0
- package/src/conformance/InboxSubject.ts +101 -0
- package/src/conformance/Ingestion.ts +425 -0
- package/src/conformance/Ingress.ts +498 -0
- package/src/conformance/Invocation.ts +780 -0
- package/src/conformance/IsolationMatrix.ts +215 -0
- package/src/conformance/LiveConnection.ts +197 -0
- package/src/conformance/LocalClient.ts +707 -0
- package/src/conformance/Locale.ts +141 -0
- package/src/conformance/MachineIdentity.ts +828 -0
- package/src/conformance/MailProvider.ts +217 -0
- package/src/conformance/Memory.ts +223 -0
- package/src/conformance/Messaging.ts +185 -0
- package/src/conformance/Metering.ts +293 -0
- package/src/conformance/ModelProvider.ts +139 -0
- package/src/conformance/ModuleManifest.ts +630 -0
- package/src/conformance/NotebookAgent.ts +41 -0
- package/src/conformance/NotificationChannel.ts +122 -0
- package/src/conformance/Notifications.ts +316 -0
- package/src/conformance/OAuthClient.ts +240 -0
- package/src/conformance/Outbox.ts +342 -0
- package/src/conformance/PlatformReference.ts +73 -0
- package/src/conformance/PlatformSubject.ts +50 -0
- package/src/conformance/Privacy.ts +577 -0
- package/src/conformance/Progress.ts +244 -0
- package/src/conformance/Push.ts +820 -0
- package/src/conformance/PushReference.ts +101 -0
- package/src/conformance/QuerySurface.ts +408 -0
- package/src/conformance/Readiness.ts +157 -0
- package/src/conformance/Reference.ts +326 -0
- package/src/conformance/Release.ts +690 -0
- package/src/conformance/ReleaseReference.ts +179 -0
- package/src/conformance/ResultRendering.ts +149 -0
- package/src/conformance/Sandbox.ts +313 -0
- package/src/conformance/SandboxReference.ts +52 -0
- package/src/conformance/Scheduler.ts +764 -0
- package/src/conformance/ScreenContext.ts +402 -0
- package/src/conformance/Search.ts +419 -0
- package/src/conformance/Secrets.ts +277 -0
- package/src/conformance/SecretsReference.ts +131 -0
- package/src/conformance/ServicesReference.ts +330 -0
- package/src/conformance/ServicesSubject.ts +105 -0
- package/src/conformance/Settings.ts +204 -0
- package/src/conformance/Sharing.ts +486 -0
- package/src/conformance/ShellSubject.ts +47 -0
- package/src/conformance/SignOutRace.ts +77 -0
- package/src/conformance/Slot.ts +84 -0
- package/src/conformance/Space.ts +432 -0
- package/src/conformance/StorageAdapter.ts +253 -0
- package/src/conformance/StorageBackend.ts +327 -0
- package/src/conformance/Subject.ts +208 -0
- package/src/conformance/Sync.ts +215 -0
- package/src/conformance/Telemetry.ts +287 -0
- package/src/conformance/ThemeTokens.ts +163 -0
- package/src/conformance/ToolSource.ts +632 -0
- package/src/conformance/Versioning.ts +199 -0
- package/src/conformance/View.ts +143 -0
- package/src/conformance/WorkItems.ts +186 -0
- package/src/conformance/Workflow.ts +304 -0
- package/src/conformance/acme/chatlog.ts +115 -0
- package/src/conformance/acme/connector.ts +151 -0
- package/src/conformance/acme/migrations/0000_messages.sql +8 -0
- package/src/conformance/archive/app.ts +33 -0
- package/src/conformance/archive/contract.ts +191 -0
- package/src/conformance/archive/memo.sync.gen.ts +25 -0
- package/src/conformance/archive/migrations/archive/0000_archive.sql +9 -0
- package/src/conformance/archive/migrations/memo/0000_memo.sql +6 -0
- package/src/conformance/archive/schema.ts +25 -0
- package/src/conformance/archive/server.ts +146 -0
- package/src/conformance/archive/sync.gen.ts +32 -0
- package/src/conformance/atlas/app.ts +16 -0
- package/src/conformance/atlas/contract.ts +118 -0
- package/src/conformance/crm/app.ts +107 -0
- package/src/conformance/crm/contract.ts +163 -0
- package/src/conformance/crm/migrations/crm/0000_crm.sql +18 -0
- package/src/conformance/crm/migrations/team/0000_team.sql +6 -0
- package/src/conformance/crm/schema.ts +28 -0
- package/src/conformance/crm/sync.gen.ts +27 -0
- package/src/conformance/desk/contract.ts +61 -0
- package/src/conformance/desk/migrations/0000_notes.sql +7 -0
- package/src/conformance/desk/server.ts +131 -0
- package/src/conformance/drafts/migrations/0000_drafts.sql +8 -0
- package/src/conformance/drafts/module.ts +211 -0
- package/src/conformance/fixture/app.ts +37 -0
- package/src/conformance/fixture/docs/bad-sync.ts +34 -0
- package/src/conformance/fixture/docs/contract.ts +297 -0
- package/src/conformance/fixture/docs/migrations/0000_docs.sql +9 -0
- package/src/conformance/fixture/docs/migrations/0001_seen.sql +12 -0
- package/src/conformance/fixture/docs/migrations/0002_attachment.sql +6 -0
- package/src/conformance/fixture/docs/policy.cedar +110 -0
- package/src/conformance/fixture/docs/schema.ts +41 -0
- package/src/conformance/fixture/docs/server.ts +292 -0
- package/src/conformance/fixture/docs/sync.gen.ts +54 -0
- package/src/conformance/fixture/docs/sync.ts +24 -0
- package/src/conformance/fixture/peer/migrations/0000_peer.sql +8 -0
- package/src/conformance/fixture/peer/module.ts +51 -0
- package/src/conformance/fixture/release/blocking/0000_item.sql +3 -0
- package/src/conformance/fixture/release/blocking/0001_wait.sql +2 -0
- package/src/conformance/fixture/release/blocking-renamed/0000_item.sql +3 -0
- package/src/conformance/fixture/release/blocking-renamed/0001_wait.sql +5 -0
- package/src/conformance/fixture/release/broken/0000_item.sql +3 -0
- package/src/conformance/fixture/release/broken/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/broken/0002_label.sql +3 -0
- package/src/conformance/fixture/release/drift/escalate/0000_item.sql +5 -0
- package/src/conformance/fixture/release/drift/escalate/0001_escalate.sql +8 -0
- package/src/conformance/fixture/release/drift/v1/0000_item.sql +5 -0
- package/src/conformance/fixture/release/escape/0000_item.sql +3 -0
- package/src/conformance/fixture/release/escape/0001_escape.sql +5 -0
- package/src/conformance/fixture/release/misnamed/0000_item.sql +3 -0
- package/src/conformance/fixture/release/misnamed/0001_misname.sql +10 -0
- package/src/conformance/fixture/release/module.ts +119 -0
- package/src/conformance/fixture/release/outside/0000_item.sql +3 -0
- package/src/conformance/fixture/release/outside/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/outside/0002_index.sql +4 -0
- package/src/conformance/fixture/release/outside/0003_later.sql +1 -0
- package/src/conformance/fixture/release/renamed/0000_item.sql +3 -0
- package/src/conformance/fixture/release/renamed/0001_misname.sql +10 -0
- package/src/conformance/fixture/release/renamed/0002_restore.sql +1 -0
- package/src/conformance/fixture/release/rogue/0000_item.sql +3 -0
- package/src/conformance/fixture/release/rogue/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/rogue/0002_definer.sql +1 -0
- package/src/conformance/fixture/release/slow/0000_item.sql +5 -0
- package/src/conformance/fixture/release/undeclared/0000_item.sql +3 -0
- package/src/conformance/fixture/release/undeclared/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/undeclared/0002_index.sql +1 -0
- package/src/conformance/fixture/release/v1/0000_item.sql +3 -0
- package/src/conformance/fixture/release/v2/0000_item.sql +3 -0
- package/src/conformance/fixture/release/v2/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/v2/0002_label.sql +3 -0
- package/src/conformance/fixture/release/viewed-retyped/0000_item.sql +3 -0
- package/src/conformance/fixture/release/viewed-retyped/0001_retype.sql +1 -0
- package/src/conformance/kit-hash.ts +18 -0
- package/src/conformance/ledger/contract.ts +92 -0
- package/src/conformance/ledger/migrations/0000_entries.sql +8 -0
- package/src/conformance/ledger/server.ts +174 -0
- package/src/conformance/library/app.ts +38 -0
- package/src/conformance/library/contract.ts +66 -0
- package/src/conformance/library/migrations/0000_library.sql +14 -0
- package/src/conformance/library/schema.ts +27 -0
- package/src/conformance/library/server.ts +65 -0
- package/src/conformance/library/sync.gen.ts +47 -0
- package/src/conformance/locale/catalog.ts +111 -0
- package/src/conformance/notebook/app.ts +115 -0
- package/src/conformance/notebook/evals/pages.evals.json +94 -0
- package/src/conformance/notebook/migrations/0000_notebook.sql +10 -0
- package/src/conformance/notebook/module.ts +215 -0
- package/src/conformance/notebook/skills/meeting-notes.md +4 -0
- package/src/conformance/pad/app.ts +21 -0
- package/src/conformance/pad/contract.ts +69 -0
- package/src/conformance/pad/migrations/pad/0000_pad.sql +8 -0
- package/src/conformance/pad/migrations/pad/0001_live_copy.sql +2 -0
- package/src/conformance/pad/schema.ts +18 -0
- package/src/conformance/pad/server.ts +102 -0
- package/src/conformance/purchases/app.ts +34 -0
- package/src/conformance/purchases/contract.ts +161 -0
- package/src/conformance/purchases/migrations/0000_purchases.sql +17 -0
- package/src/conformance/purchases/server.ts +95 -0
- package/src/conformance/replica-search.mjs +22 -0
- package/src/conformance/studio/app.ts +298 -0
- package/src/conformance/studio/contract.ts +319 -0
- package/src/conformance/studio/migrations/billing/0000_billing.sql +6 -0
- package/src/conformance/studio/migrations/journal/0000_journal.sql +9 -0
- package/src/conformance/studio/migrations/mailbox/0000_mailbox.sql +7 -0
- package/src/conformance/studio/migrations/tasks/0000_tasks.sql +7 -0
- package/src/conformance/workshop/app.ts +14 -0
- package/src/conformance/workshop/migrations/0000_notes.sql +7 -0
- package/src/conformance/workshop/module.ts +79 -0
- package/src/fakes/AcmeFake.ts +182 -0
- package/src/fakes/ApnsFake.ts +245 -0
- package/src/fakes/FcmFake.ts +231 -0
- package/src/fakes/GoogleFake.ts +1346 -0
- package/src/fakes/HttpApiFake.ts +116 -0
- package/src/fakes/McpFake.ts +355 -0
- package/src/fakes/MicrosoftGraphFake.ts +1191 -0
- package/src/fakes/S3Fake.ts +376 -0
- package/src/fakes/Server.ts +445 -0
- package/src/fakes/SignInProviderFake.ts +70 -0
- package/src/fakes/SlackFake.ts +893 -0
- package/src/fakes/Store.ts +96 -0
- package/src/fakes/TelemetryFakes.ts +197 -0
- package/src/fakes/TestCa.ts +166 -0
- package/src/fakes/WorkOsFake.ts +136 -0
- package/src/index.ts +9 -0
- package/src/make/reference.ts +259 -0
- package/src/make/sources.ts +836 -0
|
@@ -0,0 +1,1203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conformance kit for the CollabDocument contract (docs/contracts/collab-document.md) on the collab conformance app
|
|
3
|
+
* (`./pad/app.ts`): pages whose owner and editors change their collaborative document, readable by their owner, by
|
|
4
|
+
* the organisation when organisation-visible, and by whoever they are shared with.
|
|
5
|
+
*
|
|
6
|
+
* It checks each guarantee by trying to break it: reads, updates and presence through the invocation path (audited,
|
|
7
|
+
* on every surface, the transport included) and the record's policy (read versus collaborate, organisation
|
|
8
|
+
* isolation, credential scope); revocation mid-session (a shared grant revoked, a signed-out session, a member who
|
|
9
|
+
* left) closing an open connection before it receives what follows and refusing its later updates; append-only
|
|
10
|
+
* storage; compaction that keeps an update committed while it runs; size, update and rate limits that refuse; clients
|
|
11
|
+
* converging after offline edits and reconnects; presence relayed and never stored; an agent's text projection and
|
|
12
|
+
* its edits, attributed, audited and seen live; privacy export and erasure; checkpoints and restore; a deleted
|
|
13
|
+
* record's document going with it.
|
|
14
|
+
*
|
|
15
|
+
* Usage, in a Vitest file: `collabDocumentConformance(() => startMyKernel())`.
|
|
16
|
+
*/
|
|
17
|
+
import { connectCollab, type CollabConnection } from "@eloxiv/client/collab"
|
|
18
|
+
import { COLLAB_SOCKET_PATH } from "@eloxiv/contracts"
|
|
19
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest"
|
|
20
|
+
import * as Y from "yjs"
|
|
21
|
+
import type { CollabSubject, StartCollabSubject } from "./CollabSubject.ts"
|
|
22
|
+
import type { InboxOutcome, InboxSurface, InboxUser } from "./InboxSubject.ts"
|
|
23
|
+
import { PAD_LIMITS } from "./pad/contract.ts"
|
|
24
|
+
|
|
25
|
+
const ORG = "acme"
|
|
26
|
+
const OTHER = "globex"
|
|
27
|
+
const PAGE = "Pad::Page"
|
|
28
|
+
|
|
29
|
+
const toBase64 = (bytes: Uint8Array) => Buffer.from(bytes).toString("base64")
|
|
30
|
+
|
|
31
|
+
/** An update that inserts `text` at the start of the `body` text, from a fresh client. */
|
|
32
|
+
const insertion = (text: string, name = "body") => {
|
|
33
|
+
const doc = new Y.Doc()
|
|
34
|
+
doc.getText(name).insert(0, text)
|
|
35
|
+
return Y.encodeStateAsUpdate(doc)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Why a promise was refused: its error and every cause under it, as text ("" if it was not refused). */
|
|
39
|
+
const failureOf = (promise: Promise<unknown>): Promise<string> =>
|
|
40
|
+
promise.then(
|
|
41
|
+
() => "",
|
|
42
|
+
(error: unknown) => {
|
|
43
|
+
const parts: Array<string> = []
|
|
44
|
+
for (let e: any = error, depth = 0; e != null && depth < 6; e = e.cause ?? e.reason, depth++) {
|
|
45
|
+
parts.push(String(e?.message ?? e))
|
|
46
|
+
}
|
|
47
|
+
return parts.join(" <- ")
|
|
48
|
+
},
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
const until = async <A>(what: string, read: () => A | Promise<A>, done: (a: A) => boolean, ms = 15_000): Promise<A> => {
|
|
52
|
+
const started = Date.now()
|
|
53
|
+
for (;;) {
|
|
54
|
+
const value = await read()
|
|
55
|
+
if (done(value)) return value
|
|
56
|
+
if (Date.now() - started > ms)
|
|
57
|
+
throw new Error(`Timed out waiting for ${what}: ${JSON.stringify(value)?.slice(0, 500)}`)
|
|
58
|
+
await new Promise((resolve) => setTimeout(resolve, 50))
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const collabDocumentConformance = (start: StartCollabSubject) =>
|
|
63
|
+
describe("CollabDocument contract", () => {
|
|
64
|
+
let s: CollabSubject
|
|
65
|
+
let ann: InboxUser // owns pages
|
|
66
|
+
let bob: InboxUser // a member of the same organisation
|
|
67
|
+
let cat: InboxUser // another organisation
|
|
68
|
+
const open: Array<CollabConnection> = []
|
|
69
|
+
|
|
70
|
+
const call = (
|
|
71
|
+
who: InboxUser | string,
|
|
72
|
+
action: string,
|
|
73
|
+
input: unknown,
|
|
74
|
+
surface: InboxSurface = "internal",
|
|
75
|
+
org?: string,
|
|
76
|
+
) => s.invoke({ action, input, token: typeof who === "string" ? who : who.token, surface, org })
|
|
77
|
+
const ok = (outcome: InboxOutcome) => {
|
|
78
|
+
if (!outcome.ok) throw new Error(`call failed: ${JSON.stringify(outcome)}`)
|
|
79
|
+
const result = outcome.result as { output?: Record<string, unknown> } & Record<string, unknown>
|
|
80
|
+
return (result.output ?? result) as Record<string, any>
|
|
81
|
+
}
|
|
82
|
+
const tagOf = (outcome: InboxOutcome) => (outcome.ok ? "ok" : outcome.error._tag)
|
|
83
|
+
let pages = 0
|
|
84
|
+
const page = async (who: InboxUser, visibility: "private" | "org" = "private") => {
|
|
85
|
+
const id = `page-${++pages}-${crypto.randomUUID().slice(0, 8)}`
|
|
86
|
+
ok(await call(who, "pad.create", { id, title: `Page ${id}`, visibility }))
|
|
87
|
+
return id
|
|
88
|
+
}
|
|
89
|
+
const share = async (who: InboxUser, id: string, grantee: InboxUser, permission: "read" | "edit") =>
|
|
90
|
+
String(
|
|
91
|
+
ok(await call(who, "sharing.grant", { entity: PAGE, id, grantee: { user: grantee.id }, permission }))[
|
|
92
|
+
"grantId"
|
|
93
|
+
],
|
|
94
|
+
)
|
|
95
|
+
const update = (who: InboxUser | string, id: string, bytes: Uint8Array, surface: InboxSurface = "internal") =>
|
|
96
|
+
call(who, "collab.update", { entity: PAGE, id, update: toBase64(bytes) }, surface)
|
|
97
|
+
const textOf = async (who: InboxUser, id: string) =>
|
|
98
|
+
String(ok(await call(who, "collab.readText", { entity: PAGE, id }))["text"])
|
|
99
|
+
const client = (who: InboxUser | string, id: string, options: { readonly org?: string } = {}) => {
|
|
100
|
+
const connection = connectCollab({
|
|
101
|
+
baseUrl: s.url,
|
|
102
|
+
entity: PAGE,
|
|
103
|
+
id,
|
|
104
|
+
token: typeof who === "string" ? who : who.token,
|
|
105
|
+
orgId: options.org ?? ORG,
|
|
106
|
+
batchMs: 5,
|
|
107
|
+
reconnectMs: 100,
|
|
108
|
+
})
|
|
109
|
+
open.push(connection)
|
|
110
|
+
return connection
|
|
111
|
+
}
|
|
112
|
+
const body = (connection: CollabConnection) => connection.doc.getText("body").toJSON()
|
|
113
|
+
const closedOf = (connection: CollabConnection) =>
|
|
114
|
+
new Promise<{ _tag: string }>((resolve) => {
|
|
115
|
+
if (connection.status === "closed") resolve(connection.closedWith ?? { _tag: "closed" })
|
|
116
|
+
const stop = connection.subscribe((event) => {
|
|
117
|
+
if (event.type === "closed") {
|
|
118
|
+
stop()
|
|
119
|
+
resolve(event.error)
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
/** Every table of the database (but the kernel's audit log, which never holds a payload) whose rows hold `text`. */
|
|
124
|
+
const tablesHolding = async (text: string) => {
|
|
125
|
+
const tables = await s.sql<{ name: string }>(
|
|
126
|
+
`SELECT quote_ident(n.nspname) || '.' || quote_ident(c.relname) AS name
|
|
127
|
+
FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
128
|
+
WHERE c.relkind IN ('r', 'p') AND n.nspname NOT IN ('pg_catalog', 'information_schema')
|
|
129
|
+
AND n.nspname NOT LIKE 'pg_toast%' AND n.nspname NOT LIKE 'pg_temp%' ORDER BY 1`,
|
|
130
|
+
)
|
|
131
|
+
const found: Array<string> = []
|
|
132
|
+
for (const { name } of tables) {
|
|
133
|
+
const [row] = await s.sql<{ n: number }>(
|
|
134
|
+
// As text, and inside binary columns (a Yjs update holds its text as UTF-8): bytea renders as hex.
|
|
135
|
+
`SELECT count(*)::int AS n FROM ${name} t
|
|
136
|
+
WHERE strpos(t::text, $1) > 0 OR strpos(t::text, encode(convert_to($1, 'UTF8'), 'hex')) > 0`,
|
|
137
|
+
[text],
|
|
138
|
+
)
|
|
139
|
+
if ((row?.n ?? 0) > 0) found.push(name)
|
|
140
|
+
}
|
|
141
|
+
return found
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
beforeAll(async () => {
|
|
145
|
+
s = await start()
|
|
146
|
+
ann = await s.user("ann", ORG)
|
|
147
|
+
bob = await s.user("bob", ORG)
|
|
148
|
+
cat = await s.user("cat", OTHER)
|
|
149
|
+
}, 180_000)
|
|
150
|
+
afterAll(async () => {
|
|
151
|
+
for (const connection of open) connection.close()
|
|
152
|
+
await s?.dispose()
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
// ---- Ownership ------------------------------------------------------------------------------------------
|
|
156
|
+
|
|
157
|
+
it("reads and changes a document through its actions on every surface, each call audited", async () => {
|
|
158
|
+
const id = await page(ann)
|
|
159
|
+
const surfaces: ReadonlyArray<InboxSurface> = ["internal", "rpc", "http"]
|
|
160
|
+
for (const surface of surfaces)
|
|
161
|
+
expect(tagOf(await update(ann, id, insertion(`[${surface}]`), surface))).toBe("ok")
|
|
162
|
+
// Agents (the agent's tools, MCP clients) act for the person: their change waits for consent, audited as held.
|
|
163
|
+
for (const surface of ["agent", "mcp"] as const) {
|
|
164
|
+
expect(tagOf(await update(ann, id, insertion(`[${surface}]`), surface))).toBe("ConsentRequired")
|
|
165
|
+
}
|
|
166
|
+
const text = await textOf(ann, id)
|
|
167
|
+
for (const surface of surfaces) expect(text).toContain(`[${surface}]`)
|
|
168
|
+
expect(text).not.toContain("[agent]")
|
|
169
|
+
expect(text).not.toContain("[mcp]")
|
|
170
|
+
const opened = ok(await call(ann, "collab.open", { entity: PAGE, id }, "http"))
|
|
171
|
+
expect(opened).toMatchObject({ entity: PAGE, id, seq: surfaces.length, canWrite: true })
|
|
172
|
+
const audited = (await s.audit({ action: "collab.update" })).filter((a) => a.actorUserId === ann.id)
|
|
173
|
+
expect(new Set(audited.filter((a) => a.outcome === "succeeded").map((a) => a.surface))).toEqual(
|
|
174
|
+
new Set(["internal", "rpc", "http"]),
|
|
175
|
+
)
|
|
176
|
+
for (const surface of ["agent", "mcp"]) {
|
|
177
|
+
expect(audited.some((a) => a.outcome === "approval-required" && a.surface === surface)).toBe(true)
|
|
178
|
+
}
|
|
179
|
+
expect(
|
|
180
|
+
tagOf(await call(ann, "collab.readText", { entity: PAGE, id }, "agent")),
|
|
181
|
+
"an agent reads without asking",
|
|
182
|
+
).toBe("ok")
|
|
183
|
+
// The transport's frames are invocations too: an update over the socket is audited as the person's call.
|
|
184
|
+
const before = (await s.audit({ action: "collab.update" })).length
|
|
185
|
+
const connection = client(ann, id)
|
|
186
|
+
await connection.whenSynced()
|
|
187
|
+
connection.doc.getText("body").insert(0, "[socket]")
|
|
188
|
+
await connection.flush()
|
|
189
|
+
expect((await s.audit({ action: "collab.update" })).length).toBe(before + 1)
|
|
190
|
+
expect(
|
|
191
|
+
(await s.audit({ action: "collab.open" })).some((a) => a.actorUserId === ann.id && a.surface === "http"),
|
|
192
|
+
).toBe(true)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it("lets the record's read policy read, and only its collaborate policy change, the document", async () => {
|
|
196
|
+
const id = await page(ann)
|
|
197
|
+
ok(await update(ann, id, insertion("owner's words")))
|
|
198
|
+
// A private page: another member may neither read nor change it, and is told no more than for a missing one.
|
|
199
|
+
const refusedRead = await call(bob, "collab.open", { entity: PAGE, id })
|
|
200
|
+
const missing = await call(bob, "collab.open", { entity: PAGE, id: "no-such-page" })
|
|
201
|
+
expect(tagOf(refusedRead)).toBe("Forbidden")
|
|
202
|
+
expect(tagOf(missing)).toBe("Forbidden")
|
|
203
|
+
expect(refusedRead.ok ? undefined : refusedRead.error["message"]).toBe(
|
|
204
|
+
missing.ok ? null : missing.error["message"],
|
|
205
|
+
)
|
|
206
|
+
expect(tagOf(await update(bob, id, insertion("intruder")))).toBe("Forbidden")
|
|
207
|
+
expect(tagOf(await call(bob, "collab.readText", { entity: PAGE, id }))).toBe("Forbidden")
|
|
208
|
+
expect(tagOf(await call(bob, "collab.pull", { entity: PAGE, id, after: 0 }))).toBe("Forbidden")
|
|
209
|
+
// Organisation-visible: readable, still not changeable.
|
|
210
|
+
ok(await call(ann, "pad.setVisibility", { id, visibility: "org" }))
|
|
211
|
+
expect(ok(await call(bob, "collab.open", { entity: PAGE, id }))["canWrite"]).toBe(false)
|
|
212
|
+
expect(await textOf(bob, id)).toBe("owner's words")
|
|
213
|
+
expect(tagOf(await update(bob, id, insertion("intruder")))).toBe("Forbidden")
|
|
214
|
+
expect(tagOf(await call(bob, "collab.editText", { entity: PAGE, id, edits: [{ kind: "set", text: "x" }] }))).toBe(
|
|
215
|
+
"Forbidden",
|
|
216
|
+
)
|
|
217
|
+
// Shared for editing: now Bob may change it.
|
|
218
|
+
await share(ann, id, bob, "edit")
|
|
219
|
+
expect(ok(await call(bob, "collab.open", { entity: PAGE, id }))["canWrite"]).toBe(true)
|
|
220
|
+
expect(tagOf(await update(bob, id, insertion("bob's words ")))).toBe("ok")
|
|
221
|
+
expect(await textOf(ann, id)).toContain("bob's words")
|
|
222
|
+
// An entity without a collaborative document has none.
|
|
223
|
+
expect(tagOf(await call(ann, "collab.open", { entity: "Pad::Nothing", id }))).toBe("Forbidden")
|
|
224
|
+
// A connection the policy refuses is closed at once.
|
|
225
|
+
const stranger = await s.user("stranger", ORG)
|
|
226
|
+
const refused = client(stranger, await page(ann))
|
|
227
|
+
expect((await closedOf(refused))._tag).toBe("Forbidden")
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
it("keeps documents to their record's organisation", async () => {
|
|
231
|
+
const id = await page(ann, "org")
|
|
232
|
+
ok(await update(ann, id, insertion("acme only")))
|
|
233
|
+
// Cat is in another organisation; acting there or claiming acme, she reads nothing and changes nothing.
|
|
234
|
+
for (const org of [OTHER, ORG]) {
|
|
235
|
+
expect(tagOf(await call(cat, "collab.open", { entity: PAGE, id }, "internal", org))).not.toBe("ok")
|
|
236
|
+
expect(
|
|
237
|
+
tagOf(
|
|
238
|
+
await call(cat, "collab.update", { entity: PAGE, id, update: toBase64(insertion("x")) }, "internal", org),
|
|
239
|
+
),
|
|
240
|
+
).not.toBe("ok")
|
|
241
|
+
}
|
|
242
|
+
// A member of both, acting in the other organisation, does not reach acme's page either.
|
|
243
|
+
const both = await s.user("both", ORG)
|
|
244
|
+
await s.user("both", OTHER)
|
|
245
|
+
expect(tagOf(await call(both, "collab.open", { entity: PAGE, id }, "internal", OTHER))).toBe("Forbidden")
|
|
246
|
+
expect(tagOf(await call(both, "collab.open", { entity: PAGE, id }, "internal", ORG))).toBe("ok")
|
|
247
|
+
const connection = client(both, id, { org: OTHER })
|
|
248
|
+
expect((await closedOf(connection))._tag).toBe("Forbidden")
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
it("holds a credential to its scope: a token for reading cannot change a document, over the socket either", async () => {
|
|
252
|
+
const id = await page(ann)
|
|
253
|
+
ok(await update(ann, id, insertion("scoped")))
|
|
254
|
+
const response = await fetch(`${s.url}/kernel/machine-identity/createToken`, {
|
|
255
|
+
method: "POST",
|
|
256
|
+
headers: { authorization: `Bearer ${ann.token}`, "content-type": "application/json", "x-eloxiv-org": ORG },
|
|
257
|
+
body: JSON.stringify({ name: "reader", actions: ["collab.open", "collab.pull", "collab.readText"] }),
|
|
258
|
+
})
|
|
259
|
+
expect(response.status).toBe(200)
|
|
260
|
+
const token = ((await response.json()) as { token: string }).token
|
|
261
|
+
expect(tagOf(await call(token, "collab.readText", { entity: PAGE, id }, "http"))).toBe("ok")
|
|
262
|
+
expect(tagOf(await update(token, id, insertion("scoped write"), "http"))).toBe("Forbidden")
|
|
263
|
+
const connection = client(token, id)
|
|
264
|
+
await connection.whenSynced()
|
|
265
|
+
expect(body(connection)).toBe("scoped")
|
|
266
|
+
connection.doc.getText("body").insert(0, "nope ")
|
|
267
|
+
expect((await closedOf(connection))._tag).toBe("Forbidden")
|
|
268
|
+
expect(await textOf(ann, id)).toBe("scoped")
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
it("stops a connection whose grant is revoked before it receives what follows, and refuses its later updates", async () => {
|
|
272
|
+
const id = await page(ann)
|
|
273
|
+
const grant = await share(ann, id, bob, "edit")
|
|
274
|
+
const owner = client(ann, id)
|
|
275
|
+
const editor = client(bob, id)
|
|
276
|
+
await Promise.all([owner.whenSynced(), editor.whenSynced()])
|
|
277
|
+
owner.doc.getText("body").insert(0, "before ")
|
|
278
|
+
await owner.flush()
|
|
279
|
+
await until(
|
|
280
|
+
"the editor to receive the first edit",
|
|
281
|
+
() => body(editor),
|
|
282
|
+
(t) => t.includes("before"),
|
|
283
|
+
)
|
|
284
|
+
const closed = closedOf(editor)
|
|
285
|
+
ok(await call(ann, "sharing.revoke", { grantId: grant }))
|
|
286
|
+
owner.doc.getText("body").insert(0, "SECRET-AFTER-REVOCATION ")
|
|
287
|
+
await owner.flush()
|
|
288
|
+
expect((await closed)._tag).toBe("Forbidden")
|
|
289
|
+
// It never received the edit made after the revocation, and its own later edits reach nobody.
|
|
290
|
+
expect(body(editor)).not.toContain("SECRET-AFTER-REVOCATION")
|
|
291
|
+
editor.doc.getText("body").insert(0, "late ")
|
|
292
|
+
expect(tagOf(await update(bob, id, insertion("late")))).toBe("Forbidden")
|
|
293
|
+
expect(await textOf(ann, id)).not.toContain("late")
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
it("closes a connection whose session is signed out, or whose person left the organisation", async () => {
|
|
297
|
+
const id = await page(ann, "org")
|
|
298
|
+
const dan = await s.user("dan", ORG)
|
|
299
|
+
const eve = await s.user("eve", ORG)
|
|
300
|
+
const signedOut = client(dan, id)
|
|
301
|
+
const leaver = client(eve, id)
|
|
302
|
+
await Promise.all([signedOut.whenSynced(), leaver.whenSynced()])
|
|
303
|
+
const danClosed = closedOf(signedOut)
|
|
304
|
+
const eveClosed = closedOf(leaver)
|
|
305
|
+
const response = await fetch(`${s.url}/auth/sign-out`, {
|
|
306
|
+
method: "POST",
|
|
307
|
+
headers: { authorization: `Bearer ${dan.token}`, "content-type": "application/json", origin: s.url },
|
|
308
|
+
body: "{}",
|
|
309
|
+
})
|
|
310
|
+
expect(response.ok).toBe(true)
|
|
311
|
+
await s.leave(eve.id, ORG)
|
|
312
|
+
ok(await update(ann, id, insertion("AFTER-SIGN-OUT ")))
|
|
313
|
+
expect((await danClosed)._tag).toBe("Unauthenticated")
|
|
314
|
+
expect(["Forbidden", "Unauthenticated"]).toContain((await eveClosed)._tag)
|
|
315
|
+
expect(body(signedOut)).not.toContain("AFTER-SIGN-OUT")
|
|
316
|
+
expect(body(leaver)).not.toContain("AFTER-SIGN-OUT")
|
|
317
|
+
// An idle connection is re-checked too: no edit is needed to close it.
|
|
318
|
+
const fay = await s.user("fay", ORG)
|
|
319
|
+
const idle = client(fay, id)
|
|
320
|
+
await idle.whenSynced()
|
|
321
|
+
const fayClosed = closedOf(idle)
|
|
322
|
+
await s.leave(fay.id, ORG)
|
|
323
|
+
expect(["Forbidden", "Unauthenticated"]).toContain((await fayClosed)._tag)
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
// ---- Storage --------------------------------------------------------------------------------------------
|
|
327
|
+
|
|
328
|
+
it("stores updates durably and append-only", async () => {
|
|
329
|
+
const id = await page(ann)
|
|
330
|
+
for (const word of ["one ", "two ", "three "]) ok(await update(ann, id, insertion(word)))
|
|
331
|
+
const rows = await s.sql<{ seq: string; actor: string; origin: string }>(
|
|
332
|
+
`SELECT u.seq::text AS seq, u.actor_user_id AS actor, u.origin FROM eloxiv.collab_update u
|
|
333
|
+
JOIN eloxiv.collab_document d ON d.id = u.document_id WHERE d.entity = $1 AND d.record_id = $2 ORDER BY u.seq`,
|
|
334
|
+
[PAGE, id],
|
|
335
|
+
)
|
|
336
|
+
expect(rows.map((r) => r.seq)).toEqual(["1", "2", "3"])
|
|
337
|
+
expect(rows.every((r) => r.actor === ann.id && r.origin === "person")).toBe(true)
|
|
338
|
+
const where = `document_id = (SELECT id FROM eloxiv.collab_document WHERE entity = '${PAGE}' AND record_id = '${id}')`
|
|
339
|
+
// Not even the database's superuser changes an update, or deletes one the snapshot does not hold.
|
|
340
|
+
expect(
|
|
341
|
+
await failureOf(s.sql(`UPDATE eloxiv.collab_update SET update = '\\x0000'::bytea WHERE ${where}`)),
|
|
342
|
+
).toMatch(/append-only/)
|
|
343
|
+
expect(await failureOf(s.sql(`UPDATE eloxiv.collab_update SET seq = seq + 10 WHERE ${where}`))).toMatch(
|
|
344
|
+
/append-only/,
|
|
345
|
+
)
|
|
346
|
+
expect(await failureOf(s.sql(`DELETE FROM eloxiv.collab_update WHERE ${where}`))).toMatch(
|
|
347
|
+
/snapshot does not hold/,
|
|
348
|
+
)
|
|
349
|
+
// Module roles have no access to the kernel's tables at all.
|
|
350
|
+
const [privileges] = await s.sql<{ n: number }>(
|
|
351
|
+
`SELECT count(*)::int AS n FROM information_schema.role_table_grants
|
|
352
|
+
WHERE table_schema = 'eloxiv' AND table_name LIKE 'collab_%' AND grantee LIKE 'eloxiv_mod_%'`,
|
|
353
|
+
)
|
|
354
|
+
expect(privileges?.n).toBe(0)
|
|
355
|
+
// A fresh read rebuilds the same document from what is stored.
|
|
356
|
+
const text = await textOf(ann, id)
|
|
357
|
+
for (const word of ["one ", "two ", "three "]) expect(text).toContain(word)
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
it("compacts into a snapshot without losing an update committed while it runs", async () => {
|
|
361
|
+
const id = await page(ann)
|
|
362
|
+
for (let i = 0; i < 5; i++) ok(await update(ann, id, insertion(`a${i} `)))
|
|
363
|
+
// An update commits after compaction read the updates and before it writes the snapshot.
|
|
364
|
+
const compactedTo = await s.compact(PAGE, id, async () => {
|
|
365
|
+
ok(await update(ann, id, insertion("CONCURRENT ")))
|
|
366
|
+
})
|
|
367
|
+
expect(compactedTo).toBe(5)
|
|
368
|
+
const [row] = await s.sql<{ snapshotSeq: string; headSeq: string; tail: number }>(
|
|
369
|
+
`SELECT d.snapshot_seq::text AS "snapshotSeq", d.head_seq::text AS "headSeq",
|
|
370
|
+
(SELECT count(*)::int FROM eloxiv.collab_update u WHERE u.document_id = d.id) AS tail
|
|
371
|
+
FROM eloxiv.collab_document d WHERE d.entity = $1 AND d.record_id = $2`,
|
|
372
|
+
[PAGE, id],
|
|
373
|
+
)
|
|
374
|
+
expect(row).toEqual({ snapshotSeq: "5", headSeq: "6", tail: 1 })
|
|
375
|
+
const text = await textOf(ann, id)
|
|
376
|
+
expect(text).toContain("CONCURRENT")
|
|
377
|
+
for (let i = 0; i < 5; i++) expect(text).toContain(`a${i}`)
|
|
378
|
+
// Under load: three writers and repeated compaction; every word survives, and a client that held an older
|
|
379
|
+
// sequence number gets the whole state.
|
|
380
|
+
const writers = await Promise.all(
|
|
381
|
+
["w1", "w2", "w3"].map(async (name) => {
|
|
382
|
+
const connection = client(ann, id)
|
|
383
|
+
await connection.whenSynced()
|
|
384
|
+
return { name, connection }
|
|
385
|
+
}),
|
|
386
|
+
)
|
|
387
|
+
const late = client(ann, id)
|
|
388
|
+
await late.whenSynced()
|
|
389
|
+
late.disconnect()
|
|
390
|
+
const compaction = { running: true }
|
|
391
|
+
const compactions = (async () => {
|
|
392
|
+
while (compaction.running) {
|
|
393
|
+
await s.compact(PAGE, id)
|
|
394
|
+
await new Promise((resolve) => setTimeout(resolve, 5))
|
|
395
|
+
}
|
|
396
|
+
})()
|
|
397
|
+
for (let i = 0; i < 8; i++) {
|
|
398
|
+
for (const { name, connection } of writers) connection.doc.getText("body").insert(0, `${name}-${i} `)
|
|
399
|
+
await new Promise((resolve) => setTimeout(resolve, 10))
|
|
400
|
+
}
|
|
401
|
+
await Promise.all(writers.map((w) => w.connection.flush()))
|
|
402
|
+
compaction.running = false
|
|
403
|
+
await compactions
|
|
404
|
+
const final = await textOf(ann, id)
|
|
405
|
+
for (const { name } of writers) for (let i = 0; i < 8; i++) expect(final).toContain(`${name}-${i}`)
|
|
406
|
+
expect(final).toContain("CONCURRENT")
|
|
407
|
+
late.connect()
|
|
408
|
+
await until(
|
|
409
|
+
"the returning client to converge",
|
|
410
|
+
() => body(late),
|
|
411
|
+
(t) => t === final,
|
|
412
|
+
)
|
|
413
|
+
for (const { connection } of writers)
|
|
414
|
+
await until(
|
|
415
|
+
"every writer to converge",
|
|
416
|
+
() => body(connection),
|
|
417
|
+
(t) => t === final,
|
|
418
|
+
)
|
|
419
|
+
expect(ok(await call(ann, "collab.history", { entity: PAGE, id }))["versions"].length).toBeGreaterThan(0)
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
it("reads a document whole while a compaction commits under it: open, pull, the text and export", async () => {
|
|
423
|
+
const hal = await s.user("hal", ORG)
|
|
424
|
+
const id = await page(hal)
|
|
425
|
+
const words = ["alpha", "bravo", "charlie", "delta", "echo"]
|
|
426
|
+
for (const word of words) ok(await update(hal, id, insertion(`${word} `)))
|
|
427
|
+
const merged = String(ok(await call(hal, "collab.open", { entity: PAGE, id }))["state"])
|
|
428
|
+
/** Callers waiting to read the document's updates (their statement not yet begun). */
|
|
429
|
+
const waiting = async () =>
|
|
430
|
+
(
|
|
431
|
+
await s.sql<{ n: number }>(
|
|
432
|
+
`SELECT count(*)::int AS n FROM pg_catalog.pg_locks
|
|
433
|
+
WHERE NOT granted AND relation = 'eloxiv.collab_update'::regclass
|
|
434
|
+
AND database = (SELECT oid FROM pg_database WHERE datname = current_database())`,
|
|
435
|
+
)
|
|
436
|
+
)[0]?.n ?? 0
|
|
437
|
+
/**
|
|
438
|
+
* A compaction committing at a chosen moment: the snapshot written and the updates it merged deleted, held
|
|
439
|
+
* uncommitted with the updates' table locked, so a reader that already read the document's row waits before
|
|
440
|
+
* reading the updates and reads them only after the commit.
|
|
441
|
+
*/
|
|
442
|
+
const compactingUnder = async (readers: number, read: () => Promise<unknown>) => {
|
|
443
|
+
const compaction = await s.holdTransaction([
|
|
444
|
+
[
|
|
445
|
+
`UPDATE eloxiv.collab_document SET snapshot = decode($1, 'base64'), snapshot_seq = head_seq
|
|
446
|
+
WHERE entity = $2 AND record_id = $3`,
|
|
447
|
+
[merged, PAGE, id],
|
|
448
|
+
],
|
|
449
|
+
[
|
|
450
|
+
`DELETE FROM eloxiv.collab_update WHERE document_id =
|
|
451
|
+
(SELECT id FROM eloxiv.collab_document WHERE entity = $1 AND record_id = $2)`,
|
|
452
|
+
[PAGE, id],
|
|
453
|
+
],
|
|
454
|
+
[`LOCK TABLE eloxiv.collab_update IN ACCESS EXCLUSIVE MODE`],
|
|
455
|
+
])
|
|
456
|
+
const reading = read()
|
|
457
|
+
await until("the readers to reach the document", waiting, (n) => n >= readers, 20_000).catch(() => undefined)
|
|
458
|
+
await compaction.commit()
|
|
459
|
+
return reading
|
|
460
|
+
}
|
|
461
|
+
// A reader with no cached state (another kernel process), each kind at once.
|
|
462
|
+
const cold = await s.coldReader()
|
|
463
|
+
try {
|
|
464
|
+
const [text, opened, pulled] = (await compactingUnder(3, () =>
|
|
465
|
+
Promise.all([
|
|
466
|
+
cold.invoke({ action: "collab.readText", input: { entity: PAGE, id }, token: hal.token }),
|
|
467
|
+
cold.invoke({ action: "collab.open", input: { entity: PAGE, id }, token: hal.token }),
|
|
468
|
+
cold.invoke({ action: "collab.pull", input: { entity: PAGE, id, after: 0 }, token: hal.token }),
|
|
469
|
+
]),
|
|
470
|
+
)) as ReadonlyArray<InboxOutcome>
|
|
471
|
+
const textOfState = (state: string) => {
|
|
472
|
+
const doc = new Y.Doc()
|
|
473
|
+
Y.applyUpdate(doc, Buffer.from(state, "base64"))
|
|
474
|
+
return doc.getText("body").toJSON()
|
|
475
|
+
}
|
|
476
|
+
const pull = ok(pulled!)
|
|
477
|
+
const pulledDoc = new Y.Doc()
|
|
478
|
+
if (pull["reset"] !== null) Y.applyUpdate(pulledDoc, Buffer.from(String(pull["reset"]), "base64"))
|
|
479
|
+
for (const u of pull["updates"] as Array<{ update: string }>)
|
|
480
|
+
Y.applyUpdate(pulledDoc, Buffer.from(u.update, "base64"))
|
|
481
|
+
for (const read of [
|
|
482
|
+
String(ok(text!)["text"]),
|
|
483
|
+
textOfState(String(ok(opened!)["state"])),
|
|
484
|
+
pulledDoc.getText("body").toJSON(),
|
|
485
|
+
]) {
|
|
486
|
+
for (const word of words) expect(read).toContain(word)
|
|
487
|
+
}
|
|
488
|
+
} finally {
|
|
489
|
+
await cold.dispose()
|
|
490
|
+
}
|
|
491
|
+
// A data-subject export, its document read while a compaction commits under it.
|
|
492
|
+
const more = "foxtrot"
|
|
493
|
+
ok(await update(hal, id, insertion(`${more} `)))
|
|
494
|
+
words.push(more)
|
|
495
|
+
const latest = String(ok(await call(hal, "collab.open", { entity: PAGE, id }))["state"])
|
|
496
|
+
const exportCompaction = await s.holdTransaction([
|
|
497
|
+
[
|
|
498
|
+
`UPDATE eloxiv.collab_document SET snapshot = decode($1, 'base64'), snapshot_seq = head_seq
|
|
499
|
+
WHERE entity = $2 AND record_id = $3`,
|
|
500
|
+
[latest, PAGE, id],
|
|
501
|
+
],
|
|
502
|
+
[
|
|
503
|
+
`DELETE FROM eloxiv.collab_update WHERE document_id =
|
|
504
|
+
(SELECT id FROM eloxiv.collab_document WHERE entity = $1 AND record_id = $2)`,
|
|
505
|
+
[PAGE, id],
|
|
506
|
+
],
|
|
507
|
+
[`LOCK TABLE eloxiv.collab_update IN ACCESS EXCLUSIVE MODE`],
|
|
508
|
+
])
|
|
509
|
+
const requested = String(ok(await call(hal, "privacy.requestExport", {}))["id"])
|
|
510
|
+
await until("the export to reach the document", waiting, (n) => n >= 1, 30_000).catch(() => undefined)
|
|
511
|
+
await exportCompaction.commit()
|
|
512
|
+
const settled = await until(
|
|
513
|
+
"the export to settle",
|
|
514
|
+
async () =>
|
|
515
|
+
(
|
|
516
|
+
(ok(await call(hal, "privacy.requests", {}))["requests"] as ReadonlyArray<{
|
|
517
|
+
id: string
|
|
518
|
+
status: string
|
|
519
|
+
}>) ?? []
|
|
520
|
+
).find((r) => r.id === requested),
|
|
521
|
+
(r) => r !== undefined && ["succeeded", "failed", "cancelled"].includes(r.status),
|
|
522
|
+
90_000,
|
|
523
|
+
)
|
|
524
|
+
expect(settled?.status).toBe("succeeded")
|
|
525
|
+
const data = ok(await call(hal, "privacy.download", { id: requested })) as {
|
|
526
|
+
sources: Array<{ source: string; records: Array<{ recordId: string; roots: Array<{ text: string }> }> }>
|
|
527
|
+
}
|
|
528
|
+
const exported = data.sources
|
|
529
|
+
.find((source) => source.source === "eloxiv.collab")
|
|
530
|
+
?.records.find((r) => r.recordId === id)
|
|
531
|
+
for (const word of words) expect(exported?.roots[0]?.text).toContain(word)
|
|
532
|
+
}, 180_000)
|
|
533
|
+
|
|
534
|
+
it("never leaves a document behind its record: a deletion and a first update, interleaved", async () => {
|
|
535
|
+
const id = await page(ann)
|
|
536
|
+
// The record's deletion is in flight (uncommitted) when the first update arrives.
|
|
537
|
+
const deletion = await s.holdTransaction([[`DELETE FROM pad.page WHERE id = $1`, [id]]])
|
|
538
|
+
const first = update(ann, id, insertion("too late"))
|
|
539
|
+
await new Promise((resolve) => setTimeout(resolve, 300))
|
|
540
|
+
await deletion.commit()
|
|
541
|
+
expect(tagOf(await first)).toBe("Forbidden")
|
|
542
|
+
expect(
|
|
543
|
+
await s.sql(`SELECT 1 FROM eloxiv.collab_document WHERE entity = $1 AND record_id = $2`, [PAGE, id]),
|
|
544
|
+
).toEqual([])
|
|
545
|
+
// And racing, many times over: whichever goes first, no document outlives its record.
|
|
546
|
+
const raced = await Promise.all(Array.from({ length: 20 }, () => page(ann)))
|
|
547
|
+
await Promise.all(
|
|
548
|
+
raced.flatMap((other) => [
|
|
549
|
+
update(ann, other, insertion("first words")),
|
|
550
|
+
call(ann, "pad.remove", { id: other }),
|
|
551
|
+
]),
|
|
552
|
+
)
|
|
553
|
+
const [orphans] = await s.sql<{ n: number }>(
|
|
554
|
+
`SELECT count(*)::int AS n FROM eloxiv.collab_document WHERE entity = $1 AND record_id = ANY($2)`,
|
|
555
|
+
[PAGE, raced],
|
|
556
|
+
)
|
|
557
|
+
expect(orphans?.n).toBe(0)
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
it("refuses an update past the update limit, the document limit or the rate, and malformed bytes, storing nothing", async () => {
|
|
561
|
+
const id = await page(ann)
|
|
562
|
+
const stored = async () =>
|
|
563
|
+
(
|
|
564
|
+
await s.sql<{ n: number }>(
|
|
565
|
+
`SELECT count(*)::int AS n FROM eloxiv.collab_update u JOIN eloxiv.collab_document d ON d.id = u.document_id
|
|
566
|
+
WHERE d.entity = $1 AND d.record_id = $2`,
|
|
567
|
+
[PAGE, id],
|
|
568
|
+
)
|
|
569
|
+
)[0]?.n ?? 0
|
|
570
|
+
const big = insertion("x".repeat(PAD_LIMITS.maxUpdateBytes + 10))
|
|
571
|
+
expect(tagOf(await update(ann, id, big))).toBe("InvalidInput")
|
|
572
|
+
expect(
|
|
573
|
+
tagOf(
|
|
574
|
+
await call(ann, "collab.update", { entity: PAGE, id, update: toBase64(new Uint8Array([1, 2, 3, 250, 251])) }),
|
|
575
|
+
),
|
|
576
|
+
).toBe("InvalidInput")
|
|
577
|
+
expect(tagOf(await call(ann, "collab.update", { entity: PAGE, id, update: "not base64!" }))).toBe("InvalidInput")
|
|
578
|
+
expect(await stored()).toBe(0)
|
|
579
|
+
// Grow the document to just under its limit in updates under the update limit, then one more is refused.
|
|
580
|
+
const chunk = "y".repeat(PAD_LIMITS.maxUpdateBytes - 200)
|
|
581
|
+
let refused: InboxOutcome | undefined
|
|
582
|
+
for (let i = 0; i < Math.ceil(PAD_LIMITS.maxBytes / chunk.length) + 2; i++) {
|
|
583
|
+
const outcome = await update(ann, id, insertion(chunk))
|
|
584
|
+
if (!outcome.ok) {
|
|
585
|
+
refused = outcome
|
|
586
|
+
break
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
expect(refused && tagOf(refused)).toBe("InvalidInput")
|
|
590
|
+
const [size] = await s.sql<{ bytes: number }>(
|
|
591
|
+
`SELECT bytes FROM eloxiv.collab_document WHERE entity = $1 AND record_id = $2`,
|
|
592
|
+
[PAGE, id],
|
|
593
|
+
)
|
|
594
|
+
expect(size!.bytes).toBeLessThanOrEqual(PAD_LIMITS.maxBytes)
|
|
595
|
+
// The rate: a person's updates to one document in a minute.
|
|
596
|
+
const fast = await page(ann)
|
|
597
|
+
let tag = "ok"
|
|
598
|
+
let accepted = 0
|
|
599
|
+
for (let i = 0; i < PAD_LIMITS.updatesPerMinute + 5 && tag === "ok"; i++) {
|
|
600
|
+
tag = tagOf(await update(ann, fast, insertion(`r${i}`)))
|
|
601
|
+
if (tag === "ok") accepted += 1
|
|
602
|
+
}
|
|
603
|
+
expect(tag).toBe("ActionFailed")
|
|
604
|
+
expect(accepted).toBeLessThanOrEqual(PAD_LIMITS.updatesPerMinute)
|
|
605
|
+
const [rows] = await s.sql<{ n: number }>(
|
|
606
|
+
`SELECT count(*)::int AS n FROM eloxiv.collab_update u JOIN eloxiv.collab_document d ON d.id = u.document_id
|
|
607
|
+
WHERE d.entity = $1 AND d.record_id = $2`,
|
|
608
|
+
[PAGE, fast],
|
|
609
|
+
)
|
|
610
|
+
expect(rows?.n).toBe(accepted)
|
|
611
|
+
// Someone else's rate is their own.
|
|
612
|
+
await share(ann, fast, bob, "edit")
|
|
613
|
+
expect(tagOf(await update(bob, fast, insertion("bob")))).toBe("ok")
|
|
614
|
+
}, 120_000)
|
|
615
|
+
|
|
616
|
+
// ---- Transport ------------------------------------------------------------------------------------------
|
|
617
|
+
|
|
618
|
+
it("converges clients after offline edits and reconnects", async () => {
|
|
619
|
+
const id = await page(ann)
|
|
620
|
+
await share(ann, id, bob, "edit")
|
|
621
|
+
const a = client(ann, id)
|
|
622
|
+
const b = client(bob, id)
|
|
623
|
+
await Promise.all([a.whenSynced(), b.whenSynced()])
|
|
624
|
+
a.doc.getText("body").insert(0, "Hello world")
|
|
625
|
+
await a.flush()
|
|
626
|
+
await until(
|
|
627
|
+
"b to receive a's text",
|
|
628
|
+
() => body(b),
|
|
629
|
+
(t) => t === "Hello world",
|
|
630
|
+
)
|
|
631
|
+
// Both edit while b is offline, at both ends of the text.
|
|
632
|
+
b.disconnect()
|
|
633
|
+
await until(
|
|
634
|
+
"b to be offline",
|
|
635
|
+
() => b.status,
|
|
636
|
+
(st) => st === "offline",
|
|
637
|
+
)
|
|
638
|
+
a.doc.getText("body").insert(0, "[a-online] ")
|
|
639
|
+
b.doc.getText("body").insert(b.doc.getText("body").length, " [b-offline]")
|
|
640
|
+
b.doc.getText("body").insert(0, "[b-first] ")
|
|
641
|
+
await a.flush()
|
|
642
|
+
b.connect()
|
|
643
|
+
await b.whenSynced()
|
|
644
|
+
await b.flush()
|
|
645
|
+
await until(
|
|
646
|
+
"both to converge",
|
|
647
|
+
() => [body(a), body(b)],
|
|
648
|
+
([x, y]) => x === y && x!.includes("[b-offline]") && x!.includes("[a-online]"),
|
|
649
|
+
)
|
|
650
|
+
expect(body(a)).toContain("Hello world")
|
|
651
|
+
expect(body(a)).toContain("[b-first]")
|
|
652
|
+
// A client opened afterwards, and the kernel's own projection, agree.
|
|
653
|
+
const c = client(ann, id)
|
|
654
|
+
await c.whenSynced()
|
|
655
|
+
expect(body(c)).toBe(body(a))
|
|
656
|
+
expect(await textOf(ann, id)).toBe(body(a))
|
|
657
|
+
})
|
|
658
|
+
|
|
659
|
+
it("relays presence to the document's readers, stamped with the person, kept only while live and never announced", async () => {
|
|
660
|
+
const id = await page(ann, "org")
|
|
661
|
+
const listening = await s.listen()
|
|
662
|
+
const a = client(ann, id)
|
|
663
|
+
const b = client(bob, id)
|
|
664
|
+
await Promise.all([a.whenSynced(), b.whenSynced()])
|
|
665
|
+
const marker = `cursor-${crypto.randomUUID()}`
|
|
666
|
+
a.setPresence({ name: "Ann", cursor: marker })
|
|
667
|
+
const seen = await until(
|
|
668
|
+
"b to see a's presence",
|
|
669
|
+
() => b.peers,
|
|
670
|
+
(peers) => peers.some((p) => JSON.stringify(p.state).includes(marker)),
|
|
671
|
+
)
|
|
672
|
+
expect(seen.find((p) => JSON.stringify(p.state).includes(marker))?.userId).toBe(ann.id)
|
|
673
|
+
// While live it is held in one place, which no module role can read.
|
|
674
|
+
const holding = await tablesHolding(marker)
|
|
675
|
+
expect(holding.length).toBe(1)
|
|
676
|
+
const [grants] = await s.sql<{ n: number }>(
|
|
677
|
+
`SELECT count(*)::int AS n FROM information_schema.role_table_grants
|
|
678
|
+
WHERE table_schema || '.' || table_name = $1 AND grantee NOT IN ('postgres', 'eloxiv_kernel')`,
|
|
679
|
+
[holding[0]!.replaceAll('"', "")],
|
|
680
|
+
)
|
|
681
|
+
expect(grants?.n).toBe(0)
|
|
682
|
+
// Another person cannot take a client's presence over, and a non-reader publishes none.
|
|
683
|
+
const spoof = await call(bob, "collab.awareness", {
|
|
684
|
+
entity: PAGE,
|
|
685
|
+
id,
|
|
686
|
+
clientId: a.doc.clientID,
|
|
687
|
+
clock: 1_000_000,
|
|
688
|
+
state: JSON.stringify({ name: "Not Ann" }),
|
|
689
|
+
})
|
|
690
|
+
expect(tagOf(spoof)).toBe("Forbidden")
|
|
691
|
+
expect(
|
|
692
|
+
tagOf(
|
|
693
|
+
await call(
|
|
694
|
+
cat,
|
|
695
|
+
"collab.awareness",
|
|
696
|
+
{ entity: PAGE, id, clientId: 7, clock: 1, state: "{}" },
|
|
697
|
+
"internal",
|
|
698
|
+
OTHER,
|
|
699
|
+
),
|
|
700
|
+
),
|
|
701
|
+
).toBe("Forbidden")
|
|
702
|
+
a.close()
|
|
703
|
+
await until(
|
|
704
|
+
"a's presence to go when it leaves",
|
|
705
|
+
() => b.peers,
|
|
706
|
+
(peers) => !peers.some((p) => JSON.stringify(p.state).includes(marker)),
|
|
707
|
+
)
|
|
708
|
+
expect(await tablesHolding(marker)).toEqual([])
|
|
709
|
+
// Nothing any database role could hear named the presence, the person, the record or the document.
|
|
710
|
+
const heard = listening.payloads()
|
|
711
|
+
await listening.stop()
|
|
712
|
+
expect(heard.length).toBeGreaterThan(0)
|
|
713
|
+
for (const payload of heard) {
|
|
714
|
+
for (const secret of [marker, ann.id, bob.id, id, PAGE]) expect(payload).not.toContain(secret)
|
|
715
|
+
}
|
|
716
|
+
})
|
|
717
|
+
|
|
718
|
+
it("keeps a client's newest presence: a withdrawal wins over an older announcement replayed after it", async () => {
|
|
719
|
+
const id = await page(ann, "org")
|
|
720
|
+
const viewer = client(bob, id)
|
|
721
|
+
await viewer.whenSynced()
|
|
722
|
+
const announce = (clock: number, state: string | null) =>
|
|
723
|
+
call(ann, "collab.awareness", { entity: PAGE, id, clientId: 4242, clock, state })
|
|
724
|
+
const captured = { clock: 5, state: JSON.stringify({ cursor: "captured" }) }
|
|
725
|
+
expect(tagOf(await announce(captured.clock, captured.state))).toBe("ok")
|
|
726
|
+
await until(
|
|
727
|
+
"the announcement to arrive",
|
|
728
|
+
() => viewer.peers,
|
|
729
|
+
(peers) => peers.some((p) => p.clientId === 4242),
|
|
730
|
+
)
|
|
731
|
+
expect(tagOf(await announce(6, null))).toBe("ok")
|
|
732
|
+
await until(
|
|
733
|
+
"the withdrawal to arrive",
|
|
734
|
+
() => viewer.peers,
|
|
735
|
+
(peers) => !peers.some((p) => p.clientId === 4242),
|
|
736
|
+
)
|
|
737
|
+
// The captured announcement, sent again: older than the withdrawal, so nothing changes.
|
|
738
|
+
expect(tagOf(await announce(captured.clock, captured.state))).toBe("ok")
|
|
739
|
+
const pulled = ok(await call(bob, "collab.pull", { entity: PAGE, id, after: 0 }))
|
|
740
|
+
expect((pulled["awareness"] as Array<{ clientId: number }>).some((p) => p.clientId === 4242)).toBe(false)
|
|
741
|
+
// A newer one shows again.
|
|
742
|
+
expect(tagOf(await announce(7, JSON.stringify({ cursor: "back" })))).toBe("ok")
|
|
743
|
+
await until(
|
|
744
|
+
"the newer announcement to arrive",
|
|
745
|
+
() => viewer.peers,
|
|
746
|
+
(peers) => peers.some((p) => p.clientId === 4242),
|
|
747
|
+
)
|
|
748
|
+
})
|
|
749
|
+
|
|
750
|
+
it("withdraws only what a closing connection announced: a newer announcement from another connection stays", async () => {
|
|
751
|
+
const id = await page(ann, "org")
|
|
752
|
+
const viewer = client(bob, id)
|
|
753
|
+
await viewer.whenSynced()
|
|
754
|
+
const socket = async () => {
|
|
755
|
+
const ws = new WebSocket(`${s.url.replace(/^http/u, "ws")}${COLLAB_SOCKET_PATH}`)
|
|
756
|
+
const synced = new Promise<void>((resolve) =>
|
|
757
|
+
ws.addEventListener("message", (event) => {
|
|
758
|
+
if (String(event.data).includes('"sync"')) resolve()
|
|
759
|
+
}),
|
|
760
|
+
)
|
|
761
|
+
await new Promise<void>((resolve) => ws.addEventListener("open", () => resolve()))
|
|
762
|
+
ws.send(JSON.stringify({ _tag: "hello", entity: PAGE, id, token: ann.token, orgId: ORG }))
|
|
763
|
+
await synced
|
|
764
|
+
return ws
|
|
765
|
+
}
|
|
766
|
+
const older = await socket()
|
|
767
|
+
older.send(JSON.stringify({ _tag: "awareness", clientId: 777, clock: 1, state: JSON.stringify({ tab: "old" }) }))
|
|
768
|
+
await until(
|
|
769
|
+
"the older announcement",
|
|
770
|
+
() => viewer.peers,
|
|
771
|
+
(peers) => peers.some((p) => p.clientId === 777),
|
|
772
|
+
)
|
|
773
|
+
// The same client reconnected: a newer announcement over a newer connection.
|
|
774
|
+
const newer = await socket()
|
|
775
|
+
newer.send(JSON.stringify({ _tag: "awareness", clientId: 777, clock: 2, state: JSON.stringify({ tab: "new" }) }))
|
|
776
|
+
await until(
|
|
777
|
+
"the newer announcement",
|
|
778
|
+
() => viewer.peers,
|
|
779
|
+
(peers) => peers.some((p) => p.clientId === 777 && JSON.stringify(p.state).includes("new")),
|
|
780
|
+
)
|
|
781
|
+
const closed = new Promise<void>((resolve) => older.addEventListener("close", () => resolve()))
|
|
782
|
+
older.close()
|
|
783
|
+
await closed
|
|
784
|
+
await new Promise((resolve) => setTimeout(resolve, 1_500))
|
|
785
|
+
const pulled = ok(await call(bob, "collab.pull", { entity: PAGE, id, after: 0 }))
|
|
786
|
+
const still = (pulled["awareness"] as Array<{ clientId: number; state: string }>).find((p) => p.clientId === 777)
|
|
787
|
+
expect(still?.state).toContain("new")
|
|
788
|
+
newer.close()
|
|
789
|
+
await until(
|
|
790
|
+
"the newer connection's presence to go when it closes",
|
|
791
|
+
async () => {
|
|
792
|
+
const again = ok(await call(bob, "collab.pull", { entity: PAGE, id, after: 0 }))
|
|
793
|
+
return (again["awareness"] as Array<{ clientId: number }>).some((p) => p.clientId === 777)
|
|
794
|
+
},
|
|
795
|
+
(present) => !present,
|
|
796
|
+
)
|
|
797
|
+
})
|
|
798
|
+
|
|
799
|
+
// ---- Agents ---------------------------------------------------------------------------------------------
|
|
800
|
+
|
|
801
|
+
it("lets an agent read the text and edit it as attributed, audited Yjs operations a person sees live", async () => {
|
|
802
|
+
const id = await page(ann)
|
|
803
|
+
const human = client(ann, id)
|
|
804
|
+
await human.whenSynced()
|
|
805
|
+
human.doc.getText("body").insert(0, "Dear team, the meeting is on Monday.")
|
|
806
|
+
await human.flush()
|
|
807
|
+
const agent = await s.agentSession(ann, ORG)
|
|
808
|
+
const read = ok(await call(agent.token, "collab.readText", { entity: PAGE, id }, "agent"))
|
|
809
|
+
expect(read).toMatchObject({ text: "Dear team, the meeting is on Monday.", name: "body" })
|
|
810
|
+
expect(read["roots"]).toEqual([{ name: "body", kind: "text" }])
|
|
811
|
+
const edit = {
|
|
812
|
+
entity: PAGE,
|
|
813
|
+
id,
|
|
814
|
+
edits: [
|
|
815
|
+
{ kind: "replace", find: "Monday", replace: "Tuesday" },
|
|
816
|
+
{ kind: "insert", at: "end", text: " Bring the report." },
|
|
817
|
+
],
|
|
818
|
+
}
|
|
819
|
+
// An agent's edit waits for its person's consent; nothing changes until they give it.
|
|
820
|
+
const asked = await call(agent.token, "collab.editText", edit, "agent")
|
|
821
|
+
expect(tagOf(asked)).toBe("ConsentRequired")
|
|
822
|
+
expect(await textOf(ann, id)).toBe("Dear team, the meeting is on Monday.")
|
|
823
|
+
// The same change as a raw update, through another action and surface, is held as well.
|
|
824
|
+
const current = String(ok(await call(ann, "collab.open", { entity: PAGE, id }))["state"])
|
|
825
|
+
const rawDoc = new Y.Doc()
|
|
826
|
+
Y.applyUpdate(rawDoc, Buffer.from(current, "base64"))
|
|
827
|
+
const before = Y.encodeStateVector(rawDoc)
|
|
828
|
+
const rawText = rawDoc.getText("body")
|
|
829
|
+
rawText.delete(rawText.toJSON().indexOf("Monday"), "Monday".length)
|
|
830
|
+
const raw = Y.encodeStateAsUpdate(rawDoc, before)
|
|
831
|
+
expect(tagOf(await update(agent.token, id, raw, "http"))).toBe("ConsentRequired")
|
|
832
|
+
expect(await textOf(ann, id)).toBe("Dear team, the meeting is on Monday.")
|
|
833
|
+
const consentId = asked.ok ? "" : String(asked.error["consentId"])
|
|
834
|
+
ok(await call(ann, "consent.approve", { id: consentId, remember: "session" }))
|
|
835
|
+
const edited = ok(await call(agent.token, "collab.editText", edit, "agent"))
|
|
836
|
+
expect(edited["text"]).toBe("Dear team, the meeting is on Tuesday. Bring the report.")
|
|
837
|
+
await until(
|
|
838
|
+
"the person to see the agent's edit live",
|
|
839
|
+
() => body(human),
|
|
840
|
+
(t) => t === edited["text"],
|
|
841
|
+
)
|
|
842
|
+
// A concurrent human edit elsewhere merges with it.
|
|
843
|
+
human.doc.getText("body").insert(0, "Hi! ")
|
|
844
|
+
await human.flush()
|
|
845
|
+
expect(await textOf(ann, id)).toBe("Hi! Dear team, the meeting is on Tuesday. Bring the report.")
|
|
846
|
+
// Attributed to the person, as their agent's, and tied to the audit record of the agent's call.
|
|
847
|
+
const [row] = await s.sql<{ actor: string; origin: string; invocation: string }>(
|
|
848
|
+
`SELECT u.actor_user_id AS actor, u.origin, u.invocation_id AS invocation FROM eloxiv.collab_update u
|
|
849
|
+
JOIN eloxiv.collab_document d ON d.id = u.document_id
|
|
850
|
+
WHERE d.entity = $1 AND d.record_id = $2 AND u.origin = 'agent'`,
|
|
851
|
+
[PAGE, id],
|
|
852
|
+
)
|
|
853
|
+
expect(row).toMatchObject({ actor: ann.id, origin: "agent" })
|
|
854
|
+
const audit = (await s.audit({ action: "collab.editText" })).find((a) => a.invocationId === row!.invocation)
|
|
855
|
+
expect(audit).toMatchObject({ actorUserId: ann.id, outcome: "succeeded", surface: "agent" })
|
|
856
|
+
// An edit whose passage is not there changes nothing.
|
|
857
|
+
expect(
|
|
858
|
+
tagOf(
|
|
859
|
+
await call(
|
|
860
|
+
agent.token,
|
|
861
|
+
"collab.editText",
|
|
862
|
+
{ entity: PAGE, id, edits: [{ kind: "replace", find: "Friday", replace: "x" }] },
|
|
863
|
+
"agent",
|
|
864
|
+
),
|
|
865
|
+
),
|
|
866
|
+
).toBe("InvalidInput")
|
|
867
|
+
})
|
|
868
|
+
|
|
869
|
+
// ---- Versioning and records -----------------------------------------------------------------------------
|
|
870
|
+
|
|
871
|
+
it("keeps checkpoints readable through the record's policy and restores one as new edits", async () => {
|
|
872
|
+
const id = await page(ann)
|
|
873
|
+
ok(await update(ann, id, insertion("first draft")))
|
|
874
|
+
await s.compact(PAGE, id)
|
|
875
|
+
ok(await call(ann, "collab.editText", { entity: PAGE, id, edits: [{ kind: "set", text: "second draft" }] }))
|
|
876
|
+
await s.compact(PAGE, id)
|
|
877
|
+
const versions = ok(await call(ann, "collab.history", { entity: PAGE, id }))["versions"] as Array<{
|
|
878
|
+
version: number
|
|
879
|
+
seq: number
|
|
880
|
+
}>
|
|
881
|
+
expect(versions.map((v) => v.version)).toEqual([1, 2])
|
|
882
|
+
expect(tagOf(await call(bob, "collab.history", { entity: PAGE, id }))).toBe("Forbidden")
|
|
883
|
+
const viewer = client(ann, id)
|
|
884
|
+
await viewer.whenSynced()
|
|
885
|
+
const restored = ok(await call(ann, "collab.restore", { entity: PAGE, id, version: 1 }))
|
|
886
|
+
expect(restored["text"]).toBe("first draft")
|
|
887
|
+
await until(
|
|
888
|
+
"the restore to arrive live",
|
|
889
|
+
() => body(viewer),
|
|
890
|
+
(t) => t === "first draft",
|
|
891
|
+
)
|
|
892
|
+
await share(ann, id, bob, "read")
|
|
893
|
+
expect(tagOf(await call(bob, "collab.restore", { entity: PAGE, id, version: 2 }))).toBe("Forbidden")
|
|
894
|
+
// A restore undoes others' work: an agent's waits for its person's consent.
|
|
895
|
+
const agent = await s.agentSession(ann, ORG)
|
|
896
|
+
expect(tagOf(await call(agent.token, "collab.restore", { entity: PAGE, id, version: 2 }, "agent"))).toBe(
|
|
897
|
+
"ConsentRequired",
|
|
898
|
+
)
|
|
899
|
+
})
|
|
900
|
+
|
|
901
|
+
it("refuses an edit or a restore made against a sequence number the document has moved past, changing nothing", async () => {
|
|
902
|
+
const id = await page(ann)
|
|
903
|
+
const first = ok(await call(ann, "collab.editText", { entity: PAGE, id, edits: [{ kind: "set", text: "v1" }] }))
|
|
904
|
+
const read = ok(await call(ann, "collab.readText", { entity: PAGE, id }))
|
|
905
|
+
expect(read["seq"]).toBe(first["seq"])
|
|
906
|
+
// Someone else changes it after it was read.
|
|
907
|
+
ok(
|
|
908
|
+
await call(ann, "collab.editText", {
|
|
909
|
+
entity: PAGE,
|
|
910
|
+
id,
|
|
911
|
+
edits: [{ kind: "insert", at: "start", text: "[later] " }],
|
|
912
|
+
}),
|
|
913
|
+
)
|
|
914
|
+
const stale = await call(ann, "collab.editText", {
|
|
915
|
+
entity: PAGE,
|
|
916
|
+
id,
|
|
917
|
+
baseSeq: read["seq"],
|
|
918
|
+
edits: [{ kind: "set", text: "overwritten" }],
|
|
919
|
+
})
|
|
920
|
+
expect(stale.ok ? "" : `${stale.error._tag} ${String(stale.error["message"])}`).toMatch(
|
|
921
|
+
/^InvalidInput Version conflict:/u,
|
|
922
|
+
)
|
|
923
|
+
expect(await textOf(ann, id)).toBe("[later] v1")
|
|
924
|
+
// At the current sequence number it applies.
|
|
925
|
+
const current = ok(await call(ann, "collab.readText", { entity: PAGE, id }))
|
|
926
|
+
ok(
|
|
927
|
+
await call(ann, "collab.editText", {
|
|
928
|
+
entity: PAGE,
|
|
929
|
+
id,
|
|
930
|
+
baseSeq: current["seq"],
|
|
931
|
+
edits: [{ kind: "set", text: "v2" }],
|
|
932
|
+
}),
|
|
933
|
+
)
|
|
934
|
+
expect(await textOf(ann, id)).toBe("v2")
|
|
935
|
+
ok(await call(ann, "collab.snapshot", { entity: PAGE, id }))
|
|
936
|
+
ok(
|
|
937
|
+
await call(ann, "collab.editText", {
|
|
938
|
+
entity: PAGE,
|
|
939
|
+
id,
|
|
940
|
+
edits: [{ kind: "insert", at: "start", text: "[again] " }],
|
|
941
|
+
}),
|
|
942
|
+
)
|
|
943
|
+
expect(tagOf(await call(ann, "collab.restore", { entity: PAGE, id, version: 1, baseSeq: current["seq"] }))).toBe(
|
|
944
|
+
"InvalidInput",
|
|
945
|
+
)
|
|
946
|
+
expect(await textOf(ann, id)).toBe("[again] v2")
|
|
947
|
+
})
|
|
948
|
+
|
|
949
|
+
it("keeps a labelled snapshot asked for by someone who may change the document, kept apart from compaction's", async () => {
|
|
950
|
+
const id = await page(ann)
|
|
951
|
+
expect(tagOf(await call(ann, "collab.snapshot", { entity: PAGE, id }))).toBe("InvalidInput")
|
|
952
|
+
ok(await update(ann, id, insertion("draft one")))
|
|
953
|
+
const kept = ok(await call(ann, "collab.snapshot", { entity: PAGE, id, label: "Before review" }))
|
|
954
|
+
expect(kept).toMatchObject({ version: 1, reason: "snapshot", label: "Before review", seq: 1 })
|
|
955
|
+
// Reading the record is not enough to keep a snapshot; another organisation learns nothing.
|
|
956
|
+
await share(ann, id, bob, "read")
|
|
957
|
+
expect(tagOf(await call(bob, "collab.snapshot", { entity: PAGE, id }))).toBe("Forbidden")
|
|
958
|
+
expect(tagOf(await call(cat, "collab.snapshot", { entity: PAGE, id }, "internal", OTHER))).toBe("Forbidden")
|
|
959
|
+
const history = ok(await call(bob, "collab.history", { entity: PAGE, id }))["versions"] as Array<any>
|
|
960
|
+
expect(history.map((v) => [v.version, v.reason, v.label])).toEqual([[1, "snapshot", "Before review"]])
|
|
961
|
+
ok(await call(ann, "collab.editText", { entity: PAGE, id, edits: [{ kind: "set", text: "draft two" }] }))
|
|
962
|
+
// Many more snapshots than are kept never crowd out compaction's checkpoint, nor it theirs.
|
|
963
|
+
await s.compact(PAGE, id)
|
|
964
|
+
for (let n = 0; n < 21; n++) ok(await call(ann, "collab.snapshot", { entity: PAGE, id, label: `n${n}` }))
|
|
965
|
+
const after = ok(await call(ann, "collab.history", { entity: PAGE, id }))["versions"] as Array<any>
|
|
966
|
+
expect(after.filter((v) => v.reason === "compaction")).toHaveLength(1)
|
|
967
|
+
expect(after.filter((v) => v.reason === "snapshot")).toHaveLength(20)
|
|
968
|
+
expect(after.some((v) => v.label === "Before review" || v.label === "n0")).toBe(false)
|
|
969
|
+
ok(await call(ann, "collab.editText", { entity: PAGE, id, edits: [{ kind: "set", text: "draft three" }] }))
|
|
970
|
+
ok(await call(ann, "collab.restore", { entity: PAGE, id, version: after.find((v) => v.label === "n1").version }))
|
|
971
|
+
expect(await textOf(ann, id)).toBe("draft two")
|
|
972
|
+
// An agent may keep a snapshot without asking: it changes no text.
|
|
973
|
+
const agent = await s.agentSession(ann, ORG)
|
|
974
|
+
expect(tagOf(await call(agent.token, "collab.snapshot", { entity: PAGE, id }, "agent"))).toBe("ok")
|
|
975
|
+
})
|
|
976
|
+
|
|
977
|
+
it("lets the record's module keep a live copy of the text through the committed event, newest first, of its own documents only", async () => {
|
|
978
|
+
const id = await page(ann)
|
|
979
|
+
const copyOf = async () =>
|
|
980
|
+
(
|
|
981
|
+
await s.sql<{ text: string; seq: string }>(
|
|
982
|
+
`SELECT body_text AS text, body_seq::text AS seq FROM pad.page WHERE id = $1`,
|
|
983
|
+
[id],
|
|
984
|
+
)
|
|
985
|
+
)[0]!
|
|
986
|
+
const announced = async () =>
|
|
987
|
+
(
|
|
988
|
+
await s.sql<{ n: number }>(
|
|
989
|
+
`SELECT count(*)::int AS n FROM eloxiv.outbox WHERE type = 'collab.changed' AND payload->>'id' = $1`,
|
|
990
|
+
[id],
|
|
991
|
+
)
|
|
992
|
+
)[0]!.n
|
|
993
|
+
// A refused change announces nothing, and the copy stays as it was.
|
|
994
|
+
expect(tagOf(await update(bob, id, insertion("not allowed")))).toBe("Forbidden")
|
|
995
|
+
expect(await announced()).toBe(0)
|
|
996
|
+
// Edits from a live client, one after another: the copy reaches the newest text and the sequence it holds.
|
|
997
|
+
const writer = client(ann, id)
|
|
998
|
+
await writer.whenSynced()
|
|
999
|
+
for (const word of ["one ", "two ", "three"]) {
|
|
1000
|
+
writer.doc.getText("body").insert(writer.doc.getText("body").length, word)
|
|
1001
|
+
await writer.flush()
|
|
1002
|
+
}
|
|
1003
|
+
const head = Number(ok(await call(ann, "collab.readText", { entity: PAGE, id }))["seq"])
|
|
1004
|
+
await until(
|
|
1005
|
+
"the live copy to reach the document",
|
|
1006
|
+
copyOf,
|
|
1007
|
+
(copy) => copy.text === "one two three" && Number(copy.seq) === head,
|
|
1008
|
+
)
|
|
1009
|
+
expect(await announced()).toBeGreaterThanOrEqual(3)
|
|
1010
|
+
// The module may read its own documents only: another module's entity is refused.
|
|
1011
|
+
ok(await call(ann, "collab.editText", { entity: PAGE, id, edits: [{ kind: "set", text: "[probe-foreign]" }] }))
|
|
1012
|
+
await until("the probe's answer", copyOf, (copy) => copy.text === "foreign read refused")
|
|
1013
|
+
// The read never changes the subscriber's role: its own statements alongside it all run as its module role.
|
|
1014
|
+
ok(await call(ann, "collab.editText", { entity: PAGE, id, edits: [{ kind: "set", text: "[probe-role]" }] }))
|
|
1015
|
+
await until("the role probe's answer", copyOf, (copy) => copy.text.startsWith("eloxiv_"))
|
|
1016
|
+
expect((await copyOf()).text).toBe("eloxiv_mod_pad")
|
|
1017
|
+
})
|
|
1018
|
+
|
|
1019
|
+
it("gives a live copy nothing of a record that moved to another organisation after its event", async () => {
|
|
1020
|
+
const moving = await page(ann)
|
|
1021
|
+
ok(
|
|
1022
|
+
await call(ann, "collab.editText", {
|
|
1023
|
+
entity: PAGE,
|
|
1024
|
+
id: moving,
|
|
1025
|
+
edits: [{ kind: "set", text: "Secret plans" }],
|
|
1026
|
+
}),
|
|
1027
|
+
)
|
|
1028
|
+
// The record moves to another organisation; its document stays where it was written.
|
|
1029
|
+
await s.sql(`UPDATE pad.page SET org_id = $2 WHERE id = $1`, [moving, OTHER])
|
|
1030
|
+
// A delivery in the old organisation asks for its text (the fixture's probe copies what it got).
|
|
1031
|
+
const asking = await page(ann)
|
|
1032
|
+
ok(
|
|
1033
|
+
await call(ann, "collab.editText", {
|
|
1034
|
+
entity: PAGE,
|
|
1035
|
+
id: asking,
|
|
1036
|
+
edits: [{ kind: "set", text: `[probe-moved:${moving}]` }],
|
|
1037
|
+
}),
|
|
1038
|
+
)
|
|
1039
|
+
const copied = async () =>
|
|
1040
|
+
(await s.sql<{ text: string }>(`SELECT body_text AS text FROM pad.page WHERE id = $1`, [asking]))[0]!.text
|
|
1041
|
+
await until("the probe's answer", copied, (text) => text.startsWith("moved:"))
|
|
1042
|
+
expect(await copied()).toBe("moved: nothing")
|
|
1043
|
+
})
|
|
1044
|
+
|
|
1045
|
+
it("deletes a record's document with the record and closes its connections", async () => {
|
|
1046
|
+
const id = await page(ann)
|
|
1047
|
+
ok(await update(ann, id, insertion("doomed")))
|
|
1048
|
+
const connection = client(ann, id)
|
|
1049
|
+
await connection.whenSynced()
|
|
1050
|
+
const closed = closedOf(connection)
|
|
1051
|
+
ok(await call(ann, "pad.remove", { id }))
|
|
1052
|
+
expect((await closed)._tag).toBe("Forbidden")
|
|
1053
|
+
expect(
|
|
1054
|
+
await s.sql(`SELECT 1 FROM eloxiv.collab_document WHERE entity = $1 AND record_id = $2`, [PAGE, id]),
|
|
1055
|
+
).toEqual([])
|
|
1056
|
+
})
|
|
1057
|
+
|
|
1058
|
+
it("refuses a malformed first frame and a socket without hello", async () => {
|
|
1059
|
+
const ws = new WebSocket(`${s.url.replace(/^http/u, "ws")}${COLLAB_SOCKET_PATH}`)
|
|
1060
|
+
const code = await new Promise<number>((resolve) => {
|
|
1061
|
+
ws.addEventListener("open", () => ws.send("{not json"))
|
|
1062
|
+
ws.addEventListener("close", (event) => resolve(event.code))
|
|
1063
|
+
})
|
|
1064
|
+
expect(code).toBe(4400)
|
|
1065
|
+
const plain = await fetch(`${s.url}${COLLAB_SOCKET_PATH}`)
|
|
1066
|
+
expect(plain.status).toBe(426)
|
|
1067
|
+
})
|
|
1068
|
+
|
|
1069
|
+
it("authenticates a socket with cookies only from a trusted origin", async () => {
|
|
1070
|
+
const id = await page(ann)
|
|
1071
|
+
ok(await update(ann, id, insertion("cookie test")))
|
|
1072
|
+
const cookie = await s.sessionCookie(ann)
|
|
1073
|
+
const attempt = (origin: string) =>
|
|
1074
|
+
new Promise<{ code: number; frames: Array<{ _tag: string }> }>((resolve) => {
|
|
1075
|
+
const frames: Array<{ _tag: string }> = []
|
|
1076
|
+
// Runtimes' WebSocket (Bun, Node's undici) take request headers: a browser sends the page's origin and cookies.
|
|
1077
|
+
const Socket = WebSocket as unknown as new (
|
|
1078
|
+
url: string,
|
|
1079
|
+
init: { headers: Record<string, string> },
|
|
1080
|
+
) => WebSocket
|
|
1081
|
+
const ws = new Socket(`${s.url.replace(/^http/u, "ws")}${COLLAB_SOCKET_PATH}`, {
|
|
1082
|
+
headers: { cookie, origin },
|
|
1083
|
+
})
|
|
1084
|
+
ws.addEventListener("open", () => ws.send(JSON.stringify({ _tag: "hello", entity: PAGE, id, orgId: ORG })))
|
|
1085
|
+
ws.addEventListener("message", (event) => {
|
|
1086
|
+
frames.push(JSON.parse(String(event.data)) as { _tag: string })
|
|
1087
|
+
if (frames.at(-1)?._tag === "sync") ws.close(1000)
|
|
1088
|
+
})
|
|
1089
|
+
ws.addEventListener("close", (event) => resolve({ code: event.code, frames }))
|
|
1090
|
+
})
|
|
1091
|
+
const evil = await attempt("https://evil.example")
|
|
1092
|
+
expect(evil.code).toBe(4401)
|
|
1093
|
+
expect(evil.frames.map((f) => f._tag)).toEqual(["closed"])
|
|
1094
|
+
const trusted = await attempt(s.trustedOrigin)
|
|
1095
|
+
expect(trusted.frames.map((f) => f._tag)).toEqual(["sync"])
|
|
1096
|
+
})
|
|
1097
|
+
|
|
1098
|
+
it("bounds what a connection may queue: a flood of frames while its calls wait closes it", async () => {
|
|
1099
|
+
const id = await page(ann)
|
|
1100
|
+
ok(await update(ann, id, insertion("seed ")))
|
|
1101
|
+
const connection = client(ann, id)
|
|
1102
|
+
await connection.whenSynced()
|
|
1103
|
+
// The document's row is held, so every update waits.
|
|
1104
|
+
const held = await s.holdTransaction([
|
|
1105
|
+
[`SELECT 1 FROM eloxiv.collab_document WHERE entity = $1 AND record_id = $2 FOR UPDATE`, [PAGE, id]],
|
|
1106
|
+
])
|
|
1107
|
+
try {
|
|
1108
|
+
const ws = new WebSocket(`${s.url.replace(/^http/u, "ws")}${COLLAB_SOCKET_PATH}`)
|
|
1109
|
+
const closed = new Promise<number>((resolve) => ws.addEventListener("close", (event) => resolve(event.code)))
|
|
1110
|
+
await new Promise<void>((resolve) => ws.addEventListener("open", () => resolve()))
|
|
1111
|
+
ws.send(JSON.stringify({ _tag: "hello", entity: PAGE, id, token: ann.token, orgId: ORG }))
|
|
1112
|
+
await new Promise((resolve) => setTimeout(resolve, 300))
|
|
1113
|
+
const frame = (n: number) => JSON.stringify({ _tag: "update", ref: n, update: toBase64(insertion(`f${n}`)) })
|
|
1114
|
+
for (let n = 0; n < 2000; n++) ws.send(frame(n))
|
|
1115
|
+
const code = await Promise.race([
|
|
1116
|
+
closed,
|
|
1117
|
+
new Promise<number>((resolve) => setTimeout(() => resolve(-1), 15_000)),
|
|
1118
|
+
])
|
|
1119
|
+
expect(code).toBe(1008)
|
|
1120
|
+
} finally {
|
|
1121
|
+
await held.rollback()
|
|
1122
|
+
}
|
|
1123
|
+
// Of the flood, at most what was queued before the bound ran.
|
|
1124
|
+
const [stored] = await s.sql<{ n: number }>(
|
|
1125
|
+
`SELECT count(*)::int AS n FROM eloxiv.collab_update u JOIN eloxiv.collab_document d ON d.id = u.document_id
|
|
1126
|
+
WHERE d.entity = $1 AND d.record_id = $2`,
|
|
1127
|
+
[PAGE, id],
|
|
1128
|
+
)
|
|
1129
|
+
expect(stored!.n).toBeLessThan(100)
|
|
1130
|
+
})
|
|
1131
|
+
|
|
1132
|
+
it("lets one connection speak for a few clients only", async () => {
|
|
1133
|
+
const id = await page(ann, "org")
|
|
1134
|
+
const ws = new WebSocket(`${s.url.replace(/^http/u, "ws")}${COLLAB_SOCKET_PATH}`)
|
|
1135
|
+
const closed = new Promise<number>((resolve) => ws.addEventListener("close", (event) => resolve(event.code)))
|
|
1136
|
+
await new Promise<void>((resolve) => ws.addEventListener("open", () => resolve()))
|
|
1137
|
+
ws.send(JSON.stringify({ _tag: "hello", entity: PAGE, id, token: ann.token, orgId: ORG }))
|
|
1138
|
+
for (let clientId = 1; clientId <= 20; clientId++) {
|
|
1139
|
+
ws.send(JSON.stringify({ _tag: "awareness", clientId, clock: 1, state: "{}" }))
|
|
1140
|
+
}
|
|
1141
|
+
expect(await closed).toBe(4429)
|
|
1142
|
+
})
|
|
1143
|
+
|
|
1144
|
+
// ---- Privacy --------------------------------------------------------------------------------------------
|
|
1145
|
+
|
|
1146
|
+
it("exports and erases documents through the module's data subjects, keeping shared documents with a pseudonym", async () => {
|
|
1147
|
+
const gus = await s.user("gus", ORG)
|
|
1148
|
+
const mine = await page(gus)
|
|
1149
|
+
ok(await update(gus, mine, insertion("GUS-OWN-DOCUMENT")))
|
|
1150
|
+
const shared = await page(ann)
|
|
1151
|
+
await share(ann, shared, gus, "edit")
|
|
1152
|
+
ok(await update(ann, shared, insertion("ann's text ")))
|
|
1153
|
+
ok(await update(gus, shared, insertion("GUS-CONTRIBUTION ")))
|
|
1154
|
+
// Compaction folds the updates away; what Gus contributed is still his to see.
|
|
1155
|
+
await s.compact(PAGE, shared)
|
|
1156
|
+
const requested = async (kind: "requestExport" | "requestErasure") => {
|
|
1157
|
+
const id = String(ok(await call(gus, `privacy.${kind}`, {}))["id"])
|
|
1158
|
+
return until(
|
|
1159
|
+
`the ${kind} to settle`,
|
|
1160
|
+
async () =>
|
|
1161
|
+
(
|
|
1162
|
+
(ok(await call(gus, "privacy.requests", {}))["requests"] as ReadonlyArray<{
|
|
1163
|
+
id: string
|
|
1164
|
+
status: string
|
|
1165
|
+
}>) ?? []
|
|
1166
|
+
).find((r) => r.id === id),
|
|
1167
|
+
(r) => r !== undefined && ["succeeded", "failed", "cancelled"].includes(r.status),
|
|
1168
|
+
90_000,
|
|
1169
|
+
)
|
|
1170
|
+
}
|
|
1171
|
+
const exported = await requested("requestExport")
|
|
1172
|
+
expect(exported?.status).toBe("succeeded")
|
|
1173
|
+
const data = ok(await call(gus, "privacy.download", { id: exported!.id })) as {
|
|
1174
|
+
sources: Array<{ source: string; records: Array<Record<string, any>> }>
|
|
1175
|
+
}
|
|
1176
|
+
const documents = data.sources.find((source) => source.source === "eloxiv.collab")?.records ?? []
|
|
1177
|
+
expect(documents.map((d) => d["recordId"])).toEqual([mine])
|
|
1178
|
+
expect(documents[0]!["roots"]).toEqual([{ name: "body", kind: "text", text: "GUS-OWN-DOCUMENT" }])
|
|
1179
|
+
const contributions = data.sources.find((source) => source.source === "eloxiv.collab_contribution")?.records ?? []
|
|
1180
|
+
const byId = (a: unknown, b: unknown) => String(a).localeCompare(String(b))
|
|
1181
|
+
expect(contributions.map((c) => c["record_id"]).sort(byId)).toEqual([mine, shared].sort(byId))
|
|
1182
|
+
expect(contributions.every((c) => Number(c["updates"]) >= 1)).toBe(true)
|
|
1183
|
+
const erased = await requested("requestErasure")
|
|
1184
|
+
expect(erased?.status).toBe("succeeded")
|
|
1185
|
+
// Gus's own page went with its record, document and all; the shared page keeps its text, by a pseudonym.
|
|
1186
|
+
expect(
|
|
1187
|
+
await s.sql(`SELECT 1 FROM eloxiv.collab_document WHERE entity = $1 AND record_id = $2`, [PAGE, mine]),
|
|
1188
|
+
).toEqual([])
|
|
1189
|
+
const kept = await textOf(ann, shared)
|
|
1190
|
+
expect(kept).toContain("GUS-CONTRIBUTION")
|
|
1191
|
+
expect(kept).toContain("ann's text")
|
|
1192
|
+
// Who contributed (the ledger, the updates having been compacted away): Ann, and Gus only by a pseudonym.
|
|
1193
|
+
const authors = await s.sql<{ actor: string }>(
|
|
1194
|
+
`SELECT DISTINCT c.user_id AS actor FROM eloxiv.collab_contribution c
|
|
1195
|
+
WHERE c.entity = $1 AND c.record_id = $2`,
|
|
1196
|
+
[PAGE, shared],
|
|
1197
|
+
)
|
|
1198
|
+
expect(authors.map((a) => a.actor)).toContain(ann.id)
|
|
1199
|
+
expect(authors.map((a) => a.actor)).not.toContain(gus.id)
|
|
1200
|
+
expect(authors.some((a) => a.actor.startsWith("erased_"))).toBe(true)
|
|
1201
|
+
expect(await tablesHolding("GUS-OWN-DOCUMENT")).toEqual([])
|
|
1202
|
+
}, 180_000)
|
|
1203
|
+
})
|