huskies: merge 1088
This commit is contained in:
@@ -103,6 +103,7 @@ pub(crate) fn tool_dump_crdt(args: &Value) -> Result<String, String> {
|
||||
"claimed_at": item.claim_ts,
|
||||
"content_index": item.content_index,
|
||||
"is_deleted": item.is_deleted,
|
||||
"origin": item.origin,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -195,6 +195,9 @@ pub(super) async fn tool_status(args: &Value, ctx: &AppContext) -> Result<String
|
||||
if !deps.is_empty() {
|
||||
front_matter.insert("depends_on".to_string(), json!(deps));
|
||||
}
|
||||
// Story 1088: origin tracking.
|
||||
let origin_str = view.origin().unwrap_or("unknown");
|
||||
front_matter.insert("origin".to_string(), json!(origin_str));
|
||||
let stage_claim = match &typed_item.stage {
|
||||
crate::pipeline_state::Stage::Coding { claim, .. } => claim.as_ref(),
|
||||
crate::pipeline_state::Stage::Merge { claim, .. } => claim.as_ref(),
|
||||
|
||||
@@ -38,6 +38,8 @@ pub(crate) fn tool_create_bug(args: &Value, ctx: &AppContext) -> Result<String,
|
||||
depends_on.as_deref(),
|
||||
)?;
|
||||
|
||||
crate::crdt_state::set_origin(&bug_id, &super::build_origin(args));
|
||||
|
||||
let _ = ctx
|
||||
.watcher_tx
|
||||
.send(crate::io::watcher::WatcherEvent::NewItemCreated {
|
||||
|
||||
@@ -29,6 +29,8 @@ pub(crate) fn tool_create_epic(args: &Value, ctx: &AppContext) -> Result<String,
|
||||
},
|
||||
)?;
|
||||
|
||||
crate::crdt_state::set_origin(&epic_id, &super::build_origin(args));
|
||||
|
||||
Ok(format!("Created epic: {epic_id}"))
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,33 @@ mod refactor;
|
||||
mod spike;
|
||||
mod story;
|
||||
|
||||
/// Build a compact origin JSON string for a newly-created work item (story 1088).
|
||||
///
|
||||
/// `args` may contain an `"origin"` object with `kind`, `id`, and `ts` fields
|
||||
/// supplied by the caller (e.g. a coder agent passing its own identity). When
|
||||
/// absent the default is `{"kind":"user","id":"","ts":<now>}`.
|
||||
///
|
||||
/// Callers that create items on behalf of system automation (e.g. gate-failure
|
||||
/// auto-filing) should pass `kind = "system"` and `id = "<automation-name>"`.
|
||||
pub(super) fn build_origin(args: &serde_json::Value) -> String {
|
||||
let ts = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_secs_f64();
|
||||
|
||||
if let Some(origin_obj) = args.get("origin").and_then(|v| v.as_object()) {
|
||||
let kind = origin_obj
|
||||
.get("kind")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("user");
|
||||
let id = origin_obj.get("id").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let ts_val = origin_obj.get("ts").and_then(|v| v.as_f64()).unwrap_or(ts);
|
||||
serde_json::json!({"kind": kind, "id": id, "ts": ts_val}).to_string()
|
||||
} else {
|
||||
serde_json::json!({"kind": "user", "id": "", "ts": ts}).to_string()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) use bug::{tool_close_bug, tool_create_bug, tool_list_bugs};
|
||||
pub(crate) use criteria::{
|
||||
tool_add_criterion, tool_check_criterion, tool_edit_criterion, tool_ensure_acceptance,
|
||||
|
||||
@@ -36,6 +36,8 @@ pub(crate) fn tool_create_refactor(args: &Value, ctx: &AppContext) -> Result<Str
|
||||
depends_on.as_deref(),
|
||||
)?;
|
||||
|
||||
crate::crdt_state::set_origin(&refactor_id, &super::build_origin(args));
|
||||
|
||||
let _ = ctx
|
||||
.watcher_tx
|
||||
.send(crate::io::watcher::WatcherEvent::NewItemCreated {
|
||||
|
||||
@@ -36,6 +36,8 @@ pub(crate) fn tool_create_spike(args: &Value, ctx: &AppContext) -> Result<String
|
||||
depends_on.as_deref(),
|
||||
)?;
|
||||
|
||||
crate::crdt_state::set_origin(&spike_id, &super::build_origin(args));
|
||||
|
||||
let _ = ctx
|
||||
.watcher_tx
|
||||
.send(crate::io::watcher::WatcherEvent::NewItemCreated {
|
||||
|
||||
@@ -31,6 +31,8 @@ pub(crate) fn tool_create_story(args: &Value, ctx: &AppContext) -> Result<String
|
||||
false,
|
||||
)?;
|
||||
|
||||
crate::crdt_state::set_origin(&story_id, &super::super::build_origin(args));
|
||||
|
||||
let _ = ctx
|
||||
.watcher_tx
|
||||
.send(crate::io::watcher::WatcherEvent::NewItemCreated {
|
||||
|
||||
Reference in New Issue
Block a user