mirror of
https://github.com/openai/codex.git
synced 2026-10-25 23:57:40 +00:00
## What changed - Add a `thread_artifacts` SQLite table with per-thread typed identities, JSON payloads, cascade deletion, uniqueness enforcement, and an index for ordered per-thread reads. - Export artifact records, attachment and removal outcomes, and paginated result models from `codex-state`. ## Testing - Add a migration test covering preservation of existing thread-section metadata and compatibility with the previous migration set. GitOrigin-RevId: 4e0a8e5bfa168ae2b8871970466e5055e142a4a6
47 lines
1.7 KiB
Rust
47 lines
1.7 KiB
Rust
use codex_protocol::ThreadId;
|
|
use serde_json::Value;
|
|
|
|
/// A bounded artifact durably associated with one thread.
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ThreadArtifact {
|
|
/// Stable, server-assigned UUIDv7 artifact identity.
|
|
pub id: String,
|
|
/// Thread that owns this artifact.
|
|
pub thread_id: ThreadId,
|
|
/// Client-defined artifact category.
|
|
pub artifact_type: String,
|
|
/// Client-defined stable identity within the owning thread and artifact category.
|
|
pub identity_key: String,
|
|
/// Bounded, client-defined artifact metadata.
|
|
pub payload: Value,
|
|
/// Integer Unix timestamp in seconds when the artifact was attached.
|
|
pub created_at: i64,
|
|
}
|
|
|
|
/// Result of attaching one uniquely identified thread artifact.
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum ThreadArtifactAttachmentOutcome {
|
|
/// A new durable artifact was created.
|
|
Created(ThreadArtifact),
|
|
/// The artifact was already attached; its payload and creation time are unchanged.
|
|
Existing(ThreadArtifact),
|
|
}
|
|
|
|
/// Result of removing a thread artifact.
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum ThreadArtifactRemovalOutcome {
|
|
/// An attached artifact was removed.
|
|
Removed(ThreadArtifact),
|
|
/// No artifact with the requested identity was attached.
|
|
NotFound,
|
|
}
|
|
|
|
/// One deterministically ordered page of artifacts across selected threads.
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ThreadArtifactPage {
|
|
/// Artifacts ordered by thread identity, creation time, and artifact identity.
|
|
pub artifacts: Vec<ThreadArtifact>,
|
|
/// Opaque cursor for the next page, or `None` when the selection is exhausted.
|
|
pub next_cursor: Option<String>,
|
|
}
|