Centralize .madsci/ directory resolution into sentry module - #229
Merged
Conversation
All .madsci/ path resolution is now handled by madsci.common.sentry, replacing 12+ files with hardcoded paths. The module provides walk-up discovery (.madsci/ primary, .git/ secondary boundary, ~/.madsci/ fallback) with consistent logging. Also adds .git/ as a walk-up boundary in settings_dir.py, updates madsci init to scaffold .madsci/ with standard subdirs, and includes 23 new tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace default_factory sentry calls with static .madsci/ path defaults resolved at runtime via a new _resolve_sentry_paths model validator on MadsciBaseSettings. This prevents pydantic-settings-export from embedding absolute paths in .env.example and Configuration.md. Add LetterOrDigitStr TypeAlias to eliminate memory addresses in pdoc output for resource type definitions. Remove unused sentry constants (SUBDIR_MONGODB, SUBDIR_POSTGRESQL, SUBDIR_REDIS). Exclude docs/api/ from pre-commit end-of-file, trailing-whitespace, and mixed-line-ending hooks to avoid conflicts with pdoc output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add 5 new tests: _resolve_sentry_paths model validator (path resolution, str type preservation, non-sentry paths, git boundary) and .git file (worktree) boundary detection - Fix stale ~/.madsci/ references in data manager docstring and database_version_checker backup path messages - Add CHANGELOG entries for sentry module and default path changes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add post-processing step to `just docs` and GH Pages workflow that strips Python memory addresses (e.g. `at 0x108afe830`) from generated API docs. These addresses change every run and produce noisy diffs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pdoc uses non-breaking spaces (\xa0) around "at" in function references, so the regex now matches both regular and non-breaking whitespace. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
madsci.common.sentryas the canonical module for all.madsci/directory path resolution, replacing 12+ files with hardcoded paths (Path.home() / ".madsci" / "pids",Path("~") / ".madsci" / "backups", etc.).madsci/(primary sentinel) →.git/(secondary boundary) →~/.madsci/(global fallback).git/as a walk-up boundary insettings_dir.pyfor config file discoverymadsci initnow scaffolds.madsci/with standard subdirs (pids/,logs/,backups/, etc.) andregistry.jsonFiles changed (28 files, +990 / -214)
New:
sentry.py— core module withfind_madsci_dir(),get_madsci_subdir(),get_global_madsci_subdir(),ensure_madsci_dir()test_sentry.py— 20 tests covering all functions and edge casesUpdated consumers:
local_registry.py— replaced 30-line walk-up with 2-line sentry callstart.py/stop.py— PID/log dirs now project-local via sentryevent_types.py,datapoint_types.py,workcell_types.py,backup_types.py,mongodb_migration_types.py,migration_tool.py— field defaults usedefault_factorywith sentry helperstemplates/registry.py— usesget_global_madsci_subdir()for user templateslocal_runner.py— scratch dir viafind_madsci_dir()cli.py,postgres_cli.py,mongo_cli.py) — runtime resolution instead of hardcoded defaultsinit.py— callsensure_madsci_dir()after template renderingsettings_dir.py—.git/boundary + updated docstringstest_settings_dir.py— 3 new.git/boundary testsCLAUDE.md/AGENTS.md— documented sentry module and.git/boundaryTest plan
test_sentry.pytests pass (walk-up, boundaries, auto-create, subdirs, scaffolding).git/boundary tests intest_settings_dir.pypassruff checkandruff formatcleanmadsci init test_lab && cd test_lab && ls -la .madsci/madsci start manager event -dfrom project with.madsci/— verify PID goes to project-local dir🤖 Generated with Claude Code