Rust AI & Data Meetup: Alexy Khrabrov, QueryGraph.ai: Lakehouse on Sail with Type-level Semantics
Since I joined Lake sale, I was super excited about trust and you know, I knew Scala and you know a bunch of stuff. It is basically rust like same stuff, squiggles, traits, types, options, right? It's basically all the same. If you know one of the PL language, you kind of know all of them. There are some differences, there is some async and stuff, but you know, if you know how it works, you can ask. And so, I think this is super weapon. If you know what types are Who Who likes types here? Do people like types? Who doesn't like types? Who thinks types are useless? Nobody. Who changed their heart and basically doesn't believe in types anymore? Who went the other way? So, there was a recent blog I'm kind of alluding to I have a press who was a you know, he's a Haskell guy and after like 16 years of Haskell, he said like I don't need types because agents do Python much faster, right? I don't care talk about later. So, what struck me immediately when I saw um Sorry
I was like I was telling Codex to fix my presentation till last moment. So, what struck me about Rust and this whole ecosystem is that um types can be used in ways that Python people don't even imagine. Uh if you have all this agentic of a system, right? How do you do permissions? Who knows how you do permissions in Python? Who does permissions in Python? Who does security policies? Does anybody do security secure agents in Python? Is there anybody here? There is none. There is nobody in the world who does them in Python because Python cannot and enforce your security secure policy, right? Because all is fungible. Again, we can argue about it. But uh what struck me immediately, right? >> [clears throat] >> Uh it's really fantastic. Let's see. Uh it's fantastic that uh you can actually code your security policies, your access policies, your Rback and I ODRL and other things I'll mention quickly as types
So, what inspired me to do this? In 2018, at Scale by the Bay, we had a talk by David R. of Suma Logic. So, Suma Logic is a security company. They like amass enormous amount of logs, right? And then they want to kind of analyze what's going on. So, they're very paranoid about security. And so, David, as many Scala people, was a secret like crypto hustler. A lot of hustler people couldn't get jobs in for crypto, so they had to do Scala jobs, right? Then temporarily shifted and, you know, hustler was hot in crypto and then it all died, fortunately. And now kind of they're free to do useful things again
But, for a moment, Scala people borrowed from hustler. So, hustler has a library called Seclib. Who heard about Seclib? Nobody. So, Seclib is an amazing thing. It's basically is an opaque value, right? You cannot see the value. The value is secret. This is through the magic of types. However, you can apply operations to the value
For instance, if the value is an email, you cannot see the whole email, but you can cut off the suffix. You can get the domain. And then you can tabulate and see how many customers came from some domain. So, this is was my first job at Amazon 20 years ago. I went to personalization team, people who bought this, who you know, bought that. And like I had a bunch of pearl. Imagine this, we had pearl. So, the platform was using pearl to serve things
The mod pearl was the thing which actually served all these things. And I I ran a bunch of pearl and I had on like unlimited access to all Amazon customers, right? I was like a random guy who just came to Seattle from New Jersey of all places. And then I could tabulate all Amazon customers and just break them down by domain. So, so I had actually an idea, maybe I should start a hedge fund. Maybe I should see who like who from Goldman Sachs is buying books how to go to pasture and relax. And maybe we should short their stocks, right? I didn't do that. Again, normally, normally, right? You should not do this. So, Haskell has this cyclic thing
So, put all the emails in cyclic and have an operation, give me the domain, and then you can sort by domain, and you can aggregate by domain. So, that's one insight. However, the second insight I had, all these agents, right, they they basically have this enormous burden of who can access what. And so, with sale, we're the ground truth. First of all, so lakehouse is the truth of all other data. A reg database is a derivative database. Nobody puts primary data into a reg database. Nobody puts primary data into a graph database
This is all refilled from the lakehouse, right? So, we're the source of truth. We have a bunch of tables, a bunch of documents of all kinds. Uh, any agentic framework running in an enterprise will access some parts of this and uh, telling agents which, you know, agent can access what is actually super important, and nobody's really doing this properly. Nobody's like, this is just telling you, so notice every second metabyte ages well agent in production. If you keep saying this, it doesn't mean it will happen. Nobody's saying Spark in production, because Spark is already in production. There was not a single meetup here called Spark in production for 10 years, because Spark is already in production, and Kafka is already in production. However, every second meetup is called agents in the enterprise, agents in production
Why is it not happening? Because this is very difficult, and the access and permissions is a hard problem, and the enterprise would rather not give you any access, especially to a bunch of random startup people, right, who who who want customer data and financial data or health related. Nobody's going to do that. So, how can we solve this? So, my proposition is, if we are the Rust people who know the magic of types, we then will bring the types to bear on this, all right? So, I thought I'll do this experiment. So, and then I did four different things. First, I built a graph API in Rust called Grust, because Rust does not have a general graph API. Actually, Python doesn't have it either. They all have vectors, but they don't have graphs. Graph is a not a common structure
So, graph projects usually have their own little bespoke graph API inside of it, but they do not expose a general API. So, I built in this graph API and they added 15 different back ends, including PG graph, which our friends are going to talk about, and Coco index, and some others, right? And then they built this thing called type sec. So, type sec is the security framework where you define capabilities based on types. For instance, an agent have can have a type. Right? The type will be So, prompts and governance, you're sending text. Like, why are you sending your crucial business knowledge, right? Hard-earned knowledge as plain markdown? Why are you sending skills? Why are you sending prompts? This is everything you know. Why are you suddenly thinking that this is disposable when it's actually very important not to do it in plain text? Again, as industry, we're not thinking about this. Like, who would put all of your hard-earned business knowledge in a markdown file and send it to, you know, random people on the internet? We are doing it all the time with agents
So, um So, here is basically what I propose to do, all right? So, we have agents. Insecure agents will not compile. Agents have to have a type, which allows them to do stuff. For instance, some things can be only done be done with an agent which is authenticated. If it's not authenticated, it will not work. So, in your code path where an agent is not authenticated, it will not compile. Insecure agents will not exist. Right? Not possible in Python
Everything will exist in Python until it crashes during the run time. And so, kind of I propose to look at the AI. AI is a is like Unix architecture. It's a pipe. Right? AI is a pipe and you have to type different inputs and outputs and you have to check that things that you are connecting actually allow this. Right? So, So, I developed a protocol called type did. So, did is decentralized identifier. It's a W3C standard
Who heard about did, DID? So, the idea is a hyperledger, right? It's kind of from the blockchain era. People used to do it and then they forgot about it. It's actually very useful. So, Azure implements it as a primitive. You can just go to Azure and use the ID. So, it's a hyper ledger, it's a unique identifier, unforgeable, you can verify it. There is a beautiful, nice caveat. It's not just an ID, it carries a payload
It carries a little XML package you can attach to it. And what can you put in it? You can put a prompt in it. And you can put a skill in it. And furthermore, you can encrypt it with your own private key. So, imagine this, you can you you you take a prompt, you take your skill, you encrypt it, put in XML payload, and give it the unique ID on the hyper ledger, right? It's a globally verifiable ledger. So, then what we did, so this is a joint work with European consortium called Co-data and the Japan IPA agency. So, this is international effort, so it kind of kind of comes from my other thread where I, you know, started this AI lines at IBM and community effort. So, it's kind of comes from the people who want to enforce kind of security across different industries and foster the ecosystem, you know, of inter-interoperability
So, the the DID is visible to everybody. And Co-data modified Olama. They basically made Olama capability to send instead of prompt, you send it a DID. And Olama looks it up, right? It's globally visible. It's a And if Olama has your your public key, then it can decrypt the right? It can decrypt the payload and run it. So, instead of sending big blobs of markdown, you send a unique ID. The LLM, your your own LLM, open source LLM, opens the package and runs it. And then it can do whatever it wants, it can further wrap it in a secure type and send it further
So, now you can have a secure computation, permissioned, and fully auditable because all the DIDs are on the ledger, right? Imagine this. So, I built this, it's a type six stack, right? And and then we went further. So, now we want to have ontologies because some DIDs will be in automotive domain, some ideas will be in financial domain. Now, uh if you want them to kind of interoperate, an example is the DID can be a part part of a car part of a BMW. So, let's say your BMW is broken, it's a smart car, it looks up its part. Part is made in China. It orders the part to come to a Bosch repair facility near you. So, Bosch, Shenzhen supplier, and BMW all have to agree that this part is called the same exact thing
So, it's an ontology local. You need to have an ontology. Who will own the ontology? Ontology will be owned by a BMW because they they are the ones who make the car. It will not be owned by Ledger Bricks or Lake Sale or Amazon. The ontology will be a domain-specific set of DIDs. It's a hierarchical set as well. Right, so we need to agree. The agent will need to go to a BMW-authorized ontology, find the part, right? Find the unique part exactly
It's not a question of a fuzzy match. It should be exactly same part, agreed by Bosch, Shenzhen factory, and BMW. So, all of this needs to happen in the semantic layer. Semantic layer resolves the meaning, right? It's not the business metric. It's an actual meaning of what it is, right? And so, that's also a part of this. So, basically, say I built all of this in a few weeks. Uh and again, I don't have much time to go over it. Uh it ran on sale
While we were doing this, I also thought, why should we have all these gigantic catalogs? They're all blobs of Java, they all like do random things. Let's make a very tight catalog which does exactly one thing. It does governance, auditability, so every transaction is on type DID Hyperledger. And we also do open lineage. So, every transformation, we can sign an open lineage transformation with a DID. So, now we can have the provable transformation of all your data. And also, we know that the agent who did the transformation was authorized to do it, right? So, this This done in Rust, but you can use Python agents linked to it for instance by Dyntic AI version 2. Specifically centers everything on capabilities
So, capabilities is exactly what I put in type set. The capability is a type of an agent. It can do something to a resource, right? It's a tuple, right? A resource can be a table, a user, and capability can be can read, can access, can modify, right? So, basically I kind of will skip over the rest. So, in addition to all of that uh I put together a a process which writes a book about open source project. It puts all the code in Obsidian Vault. The book is delivered as an Obsidian document in markdown, and all the examples are linked to the code base. So, you can actually download all of So, there are four projects. They're on a site called firstpair.org
It's my publishing site. And you can go there, you can download all these books, you can read them as PDF, as EPUB, and Obsidian Vault. And Obsidian Vault links to the whole code base. So, there is a book on sale Learning Rust with Sailfish. I wrote for myself. I said, "Yeah, I write me a book how can I can learn Rust as it applies to Sailfish." Right? Because I want to work on Sailfish. And so, you can now download all of this, you can learn Rust, you can learn Sailfish, and you can read the book about it, and you can kind of use all these objects. So, uh I I know it's a lot
So, you know, hopefully I will sometimes give a longer talk about it, but please check it out. Let me know uh if it makes sense. Again, super happy to uh collaborate in the community. Thank you.