Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
336e80a
config: Add agent_trace repository identity keys
davidabram Jul 17, 2026
3744610
identity: Add repository identity canonicalization and hashing
davidabram Jul 17, 2026
ea41e7f
identity: Add runtime repository identity resolver
davidabram Jul 17, 2026
38d5ab3
trace: Add repository-scoped Agent Trace storage resolver
davidabram Jul 17, 2026
8eda60e
agent_trace_db: Add repository-scoped schema baseline
davidabram Jul 17, 2026
1d1e13d
agent-trace-db: Add repository-scoped write helpers
davidabram Jul 17, 2026
43264d0
agent-trace-db: Add repository recent diff trace reads
davidabram Jul 17, 2026
78566d3
context: Update repository Agent Trace lifecycle docs
davidabram Jul 17, 2026
4e8e2ad
trace: Update commands for repository-scoped databases
davidabram Jul 17, 2026
b8ba417
trace: Expose credential-safe repository diagnostics
davidabram Jul 17, 2026
a113e63
agent-trace: Document repository-scoped storage completion
davidabram Jul 17, 2026
5b5f98e
agent-trace-db: Remove dead checkout DB opener and path helper
davidabram Jul 17, 2026
738bd0a
agent-trace-db: Remove dead hooks opener and stale dead-code allows
davidabram Jul 17, 2026
a82d49e
trace: Remove the --legacy trace CLI surface
davidabram Jul 17, 2026
b1e0982
agent-trace: Migrate trace test seeders and shell read path to Reposi…
davidabram Jul 17, 2026
095f0a4
trace: Switch stats/discovery read paths to RepositoryAgentTraceDb
davidabram Jul 17, 2026
157fff9
agent-trace-db: Retire legacy AgentTraceDb adapter and reflect in con…
davidabram Jul 17, 2026
c961625
repository_identity: Implement slug + short-hash directory segment de…
davidabram Jul 17, 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
18 changes: 18 additions & 0 deletions cli/assets/generated/config/schema/sce-config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@
"workos_client_id": {
"type": "string"
},
"agent_trace": {
"description": "Agent Trace repository identity configuration. Selects the repository-scoped Agent Trace database.",
"type": "object",
"properties": {
"repository_id": {
"description": "Explicit repository identity. When set, overrides Git remote based repository identity resolution.",
"type": "string",
"minLength": 1
},
"repository_remote": {
"description": "Git remote name used to derive repository identity. Defaults to origin when omitted.",
"default": "origin",
"type": "string",
"minLength": 1
}
},
"additionalProperties": false
},
"policies": {
"type": "object",
"properties": {
Expand Down
116 changes: 116 additions & 0 deletions cli/migrations/agent-trace-repository/001_repository_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
-- Repository-scoped Agent Trace database baseline.
--
-- One logical Git repository maps to one database at
-- <state-root>/sce/repos/<repository-id>/agent-trace.db. This file is the
-- complete fresh schema for that database: repository-scoped databases are
-- always created new, so the baseline stays a single file instead of an
-- incremental migration chain. Trace tables are repository-level and
-- intentionally carry no checkout_id columns; checkout identity is
-- diagnostics-only context and is never persisted on trace rows.

CREATE TABLE IF NOT EXISTS repository_metadata (
id INTEGER PRIMARY KEY CHECK (id = 1),
repository_id TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
);

CREATE TABLE IF NOT EXISTS diff_traces (
id INTEGER PRIMARY KEY,
time_ms INTEGER NOT NULL,
session_id TEXT NOT NULL,
patch TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
model_id TEXT,
tool_name TEXT,
tool_version TEXT,
payload_type TEXT NOT NULL DEFAULT 'patch'
);

CREATE INDEX IF NOT EXISTS idx_diff_traces_time_ms_id
ON diff_traces (time_ms, id);

CREATE TABLE IF NOT EXISTS post_commit_patch_intersections (
id INTEGER PRIMARY KEY,
commit_id TEXT NOT NULL,
post_commit_time_ms INTEGER NOT NULL,
recent_window_cutoff_ms INTEGER NOT NULL,
recent_window_end_ms INTEGER NOT NULL,
loaded_diff_trace_count INTEGER NOT NULL CHECK (loaded_diff_trace_count >= 0),
skipped_diff_trace_count INTEGER NOT NULL CHECK (skipped_diff_trace_count >= 0),
intersection_patch TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
);

CREATE TABLE IF NOT EXISTS agent_traces (
id INTEGER PRIMARY KEY,
commit_id TEXT NOT NULL,
commit_time_ms INTEGER NOT NULL,
url TEXT NOT NULL,
trace_json TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
agent_trace_id TEXT NOT NULL UNIQUE,
remote_url TEXT
);

CREATE INDEX IF NOT EXISTS idx_agent_traces_agent_trace_id
ON agent_traces (agent_trace_id);

CREATE INDEX IF NOT EXISTS idx_agent_traces_remote_url
ON agent_traces (remote_url);

CREATE TABLE IF NOT EXISTS messages (
id INTEGER PRIMARY KEY,
session_id TEXT NOT NULL,
message_id TEXT NOT NULL,
role TEXT NOT NULL CHECK (role IN ('user', 'assistant')),
generated_at_unix_ms INTEGER NOT NULL CHECK (generated_at_unix_ms >= 0),
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
);

CREATE UNIQUE INDEX IF NOT EXISTS idx_messages_session_message
ON messages (session_id, message_id);

CREATE INDEX IF NOT EXISTS idx_messages_session_order
ON messages (session_id, generated_at_unix_ms, id);

CREATE TABLE IF NOT EXISTS parts (
id INTEGER PRIMARY KEY,
type TEXT NOT NULL,
text TEXT NOT NULL,
message_id TEXT NOT NULL,
session_id TEXT NOT NULL,
generated_at_unix_ms INTEGER NOT NULL CHECK (generated_at_unix_ms >= 0),
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
);

CREATE INDEX IF NOT EXISTS idx_parts_session_message_order
ON parts (session_id, message_id, generated_at_unix_ms, id);

CREATE TRIGGER IF NOT EXISTS trg_messages_updated_at
AFTER UPDATE ON messages
FOR EACH ROW
WHEN OLD.session_id IS NOT NEW.session_id
OR OLD.message_id IS NOT NEW.message_id
OR OLD.role IS NOT NEW.role
OR OLD.generated_at_unix_ms IS NOT NEW.generated_at_unix_ms
BEGIN
UPDATE messages
SET updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
WHERE id = NEW.id;
END;

CREATE TRIGGER IF NOT EXISTS trg_parts_updated_at
AFTER UPDATE ON parts
FOR EACH ROW
WHEN OLD.type IS NOT NEW.type
OR OLD.text IS NOT NEW.text
OR OLD.message_id IS NOT NEW.message_id
OR OLD.session_id IS NOT NEW.session_id
OR OLD.generated_at_unix_ms IS NOT NEW.generated_at_unix_ms
BEGIN
UPDATE parts
SET updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
WHERE id = NEW.id;
END;
10 changes: 0 additions & 10 deletions cli/migrations/agent-trace/001_create_diff_traces.sql

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions cli/migrations/agent-trace/003_create_agent_traces.sql

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions cli/migrations/agent-trace/008_create_messages.sql

This file was deleted.

10 changes: 0 additions & 10 deletions cli/migrations/agent-trace/009_create_parts.sql

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions cli/migrations/agent-trace/014_create_parts_updated_at_trigger.sql

This file was deleted.

This file was deleted.

8 changes: 4 additions & 4 deletions cli/src/cli_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub enum TraceSubcommand {
subcommand: TraceDbSubcommand,
},

#[command(about = "Show Agent Trace activity for the current checkout (or all with --all)")]
#[command(about = "Show Agent Trace activity for the current repository (or all with --all)")]
Status {
#[arg(long)]
all: bool,
Expand All @@ -255,10 +255,10 @@ pub enum TraceDbSubcommand {
format: OutputFormat,
},

#[command(about = "Open an embedded SQL shell for a discovered Agent Trace database")]
#[command(about = "Open an embedded SQL shell for an Agent Trace database")]
Shell {
#[arg(value_name = "uuid-or-alias")]
identifier: String,
#[arg(value_name = "repository-id-or-alias")]
identifier: Option<String>,
},
}

Expand Down
18 changes: 2 additions & 16 deletions cli/src/generated_migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,8 @@
#![allow(dead_code)]

#[rustfmt::skip]
pub static AGENT_TRACE_MIGRATIONS: &[(&str, &str)] = &[
("001_create_diff_traces", include_str!("../migrations/agent-trace/001_create_diff_traces.sql")),
("002_create_post_commit_patch_intersections", include_str!("../migrations/agent-trace/002_create_post_commit_patch_intersections.sql")),
("003_create_agent_traces", include_str!("../migrations/agent-trace/003_create_agent_traces.sql")),
("004_create_diff_traces_time_ms_id_index", include_str!("../migrations/agent-trace/004_create_diff_traces_time_ms_id_index.sql")),
("005_create_agent_traces_agent_trace_id_index", include_str!("../migrations/agent-trace/005_create_agent_traces_agent_trace_id_index.sql")),
("006_add_agent_traces_vcs_remote_url", include_str!("../migrations/agent-trace/006_add_agent_traces_vcs_remote_url.sql")),
("007_create_agent_traces_vcs_remote_url_index", include_str!("../migrations/agent-trace/007_create_agent_traces_vcs_remote_url_index.sql")),
("008_create_messages", include_str!("../migrations/agent-trace/008_create_messages.sql")),
("009_create_parts", include_str!("../migrations/agent-trace/009_create_parts.sql")),
("010_create_messages_session_message_unique_index", include_str!("../migrations/agent-trace/010_create_messages_session_message_unique_index.sql")),
("011_create_messages_session_order_index", include_str!("../migrations/agent-trace/011_create_messages_session_order_index.sql")),
("012_create_parts_session_message_order_index", include_str!("../migrations/agent-trace/012_create_parts_session_message_order_index.sql")),
("013_create_messages_updated_at_trigger", include_str!("../migrations/agent-trace/013_create_messages_updated_at_trigger.sql")),
("014_create_parts_updated_at_trigger", include_str!("../migrations/agent-trace/014_create_parts_updated_at_trigger.sql")),
("015_add_diff_traces_payload_type", include_str!("../migrations/agent-trace/015_add_diff_traces_payload_type.sql")),
pub static AGENT_TRACE_REPOSITORY_MIGRATIONS: &[(&str, &str)] = &[
("001_repository_schema", include_str!("../migrations/agent-trace-repository/001_repository_schema.sql")),
];

#[rustfmt::skip]
Expand Down
Loading
Loading