Skip to content

Commit e006160

Browse files
committed
feat: add health module
1 parent d65b35a commit e006160

9 files changed

Lines changed: 693 additions & 71 deletions

File tree

ATTRIBUTIONS.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,40 @@ without prior written permission from Aignostics GmbH.
273273
274274
```
275275

276+
## annotated-types (0.7.0) - MIT License
277+
278+
Reusable constraint types to use with typing.Annotated
279+
280+
* URL: https://github.com/annotated-types/annotated-types
281+
* Author(s): Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>, Samuel Colvin <s@muelcolvin.com>, Zac Hatfield-Dodds <zac@zhd.dev>
282+
283+
### License Text
284+
285+
```
286+
The MIT License (MIT)
287+
288+
Copyright (c) 2022 the contributors
289+
290+
Permission is hereby granted, free of charge, to any person obtaining a copy
291+
of this software and associated documentation files (the "Software"), to deal
292+
in the Software without restriction, including without limitation the rights
293+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
294+
copies of the Software, and to permit persons to whom the Software is
295+
furnished to do so, subject to the following conditions:
296+
297+
The above copyright notice and this permission notice shall be included in all
298+
copies or substantial portions of the Software.
299+
300+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
301+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
302+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
303+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
304+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
305+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
306+
SOFTWARE.
307+
308+
```
309+
276310
## argcomplete (3.6.3) - Apache Software License
277311

278312
Bash tab completion for argparse
@@ -5123,6 +5157,74 @@ Library for serializing and deserializing Python Objects to and from JSON and XM
51235157
51245158
```
51255159

5160+
## pydantic (2.12.5) - UNKNOWN
5161+
5162+
Data validation using Python type hints
5163+
5164+
* URL: https://github.com/pydantic/pydantic
5165+
* Author(s): Samuel Colvin <s@muelcolvin.com>, Eric Jolibois <em.jolibois@gmail.com>, Hasan Ramezani <hasan.r67@gmail.com>, Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>, Terrence Dorsey <terry@pydantic.dev>, David Montague <david@pydantic.dev>, Serge Matveenko <lig@countzero.co>, Marcelo Trylesinski <marcelotryle@gmail.com>, Sydney Runkle <sydneymarierunkle@gmail.com>, David Hewitt <mail@davidhewitt.io>, Alex Hall <alex.mojaki@gmail.com>, Victorien Plot <contact@vctrn.dev>, Douwe Maan <hi@douwe.me>
5166+
5167+
### License Text
5168+
5169+
```
5170+
The MIT License (MIT)
5171+
5172+
Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors.
5173+
5174+
Permission is hereby granted, free of charge, to any person obtaining a copy
5175+
of this software and associated documentation files (the "Software"), to deal
5176+
in the Software without restriction, including without limitation the rights
5177+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5178+
copies of the Software, and to permit persons to whom the Software is
5179+
furnished to do so, subject to the following conditions:
5180+
5181+
The above copyright notice and this permission notice shall be included in all
5182+
copies or substantial portions of the Software.
5183+
5184+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5185+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5186+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5187+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5188+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5189+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5190+
SOFTWARE.
5191+
5192+
```
5193+
5194+
## pydantic_core (2.41.5) - UNKNOWN
5195+
5196+
Core functionality for Pydantic validation and serialization
5197+
5198+
* URL: https://github.com/pydantic/pydantic-core
5199+
* Author(s): Samuel Colvin <s@muelcolvin.com>, Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>, David Montague <david@pydantic.dev>, David Hewitt <mail@davidhewitt.dev>, Sydney Runkle <sydneymarierunkle@gmail.com>, Victorien Plot <contact@vctrn.dev>
5200+
5201+
### License Text
5202+
5203+
```
5204+
The MIT License (MIT)
5205+
5206+
Copyright (c) 2022 Samuel Colvin
5207+
5208+
Permission is hereby granted, free of charge, to any person obtaining a copy
5209+
of this software and associated documentation files (the "Software"), to deal
5210+
in the Software without restriction, including without limitation the rights
5211+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5212+
copies of the Software, and to permit persons to whom the Software is
5213+
furnished to do so, subject to the following conditions:
5214+
5215+
The above copyright notice and this permission notice shall be included in all
5216+
copies or substantial portions of the Software.
5217+
5218+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5219+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5220+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5221+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5222+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5223+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5224+
SOFTWARE.
5225+
5226+
```
5227+
51265228
## pyparsing (3.3.2) - UNKNOWN
51275229

51285230
pyparsing - Classes and methods to define and execute parsing grammars
@@ -7747,6 +7849,40 @@ DEALINGS IN THE SOFTWARE.
77477849
77487850
```
77497851

7852+
## typing-inspection (0.4.2) - UNKNOWN
7853+
7854+
Runtime typing introspection tools
7855+
7856+
* URL: https://github.com/pydantic/typing-inspection
7857+
* Author(s): Victorien Plot <contact@vctrn.dev>
7858+
7859+
### License Text
7860+
7861+
```
7862+
MIT License
7863+
7864+
Copyright (c) Pydantic Services Inc. 2025 to present
7865+
7866+
Permission is hereby granted, free of charge, to any person obtaining a copy
7867+
of this software and associated documentation files (the "Software"), to deal
7868+
in the Software without restriction, including without limitation the rights
7869+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7870+
copies of the Software, and to permit persons to whom the Software is
7871+
furnished to do so, subject to the following conditions:
7872+
7873+
The above copyright notice and this permission notice shall be included in all
7874+
copies or substantial portions of the Software.
7875+
7876+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7877+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7878+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7879+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7880+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7881+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7882+
SOFTWARE.
7883+
7884+
```
7885+
77507886
## typing_extensions (4.15.0) - UNKNOWN
77517887

77527888
Backported and Experimental Type Hints for Python 3.9+

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ classifiers = [
4949

5050
requires-python = ">=3.11, <3.15"
5151

52-
dependencies = []
52+
dependencies = [
53+
"pydantic>=2,<3",
54+
]
5355

5456
[dependency-groups]
5557
dev = [

src/aignostics_foundry_core/AGENTS.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,27 @@ This file provides an overview of all modules in `aignostics_foundry_core`, thei
88

99
| Module | Purpose | Description |
1010
|--------|---------|-------------|
11-
| **greet** | Example module | Provides greeting functionality |
11+
| **health** | Service health checks | `Health` model and `HealthStatus` enum for tree-structured health status |
1212

1313
## Module Descriptions
1414

1515
<!-- For each module, document its purpose, features, dependencies, and usage. -->
1616

17-
### greet
17+
### health
1818

19-
**Greeting functionality for Foundry Python Core**
19+
**Tree-structured health status for service health checks**
2020

21-
- **Purpose**: Provides greeting utilities
22-
- **Key Features**: Simple greeting with logging
23-
- **Location**: `aignostics_foundry_core/greet.py`
24-
25-
<!-- Add descriptions for additional modules as you develop them -->
21+
- **Purpose**: Provides `Health` and `HealthStatus` for modelling UP / DEGRADED / DOWN status across a tree of service components
22+
- **Key Features**:
23+
- `HealthStatus(StrEnum)``UP`, `DEGRADED`, `DOWN` values
24+
- `Health(BaseModel)` — pydantic model with `status`, `reason`, `components`, `uptime_statistics`
25+
- `compute_health_from_components()` — recursively propagates DOWN/DEGRADED from children to parent (DOWN trumps DEGRADED)
26+
- `validate_health_state()` — model validator: DOWN/DEGRADED require a reason; UP must not have one
27+
- `__str__` — returns `"UP"`, `"DEGRADED: <reason>"`, or `"DOWN: <reason>"`
28+
- `__bool__``True` iff status is `UP`
29+
- `Health.Code``ClassVar` alias for `HealthStatus` (convenience)
30+
- **Location**: `aignostics_foundry_core/health.py`
31+
- **Dependencies**: `pydantic>=2`
2632

2733
## Architecture
2834

@@ -34,30 +40,37 @@ This file provides an overview of all modules in `aignostics_foundry_core`, thei
3440
-->
3541

3642
```text
37-
<!-- Example architecture diagram (customize for your project):
38-
3943
┌─────────────────────────────┐
4044
│ Your Application │
4145
└──────────────┬──────────────┘
4246
4347
┌──────────────┴──────────────┐
44-
aignostics_foundry_core
48+
│ aignostics_foundry_core │
4549
├─────────────────────────────┤
46-
module_a │ module_b │
50+
health
4751
└─────────────────────────────┘
48-
-->
4952
```
5053

5154
## Usage Examples
5255

53-
<!-- Document common usage patterns for your package -->
54-
5556
```python
56-
from aignostics_foundry_core import greet
57-
58-
# Example usage
59-
result = greet("World")
60-
print(result) # Hello, World!
57+
from aignostics_foundry_core import Health, HealthStatus
58+
59+
# Simple UP status
60+
health = Health(status=HealthStatus.UP)
61+
assert bool(health) # True
62+
assert str(health) == "UP"
63+
64+
# Composite health — DOWN propagates from components automatically
65+
system = Health(
66+
status=HealthStatus.UP,
67+
components={
68+
"db": Health(status=HealthStatus.UP),
69+
"cache": Health(status=HealthStatus.DOWN, reason="Connection refused"),
70+
},
71+
)
72+
assert system.status == HealthStatus.DOWN
73+
assert "cache" in system.reason
6174
```
6275

6376
## Development Guidelines
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Foundational infrastructure for Foundry components."""
22

3-
from .greet import greet
3+
from .health import Health, HealthStatus
44

5-
__all__ = ["greet"]
5+
__all__ = ["Health", "HealthStatus"]

src/aignostics_foundry_core/greet.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)