Skip to content

Commit 07f6bbe

Browse files
tbitcsoz-agent
andcommitted
feat(esdb): apply chronomemory v0.1.1 — full API surface + critical rule fixes
chronomemory v0.1.1 (Phase 3: NDJSON WAL, PyO3 bindings, pyo3 security fix): - pyproject.toml: pin chronomemory dep to @v0.1.1 tag - specsmith.esdb.__init__: re-export full v0.1.1 API surface — Phase 2 types (DepGraph, DependencyEdge, RollbackReport, invalidate, ContextPack, ContextPackCompiler, ContextPackEntry), Phase 3 (RustChronoStore, RustRecord, RUST_BACKEND), plus query and metrics module references - specsmith.esdb.bridge: update to expose Phase 2/3 types and query/metrics - retrieval.py: replace store.query(rag_filter=True) with query.what_is_known(store) — critical rule §18: excludes infra record kinds (edge, rollback_event, token_metric, skill_run) from the RAG index - context_seed.py: replace store.query() with query.what_is_known(store) in _load_esdb_snippet() — ESDB records are injected into LLM context; infra records must never appear there (critical rule §23) Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent 2c9a531 commit 07f6bbe

5 files changed

Lines changed: 99 additions & 11 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies = [
4141
"pyyaml>=6.0",
4242
"pydantic>=2.0",
4343
"rich>=13.0",
44-
"chronomemory @ git+https://github.com/layer1labs/chronomemory.git",
44+
"chronomemory @ git+https://github.com/layer1labs/chronomemory.git@v0.1.1",
4545
]
4646

4747
[project.optional-dependencies]

src/specsmith/agent/context_seed.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,18 @@ def _load_ledger_snippet(root: Path, *, max_lines: int) -> str:
186186

187187

188188
def _load_esdb_snippet(root: Path, *, max_records: int) -> str:
189-
"""Return a compact summary of the most recent ESDB ChronoRecords."""
189+
"""Return a compact summary of the most recent ESDB ChronoRecords.
190+
191+
Uses query.what_is_known() (not store.query()) so infrastructure records
192+
(edge, rollback_event, token_metric, skill_run) are excluded from the
193+
LLM context seed — critical rule §23 / ESDB spec rule 3.
194+
"""
190195
try:
191196
from chronomemory import ChronoStore
197+
from chronomemory import query as _cm_query
192198

193199
with ChronoStore(root) as store:
194-
all_records = store.query() # active records in insertion order
200+
all_records = _cm_query.what_is_known(store) # active, conf>=0.6, no infra
195201
recent = all_records[-max_records:] if len(all_records) > max_records else all_records
196202
if not recent:
197203
return ""

src/specsmith/esdb/__init__.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,62 @@
11
# specsmith.esdb — ESDB integration package
2+
#
3+
# Re-exports the full chronomemory v0.1.1 public surface under the
4+
# specsmith.esdb namespace so internal modules can use a single import
5+
# path and never import chronomemory directly in more than one place.
26

7+
# Re-export query and metrics as module references so callers can do:
8+
# from specsmith.esdb import query, metrics
9+
from chronomemory import (
10+
RUST_BACKEND,
11+
# Core store
12+
ChronoRecord,
13+
ChronoStore,
14+
# Phase 2: context pack compiler
15+
ContextPack,
16+
ContextPackCompiler,
17+
ContextPackEntry,
18+
DependencyEdge,
19+
# Phase 2: dependency graph
20+
DepGraph,
21+
# Bridge (backward-compat with .specsmith/*.json)
22+
EsdbBridge,
23+
EsdbRecord,
24+
EsdbStatus,
25+
# Phase 2: epistemic rollback
26+
RollbackReport,
27+
# Phase 3: optional Rust acceleration (None / False when not compiled)
28+
RustChronoStore,
29+
RustRecord,
30+
WalEvent,
31+
invalidate,
32+
metrics, # noqa: F401 — module re-export
33+
open_store,
34+
query, # noqa: F401 — module re-export
35+
)
36+
37+
__all__ = [
38+
# Core
39+
"ChronoStore",
40+
"ChronoRecord",
41+
"WalEvent",
42+
"open_store",
43+
# Bridge
44+
"EsdbBridge",
45+
"EsdbRecord",
46+
"EsdbStatus",
47+
# Phase 2
48+
"DepGraph",
49+
"DependencyEdge",
50+
"RollbackReport",
51+
"invalidate",
52+
"ContextPack",
53+
"ContextPackCompiler",
54+
"ContextPackEntry",
55+
# Phase 3
56+
"RustChronoStore",
57+
"RustRecord",
58+
"RUST_BACKEND",
59+
# Modules
60+
"query",
61+
"metrics",
62+
]

src/specsmith/esdb/bridge.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1-
"""specsmith.esdb.bridge — thin re-export of chronomemory.EsdbBridge.
1+
"""specsmith.esdb.bridge — backward-compat bridge shim (chronomemory v0.1.1).
22
3-
EsdbBridge lives in the chronomemory package; this module exposes it under
4-
the specsmith.esdb.bridge namespace so that save/load commands can import it
5-
without depending directly on chronomemory at the top of cli.py.
3+
For direct use prefer importing from specsmith.esdb (the package __init__)
4+
which re-exports the full chronomemory v0.1.1 surface. This module is kept
5+
for any code that specifically imports from specsmith.esdb.bridge.
66
"""
77

8-
from chronomemory import EsdbBridge
8+
from chronomemory import (
9+
RUST_BACKEND,
10+
ContextPackCompiler,
11+
DepGraph,
12+
EsdbBridge,
13+
EsdbRecord,
14+
EsdbStatus,
15+
metrics,
16+
query,
17+
)
918

10-
__all__ = ["EsdbBridge"]
19+
__all__ = [
20+
"EsdbBridge",
21+
"EsdbRecord",
22+
"EsdbStatus",
23+
"ContextPackCompiler",
24+
"DepGraph",
25+
"RUST_BACKEND",
26+
"query",
27+
"metrics",
28+
]

src/specsmith/retrieval.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ def build_index(root: Path, *, include_ledger: bool = False, external: str = "")
4040
"""
4141
entries: list[dict[str, str]] = []
4242

43-
# H18: inject high-confidence ESDB records as retrieval context
43+
# H18: inject high-confidence ESDB records as retrieval context.
44+
# Use query.what_is_known() (not store.query(rag_filter=True)) so that
45+
# infrastructure records (edge, rollback_event, token_metric, skill_run)
46+
# are excluded from the RAG index — critical rule §18.
4447
wal = root / ".chronomemory" / "events.wal"
4548
if wal.exists():
4649
try:
4750
from chronomemory import ChronoStore
51+
from chronomemory import query as _cm_query
4852

4953
with ChronoStore(root) as store:
50-
for rec in store.query(rag_filter=True): # confidence >= 0.6
54+
for rec in _cm_query.what_is_known(store):
5155
if rec.data:
5256
content = (
5357
f"[{rec.kind.upper()} {rec.id}] {rec.label}\n"

0 commit comments

Comments
 (0)