Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6a109d9
feat(canonical): add atomic-canonical crate — Recording-the-Why engin…
graywolf336 Jul 1, 2026
ed6ac14
feat(canonical): collection sub-nodes, generalized attestation, and t…
graywolf336 Jul 1, 2026
9a2e38a
feat(cli): add top-level `atomic intent` verbs backed by atomic-canon…
graywolf336 Jul 1, 2026
dba5370
feat(vault): store RtW attestations as tracked vault entries (existin…
graywolf336 Jul 2, 2026
4fd2f33
feat(cli): add top-level `atomic memory` verbs (canonical RtW surface)
graywolf336 Jul 2, 2026
0b6ba0a
feat(cli): add attestation-aware `atomic intent list` and `atomic mem…
graywolf336 Jul 2, 2026
2d8ce04
fix(cli): materialize attestations on attest; reclassify no-default-i…
graywolf336 Jul 2, 2026
de557f8
feat(canonical,cli): W3C PROV provenance projection (spine slice)
graywolf336 Jul 2, 2026
dd67820
spike(shacl): evaluate oxirs-shacl as the gate's engine (verdict: unfit)
graywolf336 Jul 2, 2026
34ed8bc
fix(canonical): W3C spec conformance — base58btc proofValue, UTF-16 J…
graywolf336 Jul 6, 2026
52938f8
feat(canonical,cli): align PROV projection to the Recording-the-Why b…
graywolf336 Jul 6, 2026
f72cb69
chore(shacl): remove atomic-shacl spike — SHACL runs in Circuit Break…
graywolf336 Jul 6, 2026
623c7d3
feat(canonical): inline directive form :name[label]{attrs}
vinceblock99 Jul 2, 2026
87fa7d9
feat(canonical,cli): reject embedded directives in prose; resolve evi…
graywolf336 Jul 6, 2026
413b73e
style: cargo fmt across the Recording-the-Why crates
graywolf336 Jul 7, 2026
03651bf
fix(ci): clippy sort_by_key, ambiguous render doc link, Windows test …
graywolf336 Jul 9, 2026
97affec
fix(ci): remaining clippy/doc failures across the merged tree
graywolf336 Jul 9, 2026
b937f15
fix(ci): rust 1.97 clippy lints (question_mark, redundant format! refs)
graywolf336 Jul 9, 2026
e6ceea6
chore: sync Cargo.lock after rebase onto dev (0.9.1)
graywolf336 Jul 14, 2026
3d54e63
feat(cli): deprecate `atomic vault intent` in favor of `atomic intent`
graywolf336 Jul 15, 2026
06f0a95
feat(cli): complete the atomic intent family (update/delete/link)
graywolf336 Jul 15, 2026
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
25 changes: 25 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resolver = "2"
members = [
"atomic-agent",
"atomic-canonical",
"atomic-cli",
"atomic-core",
"atomic-config",
Expand All @@ -24,6 +25,7 @@ rust-version = "1.90"
[workspace.dependencies]
# Core
atomic-agent = { path = "atomic-agent" }
atomic-canonical = { path = "atomic-canonical" }
atomic-core = { path = "atomic-core" }
atomic-config = { path = "atomic-config" }
atomic-identity = { path = "atomic-identity" }
Expand All @@ -45,6 +47,7 @@ rayon = "1.10"
fastcdc = "3.1"

# Hashing & Crypto
bs58 = "0.5"
blake3 = "1.5"
ed25519-dalek = { version = "2.1", features = ["serde"] }
rand = "0.8"
Expand Down
19 changes: 19 additions & 0 deletions atomic-canonical/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "atomic-canonical"
description = "Recording the Why — canonical typed nodes (JSON-LD), JCS+BLAKE3 hashing, Data Integrity proofs, the lift, and the SHACL-style gate"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true

[dependencies]
serde = { workspace = true }
serde_json = { workspace = true }
blake3 = { workspace = true }
bs58 = { workspace = true }
chrono = { workspace = true }
thiserror = { workspace = true }
data-encoding = { workspace = true }
atomic-identity = { workspace = true }
85 changes: 85 additions & 0 deletions atomic-canonical/ns/ctx.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"@context": {
"@version": 1.1,
"atom": "https://atomic.dev/ns#",
"prov": "http://www.w3.org/ns/prov#",
"sec": "https://w3id.org/security#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"xsd": "http://www.w3.org/2001/XMLSchema#",

"Intent": "atom:Intent",
"AcceptanceCriterion": "atom:AcceptanceCriterion",
"Task": "atom:Task",
"ScopeItem": "atom:ScopeItem",
"Constraint": "atom:Constraint",
"Ref": "atom:Ref",
"Memory": "atom:Memory",

"humanKey": "atom:humanKey",
"title": "atom:title",
"status": "atom:status",
"priority": "atom:priority",
"view": "atom:view",
"why": "atom:why",
"text": "atom:text",
"contentHash": "atom:contentHash",
"createdAt": { "@id": "atom:createdAt", "@type": "xsd:dateTime" },
"attributedTo": { "@id": "atom:attributedTo", "@type": "@id" },

"motivatedBy": { "@id": "atom:motivatedBy", "@type": "@id" },
"informedBy": { "@id": "atom:informedBy", "@type": "@id" },
"hasAcceptanceCriterion": "atom:hasAcceptanceCriterion",
"hasTask": "atom:hasTask",
"hasScopeIn": "atom:hasScopeIn",
"hasScopeOut": "atom:hasScopeOut",
"hasConstraint": "atom:hasConstraint",
"dependsOn": "atom:dependsOn",

"acStatus": "atom:acStatus",
"verifiedBy": { "@id": "atom:verifiedBy", "@type": "@id" },
"evidence": { "@id": "atom:evidence", "@type": "@id" },

"taskStatus": "atom:taskStatus",
"touchesFile": "atom:touchesFile",
"satisfies": { "@id": "atom:satisfies", "@type": "@id" },

"to": { "@id": "atom:to", "@type": "@id" },
"edge": "atom:edge",

"memoryKind": "atom:memoryKind",
"about": { "@id": "atom:about", "@type": "@id" },
"supersedes": { "@id": "atom:supersedes", "@type": "@id" },
"previousRevision": { "@id": "atom:previousRevision", "@type": "@id" },

"proof": "sec:proof",
"DataIntegrityProof": "sec:DataIntegrityProof",
"cryptosuite": "sec:cryptosuite",
"verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" },
"proofPurpose": "sec:proofPurpose",
"proofValue": "sec:proofValue",

"Activity": "prov:Activity",
"SoftwareAgent": "prov:SoftwareAgent",
"Person": "prov:Person",
"label": "rdfs:label",
"associatedWith": { "@id": "prov:wasAssociatedWith", "@type": "@id" },
"wasAssociatedWith": { "@id": "prov:wasAssociatedWith", "@type": "@id" },
"actedOnBehalfOf": { "@id": "prov:actedOnBehalfOf", "@type": "@id" },
"used": { "@id": "prov:used", "@type": "@id" },
"generated": { "@id": "prov:generated", "@type": "@id" },
"startedAtTime": { "@id": "prov:startedAtTime", "@type": "xsd:dateTime" },
"endedAtTime": { "@id": "prov:endedAtTime", "@type": "xsd:dateTime" },

"sessionId": "atom:sessionId",
"runId": "atom:runId",
"agentName": "atom:agentName",
"agentDisplayName": "atom:agentDisplayName",
"model": "atom:model",
"vendor": "atom:vendor",
"turnCount": { "@id": "atom:turnCount", "@type": "xsd:integer" },
"turnParent": { "@id": "atom:turnParent", "@type": "@id" },
"partOfRun": { "@id": "atom:partOfRun", "@type": "@id" },
"ownerSessionId": "atom:ownerSessionId",
"workItem": { "@id": "atom:workItem", "@type": "@id" }
}
}
70 changes: 70 additions & 0 deletions atomic-canonical/src/context.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//! The JSON-LD `@context` document — the real term→IRI table served at
//! [`crate::node::CONTEXT_URL`].
//!
//! Every canonical node (Intent, Memory) and the PROV projection name this one
//! context by URL. Shipping the actual document (rather than a bare URL) makes
//! the emitted JSON genuine, offline-processable RDF: each short key maps to a
//! `prov:`/`atom:`/`sec:`/`rdfs:`/`xsd:` IRI, object properties are `@type:@id`,
//! and timestamps are `xsd:dateTime`. The compiled bytes are the trusted
//! artifact; the file under `ns/` is the reviewable source.

use std::collections::BTreeSet;

use serde_json::Value;

/// The embedded `@context` document (the bytes served at `CONTEXT_URL`).
pub const CONTEXT_JSONLD: &str = include_str!("../ns/ctx.jsonld");

/// The set of term keys defined by the context (terms + namespace prefixes).
/// Parsed from the embedded document.
pub fn defined_terms() -> BTreeSet<String> {
let doc: Value = serde_json::from_str(CONTEXT_JSONLD).expect("ctx.jsonld is valid JSON");
doc.get("@context")
.and_then(Value::as_object)
.map(|m| m.keys().cloned().collect())
.unwrap_or_default()
}

/// Collect every object key appearing anywhere in `value`.
pub fn collect_keys(value: &Value, out: &mut BTreeSet<String>) {
match value {
Value::Object(map) => {
for (k, v) in map {
out.insert(k.clone());
collect_keys(v, out);
}
}
Value::Array(items) => items.iter().for_each(|v| collect_keys(v, out)),
_ => {}
}
}

/// The keys in `value` that the context must define: bare terms only —
/// JSON-LD keywords (`@id`, `@type`, …) need no term, and CURIEs (`prov:Activity`)
/// resolve through their namespace prefix.
pub fn undefined_terms(value: &Value) -> BTreeSet<String> {
let defined = defined_terms();
let mut keys = BTreeSet::new();
collect_keys(value, &mut keys);
keys.into_iter()
.filter(|k| !k.starts_with('@') && !k.contains(':'))
.filter(|k| !defined.contains(k))
.collect()
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn context_document_is_valid_and_nonempty() {
assert!(
defined_terms().len() > 20,
"context should define the vocabulary"
);
assert!(defined_terms().contains("prov"));
assert!(defined_terms().contains("used"));
assert!(defined_terms().contains("associatedWith"));
assert!(defined_terms().contains("label"));
}
}
109 changes: 109 additions & 0 deletions atomic-canonical/src/did.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//! The `did:atomic` method (in-tree, per the M0 decision).
//!
//! An identity's DID is derived from its Ed25519 public key exactly the way
//! atomic already derives `IdentityId`: `blake3(pubkey)`, base32-encoded. This
//! keeps the DID consistent with the rest of atomic's identity model.
//!
//! `did:atomic:<base32(blake3(pubkey))>` is a *fingerprint* of the key, so the
//! public key cannot be recovered from the DID alone — verification needs a
//! resolver (an `IdentityStore` lookup). For the self-contained M0 crate,
//! `verify` takes the `PublicKey` directly and `did_matches_public_key`
//! confirms the DID belongs to that key. The store-backed resolver arrives in
//! M1 when this wires into the vault.
//!
//! `did:atomic` stays the in-tree method (it matches atomic's identity
//! model), and [`did_key_for_public_key`] additionally provides the standard
//! `did:key` representation of the same key — multicodec `ed25519-pub`
//! (0xed 0x01) + the 32-byte key, multibase base58btc — for interop with
//! Data-Integrity tooling that resolves `did:key` natively. Verification
//! accepts either method for the same key.

use atomic_identity::keypair::PublicKey;

pub const DID_ATOMIC_PREFIX: &str = "did:atomic:";
pub const DID_KEY_PREFIX: &str = "did:key:";
/// Multicodec prefix for an Ed25519 public key (varint 0xed01).
const MULTICODEC_ED25519_PUB: [u8; 2] = [0xed, 0x01];

/// Build the `did:atomic:...` identifier for a public key.
pub fn did_for_public_key(public_key: &PublicKey) -> String {
let fingerprint = blake3::hash(public_key.as_bytes());
format!(
"{}{}",
DID_ATOMIC_PREFIX,
data_encoding::BASE32_NOPAD.encode(fingerprint.as_bytes())
)
}

/// Build the standard `did:key` identifier for an Ed25519 public key
/// (multicodec `ed25519-pub` + key bytes, base58btc multibase). Always
/// starts `did:key:z6Mk` for Ed25519 keys.
pub fn did_key_for_public_key(public_key: &PublicKey) -> String {
let mut bytes = Vec::with_capacity(2 + public_key.as_bytes().len());
bytes.extend_from_slice(&MULTICODEC_ED25519_PUB);
bytes.extend_from_slice(public_key.as_bytes());
format!("{}z{}", DID_KEY_PREFIX, bs58::encode(bytes).into_string())
}

/// The verification method id used in a proof (`<did>#key-1`).
pub fn verification_method(did: &str) -> String {
format!("{did}#key-1")
}

/// The DID out of a `<did>#fragment` verification method string.
pub fn did_from_verification_method(vm: &str) -> &str {
vm.split('#').next().unwrap_or(vm)
}

/// Does this DID correspond to the given public key? Accepts either the
/// in-tree `did:atomic` fingerprint or the standard `did:key` form.
pub fn did_matches_public_key(did: &str, public_key: &PublicKey) -> bool {
did == did_for_public_key(public_key) || did == did_key_for_public_key(public_key)
}

#[cfg(test)]
mod tests {
use super::*;
use atomic_identity::keypair::KeyPair;

#[test]
fn did_is_stable_and_key_bound() {
let kp = KeyPair::generate();
let did = did_for_public_key(&kp.public);
assert!(did.starts_with("did:atomic:"));
assert_eq!(did, did_for_public_key(&kp.public));
assert!(did_matches_public_key(&did, &kp.public));

let other = KeyPair::generate();
assert!(!did_matches_public_key(&did, &other.public));
}

#[test]
fn did_key_has_ed25519_multicodec_shape_and_verifies() {
let kp = KeyPair::generate();
let did_key = did_key_for_public_key(&kp.public);
// Ed25519 multicodec + base58btc always yields the z6Mk prefix.
assert!(
did_key.starts_with("did:key:z6Mk"),
"unexpected did:key form: {did_key}"
);
assert_eq!(did_key, did_key_for_public_key(&kp.public), "stable");
// Either representation of the same key verifies.
assert!(did_matches_public_key(&did_key, &kp.public));
assert!(did_matches_public_key(
&did_for_public_key(&kp.public),
&kp.public
));

let other = KeyPair::generate();
assert!(!did_matches_public_key(&did_key, &other.public));
}

#[test]
fn verification_method_roundtrips_to_did() {
let kp = KeyPair::generate();
let did = did_for_public_key(&kp.public);
let vm = verification_method(&did);
assert_eq!(did_from_verification_method(&vm), did);
}
}
Loading
Loading