Skip to content

Commit a2c30a3

Browse files
ecoPrimalsecoPrimals
authored andcommitted
v0.7.27: deep debt — coordinated shutdown, zero-copy phase 3, type safety
Coordinated graceful shutdown via tokio::sync::watch for HTTP/tarpc/UDS. Zero-copy Phase 3: BraidMetadata title/description/tags to Arc<str>. JsonLdVersion replaces f32 for content-addressed precision. get_batch surfaces store errors. RegistryRpc structured errors. Discoverable vocab URIs. AttributionNotice Display single source of truth. 1,128 tests, 90.23% line coverage, 0 clippy, 0 unsafe, 0 TODOs. Made-with: Cursor
1 parent 5f844db commit a2c30a3

44 files changed

Lines changed: 469 additions & 203 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,64 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.7.27] - 2026-03-24
11+
12+
### Deep Debt: Coordinated Shutdown, Zero-Copy Phase 3, Type Safety, Structured Errors
13+
14+
Comprehensive debt resolution across 11 audit items: coordinated graceful
15+
shutdown, zero-copy BraidMetadata, JSON-LD version type safety, structured
16+
registry errors, discoverable vocab URIs, and store error surfacing.
17+
18+
### Added
19+
20+
- **Coordinated shutdown**`tokio::sync::watch` channel coordinates HTTP,
21+
tarpc, and UDS graceful shutdown; spawned servers drain in-flight requests
22+
before process exit (was fire-and-forget)
23+
- **`JsonLdVersion` type** — replaces `f32` for `BraidContext.version`;
24+
always serializes to `1.1`, validates on deserialization (eliminates float
25+
precision drift in content-addressed hashing)
26+
- **`RegistryError` enum** — structured error type for `RegistryRpc` tarpc
27+
service (`NotFound`, `RegistrationFailed`, `Internal`); replaces `String`
28+
- **Discoverable vocab URIs**`ecop_vocab_uri()` / `ecop_base_uri()`
29+
resolve from `ECOP_VOCAB_URI` / `ECOP_BASE_URI` env vars with fallback
30+
defaults; `BraidContext::default()` uses discoverable functions
31+
- **`Display` impl for `AttributionNotice`** — single source of truth for
32+
notice text generation (removed `notice_text` field to prevent drift)
33+
34+
### Changed
35+
36+
- **Zero-copy Phase 3: `BraidMetadata`**`title: Option<String>`
37+
`Option<Arc<str>>`, `description``Option<Arc<str>>`, `tags: Vec<String>`
38+
`Vec<Arc<str>>`; cross-crate migration across all 10 crates + 4 store
39+
backends + tests
40+
- **Tag index evolved**`HashMap<String, HashSet<BraidId>>`
41+
`HashMap<Arc<str>, HashSet<BraidId>>` in memory store (zero-copy tags)
42+
- **`get_batch` returns errors** — changed from `Vec<Option<Braid>>` to
43+
`(Vec<Option<Braid>>, Vec<StoreError>)` matching `put_batch` pattern;
44+
store errors are now visible instead of silently swallowed as "not found"
45+
- **`CachedDiscovery.find_one`** — sorts by `last_seen` (most recent first)
46+
before selecting; deterministic instead of hash-map iteration order
47+
- **Health check parsing** — replaced fragile `response.contains("200 OK")`
48+
with numeric status code parsing; accepts any 2xx response
49+
- **`println!``tracing::info!`** — 2 chaos test diagnostics migrated
50+
- **`RewardShare` documented**`share`/`amount` fields documented as
51+
informational ratios with evolution path to integer basis points
52+
53+
### Verified
54+
55+
- `cargo fmt` — 0 diffs
56+
- `cargo clippy` (pedantic + nursery, `-D warnings`) — 0 warnings
57+
- `cargo doc` — 0 warnings
58+
- `cargo test` — 1,128 tests, 0 failures
59+
- `cargo llvm-cov`**90.23% line coverage**
60+
- 0 TODOs, 0 unsafe, 0 production unwraps, all files under 1000 LOC
61+
62+
## [0.7.26] - 2026-03-23
63+
64+
### Ecosystem Absorption: scyBorg License, Sled Deprecation, Lint Evolution
65+
66+
See ROADMAP.md for full details.
67+
1068
## [0.7.25] - 2026-03-23
1169

1270
### Coverage Push and Test Hygiene

CONTEXT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ attribution before distributing rewards.
2828
- **Communication:** JSON-RPC 2.0 (required) + tarpc (optional high-perf) + REST + UDS
2929
- **License:** scyBorg Triple-Copyleft (AGPL-3.0 + ORC-1.0 + CC-BY-SA-4.0)
3030
- **Tests:** 1,128 passing
31-
- **Coverage:** ~90% line coverage (testable code, excluding Postgres which needs runtime)
31+
- **Coverage:** 90.23% line coverage (llvm-cov, excluding Postgres which needs runtime)
3232
- **MSRV:** 1.87 (Edition 2024)
3333
- **Crate count:** 10 workspace crates
3434
- **Unsafe code:** 0 blocks (`#![forbid(unsafe_code)]` on all crates)

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ members = [
1616
]
1717

1818
[workspace.package]
19-
version = "0.7.26"
19+
version = "0.7.27"
2020
edition = "2024"
2121
rust-version = "1.87"
2222
license = "AGPL-3.0-only"

DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 🌾 SweetGrass — Development Guide
22

33
**Last Updated**: March 23, 2026
4-
**Version**: v0.7.26
4+
**Version**: v0.7.27
55

66
---
77

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Semantic Provenance and Attribution Layer for ecoPrimals**
44

5-
v0.7.26 | 1,128 tests | Edition 2024 | scyBorg Triple-Copyleft | Pure Rust | ecoBin compliant | Sovereign types
5+
v0.7.27 | 1,128 tests | Edition 2024 | scyBorg Triple-Copyleft | Pure Rust | ecoBin compliant | Sovereign types
66

77
---
88

@@ -180,7 +180,7 @@ See [DEVELOPMENT.md](./DEVELOPMENT.md) for all options.
180180

181181
| Metric | Value |
182182
|--------|-------|
183-
| Version | v0.7.26 |
183+
| Version | v0.7.27 |
184184
| Tests | 1,128 passing |
185185
| Coverage | ~90% lines (llvm-cov, excluding Postgres runtime tests) |
186186
| Edition | 2024 (MSRV 1.87) |
@@ -211,7 +211,7 @@ See [DEVELOPMENT.md](./DEVELOPMENT.md) for all options.
211211

212212
### Zero-Copy
213213

214-
`ContentHash`, `BraidId`, `Did`, `ActivityId`, `Braid.mime_type`, `EcoPrimalsAttributes.source_primal`, `EcoPrimalsAttributes.niche`, `LoamCommitRef.spine_id`, `BraidFactory.source_primal`, and `CompressionEngine.source_primal` use `Arc<str>` internally — `.clone()` is O(1) atomic refcount increment. MIME type indexes (`MemoryStore`, `AgentContributions`) share the same `Arc<str>`, eliminating per-query allocations on hot paths. `BraidSignature` fields use `Cow<'static, str>` for zero-allocation static values. `BraidContext.imports` uses `IndexMap` for deterministic serialization.
214+
`ContentHash`, `BraidId`, `Did`, `ActivityId`, `Braid.mime_type`, `BraidMetadata.title`, `BraidMetadata.description`, `BraidMetadata.tags`, `EcoPrimalsAttributes.source_primal`, `EcoPrimalsAttributes.niche`, `LoamCommitRef.spine_id`, `BraidFactory.source_primal`, and `CompressionEngine.source_primal` use `Arc<str>` internally — `.clone()` is O(1) atomic refcount increment. MIME type and tag indexes (`MemoryStore`, `AgentContributions`) share the same `Arc<str>`, eliminating per-query allocations on hot paths. `BraidSignature` fields use `Cow<'static, str>` for zero-allocation static values. `BraidContext.imports` uses `IndexMap` for deterministic serialization.
215215

216216
### Configuration
217217

ROADMAP.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
# SweetGrass Roadmap
22

3-
**Current Version**: v0.7.26 (March 2026)
3+
**Current Version**: v0.7.27 (March 2026)
44

55
---
66

77
## Completed
88

9+
### v0.7.27 — Deep Debt: Coordinated Shutdown, Zero-Copy Phase 3, Type Safety (March 2026)
10+
11+
- [x] **Coordinated graceful shutdown**`tokio::sync::watch` channel coordinates HTTP, tarpc, and UDS; spawned servers drain in-flight requests before process exit (was fire-and-forget `tokio::spawn`)
12+
- [x] **Zero-copy Phase 3: `BraidMetadata`**`title`, `description``Option<Arc<str>>`, `tags``Vec<Arc<str>>`; cross-crate migration across all 10 crates + 4 store backends
13+
- [x] **`JsonLdVersion` type** — replaces `f32` for `BraidContext.@version`; zero-size type always serializes to `1.1`, validates on deserialization (eliminates float precision drift)
14+
- [x] **`get_batch` error surfacing** — returns `(Vec<Option<Braid>>, Vec<StoreError>)` matching `put_batch` pattern; store errors now visible instead of silently swallowed
15+
- [x] **`RegistryRpc` structured errors**`Result<T, String>``Result<T, RegistryError>` with `NotFound`/`RegistrationFailed`/`Internal` variants
16+
- [x] **Discoverable vocab URIs**`ecop_vocab_uri()` / `ecop_base_uri()` resolve from env vars with fallback defaults; `BraidContext::default()` uses discoverable functions
17+
- [x] **`AttributionNotice` single source of truth** — removed `notice_text` field; `Display` impl generates text from structured data
18+
- [x] **`CachedDiscovery.find_one` stable ordering** — sorts by `last_seen` (newest first) for deterministic selection
19+
- [x] **Health check parsing** — numeric status code extraction replaces fragile string matching
20+
- [x] **Tag index zero-copy**`HashMap<String, ...>``HashMap<Arc<str>, ...>` in memory store
21+
- [x] **`println!``tracing`** in chaos tests
22+
- [x] **`RewardShare` f64 documented** — informational ratios with evolution path to integer basis points (sunCloud v0.9.0+)
23+
- [x] 1,128 tests passing, 90.23% line coverage (llvm-cov), 0 clippy warnings, 0 doc warnings, 0 unsafe, 0 fmt issues
24+
925
### v0.7.26 — Ecosystem Absorption: scyBorg License, Sled Deprecation, Lint Evolution (March 2026)
1026

1127
- [x] **scyBorg Triple-Copyleft LICENSE** — adopted rhizoCrypt v0.13.0 format (AGPL + ORC + CC-BY-SA with Reserved Material section)
@@ -464,7 +480,8 @@
464480

465481
| Version | Target | Focus |
466482
|---------|--------|-------|
467-
| v0.7.26 | **March 2026** | Ecosystem Absorption: scyBorg License, Sled Deprecation, Lint Evolution (DONE) |
483+
| v0.7.27 | **March 2026** | Deep Debt: Coordinated Shutdown, Zero-Copy Phase 3, Type Safety (DONE) |
484+
| v0.7.26 | March 2026 | Ecosystem Absorption: scyBorg License, Sled Deprecation, Lint Evolution (DONE) |
468485
| v0.7.25 | March 2026 | Coverage Push, Test Hygiene, PUBLIC_SURFACE_STANDARD Compliance (DONE) |
469486
| v0.7.24 | March 2026 | Deep Debt: Zero-Copy Phase 2, Public Surface, Audit (DONE) |
470487
| v0.7.23 | March 2026 | Ecosystem Absorption: MCP Tool Exposure, Canonical Capabilities (DONE) |

config/capability_registry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[primal]
99
name = "sweetgrass"
10-
version = "0.7.26"
10+
version = "0.7.27"
1111
description = "Semantic provenance and attribution layer"
1212
license = "AGPL-3.0-only"
1313
protocol = "jsonrpc-2.0"

crates/sweet-grass-compression/src/engine/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,14 @@ impl CompressionEngine {
236236

237237
// Build metadata
238238
let metadata = BraidMetadata {
239-
title: Some(format!("Session {}", session.id)),
240-
description: Some(format!(
241-
"Compressed from {} vertices ({} committed)",
242-
analysis.vertex_count, analysis.committed_count
243-
)),
239+
title: Some(format!("Session {}", session.id).into()),
240+
description: Some(
241+
format!(
242+
"Compressed from {} vertices ({} committed)",
243+
analysis.vertex_count, analysis.committed_count
244+
)
245+
.into(),
246+
),
244247
..Default::default()
245248
};
246249

crates/sweet-grass-core/src/braid/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ pub mod types;
2323
pub use builder::BraidBuilder;
2424
pub use types::{
2525
BraidContext, BraidId, BraidMetadata, BraidSignature, BraidType, CompressionMeta, ContentHash,
26-
ECOP_BASE_URI, ECOP_VOCAB_URI, EcoPrimalsAttributes, LoamAnchor, LoamCommitRef, PROV_VOCAB_URI,
27-
SCHEMA_VOCAB_URI, SummaryType, Timestamp, XSD_VOCAB_URI, current_timestamp_nanos,
26+
DEFAULT_ECOP_BASE_URI, DEFAULT_ECOP_VOCAB_URI, EcoPrimalsAttributes, JsonLdVersion, LoamAnchor,
27+
LoamCommitRef, PROV_VOCAB_URI, SCHEMA_VOCAB_URI, SummaryType, Timestamp, XSD_VOCAB_URI,
28+
current_timestamp_nanos, ecop_base_uri, ecop_vocab_uri,
2829
};
2930

3031
/// A `SweetGrass` Braid (provenance record).

crates/sweet-grass-core/src/braid/tests.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ mod unit_tests {
8686
#[test]
8787
fn test_braid_context_default() {
8888
let ctx = BraidContext::default();
89-
assert!((ctx.version - 1.1).abs() < f32::EPSILON);
89+
let version_json = serde_json::to_value(ctx.version).unwrap();
90+
assert!((version_json.as_f64().unwrap() - 1.1).abs() < f64::EPSILON);
9091
assert!(ctx.imports.contains_key("prov"));
9192
assert!(ctx.imports.contains_key("ecop"));
9293
}
@@ -366,7 +367,7 @@ mod proptests {
366367
fn test_braid_builder_metadata() {
367368
let did = Did::new("did:key:z6MkBuilderMeta");
368369
let meta = BraidMetadata {
369-
tags: vec!["important".to_string()],
370+
tags: vec!["important".into()],
370371
..BraidMetadata::default()
371372
};
372373
let braid = Braid::builder()
@@ -378,7 +379,8 @@ mod proptests {
378379
.build()
379380
.expect("should build");
380381

381-
assert_eq!(braid.metadata.tags, vec!["important"]);
382+
let expected: Vec<std::sync::Arc<str>> = vec!["important".into()];
383+
assert_eq!(braid.metadata.tags, expected);
382384
}
383385

384386
#[test]

0 commit comments

Comments
 (0)