feat: initial implementation of TFTSR IT Triage & RCA application
Implements Phases 1-8 of the TFTSR implementation plan.
Rust backend (Tauri 2.x, src-tauri/):
- Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama
- PII detection engine: 11 regex patterns with overlap resolution
- SQLCipher AES-256 encrypted database with 10 versioned migrations
- 28 Tauri IPC commands for triage, analysis, document, and system ops
- Ollama: hardware probe, model recommendations, pull/delete with events
- RCA and blameless post-mortem Markdown document generators
- PDF export via printpdf
- Audit log: SHA-256 hash of every external data send
- Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2)
Frontend (React 18 + TypeScript + Vite, src/):
- 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings
- 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives
- 3 Zustand stores: session, settings (persisted), history
- Type-safe tauriCommands.ts matching Rust backend types exactly
- 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs)
DevOps:
- .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push
- .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload
Verified:
- cargo check: zero errors
- tsc --noEmit: zero errors
- vitest run: 13/13 unit tests passing
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 03:36:25 +00:00
|
|
|
use crate::db::models::AuditEntry;
|
|
|
|
|
|
|
|
|
|
/// Write an audit event to the audit_log table.
|
|
|
|
|
pub fn write_audit_event(
|
|
|
|
|
conn: &rusqlite::Connection,
|
|
|
|
|
action: &str,
|
|
|
|
|
entity_type: &str,
|
|
|
|
|
entity_id: &str,
|
|
|
|
|
details: &str,
|
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
|
let entry = AuditEntry::new(
|
|
|
|
|
action.to_string(),
|
|
|
|
|
entity_type.to_string(),
|
|
|
|
|
entity_id.to_string(),
|
|
|
|
|
details.to_string(),
|
|
|
|
|
);
|
|
|
|
|
conn.execute(
|
|
|
|
|
"INSERT INTO audit_log (id, timestamp, action, entity_type, entity_id, user_id, details) \
|
|
|
|
|
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)",
|
|
|
|
|
rusqlite::params![
|
|
|
|
|
entry.id,
|
|
|
|
|
entry.timestamp,
|
|
|
|
|
entry.action,
|
|
|
|
|
entry.entity_type,
|
|
|
|
|
entry.entity_id,
|
|
|
|
|
entry.user_id,
|
|
|
|
|
entry.details,
|
|
|
|
|
],
|
|
|
|
|
)?;
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
fn setup_test_db() -> rusqlite::Connection {
|
|
|
|
|
let conn = rusqlite::Connection::open_in_memory().unwrap();
|
|
|
|
|
conn.execute_batch(
|
|
|
|
|
"CREATE TABLE audit_log (
|
|
|
|
|
id TEXT PRIMARY KEY,
|
|
|
|
|
timestamp TEXT NOT NULL,
|
|
|
|
|
action TEXT NOT NULL,
|
|
|
|
|
entity_type TEXT NOT NULL DEFAULT '',
|
|
|
|
|
entity_id TEXT NOT NULL DEFAULT '',
|
|
|
|
|
user_id TEXT NOT NULL DEFAULT 'local',
|
|
|
|
|
details TEXT NOT NULL DEFAULT '{}'
|
|
|
|
|
);",
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
conn
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_write_audit_event_inserts_row() {
|
|
|
|
|
let conn = setup_test_db();
|
2026-03-15 17:43:46 +00:00
|
|
|
write_audit_event(
|
|
|
|
|
&conn,
|
|
|
|
|
"test_action",
|
|
|
|
|
"issue",
|
|
|
|
|
"issue-123",
|
|
|
|
|
r#"{"key":"val"}"#,
|
|
|
|
|
)
|
|
|
|
|
.expect("should insert");
|
feat: initial implementation of TFTSR IT Triage & RCA application
Implements Phases 1-8 of the TFTSR implementation plan.
Rust backend (Tauri 2.x, src-tauri/):
- Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama
- PII detection engine: 11 regex patterns with overlap resolution
- SQLCipher AES-256 encrypted database with 10 versioned migrations
- 28 Tauri IPC commands for triage, analysis, document, and system ops
- Ollama: hardware probe, model recommendations, pull/delete with events
- RCA and blameless post-mortem Markdown document generators
- PDF export via printpdf
- Audit log: SHA-256 hash of every external data send
- Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2)
Frontend (React 18 + TypeScript + Vite, src/):
- 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings
- 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives
- 3 Zustand stores: session, settings (persisted), history
- Type-safe tauriCommands.ts matching Rust backend types exactly
- 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs)
DevOps:
- .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push
- .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload
Verified:
- cargo check: zero errors
- tsc --noEmit: zero errors
- vitest run: 13/13 unit tests passing
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 03:36:25 +00:00
|
|
|
|
|
|
|
|
let count: i64 = conn
|
|
|
|
|
.prepare("SELECT COUNT(*) FROM audit_log")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.query_row([], |row| row.get(0))
|
|
|
|
|
.unwrap();
|
|
|
|
|
assert_eq!(count, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_write_audit_event_correct_fields() {
|
|
|
|
|
let conn = setup_test_db();
|
|
|
|
|
write_audit_event(&conn, "create_issue", "issue", "abc-999", "details here")
|
|
|
|
|
.expect("should insert");
|
|
|
|
|
|
|
|
|
|
let (action, entity_type, entity_id, user_id): (String, String, String, String) = conn
|
|
|
|
|
.prepare("SELECT action, entity_type, entity_id, user_id FROM audit_log LIMIT 1")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.query_row([], |row| {
|
|
|
|
|
Ok((row.get(0)?, row.get(1)?, row.get(2)?, row.get(3)?))
|
|
|
|
|
})
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
assert_eq!(action, "create_issue");
|
|
|
|
|
assert_eq!(entity_type, "issue");
|
|
|
|
|
assert_eq!(entity_id, "abc-999");
|
|
|
|
|
assert_eq!(user_id, "local");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_write_multiple_events() {
|
|
|
|
|
let conn = setup_test_db();
|
|
|
|
|
for i in 0..5 {
|
|
|
|
|
write_audit_event(
|
|
|
|
|
&conn,
|
|
|
|
|
&format!("action_{}", i),
|
|
|
|
|
"test",
|
|
|
|
|
&format!("id_{}", i),
|
|
|
|
|
"{}",
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let count: i64 = conn
|
|
|
|
|
.prepare("SELECT COUNT(*) FROM audit_log")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.query_row([], |row| row.get(0))
|
|
|
|
|
.unwrap();
|
|
|
|
|
assert_eq!(count, 5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_write_audit_event_generates_unique_ids() {
|
|
|
|
|
let conn = setup_test_db();
|
|
|
|
|
write_audit_event(&conn, "a", "t", "1", "{}").unwrap();
|
|
|
|
|
write_audit_event(&conn, "b", "t", "2", "{}").unwrap();
|
|
|
|
|
|
|
|
|
|
let mut stmt = conn.prepare("SELECT id FROM audit_log").unwrap();
|
|
|
|
|
let ids: Vec<String> = stmt
|
|
|
|
|
.query_map([], |row| row.get(0))
|
|
|
|
|
.unwrap()
|
|
|
|
|
.filter_map(|r| r.ok())
|
|
|
|
|
.collect();
|
|
|
|
|
assert_eq!(ids.len(), 2);
|
|
|
|
|
assert_ne!(ids[0], ids[1]);
|
|
|
|
|
}
|
|
|
|
|
}
|