rootline 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 (72) hide show
  1. rootline-0.1.0/.env.example +3 -0
  2. rootline-0.1.0/.github/workflows/ci.yml +59 -0
  3. rootline-0.1.0/.github/workflows/release.yml +41 -0
  4. rootline-0.1.0/.gitignore +33 -0
  5. rootline-0.1.0/.pre-commit-config.yaml +13 -0
  6. rootline-0.1.0/.python-version +1 -0
  7. rootline-0.1.0/LICENSE +178 -0
  8. rootline-0.1.0/PKG-INFO +96 -0
  9. rootline-0.1.0/README.md +80 -0
  10. rootline-0.1.0/apps/api/pyproject.toml +13 -0
  11. rootline-0.1.0/apps/api/src/rootline_api/__init__.py +3 -0
  12. rootline-0.1.0/apps/api/src/rootline_api/app.py +141 -0
  13. rootline-0.1.0/apps/api/src/rootline_api/store.py +48 -0
  14. rootline-0.1.0/apps/web/README.md +6 -0
  15. rootline-0.1.0/apps/web/index.html +12 -0
  16. rootline-0.1.0/apps/web/package-lock.json +4050 -0
  17. rootline-0.1.0/apps/web/package.json +33 -0
  18. rootline-0.1.0/apps/web/reference/design-proposal.html +667 -0
  19. rootline-0.1.0/apps/web/src/App.test.tsx +45 -0
  20. rootline-0.1.0/apps/web/src/App.tsx +47 -0
  21. rootline-0.1.0/apps/web/src/api.ts +29 -0
  22. rootline-0.1.0/apps/web/src/components/CandidatesTable.tsx +70 -0
  23. rootline-0.1.0/apps/web/src/components/Explanation.tsx +38 -0
  24. rootline-0.1.0/apps/web/src/data/sample.ts +25 -0
  25. rootline-0.1.0/apps/web/src/graph/GraphExplorer.test.tsx +43 -0
  26. rootline-0.1.0/apps/web/src/graph/GraphExplorer.tsx +85 -0
  27. rootline-0.1.0/apps/web/src/graph/cytoscape.ts +108 -0
  28. rootline-0.1.0/apps/web/src/index.css +9 -0
  29. rootline-0.1.0/apps/web/src/main.tsx +15 -0
  30. rootline-0.1.0/apps/web/src/store.ts +16 -0
  31. rootline-0.1.0/apps/web/src/types.ts +26 -0
  32. rootline-0.1.0/apps/web/src/useAnalysis.ts +20 -0
  33. rootline-0.1.0/apps/web/src/vite-env.d.ts +1 -0
  34. rootline-0.1.0/apps/web/tsconfig.json +16 -0
  35. rootline-0.1.0/apps/web/vite.config.ts +10 -0
  36. rootline-0.1.0/examples/regression-01/README.md +9 -0
  37. rootline-0.1.0/examples/regression-02/README.md +11 -0
  38. rootline-0.1.0/packages/cli/pyproject.toml +16 -0
  39. rootline-0.1.0/packages/cli/src/rootline_cli/__init__.py +3 -0
  40. rootline-0.1.0/packages/cli/src/rootline_cli/benchmark.py +68 -0
  41. rootline-0.1.0/packages/cli/src/rootline_cli/cli.py +268 -0
  42. rootline-0.1.0/packages/core/pyproject.toml +12 -0
  43. rootline-0.1.0/packages/core/src/rootline_core/__init__.py +3 -0
  44. rootline-0.1.0/packages/core/src/rootline_core/blast.py +49 -0
  45. rootline-0.1.0/packages/core/src/rootline_core/config.py +41 -0
  46. rootline-0.1.0/packages/core/src/rootline_core/corpus.py +99 -0
  47. rootline-0.1.0/packages/core/src/rootline_core/explain.py +28 -0
  48. rootline-0.1.0/packages/core/src/rootline_core/export.py +28 -0
  49. rootline-0.1.0/packages/core/src/rootline_core/git.py +81 -0
  50. rootline-0.1.0/packages/core/src/rootline_core/graph.py +126 -0
  51. rootline-0.1.0/packages/core/src/rootline_core/junit.py +81 -0
  52. rootline-0.1.0/packages/core/src/rootline_core/parsers/__init__.py +6 -0
  53. rootline-0.1.0/packages/core/src/rootline_core/parsers/base.py +30 -0
  54. rootline-0.1.0/packages/core/src/rootline_core/parsers/python_lang.py +86 -0
  55. rootline-0.1.0/packages/core/src/rootline_core/parsers/registry.py +44 -0
  56. rootline-0.1.0/packages/core/src/rootline_core/parsers/ts_lang.py +120 -0
  57. rootline-0.1.0/packages/core/src/rootline_core/pipeline.py +43 -0
  58. rootline-0.1.0/packages/core/src/rootline_core/ranking.py +180 -0
  59. rootline-0.1.0/packages/core/src/rootline_core/report.py +62 -0
  60. rootline-0.1.0/pyproject.toml +56 -0
  61. rootline-0.1.0/src/rootline/__init__.py +3 -0
  62. rootline-0.1.0/src/rootline/__main__.py +6 -0
  63. rootline-0.1.0/tests/test_api.py +66 -0
  64. rootline-0.1.0/tests/test_benchmark.py +23 -0
  65. rootline-0.1.0/tests/test_bootstrap.py +9 -0
  66. rootline-0.1.0/tests/test_cli.py +119 -0
  67. rootline-0.1.0/tests/test_git.py +57 -0
  68. rootline-0.1.0/tests/test_junit.py +61 -0
  69. rootline-0.1.0/tests/test_parsers.py +101 -0
  70. rootline-0.1.0/tests/test_ranking.py +99 -0
  71. rootline-0.1.0/uv.lock +823 -0
  72. rootline-0.1.0/workers/api/README.md +5 -0
@@ -0,0 +1,3 @@
1
+ # Rootline local defaults (no secrets here)
2
+ DATABASE_URL=sqlite:///./rootline.db
3
+ ROOTLINE_LOG_LEVEL=info
@@ -0,0 +1,59 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: astral-sh/setup-uv@v3
15
+ with:
16
+ python-version: "3.13"
17
+ - run: uv sync --group dev
18
+ - run: uvx ruff check .
19
+ - run: uvx ruff format --check .
20
+
21
+ type:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - uses: astral-sh/setup-uv@v3
26
+ with:
27
+ python-version: "3.13"
28
+ - run: uv sync --group dev
29
+ - run: uv run mypy packages apps/api/src src
30
+ - run: uv build
31
+
32
+ test:
33
+ strategy:
34
+ matrix:
35
+ os: [ubuntu-latest, windows-latest]
36
+ runs-on: ${{ matrix.os }}
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+ - uses: astral-sh/setup-uv@v3
40
+ with:
41
+ python-version: "3.13"
42
+ - run: uv sync --group dev
43
+ - run: uv run pytest -q
44
+
45
+ dashboard:
46
+ runs-on: ubuntu-latest
47
+ defaults:
48
+ run:
49
+ working-directory: apps/web
50
+ steps:
51
+ - uses: actions/checkout@v4
52
+ - uses: actions/setup-node@v4
53
+ with:
54
+ node-version: 24
55
+ cache: npm
56
+ cache-dependency-path: apps/web/package-lock.json
57
+ - run: npm ci
58
+ - run: npm test -- --run
59
+ - run: npm run build
@@ -0,0 +1,41 @@
1
+ name: Release
2
+
3
+ # Publishes to PyPI via trusted publishing (OIDC, no tokens).
4
+ # One-time manual setup (no credit card):
5
+ # 1. Create an account at https://pypi.org/account/register/
6
+ # 2. Register the project name (or add a pending publisher for
7
+ # github.com/Pa004/rootline with workflow name "Release").
8
+ # 3. Push a tag matching pyproject.toml version, e.g. `git push origin v0.1.0`.
9
+ # If the `rootline` name is taken, rename the project first (see Rootline.md).
10
+
11
+ on:
12
+ push:
13
+ tags:
14
+ - "v*"
15
+
16
+ jobs:
17
+ build:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: astral-sh/setup-uv@v3
22
+ with:
23
+ python-version: "3.13"
24
+ - run: uv build
25
+ - uses: actions/upload-artifact@v4
26
+ with:
27
+ name: dist
28
+ path: dist/
29
+
30
+ publish:
31
+ needs: build
32
+ runs-on: ubuntu-latest
33
+ permissions:
34
+ id-token: write
35
+ contents: read
36
+ steps:
37
+ - uses: actions/download-artifact@v4
38
+ with:
39
+ name: dist
40
+ path: dist/
41
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,33 @@
1
+ # Ignore all markdown except README
2
+ *.md
3
+ !README.md
4
+ !README.*.md
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.py[cod]
9
+ *.egg-info/
10
+ .eggs/
11
+ .venv/
12
+ .pytest_cache/
13
+ .mypy_cache/
14
+ .ruff_cache/
15
+
16
+ # uv
17
+ .uv/
18
+
19
+ # Node (Phase 3+)
20
+ node_modules/
21
+ dist/
22
+ *.tsbuildinfo
23
+
24
+ # Env / local
25
+ .env
26
+ *.db
27
+ *.sqlite3
28
+
29
+ # OS / editors
30
+ .DS_Store
31
+ Thumbs.db
32
+ .vscode/
33
+ .idea/
@@ -0,0 +1,13 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: end-of-file-fixer
7
+ - id: check-yaml
8
+ - id: check-toml
9
+ - repo: https://github.com/astral-sh/ruff-pre-commit
10
+ rev: v0.8.0
11
+ hooks:
12
+ - id: ruff
13
+ - id: ruff-format
@@ -0,0 +1 @@
1
+ 3.13
rootline-0.1.0/LICENSE ADDED
@@ -0,0 +1,178 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Rootline Contributors
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.5
2
+ Name: rootline
3
+ Version: 0.1.0
4
+ Summary: Trace the change. Find the cause.
5
+ Project-URL: repository, https://github.com/Pa004/rootline
6
+ Author: Pablo Domínguez
7
+ License: Apache-2.0
8
+ License-File: LICENSE
9
+ Keywords: causal-analysis,debugging,git,regression
10
+ Requires-Python: >=3.13
11
+ Requires-Dist: pyyaml>=6.0
12
+ Requires-Dist: rootline-api
13
+ Requires-Dist: rootline-cli
14
+ Requires-Dist: rootline-core
15
+ Description-Content-Type: text/markdown
16
+
17
+ # Rootline
18
+
19
+ > **Trace the change. Find the cause.**
20
+
21
+ Causal evidence analysis for software regressions: given a Git repository plus a
22
+ failing test, Rootline ranks candidate causal changes with supporting and
23
+ contradictory evidence — fully local, no paid services.
24
+
25
+ Status: **MVP core** — CLI + API over a causal evidence graph
26
+ (Python + TypeScript). The full specification lives in `Rootline.md`
27
+ (local working spec, git-ignored by design).
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ uv sync
33
+ ```
34
+
35
+ Requires Python 3.13+ and a git binary. No accounts, no paid services.
36
+
37
+ ## CLI usage
38
+
39
+ ```bash
40
+ uv run rootline analyze ./repo \
41
+ --test-results results.xml \
42
+ --baseline main \
43
+ --max-commits 50 \
44
+ --fail-on low \
45
+ --output analysis.json
46
+ uv run rootline candidates analysis.json
47
+ uv run rootline explain analysis.json
48
+ uv run rootline report analysis.json -o report.html
49
+ uv run rootline verify <sha> --test test_create_user
50
+ uv run rootline blast-radius <sha>
51
+ uv run rootline benchmark
52
+ ```
53
+
54
+ Exit codes: `0` clean, `1` regression found (or benchmark Top-1 miss),
55
+ `2` usage/analysis error. `rootline init` writes a sample `rootline.toml`
56
+ with evidence weights.
57
+
58
+ ## API usage
59
+
60
+ ```bash
61
+ uv run uvicorn rootline_api.app:create_app --factory --port 8000
62
+ ```
63
+
64
+ Endpoints (`GET` paginated with `limit`/`cursor`):
65
+
66
+ ```http
67
+ POST /api/v1/analyses
68
+ GET /api/v1/analyses/{id}
69
+ GET /api/v1/analyses/{id}/candidates
70
+ GET /api/v1/analyses/{id}/graph
71
+ GET /api/v1/analyses/{id}/evidence/{sha}
72
+ ```
73
+
74
+ OpenAPI docs at `/docs` when the server runs.
75
+
76
+ ## Layout
77
+
78
+ ```text
79
+ rootline/
80
+ ├── apps/api/ # FastAPI (uv workspace member)
81
+ ├── apps/web/ # React + Vite + Cytoscape.js (Phase 3)
82
+ ├── workers/api/ # Cloudflare Python Worker demo, read-only (Phase 4)
83
+ ├── packages/core/ # Evidence graph + ranking
84
+ ├── packages/cli/ # Typer CLI
85
+ ├── examples/ # Regression corpus with ground truth
86
+ └── tests/ # Bootstrap + unit tests
87
+ ```
88
+
89
+ ## Deploy
90
+
91
+ Local-first with `uv run` — no Docker required. Public demo on Cloudflare
92
+ Pages + Python Worker + D1/R2, free tier without credit card. See spec §26.
93
+
94
+ ## License
95
+
96
+ [Apache-2.0](LICENSE)
@@ -0,0 +1,80 @@
1
+ # Rootline
2
+
3
+ > **Trace the change. Find the cause.**
4
+
5
+ Causal evidence analysis for software regressions: given a Git repository plus a
6
+ failing test, Rootline ranks candidate causal changes with supporting and
7
+ contradictory evidence — fully local, no paid services.
8
+
9
+ Status: **MVP core** — CLI + API over a causal evidence graph
10
+ (Python + TypeScript). The full specification lives in `Rootline.md`
11
+ (local working spec, git-ignored by design).
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ uv sync
17
+ ```
18
+
19
+ Requires Python 3.13+ and a git binary. No accounts, no paid services.
20
+
21
+ ## CLI usage
22
+
23
+ ```bash
24
+ uv run rootline analyze ./repo \
25
+ --test-results results.xml \
26
+ --baseline main \
27
+ --max-commits 50 \
28
+ --fail-on low \
29
+ --output analysis.json
30
+ uv run rootline candidates analysis.json
31
+ uv run rootline explain analysis.json
32
+ uv run rootline report analysis.json -o report.html
33
+ uv run rootline verify <sha> --test test_create_user
34
+ uv run rootline blast-radius <sha>
35
+ uv run rootline benchmark
36
+ ```
37
+
38
+ Exit codes: `0` clean, `1` regression found (or benchmark Top-1 miss),
39
+ `2` usage/analysis error. `rootline init` writes a sample `rootline.toml`
40
+ with evidence weights.
41
+
42
+ ## API usage
43
+
44
+ ```bash
45
+ uv run uvicorn rootline_api.app:create_app --factory --port 8000
46
+ ```
47
+
48
+ Endpoints (`GET` paginated with `limit`/`cursor`):
49
+
50
+ ```http
51
+ POST /api/v1/analyses
52
+ GET /api/v1/analyses/{id}
53
+ GET /api/v1/analyses/{id}/candidates
54
+ GET /api/v1/analyses/{id}/graph
55
+ GET /api/v1/analyses/{id}/evidence/{sha}
56
+ ```
57
+
58
+ OpenAPI docs at `/docs` when the server runs.
59
+
60
+ ## Layout
61
+
62
+ ```text
63
+ rootline/
64
+ ├── apps/api/ # FastAPI (uv workspace member)
65
+ ├── apps/web/ # React + Vite + Cytoscape.js (Phase 3)
66
+ ├── workers/api/ # Cloudflare Python Worker demo, read-only (Phase 4)
67
+ ├── packages/core/ # Evidence graph + ranking
68
+ ├── packages/cli/ # Typer CLI
69
+ ├── examples/ # Regression corpus with ground truth
70
+ └── tests/ # Bootstrap + unit tests
71
+ ```
72
+
73
+ ## Deploy
74
+
75
+ Local-first with `uv run` — no Docker required. Public demo on Cloudflare
76
+ Pages + Python Worker + D1/R2, free tier without credit card. See spec §26.
77
+
78
+ ## License
79
+
80
+ [Apache-2.0](LICENSE)
@@ -0,0 +1,13 @@
1
+ [project]
2
+ name = "rootline-api"
3
+ version = "0.1.0"
4
+ description = "Rootline API (FastAPI). Phase 1+."
5
+ requires-python = ">=3.13"
6
+ dependencies = [
7
+ "rootline-core",
8
+ "fastapi>=0.115",
9
+ "uvicorn>=0.30",
10
+ ]
11
+
12
+ [tool.uv.sources]
13
+ rootline-core = { workspace = true }
@@ -0,0 +1,3 @@
1
+ """Rootline API (FastAPI). Phase 1+."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,141 @@
1
+ """Rootline API (spec §16). Local full mode; demo caps arrive with deploy."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ from fastapi import FastAPI, HTTPException, Request
8
+ from pydantic import BaseModel, ConfigDict
9
+ from rootline_core.pipeline import run_analysis
10
+ from rootline_core.ranking import CandidateScore
11
+
12
+ from rootline_api.store import FileStore, UnknownAnalysisError
13
+
14
+ DEFAULT_LIMIT = 50
15
+
16
+
17
+ class AnalysisRequest(BaseModel):
18
+ model_config = ConfigDict(frozen=True)
19
+
20
+ repo: str
21
+ test_results: str | None = None
22
+ baseline: str = "HEAD~50"
23
+ max_commits: int = 50
24
+ max_files: int = 500
25
+ config: str | None = None
26
+
27
+
28
+ class AnalysisCreated(BaseModel):
29
+ model_config = ConfigDict(frozen=True)
30
+
31
+ id: str
32
+ candidate_count: int
33
+ top_sha: str | None
34
+ top_score: float | None
35
+
36
+
37
+ class CandidatePage(BaseModel):
38
+ model_config = ConfigDict(frozen=True)
39
+
40
+ items: list[CandidateScore]
41
+ next_cursor: str | None
42
+
43
+
44
+ class GraphPage(BaseModel):
45
+ model_config = ConfigDict(frozen=True)
46
+
47
+ nodes: list[dict[str, str]]
48
+ edges: list[dict[str, str]]
49
+ next_cursor: str | None
50
+
51
+
52
+ def create_app(store_dir: str | Path | None = None) -> FastAPI:
53
+ store = FileStore(store_dir or Path("analyses"))
54
+ app = FastAPI(title="Rootline API")
55
+ app.state.store = store
56
+
57
+ def _store(request: Request) -> FileStore:
58
+ store = request.app.state.store
59
+ assert isinstance(store, FileStore)
60
+ return store
61
+
62
+ @app.post("/api/v1/analyses", response_model=AnalysisCreated)
63
+ def create_analysis(body: AnalysisRequest, request: Request) -> AnalysisCreated:
64
+ try:
65
+ run = run_analysis(
66
+ body.repo,
67
+ body.test_results,
68
+ body.baseline,
69
+ body.max_commits,
70
+ body.max_files,
71
+ body.config,
72
+ )
73
+ except Exception as exc:
74
+ raise HTTPException(status_code=400, detail=str(exc)) from exc
75
+ analysis_id = _store(request).save(run.analysis, run.graph)
76
+ top = run.analysis.candidates[0] if run.analysis.candidates else None
77
+ return AnalysisCreated(
78
+ id=analysis_id,
79
+ candidate_count=len(run.analysis.candidates),
80
+ top_sha=top.commit_sha if top else None,
81
+ top_score=top.score if top else None,
82
+ )
83
+
84
+ @app.get("/api/v1/analyses/{analysis_id}")
85
+ def get_analysis(analysis_id: str, request: Request) -> dict[str, object]:
86
+ try:
87
+ analysis = _store(request).load_analysis(analysis_id)
88
+ except UnknownAnalysisError as exc:
89
+ raise HTTPException(status_code=404, detail="Unknown analysis.") from exc
90
+ return analysis.model_dump(mode="json")
91
+
92
+ @app.get("/api/v1/analyses/{analysis_id}/candidates", response_model=CandidatePage)
93
+ def get_candidates(
94
+ analysis_id: str, request: Request, limit: int = DEFAULT_LIMIT, cursor: str = "0"
95
+ ) -> CandidatePage:
96
+ try:
97
+ candidates = _store(request).load_analysis(analysis_id).candidates
98
+ except UnknownAnalysisError as exc:
99
+ raise HTTPException(status_code=404, detail="Unknown analysis.") from exc
100
+ items, next_cursor = _page(candidates, limit, cursor)
101
+ return CandidatePage(items=items, next_cursor=next_cursor)
102
+
103
+ @app.get("/api/v1/analyses/{analysis_id}/graph", response_model=GraphPage)
104
+ def get_graph(
105
+ analysis_id: str, request: Request, limit: int = DEFAULT_LIMIT, cursor: str = "0"
106
+ ) -> GraphPage:
107
+ try:
108
+ graph = _store(request).load_graph(analysis_id)
109
+ except UnknownAnalysisError as exc:
110
+ raise HTTPException(status_code=404, detail="Unknown analysis.") from exc
111
+ nodes = [{"id": n, **{k: str(v) for k, v in graph.nodes[n].items()}} for n in graph.nodes]
112
+ edges = [
113
+ {"source": str(u), "target": str(v), **{k: str(x) for k, x in d.items()}}
114
+ for u, v, d in graph.edges(data=True)
115
+ ]
116
+ node_items, node_cursor = _page(nodes, limit, cursor)
117
+ edge_items, _ = _page(edges, limit, cursor)
118
+ return GraphPage(nodes=node_items, edges=edge_items, next_cursor=node_cursor)
119
+
120
+ @app.get("/api/v1/analyses/{analysis_id}/evidence/{sha}")
121
+ def get_evidence(analysis_id: str, sha: str, request: Request) -> dict[str, object]:
122
+ try:
123
+ candidates = _store(request).load_analysis(analysis_id).candidates
124
+ except UnknownAnalysisError as exc:
125
+ raise HTTPException(status_code=404, detail="Unknown analysis.") from exc
126
+ match = next((c for c in candidates if c.commit_sha.startswith(sha)), None)
127
+ if match is None:
128
+ raise HTTPException(status_code=404, detail="Unknown candidate.")
129
+ return match.model_dump(mode="json")
130
+
131
+ return app
132
+
133
+
134
+ def _page[T](items: list[T], limit: int, cursor: str) -> tuple[list[T], str | None]:
135
+ try:
136
+ offset = max(int(cursor), 0)
137
+ except ValueError:
138
+ offset = 0
139
+ window = items[offset : offset + max(limit, 1)]
140
+ rest = offset + max(limit, 1)
141
+ return window, (str(rest) if rest < len(items) else None)