1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;; Typed border for the L1 AstGraph — the parsed, canonicalized,
;; content-addressed form of a single Nix expression (one `.nix` file
;; or one inline expression).
;;
;; Mirrors lockfile_graph.lisp's pattern: an `AstGraph` is a dense
;; `Vec<AstNode>` keyed by `NodeId` (u32), where `nodes[0]` is the root
;; expression. Every reference between nodes is a `NodeId`, so the
;; archive form is flat, pointer-free, and mmap-and-cast-able.
;;
;; Why a typed AST and not the rnix CST:
;;
;; * rnix gives a lossless rowan CST (every byte of the source is
;; reachable). That's the right shape for tooling (LSP, formatter),
;; the wrong shape for archiving (heavy green tree, parse-specific,
;; re-parses on every access).
;; * The L1 AstGraph is what every downstream cares about: which
;; identifiers, which attrset paths, which lambda formals, which
;; imports. The byte-level rendering is recoverable from the source
;; text (which is also content-addressed in the store).
;;
;; Coverage:
;;
;; - Literals: Int, Float, Str (including interpolation), Path,
;; IndentedStr, NullLit, BoolLit
;; - References: Ident, Select (attrset.a.b.c with optional fallback)
;; - Containers: List, AttrSet (recursive or not, including `inherit`)
;; - Bindings: LetIn, With, Assert
;; - Functions: Lambda (with formal-args destructuring), Apply
;; - Control: IfThenElse
;; - Operators: BinOp (+, -, *, /, ==, !=, <, <=, >, >=, &&, ||, ->,
;; //, ++), UnaryOp (Neg, Not), HasAttr (a ? b)
;; - Forward-compat: Unknown { kind, source_text } — preserves the
;; source verbatim so future versions can re-parse it without losing
;; information.
;;
;; This file holds *fixtures* used by ast_graph tests. Production
;; AstGraphs are built from real `.nix` files via
;; `AstGraph::from_source` and persisted as rkyv blobs in
;; sui-graph-store.
;; ── Fixture 1: single integer literal ──────────────────────────────
;; `42`
;; ── Fixture 2: let-in binding ──────────────────────────────────────
;; `let x = 1; in x + 2`
;; ── Fixture 3: nixos-module style attrset ──────────────────────────
;; `{ config, lib, pkgs, ... }: { networking.hostName = "rio"; }`