alert_login_current_tp
The canonical tp(t) count-over-timepoints idiom with no temporal wrapper
on the aggregation body. The count for (t: Timepoint) ranges over distinct
timepoints, and because there is no formerly/since/previous wrapper on the
Login::request predicate, the count sees only same-timepoint events. The
policy permits an Alert iff at least one Login to this same server
(input.server: context.input.server) occurred at the current timepoint.
No trace is authored for this example (validate-only).
Referenced by guide/04-temporal-expressions.md.
Policy
// The `tp(t)` binder binds `t` to each visited timepoint, letting the
// aggregation range over distinct timepoints. With NO temporal wrapper on the
// body, the count sees only same-timepoint events. Permit an Alert if at least
// one Login to this server occurred at the current timepoint.
@id("alert_login_current_tp")
permit (
principal,
action == Drupe::Action::"Alert",
resource
)
when temporal {
exists (n: Long). (
(count for (t: Timepoint). where (
Drupe::Action::"Login"::request{ input.user: _, input.server: context.input.server } && tp(t)
)) == n && n > 0
)
};
Schema
namespace Drupe {
type AlertInput = {
level: Long,
server: String
};
type AlertOutput = { };
type ContentFilterFinding = {
severityScore: decimal
};
type LoginInput = {
server: String,
user: String
};
type LoginOutput = { };
type PromptAttackFinding = {
severityScore: decimal
};
type SensitiveInfoFinding = {
confidenceScore: decimal
};
type SystemContext = {
now: datetime
};
entity Gateway;
entity IamEntity = {
id: String
};
entity OAuthUser = {
id: String
} tags String;
entity UnauthenticatedUser;
action "Alert" in [Action::"CallTool"] appliesTo {
principal: [IamEntity, OAuthUser, UnauthenticatedUser],
resource: [Gateway],
context: {
input: AlertInput,
output?: AlertOutput,
system: SystemContext
}
};
action "CallTool" in [Action::"Mcp"] appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
action "Http" appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
action "InvokeAgent" in [Action::"Http"] appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
input?: { },
system: SystemContext
}
};
action "InvokeLLM" in [Action::"Http"] appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
input?: { },
system: SystemContext
}
};
action "Login" in [Action::"CallTool"] appliesTo {
principal: [IamEntity, OAuthUser, UnauthenticatedUser],
resource: [Gateway],
context: {
input: LoginInput,
output?: LoginOutput,
system: SystemContext
}
};
action "Mcp" appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
action "UnknownTool" in [Action::"CallTool"] appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
}