Skip to content

Commit edcd85a

Browse files
tbitcsoz-agent
andcommitted
feat(skills): add chronomemory-esdb and github-actions-ci skills
chronomemory-esdb (governance domain): Full v0.1.1 API reference + 5 critical rules as an installable skill. Covers: imports, ChronoStore write/read, query.what_is_known, ContextPackCompiler, DepGraph, epistemic rollback, 10 query function signatures, token metrics, skills system, and RUST_BACKEND note. Activated by esdb/chronomemory/query tags. github-actions-ci (devops domain): Layer1Labs CI pattern: permissions:{} at workflow level, per-job contents:read, all jobs parallel (no needs chain), Python 3.10-3.13 x ubuntu+windows matrix, --cov-fail-under=85 gate, named jobs, fail-fast:false. Includes canonical template and explicit 'What NOT to do' list. Rust project job templates included. pyproject.toml: add E501 ignore for src/specsmith/skills/*.py (markdown body content) Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent 07f6bbe commit edcd85a

3 files changed

Lines changed: 303 additions & 0 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ select = ["E", "F", "W", "I", "UP", "B", "SIM"]
128128
"src/specsmith/ci_manager.py" = ["E501"]
129129
# Context orchestrator: tier descriptions are intentionally descriptive
130130
"src/specsmith/context_orchestrator.py" = ["E501"]
131+
# Skills module: skill body strings contain markdown content with long lines
132+
"src/specsmith/skills/*.py" = ["E501"]
131133
# Migration files: rule description strings and template content
132134
"src/specsmith/migrations/m001_governance_yaml.py" = ["E501"]
133135
"src/specsmith/migrations/m004_ledger_esdb.py" = ["E501"]

src/specsmith/skills/devops.py

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,165 @@
44
from specsmith.skills import SkillDomain, SkillEntry
55

66
SKILLS: list[SkillEntry] = [
7+
SkillEntry(
8+
slug="github-actions-ci",
9+
name="GitHub Actions CI — Layer1Labs pattern (zero-trust, parallel, coverage-gated)",
10+
description=(
11+
"Standard Layer1Labs GitHub Actions CI pattern: permissions: {} at workflow level, "
12+
"per-job contents: read grants, parallel jobs (no needs chain), full Python matrix "
13+
"3.10–3.13, and --cov-fail-under=85 coverage gate."
14+
),
15+
domain=SkillDomain.DEVOPS,
16+
tags=[
17+
"ci", "github-actions", "permissions", "pytest", "coverage",
18+
"ruff", "mypy", "security", "python", "matrix", "zero-trust",
19+
],
20+
platforms=["linux", "windows", "macos"],
21+
prerequisites=["gh"],
22+
body=("""\
23+
# GitHub Actions CI Skill (Layer1Labs pattern)
24+
25+
Standard CI pattern used across all Layer1Labs / BitConcepts Python projects.
26+
Reference implementation: `chronomemory/.github/workflows/ci.yml`
27+
28+
## Core principles
29+
- `permissions: {}` at workflow level — deny all by default.
30+
- `permissions: contents: read` on each individual job — grant minimum needed.
31+
- All jobs run **in parallel** — no `needs:` dependency chain unless truly required.
32+
- Full Python matrix: **3.10, 3.11, 3.12, 3.13** × ubuntu-latest, windows-latest.
33+
- Coverage gate: `--cov-fail-under=85`.
34+
- Named jobs (`name:` field) for readable GitHub UI.
35+
- `fail-fast: false` on the test matrix so all combinations are reported.
36+
37+
## Canonical template
38+
```yaml
39+
name: CI
40+
41+
on:
42+
push:
43+
branches: [main, develop]
44+
pull_request:
45+
branches: [main, develop]
46+
workflow_dispatch:
47+
48+
# Default: deny all. Each job grants only what it needs.
49+
permissions: {}
50+
51+
jobs:
52+
lint:
53+
name: Lint (ruff)
54+
runs-on: ubuntu-latest
55+
permissions:
56+
contents: read
57+
steps:
58+
- uses: actions/checkout@v6
59+
- uses: actions/setup-python@v6
60+
with:
61+
python-version: "3.12"
62+
cache: pip
63+
- run: pip install ruff
64+
- name: ruff format --check
65+
run: ruff format --check src/ tests/
66+
- name: ruff check
67+
run: ruff check src/ tests/
68+
69+
typecheck:
70+
name: Type check (mypy)
71+
runs-on: ubuntu-latest
72+
permissions:
73+
contents: read
74+
steps:
75+
- uses: actions/checkout@v6
76+
- uses: actions/setup-python@v6
77+
with:
78+
python-version: "3.12"
79+
cache: pip
80+
- run: pip install -e ".[dev]"
81+
- run: mypy src/<package>/
82+
83+
test:
84+
name: Test (Python ${{ matrix.python-version }} / ${{ matrix.os }})
85+
runs-on: ${{ matrix.os }}
86+
permissions:
87+
contents: read
88+
strategy:
89+
fail-fast: false
90+
matrix:
91+
python-version: ["3.10", "3.11", "3.12", "3.13"]
92+
os: [ubuntu-latest, windows-latest]
93+
steps:
94+
- uses: actions/checkout@v6
95+
- uses: actions/setup-python@v6
96+
with:
97+
python-version: ${{ matrix.python-version }}
98+
cache: pip
99+
- run: pip install -e ".[dev]"
100+
- run: pytest --cov=<package> --cov-report=term-missing --cov-fail-under=85
101+
102+
security:
103+
name: Security audit (pip-audit)
104+
runs-on: ubuntu-latest
105+
permissions:
106+
contents: read
107+
steps:
108+
- uses: actions/checkout@v6
109+
- uses: actions/setup-python@v6
110+
with:
111+
python-version: "3.12"
112+
cache: pip
113+
- run: pip install pip-audit
114+
- run: pip install -e .
115+
- run: pip-audit
116+
```
117+
118+
## What NOT to do
119+
- Do NOT set `permissions: contents: read` at workflow level — use `permissions: {}` + per-job grants.
120+
- Do NOT use `needs: [lint, typecheck]` to gate the test job — run all in parallel.
121+
- Do NOT omit Python 3.11 from the matrix.
122+
- Do NOT skip `--cov-fail-under` — the 85% gate is non-negotiable.
123+
- Do NOT use `cancel-in-progress: true` (concurrency block) unless there is a
124+
specific reason — chronomemory pattern omits it.
125+
- Do NOT use `macos-latest` in the matrix unless macOS-specific behavior must be
126+
tested — it is ~10× slower and uses more CI minutes.
127+
128+
## Rust projects (additional jobs)
129+
```yaml
130+
rust-lint:
131+
name: Rust lint (clippy + fmt)
132+
runs-on: ubuntu-latest
133+
permissions:
134+
contents: read
135+
steps:
136+
- uses: actions/checkout@v6
137+
- uses: dtolnay/rust-toolchain@stable
138+
with:
139+
components: clippy, rustfmt
140+
- run: cargo fmt --check --all
141+
- run: cargo clippy --workspace -- -D warnings
142+
143+
rust-test:
144+
name: Rust tests
145+
runs-on: ubuntu-latest
146+
permissions:
147+
contents: read
148+
steps:
149+
- uses: actions/checkout@v6
150+
- uses: dtolnay/rust-toolchain@stable
151+
- run: cargo test --workspace
152+
153+
security:
154+
name: Security audit (cargo-audit)
155+
runs-on: ubuntu-latest
156+
permissions:
157+
contents: read
158+
steps:
159+
- uses: actions/checkout@v6
160+
- uses: dtolnay/rust-toolchain@stable
161+
- run: cargo install cargo-audit --locked
162+
- run: cargo audit
163+
```
164+
"""),
165+
),
7166
SkillEntry(
8167
slug="docker-workflow",
9168
name="Docker — multi-stage builds, Compose, registries, security",

src/specsmith/skills/governance.py

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,148 @@
140140
"If step 7 fails: `git tag -d v<version> && git reset --hard HEAD~1`.\n"
141141
),
142142
),
143+
SkillEntry(
144+
slug="chronomemory-esdb",
145+
name="ChronoMemory ESDB — epistemic state database (v0.1.1)",
146+
description=(
147+
"Full API reference and critical rules for chronomemory v0.1.1: "
148+
"ChronoStore WAL, query module, ContextPackCompiler, DepGraph, "
149+
"token metrics, skills system, and Rust acceleration."
150+
),
151+
domain=SkillDomain.GOVERNANCE,
152+
tags=[
153+
"esdb", "chronomemory", "epistemics", "wal", "persistence",
154+
"context-pack", "query", "dep-graph", "rollback", "token-metrics",
155+
"aee", "anti-hallucination",
156+
],
157+
prerequisites=["chronomemory"],
158+
body=("""\
159+
# ChronoMemory ESDB Skill (v0.1.1)
160+
161+
EpiStemic State Database for Layer1Labs agentic projects.
162+
WAL at `<root>/.chronomemory/events.wal` — NDJSON, append-only, SHA-256 chained.
163+
164+
## Imports
165+
```python
166+
from chronomemory import (
167+
ChronoStore, ChronoRecord, WalEvent, open_store, # Core
168+
EsdbBridge, # Backward-compat bridge
169+
DepGraph, DependencyEdge, # Phase 2: dep graph
170+
RollbackReport, invalidate, # Phase 2: rollback
171+
ContextPack, ContextPackCompiler, ContextPackEntry, # Phase 2: context packs
172+
RustChronoStore, RustRecord, RUST_BACKEND, # Phase 3: Rust (optional)
173+
)
174+
from chronomemory import query # 18 ESDB §23 query functions
175+
from chronomemory import metrics # token metrics + skill system
176+
177+
# Or via specsmith.esdb namespace (preferred within specsmith code):
178+
from specsmith.esdb import ChronoStore, query, metrics, ContextPackCompiler
179+
```
180+
181+
## Critical rules — never break these
182+
1. `dependencies = []` in pyproject.toml must stay empty — chronomemory is stdlib-only.
183+
2. Never physically delete WAL records — always `store.delete(id)` (tombstone only).
184+
3. Use `query.what_is_known(store)` not `store.query(rag_filter=True)` for LLM context
185+
— the former excludes infra record kinds (edge, rollback_event, token_metric, skill_run).
186+
4. Governance status (`defined`/`implemented`) ≠ ESDB status (`active`/`tombstone`)
187+
— never conflate when migrating from `.specsmith/*.json`.
188+
5. WAL is append-only NDJSON — one JSON object per line, SHA-256 chained.
189+
190+
## Core write/read
191+
```python
192+
with ChronoStore(project_root) as store:
193+
store.upsert(ChronoRecord(
194+
id="FACT-001", kind="fact",
195+
label="CPSC projection is the sole validity authority",
196+
source_type="observed", confidence=0.99,
197+
evidence=["CPSC-Specification.md §9"],
198+
))
199+
store.delete("OLD-001") # tombstone only — never physically removes
200+
store.chain_valid() # verify SHA-256 WAL integrity
201+
202+
# For LLM context — always use query.what_is_known (rule #3)
203+
with ChronoStore(project_root) as store:
204+
beliefs = query.what_is_known(store) # active, conf>=0.6, no infra records
205+
hypotheses = query.what_requires_reverification(store)
206+
done = query.has_this_work_been_done(store, "migrate flat JSON")
207+
```
208+
209+
## Backward-compat bridge
210+
```python
211+
bridge = EsdbBridge(project_root)
212+
bridge.status().backend # "ChronoStore WAL" or "json"
213+
store.migrate_from_json(Path(project_root) / ".specsmith")
214+
```
215+
216+
## Dependency graph
217+
```python
218+
g = DepGraph(store=store)
219+
g.add_edge("HYP-001", "FACT-001", "depends_on")
220+
# Valid edge types: assumes contradicts depends_on derived_from
221+
# generated_from invalidates supports supersedes validated_by
222+
```
223+
224+
## Epistemic rollback
225+
```python
226+
report = store.invalidate("FACT-001", "reason", dep_graph=g)
227+
# Cascades depends_on/derived_from → status=hypothesis, confidence halved
228+
```
229+
230+
## Context pack for LLM injection
231+
```python
232+
pack = ContextPackCompiler(store).compile(
233+
task_id="TASK-42", goal="fix ruff errors", token_budget=4096
234+
)
235+
context_json = pack.to_dict() # inject into LLM context
236+
# Excludes: tombstone/invalidated/hypothesis, conf<0.6, infra kinds, over-budget
237+
```
238+
239+
## Query API (18 functions — all degrade gracefully without dep_graph)
240+
```python
241+
query.what_is_known(store) # active beliefs, no infra kinds
242+
query.what_requires_reverification(store) # hypotheses needing confirmation
243+
query.has_this_work_been_done(store, label) # bool — check prior decisions
244+
query.why_do_we_believe(store, "FACT-001") # evidence chain for a record
245+
query.what_skills_apply(store, "run lint") # skills matching task label
246+
query.what_changed_since(store, seq) # records written after WAL seq N
247+
query.what_confidence_collapsed(store, 0.6) # hypotheses below threshold
248+
query.what_can_agent_do_next(store, goal) # unblocked action records
249+
query.what_should_agent_not_do(store) # stop_condition records
250+
query.is_this_action_duplicate(store, label) # alias for has_this_work_been_done
251+
```
252+
253+
## Token metrics
254+
```python
255+
metrics.record_token_metric(
256+
store, task_id="TASK-1",
257+
context_tokens=512, input_tokens=256, output_tokens=128,
258+
tool_calls=4, elapsed_ms=1800, success=True,
259+
)
260+
metrics.token_efficiency_report(store) # {tokens_per_success, avg_tool_calls, ...}
261+
```
262+
263+
## Skills system
264+
```python
265+
# Register a skill
266+
store.upsert(ChronoRecord(
267+
id="SKILL-ruff", kind="skill", label="ruff linter", confidence=0.9,
268+
data={"activation": ["lint", "ruff", "python"]},
269+
))
270+
metrics.find_skills(store, "run ruff lint") # returns matching skill records
271+
metrics.record_skill_run(store, "SKILL-ruff", # writes a skill_run WAL record
272+
success=True, tokens_used=150, output={"errors": 0})
273+
```
274+
275+
## Rust acceleration (Phase 3)
276+
```python
277+
from chronomemory import RUST_BACKEND
278+
# False by default — requires: pip install maturin
279+
# maturin develop --manifest-path crates/chronomemory-py/Cargo.toml
280+
# When True, RustChronoStore and RustRecord are available.
281+
print("Rust backend:", RUST_BACKEND)
282+
```
283+
"""),
284+
),
143285
SkillEntry(
144286
slug="issue-triage",
145287
name="Issue Triage — classify and prioritise GitHub issues",

0 commit comments

Comments
 (0)