access_not_revoked_since_grant
The “open session” idiom: a negated left operand on since expresses “has
not happened since.” Because ! binds tighter than since, !A since within W B negates only A, giving “no A has happened since B.” Here: permit an
Access only if a completed grant has been observed for this user and resource
within the last hour, with no completed revocation observed since
(!Revoke::response since within 1h Grant::response, with both input.user
and input.resource pinned).
The trace shows a delayed revocation notice, with timestamps in seconds since midnight. Access is revoked at 10:00, but the notice arrives at 10:02:
@35940(09:59) —Grant::responsereports a completed grant fordoc1/alice(history-only; no verdict).@36060(10:01) —alicerequests access todoc1, with no revocation observed since the grant → allow.@36120(10:02) —Revoke::responsereports the completed revocation fordoc1/alice(history-only; no verdict); the notice was delayed.@36180(10:03) —alicerequests access todoc1again, but a revocation has now been observed since the grant → deny.
Had the revocation notice arrived before the 10:01 request, that request would have been denied. Increasing timestamps cannot compensate for missing history, and the late notice does not revise the earlier verdict.
Referenced by guide/04-temporal-expressions.md.
Policy
// The "open session" idiom: a negated LEFT operand expresses "has not happened
// since". Because `!` binds tighter than `since`, `!A since within W B`
// negates only A. Permit Access only if a completed grant was observed for
// this user and resource within the last hour, with no completed revocation
// observed since.
@id("access_not_revoked_since_grant")
permit (
principal,
action == Drupe::Action::"Access",
resource
)
when temporal {
!Drupe::Action::"Revoke"::response{ input.user: context.input.user, input.resource: context.input.resource }
since within 1h
Drupe::Action::"Grant"::response{ input.user: context.input.user, input.resource: context.input.resource }
};
Schema
namespace Drupe {
type AccessInput = {
resource: String,
user: String
};
type AccessOutput = { };
type ContentFilterFinding = {
severityScore: decimal
};
type GrantInput = {
resource: String,
user: String
};
type GrantOutput = { };
type PromptAttackFinding = {
severityScore: decimal
};
type RevokeInput = {
resource: String,
user: String
};
type RevokeOutput = { };
type SensitiveInfoFinding = {
confidenceScore: decimal
};
type SystemContext = {
now: datetime
};
entity Gateway;
entity IamEntity = {
id: String
};
entity OAuthUser = {
id: String
} tags String;
entity UnauthenticatedUser;
action "Access" in [Action::"CallTool"] appliesTo {
principal: [IamEntity, OAuthUser, UnauthenticatedUser],
resource: [Gateway],
context: {
input: AccessInput,
output?: AccessOutput,
system: SystemContext
}
};
action "CallTool" in [Action::"Mcp"] appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
action "Grant" in [Action::"CallTool"] appliesTo {
principal: [IamEntity, OAuthUser, UnauthenticatedUser],
resource: [Gateway],
context: {
input: GrantInput,
output?: GrantOutput,
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 "Mcp" appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
action "Revoke" in [Action::"CallTool"] appliesTo {
principal: [IamEntity, OAuthUser, UnauthenticatedUser],
resource: [Gateway],
context: {
input: RevokeInput,
output?: RevokeOutput,
system: SystemContext
}
};
action "UnknownTool" in [Action::"CallTool"] appliesTo {
principal: [OAuthUser, IamEntity, UnauthenticatedUser],
resource: [Gateway],
context: {
system: SystemContext
}
};
}
Trace
@35940 scope(principal: Drupe::OAuthUser::"alice", resource: Drupe::Gateway::"gw1") request_context(input: { resource: "doc1", user: "alice" }) Drupe::Action::"Grant"::response(input: { resource: "doc1", user: "alice" }, callerPrincipal: Drupe::OAuthUser::"alice", callerResource: Drupe::Gateway::"gw1", requestId: "u1")
@36060 scope(principal: Drupe::OAuthUser::"alice", resource: Drupe::Gateway::"gw1") request_context(input: { resource: "doc1", user: "alice" }, system: { now: datetime("1970-01-01T10:01:00Z") }) Drupe::Action::"Access"::request(input: { resource: "doc1", user: "alice" }, callerPrincipal: Drupe::OAuthUser::"alice", callerResource: Drupe::Gateway::"gw1", requestId: "u2")
@36120 scope(principal: Drupe::OAuthUser::"alice", resource: Drupe::Gateway::"gw1") request_context(input: { resource: "doc1", user: "alice" }) Drupe::Action::"Revoke"::response(input: { resource: "doc1", user: "alice" }, callerPrincipal: Drupe::OAuthUser::"alice", callerResource: Drupe::Gateway::"gw1", requestId: "u3")
@36180 scope(principal: Drupe::OAuthUser::"alice", resource: Drupe::Gateway::"gw1") request_context(input: { resource: "doc1", user: "alice" }, system: { now: datetime("1970-01-01T10:03:00Z") }) Drupe::Action::"Access"::request(input: { resource: "doc1", user: "alice" }, callerPrincipal: Drupe::OAuthUser::"alice", callerResource: Drupe::Gateway::"gw1", requestId: "u4")
Expected Output
@36060 (time point 0): ALLOW [rules: 0]
@36180 (time point 1): DENY