our-models 0.1.0__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.
- our_models-0.1.0/.github/workflows/ci.yml +24 -0
- our_models-0.1.0/.github/workflows/release.yml +13 -0
- our_models-0.1.0/.gitignore +38 -0
- our_models-0.1.0/.pre-commit-config.yaml +33 -0
- our_models-0.1.0/CHANGELOG.md +11 -0
- our_models-0.1.0/LICENSE +21 -0
- our_models-0.1.0/Makefile +38 -0
- our_models-0.1.0/PKG-INFO +196 -0
- our_models-0.1.0/README.md +170 -0
- our_models-0.1.0/pyproject.toml +81 -0
- our_models-0.1.0/src/our_models/__init__.py +57 -0
- our_models-0.1.0/src/our_models/interface.py +15 -0
- our_models-0.1.0/src/our_models/models.py +504 -0
- our_models-0.1.0/src/our_models/py.typed +0 -0
- our_models-0.1.0/src/our_models/temporal.py +257 -0
- our_models-0.1.0/tests/conftest.py +206 -0
- our_models-0.1.0/tests/test_init.py +7 -0
- our_models-0.1.0/tests/test_models.py +850 -0
- our_models-0.1.0/tests/test_temporal.py +717 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
paths-ignore:
|
|
8
|
+
- '*.md'
|
|
9
|
+
- 'docs/**'
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ci-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
lint:
|
|
17
|
+
uses: ourochronos/our-infra/.github/workflows/lint.yml@main
|
|
18
|
+
with:
|
|
19
|
+
extra-install: "git+https://github.com/ourochronos/our-confidence.git"
|
|
20
|
+
test:
|
|
21
|
+
needs: lint
|
|
22
|
+
uses: ourochronos/our-infra/.github/workflows/test.yml@main
|
|
23
|
+
with:
|
|
24
|
+
extra-install: "git+https://github.com/ourochronos/our-confidence.git"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg-info/
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
env/
|
|
15
|
+
|
|
16
|
+
# Testing
|
|
17
|
+
.pytest_cache/
|
|
18
|
+
htmlcov/
|
|
19
|
+
.coverage
|
|
20
|
+
.coverage.*
|
|
21
|
+
coverage.xml
|
|
22
|
+
|
|
23
|
+
# Type checking
|
|
24
|
+
.mypy_cache/
|
|
25
|
+
|
|
26
|
+
# Linting
|
|
27
|
+
.ruff_cache/
|
|
28
|
+
|
|
29
|
+
# IDE
|
|
30
|
+
.idea/
|
|
31
|
+
.vscode/
|
|
32
|
+
*.swp
|
|
33
|
+
*.swo
|
|
34
|
+
*~
|
|
35
|
+
|
|
36
|
+
# OS
|
|
37
|
+
.DS_Store
|
|
38
|
+
Thumbs.db
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v4.6.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: check-added-large-files
|
|
9
|
+
args: ['--maxkb=500']
|
|
10
|
+
- id: check-merge-conflict
|
|
11
|
+
|
|
12
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
13
|
+
rev: v0.4.4
|
|
14
|
+
hooks:
|
|
15
|
+
- id: ruff
|
|
16
|
+
args: [--fix]
|
|
17
|
+
- id: ruff-format
|
|
18
|
+
|
|
19
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
20
|
+
rev: v1.10.0
|
|
21
|
+
hooks:
|
|
22
|
+
- id: mypy
|
|
23
|
+
additional_dependencies: []
|
|
24
|
+
args: [--config-file=pyproject.toml]
|
|
25
|
+
stages: [commit]
|
|
26
|
+
language: system
|
|
27
|
+
|
|
28
|
+
- repo: https://github.com/PyCQA/bandit
|
|
29
|
+
rev: 1.7.8
|
|
30
|
+
hooks:
|
|
31
|
+
- id: bandit
|
|
32
|
+
args: ['-q', '--severity-level', 'medium']
|
|
33
|
+
exclude: tests/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial project structure
|
our_models-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chris Jacobs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.PHONY: help install dev lint format test test-unit test-int test-cov clean
|
|
2
|
+
|
|
3
|
+
help: ## Show this help
|
|
4
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
|
5
|
+
|
|
6
|
+
install: ## Install package
|
|
7
|
+
pip install -e .
|
|
8
|
+
|
|
9
|
+
dev: ## Install package with dev dependencies
|
|
10
|
+
pip install -e ".[dev]"
|
|
11
|
+
pre-commit install
|
|
12
|
+
|
|
13
|
+
lint: ## Run linters (ruff + mypy)
|
|
14
|
+
ruff check src/ tests/
|
|
15
|
+
ruff format --check src/ tests/
|
|
16
|
+
mypy src/
|
|
17
|
+
|
|
18
|
+
format: ## Auto-format code
|
|
19
|
+
ruff check --fix src/ tests/
|
|
20
|
+
ruff format src/ tests/
|
|
21
|
+
|
|
22
|
+
test: test-unit ## Run tests (unit only by default)
|
|
23
|
+
|
|
24
|
+
test-unit: ## Run unit tests
|
|
25
|
+
pytest tests/ -m "not integration and not slow" -v
|
|
26
|
+
|
|
27
|
+
test-int: ## Run integration tests
|
|
28
|
+
pytest tests/ -m integration -v --timeout=60
|
|
29
|
+
|
|
30
|
+
test-all: ## Run all tests
|
|
31
|
+
pytest tests/ -v --timeout=120
|
|
32
|
+
|
|
33
|
+
test-cov: ## Run tests with coverage report
|
|
34
|
+
pytest tests/ -m "not integration and not slow" --cov --cov-report=term-missing --cov-report=html
|
|
35
|
+
|
|
36
|
+
clean: ## Remove build artifacts and caches
|
|
37
|
+
rm -rf build/ dist/ *.egg-info .pytest_cache .mypy_cache .ruff_cache htmlcov .coverage
|
|
38
|
+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: our-models
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Data models with temporal validity and dimensional confidence for the ourochronos ecosystem
|
|
5
|
+
Project-URL: Homepage, https://github.com/ourochronos/our-models
|
|
6
|
+
Project-URL: Repository, https://github.com/ourochronos/our-models
|
|
7
|
+
Author: Chris Jacobs
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: our-confidence>=0.1.0
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
19
|
+
Requires-Dist: pre-commit>=3.7; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest-mock>=3.12; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# our-models
|
|
28
|
+
|
|
29
|
+
Data models with temporal validity, dimensional confidence, and conversation tracking for the ourochronos ecosystem.
|
|
30
|
+
|
|
31
|
+
## Overview
|
|
32
|
+
|
|
33
|
+
our-models provides the Python dataclasses and enums that represent the Valence knowledge substrate. It bridges the PostgreSQL schema and application code with structured types for beliefs, entities, sessions, exchanges, patterns, and tensions. Key features include time-bounded validity on knowledge claims, exponential freshness decay, and supersession chains that track belief evolution.
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install our-models
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Requires `our-confidence>=0.1.0`.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### Beliefs
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from uuid import uuid4
|
|
49
|
+
from datetime import datetime
|
|
50
|
+
from our_models import Belief, BeliefStatus
|
|
51
|
+
from our_confidence import DimensionalConfidence
|
|
52
|
+
|
|
53
|
+
belief = Belief(
|
|
54
|
+
id=uuid4(),
|
|
55
|
+
content="Python 3.12 adds incremental GC",
|
|
56
|
+
confidence=DimensionalConfidence(overall=0.9),
|
|
57
|
+
domain_path=["tech", "python"],
|
|
58
|
+
valid_from=datetime.now(),
|
|
59
|
+
status=BeliefStatus.ACTIVE,
|
|
60
|
+
)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Temporal Validity
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from our_models import TemporalValidity
|
|
67
|
+
|
|
68
|
+
# Valid for a specific range
|
|
69
|
+
tv = TemporalValidity.range(start, end)
|
|
70
|
+
tv.is_valid_at(some_date) # True/False
|
|
71
|
+
tv.is_expired()
|
|
72
|
+
tv.remaining() # timedelta or None
|
|
73
|
+
|
|
74
|
+
# Always valid
|
|
75
|
+
tv = TemporalValidity.always_valid()
|
|
76
|
+
|
|
77
|
+
# Valid from now for 30 days
|
|
78
|
+
tv = TemporalValidity.for_duration(timedelta(days=30))
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Freshness Scoring
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from our_models import calculate_freshness, freshness_label
|
|
85
|
+
|
|
86
|
+
score = calculate_freshness(belief.created_at, half_life_days=30)
|
|
87
|
+
# 1.0 = just created, decays exponentially
|
|
88
|
+
|
|
89
|
+
label = freshness_label(score)
|
|
90
|
+
# "very fresh" | "fresh" | "aging" | "stale" | "very stale"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Supersession Chains
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from our_models import SupersessionChain
|
|
97
|
+
|
|
98
|
+
chain = SupersessionChain(entries=[...])
|
|
99
|
+
chain.original_id # first belief in the chain
|
|
100
|
+
chain.current_id # latest belief
|
|
101
|
+
chain.revision_count
|
|
102
|
+
chain.get_at_time(some_date) # belief that was current at that time
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Sessions and Exchanges
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from our_models import Session, Exchange, Platform, ExchangeRole
|
|
109
|
+
|
|
110
|
+
session = Session(
|
|
111
|
+
id=uuid4(),
|
|
112
|
+
platform=Platform.CLAUDE_CODE,
|
|
113
|
+
project_context="valence",
|
|
114
|
+
themes=["refactoring", "testing"],
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
exchange = Exchange(
|
|
118
|
+
session_id=session.id,
|
|
119
|
+
sequence=1,
|
|
120
|
+
role=ExchangeRole.USER,
|
|
121
|
+
content="How do I add a new MCP tool?",
|
|
122
|
+
)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Serialization
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
# All models support database round-tripping
|
|
129
|
+
d = belief.to_dict() # JSON-serializable dict
|
|
130
|
+
belief = Belief.from_row(db_row) # Reconstruct from database row
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## API
|
|
134
|
+
|
|
135
|
+
### Knowledge Models
|
|
136
|
+
|
|
137
|
+
| Class | Description |
|
|
138
|
+
|-------|-------------|
|
|
139
|
+
| `Belief` | Knowledge claim with confidence, domain path, and temporal validity |
|
|
140
|
+
| `Entity` | Person, tool, concept, etc. that beliefs reference |
|
|
141
|
+
| `Source` | Provenance information (type, URL, content hash) |
|
|
142
|
+
| `Tension` | Contradiction between beliefs with severity and resolution status |
|
|
143
|
+
| `BeliefEntity` | Junction linking a belief to an entity with a role |
|
|
144
|
+
|
|
145
|
+
### Conversation Models
|
|
146
|
+
|
|
147
|
+
| Class | Description |
|
|
148
|
+
|-------|-------------|
|
|
149
|
+
| `Session` | A conversation session with platform, themes, metadata |
|
|
150
|
+
| `Exchange` | A single turn (user/assistant/system) |
|
|
151
|
+
| `Pattern` | Behavioral pattern observed across sessions |
|
|
152
|
+
| `SessionInsight` | Link between a session and an extracted belief |
|
|
153
|
+
|
|
154
|
+
### Temporal
|
|
155
|
+
|
|
156
|
+
| Symbol | Description |
|
|
157
|
+
|--------|-------------|
|
|
158
|
+
| `TemporalValidity` | Time-bounded validity with factory methods and queries |
|
|
159
|
+
| `SupersessionChain` | Tracks belief evolution through supersessions |
|
|
160
|
+
| `calculate_freshness()` | Exponential decay scoring (configurable half-life) |
|
|
161
|
+
| `freshness_label()` | Human-readable freshness labels |
|
|
162
|
+
|
|
163
|
+
### Enums
|
|
164
|
+
|
|
165
|
+
`BeliefStatus`, `EntityType`, `EntityRole`, `SessionStatus`, `Platform`, `ExchangeRole`, `PatternStatus`, `TensionType`, `TensionSeverity`, `TensionStatus`
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Install with dev dependencies
|
|
171
|
+
make dev
|
|
172
|
+
|
|
173
|
+
# Run linters
|
|
174
|
+
make lint
|
|
175
|
+
|
|
176
|
+
# Run tests
|
|
177
|
+
make test
|
|
178
|
+
|
|
179
|
+
# Run tests with coverage
|
|
180
|
+
make test-cov
|
|
181
|
+
|
|
182
|
+
# Auto-format
|
|
183
|
+
make format
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## State Ownership
|
|
187
|
+
|
|
188
|
+
None directly. This package defines data shapes — state is owned by the database layer (`our-db`) and the substrate that persists these models.
|
|
189
|
+
|
|
190
|
+
## Part of Valence
|
|
191
|
+
|
|
192
|
+
This brick is part of the [Valence](https://github.com/ourochronos/valence) knowledge substrate. See [our-infra](https://github.com/ourochronos/our-infra) for ourochronos conventions.
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# our-models
|
|
2
|
+
|
|
3
|
+
Data models with temporal validity, dimensional confidence, and conversation tracking for the ourochronos ecosystem.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
our-models provides the Python dataclasses and enums that represent the Valence knowledge substrate. It bridges the PostgreSQL schema and application code with structured types for beliefs, entities, sessions, exchanges, patterns, and tensions. Key features include time-bounded validity on knowledge claims, exponential freshness decay, and supersession chains that track belief evolution.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install our-models
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires `our-confidence>=0.1.0`.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Beliefs
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from uuid import uuid4
|
|
23
|
+
from datetime import datetime
|
|
24
|
+
from our_models import Belief, BeliefStatus
|
|
25
|
+
from our_confidence import DimensionalConfidence
|
|
26
|
+
|
|
27
|
+
belief = Belief(
|
|
28
|
+
id=uuid4(),
|
|
29
|
+
content="Python 3.12 adds incremental GC",
|
|
30
|
+
confidence=DimensionalConfidence(overall=0.9),
|
|
31
|
+
domain_path=["tech", "python"],
|
|
32
|
+
valid_from=datetime.now(),
|
|
33
|
+
status=BeliefStatus.ACTIVE,
|
|
34
|
+
)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Temporal Validity
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from our_models import TemporalValidity
|
|
41
|
+
|
|
42
|
+
# Valid for a specific range
|
|
43
|
+
tv = TemporalValidity.range(start, end)
|
|
44
|
+
tv.is_valid_at(some_date) # True/False
|
|
45
|
+
tv.is_expired()
|
|
46
|
+
tv.remaining() # timedelta or None
|
|
47
|
+
|
|
48
|
+
# Always valid
|
|
49
|
+
tv = TemporalValidity.always_valid()
|
|
50
|
+
|
|
51
|
+
# Valid from now for 30 days
|
|
52
|
+
tv = TemporalValidity.for_duration(timedelta(days=30))
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Freshness Scoring
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from our_models import calculate_freshness, freshness_label
|
|
59
|
+
|
|
60
|
+
score = calculate_freshness(belief.created_at, half_life_days=30)
|
|
61
|
+
# 1.0 = just created, decays exponentially
|
|
62
|
+
|
|
63
|
+
label = freshness_label(score)
|
|
64
|
+
# "very fresh" | "fresh" | "aging" | "stale" | "very stale"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Supersession Chains
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from our_models import SupersessionChain
|
|
71
|
+
|
|
72
|
+
chain = SupersessionChain(entries=[...])
|
|
73
|
+
chain.original_id # first belief in the chain
|
|
74
|
+
chain.current_id # latest belief
|
|
75
|
+
chain.revision_count
|
|
76
|
+
chain.get_at_time(some_date) # belief that was current at that time
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Sessions and Exchanges
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from our_models import Session, Exchange, Platform, ExchangeRole
|
|
83
|
+
|
|
84
|
+
session = Session(
|
|
85
|
+
id=uuid4(),
|
|
86
|
+
platform=Platform.CLAUDE_CODE,
|
|
87
|
+
project_context="valence",
|
|
88
|
+
themes=["refactoring", "testing"],
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
exchange = Exchange(
|
|
92
|
+
session_id=session.id,
|
|
93
|
+
sequence=1,
|
|
94
|
+
role=ExchangeRole.USER,
|
|
95
|
+
content="How do I add a new MCP tool?",
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Serialization
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
# All models support database round-tripping
|
|
103
|
+
d = belief.to_dict() # JSON-serializable dict
|
|
104
|
+
belief = Belief.from_row(db_row) # Reconstruct from database row
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## API
|
|
108
|
+
|
|
109
|
+
### Knowledge Models
|
|
110
|
+
|
|
111
|
+
| Class | Description |
|
|
112
|
+
|-------|-------------|
|
|
113
|
+
| `Belief` | Knowledge claim with confidence, domain path, and temporal validity |
|
|
114
|
+
| `Entity` | Person, tool, concept, etc. that beliefs reference |
|
|
115
|
+
| `Source` | Provenance information (type, URL, content hash) |
|
|
116
|
+
| `Tension` | Contradiction between beliefs with severity and resolution status |
|
|
117
|
+
| `BeliefEntity` | Junction linking a belief to an entity with a role |
|
|
118
|
+
|
|
119
|
+
### Conversation Models
|
|
120
|
+
|
|
121
|
+
| Class | Description |
|
|
122
|
+
|-------|-------------|
|
|
123
|
+
| `Session` | A conversation session with platform, themes, metadata |
|
|
124
|
+
| `Exchange` | A single turn (user/assistant/system) |
|
|
125
|
+
| `Pattern` | Behavioral pattern observed across sessions |
|
|
126
|
+
| `SessionInsight` | Link between a session and an extracted belief |
|
|
127
|
+
|
|
128
|
+
### Temporal
|
|
129
|
+
|
|
130
|
+
| Symbol | Description |
|
|
131
|
+
|--------|-------------|
|
|
132
|
+
| `TemporalValidity` | Time-bounded validity with factory methods and queries |
|
|
133
|
+
| `SupersessionChain` | Tracks belief evolution through supersessions |
|
|
134
|
+
| `calculate_freshness()` | Exponential decay scoring (configurable half-life) |
|
|
135
|
+
| `freshness_label()` | Human-readable freshness labels |
|
|
136
|
+
|
|
137
|
+
### Enums
|
|
138
|
+
|
|
139
|
+
`BeliefStatus`, `EntityType`, `EntityRole`, `SessionStatus`, `Platform`, `ExchangeRole`, `PatternStatus`, `TensionType`, `TensionSeverity`, `TensionStatus`
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Install with dev dependencies
|
|
145
|
+
make dev
|
|
146
|
+
|
|
147
|
+
# Run linters
|
|
148
|
+
make lint
|
|
149
|
+
|
|
150
|
+
# Run tests
|
|
151
|
+
make test
|
|
152
|
+
|
|
153
|
+
# Run tests with coverage
|
|
154
|
+
make test-cov
|
|
155
|
+
|
|
156
|
+
# Auto-format
|
|
157
|
+
make format
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## State Ownership
|
|
161
|
+
|
|
162
|
+
None directly. This package defines data shapes — state is owned by the database layer (`our-db`) and the substrate that persists these models.
|
|
163
|
+
|
|
164
|
+
## Part of Valence
|
|
165
|
+
|
|
166
|
+
This brick is part of the [Valence](https://github.com/ourochronos/valence) knowledge substrate. See [our-infra](https://github.com/ourochronos/our-infra) for ourochronos conventions.
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "our-models"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Data models with temporal validity and dimensional confidence for the ourochronos ecosystem"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Chris Jacobs" },
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"our-confidence>=0.1.0",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/ourochronos/our-models"
|
|
28
|
+
Repository = "https://github.com/ourochronos/our-models"
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
dev = [
|
|
32
|
+
"pytest>=8.0",
|
|
33
|
+
"pytest-asyncio>=0.23",
|
|
34
|
+
"pytest-cov>=4.0",
|
|
35
|
+
"pytest-mock>=3.12",
|
|
36
|
+
"ruff>=0.4",
|
|
37
|
+
"mypy>=1.10",
|
|
38
|
+
"pre-commit>=3.7",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["src/our_models"]
|
|
43
|
+
|
|
44
|
+
[tool.ruff]
|
|
45
|
+
target-version = "py311"
|
|
46
|
+
line-length = 120
|
|
47
|
+
src = ["src", "tests"]
|
|
48
|
+
|
|
49
|
+
[tool.ruff.lint]
|
|
50
|
+
select = ["E", "F", "I", "N", "W", "UP", "B", "C4"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint.isort]
|
|
53
|
+
known-first-party = ["our_models"]
|
|
54
|
+
|
|
55
|
+
[tool.mypy]
|
|
56
|
+
python_version = "3.11"
|
|
57
|
+
disallow_untyped_defs = true
|
|
58
|
+
strict_optional = true
|
|
59
|
+
warn_redundant_casts = true
|
|
60
|
+
warn_unused_ignores = true
|
|
61
|
+
|
|
62
|
+
[[tool.mypy.overrides]]
|
|
63
|
+
module = ["our_confidence", "our_confidence.*"]
|
|
64
|
+
ignore_missing_imports = true
|
|
65
|
+
follow_untyped_imports = true
|
|
66
|
+
|
|
67
|
+
[tool.pytest.ini_options]
|
|
68
|
+
testpaths = ["tests"]
|
|
69
|
+
asyncio_mode = "auto"
|
|
70
|
+
markers = [
|
|
71
|
+
"unit: Unit tests (no external dependencies)",
|
|
72
|
+
"integration: Integration tests (require external services)",
|
|
73
|
+
"slow: Slow tests (>5s)",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[tool.coverage.run]
|
|
77
|
+
branch = true
|
|
78
|
+
source = ["src/our_models"]
|
|
79
|
+
|
|
80
|
+
[tool.coverage.report]
|
|
81
|
+
show_missing = true
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""our-models -- Data models with temporal validity and dimensional confidence for the ourochronos ecosystem."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0"
|
|
4
|
+
|
|
5
|
+
from .models import (
|
|
6
|
+
Belief,
|
|
7
|
+
BeliefEntity,
|
|
8
|
+
BeliefStatus,
|
|
9
|
+
Entity,
|
|
10
|
+
EntityRole,
|
|
11
|
+
EntityType,
|
|
12
|
+
Exchange,
|
|
13
|
+
ExchangeRole,
|
|
14
|
+
Pattern,
|
|
15
|
+
PatternStatus,
|
|
16
|
+
Platform,
|
|
17
|
+
Session,
|
|
18
|
+
SessionInsight,
|
|
19
|
+
SessionStatus,
|
|
20
|
+
Source,
|
|
21
|
+
Tension,
|
|
22
|
+
TensionSeverity,
|
|
23
|
+
TensionStatus,
|
|
24
|
+
TensionType,
|
|
25
|
+
)
|
|
26
|
+
from .temporal import (
|
|
27
|
+
SupersessionChain,
|
|
28
|
+
TemporalValidity,
|
|
29
|
+
calculate_freshness,
|
|
30
|
+
freshness_label,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
__all__ = [
|
|
34
|
+
"Belief",
|
|
35
|
+
"BeliefEntity",
|
|
36
|
+
"BeliefStatus",
|
|
37
|
+
"Entity",
|
|
38
|
+
"EntityRole",
|
|
39
|
+
"EntityType",
|
|
40
|
+
"Exchange",
|
|
41
|
+
"ExchangeRole",
|
|
42
|
+
"Pattern",
|
|
43
|
+
"PatternStatus",
|
|
44
|
+
"Platform",
|
|
45
|
+
"Session",
|
|
46
|
+
"SessionInsight",
|
|
47
|
+
"SessionStatus",
|
|
48
|
+
"Source",
|
|
49
|
+
"SupersessionChain",
|
|
50
|
+
"TemporalValidity",
|
|
51
|
+
"Tension",
|
|
52
|
+
"TensionSeverity",
|
|
53
|
+
"TensionStatus",
|
|
54
|
+
"TensionType",
|
|
55
|
+
"calculate_freshness",
|
|
56
|
+
"freshness_label",
|
|
57
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Public interface for our-models.
|
|
2
|
+
|
|
3
|
+
This brick provides data models (dataclasses) and enums rather than
|
|
4
|
+
abstract interfaces. The models themselves ARE the public contract.
|
|
5
|
+
|
|
6
|
+
Core types:
|
|
7
|
+
- Belief, Entity, Source, Tension -- knowledge substrate models
|
|
8
|
+
- Session, Exchange, Pattern, SessionInsight -- conversation tracking models
|
|
9
|
+
- TemporalValidity, SupersessionChain -- temporal utilities
|
|
10
|
+
- calculate_freshness, freshness_label -- freshness scoring
|
|
11
|
+
|
|
12
|
+
All types are re-exported from the package root:
|
|
13
|
+
|
|
14
|
+
from our_models import Belief, TemporalValidity
|
|
15
|
+
"""
|