pub struct CodeArtifact {
pub id: String,
pub language: String,
pub repo_url: Option<String>,
pub git_commit: Option<String>,
pub path: String,
pub line_range: Option<(u32, u32)>,
pub content_hash: String,
pub entry_point: Option<String>,
pub created: String,
}Expand description
v0.33: CodeArtifact as a first-class kernel object.
A CodeArtifact is a content-addressed pointer at a specific
region of source code (a function, a notebook cell, a script, a
pipeline step) at a specific git commit. Before v0.33, code was
captured as a string in Evidence.method — “we ran a logistic
regression” — with no way for a reader to verify which code
produced the result, or to re-run it.
vc_<id> is content-addressed over `repo_url + git_commit + path
- line_range + content_hash`. The same code at two commits gets two records (the relevant historical fact); the same code in two paths in the same repo also gets two records (location matters for re-execution).
Fields§
§id: Stringvc_<16hex>, content-addressed; see CodeArtifact::content_address.
language: StringSource language: python / r / julia / rust / bash,
etc. Not validated against a closed allow-list — code provenance
should accept whatever language the analysis was actually in.
repo_url: Option<String>Repository URL (e.g. https://github.com/vela-science/vela).
git_commit: Option<String>Specific git commit (40-char SHA preferred). Required for
reproducibility; None means “unpinned” and weakens the
substrate claim.
path: StringPath within the repository (e.g. crates/vela-scientist/src/notes.rs).
line_range: Option<(u32, u32)>Optional line range as (start, end), both inclusive.
content_hash: StringSHA-256 of the snippet body. Decouples the artifact from the repository’s external state — even if a repo is deleted, the content_hash remains anchored.
entry_point: Option<String>Optional entry point: function name, notebook cell id, or
__main__. Used by re-execution tooling.
created: StringRFC 3339 creation timestamp.
Implementations§
Source§impl CodeArtifact
impl CodeArtifact
Sourcepub fn content_address(
repo_url: Option<&str>,
git_commit: Option<&str>,
path: &str,
line_range: Option<(u32, u32)>,
content_hash: &str,
) -> String
pub fn content_address( repo_url: Option<&str>, git_commit: Option<&str>, path: &str, line_range: Option<(u32, u32)>, content_hash: &str, ) -> String
Compute the content-addressed ID per v0.33 spec:
SHA-256(repo_url | git_commit | path | line_range | content_hash).
Returns first 16 hex chars prefixed with “vc_”.
Sourcepub fn new(
language: impl Into<String>,
repo_url: Option<String>,
git_commit: Option<String>,
path: impl Into<String>,
line_range: Option<(u32, u32)>,
content_hash: impl Into<String>,
entry_point: Option<String>,
) -> Self
pub fn new( language: impl Into<String>, repo_url: Option<String>, git_commit: Option<String>, path: impl Into<String>, line_range: Option<(u32, u32)>, content_hash: impl Into<String>, entry_point: Option<String>, ) -> Self
Construct a new CodeArtifact with a freshly-derived id and
created timestamp.
Trait Implementations§
Source§impl Clone for CodeArtifact
impl Clone for CodeArtifact
Source§fn clone(&self) -> CodeArtifact
fn clone(&self) -> CodeArtifact
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more