feat(suppress): group-suppress warnings + ls + journey + docs (M1.5)
- dangling_suppress_warnings takes an ApplyOwner and walks the group's own
chain (GROUP_CHAIN_LEVELS_CTE) for a group node; runs for both owners.
- GET /groups/{id}/suppressions + `pic suppress ls --group` (client + cmd +
main.rs; --app/--group mutually exclusive).
- suppress journey: a child group declines a parent template for its subtree;
suppress ls --group shows the marker. Docs §4.5 + CLAUDE.md move group-level
suppression from Deferred to implemented.
Completes M1. (An unrelated pre-existing email_inbound dispatch-timing flake
passes in isolation.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,7 @@ pub fn apply_router(service: ApplyService) -> Router {
|
||||
.route("/groups/{id}/triggers", get(group_triggers_handler))
|
||||
.route("/groups/{id}/routes", get(group_routes_handler))
|
||||
.route("/apps/{id}/suppressions", get(app_suppressions_handler))
|
||||
.route("/groups/{id}/suppressions", get(group_suppressions_handler))
|
||||
.with_state(service)
|
||||
}
|
||||
|
||||
@@ -64,6 +65,26 @@ async fn app_suppressions_handler(
|
||||
Ok(Json(report))
|
||||
}
|
||||
|
||||
/// Read-only §11 tail M1 suppression report for a group: the inherited templates
|
||||
/// it declines for its whole subtree (`target_kind`, `reference`). Viewer-tier
|
||||
/// `GroupScriptsRead`. Backs `pic suppress ls --group`.
|
||||
async fn group_suppressions_handler(
|
||||
State(svc): State<ApplyService>,
|
||||
Extension(principal): Extension<Principal>,
|
||||
Path(id_or_slug): Path<String>,
|
||||
) -> Result<Json<Vec<SuppressionInfo>>, ApplyError> {
|
||||
let group_id = resolve_group_id(svc.groups.as_ref(), &id_or_slug).await?;
|
||||
require(
|
||||
svc.authz.as_ref(),
|
||||
&principal,
|
||||
Capability::GroupScriptsRead(group_id),
|
||||
)
|
||||
.await
|
||||
.map_err(map_authz)?;
|
||||
let report = svc.suppression_report(ApplyOwner::Group(group_id)).await?;
|
||||
Ok(Json(report))
|
||||
}
|
||||
|
||||
/// Read-only §11 tail route-template report for a group: its own declared route
|
||||
/// templates (method, host, path, handler script, dispatch, enabled). Viewer-
|
||||
/// tier read. Backs `pic routes ls --group`.
|
||||
|
||||
@@ -1293,16 +1293,17 @@ impl ApplyService {
|
||||
// A group endpoint is reached by *inheritance* (a descendant app binds
|
||||
// it by name), never by its own route, so the "no route/trigger"
|
||||
// warning is noise for every group script — emit it for apps only.
|
||||
if let ApplyOwner::App(app_id) = owner {
|
||||
if let ApplyOwner::App(_) = owner {
|
||||
report
|
||||
.warnings
|
||||
.extend(unreachable_endpoint_warnings(bundle));
|
||||
// §11 tail: a suppress reference that matches no inherited template
|
||||
// silently does nothing — warn (typo guard), don't fail.
|
||||
report
|
||||
.warnings
|
||||
.extend(self.dangling_suppress_warnings(app_id, bundle).await?);
|
||||
}
|
||||
// §11 tail: a suppress reference that matches no inherited template (or
|
||||
// only sealed ones) silently does nothing — warn (typo guard), don't
|
||||
// fail. M1: runs for a group node too (it walks the group's own chain).
|
||||
report
|
||||
.warnings
|
||||
.extend(self.dangling_suppress_warnings(owner, bundle).await?);
|
||||
|
||||
self.reconcile_node_tx(
|
||||
&mut tx,
|
||||
@@ -2151,39 +2152,52 @@ impl ApplyService {
|
||||
/// refs match an ancestor-group route's path.
|
||||
async fn dangling_suppress_warnings(
|
||||
&self,
|
||||
app_id: AppId,
|
||||
owner: ApplyOwner,
|
||||
bundle: &Bundle,
|
||||
) -> Result<Vec<String>, ApplyError> {
|
||||
if bundle.suppress_triggers.is_empty() && bundle.suppress_routes.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
// Inherited (ancestor-group) trigger handler names + route paths, each
|
||||
// tagged with whether ANY matching template is un-sealed (i.e. actually
|
||||
// suppressible). `bool_or(NOT sealed)` = true iff at least one match can
|
||||
// be declined; false = every match is `sealed` (§11 tail), so the
|
||||
// suppression is inert; absent = no inherited template at all (a typo).
|
||||
// §11 tail M1: the set of templates a suppression can decline lives on
|
||||
// the OWNER's chain — an app walks its ancestor groups (`CHAIN_LEVELS_CTE`
|
||||
// bound to the app), a group walks itself + its ancestors
|
||||
// (`GROUP_CHAIN_LEVELS_CTE` bound to the group). Both CTEs expose a
|
||||
// `chain` view with a `group_owner` column, so the queries below are
|
||||
// identical modulo which CTE + bind.
|
||||
let (chain_cte, owner_uuid) = match owner {
|
||||
ApplyOwner::App(a) => (CHAIN_LEVELS_CTE, a.into_inner()),
|
||||
ApplyOwner::Group(g) => (
|
||||
crate::config_resolver::GROUP_CHAIN_LEVELS_CTE,
|
||||
g.into_inner(),
|
||||
),
|
||||
};
|
||||
// Inherited trigger handler names + route paths, each tagged with whether
|
||||
// ANY matching template is un-sealed (i.e. actually suppressible).
|
||||
// `bool_or(NOT sealed)` = true iff at least one match can be declined;
|
||||
// false = every match is `sealed` (§11 tail), so the suppression is
|
||||
// inert; absent = no inherited template at all (a typo).
|
||||
let trig_names: Vec<(String, bool)> = sqlx::query_as(&format!(
|
||||
"{CHAIN_LEVELS_CTE} \
|
||||
"{chain_cte} \
|
||||
SELECT LOWER(s.name), bool_or(NOT t.sealed) FROM triggers t \
|
||||
JOIN scripts s ON s.id = t.script_id \
|
||||
JOIN chain c ON t.group_id = c.group_owner \
|
||||
WHERE t.group_id IS NOT NULL \
|
||||
GROUP BY LOWER(s.name)",
|
||||
))
|
||||
.bind(app_id.into_inner())
|
||||
.bind(owner_uuid)
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
.map_err(|e| ApplyError::Backend(e.to_string()))?;
|
||||
let inherited_handlers: HashMap<String, bool> = trig_names.into_iter().collect();
|
||||
|
||||
let route_paths: Vec<(String, bool)> = sqlx::query_as(&format!(
|
||||
"{CHAIN_LEVELS_CTE} \
|
||||
"{chain_cte} \
|
||||
SELECT r.path, bool_or(NOT r.sealed) FROM routes r \
|
||||
JOIN chain c ON r.group_id = c.group_owner \
|
||||
WHERE r.group_id IS NOT NULL \
|
||||
GROUP BY r.path",
|
||||
))
|
||||
.bind(app_id.into_inner())
|
||||
.bind(owner_uuid)
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
.map_err(|e| ApplyError::Backend(e.to_string()))?;
|
||||
|
||||
Reference in New Issue
Block a user