jsonpit 4.4.3__tar.gz → 4.4.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: jsonpit
3
- Version: 4.4.3
3
+ Version: 4.4.4
4
4
  Summary: Daemon-free distributed storage over Cloud Drives for developers and AI agents — multi-process, immutable history, zero dependencies.
5
5
  Author: Dr. Rainer Burkhardt
6
6
  License-Expression: Apache-2.0
@@ -31,14 +31,14 @@ The canonical **reference (lead) implementation** is C# `JsonPit` and the `pits`
31
31
 
32
32
  ---
33
33
 
34
- ## Cross-Tool & Cross-Language Version Alignment (`v4.4.3`)
34
+ ## Cross-Tool & Cross-Language Version Alignment (`v4.4.4`)
35
35
 
36
- `jsonpit` and the `jpit` CLI are version-synchronized to **`v4.4.3`** in direct lockstep with C# `JsonPit` and `pits 4.4.3` in [RAIkeep](https://github.com/Burkhardt/RAIkeep).
36
+ `jsonpit` and the `jpit` CLI are version-synchronized to **`v4.4.4`** in direct lockstep with C# `JsonPit` and `pits 4.4.4` in [RAIkeep](https://github.com/Burkhardt/RAIkeep).
37
37
 
38
38
  ### Why Harmonized Versioning is Essential:
39
39
  - **Instant Compatibility Clarity:** Operators, DevOps pipelines, and autonomous AI agents immediately know whether `jpit` and `pits` share the exact same distributed protocol revision. If both tools report `4.4.x`, they guarantee identical master leasing rules, receipt mechanisms, 7-digit UTC timestamp parsing, and CR041 clean change file conventions.
40
40
  - **Elimination of Multi-Language Matrix Confusion:** In heterogeneous environments (e.g. C# backend daemons paired with Python agent orchestrators and data science tooling), unified SemVer tags eliminate complex cross-compatibility lookup tables.
41
- - **Joint Protocol Governance:** Architectural changes (such as CR040 anti-Read-Modify-Write rules and CR041 clean change file formatting) are certified across both languages under the exact same version milestone before release.
41
+ - **Joint Protocol Governance:** Architectural changes (such as CR040 anti-Read-Modify-Write rules, CR041 clean change file formatting, and CR044 missing configuration diagnostics) are certified across both languages under the exact same version milestone before release.
42
42
 
43
43
  ---
44
44
 
@@ -54,6 +54,69 @@ The canonical **reference (lead) implementation** is C# `JsonPit` and the `pits`
54
54
 
55
55
  ---
56
56
 
57
+ ## Installation & Upgrade
58
+
59
+ ### As a Global CLI Tool (`jpit`) via `pipx` (Recommended)
60
+ To run the `jpit` command-line companion anywhere across your machine in an isolated environment without polluting system packages:
61
+
62
+ ```bash
63
+ # Install globally
64
+ pipx install jsonpit
65
+ # (or via companion alias)
66
+ pipx install jpit
67
+
68
+ # Upgrade to the latest lockstep release (v4.4.4)
69
+ pipx upgrade jsonpit
70
+ # (or)
71
+ pipx upgrade jpit
72
+ ```
73
+
74
+ ### In a Project / Virtual Environment via `pip`
75
+ To embed `jsonpit` into your Python applications, data science workflows, or agentic runtimes:
76
+
77
+ ```bash
78
+ # Install
79
+ pip install jsonpit
80
+
81
+ # Upgrade to the latest release
82
+ pip install --upgrade jsonpit
83
+ ```
84
+
85
+ ### Upgrading with Multi-Python / `pyenv` Environments
86
+ If you maintain multiple Python versions on your machine (e.g. 3.12, 3.13, 3.14):
87
+
88
+ 1. **Always anchor `pip` to your active Python interpreter:**
89
+ ```bash
90
+ python -m pip install --upgrade jpit
91
+ ```
92
+ *(Avoid bare `pip install`: invoking `pip` directly may resolve to an older Python version in `$PATH`, installing the package into the wrong runtime).*
93
+
94
+ 2. **If using `pyenv`, regenerate shims:**
95
+ ```bash
96
+ pyenv rehash
97
+ ```
98
+ *This ensures `which jpit` resolves to `~/.pyenv/shims/jpit`, which dynamically routes to whichever Python version is currently active in your shell.*
99
+
100
+ 3. **Verify the active executable:**
101
+ ```bash
102
+ which jpit
103
+ jpit --version
104
+ ```
105
+
106
+ > [!TIP]
107
+ > **Encountering `error: externally-managed-environment` (Homebrew Python or modern Linux / PEP 668)?**
108
+ > Modern Homebrew and Linux package managers protect their system Python prefix by default. You have two clean options:
109
+ > - **Option A (Isolated CLI via `pipx`):** Run `brew install pipx && pipx ensurepath`, then `pipx install jpit`.
110
+ > - **Option B (Direct install into Homebrew Python):** Pass `--break-system-packages`:
111
+ > ```bash
112
+ > python -m pip install --upgrade --break-system-packages jpit
113
+ > ```
114
+ > *(Completely safe: `jsonpit` has zero runtime dependencies and cannot break system packages).*
115
+
116
+ *(Both the `jsonpit` library package and the `jpit` companion package provide both `jpit` and `jsonpit` command-line executables).*
117
+
118
+ ---
119
+
57
120
  ## Quickstart
58
121
 
59
122
  ### 1. Cloud-First Triad (The Standard Pattern)
@@ -9,14 +9,14 @@ The canonical **reference (lead) implementation** is C# `JsonPit` and the `pits`
9
9
 
10
10
  ---
11
11
 
12
- ## Cross-Tool & Cross-Language Version Alignment (`v4.4.3`)
12
+ ## Cross-Tool & Cross-Language Version Alignment (`v4.4.4`)
13
13
 
14
- `jsonpit` and the `jpit` CLI are version-synchronized to **`v4.4.3`** in direct lockstep with C# `JsonPit` and `pits 4.4.3` in [RAIkeep](https://github.com/Burkhardt/RAIkeep).
14
+ `jsonpit` and the `jpit` CLI are version-synchronized to **`v4.4.4`** in direct lockstep with C# `JsonPit` and `pits 4.4.4` in [RAIkeep](https://github.com/Burkhardt/RAIkeep).
15
15
 
16
16
  ### Why Harmonized Versioning is Essential:
17
17
  - **Instant Compatibility Clarity:** Operators, DevOps pipelines, and autonomous AI agents immediately know whether `jpit` and `pits` share the exact same distributed protocol revision. If both tools report `4.4.x`, they guarantee identical master leasing rules, receipt mechanisms, 7-digit UTC timestamp parsing, and CR041 clean change file conventions.
18
18
  - **Elimination of Multi-Language Matrix Confusion:** In heterogeneous environments (e.g. C# backend daemons paired with Python agent orchestrators and data science tooling), unified SemVer tags eliminate complex cross-compatibility lookup tables.
19
- - **Joint Protocol Governance:** Architectural changes (such as CR040 anti-Read-Modify-Write rules and CR041 clean change file formatting) are certified across both languages under the exact same version milestone before release.
19
+ - **Joint Protocol Governance:** Architectural changes (such as CR040 anti-Read-Modify-Write rules, CR041 clean change file formatting, and CR044 missing configuration diagnostics) are certified across both languages under the exact same version milestone before release.
20
20
 
21
21
  ---
22
22
 
@@ -32,6 +32,69 @@ The canonical **reference (lead) implementation** is C# `JsonPit` and the `pits`
32
32
 
33
33
  ---
34
34
 
35
+ ## Installation & Upgrade
36
+
37
+ ### As a Global CLI Tool (`jpit`) via `pipx` (Recommended)
38
+ To run the `jpit` command-line companion anywhere across your machine in an isolated environment without polluting system packages:
39
+
40
+ ```bash
41
+ # Install globally
42
+ pipx install jsonpit
43
+ # (or via companion alias)
44
+ pipx install jpit
45
+
46
+ # Upgrade to the latest lockstep release (v4.4.4)
47
+ pipx upgrade jsonpit
48
+ # (or)
49
+ pipx upgrade jpit
50
+ ```
51
+
52
+ ### In a Project / Virtual Environment via `pip`
53
+ To embed `jsonpit` into your Python applications, data science workflows, or agentic runtimes:
54
+
55
+ ```bash
56
+ # Install
57
+ pip install jsonpit
58
+
59
+ # Upgrade to the latest release
60
+ pip install --upgrade jsonpit
61
+ ```
62
+
63
+ ### Upgrading with Multi-Python / `pyenv` Environments
64
+ If you maintain multiple Python versions on your machine (e.g. 3.12, 3.13, 3.14):
65
+
66
+ 1. **Always anchor `pip` to your active Python interpreter:**
67
+ ```bash
68
+ python -m pip install --upgrade jpit
69
+ ```
70
+ *(Avoid bare `pip install`: invoking `pip` directly may resolve to an older Python version in `$PATH`, installing the package into the wrong runtime).*
71
+
72
+ 2. **If using `pyenv`, regenerate shims:**
73
+ ```bash
74
+ pyenv rehash
75
+ ```
76
+ *This ensures `which jpit` resolves to `~/.pyenv/shims/jpit`, which dynamically routes to whichever Python version is currently active in your shell.*
77
+
78
+ 3. **Verify the active executable:**
79
+ ```bash
80
+ which jpit
81
+ jpit --version
82
+ ```
83
+
84
+ > [!TIP]
85
+ > **Encountering `error: externally-managed-environment` (Homebrew Python or modern Linux / PEP 668)?**
86
+ > Modern Homebrew and Linux package managers protect their system Python prefix by default. You have two clean options:
87
+ > - **Option A (Isolated CLI via `pipx`):** Run `brew install pipx && pipx ensurepath`, then `pipx install jpit`.
88
+ > - **Option B (Direct install into Homebrew Python):** Pass `--break-system-packages`:
89
+ > ```bash
90
+ > python -m pip install --upgrade --break-system-packages jpit
91
+ > ```
92
+ > *(Completely safe: `jsonpit` has zero runtime dependencies and cannot break system packages).*
93
+
94
+ *(Both the `jsonpit` library package and the `jpit` companion package provide both `jpit` and `jsonpit` command-line executables).*
95
+
96
+ ---
97
+
35
98
  ## Quickstart
36
99
 
37
100
  ### 1. Cloud-First Triad (The Standard Pattern)
@@ -12,7 +12,7 @@ from .exceptions import (
12
12
  ProtectedAttributeError,
13
13
  TombstoneError,
14
14
  )
15
- from .fs import OsConfig
15
+ from .config import DEFAULT_CONFIG_FILE_LOCATION, OsConfig, missing_configuration_diagnostic
16
16
  from .history import PitItems
17
17
  from .icons import Icons
18
18
  from .item import PitItem
@@ -22,7 +22,7 @@ try:
22
22
  import importlib.metadata
23
23
  __version__ = importlib.metadata.version("jsonpit")
24
24
  except Exception:
25
- __version__ = "4.4.3"
25
+ __version__ = "4.4.4"
26
26
 
27
27
  __all__ = [
28
28
  "Pit",
@@ -31,6 +31,8 @@ __all__ = [
31
31
  "PitItem",
32
32
  "PitItems",
33
33
  "OsConfig",
34
+ "DEFAULT_CONFIG_FILE_LOCATION",
35
+ "missing_configuration_diagnostic",
34
36
  "Icons",
35
37
  "JsonPitError",
36
38
  "PitNotFoundError",
@@ -19,7 +19,7 @@ import sys
19
19
  from typing import Any
20
20
 
21
21
  from .canonical import canonical_json, format_iso_timestamp, parse_iso_timestamp, utcnow
22
- from .config import OsConfig, loads_json5
22
+ from .config import OsConfig, loads_json5, missing_configuration_diagnostic
23
23
  from .exceptions import JsonPitError, PitNotFoundError, ProtectedAttributeError
24
24
  from .fs import resolve_pit_target
25
25
  from .item import PitItem
@@ -70,21 +70,39 @@ def discover_pits(
70
70
  return discovered_cwd
71
71
 
72
72
  # Check if target is a single pit or an explicit directory
73
- try:
74
- p_dir, p_name = resolve_pit_target(target, cloud=cloud, root=root)
75
- if (p_dir / f"{p_name}.pit").is_file() or p_dir.is_dir():
76
- return [(p_dir, p_name)]
77
- except Exception:
78
- pass
79
-
80
- # Check if target is a tenant/root folder containing multiple pit directories
73
+ raw_str = str(target).strip()
74
+ is_explicit_path = (
75
+ raw_str.startswith(("/", "~", ".", "\\"))
76
+ or ("/" in raw_str and not raw_str.startswith("-"))
77
+ or ("\\" in raw_str)
78
+ or Path(raw_str).exists()
79
+ )
80
+ if is_explicit_path:
81
+ try:
82
+ p_dir, p_name = resolve_pit_target(target, cloud=cloud, root=root)
83
+ if (p_dir / f"{p_name}.pit").is_file() or p_dir.is_dir():
84
+ return [(p_dir, p_name)]
85
+ except Exception:
86
+ pass
87
+ if Path(target).is_dir():
88
+ discovered = []
89
+ for child in sorted(Path(target).iterdir()):
90
+ if child.is_dir():
91
+ pit_file = child / f"{child.name}.pit"
92
+ if pit_file.is_file():
93
+ discovered.append((child, child.name))
94
+ if discovered:
95
+ return discovered
96
+
97
+ # Target requires cloud resolution
81
98
  cfg = OsConfig.load()
99
+ if not cfg.is_config_loaded and not is_explicit_path:
100
+ raise PitNotFoundError(missing_configuration_diagnostic())
101
+
82
102
  cloud_root = cfg.get_cloud_root(cloud)
83
103
  candidates: list[Path] = []
84
104
  if cloud_root and (cloud_root / target).is_dir():
85
105
  candidates.append(cloud_root / target)
86
- if Path(target).is_dir():
87
- candidates.append(Path(target))
88
106
 
89
107
  discovered: list[tuple[Path, str]] = []
90
108
  for candidate_root in candidates:
@@ -97,13 +115,10 @@ def discover_pits(
97
115
  if discovered:
98
116
  return discovered
99
117
 
100
- # Fallback single pit target (only return if it physically exists)
101
- try:
102
- p_dir, p_name = resolve_pit_target(target, cloud=cloud, root=root)
103
- if (p_dir / f"{p_name}.pit").is_file() or p_dir.is_dir():
104
- return [(p_dir, p_name)]
105
- except Exception:
106
- pass
118
+ # Fallback single pit target
119
+ p_dir, p_name = resolve_pit_target(target, cloud=cloud, root=root)
120
+ if (p_dir / f"{p_name}.pit").is_file() or p_dir.is_dir():
121
+ return [(p_dir, p_name)]
107
122
  return []
108
123
 
109
124
 
@@ -111,17 +126,16 @@ def discover_root_pits(root: str | None, cloud: str | None = "OneDrive") -> list
111
126
  """Discovers all pit names under a resolved tenant root directory."""
112
127
  if not root:
113
128
  return []
114
- cfg = OsConfig.load()
115
- cloud_root = cfg.get_cloud_root(cloud or "OneDrive")
116
- candidate: Path | None = None
117
- if cloud_root and (cloud_root / root).is_dir():
118
- candidate = cloud_root / root
129
+ raw_str = str(root).strip()
130
+ p = Path(os.path.expanduser(raw_str))
131
+ if p.is_dir():
132
+ candidate: Path | None = p
119
133
  else:
120
- p = Path(os.path.expanduser(root))
121
- if p.is_dir():
122
- candidate = p
123
- elif cloud_root:
124
- candidate = cloud_root / root
134
+ cfg = OsConfig.load()
135
+ if not cfg.is_config_loaded:
136
+ raise PitNotFoundError(missing_configuration_diagnostic())
137
+ cloud_root = cfg.get_cloud_root(cloud or "OneDrive")
138
+ candidate = cloud_root / root if cloud_root else None
125
139
 
126
140
  if not candidate or not candidate.is_dir():
127
141
  return []
@@ -735,7 +749,10 @@ def print_top_help(
735
749
  # Dynamic Pits Discovery line
736
750
  pits_title = color(f"{Icons.INFO} PitNames", C_CYAN, use_color)
737
751
  if root:
738
- discovered = discover_root_pits(root, cloud)
752
+ try:
753
+ discovered = discover_root_pits(root, cloud)
754
+ except Exception:
755
+ discovered = []
739
756
  if discovered:
740
757
  formatted_pits = []
741
758
  for idx, p in enumerate(discovered):
@@ -217,6 +217,20 @@ def loads_json5(text: str) -> Any:
217
217
  return parse_value()
218
218
 
219
219
 
220
+ DEFAULT_CONFIG_FILE_LOCATION: str = "~/.config/RAIkeep.json5"
221
+
222
+
223
+ def missing_configuration_diagnostic() -> str:
224
+ """
225
+ CR044 §7.4: Standardized diagnostic when RAIkeep configuration is not found.
226
+ Directs the operator to 'amafu init'.
227
+ """
228
+ return (
229
+ f"RAIkeep configuration was not found at '{DEFAULT_CONFIG_FILE_LOCATION}'. "
230
+ "Run 'amafu init' to detect cloud providers and create it."
231
+ )
232
+
233
+
220
234
  class OsConfig:
221
235
  """
222
236
  System configuration derived from ~/.config/RAIkeep.json5 or fallback files.
@@ -253,6 +267,16 @@ class OsConfig:
253
267
  if path_str:
254
268
  self.clouds[name] = self._normalize_path(str(path_str))
255
269
 
270
+ @property
271
+ def is_config_loaded(self) -> bool:
272
+ """Returns True if configuration was loaded from a file or explicit dictionary."""
273
+ return self._config_path is not None or bool(self.clouds)
274
+
275
+ @classmethod
276
+ def reset(cls) -> None:
277
+ """Resets the singleton instance (used in tests)."""
278
+ cls._instance = None
279
+
256
280
  @staticmethod
257
281
  def _normalize_path(p: str) -> Path:
258
282
  expanded = os.path.expanduser(p.strip())
@@ -11,7 +11,7 @@ import shutil
11
11
  from pathlib import Path
12
12
  from typing import Any
13
13
 
14
- from .config import OsConfig
14
+ from .config import DEFAULT_CONFIG_FILE_LOCATION, OsConfig, missing_configuration_diagnostic
15
15
  from .exceptions import PitNotFoundError
16
16
 
17
17
 
@@ -52,12 +52,16 @@ def resolve_pit_target(
52
52
  pit_name = resolved.name
53
53
  return pit_dir, pit_name
54
54
 
55
+ # CR044 §7.4: If attempting cloud triad resolution and no configuration file exists
56
+ if not cfg.is_config_loaded:
57
+ raise PitNotFoundError(missing_configuration_diagnostic())
58
+
55
59
  # Cloud triad resolution (e.g. name="Person", cloud="OneDrive", root="AfricaStage")
56
60
  cloud_root = cfg.get_cloud_root(cloud)
57
61
  if cloud_root is None:
58
62
  raise PitNotFoundError(
59
63
  f"Could not resolve cloud storage root for cloud '{cloud or 'default'}'. "
60
- "Ensure ~/.config/RAIkeep.json5 or ~/.config/jsonpit.json5 is configured."
64
+ f"Ensure {DEFAULT_CONFIG_FILE_LOCATION} or ~/.config/jsonpit.json5 is configured."
61
65
  )
62
66
 
63
67
  pit_name = raw_str
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "jsonpit"
7
- version = "4.4.3"
7
+ version = "4.4.4"
8
8
  description = "Daemon-free distributed storage over Cloud Drives for developers and AI agents — multi-process, immutable history, zero dependencies."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes