# S-expression Output Notation Every output line is a self-contained fact. Each fact that references a module carries `:lang` (py/ts/tsx). **Module ID**: relative path from workspace root, no extension, no `/index`. Example: `drive/modules/drive_db/api/drive_db_api.ts` -> `drive/modules/drive_db/api/drive_db_api`. ## Raw Graph Facts (in .belief_map.sexp) ```scheme (node "" :naming :pkg ) (fn :eid ) (cls :eid (:bases A) (:deco D) (:methods m1 m2)) (ifc :eid (:methods m1 m2)) (typ :eid ) (enm :eid ) (imports [:via-base] [:lsp]) (calls-api :via-ifc [:lsp]) (data-flow [:validated]) (refs :: [:lsp]) (calls :: :: :lines L1 L2 :lsp) ``` ## boundary Output ```scheme (boundary :lang py :file :purpose "") (cls :lang py (:bases A) (:deco D) (:methods m1 m2)) (boundary-dep :lang ts :file :relation imports) (boundary-rdep :lang py :file :relation imports) (boundary-summary :total 10 :deps 7 :rdeps 2) ``` ## analyze Output ```scheme (analyze :lang py "" :file ) (cls :lang py (:bases A) (:deco D) (:methods m1 m2)) (analyze-import :lang ts :file ) (analyze-dataflow :lang py :validated) (refs ::) (analyze-dependent :lang tsx :via imports refs :file ) (dep :lang py :via imports :depth 1) (rdep :lang tsx :via imports :depth 1) (key-entity :lang py :kind cls :line 32 :refs 7 :modules 4) (key-entity-ref :lang ts) (boundary-file ) (layer :layer domain) (analyze-summary :entities 31 :imports 1 :dataflows 0 :refs 1 :dependents 50 :boundary-files 52) ``` ## entity Output ```scheme (entity-def cls :lang py :file ) (entity-def ifc :lang ts :file ) (refs ::) ``` ## deps / rdeps Output ```scheme (deps-root :lang py) (dep :lang ts :via imports :depth 1) (dep :lang py :via data-flow :depth 2 :cycle) (rdeps-root :lang ts) (rdep :lang tsx :via imports :depth 1) ``` ## flow Output ```scheme (flow :: :: :lang py :via calls :depth 0) (flow :: :lang ts :via imports :depth 1 :module-level) ``` ## boundaries Output ```scheme (violation :src-layer domain :tgt-layer api :via imports :lang ts "") (boundaries-summary :violations 2 :checked 3587) (boundaries-ok :checked 3587) ``` ## invariants Output ```scheme (invariant-violation :expected snake_case :actual PascalCase :lang py :pkg ) (invariants-summary :violations 12 :checked 3587) (invariants-ok :checked 3587) ``` ## layers Output ```scheme (layer-group api :count 144) (layer-member api :lang ts) ``` ## find_function / find_type Output ```scheme (fn-def :: :line 42 :lang ts :file :kind function) (fn-def ::. :line 42 :lang py :file :kind method) (type-def cls :: :line 10 :lang ts :file (:bases A) (:methods m1 m2)) (type-def ifc :: :line 10 :lang ts :file ) ``` ## find_callers / find_calls Output ```scheme (callers-target :: :line 42 :lang ts :file ) (caller :: -> :: :lang ts :file :lines L1 L2 :lsp) (caller-module -> :via imports :depth 1 :lang ts :file ) (calls-source :: :line 42 :lang ts :file ) (calls-target :: -> :: :lang ts :file ) (calls-module -> :via imports :depth 1 :lang ts :file ) ``` ## find_callchain Output ```scheme (callchain-step 0 :: :lang ts :file ) (callchain-step 1 :: :lang py :file ) (callchain-summary :length 3 :hops 2) (callchain-module-step 0 :lang ts :file ) (callchain-module-summary :length 2 :hops 1) (callchain-none "srcFn" -> "tgtFn" :max-depth 5) ``` ## grep_functions Output ```scheme (grep-fn :: :line 55 :lang ts :file :match "matched line text") (grep-functions-summary :matches 12 :pattern "pattern") (grep-functions-empty "pattern") ``` ## diff_functions Output ```scheme (diff-fn :: :kind fn :line 42 :lang ts :file ) (diff-functions-summary :changed 5 :files 3 :ref "HEAD") (diff-file :hunks 2) (diff-functions-no-match :files 3 :ref "HEAD") (diff-functions-empty "HEAD") ``` ## query / repl Output ```scheme (result ) (result-empty) (result-count 42) ``` ## :lang Values | Value | Language | Naming | Example | |---|---|---|---| | `py` | Python | snake_case fns, PascalCase classes | `drive_path_to_entry`, `DrivePath` | | `ts` | TypeScript | camelCase fns, PascalCase classes | `calculateTotal`, `OperativesService` | | `tsx` | TSX/React | PascalCase components, camelCase hooks | `FileBrowser`, `useQuery` | ## Architecture Layers | Layer | Path patterns | Role | |---|---|---| | `domain` | `/domain/`, `/entities/`, `_schema` | Pure business logic | | `api` | `/api/`, `/routes/`, `/controllers/` | HTTP/RPC handlers | | `service` | `/services/`, `/application/` | Business orchestration | | `infra` | `/repositories/`, `/db/`, `/infra/` | Database, storage, messaging | | `shared` | `/commons/`, `/utils/`, `/types/` | Cross-cutting utilities | | `test` | `/tests/`, `.test.`, `.spec.` | Test files | | `ui` | `/components/`, `/pages/`, `/hooks/` | Frontend UI | | `config` | `/config/`, `/env/` | Configuration | | `other` | (no match) | Unclassified |