Skip to content

Centralize .madsci/ directory resolution into sentry module - #229

Merged
RyanTheRobothead merged 6 commits into
unstablefrom
sentry_folder
Mar 2, 2026
Merged

Centralize .madsci/ directory resolution into sentry module#229
RyanTheRobothead merged 6 commits into
unstablefrom
sentry_folder

Conversation

@RyanTheRobothead

Copy link
Copy Markdown
Member

Summary

  • Introduces madsci.common.sentry as the canonical module for all .madsci/ directory path resolution, replacing 12+ files with hardcoded paths (Path.home() / ".madsci" / "pids", Path("~") / ".madsci" / "backups", etc.)
  • Walk-up resolution: .madsci/ (primary sentinel) → .git/ (secondary boundary) → ~/.madsci/ (global fallback)
  • Adds .git/ as a walk-up boundary in settings_dir.py for config file discovery
  • madsci init now scaffolds .madsci/ with standard subdirs (pids/, logs/, backups/, etc.) and registry.json

Files changed (28 files, +990 / -214)

New:

  • sentry.py — core module with find_madsci_dir(), get_madsci_subdir(), get_global_madsci_subdir(), ensure_madsci_dir()
  • test_sentry.py — 20 tests covering all functions and edge cases

Updated consumers:

  • local_registry.py — replaced 30-line walk-up with 2-line sentry call
  • start.py / stop.py — PID/log dirs now project-local via sentry
  • event_types.py, datapoint_types.py, workcell_types.py, backup_types.py, mongodb_migration_types.py, migration_tool.py — field defaults use default_factory with sentry helpers
  • templates/registry.py — uses get_global_madsci_subdir() for user templates
  • local_runner.py — scratch dir via find_madsci_dir()
  • Backup CLIs (cli.py, postgres_cli.py, mongo_cli.py) — runtime resolution instead of hardcoded defaults
  • init.py — calls ensure_madsci_dir() after template rendering
  • settings_dir.py.git/ boundary + updated docstrings
  • test_settings_dir.py — 3 new .git/ boundary tests
  • CLAUDE.md / AGENTS.md — documented sentry module and .git/ boundary

Test plan

  • 20 new test_sentry.py tests pass (walk-up, boundaries, auto-create, subdirs, scaffolding)
  • 3 new .git/ boundary tests in test_settings_dir.py pass
  • Full test suite: 2591 passed, 0 failures
  • ruff check and ruff format clean
  • All pre-commit hooks pass
  • Manual smoke test: madsci init test_lab && cd test_lab && ls -la .madsci/
  • Manual smoke test: madsci start manager event -d from project with .madsci/ — verify PID goes to project-local dir

🤖 Generated with Claude Code

RyanTheRobothead and others added 6 commits March 1, 2026 11:28
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>
@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/madsci_client/madsci/client/cli/commands
  init.py
  start.py 39-41, 46-48, 195-201, 210-216, 226-231, 263-264
  src/madsci_common/madsci/common
  sentry.py
  settings_dir.py
  src/madsci_common/madsci/common/backup_tools
  cli.py
  mongo_cli.py
  postgres_cli.py
  src/madsci_common/madsci/common/registry
  local_registry.py 92
  src/madsci_common/madsci/common/templates
  registry.py
  src/madsci_common/madsci/common/types
  base_types.py 33-37, 235-236, 269
  datapoint_types.py
  event_types.py
  mongodb_migration_types.py
  workcell_types.py
  src/madsci_common/madsci/common/types/resource_types
  definitions.py 36
  src/madsci_resource_manager/madsci/resource_manager
  database_version_checker.py
  migration_tool.py
Project Total  

This report was generated by python-coverage-comment-action

@RyanTheRobothead
RyanTheRobothead marked this pull request as ready for review March 2, 2026 16:21
@RyanTheRobothead
RyanTheRobothead merged commit 649a1a4 into unstable Mar 2, 2026
4 checks passed
@RyanTheRobothead
RyanTheRobothead deleted the sentry_folder branch April 9, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant