Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ diagram, layer responsibilities, and telemetry schema.
## Examples

```bash
python anomaly_poc.py # deterministic anomaly-stream PoC
python simulation_run.py # end-to-end simulation
python examples/anomaly_detection.py # deterministic anomaly-stream PoC
python examples/simulation.py # end-to-end simulation
Comment on lines +85 to +86
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fix example entrypoints after moving scripts into examples/

The new README commands run python examples/..., but those scripts now execute with sys.path[0] set to examples/, so imports like import temporal_gradient fail on a clean checkout (ModuleNotFoundError: No module named 'temporal_gradient'). This is a regression from the root-level scripts, and it makes the primary documented examples unusable unless users manually set PYTHONPATH or install the package first.

Useful? React with 👍 / 👎.

python examples/embedding_novelty_replay_demo.py
python scripts/chronos_demo.py # minimal clock demo
```
Expand Down
3 changes: 3 additions & 0 deletions anomaly_poc.py → examples/anomaly_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import argparse
import json
import random
import sys
from dataclasses import asdict, dataclass
from pathlib import Path
from typing import Any

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

import temporal_gradient as tg
from temporal_gradient.memory.decay import DecayEngine, EntropicMemory
from temporal_gradient.telemetry.chronometric_vector import ChronometricVector
Expand Down
4 changes: 4 additions & 0 deletions calibration_harness.py → examples/calibration_harness.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import json
import random
import statistics
import sys
import time
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

from temporal_gradient.clock.chronos import ClockRateModulator
from temporal_gradient.memory.decay import DecayEngine, EntropicMemory, initial_strength_from_psi, should_encode
Expand Down
4 changes: 4 additions & 0 deletions sanity_harness.py → examples/sanity_harness.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from __future__ import annotations

import json
import sys
from pathlib import Path
from typing import Dict, List, Tuple

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

from temporal_gradient.clock.chronos import ClockRateModulator
from temporal_gradient.telemetry.chronometric_vector import ChronometricVector
from temporal_gradient.telemetry.schema import validate_packet_schema
Expand Down
5 changes: 5 additions & 0 deletions simulation_run.py → examples/simulation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import sys
import time
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

from temporal_gradient.clock.chronos import ClockRateModulator
from temporal_gradient.telemetry.chronometric_vector import ChronometricVector
from temporal_gradient.memory.decay import (
Expand Down
4 changes: 4 additions & 0 deletions twin_paradox.py → examples/twin_paradox.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import sys
import time
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

from temporal_gradient.clock.chronos import ClockRateModulator
from temporal_gradient.telemetry.chronometric_vector import ChronometricVector
Expand Down
8 changes: 4 additions & 4 deletions scripts/check_to_packet_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

ROOT = Path(__file__).resolve().parents[1]
TARGET_FILES: tuple[Path, ...] = (
ROOT / "anomaly_poc.py",
ROOT / "sanity_harness.py",
ROOT / "simulation_run.py",
ROOT / "twin_paradox.py",
ROOT / "examples" / "anomaly_detection.py",
ROOT / "examples" / "sanity_harness.py",
ROOT / "examples" / "simulation.py",
ROOT / "examples" / "twin_paradox.py",
)

CONTRACT_MESSAGE = (
Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
for path in (ROOT, ROOT / "examples"):
if str(path) not in sys.path:
sys.path.insert(0, str(path))
6 changes: 3 additions & 3 deletions tests/test_anomaly_poc.py → tests/test_anomaly_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections.abc import Mapping
from unittest.mock import patch

from anomaly_poc import run_poc
from anomaly_detection import run_poc
from temporal_gradient.telemetry.chronometric_vector import ChronometricVector


Expand Down Expand Up @@ -118,8 +118,8 @@ def test_run_poc_replay_strict_mode_uses_provenance_hashes():
def test_run_poc_to_packet_returns_mapping_contract():
cfg = _write_cfg(cooldown_tau=0.0, encode_threshold=0.0, s_max=1.5, decay_lambda=0.05, sweep_every=5.0)

with patch("anomaly_poc.ChronometricVector.to_packet", autospec=True) as to_packet, patch(
"anomaly_poc.ChronometricVector.to_packet_json",
with patch("anomaly_detection.ChronometricVector.to_packet", autospec=True) as to_packet, patch(
"anomaly_detection.ChronometricVector.to_packet_json",
autospec=True,
side_effect=AssertionError("run_poc should consume packet mappings, not JSON text"),
):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_harness_regressions_v020.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def test_calibration_harness_deterministic_given_fixed_inputs(tmp_path, capsys):


def test_harnesses_use_only_config_loader_imports():
harness_files = ["sanity_harness.py", "calibration_harness.py"]
for harness_file in harness_files:
source = Path(harness_file).read_text()
examples = Path(__file__).resolve().parents[1] / "examples"
for harness_file in ("sanity_harness.py", "calibration_harness.py"):
source = (examples / harness_file).read_text()
assert "temporal_gradient.config_loader" in source
assert not re.search(r"(?:from|import)\s+temporal_gradient\.config\b", source)
4 changes: 2 additions & 2 deletions tests/test_packet_contract_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def test_packet_contract_targets_active_v03_entrypoints() -> None:
target_names = {path.name for path in packet_check.TARGET_FILES}

assert target_names == {
"anomaly_poc.py",
"anomaly_detection.py",
"sanity_harness.py",
"simulation_run.py",
"simulation.py",
"twin_paradox.py",
}
Loading