6 ms·
Beagle, a source code management system that stores AST trees
- ktpsns 7mo agoGlad to see this. We can do better then git.
- thunderbong 7mo agoCare to elaborate?
- _ZeD_ 7mo agowho is "we"? and "better" in what measure?
- MadxX79 7mo agoCan it store my PIN numbers and my map of ATM machines also?
- wolfi1 7mo agowas about to point that out, you beat me to it
- MadxX79 7mo agoI rushed so much that I didn't have time to do it right. It could have been the AST tree of my PIN number validation algorithm for ATM machines. :-P
- danparsonson 7mo agoI don't think your original post suffered for the lack of one more TLA acronym.
- pseudohadamard 7mo agoRight! I had to get up in the morning, at ten o'clock at night, half an hour before I went to bed... sorry, wrong sketch. I had to set up my PIN number to display on the LCD display of an ATM machine with the instructions printed in PDF format telling me how to add VAT tax all before midday GMT time. And you try and tell the young people of today about RAS syndrome, they won't believe you!
- Maxious 7mo agohttps://github.com/Ataraxy-Labs/sem https://github.com/Ataraxy-Labs/sem stores AST operations in git https://news.ycombinator.com/item?id=47294924 https://news.ycombinator.com/item?id=47294924
- xedrac 7mo agoThis sounds good in theory, but it means Beagle needs to understand how to parse every language, and keep up with how they evolve. This sounds like a ton of work and a regression could be a disaster. It'll be interesting to see how this progresses though.
- bri3d 7mo agoIMO this really isn’t a huge problem for this project specifically, since that part is outsourced to tree-sitter which has a lot of effort behind it to begin with. I think this project is incredibly cool as a line of research / thought but my general experience in trying to provide human interfaces using abstractions over source code suggests that most people in general and programmers especially are better at reasoning in the source code space. Of course, beagle can generate into the source code space at each user interaction point, but at that point, why not do the opposite thing, which is what we already do with language servers and AST driven (semantic) merge and diff tools?
- ibejoeb 7mo agoIt's also just one more facet. The problem already exists for anything else that we already have, like formatters, linters, syntax highlighters, language servers... And it's also not an exclusive choice. If you want to use a dumb editor, there's nothing preventing that. All of the machinery to go back and forth to text exists. Not really a huge departure.
- computably 7mo ago> AST driven (semantic) merge and diff tools? Would you say these are commonly in use, and if so what are some "mainstream" examples? IME most people just use git's built-in diff/merge...
- mtndew4brkfst 7mo agoI find Mergiraf pretty pleasant to use and frequently pretty helpful as a time-saver. Handles TOML and Rust for me, and I have way fewer manual interventions, especially after supplementing it with rustfmt rules to not do a bunch of merged use statements in one go. Easy to configure as a jujutsu tool as well. https://mergiraf.org/ https://mergiraf.org/
- a-dub 7mo agommm. interesting and fun concept, but it seems to me like the text is actually the right layer for storing and expressing changes since that is what gets read, changed and reasoned about. why does it make more sense to use asts here? are these asts fully normalized or do (x) and ((x)) produce different trees, yet still express the same thing? why change what is being stored and tracked when the language aware metadata for each change can be generated after the fact (or alongside the changes)? (adding transform layers between what appears and what gets stored/tracked seems like it could get confusing?)
- deleted 7mo ago[deleted]
- bri3d 7mo ago100% agree. I think AST-driven tooling is very valuable (most big companies have internal tools akin to each operation Beagle provides, and Linux have Coccinelle / Spatch for example), but it's still just easier implemented as a layer on top of source code than the fundamental source of truth. There are some clever things that can be done with merge/split using CRDTs as the stored transformation, but they're hard to reason about compared to just semantic merge tools, and don't outweigh the cognitive overhead IMO. Having worked for many years with programming systems which were natively expressed as trees - often just operation trees and object graphs, discarding the notion of syntax completely, this layer is incredibly difficult for humans to reason about, especially when it comes to diffs, and usually at the end you end up having to build a system which can produce and act upon text-based diffs anyway. I think there's some notion of these kinds of revision management tools being useful for an LLM, but again, at that point you might as well run them aside (just perform the source -> AST transformation at each commit) rather than use them as the core storage.
- ragall 7mo ago> but it's still just easier implemented as a layer on top of source code than the fundamental source of truth Easier but much less valuable.
- westurner 7mo agoIt makes a lot of sense for math-focused LLMs to work with higher order symbols - or context-dependent chunking - than tokens. The same is probably true for software. From "Large Language Models for Mathematicians (2023)" (2025) https://news.ycombinator.com/item?id=42899805 https://news.ycombinator.com/item?id=42899805 : > It makes sense for LLMs to work with testable code for symbolic mathematics; CAS Computer Algebra System code instead of LaTeX which only roughly corresponds. > Are LLMs training on the AST parses of the symbolic expressions, or token coocurrence? What about training on the relations between code and tests? There are already token occurrence relations between test functions and the functions under test that they call. What additional information would it be useful to parse and extract and graph rewrite onto source code before training, looking up embeddings, and agent reasoning?
- nzoschke 7mo agoIn https://replicated.wiki/blog/partII https://replicated.wiki/blog/partII this part is very interesting to me: > Want to keep LLM .md files in a separate overlay, only make them visible on request? Also easy. CRDT gives the freedom in splitting and joining along all the axes. I now have a bunch of layers of text / markdown: system prompts, AGENTS.md, SKILL.md, plus user tweaks or full out replacements to these on every repo or subproject. Then we want to do things like update the "root" system prompt and have that applied everywhere. There are analogies in git, CMS templating systems, software package interfaces and versioning. Doing it all with plain text doesn't feel right to me. Any other approaches to this problem? Or is Beagle and ASTs and CDRTs really onto something here?
- deleted 7mo ago[deleted]
- omoikane 7mo agoThe linked page looks like a subsystem of some specific library, I am not sure if it is intended for general use. If it were intended to be general replacement for general purpose version control systems, I am not sure how storing AST is better than storing the original plain text files since the transformation from text to AST might be lossy. I might want to store files with no AST (e.g. plain text files), files with multiple AST (e.g. polyglots), multiple files with the same AST (e.g. files to test different code layout), broken AST (e.g. data files to be used as test cases). These use cases would be trivially supported by storing the original file as is, whereas storing any processed form of the file would require extra work.
- sethev 7mo agoIt leans on tree-sitter for language handling, so i wonder if they're actually Concrete Syntax Trees.
- gritzko 7mo ago(Author) There is a fall-back general-text codec: tokens, no AST (e.g. for Markdown). If that fails (non UTF8), there is the general-blob final-fallback codec (the git mode). The way it makes an AST tree is non-lossy. Additionally, it stamps ids on the nodes, so merges do not get confused by renames, formatting changes and similar things. There is value in preserving structure this way that repeat parsing can not provide. In big-O terms, working with such an AST tree and a stack of its patches is not much different from stacks of binary diffs git is using. If I have k independent changesets, I have k^2 unplanned interactions and 2^k unplanned change combinations. Having a bunch of change sets, which I had not fully evaluated yet, esp in relation to one another, I would like k-way merges and repeat-merges to be seamless, non-intrusive and deterministic. git's merges are not. The project is experimental at this point.
- jhancock 7mo agoAST of what? Will it read my clojure code's forms as such? What if my source file has a paran balancing error? I feel I'm thinking of this at the wrong level/angle.
- majkinetor 7mo agoSomewhat similar project is unison: https://www.unison-lang.org/docs/the-big-idea https://www.unison-lang.org/docs/the-big-idea
- ValentineC 7mo agoMildly pedantic, but AST already stands for Abstract Syntax Tree, so the post title when unabbreviated is Abstract Syntax Tree trees.
- BlueHotDog2 7mo agowhat bothers me is, while CRDTS converge, the question is to what. in this case, it seems like there's a last-write-wins semantic. which is very problematic as an implicit assumption for code(or anything where this isn't the explicit invaraint)
- Chris2048 7mo agoSpeaking on the concept of AST storage, VCS in general (not Beagle specifically); Hopefully this is the path to protentional editing/editors - the underlying code is an AST, but what you see, and edit, is the human-friendly text representation of that AST. Of course, you need a solid transform not just from text/PL repr to AST, but also AST to PL, possibly keeping local metadata relevant to the second part (e.g. where to put non-generated-by-default-from-ast whitespace and other formatting), so this might call for new (or modified) prog-langs for this explicit purpose?
- halis 7mo agoI suppose if you stored the code in ASTs and the LLMs all have to parse the code into ASTs when analyzing it, you could make it more efficient for them to work on code?
- halis 7mo agoActually, based on a google search apparently LLMs don't parse code into ASTs.