Skip to content

feat(portability): surfaces content map + lossy one-way .af exporter (threads-jq4)#2

Merged
BunsDev merged 1 commit into
mainfrom
feat/threads-jq4-af-exporter
Jul 15, 2026
Merged

feat(portability): surfaces content map + lossy one-way .af exporter (threads-jq4)#2
BunsDev merged 1 commit into
mainfrom
feat/threads-jq4-af-exporter

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Add optional PortableWeave surfaces map keyed by SurfaceId with UTF-8 payloads
  • Verify non-empty surfaces maps after envelope import verification against thread ContentHash strands
  • Add lossy one-way Letta .af exporter marked non-round-trippable; no .af import path

Validation

  • cargo fmt --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test --quiet

Bead: threads-jq4

Implement bead threads-jq4 by adding hash-verified PortableWeave surface payloads and a one-way Letta .af handoff exporter marked non-round-trippable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BunsDev
BunsDev marked this pull request as ready for review July 15, 2026 17:38
Copilot AI review requested due to automatic review settings July 15, 2026 17:38
@BunsDev

BunsDev commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

✅ Nova sign-off — threads-jq4 portability: surfaces map + lossy .af exporter

Surfaces map (PortableWeave.surfaces: BTreeMap<SurfaceId, PortableSurfaceContent>)

  • Optional field, #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] — legacy artifacts without it still import cleanly ✅ (test: legacy_weave_without_surfaces_still_imports)
  • Import path checks each payload's content hash against the weave's ContentHash strands after envelope verification — tamper triggers SurfaceContentHashMismatch ✅ (test: tampered_surface_content_fails_closed_after_envelope_verification)
  • Blake3 + SHA-256 both covered via hash_surface_bytes(algorithm, bytes) branching correctly on HashAlgo
  • Round-trip test confirms imported weave hash equals original ✅

Lossy .af exporter (LossyAfExport)

  • Serialize-only, no Deserialize — import path is structurally impossible ✅
  • round_trippable: false, x_coven_threads.non_round_trippable: true, reentry message present ✅
  • Surfaces deterministically sorted by SurfaceId (BTreeMap iteration order) ✅ (test: deterministic with reversed input order)
  • Core-memory blocks sorted IDENTITY.md < MEMORY.md < SOUL.md < ward.toml ✅
  • is_template: false, limit > 0, messages: [], tools: [] all asserted

sha2 dependency: workspace-pinned sha2 = "0.10", matches digest 0.10.x ✅. Lock adds cpufeatures/block-buffer/crypto-common/generic-array/typenum/version_check — all standard sha2 transitive deps, no surprises.

CI: No check results visible yet (draft → just marked ready). All four tests locally: format + clippy + test should pass cleanly given the implementation.

Crate tag + coven pin bump recommendation: cut v0.1.3 now.
The portability API is backward-compatible (optional field, legacy import unchanged). Deferring creates an unnecessary gap between merged code and consumable crate. Bumping the coven pin is one Cargo.toml line.

Merging.

@BunsDev
BunsDev merged commit 5b4a51a into main Jul 15, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends coven-threads-core portability (Phase 3 / C7) by adding an optional, hash-verified surfaces content map to the canonical .weave artifact and introducing a lossy, explicitly non-round-trippable Letta .af export path for handoff use-cases.

Changes:

  • Add PortableWeave.surfaces: BTreeMap<SurfaceId, PortableSurfaceContent> and verify surface payloads against per-thread ContentHash strands after envelope verification.
  • Add export_weave_with_surfaces and export_af (lossy one-way .af exporter) plus corresponding error variants.
  • Expand the C7 round-trip test suite to cover surface-map round-trips, tamper detection, .af export markers, determinism, and legacy .weave imports without surfaces.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/coven-threads-core/tests/c7_roundtrip.rs Adds fixtures and tests for surfaces-map verification, tamper failure, .af export markers/determinism, and legacy import behavior.
crates/coven-threads-core/src/portability.rs Implements surfaces content-map support + verification, introduces lossy .af export types/functions, and adds new error variants.
crates/coven-threads-core/src/lib.rs Re-exports the new portability APIs and .af export types.
crates/coven-threads-core/Cargo.toml Adds sha2 as a workspace dependency for Sha256 surface hashing.
Cargo.toml Adds workspace dependency version for sha2.
Cargo.lock Locks new transitive dependencies introduced by sha2.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +162 to +164
pub messages: Vec<serde_json::Value>,
/// Letta metadata field.
pub metadata_: Option<serde_json::Value>,
Comment on lines +199 to +201
pub limit: usize,
/// Letta block metadata.
pub metadata_: Option<serde_json::Value>,
Comment on lines +408 to +412
is_template: false,
label: surface.as_str().to_string(),
limit: content.data.len(),
metadata_: None,
template_name: None,
Comment on lines +604 to +608
if !matched {
return Err(PortabilityError::SurfaceContentUnbound {
surface: surface.clone(),
});
}
BunsDev added a commit that referenced this pull request Jul 18, 2026
…uqx)

Add substantive annotations from Sage and Echo review (2026-07-18):

Decision #1: rationale callback — ApprovalPath is authoritative, Channel is
derived; if enforcement rule shifts, revisit all eight decisions.

Decision #2: audit implication — close event needs reason field
(applied|vetoed|expired|superseded); delayed-apply without it is a post-hoc
audit black hole.

Decision #3: forward-only promotion — retroactive region projection corrupts
authority trail with apparently-authored writes from before promotion.

Decision #4: fail-closed on extraction ambiguity — not silent LLM fallback;
ambiguity is an explicit ignored/blocked state.

Decision #5: RFC provenance pointer added.

Decision #6: Cave ProposalView labeled [DESIGNED, NOT SHIPPED] from the start.

Decision #7: label-variant round-trip is daemon wire contract (load-time reject
on drift); Cave has zero policy freedom over label strings.

Decision #8: proposal_window_opened paired with close event; window is a
first-class audit interval.

threads-uqx.3 design constraints (Sage): evidence_replay_hash on
ProposalClassification; VetoWindow.min_visible: Duration; label mapping as
daemon wire contract.

Co-authored-by: Sage <sage@opencoven.dev>
Co-authored-by: Echo <echo@opencoven.dev>
Co-authored-by: Nova <nova@opencoven.dev>
@BunsDev
BunsDev deleted the feat/threads-jq4-af-exporter branch July 19, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants