read_prev_compute_open_session
A top-level previous && (open-session since) chain: permit a Read only if the
same user computed at the immediately preceding timepoint (previous within 1h ... Compute, user pinned via input.user: context.input.user) AND
that user has an open session — no Logout since their Login within 24h
(!Logout since within 24h Login).
The since-clause is parenthesized so that && (the loosest-binding operator)
groups the two conjuncts, rather than the since swallowing the previous
conjunct. This demonstrates combining previous with a negated-left since in
one top-level temporal chain.
Referenced by guide/04-temporal-expressions.md.
Policy
// A top-level `previous && (open-session)` chain. Permit a Read only if the
// same user computed at the immediately preceding timepoint AND has an open
// session -- no Logout since their Login within 24h. The since-clause is
// parenthesized so && (loosest) groups the two conjuncts, not the since.
@id("read_prev_compute_open_session")
permit (
principal,
action == Drupe::Action::"Read",
resource
)
when temporal {
previous within 1h Drupe::Action::"Compute"::request{ input.user: context.input.user }
&& (!Drupe::Action::"Logout"::request{ input.user: context.input.user }
since within 24h
Drupe::Action::"Login"::request{ input.user: context.input.user })
};
Schema
namespace Drupe {
type ComputeInput = {
user: String
};
type ComputeOutput = { };
type ContentFilterFinding = {
severityScore: decimal
};
type LoginInput = {
server: String,
user: String
};
type LoginOutput = { };
type LogoutInput = {
user: String
};
type LogoutOutput = { };
type PromptAttackFinding = {
severityScore: decimal
};
type ReadInput = {
document: String,
user: String
};
type ReadOutput = { };
type SensitiveInfoFinding = {
confidenceScore: decimal
};
type SystemContext = {
now: datetime
};
entity Gateway;
entity IamEntity = {
id: String
};
entity OAuthUser = {
id: String
} tags String;
entity UnauthenticatedUser;
action "CallTool" in [Action::"Mcp"] appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
action "Compute" in [Action::"CallTool"] appliesTo {
principal: [IamEntity, OAuthUser, UnauthenticatedUser],
resource: [Gateway],
context: {
input: ComputeInput,
output?: ComputeOutput,
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 "Logout" in [Action::"CallTool"] appliesTo {
principal: [IamEntity, OAuthUser, UnauthenticatedUser],
resource: [Gateway],
context: {
input: LogoutInput,
output?: LogoutOutput,
system: SystemContext
}
};
action "Mcp" appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
action "Read" in [Action::"CallTool"] appliesTo {
principal: [IamEntity, OAuthUser, UnauthenticatedUser],
resource: [Gateway],
context: {
input: ReadInput,
output?: ReadOutput,
system: SystemContext
}
};
action "UnknownTool" in [Action::"CallTool"] appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
}