Repository navigation
Fix/28 full rerun targeted deletion #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9a12673
Refactor output path computation into shared helper
thompsonmj 55236b1
Fix #28: target --full-rerun to TaxonoPy-specific output files via ma…
thompsonmj 504de67
Add tests for manifest-based output tracking
thompsonmj eb7b5bb
Document --full-rerun behavior, manifest, and rerun lifecycle
thompsonmj efae52f
Update contribution convention to use Co-Authored-By for AI attribution
thompsonmj b0b3c62
Prevent symlink and traversal sequences from escaping the output dire…
thompsonmj 98b2e0a
Add security tests for manifest deletion path containment
thompsonmj d392ba1
Fix linting errors
thompsonmj 661bfed
Raise on corrupt or unreadable manifest with an actionable error message
thompsonmj 73019c0
Test that read_manifest raises on corrupt JSON
thompsonmj 75691a8
Document no-hard-wrap convention and fix existing wraps in AGENTS.md
thompsonmj 273edcb
Remove hard wrapping from all files touched by this PR
thompsonmj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,8 @@ Use this file primarily when operating as a coding agent. Its intent is to captu | |
| - When instructions here conflict with new information, trust the current codebase and update AGENTS.md alongside your change. If critical context is still missing, pause and ask the maintainer rather than guessing. | ||
|
|
||
| ## Project Snapshot | ||
| - CLI-first tool for normalizing taxonomy: ingest (Parquet/CSV) → parse/group (`TaxonomicEntry`/`EntryGroupRef`) → plan + run GNVerifier queries → classify via strategy profiles → write | ||
| resolved & unsolved outputs → optional common-name enrichment. | ||
| - Source layout: CLI entry (`src/taxonopy/cli.py`), parsing/grouping/cache (`input_parser`, `entry_grouper`, `cache_manager`), query stack (`query/planner|executor|gnverifier_client`), | ||
| resolution logic (`resolution/attempt_manager` + profiles), outputs (`output_manager`), tracing (`trace/entry.py`). | ||
| - CLI-first tool for normalizing taxonomy: ingest (Parquet/CSV) → parse/group (`TaxonomicEntry`/`EntryGroupRef`) → plan + run GNVerifier queries → classify via strategy profiles → write resolved & unsolved outputs → optional common-name enrichment. | ||
| - Source layout: CLI entry (`src/taxonopy/cli.py`), parsing/grouping/cache (`input_parser`, `entry_grouper`, `cache_manager`), query stack (`query/planner|executor|gnverifier_client`), resolution logic (`resolution/attempt_manager` + profiles), outputs (`output_manager`), manifest tracking (`manifest.py`), tracing (`trace/entry.py`). | ||
| - Dependencies (see `pyproject.toml`): Python ≥ 3.10, Polars, Pandas/PyArrow, Pydantic v2, tqdm, requests; dev extras provide Ruff, pytest scaffolding, datamodel-code-generator, pre-commit. | ||
|
|
||
| ## Environment Setup | ||
|
|
@@ -73,13 +71,17 @@ taxonopy common-names \ | |
| - `--clear-cache` | ||
| - `--refresh-cache` (per run) to ignore stale grouping/parsing caches. | ||
| - Don’t delete cache files manually unless instructed; prefer the flags above. | ||
| - `--full-rerun` clears the input-scoped cache namespace and deletes only the files listed in `taxonopy_resolve_manifest.json` (written before any output on every run). Non-TaxonoPy files in the output directory are never touched. If no manifest is found (pre-v0.3.0 output), a warning is logged and no files are removed. | ||
|
|
||
| ## Validation & QA | ||
| - Run `ruff check .` after modifying Python files (requires the `dev` extra). | ||
| - Run `pytest` even though the suite is sparse today; it protects future additions and should pass cleanly. | ||
| - Validate functional changes by running `taxonopy resolve` against `examples/input` (or issue-specific datasets) and reviewing outputs/logs, plus `taxonopy trace entry ...` when touching parsing/grouping logic. | ||
|
|
||
| ## Coding Conventions | ||
| - Don't hard-wrap comments. Only use line breaks for new paragraphs. Let the editor soft-wrap content. | ||
| - Don't hard-wrap string literals. Keep each log or user-facing message in a single source line and rely on soft wrapping when reading it. | ||
| - Don't hard-wrap markdown prose in documentation. Let the renderer wrap lines as needed. | ||
| - Prefer frozen dataclasses (`types/data_classes.py`) for shared structures; mutate via new objects rather than in-place edits. | ||
| - Rely on strong typing + Pydantic models for external data (`types/gnverifier.py`); regenerate via the helper script instead of editing generated files. | ||
| - Log through the standard logging config (`logging_config.setup_logging`) and keep tqdm progress bars for long-running loops. | ||
|
|
@@ -100,7 +102,12 @@ taxonopy common-names \ | |
| - Follow best version control practices including, but not limited to, the following: | ||
| - At the start of a session, ensure that work is done on a relevant branch (not `main`), and pull the latest changes from `main` before starting. | ||
| - Make commit messages imperative, one line, and descriptive of the change's "what" and "why" (not "how"). Any needed description beyond this can go in the extended body. | ||
| - For every commit you produce, append "[AI-assisted session]" as a final line in the extended commit message body. | ||
| - For every commit you produce, add a `Co-Authored-By` trailer in the extended commit message body identifying the model and provider, e.g.: | ||
| ``` | ||
| Co-Authored-By: Claude Sonnet 4.6 <[email protected]> | ||
| Co-Authored-By: GPT-4o <[email protected]> | ||
| Co-Authored-By: Gemini 2.0 Flash <[email protected]> | ||
| ``` | ||
| - Do not use Git or the GitHub CLI for any destructive actions like `git reset --hard`, `git rebase`, `git push --force`, `git branch -D`, `gh repo delete`, `gh issue delete`, and so on, nor commands like `rm -rf` that delete files or directories. If you consider a destructive command to be necessary, stop and discuss the situation with a maintainer. | ||
| - When modifying CLI behavior, resolution strategies, or caching semantics, update this AGENTS file so future agents follow the latest contract. | ||
| - Run `ruff check .`, `pytest`, and the sample `taxonopy resolve` workflow before handing off changes or opening discussions with maintainers. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,8 @@ | ||
| # IO | ||
|
|
||
| TaxonoPy accepts CSV or Parquet inputs with the same schema. Use the pages below | ||
| for the exact input columns, the structure of resolved/unsolved outputs, and how | ||
| the cache supports provenance and transparency throughout the resolution process. | ||
| TaxonoPy accepts CSV or Parquet inputs with the same schema. Use the pages below for the exact input columns, the structure of resolved/unsolved outputs, and how the cache supports provenance and transparency throughout the resolution process. | ||
|
|
||
| - [Input](input.md) | ||
| - [Output](output.md) | ||
| - [Cache](cache.md) | ||
| - [Reruns](reruns.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Reruns | ||
|
|
||
| ## The Guard | ||
|
|
||
| TaxonoPy checks for existing output before processing. If a prior run is detected for the current input, it exits with a warning rather than silently overwriting: | ||
|
|
||
| ``` | ||
| Existing cache (...) and/or output (...) detected for this input. | ||
| Rerun with --full-rerun to replace them. | ||
| ``` | ||
|
|
||
| Detection uses two signals: | ||
|
|
||
| - the presence of a `taxonopy_resolve_manifest.json` in the output directory (written by any run using TaxonoPy v0.3.0 or later), or | ||
| - `.resolved.*` files in the output directory root (legacy fallback for output produced by earlier versions). | ||
|
|
||
| ## `--full-rerun` | ||
|
|
||
| `--full-rerun` is the explicit escape hatch through the guard. It clears the input-scoped cache namespace and removes all TaxonoPy-specific files from the output directory before proceeding. | ||
|
|
||
| ```console | ||
| taxonopy resolve \ | ||
| --input examples/input \ | ||
| --output-dir examples/resolved \ | ||
| --full-rerun | ||
| ``` | ||
|
|
||
| ### What it touches | ||
|
|
||
| - **Cache**: the namespace scoped to the current command, TaxonoPy version, and input fingerprint. Other namespaces (different inputs, different versions) are not affected. | ||
| - **Output files**: only the files listed in `taxonopy_resolve_manifest.json`. Any other files in the output directory are left untouched. | ||
|
|
||
| ### What it does not touch | ||
|
|
||
| - Files not listed in the manifest — including any non-TaxonoPy files you have placed in the output directory. | ||
| - Cache namespaces from other runs. | ||
|
|
||
| ### No manifest found | ||
|
|
||
| If `--full-rerun` is used but no manifest is present (e.g. output from a pre-v0.3.0 run, or a manually populated directory), TaxonoPy logs a warning and proceeds without removing any files: | ||
|
|
||
| ``` | ||
| --full-rerun: no manifest found in <output-dir>; no output files were removed. | ||
| ``` | ||
|
|
||
| The run then writes fresh output and a new manifest. | ||
|
|
||
| ## The Manifest | ||
|
|
||
| Every TaxonoPy run writes a manifest file to the output directory **before** creating any output. This means interrupted runs leave a complete record of what should be cleaned up — `--full-rerun` deletes exactly those files and nothing else. | ||
|
|
||
| Manifest files are command-scoped so they coexist safely if multiple commands share an output directory: | ||
|
|
||
| | Command | Manifest file | | ||
| |---|---| | ||
| | `resolve` | `taxonopy_resolve_manifest.json` | | ||
| | `common-names` | `taxonopy_common_names_manifest.json` | | ||
|
|
||
| ### Schema | ||
|
|
||
| ```json | ||
| { | ||
| "taxonopy_version": "0.3.0", | ||
| "command": "resolve", | ||
| "created_at": "2025-07-19T10:38:04.123456", | ||
| "input": "examples/input", | ||
| "cache_namespace": "~/.cache/taxonopy/resolve_v0.3.0_a3f9b2c1d4e5f678", | ||
|
thompsonmj marked this conversation as resolved.
|
||
| "files": [ | ||
| "sample.resolved.parquet", | ||
| "sample.unsolved.parquet", | ||
| "resolution_stats.json", | ||
| "taxonopy_resolve_manifest.json" | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| All paths in `files` are relative to the output directory. `cache_namespace` is `null` for `common-names`, which does not use an input-scoped cache. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.