Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
46f1c50
feat(server): acknowledge ongoing attention conditions as audit events
kvlonge Nov 18, 2026
54a8e8f
feat(ui): acknowledge any attention item; conditions come back when t…
kvlonge Nov 18, 2026
df65224
fix(server): describe an attention shape as any JSON in the API contract
kvlonge Nov 18, 2026
f937164
feat(ui): the catalog's folders as an expandable tree; the Overview c…
kvlonge Nov 18, 2026
027fa14
perf(ui): measure the Overview and the folder view on a 10,000-node p…
kvlonge Nov 18, 2026
f0142c5
fix(ui): make request IDs and copying work over plain HTTP
kvlonge Nov 18, 2026
33eeca5
fix(ui): keep the selection when copying without the Clipboard API, a…
kvlonge Nov 18, 2026
c8693e4
fix(ui): bring acknowledged server problems back when they change, an…
kvlonge Nov 18, 2026
dfdfcad
refactor(server): list run and condition acknowledgements through one…
kvlonge Nov 18, 2026
b2fe127
refactor(server): follow the project's structure rules in attention a…
kvlonge Nov 18, 2026
a3f4fef
feat: configurable attention snooze, and withdraw acknowledgements of…
kvlonge Nov 18, 2026
850ca65
fix(ui): word the Ack tooltip's time limit as "or after 1 day"
kvlonge Nov 18, 2026
4a1008b
docs: regenerate the docs skill's server page for attention_snooze
kvlonge Nov 18, 2026
9dda6c4
fix: withdraw a cleared acknowledgement only on what the read really …
kvlonge Nov 18, 2026
ec130ed
fix(ui): judge the page's own read by its ID, and read again once nod…
kvlonge Nov 18, 2026
1bb1e05
test(ui): drive automatic withdrawal through the real Overview agains…
kvlonge Nov 18, 2026
f13c235
fix: read the acknowledgement listing through its index, and make the…
kvlonge Nov 18, 2026
01916d9
feat(server): build the attention acknowledgement index through store…
kvlonge Nov 18, 2026
1e3480d
test(ui): hold the 10,000-node Overview and folder view to counted wo…
kvlonge Nov 18, 2026
f0b2941
Merge remote-tracking branch 'origin/main' into feat/overview-attention
kvlonge Nov 18, 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
150 changes: 150 additions & 0 deletions clients/typescript/src/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,22 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/control/locations/{location_id}/targets/{target}/attention-acknowledgements": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["listAttentionAcknowledgements"];
put?: never;
post: operations["acknowledgeAttention"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/control/locations/{location_id}/targets/{target}/catalog": {
parameters: {
query?: never;
Expand Down Expand Up @@ -1598,6 +1614,51 @@ export interface components {
decision_id?: string | null;
error: string;
};
/** @description A condition whose latest acknowledgement event marks it handled. */
AttentionAcknowledgement: {
/** Format: date-time */
acknowledged_at: string;
/** @description The person's name, or the audit actor when the person no longer exists. */
acknowledged_by: string;
/**
* Format: uuid
* @description The acknowledging audit event, which a withdrawal can name.
*/
event_id: string;
key: string;
shape: unknown;
/**
* Format: date-time
* @description When the acknowledgement lapses even if the condition never changes; none without a time limit.
*/
until?: string | null;
};
/** @description Marks an ongoing condition handled as it looks now, or withdraws that; an event ID applies once. */
AttentionAcknowledgementRequest: {
acknowledged: boolean;
/** Format: uuid */
event_id: string;
/** @description The condition's kind and subject, stable while it lasts, such as `stale_sources`. */
key: string;
/** @description Why, when it isn't a person's own choice, such as a withdrawal once the condition cleared. */
reason?: string | null;
/** @description What the condition looks like, as a JSON object of at most 8 KiB that later states are compared with. */
shape: unknown;
/**
* Format: uuid
* @description For a withdrawal, the acknowledgement event it withdraws: it applies only while that is still the latest.
*/
withdraws?: string | null;
};
/** @description A target's condition acknowledgements, and how long one lasts while its condition is unchanged. */
AttentionAcknowledgements: {
acknowledgements: components["schemas"]["AttentionAcknowledgement"][];
/**
* Format: int64
* @description The server's `attention_snooze` in seconds; none when acknowledgements have no time limit.
*/
snooze_seconds?: number | null;
};
AuthenticationDenial: {
error: string;
/** Format: uuid */
Expand Down Expand Up @@ -4879,6 +4940,95 @@ export interface operations {
};
};
};
listAttentionAcknowledgements: {
parameters: {
query?: never;
header?: never;
path: {
location_id: string;
target: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Conditions marked handled within two snoozes, lapsed ones included, and the snooze */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["AttentionAcknowledgements"];
};
};
/** @description Session rejected */
401: {
headers: {
[name: string]: unknown;
};
content?: never;
};
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorBody"];
};
};
};
};
acknowledgeAttention: {
parameters: {
query?: never;
header: {
"x-sqb-csrf": string;
};
path: {
location_id: string;
target: string;
};
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["AttentionAcknowledgementRequest"];
};
};
responses: {
/** @description Whether the condition's acknowledgement changed */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["MutationResponse"];
};
};
/** @description The key, shape or reason is invalid, or the event ID was reused */
400: {
headers: {
[name: string]: unknown;
};
content?: never;
};
/** @description Session rejected */
401: {
headers: {
[name: string]: unknown;
};
content?: never;
};
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorBody"];
};
};
};
};
readPersonCatalog: {
parameters: {
query: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::path::PathBuf;

use chrono::{DateTime, Utc};
use serde_json::json;
use sqlbuild_orchestration::acknowledgements::models::AttentionSnooze;
use sqlbuild_orchestration::api::models::{ApiAuthentication, HumanLogin, ServerFacts};
use sqlbuild_orchestration::credentials::models::{AuditRetention, CredentialScope};
use sqlbuild_orchestration::declarations::models::TriggerChange;
Expand Down Expand Up @@ -335,6 +336,15 @@ pub(crate) fn control_api_settings(
run_logs,
state_history,
pool_caps: Default::default(),
attention_snooze: match &config.server.attention_snooze {
Some(text) => AttentionSnooze::parse(text).map_err(|error| match error {
ControlError::Invalid(message) => {
ControlError::Invalid(format!("[server] {message}"))
}
other => other,
})?,
None => AttentionSnooze::default(),
},
},
))
}
Expand Down
3 changes: 2 additions & 1 deletion crates/sqlbuild-cli/src/server_config/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) struct ServerConfig {
pub(crate) launchers: Launchers,
}

/// The listener, control database variable, password sign-in, default role and scheduler.
/// The listener, control database variable, password sign-in, default role, scheduler and attention snooze.
#[derive(Debug, Default, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub(crate) struct ServerSection {
Expand All @@ -29,6 +29,7 @@ pub(crate) struct ServerSection {
pub(crate) password_origin: Option<String>,
pub(crate) default_role: Option<String>,
pub(crate) scheduler: Option<bool>,
pub(crate) attention_snooze: Option<String>,
}

/// How long the server keeps statistics, audit records, snapshots, run logs and state history.
Expand Down
4 changes: 2 additions & 2 deletions crates/sqlbuild-cli/tests/native_commands/test_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ fn given_a_control_store_when_running_server_migrate_then_dry_run_lists_and_migr
StoreMigrationCommandTestCase {
description: "migrate an empty store",
arguments: &["server", "migrate"],
expected_stdout: "The control store is empty: created schema version 2.\n",
expected_stdout: "The control store is empty: created schema version 3.\n",
expected_store: true,
},
StoreMigrationCommandTestCase {
description: "dry run on a current store",
arguments: &["server", "migrate", "--dry-run"],
expected_stdout: "The control store is at schema version 2: nothing to migrate.\n",
expected_stdout: "The control store is at schema version 3: nothing to migrate.\n",
expected_store: true,
},
];
Expand Down
12 changes: 12 additions & 0 deletions crates/sqlbuild-cli/tests/native_commands/test_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ fn given_invalid_or_conflicting_server_configuration_when_a_standalone_server_st
arguments: &[],
expected_error: "[retention] statistics_days must be between 1 and 65535",
},
ServerConfigurationTestCase {
description: "an attention snooze that isn't a duration names its key",
configuration: "[server]\nattention_snooze = \"a day\"\n",
arguments: &[],
expected_error: "[server] attention_snooze must be a duration such as \"24h\" or \"1d12h\", or \"0\" for no time limit",
},
ServerConfigurationTestCase {
description: "an attention snooze in months is refused",
configuration: "[server]\nattention_snooze = \"1mo\"\n",
arguments: &[],
expected_error: "[server] attention_snooze can't use years or months",
},
ServerConfigurationTestCase {
description: "the replaced trusted-proxy flag points to the file",
configuration: "",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//! What is already stored for a condition when a person acknowledges it or withdraws that.

use chrono::{DateTime, Utc};
use serde_json::Value;
use uuid::Uuid;

use crate::acknowledgements::constants::{ACKNOWLEDGED, WITHDRAWN};
use crate::acknowledgements::models::PriorAttention;
use crate::acknowledgements::models::{
AttentionAcknowledgementRequest, AttentionSnooze, StandingAttention,
};
use crate::store::errors::ControlError;
use crate::store::main::query::query;
use crate::store::models::{ControlTransaction, Parameter};

/// The request's earlier application under its event ID, or else the condition's latest event.
pub(crate) async fn prior_attention(
transaction: ControlTransaction,
(location_id, target): (Uuid, &str),
(request, body): (&AttentionAcknowledgementRequest, &Value),
) -> Result<(ControlTransaction, PriorAttention), ControlError> {
let (transaction, retried) = query(
transaction,
"SELECT scope_json FROM sqb_security_audit WHERE event_id=$1",
vec![Parameter::Id(request.event_id)],
)
.await?;
if let Some(previous) = retried.first() {
if previous["scope_json"].get("request") != Some(body) {
return Err(ControlError::Invalid(
"acknowledgement event ID already has different content".into(),
));
}
return Ok((transaction, PriorAttention::Retried));
}
let (transaction, latest) = query(
transaction,
&format!(
"SELECT event_id, action, occurred_at, scope_json FROM sqb_security_audit \
WHERE action IN ('{ACKNOWLEDGED}','{WITHDRAWN}') AND scope_json ->> 'location_id'=$1 \
AND scope_json ->> 'target'=$2 AND scope_json ->> 'key'=$3 ORDER BY storage_id DESC LIMIT 1"
),
vec![
Parameter::Text(location_id.to_string()),
Parameter::Text(target.into()),
Parameter::Text(request.key.clone()),
],
)
.await?;
let previous = latest.first();
let at: Option<DateTime<Utc>> = previous
.map(|row| serde_json::from_value(row["occurred_at"].clone()))
.transpose()
.map_err(|error| ControlError::Schema(format!("acknowledgement time: {error}")))?;
let event_id: Option<Uuid> = previous
.map(|row| serde_json::from_value(row["event_id"].clone()))
.transpose()
.map_err(|error| ControlError::Schema(format!("acknowledgement event: {error}")))?;
let standing = StandingAttention {
event_id,
acknowledged: previous.is_some_and(|row| row["action"].as_str() == Some(ACKNOWLEDGED)),
shape: previous.map_or(Value::Null, |row| row["scope_json"]["shape"].clone()),
at,
};
Ok((transaction, PriorAttention::Standing(standing)))
}

/// Whether a request changes nothing: a held shape, or a withdrawal of nothing or of a superseded acknowledgement.
pub(crate) fn unchanged(
standing: &StandingAttention,
request: &AttentionAcknowledgementRequest,
(now, snooze): (DateTime<Utc>, AttentionSnooze),
) -> bool {
if !request.acknowledged {
return !standing.acknowledged
|| request
.withdraws
.is_some_and(|named| standing.event_id != Some(named));
}
standing.acknowledged
&& standing.shape == request.shape
&& standing
.at
.is_some_and(|at| snooze.until(at).is_none_or(|until| now < until))
}
Loading
Loading