freshctx 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.
- freshctx-0.1.0/API.md +134 -0
- freshctx-0.1.0/ARCHITECTURE.md +101 -0
- freshctx-0.1.0/BACKLOG.md +66 -0
- freshctx-0.1.0/CHANGELOG.md +29 -0
- freshctx-0.1.0/CODE_OF_CONDUCT.md +71 -0
- freshctx-0.1.0/CONTRIBUTING.md +38 -0
- freshctx-0.1.0/GOVERNANCE.md +5 -0
- freshctx-0.1.0/LICENSE +202 -0
- freshctx-0.1.0/MANIFEST.in +24 -0
- freshctx-0.1.0/Makefile +16 -0
- freshctx-0.1.0/NOTICE +6 -0
- freshctx-0.1.0/PKG-INFO +351 -0
- freshctx-0.1.0/PROJECT_STATUS.md +56 -0
- freshctx-0.1.0/README.md +318 -0
- freshctx-0.1.0/RELEASING.md +13 -0
- freshctx-0.1.0/SECURITY.md +21 -0
- freshctx-0.1.0/SPEC.md +30 -0
- freshctx-0.1.0/SUPPORT.md +9 -0
- freshctx-0.1.0/THIRD_PARTY_NOTICES.md +7 -0
- freshctx-0.1.0/TRADEMARKS.md +7 -0
- freshctx-0.1.0/adr/0001-local-first-sqlite.md +15 -0
- freshctx-0.1.0/adr/0002-fail-closed-and-four-states.md +15 -0
- freshctx-0.1.0/adr/0003-sha256-canonical-fingerprints.md +15 -0
- freshctx-0.1.0/adr/0004-adapters-own-validation.md +15 -0
- freshctx-0.1.0/adr/0005-declared-dependency-graph.md +15 -0
- freshctx-0.1.0/docs/ADAPTER_CONTRACT.md +58 -0
- freshctx-0.1.0/docs/FAQ.md +45 -0
- freshctx-0.1.0/docs/PERFORMANCE.md +5 -0
- freshctx-0.1.0/docs/SECURITY_MODEL.md +9 -0
- freshctx-0.1.0/docs/SUCCESS_CASES.md +48 -0
- freshctx-0.1.0/examples/audit_reasoning_drift.py +17 -0
- freshctx-0.1.0/examples/coding_file_drift.py +21 -0
- freshctx-0.1.0/examples/configuration_api_drift.py +43 -0
- freshctx-0.1.0/examples/quickstart.py +26 -0
- freshctx-0.1.0/examples/real_world_success_cases.py +488 -0
- freshctx-0.1.0/examples/stale_config.py +25 -0
- freshctx-0.1.0/pyproject.toml +40 -0
- freshctx-0.1.0/schemas/audit-event.schema.json +17 -0
- freshctx-0.1.0/schemas/check-result.schema.json +16 -0
- freshctx-0.1.0/schemas/observation-token.schema.json +17 -0
- freshctx-0.1.0/schemas/reasoning-node.schema.json +16 -0
- freshctx-0.1.0/scripts/banking_postgres_success_case.py +118 -0
- freshctx-0.1.0/scripts/release_check.py +66 -0
- freshctx-0.1.0/setup.cfg +4 -0
- freshctx-0.1.0/src/freshctx/__init__.py +15 -0
- freshctx-0.1.0/src/freshctx/adapters.py +175 -0
- freshctx-0.1.0/src/freshctx/core.py +137 -0
- freshctx-0.1.0/src/freshctx/errors.py +25 -0
- freshctx-0.1.0/src/freshctx/model.py +68 -0
- freshctx-0.1.0/src/freshctx/redaction.py +33 -0
- freshctx-0.1.0/src/freshctx/schemas/audit-event.schema.json +17 -0
- freshctx-0.1.0/src/freshctx/schemas/check-result.schema.json +16 -0
- freshctx-0.1.0/src/freshctx/schemas/observation-token.schema.json +17 -0
- freshctx-0.1.0/src/freshctx/schemas/reasoning-node.schema.json +16 -0
- freshctx-0.1.0/src/freshctx/store.py +71 -0
- freshctx-0.1.0/src/freshctx.egg-info/PKG-INFO +351 -0
- freshctx-0.1.0/src/freshctx.egg-info/SOURCES.txt +63 -0
- freshctx-0.1.0/src/freshctx.egg-info/dependency_links.txt +1 -0
- freshctx-0.1.0/src/freshctx.egg-info/requires.txt +12 -0
- freshctx-0.1.0/src/freshctx.egg-info/top_level.txt +1 -0
- freshctx-0.1.0/tests/test_external_gate.py +117 -0
- freshctx-0.1.0/tests/test_release_features.py +298 -0
- freshctx-0.1.0/tests/test_schemas.py +105 -0
- freshctx-0.1.0/tests/test_success_cases.py +55 -0
- freshctx-0.1.0/tests/test_vertical_slice.py +78 -0
freshctx-0.1.0/API.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# FreshCtx Python API contract
|
|
2
|
+
|
|
3
|
+
Status: frozen v0.1 release-candidate contract.
|
|
4
|
+
|
|
5
|
+
## `guard()`
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
guard(
|
|
9
|
+
policy: str = "block",
|
|
10
|
+
store: Store | None = None,
|
|
11
|
+
run_id: str | None = None,
|
|
12
|
+
audit_path: str | Path = ".freshctx/audit.jsonl",
|
|
13
|
+
) -> Guard
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Creates a run-local enforcement context. Nested guards are permitted only when their dependencies remain isolated. On successful context exit, the guard checks the most recently protected subject. If no subject was protected, it exits without a freshness evaluation.
|
|
17
|
+
|
|
18
|
+
Supported policies:
|
|
19
|
+
|
|
20
|
+
- `block`: raise `FreshnessBlocked` for any non-current result.
|
|
21
|
+
- `warn`: emit `RuntimeWarning` and permit exit.
|
|
22
|
+
- `allow`: permit exit and retain the non-current audit result.
|
|
23
|
+
- `refresh`: invoke one registered callback, recheck once, and block unless the replacement subject becomes current.
|
|
24
|
+
|
|
25
|
+
`Guard.result` contains the final `CheckResult` after automatic enforcement.
|
|
26
|
+
|
|
27
|
+
## `observe()`
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
observe(
|
|
31
|
+
locator: str | PathLike,
|
|
32
|
+
adapter: str | None = None,
|
|
33
|
+
**options: object,
|
|
34
|
+
) -> ObservationToken
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Requires an active guard. If `adapter` is omitted, v0.1 selects `filesystem`. The adapter observes the source, the token is persisted, and an audit event is emitted.
|
|
38
|
+
|
|
39
|
+
Current adapter options:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
observe("config.yaml")
|
|
43
|
+
observe("/repo", adapter="git", scope="repository")
|
|
44
|
+
observe("/repo", adapter="git", scope="path", path="config.yaml", ref="HEAD")
|
|
45
|
+
observe("config.yaml", root=".", max_file_bytes=16 * 1024 * 1024)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Unknown adapters raise the public `ConfigurationError` exception.
|
|
49
|
+
|
|
50
|
+
## `reasoning()`
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
reasoning(
|
|
54
|
+
kind: str,
|
|
55
|
+
depends_on: Iterable[ObservationToken | ReasoningNode | ReasoningContext | str],
|
|
56
|
+
metadata: dict | None = None,
|
|
57
|
+
) -> ReasoningContext
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Requires an active guard when the context exits. A successful exit persists one `ReasoningNode`. An exceptional exit does not create a valid node. The completed context may be supplied to `depends_on`; using it before completion raises `FreshCtxError`.
|
|
61
|
+
|
|
62
|
+
The digest is SHA-256 of canonical JSON over domain `freshctx.reasoning-digest.v1`, reasoning kind, sorted/deduplicated dependency IDs, and redacted metadata. Metadata keys must be strings; dictionary and set ordering are canonical, sets are stored as sorted lists, list ordering is meaningful, and unsupported or non-finite values raise `ConfigurationError`. It stores no raw prompts, hidden reasoning, model output, or source content. The digest identifies the declared reasoning inputs within this contract; it is not a signature, authorization decision, tamper-proof evidence, or proof of correctness. Source freshness always comes from adapter revalidation.
|
|
63
|
+
|
|
64
|
+
## `Guard.protect()`
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
Guard.protect(
|
|
68
|
+
value: object = None,
|
|
69
|
+
*,
|
|
70
|
+
depends_on: Iterable[dependency],
|
|
71
|
+
boundary: str = "output",
|
|
72
|
+
) -> object
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Registers a protected output or action. When one dependency is supplied, it becomes the subject directly. Multiple dependencies create a synthetic boundary node. The input `value` is returned unchanged.
|
|
76
|
+
|
|
77
|
+
Call `protect()` immediately before the real side effect when possible. Guard exit enforcement cannot prevent a side effect that already happened inside the context.
|
|
78
|
+
|
|
79
|
+
## `Guard.run()`
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
Guard.run(
|
|
83
|
+
action: Callable,
|
|
84
|
+
*args: object,
|
|
85
|
+
depends_on: Iterable[dependency],
|
|
86
|
+
boundary: str = "action",
|
|
87
|
+
refresh: Callable[[CheckResult], dependency | None] | None = None,
|
|
88
|
+
**kwargs: object,
|
|
89
|
+
) -> object
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This is the required API for protected side effects. It resolves freshness and records the allow decision before invoking `action`. Under `block` or `refresh`, a non-current result or required audit failure raises `FreshnessBlocked` and the callable is not invoked. Refresh is attempted at most once.
|
|
93
|
+
|
|
94
|
+
## `Guard.check()`
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
Guard.check(subject: dependency | None = None) -> CheckResult
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Evaluates a subject without automatically raising. If omitted, the latest protected subject is used. The caller may inspect `state`, `causes`, `adapter_results`, and `policy_decision`.
|
|
101
|
+
|
|
102
|
+
## `FreshnessBlocked`
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
class FreshnessBlocked(RuntimeError):
|
|
106
|
+
result: CheckResult
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Raised by the blocking policy. The message is safe and concise; detailed machine-readable evidence is available through `result`.
|
|
110
|
+
|
|
111
|
+
## Domain objects
|
|
112
|
+
|
|
113
|
+
The authoritative fields are defined in `schemas/`. Python dataclasses use immutable instances. IDs are UUID strings in the current implementation; future ULID support must preserve string compatibility.
|
|
114
|
+
|
|
115
|
+
`ReasoningNode.dependencies` is the canonical graph-edge representation. Stores are immutable by ID: identical repeats are idempotent; different content under an existing ID raises `StorageConflictError` and preserves the original. `SQLiteStore.close()` closes its local connection.
|
|
116
|
+
|
|
117
|
+
The filesystem adapter accepts `root`, `max_file_bytes` (default 16 MiB), `max_total_bytes` (64 MiB), `max_entries` (10,000), and `follow_symlinks` (false). Followed file symlinks must resolve inside `root`; directory symlink traversal is unsupported. Limit and scope failures validate as `UNVERIFIABLE`. External adapters may keep credentials, readers, or other validation inputs only in process-local state; applications must reconstruct that state after restart.
|
|
118
|
+
|
|
119
|
+
## Example
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from freshctx import FreshnessBlocked, guard, observe, reasoning
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
with guard(policy="block") as ctx:
|
|
126
|
+
config = observe("config.yaml")
|
|
127
|
+
with reasoning("deployment_target", [config]) as decision:
|
|
128
|
+
target = choose_target(config)
|
|
129
|
+
ctx.run(deploy, target, depends_on=[decision], boundary="deploy")
|
|
130
|
+
except FreshnessBlocked as blocked:
|
|
131
|
+
print(blocked.result.state.value)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Asynchronous guard support is not part of v0.1.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# FreshCtx architecture
|
|
2
|
+
|
|
3
|
+
## System purpose
|
|
4
|
+
|
|
5
|
+
FreshCtx determines whether evidence and the reasoning derived from it remain current at the moment an AI agent produces a protected output or performs a protected action.
|
|
6
|
+
|
|
7
|
+
The core data flow is:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
source -> adapter.observe() -> ObservationToken
|
|
11
|
+
ObservationToken(s) -> reasoning() -> ReasoningNode
|
|
12
|
+
ReasoningNode -> guard.check() -> CheckResult
|
|
13
|
+
CheckResult + policy -> allow, warn, refresh, or block
|
|
14
|
+
all significant transitions -> AuditEvent
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Components
|
|
18
|
+
|
|
19
|
+
### Public API
|
|
20
|
+
|
|
21
|
+
`guard()`, `observe()`, `reasoning()`, and `Guard.run()` provide the framework-neutral Python surface. The API establishes a run-local context, records declared dependencies, and validates plus audits immediately before protected actions.
|
|
22
|
+
|
|
23
|
+
### Adapter registry
|
|
24
|
+
|
|
25
|
+
Adapters translate heterogeneous source state into versioned observation tokens. Every adapter implements:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
observe(locator, **options) -> ObservationToken
|
|
29
|
+
validate(token) -> AdapterResult
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Validation must be read-only. An adapter returns `equivalent`, `changed`, or `indeterminate`; it never directly selects a FreshCtx policy.
|
|
33
|
+
|
|
34
|
+
### Dependency graph
|
|
35
|
+
|
|
36
|
+
Observation tokens are leaves. Reasoning nodes reference observations or other reasoning nodes. The evaluator traverses the declared subgraph, detects missing objects and cycles, validates unique observations, and propagates stale or unverifiable states toward the protected subject.
|
|
37
|
+
|
|
38
|
+
### Evaluator
|
|
39
|
+
|
|
40
|
+
Evaluation order is deterministic:
|
|
41
|
+
|
|
42
|
+
1. Resolve the protected subject.
|
|
43
|
+
2. Load and validate the dependency graph.
|
|
44
|
+
3. Deduplicate and validate source observations.
|
|
45
|
+
4. Propagate source outcomes through reasoning nodes.
|
|
46
|
+
5. Aggregate the final state.
|
|
47
|
+
6. Apply policy.
|
|
48
|
+
7. Emit the audit result before returning or raising.
|
|
49
|
+
|
|
50
|
+
State precedence is stale over unverifiable over current. A stale observation produces `STALE_SOURCE`; a reasoning node depending on stale input produces `STALE_REASONING`.
|
|
51
|
+
|
|
52
|
+
### Policy engine
|
|
53
|
+
|
|
54
|
+
The policy layer consumes a `CheckResult`. The default `block` policy fails closed. `warn` and `allow` preserve the non-current result in audit events. The implemented `refresh` policy performs at most one caller-supplied refresh and one recheck before blocking.
|
|
55
|
+
|
|
56
|
+
### Storage
|
|
57
|
+
|
|
58
|
+
The default local store is SQLite at `.freshctx/freshctx.db`, using WAL mode and atomic transactions. Tests may use `MemoryStore`. Stored objects are immutable by ID; replacement is permitted only for identical logical records during idempotent writes.
|
|
59
|
+
|
|
60
|
+
SQLite is FreshCtx persistence. The Postgres adapter only observes application query results. Conflicting writes raise `StorageConflictError` and leave the original record unchanged.
|
|
61
|
+
|
|
62
|
+
### Audit
|
|
63
|
+
|
|
64
|
+
The default sink is append-only JSONL at `.freshctx/audit.jsonl`. Events include `schema_version`, `event_id`, `run_id`, type, timestamp, subject, and redacted details. An audit failure under the blocking policy must eventually produce `UNVERIFIABLE` and prevent the protected operation.
|
|
65
|
+
|
|
66
|
+
## Trust boundaries
|
|
67
|
+
|
|
68
|
+
- FreshCtx trusts adapters to implement side-effect-free validation.
|
|
69
|
+
- FreshCtx does not trust source availability, credentials, source metadata, or adapter exceptions.
|
|
70
|
+
- Raw source content, prompts, model outputs, credentials, and authorization material are excluded by default.
|
|
71
|
+
- FreshCtx guarantees only declared dependencies. Undeclared evidence cannot be evaluated.
|
|
72
|
+
- `CURRENT` covers only reachable declared dependencies successfully revalidated under configured adapters at check time; it does not prove source truth, logical correctness, authorization, safety, compliance, or global reality.
|
|
73
|
+
- HTTP, Postgres, and MCP perform external calls only when explicitly selected. Their readers, credentials, and other process-local validation state must be reconstructed after restart.
|
|
74
|
+
|
|
75
|
+
### Reasoning digest
|
|
76
|
+
|
|
77
|
+
`ReasoningNode.dependencies` is the canonical edge representation. IDs are sorted and deduplicated. The v0.1 digest is SHA-256 over canonical JSON containing domain `freshctx.reasoning-digest.v1`, the reasoning kind, normalized dependencies, and redacted metadata. It is identity/integrity metadata for those fields, not a signature, correctness proof, authorization result, or freshness check.
|
|
78
|
+
|
|
79
|
+
## Concurrency model
|
|
80
|
+
|
|
81
|
+
Run-local state uses `contextvars` to prevent dependency leakage between concurrent guards. SQLite access must be safe for supported thread usage. v0.1 does not guarantee multi-host coordination or distributed consensus.
|
|
82
|
+
|
|
83
|
+
## Extension model
|
|
84
|
+
|
|
85
|
+
New adapters register a unique name, version their validator evidence, return only safe audit evidence, and satisfy the shared adapter test suite. Model or framework integrations must remain optional extras layered above the core API.
|
|
86
|
+
|
|
87
|
+
## Package layout
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
src/freshctx/
|
|
91
|
+
__init__.py public exports
|
|
92
|
+
model.py canonical domain objects and states
|
|
93
|
+
adapters.py adapter implementations and registry
|
|
94
|
+
core.py contexts, evaluator, policies, and audit
|
|
95
|
+
store.py SQLite and memory persistence
|
|
96
|
+
schemas/ JSON Schema contracts
|
|
97
|
+
docs/ concept and technical specifications
|
|
98
|
+
adr/ architectural decisions
|
|
99
|
+
examples/ executable demonstrations
|
|
100
|
+
tests/ behavioral and acceptance tests
|
|
101
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# FreshCtx v0.1 implementation backlog
|
|
2
|
+
|
|
3
|
+
Issues are ordered for a single initial milestone. Each item should become one Git-hosting issue and reference the technical specification.
|
|
4
|
+
|
|
5
|
+
## Completed v0.1 implementation items
|
|
6
|
+
|
|
7
|
+
1. Protected action wrapper — completed
|
|
8
|
+
- Validate immediately before invoking a side effect.
|
|
9
|
+
- Add tests proving blocked actions never execute.
|
|
10
|
+
2. Graph validation — completed
|
|
11
|
+
- Detect cycles and missing dependencies without recursion failure.
|
|
12
|
+
- Implements acceptance test A8.
|
|
13
|
+
3. Audit failure behavior — completed
|
|
14
|
+
- Convert write failures to `UNVERIFIABLE` under block policy.
|
|
15
|
+
- Implements A11.
|
|
16
|
+
4. Redaction layer — completed baseline
|
|
17
|
+
- Redact credentials, DSNs, headers, cookies, and configurable keys.
|
|
18
|
+
- Implements A12.
|
|
19
|
+
5. Refresh policy — completed
|
|
20
|
+
- One bounded callback cycle; rebuild and recheck; otherwise block.
|
|
21
|
+
- Implements A9.
|
|
22
|
+
|
|
23
|
+
## Completed adapter contracts
|
|
24
|
+
|
|
25
|
+
6. HTTP adapter — completed
|
|
26
|
+
- Conditional GET, strong and weak ETag rules, Last-Modified, body hash, standard-library redirects, and timeout handling.
|
|
27
|
+
- Implements A3-A4.
|
|
28
|
+
7. Postgres adapter — completed with injected-connector tests
|
|
29
|
+
- Read-only validation, statement timeout, canonical rows, ordered/unordered query semantics.
|
|
30
|
+
- Implements A6.
|
|
31
|
+
8. MCP adapter — completed with safe-reader tests
|
|
32
|
+
- Server identity, normalized arguments, safe resource/tool validator, non-idempotent protection.
|
|
33
|
+
- Implements A7.
|
|
34
|
+
|
|
35
|
+
## P1 — runtime quality
|
|
36
|
+
|
|
37
|
+
9. Concurrency isolation — completed for concurrent thread guards
|
|
38
|
+
- Concurrent guards, run IDs, SQLite access, context propagation.
|
|
39
|
+
- Implements A10.
|
|
40
|
+
10. Public exception hierarchy — completed for v0.1 behaviors
|
|
41
|
+
- Configuration, storage-conflict, filesystem-boundary, audit, and enforcement exceptions.
|
|
42
|
+
11. Store migrations
|
|
43
|
+
- Schema version table, forward migration command, corruption handling.
|
|
44
|
+
12. Shared adapter conformance tests
|
|
45
|
+
- Equivalent/changed/indeterminate, timeouts, redaction, side-effect safety.
|
|
46
|
+
|
|
47
|
+
## P2 — packaging and developer experience
|
|
48
|
+
|
|
49
|
+
13. CLI
|
|
50
|
+
- `freshctx check`, `freshctx audit`, `freshctx doctor`, and schema version reporting.
|
|
51
|
+
14. Type-checking and formatting
|
|
52
|
+
- Add Ruff and mypy or Pyright configuration after dependency policy is approved.
|
|
53
|
+
15. Package build verification
|
|
54
|
+
- Build wheel and source distribution; install into a clean environment.
|
|
55
|
+
16. Documentation examples
|
|
56
|
+
- Filesystem, Git, HTTP, Postgres, MCP, and framework-neutral agent examples.
|
|
57
|
+
17. Performance baseline
|
|
58
|
+
- Graph traversal, hash cost, validation latency, and large-directory behavior.
|
|
59
|
+
|
|
60
|
+
## Release gate
|
|
61
|
+
|
|
62
|
+
- Acceptance tests A1-A12 pass.
|
|
63
|
+
- Python 3.10-3.13 CI passes.
|
|
64
|
+
- Wheel and source distribution install cleanly.
|
|
65
|
+
- No required account, telemetry, or model framework.
|
|
66
|
+
- License, security policy, changelog, API contract, and schemas are present. Store migrations remain future work because v0.1 has no prior public schema.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable FreshCtx changes will be documented here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 - 2026-08-27
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Core observation and reasoning data models
|
|
10
|
+
- Filesystem adapter
|
|
11
|
+
- Git repository- and path-scoped adapter
|
|
12
|
+
- Transitive freshness evaluation
|
|
13
|
+
- Blocking, warning, and allow policies
|
|
14
|
+
- SQLite and in-memory stores
|
|
15
|
+
- Local JSONL audit events
|
|
16
|
+
- Initial end-to-end tests
|
|
17
|
+
- Pre-action protected execution
|
|
18
|
+
- Graph corruption and depth safeguards
|
|
19
|
+
- Fail-closed audit handling and redaction
|
|
20
|
+
- HTTP, Postgres, and MCP adapter contracts
|
|
21
|
+
- Bounded refresh and concurrency isolation
|
|
22
|
+
- Wheel packaging and release automation
|
|
23
|
+
- External developer gate coverage for selective invalidation and safe connection-loss behavior
|
|
24
|
+
- Three executable reference demos for file, configuration/API, and audit reasoning drift
|
|
25
|
+
- Versioned deterministic reasoning digests over normalized dependencies and redacted metadata
|
|
26
|
+
- Immutable-by-ID SQLite and memory-store writes with conflict errors
|
|
27
|
+
- Runtime-produced JSON Schema conformance and negative-fixture coverage
|
|
28
|
+
- Bounded streaming filesystem traversal with explicit symlink and root policy
|
|
29
|
+
- Community security, conduct, support, ownership, trademark, and third-party notices
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socioeconomic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment include:
|
|
12
|
+
|
|
13
|
+
- Demonstrating empathy and kindness toward other people.
|
|
14
|
+
- Respecting differing opinions, viewpoints, and experiences.
|
|
15
|
+
- Giving and gracefully accepting constructive feedback.
|
|
16
|
+
- Accepting responsibility, apologizing to those affected by our mistakes, and learning from the experience.
|
|
17
|
+
- Focusing on what is best for the overall community.
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
- Sexualized language or imagery, and sexual attention or advances of any kind.
|
|
22
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks.
|
|
23
|
+
- Public or private harassment.
|
|
24
|
+
- Publishing another person’s private information without explicit permission.
|
|
25
|
+
- Other conduct which could reasonably be considered inappropriate in a professional setting.
|
|
26
|
+
|
|
27
|
+
## Enforcement Responsibilities
|
|
28
|
+
|
|
29
|
+
Project maintainers are responsible for clarifying and enforcing standards of acceptable behavior. They will take appropriate and fair corrective action in response to behavior they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
+
|
|
31
|
+
Maintainers may remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
32
|
+
|
|
33
|
+
## Scope
|
|
34
|
+
|
|
35
|
+
This Code applies within all community spaces and when an individual officially represents the community in public spaces. Examples include using an official email address, posting through an official social-media account, or acting as an appointed representative at an event.
|
|
36
|
+
|
|
37
|
+
## Enforcement
|
|
38
|
+
|
|
39
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported confidentially to `conduct@hyperwise.io`. Hyperwise LLC’s project maintainers will review complaints promptly and fairly. All maintainers must respect the privacy and security of the reporter. A maintainer with a conflict of interest must recuse themselves. Do not use the security inbox for conduct reports.
|
|
40
|
+
|
|
41
|
+
## Enforcement Guidelines
|
|
42
|
+
|
|
43
|
+
Maintainers will follow these Community Impact Guidelines when determining consequences:
|
|
44
|
+
|
|
45
|
+
### 1. Correction
|
|
46
|
+
|
|
47
|
+
**Community impact:** Use of inappropriate language or other behavior deemed unprofessional or unwelcome.
|
|
48
|
+
|
|
49
|
+
**Consequence:** A private written warning that explains the violation and why the behavior was inappropriate. A public apology may be requested.
|
|
50
|
+
|
|
51
|
+
### 2. Warning
|
|
52
|
+
|
|
53
|
+
**Community impact:** A violation through a single incident or series of actions.
|
|
54
|
+
|
|
55
|
+
**Consequence:** A warning with consequences for continued behavior. The person may not interact with the people involved, including unsolicited interaction with those enforcing this Code, for a specified period. Violating these terms may lead to a temporary or permanent ban.
|
|
56
|
+
|
|
57
|
+
### 3. Temporary Ban
|
|
58
|
+
|
|
59
|
+
**Community impact:** A serious violation of community standards, including sustained inappropriate behavior.
|
|
60
|
+
|
|
61
|
+
**Consequence:** A temporary ban from interaction or public communication with the community for a specified period. Violating the terms may lead to a permanent ban.
|
|
62
|
+
|
|
63
|
+
### 4. Permanent Ban
|
|
64
|
+
|
|
65
|
+
**Community impact:** A pattern of violations, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
66
|
+
|
|
67
|
+
**Consequence:** A permanent ban from public interaction within the community.
|
|
68
|
+
|
|
69
|
+
## Attribution
|
|
70
|
+
|
|
71
|
+
This Code of Conduct is adapted from the [Contributor Covenant, version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html). Community Impact Guidelines were inspired by Mozilla’s code-of-conduct enforcement ladder.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Contributing to FreshCtx
|
|
2
|
+
|
|
3
|
+
FreshCtx is owned and stewarded by Hyperwise LLC and welcomes focused contributions that preserve its core guarantees: explicit freshness states, deterministic evaluation, safe validation, local-first operation, and no required telemetry. Contributors retain rights to their contributions. By submitting a contribution, you agree that it is accepted under the project's Apache License 2.0. FreshCtx v0.1 does not require a Contributor License Agreement (CLA) or Developer Certificate of Origin (DCO).
|
|
4
|
+
|
|
5
|
+
## Contribution licensing
|
|
6
|
+
|
|
7
|
+
The same Apache-2.0 terms apply to project code and accepted contributions. Hyperwise LLC does not require contributors to grant separate proprietary relicensing rights for v0.1. Commercial services and possible future products remain separate from FreshCtx core.
|
|
8
|
+
|
|
9
|
+
If Hyperwise LLC later considers a genuine dual-licensing model, it will publish and review any proposed contribution terms before accepting code that would need those additional rights. Existing contributions will not silently receive new terms.
|
|
10
|
+
|
|
11
|
+
The Apache-2.0 software license does not grant rights to use FreshCtx™ names, logos, or branding beyond truthful reference to the project. See `TRADEMARKS.md`.
|
|
12
|
+
|
|
13
|
+
## Development setup
|
|
14
|
+
|
|
15
|
+
1. Use Python 3.10 or newer.
|
|
16
|
+
2. Create and activate a virtual environment.
|
|
17
|
+
3. Install the development dependencies in editable mode.
|
|
18
|
+
4. Run the test suite before submitting changes.
|
|
19
|
+
|
|
20
|
+
```console
|
|
21
|
+
python -m venv .venv
|
|
22
|
+
source .venv/bin/activate
|
|
23
|
+
python -m pip install -e '.[dev]'
|
|
24
|
+
python -m unittest discover -s tests -v
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Contribution requirements
|
|
28
|
+
|
|
29
|
+
- Add tests for behavioral changes.
|
|
30
|
+
- Preserve the normative requirements in the versioned `SPEC.md`.
|
|
31
|
+
- Treat validation as side-effect free.
|
|
32
|
+
- Never treat an unknown or failed check as `CURRENT`.
|
|
33
|
+
- Do not persist credentials or enable telemetry by default.
|
|
34
|
+
- Keep model and agent-framework integrations optional.
|
|
35
|
+
|
|
36
|
+
Open an issue before making a breaking API or data-schema change.
|
|
37
|
+
|
|
38
|
+
See `CODE_OF_CONDUCT.md`, `SECURITY.md`, and `SUPPORT.md` for the correct private reporting and support routes.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Governance
|
|
2
|
+
|
|
3
|
+
FreshCtx™ is owned and commercially stewarded by Hyperwise LLC as an independent Apache-2.0 open-source project. Community contains the complete usable v0.1 runtime, schemas, adapter contract, examples, compatibility tests, and five initial adapters for local developer use. Maintainers appointed by Hyperwise LLC decide changes through review against the versioned specification, security requirements, compatibility tests, and project scope. Contributor identity and commit attribution are preserved, and contributors retain rights to their contributions subject to accepted contribution terms unless a different executed agreement applies.
|
|
4
|
+
|
|
5
|
+
The v0.1 contract is frozen. Breaking changes require a documented proposal, migration guidance, and a new specification version. Other Hyperwise products and possible future commercial services are separate from FreshCtx core. Hyperwise LLC may offer architecture, integration, deployment, or support separately; this statement does not claim that a hosted service, control plane, enterprise edition, or SLA exists today.
|
freshctx-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|