Add proper lifecycle and superseding support for Architectural Decision Records
This commit is contained in:
1 parent
70edfa4389
commit
54aead2151
4 files changed
+28
-3
No files matched your search
@@ -1085,10 +1085,12 @@
|
|||||||
`);
|
`);
|
||||||
|
|
||||||
loadGenericList('/api/adrs', 'adrs-container', item => `
|
loadGenericList('/api/adrs', 'adrs-container', item => `
|
||||||
<strong>${item.title}</strong>
|
<strong>${item.id} | ${item.title}</strong>
|
||||||
<div style="font-size:0.9em; margin-bottom:8px;"><em>Context:</em> ${item.context || ''}</div>
|
<span style="float:right; background:var(--canvas-bg); padding:2px 6px; border-radius:4px; font-size:0.8em; border:1px solid var(--border-color); ${item.status === 'superseded' ? 'text-decoration: line-through; color:var(--error-color);' : 'color:var(--success-color);'}">${item.status}</span>
|
||||||
|
<div style="font-size:0.9em; margin-bottom:8px; margin-top:8px;"><em>Context:</em> ${item.context || ''}</div>
|
||||||
<div style="font-size:0.9em; margin-bottom:8px;"><em>Decision:</em> ${item.decision || ''}</div>
|
<div style="font-size:0.9em; margin-bottom:8px;"><em>Decision:</em> ${item.decision || ''}</div>
|
||||||
<div style="font-size:0.9em;"><em>Consequences:</em> ${item.consequences || ''}</div>
|
<div style="font-size:0.9em; margin-bottom:8px;"><em>Consequence:</em> ${item.consequence || ''}</div>
|
||||||
|
${item.supersedes ? `<div style="font-size:0.9em; font-weight:bold; color:var(--warning-color);">Supersedes: ${item.supersedes}</div>` : ''}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
loadGenericList('/api/context_workspaces', 'workspaces-container', item => `
|
loadGenericList('/api/context_workspaces', 'workspaces-container', item => `
|
||||||
|
|||||||
@@ -25,6 +25,17 @@ impl McpTool for LogDecisionHandler {
|
|||||||
let mut final_id = String::new();
|
let mut final_id = String::new();
|
||||||
|
|
||||||
state.adrs.modify(|adrs| {
|
state.adrs.modify(|adrs| {
|
||||||
|
if let Some(superseded_id) = &req.supersedes {
|
||||||
|
for old_adr in adrs.iter_mut() {
|
||||||
|
if old_adr.id == *superseded_id {
|
||||||
|
old_adr.status = "superseded".to_string();
|
||||||
|
// Re-index the modified old ADR
|
||||||
|
drop(idx.index_adr(old_adr));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final_id = format!("ADR-{:04}", adrs.len() + 1);
|
final_id = format!("ADR-{:04}", adrs.len() + 1);
|
||||||
let a = Adr {
|
let a = Adr {
|
||||||
id: final_id.clone(),
|
id: final_id.clone(),
|
||||||
@@ -32,6 +43,8 @@ impl McpTool for LogDecisionHandler {
|
|||||||
context: req.context,
|
context: req.context,
|
||||||
decision: req.decision,
|
decision: req.decision,
|
||||||
consequence: req.consequence,
|
consequence: req.consequence,
|
||||||
|
status: "accepted".to_string(),
|
||||||
|
supersedes: req.supersedes,
|
||||||
timestamp: crate::handlers::utils::now_secs(),
|
timestamp: crate::handlers::utils::now_secs(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -82,8 +82,16 @@ pub struct Adr {
|
|||||||
pub context: String,
|
pub context: String,
|
||||||
pub decision: String,
|
pub decision: String,
|
||||||
pub consequence: String,
|
pub consequence: String,
|
||||||
|
#[serde(default = "default_adr_status")]
|
||||||
|
pub status: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub supersedes: Option<String>,
|
||||||
pub timestamp: u64,
|
pub timestamp: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_adr_status() -> String {
|
||||||
|
"accepted".to_string()
|
||||||
|
}
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct Preference {
|
pub struct Preference {
|
||||||
pub key: String,
|
pub key: String,
|
||||||
|
|||||||
@@ -220,6 +220,8 @@ pub struct LogDecisionTool {
|
|||||||
pub decision: String,
|
pub decision: String,
|
||||||
/// The consequence of the decision.
|
/// The consequence of the decision.
|
||||||
pub consequence: String,
|
pub consequence: String,
|
||||||
|
/// The ID of an older ADR this decision supersedes, if any.
|
||||||
|
pub supersedes: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query architectural decision records.
|
/// Query architectural decision records.
|
||||||
|
|||||||
Reference in new issue
Block a user