astscribe 0.8.2__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 (86) hide show
  1. astscribe-0.8.2/CHANGELOG.md +226 -0
  2. astscribe-0.8.2/CITATION.cff +12 -0
  3. astscribe-0.8.2/CODE_OF_CONDUCT.md +7 -0
  4. astscribe-0.8.2/CONTRIBUTING.md +37 -0
  5. astscribe-0.8.2/LICENSE +201 -0
  6. astscribe-0.8.2/MANIFEST.in +8 -0
  7. astscribe-0.8.2/NOTICE +5 -0
  8. astscribe-0.8.2/PKG-INFO +134 -0
  9. astscribe-0.8.2/README.md +96 -0
  10. astscribe-0.8.2/SECURITY.md +7 -0
  11. astscribe-0.8.2/docs/cell_dependency_graph.md +164 -0
  12. astscribe-0.8.2/docs/datasets_quantization.md +80 -0
  13. astscribe-0.8.2/docs/experiment_pipeline.md +120 -0
  14. astscribe-0.8.2/docs/notebook_diagnostics.md +141 -0
  15. astscribe-0.8.2/docs/peft_semantics.md +102 -0
  16. astscribe-0.8.2/docs/releasing.md +57 -0
  17. astscribe-0.8.2/docs/transformers_semantics.md +128 -0
  18. astscribe-0.8.2/examples/analyze_notebook.py +13 -0
  19. astscribe-0.8.2/examples/basic_training.py +13 -0
  20. astscribe-0.8.2/examples/dependency_graph.py +47 -0
  21. astscribe-0.8.2/examples/inference.py +9 -0
  22. astscribe-0.8.2/pyproject.toml +86 -0
  23. astscribe-0.8.2/setup.cfg +4 -0
  24. astscribe-0.8.2/src/astscribe/__init__.py +37 -0
  25. astscribe-0.8.2/src/astscribe/__main__.py +3 -0
  26. astscribe-0.8.2/src/astscribe/api.py +52 -0
  27. astscribe-0.8.2/src/astscribe/cli.py +84 -0
  28. astscribe-0.8.2/src/astscribe/dependency.py +351 -0
  29. astscribe-0.8.2/src/astscribe/diagnostics.py +157 -0
  30. astscribe-0.8.2/src/astscribe/impact.py +220 -0
  31. astscribe-0.8.2/src/astscribe/ipython/__init__.py +3 -0
  32. astscribe-0.8.2/src/astscribe/ipython/magic.py +18 -0
  33. astscribe-0.8.2/src/astscribe/methodology.py +244 -0
  34. astscribe-0.8.2/src/astscribe/notebook.py +233 -0
  35. astscribe-0.8.2/src/astscribe/parser/__init__.py +13 -0
  36. astscribe-0.8.2/src/astscribe/parser/ast_parser.py +24 -0
  37. astscribe-0.8.2/src/astscribe/parser/imports.py +32 -0
  38. astscribe-0.8.2/src/astscribe/parser/symbols.py +155 -0
  39. astscribe-0.8.2/src/astscribe/patterns/__init__.py +4 -0
  40. astscribe-0.8.2/src/astscribe/patterns/evaluation.py +7 -0
  41. astscribe-0.8.2/src/astscribe/patterns/inference.py +19 -0
  42. astscribe-0.8.2/src/astscribe/patterns/training.py +23 -0
  43. astscribe-0.8.2/src/astscribe/pipeline.py +144 -0
  44. astscribe-0.8.2/src/astscribe/py.typed +1 -0
  45. astscribe-0.8.2/src/astscribe/renderers/__init__.py +20 -0
  46. astscribe-0.8.2/src/astscribe/renderers/concise.py +13 -0
  47. astscribe-0.8.2/src/astscribe/renderers/educational.py +11 -0
  48. astscribe-0.8.2/src/astscribe/renderers/scientific.py +43 -0
  49. astscribe-0.8.2/src/astscribe/semantics/__init__.py +3 -0
  50. astscribe-0.8.2/src/astscribe/semantics/datasets.py +260 -0
  51. astscribe-0.8.2/src/astscribe/semantics/peft.py +372 -0
  52. astscribe-0.8.2/src/astscribe/semantics/pytorch.py +615 -0
  53. astscribe-0.8.2/src/astscribe/semantics/pytorch_experiment.py +418 -0
  54. astscribe-0.8.2/src/astscribe/semantics/pytorch_reproducibility.py +149 -0
  55. astscribe-0.8.2/src/astscribe/semantics/registry.py +54 -0
  56. astscribe-0.8.2/src/astscribe/semantics/transformers.py +520 -0
  57. astscribe-0.8.2/src/astscribe/semantics/transformers_models.py +197 -0
  58. astscribe-0.8.2/src/astscribe/semantics/transformers_quantization.py +212 -0
  59. astscribe-0.8.2/src/astscribe/sir/__init__.py +19 -0
  60. astscribe-0.8.2/src/astscribe/sir/nodes.py +90 -0
  61. astscribe-0.8.2/src/astscribe/techniques.py +110 -0
  62. astscribe-0.8.2/src/astscribe.egg-info/PKG-INFO +134 -0
  63. astscribe-0.8.2/src/astscribe.egg-info/SOURCES.txt +84 -0
  64. astscribe-0.8.2/src/astscribe.egg-info/dependency_links.txt +1 -0
  65. astscribe-0.8.2/src/astscribe.egg-info/entry_points.txt +2 -0
  66. astscribe-0.8.2/src/astscribe.egg-info/requires.txt +11 -0
  67. astscribe-0.8.2/src/astscribe.egg-info/top_level.txt +1 -0
  68. astscribe-0.8.2/tests/test_advanced_pytorch.py +74 -0
  69. astscribe-0.8.2/tests/test_api.py +24 -0
  70. astscribe-0.8.2/tests/test_cli.py +81 -0
  71. astscribe-0.8.2/tests/test_datasets_quantization.py +150 -0
  72. astscribe-0.8.2/tests/test_dependency_graph.py +155 -0
  73. astscribe-0.8.2/tests/test_diagnostics.py +129 -0
  74. astscribe-0.8.2/tests/test_experiment_pipeline.py +110 -0
  75. astscribe-0.8.2/tests/test_impact.py +149 -0
  76. astscribe-0.8.2/tests/test_imports_symbols.py +15 -0
  77. astscribe-0.8.2/tests/test_ipynb.py +61 -0
  78. astscribe-0.8.2/tests/test_methodology.py +45 -0
  79. astscribe-0.8.2/tests/test_notebook_context.py +74 -0
  80. astscribe-0.8.2/tests/test_peft.py +125 -0
  81. astscribe-0.8.2/tests/test_pipeline.py +40 -0
  82. astscribe-0.8.2/tests/test_pytorch.py +48 -0
  83. astscribe-0.8.2/tests/test_reproducibility.py +47 -0
  84. astscribe-0.8.2/tests/test_safety.py +11 -0
  85. astscribe-0.8.2/tests/test_serialization.py +8 -0
  86. astscribe-0.8.2/tests/test_transformers.py +176 -0
@@ -0,0 +1,226 @@
1
+ # Changelog
2
+
3
+ All notable changes to ASTScribe will be documented in this file.
4
+
5
+ Versions 0.1.0 through 0.7.0 were internal development milestones and were not
6
+ published to PyPI.
7
+
8
+ ## [0.8.2] - 2026-10-06
9
+
10
+ ### Added
11
+
12
+ - A `--strict` CLI option for notebooks, allowing CI and validation workflows to fail when a code cell is not valid Python instead of silently skipping it.
13
+ - A PyPI downloads badge alongside the existing PyPI version and supported-Python badges.
14
+
15
+ ### Changed
16
+
17
+ - Simplified the README further around installation, quick-start usage, notebook reports, CLI examples, and supported semantics.
18
+ - Made the release checklist version-agnostic and aligned it with the actual dynamic version source.
19
+ - Made the production release workflow self-contained: it can be run from Actions, derives the version, validates/builds first, creates the annotated tag, publishes to PyPI, and creates the GitHub Release.
20
+
21
+ ### Fixed
22
+
23
+ - Removed the misleading release-checklist instruction to compare `pyproject.toml` with the package version even though the project declares its version dynamically.
24
+
25
+ ## [0.8.1] - 2026-10-06
26
+
27
+ ### Added
28
+
29
+ - Command-line support for reading Python source from standard input with `astscribe -`, making ASTScribe easier to use in pipes and CI workflows.
30
+
31
+ ### Changed
32
+
33
+ - Simplified the README around installation, core usage, notebook analysis, CLI examples, and semantic scope.
34
+ - Added PyPI version and supported-Python badges to the README.
35
+
36
+ ### Fixed
37
+
38
+ - Invalid notebook files whose JSON root is not an object now raise a clear validation error instead of leaking an `AttributeError` through the CLI.
39
+
40
+ ## [0.8.0] - 2026-10-06
41
+
42
+ ### Added
43
+
44
+ - Transitive notebook impact analysis, propagation paths, prerequisite discovery, and impact ranking.
45
+ - Command-line interface for Python explanations and notebook methodology, pipeline, technique, dependency, diagnostic, and impact reports.
46
+ - `py.typed` marker for typed-library consumers.
47
+ - Complete source distributions containing project documentation, examples, and community files.
48
+ - Trusted Publishing workflow for tagged PyPI releases, including distribution validation.
49
+ - Manual TestPyPI rehearsal workflow and a release checklist with exact publisher settings.
50
+ - Python 3.14 support in package metadata and the CI test matrix.
51
+
52
+ ### Changed
53
+
54
+ - Package metadata now uses `astscribe.__version__` as its single version source.
55
+ - CI validates both wheel and source distributions with Twine before release.
56
+ - Distribution CI installs the built wheel and exercises its command-line entry point.
57
+ - Successful PyPI publication creates the matching GitHub Release automatically.
58
+
59
+ ## [0.7.0] - 2026-10-02
60
+
61
+ ### Added
62
+
63
+ - Dependency-aware notebook diagnostics built on the framework-independent cell dependency graph.
64
+ - `dependency.forward_reference` warnings for reads that cannot be resolved in source order but have a supported definition in a later cell.
65
+ - `dependency.unresolved_symbol` warnings for non-builtin reads with no supported notebook definition, explicitly allowing for hidden kernel state or external injection.
66
+ - `dependency.symbol_redefinition` informational findings for cross-cell rebinding of notebook-global names.
67
+ - `dependency.overwritten_before_cross_cell_use` informational findings when a definition is replaced before any later analyzed cell consumes that specific definition.
68
+ - Read-before-write handling so patterns such as `x = x + 1` count as consuming the previous definition before rebinding it.
69
+ - `NotebookAnalyzer.diagnostics()` and `NotebookAnalyzer.render_diagnostics()`.
70
+ - Structured `NotebookDiagnostic` / `NotebookDiagnostics` APIs, stable diagnostic codes, `by_code(...)`, and `to_dict()` export.
71
+ - Original `.ipynb` cell-index preservation in diagnostic locations and related-cell references.
72
+ - Dedicated diagnostic semantics and limitations in `docs/notebook_diagnostics.md`.
73
+ - Tests covering forward references, hidden/external state, redefinitions, conservative overwrite detection, deterministic rendering, and structured output.
74
+
75
+ ### Changed
76
+
77
+ - ASTScribe can now distinguish a likely source-order notebook dependency from a symbol that remains unresolved across the analyzed notebook, rather than collapsing both cases into the same static finding.
78
+ - Dependency diagnostics use warnings only for unresolved source-order structure and informational severity for potentially confusing but valid notebook rebinding patterns.
79
+
80
+ ## [0.6.0] - 2026-10-02
81
+
82
+ ### Added
83
+
84
+ - Framework-agnostic notebook cell dependency graph based on ordered Python symbol reads, writes, and deletions.
85
+ - Static resolution of cross-cell symbol reads to the latest previously observed producer.
86
+ - Aggregated producer-cell to consumer-cell edges with the symbols responsible for each dependency.
87
+ - Per-cell unresolved-read reporting for non-builtin symbols with no supported prior producer.
88
+ - Cross-cell symbol-redefinition tracking for names repeatedly rebound during notebook experimentation.
89
+ - `NotebookAnalyzer.dependency_graph()`, `render_dependency_graph()`, and `dependency_dot()`.
90
+ - `NotebookDependencyGraph.parents(...)`, `children(...)`, structured `to_dict()`, deterministic text rendering, and Graphviz DOT source export.
91
+ - Original `.ipynb` cell-index preservation in graph nodes and edges.
92
+ - Conservative scope handling for imports, assignments, augmented assignments, loops, context-manager bindings, comprehensions, function defaults, classes, and deletion.
93
+ - Dedicated dependency-graph semantics and limitations in `docs/cell_dependency_graph.md`.
94
+ - Tests covering read-before-write reassignment, producer replacement, comprehension scope, function-definition behavior, deletion, unresolved reads, original notebook indices, and DOT export.
95
+
96
+ ### Changed
97
+
98
+ - ASTScribe now includes a framework-independent notebook structural/dataflow layer in addition to framework semantic analysis, experiment reconstruction, and composite-technique detection.
99
+ - Dependency analysis is flow-sensitive to supported syntactic event order while remaining intentionally non-branch-sensitive and independent of historical Jupyter kernel execution state.
100
+
101
+ ## [0.5.0] - 2026-10-02
102
+
103
+ ### Added
104
+
105
+ - First Hugging Face Datasets semantic analyzer with no runtime `datasets` dependency.
106
+ - Static `load_dataset(...)` and `load_from_disk(...)` analysis with dataset identifier, split, streaming, and other statically resolvable options.
107
+ - Dataset `map`, `filter`, `train_test_split`, `shuffle`, `select`, and common schema-transformation semantics.
108
+ - Dataset lineage resolution across notebook cells.
109
+ - Dedicated `Dataset preparation` Methods and experiment-pipeline stage.
110
+ - First bitsandbytes-oriented Transformers quantization analyzer with no runtime `bitsandbytes` dependency.
111
+ - `BitsAndBytesConfig(...)` analysis for explicit 4-bit/8-bit settings, NF4/FP4-related configuration, compute dtype expressions, double quantization, and int8 threshold when statically available.
112
+ - Cross-cell linking of named `BitsAndBytesConfig` instances to model `from_pretrained(..., quantization_config=...)` calls.
113
+ - Dedicated `Quantization` Methods and experiment-pipeline stage.
114
+ - `NotebookAnalyzer.techniques()` and `NotebookAnalyzer.render_techniques()` for techniques requiring evidence across multiple cells.
115
+ - Conservative composite QLoRA detection requiring explicit 4-bit model loading, LoRA application, and an invoked training procedure.
116
+ - Broader Transformers model-class coverage for classes such as VLM/generative implementations whose names do not literally contain `Model`.
117
+ - Dataset/quantization/QLoRA evidence contract in `docs/datasets_quantization.md`.
118
+ - Tests for dataset lineage, fluent reassignment, quantized model loading, QLoRA positive/negative cases, VLM model classes, Methods output, and pipeline reconstruction.
119
+
120
+ ### Changed
121
+
122
+ - Fluent self-reassignment such as `dataset = dataset.map(...)` now preserves constructor lineage, improving cross-cell semantic context without framework-specific parser logic.
123
+ - ASTScribe now supports PyTorch, Hugging Face Transformers, Hugging Face Datasets, and PEFT as first-class semantic frameworks.
124
+ - The experiment pipeline can distinguish dataset preparation, model architecture, quantization, and parameter-efficient adaptation as separate evidence-backed stages.
125
+
126
+ ## [0.4.0] - 2026-10-02
127
+
128
+ ### Added
129
+
130
+ - First PEFT semantic analyzer with no runtime `peft` dependency.
131
+ - Static analysis for `peft.*Config` adapter configurations, including LoRA, AdaLoRA, and IA3 family labeling when explicit from the config class.
132
+ - Recovery of statically resolvable LoRA settings such as rank, alpha, dropout, bias, literal target modules, and PEFT task type expressions.
133
+ - `get_peft_model(...)` adapter-application analysis with forward-only cross-cell recovery of adapter configuration.
134
+ - `prepare_model_for_kbit_training(...)` semantics without automatically claiming QLoRA.
135
+ - `PeftModel*.from_pretrained(...)` adapter checkpoint loading with explicit adapter identifier and trainability settings when statically resolvable.
136
+ - PEFT adapter save, load, activation, addition, merge, and state-dictionary extraction semantics.
137
+ - Dedicated `Parameter-efficient fine-tuning` notebook Methods section.
138
+ - Optional `adaptation` experiment-pipeline stage between model architecture and objective/optimization.
139
+ - PEFT evidence contract and explicit non-goals in `docs/peft_semantics.md`.
140
+ - Tests for LoRA hyperparameters, cross-cell adapter context, adapter checkpoint operations, k-bit preparation, and pipeline reconstruction.
141
+
142
+ ### Changed
143
+
144
+ - ASTScribe now supports PyTorch, Hugging Face Transformers, and PEFT as first-class semantic frameworks.
145
+ - Experiment pipelines can distinguish base-model construction from parameter-efficient adaptation without changing pipelines that contain no PEFT evidence.
146
+
147
+ ## [0.3.0] - 2026-10-02
148
+
149
+ ### Added
150
+
151
+ - First Hugging Face Transformers semantic analyzer with no runtime Transformers dependency.
152
+ - `AutoTokenizer*`, processor, image-processor, feature-extractor, config, and `AutoModel*` `from_pretrained(...)` analysis.
153
+ - Cross-cell tokenizer and processor invocation semantics.
154
+ - Transformers model forward-pass analysis with explicit `labels=` supervision evidence.
155
+ - `TrainingArguments` and `Seq2SeqTrainingArguments` static hyperparameter recovery.
156
+ - `Trainer` and `Seq2SeqTrainer` configuration, training, evaluation, and prediction semantics.
157
+ - Common `DataCollator*` configuration analysis.
158
+ - `transformers.set_seed(...)` reproducibility analysis.
159
+ - `transformers.pipeline(...)` inference-pipeline analysis.
160
+ - `generate(...)` analysis for statically resolvable generation parameters including token limits, beam search, and sampling controls.
161
+ - Tokenizer `decode(...)` and `batch_decode(...)` output-decoding analysis.
162
+ - Transformers `save_pretrained(...)` checkpoint/export semantics.
163
+ - Dedicated notebook Methods section for tokenization and input preparation.
164
+ - Transformers-aware structured experiment-pipeline reconstruction.
165
+ - Tests for import alias resolution, cross-cell Transformers context, generation, Trainer workflows, Methods reporting, and pipeline reconstruction.
166
+ - A documented Transformers evidence contract and explicit non-goals in `docs/transformers_semantics.md`.
167
+
168
+ ### Changed
169
+
170
+ - ASTScribe now supports PyTorch and Hugging Face Transformers as first-class semantic frameworks.
171
+ - Transformers tokenization and processor operations share the existing structured preprocessing pipeline stage while receiving a dedicated Methods section, preserving the public pipeline title used by v0.2.
172
+
173
+ ## [0.2.0] - 2026-10-02
174
+
175
+ ### Added
176
+
177
+ - Experiment-level semantic analysis for torchvision datasets and model constructors.
178
+ - Static detection of `torch.utils.data.random_split(...)` dataset partitions.
179
+ - Preprocessing and data-augmentation analysis for common torchvision transforms.
180
+ - Scientific descriptions for composed preprocessing pipelines without claiming unsupported performance effects.
181
+ - Model architecture reconstruction for torchvision models and PyTorch head replacement.
182
+ - Explicit parameter-freezing analysis through `requires_grad = False`.
183
+ - TorchMetrics configuration analysis.
184
+ - Argmax prediction-selection and softmax-normalization analysis.
185
+ - `load_state_dict(...)` checkpoint restoration semantics.
186
+ - Reproducibility analysis for CUDA seeds, deterministic algorithms, and cuDNN deterministic/benchmark flags.
187
+ - Structured `ExperimentPipeline` / `PipelineStage` API.
188
+ - `NotebookAnalyzer.pipeline()` and `NotebookAnalyzer.render_pipeline()`.
189
+ - More granular Methods sections for dataset, preprocessing, model architecture, objective, evaluation, metrics, and reproducibility.
190
+ - GitHub Actions quality gates for Ruff and strict mypy checks.
191
+ - A CI-enforced wheel-size limit of less than 1,000,000 bytes.
192
+
193
+ ### Changed
194
+
195
+ - The semantic registry now supports multiple analyzers per framework, allowing experiment-level rules to evolve independently from the core PyTorch analyzer.
196
+ - Notebook methodology reports now follow the order of a typical ML experiment more closely.
197
+ - Static analyzer typing is validated in CI while keeping optional IPython typing exceptions narrowly scoped.
198
+
199
+ ## [0.1.0] - 2026-10-02
200
+
201
+ ### Added
202
+
203
+ - Initial Python AST parsing and import alias resolution.
204
+ - Lightweight static symbol resolution for literal values and constructors.
205
+ - Scientific Interpretation Representation (SIR) with evidence-backed claims.
206
+ - Concise, educational, and scientific renderers.
207
+ - Forward-only notebook context through `NotebookAnalyzer`.
208
+ - Direct `.ipynb` loading using the Python standard library.
209
+ - Preservation of original notebook cell indices in evidence provenance.
210
+ - Explicit tracking of skipped non-Python/IPython-specific cells.
211
+ - Cross-cell recovery of optimizer constructors and statically resolvable hyperparameters.
212
+ - Cell-aware evidence provenance for claims derived from earlier notebook cells.
213
+ - PyTorch semantic rules for training, inference, optimizers, losses, seeds, checkpoints, and DataLoaders.
214
+ - Static epoch-count extraction for common `range(...)` training loops.
215
+ - PyTorch device configuration and transfer analysis.
216
+ - Learning-rate scheduler configuration and scheduler-step analysis.
217
+ - Gradient clipping analysis.
218
+ - Automatic mixed-precision and GradScaler analysis.
219
+ - Deterministic notebook-level `# Methods` reports with optional evidence appendix.
220
+ - Optional `%%scribe` IPython cell magic.
221
+ - Static safety tests guaranteeing analyzed code is not executed.
222
+ - Apache License 2.0 licensing metadata and NOTICE file.
223
+
224
+ ### Changed
225
+
226
+ - Optimizer-step detection now distinguishes optimizer, scheduler, and GradScaler `.step()` calls to reduce false methodological claims.
@@ -0,0 +1,12 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use ASTScribe in your work, please cite this software."
3
+ title: "ASTScribe"
4
+ type: software
5
+ authors:
6
+ - family-names: "Barrios"
7
+ given-names: "Eduardo J."
8
+ version: 0.8.2
9
+ date-released: 2026-10-06
10
+ repository-code: "https://github.com/edujbarrios/astscribe"
11
+ url: "https://github.com/edujbarrios/astscribe"
12
+ license: Apache-2.0
@@ -0,0 +1,7 @@
1
+ # Code of Conduct
2
+
3
+ ASTScribe is committed to a welcoming, respectful, and harassment-free open-source community.
4
+
5
+ Contributors are expected to communicate professionally, assume good faith, accept constructive review, and avoid discriminatory, abusive, or disruptive behavior.
6
+
7
+ Project maintainers may remove content or restrict participation when behavior materially harms the community or project.
@@ -0,0 +1,37 @@
1
+ # Contributing to ASTScribe
2
+
3
+ ASTScribe is open source and welcomes contributions through issues and pull requests.
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ git clone https://github.com/edujbarrios/astscribe.git
9
+ cd astscribe
10
+ python -m venv .venv
11
+ source .venv/bin/activate # Windows PowerShell: .venv\Scripts\Activate.ps1
12
+ pip install -e ".[dev]"
13
+ ```
14
+
15
+ Run the quality checks with:
16
+
17
+ ```bash
18
+ pytest
19
+ ruff check .
20
+ mypy src/astscribe
21
+ ```
22
+
23
+ Release preparation and Trusted Publishing setup are documented in
24
+ [`docs/releasing.md`](docs/releasing.md).
25
+
26
+ ## Adding a semantic rule
27
+
28
+ A semantic rule should:
29
+
30
+ 1. match source structure statically;
31
+ 2. emit a structured SIR operation;
32
+ 3. attach explicit evidence and source locations;
33
+ 4. avoid unsupported methodological claims;
34
+ 5. include focused tests;
35
+ 6. never execute analyzed source code.
36
+
37
+ Prefer a small, defensible rule over a broad heuristic that can produce misleading explanations.
@@ -0,0 +1,201 @@
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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Eduardo J. Barrios
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ include CHANGELOG.md
2
+ include CITATION.cff
3
+ include CODE_OF_CONDUCT.md
4
+ include CONTRIBUTING.md
5
+ include SECURITY.md
6
+ graft docs
7
+ graft examples
8
+ global-exclude __pycache__ *.py[cod]
astscribe-0.8.2/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ ASTScribe
2
+ Copyright 2026 Eduardo J. Barrios
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
5
+ See the LICENSE file distributed with this work for the full license terms.
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: astscribe
3
+ Version: 0.8.2
4
+ Summary: Evidence-backed scientific explanations for ML notebooks, without LLMs.
5
+ Author: Eduardo J. Barrios
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Changelog, https://github.com/edujbarrios/astscribe/blob/main/CHANGELOG.md
8
+ Project-URL: Documentation, https://github.com/edujbarrios/astscribe#readme
9
+ Project-URL: Homepage, https://github.com/edujbarrios/astscribe
10
+ Project-URL: Repository, https://github.com/edujbarrios/astscribe
11
+ Project-URL: Issues, https://github.com/edujbarrios/astscribe/issues
12
+ Keywords: ast,pytorch,jupyter,static-analysis,machine-learning,scientific-computing
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ License-File: NOTICE
28
+ Provides-Extra: ipython
29
+ Requires-Dist: ipython>=8; extra == "ipython"
30
+ Provides-Extra: dev
31
+ Requires-Dist: build>=1.2; extra == "dev"
32
+ Requires-Dist: mypy>=1.10; extra == "dev"
33
+ Requires-Dist: pytest>=8; extra == "dev"
34
+ Requires-Dist: ruff>=0.6; extra == "dev"
35
+ Requires-Dist: twine>=5; extra == "dev"
36
+ Requires-Dist: ipython>=8; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ # ASTScribe
40
+
41
+ > Evidence-backed scientific explanations for ML notebooks, without LLMs.
42
+
43
+ [![PyPI version](https://img.shields.io/pypi/v/astscribe.svg)](https://pypi.org/project/astscribe/)
44
+ [![Python versions](https://img.shields.io/pypi/pyversions/astscribe.svg)](https://pypi.org/project/astscribe/)
45
+ [![PyPI downloads](https://img.shields.io/pypi/dm/astscribe.svg)](https://pypi.org/project/astscribe/)
46
+ [![Tests](https://github.com/edujbarrios/astscribe/actions/workflows/tests.yml/badge.svg)](https://github.com/edujbarrios/astscribe/actions/workflows/tests.yml)
47
+ [![License](https://img.shields.io/github/license/edujbarrios/astscribe.svg)](https://github.com/edujbarrios/astscribe/blob/main/LICENSE)
48
+
49
+ ASTScribe statically analyzes Python and Jupyter notebooks and turns supported ML
50
+ operations into deterministic, traceable explanations.
51
+
52
+ **No LLMs. No API keys. No code execution. No telemetry.**
53
+
54
+ ## Install
55
+
56
+ ```bash
57
+ python -m pip install astscribe
58
+ ```
59
+
60
+ Optional IPython/Jupyter integration:
61
+
62
+ ```bash
63
+ python -m pip install "astscribe[ipython]"
64
+ ```
65
+
66
+ ## Quick start
67
+
68
+ ```python
69
+ from astscribe import explain
70
+
71
+ print(explain("""
72
+ model.eval()
73
+ with torch.no_grad():
74
+ outputs = model(inputs)
75
+ """, style="scientific"))
76
+ ```
77
+
78
+ For notebooks:
79
+
80
+ ```python
81
+ from astscribe import NotebookAnalyzer
82
+
83
+ notebook = NotebookAnalyzer.from_ipynb("experiment.ipynb")
84
+ print(notebook.render_methodology(include_evidence=True))
85
+ print(notebook.render_diagnostics())
86
+ ```
87
+
88
+ ASTScribe only reports claims supported by the source it can inspect.
89
+
90
+ ## CLI
91
+
92
+ ```bash
93
+ astscribe training.py --style concise
94
+ astscribe experiment.ipynb --report methodology --evidence
95
+ astscribe experiment.ipynb --report diagnostics
96
+ astscribe experiment.ipynb --report impact --cell 3
97
+
98
+ # Read Python source from stdin
99
+ printf 'model.eval()\n' | astscribe - --style concise
100
+
101
+ # Fail if a notebook contains a code cell that is not valid Python
102
+ astscribe experiment.ipynb --report diagnostics --strict
103
+ ```
104
+
105
+ The same CLI is available as `python -m astscribe`.
106
+
107
+ ## Supported semantics
108
+
109
+ ASTScribe has first-class static semantics for **PyTorch**, **Hugging Face
110
+ Transformers**, **Hugging Face Datasets**, and **PEFT**. It can reconstruct notebook
111
+ methodology, experiment pipelines, cross-cell dependencies, diagnostics, impact, and
112
+ conservative composite techniques such as QLoRA.
113
+
114
+ Generated claims retain source provenance and an evidence level. The scientific
115
+ renderer uses directly observed, statically resolved, and known-framework claims by
116
+ default.
117
+
118
+ Detailed contracts and limitations live in [docs](https://github.com/edujbarrios/astscribe/tree/main/docs).
119
+
120
+ ## Development
121
+
122
+ ```bash
123
+ python -m pip install -e ".[dev]"
124
+ pytest
125
+ ruff check .
126
+ mypy src/astscribe
127
+ ```
128
+
129
+ See [CONTRIBUTING.md](https://github.com/edujbarrios/astscribe/blob/main/CONTRIBUTING.md)
130
+ and [docs/releasing.md](https://github.com/edujbarrios/astscribe/blob/main/docs/releasing.md).
131
+
132
+ ## License
133
+
134
+ Apache License 2.0. See [LICENSE](https://github.com/edujbarrios/astscribe/blob/main/LICENSE).