trailmark 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. trailmark-0.1.0/.github/dependabot.yml +21 -0
  2. trailmark-0.1.0/.github/workflows/ci.yml +70 -0
  3. trailmark-0.1.0/.github/workflows/mutation.yml +38 -0
  4. trailmark-0.1.0/.github/workflows/publish.yml +54 -0
  5. trailmark-0.1.0/.github/workflows/semgrep.yml +41 -0
  6. trailmark-0.1.0/.github/workflows/zizmor.yml +33 -0
  7. trailmark-0.1.0/.gitignore +15 -0
  8. trailmark-0.1.0/AGENTS.md +90 -0
  9. trailmark-0.1.0/CONTRIBUTING.md +80 -0
  10. trailmark-0.1.0/LICENSE +200 -0
  11. trailmark-0.1.0/NOTICE +12 -0
  12. trailmark-0.1.0/PKG-INFO +309 -0
  13. trailmark-0.1.0/README.md +292 -0
  14. trailmark-0.1.0/pyproject.toml +56 -0
  15. trailmark-0.1.0/src/trailmark/__init__.py +3 -0
  16. trailmark-0.1.0/src/trailmark/analysis/__init__.py +5 -0
  17. trailmark-0.1.0/src/trailmark/analysis/augment.py +384 -0
  18. trailmark-0.1.0/src/trailmark/analysis/preanalysis.py +318 -0
  19. trailmark-0.1.0/src/trailmark/cli.py +156 -0
  20. trailmark-0.1.0/src/trailmark/diagram.py +521 -0
  21. trailmark-0.1.0/src/trailmark/models/__init__.py +43 -0
  22. trailmark-0.1.0/src/trailmark/models/annotations.py +88 -0
  23. trailmark-0.1.0/src/trailmark/models/edges.py +37 -0
  24. trailmark-0.1.0/src/trailmark/models/graph.py +67 -0
  25. trailmark-0.1.0/src/trailmark/models/nodes.py +77 -0
  26. trailmark-0.1.0/src/trailmark/parsers/__init__.py +1 -0
  27. trailmark-0.1.0/src/trailmark/parsers/_common.py +260 -0
  28. trailmark-0.1.0/src/trailmark/parsers/base.py +24 -0
  29. trailmark-0.1.0/src/trailmark/parsers/c/__init__.py +5 -0
  30. trailmark-0.1.0/src/trailmark/parsers/c/parser.py +424 -0
  31. trailmark-0.1.0/src/trailmark/parsers/cairo/__init__.py +5 -0
  32. trailmark-0.1.0/src/trailmark/parsers/cairo/parser.py +605 -0
  33. trailmark-0.1.0/src/trailmark/parsers/circom/__init__.py +5 -0
  34. trailmark-0.1.0/src/trailmark/parsers/circom/parser.py +322 -0
  35. trailmark-0.1.0/src/trailmark/parsers/cpp/__init__.py +5 -0
  36. trailmark-0.1.0/src/trailmark/parsers/cpp/parser.py +638 -0
  37. trailmark-0.1.0/src/trailmark/parsers/csharp/__init__.py +5 -0
  38. trailmark-0.1.0/src/trailmark/parsers/csharp/parser.py +574 -0
  39. trailmark-0.1.0/src/trailmark/parsers/erlang/__init__.py +5 -0
  40. trailmark-0.1.0/src/trailmark/parsers/erlang/parser.py +621 -0
  41. trailmark-0.1.0/src/trailmark/parsers/go/__init__.py +5 -0
  42. trailmark-0.1.0/src/trailmark/parsers/go/parser.py +447 -0
  43. trailmark-0.1.0/src/trailmark/parsers/haskell/__init__.py +5 -0
  44. trailmark-0.1.0/src/trailmark/parsers/haskell/parser.py +691 -0
  45. trailmark-0.1.0/src/trailmark/parsers/java/__init__.py +5 -0
  46. trailmark-0.1.0/src/trailmark/parsers/java/parser.py +553 -0
  47. trailmark-0.1.0/src/trailmark/parsers/javascript/__init__.py +5 -0
  48. trailmark-0.1.0/src/trailmark/parsers/javascript/parser.py +612 -0
  49. trailmark-0.1.0/src/trailmark/parsers/masm/__init__.py +5 -0
  50. trailmark-0.1.0/src/trailmark/parsers/masm/parser.py +361 -0
  51. trailmark-0.1.0/src/trailmark/parsers/php/__init__.py +5 -0
  52. trailmark-0.1.0/src/trailmark/parsers/php/parser.py +560 -0
  53. trailmark-0.1.0/src/trailmark/parsers/python/__init__.py +5 -0
  54. trailmark-0.1.0/src/trailmark/parsers/python/parser.py +434 -0
  55. trailmark-0.1.0/src/trailmark/parsers/ruby/__init__.py +5 -0
  56. trailmark-0.1.0/src/trailmark/parsers/ruby/parser.py +523 -0
  57. trailmark-0.1.0/src/trailmark/parsers/rust/__init__.py +5 -0
  58. trailmark-0.1.0/src/trailmark/parsers/rust/parser.py +473 -0
  59. trailmark-0.1.0/src/trailmark/parsers/solidity/__init__.py +5 -0
  60. trailmark-0.1.0/src/trailmark/parsers/solidity/parser.py +430 -0
  61. trailmark-0.1.0/src/trailmark/parsers/typescript/__init__.py +5 -0
  62. trailmark-0.1.0/src/trailmark/parsers/typescript/parser.py +905 -0
  63. trailmark-0.1.0/src/trailmark/py.typed +0 -0
  64. trailmark-0.1.0/src/trailmark/query/__init__.py +5 -0
  65. trailmark-0.1.0/src/trailmark/query/api.py +286 -0
  66. trailmark-0.1.0/src/trailmark/storage/__init__.py +5 -0
  67. trailmark-0.1.0/src/trailmark/storage/graph_store.py +241 -0
  68. trailmark-0.1.0/src/trailmark/tree_sitter_custom/__init__.py +0 -0
  69. trailmark-0.1.0/src/trailmark/tree_sitter_custom/circom/LICENSE +21 -0
  70. trailmark-0.1.0/src/trailmark/tree_sitter_custom/circom/__init__.py +56 -0
  71. trailmark-0.1.0/src/trailmark/tree_sitter_custom/circom/binding.c +27 -0
  72. trailmark-0.1.0/src/trailmark/tree_sitter_custom/circom/grammar.js +495 -0
  73. trailmark-0.1.0/src/trailmark/tree_sitter_custom/circom/src/parser.c +12129 -0
  74. trailmark-0.1.0/src/trailmark/tree_sitter_custom/circom/src/tree_sitter/parser.h +266 -0
  75. trailmark-0.1.0/src/trailmark/tree_sitter_custom/masm/LICENSE +21 -0
  76. trailmark-0.1.0/src/trailmark/tree_sitter_custom/masm/__init__.py +55 -0
  77. trailmark-0.1.0/src/trailmark/tree_sitter_custom/masm/binding.c +27 -0
  78. trailmark-0.1.0/src/trailmark/tree_sitter_custom/masm/grammar.js +444 -0
  79. trailmark-0.1.0/src/trailmark/tree_sitter_custom/masm/src/parser.c +24046 -0
  80. trailmark-0.1.0/src/trailmark/tree_sitter_custom/masm/src/tree_sitter/alloc.h +54 -0
  81. trailmark-0.1.0/src/trailmark/tree_sitter_custom/masm/src/tree_sitter/array.h +291 -0
  82. trailmark-0.1.0/src/trailmark/tree_sitter_custom/masm/src/tree_sitter/parser.h +286 -0
  83. trailmark-0.1.0/tests/__init__.py +0 -0
  84. trailmark-0.1.0/tests/test_augment.py +612 -0
  85. trailmark-0.1.0/tests/test_c_parser.py +219 -0
  86. trailmark-0.1.0/tests/test_cairo_parser.py +341 -0
  87. trailmark-0.1.0/tests/test_circom_grammar.py +168 -0
  88. trailmark-0.1.0/tests/test_circom_parser.py +233 -0
  89. trailmark-0.1.0/tests/test_cli.py +516 -0
  90. trailmark-0.1.0/tests/test_cpp_parser.py +336 -0
  91. trailmark-0.1.0/tests/test_csharp_parser.py +284 -0
  92. trailmark-0.1.0/tests/test_diagram_script.py +380 -0
  93. trailmark-0.1.0/tests/test_erlang_parser.py +242 -0
  94. trailmark-0.1.0/tests/test_go_parser.py +247 -0
  95. trailmark-0.1.0/tests/test_haskell_parser.py +249 -0
  96. trailmark-0.1.0/tests/test_java_parser.py +276 -0
  97. trailmark-0.1.0/tests/test_javascript_parser.py +297 -0
  98. trailmark-0.1.0/tests/test_masm_parser.py +241 -0
  99. trailmark-0.1.0/tests/test_models.py +288 -0
  100. trailmark-0.1.0/tests/test_parser_edge_cases.py +533 -0
  101. trailmark-0.1.0/tests/test_php_parser.py +274 -0
  102. trailmark-0.1.0/tests/test_preanalysis.py +351 -0
  103. trailmark-0.1.0/tests/test_property_based.py +216 -0
  104. trailmark-0.1.0/tests/test_python_parser.py +257 -0
  105. trailmark-0.1.0/tests/test_query.py +587 -0
  106. trailmark-0.1.0/tests/test_query_edge_cases.py +64 -0
  107. trailmark-0.1.0/tests/test_ruby_parser.py +260 -0
  108. trailmark-0.1.0/tests/test_rust_parser.py +275 -0
  109. trailmark-0.1.0/tests/test_solidity_parser.py +311 -0
  110. trailmark-0.1.0/tests/test_storage.py +588 -0
  111. trailmark-0.1.0/tests/test_storage_edge_cases.py +75 -0
  112. trailmark-0.1.0/tests/test_typescript_parser.py +349 -0
  113. trailmark-0.1.0/uv.lock +742 -0
@@ -0,0 +1,21 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: pip
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ cooldown:
8
+ default-days: 7
9
+ groups:
10
+ all:
11
+ patterns: ["*"]
12
+
13
+ - package-ecosystem: github-actions
14
+ directory: /
15
+ schedule:
16
+ interval: weekly
17
+ cooldown:
18
+ default-days: 7
19
+ groups:
20
+ all:
21
+ patterns: ["*"]
@@ -0,0 +1,70 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ lint:
18
+ name: Lint
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22
+ with:
23
+ persist-credentials: false
24
+
25
+ - uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6 # v3.6.1
26
+ with:
27
+ args: check src/ tests/
28
+
29
+ - uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6 # v3.6.1
30
+ with:
31
+ args: format --check src/ tests/
32
+
33
+ type-check:
34
+ name: Type Check
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
38
+ with:
39
+ persist-credentials: false
40
+
41
+ - uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
42
+
43
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
44
+ with:
45
+ python-version: "3.13"
46
+
47
+ - run: uv sync --all-groups
48
+
49
+ - run: uv tool install ty && ty check
50
+
51
+ test:
52
+ name: Test
53
+ runs-on: ubuntu-latest
54
+ strategy:
55
+ matrix:
56
+ python-version: ["3.12", "3.13", "3.14"]
57
+ steps:
58
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59
+ with:
60
+ persist-credentials: false
61
+
62
+ - uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
63
+
64
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
65
+ with:
66
+ python-version: ${{ matrix.python-version }}
67
+
68
+ - run: uv sync --all-groups
69
+
70
+ - run: uv run pytest -q tests/
@@ -0,0 +1,38 @@
1
+ name: Mutation Testing
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ mutmut:
18
+ name: Mutation Testing
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22
+ with:
23
+ persist-credentials: false
24
+
25
+ - uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
26
+
27
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
28
+ with:
29
+ python-version: "3.13"
30
+
31
+ - run: uv sync --all-groups
32
+
33
+ - name: Run mutation testing
34
+ run: uv run mutmut run
35
+
36
+ - name: Show results
37
+ if: always()
38
+ run: uv run mutmut results
@@ -0,0 +1,54 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions: {}
8
+
9
+ jobs:
10
+ build:
11
+ name: Build
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ steps:
16
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17
+ with:
18
+ persist-credentials: false
19
+
20
+ - uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
21
+
22
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
23
+ with:
24
+ python-version: "3.13"
25
+
26
+ - run: uv build
27
+
28
+ - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
29
+ with:
30
+ name: dist
31
+ path: dist/
32
+
33
+ publish:
34
+ name: Publish
35
+ needs: build
36
+ runs-on: ubuntu-latest
37
+ environment: pypi
38
+ permissions:
39
+ id-token: write
40
+ attestations: write
41
+ contents: read
42
+ steps:
43
+ - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
44
+ with:
45
+ name: dist
46
+ path: dist/
47
+
48
+ - uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
49
+ with:
50
+ subject-path: "dist/*"
51
+
52
+ - uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
53
+ with:
54
+ attestations: true
@@ -0,0 +1,41 @@
1
+ name: Semgrep
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ semgrep:
18
+ name: Semgrep Scan
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22
+ with:
23
+ persist-credentials: false
24
+
25
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
26
+ with:
27
+ python-version: "3.13"
28
+
29
+ - name: Install Semgrep
30
+ run: pip install semgrep
31
+
32
+ - name: Run Semgrep
33
+ run: >
34
+ semgrep scan
35
+ --metrics=off
36
+ --error
37
+ --config p/python
38
+ --config p/security-audit
39
+ --config p/secrets
40
+ --include="*.py"
41
+ .
@@ -0,0 +1,33 @@
1
+ name: Zizmor
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - ".github/workflows/**"
8
+ pull_request:
9
+ branches: [main]
10
+ paths:
11
+ - ".github/workflows/**"
12
+
13
+ concurrency:
14
+ group: ${{ github.workflow }}-${{ github.ref }}
15
+ cancel-in-progress: true
16
+
17
+ permissions:
18
+ contents: read
19
+ actions: read
20
+
21
+ jobs:
22
+ zizmor:
23
+ name: Workflow Security Audit
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27
+ with:
28
+ persist-credentials: false
29
+
30
+ - uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2
31
+ with:
32
+ version: latest
33
+ advanced-security: false
@@ -0,0 +1,15 @@
1
+ .coverage
2
+ .hypothesis
3
+ .idea
4
+ .pytest_cache
5
+ .ruff_cache
6
+ .serena
7
+ .supply-chain-risk-auditor
8
+ /src/trailmark/__pycache__
9
+ /src/trailmark/*/__pycache__
10
+ /src/trailmark/*/*/__pycache__
11
+ /tests/__pycache__
12
+ *.pyc
13
+ mutants/
14
+ src/trailmark/tree_sitter_custom/**/*.so
15
+ src/trailmark/tree_sitter_custom/**/*.pyd
@@ -0,0 +1,90 @@
1
+ # Agents
2
+
3
+ Development context for AI agents working on this codebase.
4
+
5
+ ## Project Overview
6
+
7
+ Trailmark parses source code into directed graphs of functions, classes,
8
+ calls, and semantic metadata for security analysis. It supports 16
9
+ languages via tree-sitter (plus a bundled Circom grammar) and uses
10
+ rustworkx for graph traversal.
11
+
12
+ ## Architecture
13
+
14
+ ```
15
+ CodeGraph (data) -> GraphStore (indexed storage) -> QueryEngine (facade)
16
+ ```
17
+
18
+ - **CodeGraph** holds raw nodes, edges, annotations, entrypoints. Mutable.
19
+ - **GraphStore** wraps CodeGraph in a rustworkx PyDiGraph. Validates
20
+ node existence. Returns model objects.
21
+ - **QueryEngine** resolves names to node IDs, delegates to GraphStore,
22
+ returns plain dicts for JSON serialization.
23
+
24
+ ## Key Conventions
25
+
26
+ - All public methods return `False` or `[]` for missing nodes. Never raise.
27
+ - QueryEngine returns dicts; GraphStore returns model objects.
28
+ - Node IDs follow `module:function`, `module:Class`, `module:Class.method`.
29
+ - Edge confidence: `certain`, `inferred`, `uncertain`.
30
+ - Annotation sources: `"llm"`, `"docstring"`, `"manual"`.
31
+ - Frozen dataclasses for immutable data. `CodeGraph` is mutable.
32
+ - No relative (`..`) imports. Use `from trailmark.*`.
33
+
34
+ ## File Layout
35
+
36
+ ```
37
+ src/trailmark/
38
+ models/ # Data classes: CodeUnit, CodeEdge, Annotation, CodeGraph
39
+ graph.py # CodeGraph with add_annotation, clear_annotations, merge
40
+ nodes.py # CodeUnit, Parameter, TypeRef, BranchInfo
41
+ edges.py # CodeEdge, EdgeKind, EdgeConfidence
42
+ annotations.py # Annotation, AnnotationKind, EntrypointTag
43
+ parsers/ # Language-specific tree-sitter parsers
44
+ base.py # BaseParser protocol
45
+ _common.py # Shared parser utilities
46
+ python/ # One subpackage per language
47
+ javascript/
48
+ ...
49
+ storage/
50
+ graph_store.py # GraphStore: rustworkx-backed indexed storage
51
+ query/
52
+ api.py # QueryEngine: high-level facade
53
+ cli.py # CLI entry point
54
+ tests/ # pytest test suite
55
+ ```
56
+
57
+ ## Running Checks
58
+
59
+ ```bash
60
+ uv run ruff check --fix src/ tests/
61
+ uv run ruff format src/ tests/
62
+ uv run ty check
63
+ pytest -q
64
+ ```
65
+
66
+ ## Mutation Testing
67
+
68
+ ```bash
69
+ uv run mutmut run
70
+ uv run mutmut results
71
+ ```
72
+
73
+ ### macOS Fork Safety
74
+
75
+ mutmut uses `fork()` which segfaults with rustworkx on macOS. Set:
76
+
77
+ ```bash
78
+ export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
79
+ ```
80
+
81
+ This is not needed on Linux/CI (Ubuntu).
82
+
83
+ ## Adding Features
84
+
85
+ - Follow the three-layer pattern: add to CodeGraph first, then GraphStore
86
+ (with validation), then QueryEngine (with name resolution and dict
87
+ conversion).
88
+ - Add tests at each layer: `test_models.py`, `test_storage.py`,
89
+ `test_query.py`.
90
+ - Update `README.md` if adding user-facing API.
@@ -0,0 +1,80 @@
1
+ # Contributing to Trailmark
2
+
3
+ ## Setup
4
+
5
+ Requires Python >= 3.13 and [uv](https://docs.astral.sh/uv/).
6
+
7
+ ```bash
8
+ uv sync --all-groups
9
+ ```
10
+
11
+ ## Running Checks
12
+
13
+ Run all three before submitting changes:
14
+
15
+ ```bash
16
+ # Lint and format
17
+ uv run ruff check --fix src/ tests/
18
+ uv run ruff format src/ tests/
19
+
20
+ # Type check
21
+ uv run ty check
22
+
23
+ # Tests
24
+ pytest -q
25
+ ```
26
+
27
+ ## Mutation Testing
28
+
29
+ Trailmark uses [mutmut](https://mutmut.readthedocs.io/) to verify test
30
+ suite quality. Mutmut generates source code mutations and confirms that
31
+ tests catch each one.
32
+
33
+ ```bash
34
+ uv run mutmut run
35
+ uv run mutmut results
36
+ ```
37
+
38
+ ### macOS: Fork Safety
39
+
40
+ mutmut uses `fork()` to isolate mutation runs. On macOS, this conflicts
41
+ with the Objective-C runtime and with native extensions like rustworkx
42
+ (a Rust/C extension). You **must** set this environment variable:
43
+
44
+ ```bash
45
+ export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
46
+ ```
47
+
48
+ Without it, mutmut will segfault on every mutant. This is not needed on
49
+ Linux (CI runs on Ubuntu without issue).
50
+
51
+ ## Architecture
52
+
53
+ Trailmark has a three-layer architecture:
54
+
55
+ 1. **CodeGraph** (`src/trailmark/models/graph.py`) -- mutable data
56
+ container holding nodes, edges, annotations, and entrypoints.
57
+ 2. **GraphStore** (`src/trailmark/storage/graph_store.py`) -- wraps
58
+ CodeGraph in a rustworkx `PyDiGraph` with bidirectional ID/index
59
+ mappings. Validates node existence before mutations.
60
+ 3. **QueryEngine** (`src/trailmark/query/api.py`) -- high-level facade
61
+ that resolves names, delegates to GraphStore, and returns plain dicts.
62
+
63
+ ### Conventions
64
+
65
+ - **No exceptions for missing nodes.** All methods return `False` or `[]`
66
+ when a node is not found.
67
+ - **QueryEngine returns dicts**, GraphStore returns model objects.
68
+ - **Helper functions** like `_unit_to_dict()`, `_edge_to_dict()`,
69
+ `_annotation_to_dict()` live at module level alongside their class.
70
+ - **Frozen dataclasses** for immutable data (`CodeUnit`, `CodeEdge`,
71
+ `Annotation`). `CodeGraph` is mutable (not frozen).
72
+ - **No relative imports.** Use absolute imports from `trailmark.*`.
73
+
74
+ ## Adding a New Language Parser
75
+
76
+ 1. Create `src/trailmark/parsers/<lang>/parser.py` implementing the
77
+ `BaseParser` protocol from `src/trailmark/parsers/base.py`.
78
+ 2. Register the language in `src/trailmark/parsers/__init__.py`.
79
+ 3. Add tests in `tests/test_<lang>_parser.py`.
80
+ 4. Update the language table in `README.md`.
@@ -0,0 +1,200 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. Please do not edit this text;
186
+ you should only fill in the blanks.
187
+
188
+ Copyright 2025 Trail of Bits, Inc.
189
+
190
+ Licensed under the Apache License, Version 2.0 (the "License");
191
+ you may not use this file except in compliance with the License.
192
+ You may obtain a copy of the License at
193
+
194
+ http://www.apache.org/licenses/LICENSE-2.0
195
+
196
+ Unless required by applicable law or agreed to in writing, software
197
+ distributed under the License is distributed on an "AS IS" BASIS,
198
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199
+ See the License for the specific language governing permissions and
200
+ limitations under the License.
trailmark-0.1.0/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ Trailmark
2
+ Copyright 2026 Trail of Bits, Inc.
3
+
4
+ This product includes software developed at Trail of Bits, Inc.
5
+ (https://www.trailofbits.com/).
6
+
7
+ This product bundles the following third-party components:
8
+
9
+ - tree-sitter-circom grammar (src/trailmark/tree_sitter_custom/circom/)
10
+ Copyright 2024 Decurity
11
+ Licensed under the MIT License
12
+ https://github.com/nicedrop/tree-sitter-circom