coltrace 0.1.0.dev4__py3-none-any.whl

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.
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.4
2
+ Name: coltrace
3
+ Version: 0.1.0.dev4
4
+ Summary: Static Pandas column lineage, impact analysis, and local dependency graphs
5
+ Author: Cristiano Diniz
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: networkx<4,>=3.2
11
+ Requires-Dist: typer<1,>=0.12
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8; extra == "dev"
14
+ Requires-Dist: ruff>=0.9; extra == "dev"
15
+ Requires-Dist: mypy>=1.14; extra == "dev"
16
+ Requires-Dist: build>=1.2; extra == "dev"
17
+ Requires-Dist: types-networkx>=3.2; extra == "dev"
18
+ Provides-Extra: viz
19
+ Requires-Dist: pyvis<0.4,>=0.3.2; extra == "viz"
20
+ Dynamic: license-file
21
+
22
+ # ColTrace
23
+
24
+ Static Pandas column lineage and potential impact analysis for Python projects.
25
+ ColTrace reads source files, identifies supported transformations, and connects
26
+ column versions across direct function calls. It never imports or executes the
27
+ project or reads the project's input data.
28
+
29
+ **Development preview: `0.1.0.dev4`.** The supported subset is deliberately small.
30
+ Unsupported operations produce diagnostics and may interrupt lineage. A graph
31
+ with no edge is not proof that a dependency does not exist.
32
+
33
+ ## Install locally
34
+
35
+ Requires Python 3.11+. From this checkout:
36
+
37
+ ```sh
38
+ python -m venv .venv
39
+ # Activate .venv using your shell, then:
40
+ python -m pip install -e ".[dev,viz]"
41
+ coltrace --help
42
+ ```
43
+
44
+ On Windows without activation, use `.\.venv\Scripts\python.exe -m coltrace`.
45
+ The `viz` extra supplies PyVis for HTML export; basic analysis and JSON need only
46
+ NetworkX and Typer. Pandas is not a runtime dependency. Publication to PyPI is a
47
+ separate release step; these commands install the local project.
48
+
49
+ ## Try the complete example
50
+
51
+ ```sh
52
+ coltrace scan examples/pricing_pipeline
53
+ coltrace trace preco_referencia
54
+ coltrace impact preco_referencia
55
+ coltrace graph preco_referencia --open
56
+ coltrace export preco_referencia --format json --output .coltrace/pricing.json
57
+ ```
58
+
59
+ The example connects extraction, pricing, and feature functions through explicit
60
+ calls in `pipeline.py`. No `prices.csv` file is needed to analyze it.
61
+
62
+ ```text
63
+ valor_produto -> preco_bruto -> preco_referencia -> margem
64
+ | |
65
+ +--------------+-> margem_percentual
66
+ custo ---------------------------------------------> margem
67
+ ```
68
+
69
+ `impact preco_referencia` identifies `margem` and `margem_percentual` as direct
70
+ potential dependents. There is also a longer path through `margem`. A changed
71
+ input does not necessarily change every downstream value.
72
+
73
+ `scan` writes `.coltrace/scan.json` by default. `--out DIRECTORY` selects another
74
+ snapshot directory. Queries load that snapshot explicitly; they do not silently
75
+ rescan the project. Rescan after editing source, or use `--project DIRECTORY` to
76
+ analyze current files in memory. `--from FILE` selects an existing snapshot.
77
+
78
+ ```sh
79
+ coltrace trace margem --project examples/pricing_pipeline --upstream --depth 2
80
+ coltrace impact preco_referencia --from .coltrace/scan.json --evidence confirmed
81
+ coltrace graph --from .coltrace/scan.json --output .coltrace/all.html
82
+ ```
83
+
84
+ HTML files contain their visualization resources and work locally without a
85
+ server or CDN. A selected column opens its journey: direct reads, applications,
86
+ writes, derived columns and destinations. Frame passage is labeled separately
87
+ from a direct column read. Callback control and configuration appear in the
88
+ expandable creation history, rather than as direct uses of the selected column.
89
+ The graph uses generously spaced, numbered blocks in a vertical flow. The
90
+ scrollable sidebar contains the trace history, source code, and locations;
91
+ selecting a step highlights its matching graph block, and vice versa. Open Details
92
+ or Diagnostics without losing the current selection. The Outcomes tab shows
93
+ derived-column destinations and the DataFrames carrying the selected column.
94
+ Zoom in/out, use **Fit all**
95
+ for an overview, or **Reset view** to return to a readable scale.
96
+ `--view columns` shows the column dependency projection; `--operations` includes
97
+ operation nodes in that projection. A graph without a selected column shows the
98
+ whole project's column dependencies.
99
+
100
+ ```sh
101
+ coltrace scan examples/text_pipeline
102
+ coltrace trace comment_text --function process_train
103
+ coltrace graph comment_text --function process_train --open
104
+ ```
105
+
106
+ `trace` defaults to direct column actions, derived-column outcomes, and containing
107
+ DataFrames. `--full-history` includes creation ancestry and callback internals,
108
+ with control/configuration distinguished from value transformations.
109
+ `--diagnostics` also displays dependency lists and relevant diagnostics. Rescan after an
110
+ upgrade: schema 0.2 snapshots have no recorded history. See the
111
+ [column history guide](docs/column-history.md) and [current checkpoint](docs/history-checkpoint.md).
112
+ The [graph workspace checkpoint](docs/graph-workspace-checkpoint.md) describes the
113
+ current layout and [additional column checks](docs/other-column-checkpoint.md).
114
+ See the [column journey checkpoint](docs/column-journey-checkpoint.md) for the
115
+ usage-first view and its acceptance cases.
116
+
117
+ ## Identity and ambiguity
118
+
119
+ Different DataFrames keep different identities, even when both contain a column
120
+ named `score`. Assignments create column versions. `frame["a"] = frame["a"] + 1`
121
+ connects the old and new versions; `frame["a"] = 0` cuts the old value's lineage.
122
+ History still records that overwrite without adding a false value dependency.
123
+
124
+ Selection by name uses the latest observed version within each DataFrame. If
125
+ several unrelated identities remain, the CLI lists candidates and exits with status 3.
126
+ Same-name copies connected by proven pass-through relations form one selectable
127
+ family, whose original observed column is selected. A rename, value derivation,
128
+ or shared label alone does not establish that equivalence.
129
+ Select one explicitly using `--column-id ID` or `--dataframe ID`. Use `--version`
130
+ for an older version, and `--module` or `--function` for exact source filters.
131
+ IDs are opaque, deterministic within equivalent scans, and may change when source
132
+ locations or call contexts change. They are not permanent database keys.
133
+
134
+ `--depth` counts column-to-column hops. `--relation derive|rename|pass` filters
135
+ relations, while `--evidence confirmed|all` filters their evidence. Filtering out
136
+ intermediate relations can disconnect a path. Direct and transitive lists use
137
+ the shortest eligible distance, so a node reached both ways appears as direct.
138
+
139
+ ## Supported patterns
140
+
141
+ | Pattern | Support |
142
+ | --- | --- |
143
+ | Explicit Pandas imports and aliases | Recognized origins; names such as `df` alone are insufficient |
144
+ | `read_csv`, `read_parquet` | External schema is unknown; CSV chunk/iterator forms are excluded |
145
+ | Literal dictionary `DataFrame` construction | String column keys and literal values |
146
+ | `frame["column"]`, `frame.loc[:, "column"]` | Single literal string labels, all rows |
147
+ | `frame["c"] = frame["a"] + frame["b"]` | Arithmetic, scalar constants, temporary values, versions |
148
+ | `alias = frame` | Same abstract object and shared mutation |
149
+ | `rename(columns={"old": "new"})` | Literal, non-colliding map; new DataFrame, or shared mutation with `inplace=True` |
150
+ | `assign(b=lambda x: x["a"] * 2)` | Sequential simple lambdas; eager arguments use their original scope |
151
+ | `Series.apply(clean_text)` | Resolved scalar callbacks; bounded summaries and inferred evidence |
152
+ | `frame[["a", "b"]] = DataFrame(results.tolist(), index=frame.index)` | Fixed callback output width and matching source index |
153
+ | `dropna`, literal projection, boolean row filters | Preserve value lineage; predicate consumption tracked separately |
154
+ | `to_parquet` / `to_csv` | Located export consumption with literal options |
155
+ | Direct synchronous function calls | Explicit arguments/returns, bounded acyclic contexts and explicit imports |
156
+ | Annotated, uncalled functions | Separate inferred templates, not evidence of pipeline connections |
157
+
158
+ See [the supported subset and boundaries](docs/supported-patterns.md) for the exact
159
+ contract. Calls, branches, dynamic columns, and Pandas operations outside that
160
+ contract produce located diagnostics rather than invented connections.
161
+
162
+ The [text pipeline example](examples/text_pipeline/README.md) demonstrates
163
+ independent train/evaluation flows, multi-output text cleaning, row filters, and
164
+ exports. See the [NLP checkpoint](docs/nlp-checkpoint.md) for what was validated
165
+ against a real project and which downstream third-party operations remain opaque.
166
+
167
+ ## Evidence and completeness
168
+
169
+ - `confirmed`: supported syntax and receiver identity establish the relation.
170
+ - `inferred`: the relation depends on an explicit assumption, such as an uncalled
171
+ function's DataFrame annotation or an unknown external schema during rename.
172
+ - `unresolved`: insufficient evidence across an unsupported boundary.
173
+
174
+ `complete`, `partial`, and `unresolved` describe how much of an operation is
175
+ understood; evidence and completeness are separate. External column reads are
176
+ marked as external/unknown origins. They do not identify the real upstream data
177
+ source's column definition or guarantee its presence.
178
+
179
+ Use `--diagnostics` to inspect warnings and errors. Query output also includes
180
+ relevant gaps. An inconclusive trace prints `Not determined` for empty dependency
181
+ lists and shows the recognized DataFrame origin separately from column evidence.
182
+ See [troubleshooting incomplete traces](docs/troubleshooting.md).
183
+ The analyzer is not a Python type checker or an execution
184
+ validator. Its grammar is limited by the interpreter running ColTrace. Pandas
185
+ imports are assumed to refer to the real library; environment/module impersonation
186
+ is not resolved.
187
+
188
+ ## Python API
189
+
190
+ ```python
191
+ from coltrace import analyze_project
192
+ from coltrace.graph import LineageGraph
193
+
194
+ report = analyze_project("examples/pricing_pipeline")
195
+ graph = LineageGraph(report)
196
+ column = graph.select("preco_referencia")
197
+ impact = graph.impact(column.id)
198
+ print(report.to_json())
199
+ ```
200
+
201
+ The earlier `scan_project` API remains available for raw occurrences and receiver
202
+ evidence. Its discovery report (`0.1`) is a different format from the lineage
203
+ snapshot (`0.3`). See [discovery JSON](docs/discovery-json.md) and
204
+ [lineage JSON](docs/lineage-json.md). Public facts are dataclasses; their serialized
205
+ form is independent of NetworkX and contains no AST or executable objects.
206
+
207
+ ## Configuration
208
+
209
+ Only the scanned root's `pyproject.toml` is read:
210
+
211
+ ```toml
212
+ [tool.coltrace]
213
+ exclude = ["generated", "legacy/*.py", "*_test.py"]
214
+ ```
215
+
216
+ Glob patterns match case-sensitive, project-relative POSIX paths. Patterns with
217
+ no `/` also match individual path components. Built-in exclusions cover `.venv`,
218
+ `venv`, `.git`, `__pycache__`, `.coltrace`, pytest/mypy/Ruff caches, `build`, and
219
+ `dist`. Linked files/directories and Windows reparse points are skipped.
220
+ `ScanConfig(exclude=("generated",))` overrides TOML settings and extends built-ins.
221
+
222
+ ## Development
223
+
224
+ ```sh
225
+ python -m pytest -q
226
+ python -m ruff check src tests examples
227
+ python -m ruff format --check src tests examples
228
+ python -m mypy
229
+ python -m build
230
+ ```
231
+
232
+ Tests include independent expected dependencies, forbidden edges, alias/version
233
+ semantics, cross-module calls, CLI, malformed snapshots, offline HTML, and a
234
+ sentinel proving that analyzed source is not executed. See the
235
+ [accuracy protocol](docs/accuracy.md), [current checkpoint](docs/nlp-checkpoint.md),
236
+ [decision log](docs/decisions.md), and [backlog](docs/backlog.md).
237
+
238
+ The GitHub Actions workflow configures Windows/Linux with Python 3.11–3.13. It
239
+ must run in the repository before those combinations can be claimed as verified.
240
+
241
+ Licensed under the [MIT License](LICENSE). Copyright 2026 Cristiano Diniz.
@@ -0,0 +1,22 @@
1
+ coltrace/__init__.py,sha256=94i70hEERBM8qDz0xPiNIHaF9extfuAI07oGh1hv6rE,358
2
+ coltrace/__main__.py,sha256=XjZeA9-YaZ07jZrK-kQE7vmqTpG0dvFhYw_3nZlygSY,137
3
+ coltrace/analysis.py,sha256=F3cbHMgDaX6wcE7hy-tZ9T67Dt-HDG2XLTiVHvdHXw4,93365
4
+ coltrace/callbacks.py,sha256=YF-dqFKcKJrwpQ7Afy4EGMNDMuxiNedCQEOwOaNHrV8,24906
5
+ coltrace/cli.py,sha256=_3QL9TlGxlE2iF4yfwGKeclYMRZ6dwjMVxzGP04z6oc,27088
6
+ coltrace/collector.py,sha256=MKshuU6uG1QNFLAmjf6aJs9SXlew2NOtyvXqVJMr5Rs,21936
7
+ coltrace/exporters.py,sha256=OyshvS-Rm4Q_zfb0OxCiZ1DASonmh8CYXukfdp7RyrM,28433
8
+ coltrace/graph.py,sha256=6BhClA1VxBtEbq-J7iZJg09GTNISrx8Vp9x3mtHboWo,17529
9
+ coltrace/history.py,sha256=JE7P_U9NIYtzQWARbaU6xIVIluQIiQySxEtWxMp0z1E,17675
10
+ coltrace/journey.py,sha256=M60ZZm-74avYYEQCRGSyaHdVa-nNxKyxaftduyyPnyw,24827
11
+ coltrace/lineage_models.py,sha256=QEpxJ1NbDMbsOPCrstDHepmS7wYbvrnPUA8VCw66o0Q,2665
12
+ coltrace/models.py,sha256=8BJMdj9Z_WxWKyh3hrosaroYLghXJqoWvxlPHnO4lrQ,2246
13
+ coltrace/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ coltrace/scanner.py,sha256=zdILpuEPcJpzugby8CN-uy34h6-k2KuAfVfoCqBa66Q,8413
15
+ coltrace/visual_layout.py,sha256=1ICyfebm_cjixPrqfjv2FzLrf0k04GEDDw82bbcofDY,6708
16
+ coltrace/templates/graph.html,sha256=66NKL6egh6emU6jFLnesjmax5xfbmC_pihdNGFq9Ij4,30141
17
+ coltrace-0.1.0.dev4.dist-info/licenses/LICENSE,sha256=TLXAlpQbJLqXQZRfkicbF_sNmQDyL6yy04Rc1RT11Mo,1072
18
+ coltrace-0.1.0.dev4.dist-info/METADATA,sha256=H-vV2POPgq--APZcdL0JUO3s2PnxkzciJxiX0i46MoY,11962
19
+ coltrace-0.1.0.dev4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
20
+ coltrace-0.1.0.dev4.dist-info/entry_points.txt,sha256=nYK3AJlNnIRmGqc5nCR-bbGB90EoGtJcxE4uW00HnrE,46
21
+ coltrace-0.1.0.dev4.dist-info/top_level.txt,sha256=cvliY6pFzj97aZEYfG3MHSOOzCWxReXFIzv8ELMCVOU,9
22
+ coltrace-0.1.0.dev4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ coltrace = coltrace.cli:app
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cristiano Diniz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ coltrace