Skip to main content

Module ast

Module ast 

Source
Expand description

Condensing source code: keep the shape, elide the bodies.

§Why code cannot be truncated

Cutting a source file at a byte offset destroys exactly what a coding agent needs. The signatures are spread through the file, the imports are at the top, and the function the agent was asked about is as likely to be at the end as anywhere. A model handed the first two hundred lines of a thousand line file knows less than one handed every signature in it.

So this slicer parses, keeps the declarations, and replaces each body with a marker. A four hundred line module becomes forty lines of signatures that still say what the module is.

§The output is still source

Every elision marker is valid syntax in the language it replaces — a block comment in Rust and JavaScript, ... in Python. The result parses. That is not decoration: a model reading something that looks like code but does not parse will reproduce the malformation in its patch, and a downstream syntax checker will then blame the agent.

§Relevance, not file order

When the cap will not hold every signature, the ones that go are chosen by relevance to what the step was asked to do rather than by position. The terms come from the caller — the runtime holds the WorkOrder and constructs the slicer with terms drawn from its intent — because the Slicer contract takes raw output and a cap and nothing else, and widening it so one slicer could see the work order would put a model’s proposal into every slicer’s reach.

Whatever survives is emitted in source order. Reordering a file to put the relevant parts first would make the line numbers lie.

§When it cannot parse

It degrades to the log slicer rather than failing the step. An unsupported language, a file that is mostly a syntax error, a template with a foreign preprocessor — all of them are still text, and text sliced by the log slicer is far more useful than a refused step. The condensate says which slicer actually produced it, so nothing downstream is misled about what it is reading.

Structs§

AstSlicer
Condenses source code to an outline.
Item
One declaration kept from a file.

Enums§

Language
A language this slicer can parse.

Constants§

AST_SCHEMA
The schema an outline condensate declares.