mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
refactor(permission-system): simplify policy and autoreview flow
This commit is contained in:
@@ -48,7 +48,7 @@ function makeCtx(overrides: Partial<ExtensionContext> = {}): ExtensionContext {
|
||||
} as unknown as ExtensionContext;
|
||||
}
|
||||
|
||||
/** Details whose gate-computed surface drives the delegation envelope. */
|
||||
/** Details carrying the gate-computed surface supplied to authorizers. */
|
||||
function makeDetailsOn(surface: string): PromptPermissionDetails {
|
||||
return makeDetails({
|
||||
accessIntent: { surface, matchValues: ["/v"], boundaryValue: null },
|
||||
@@ -340,29 +340,8 @@ describe("AuthorizerSelection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("caps a link's allow on an excluded surface, falling through to the terminal", async () => {
|
||||
const registry = new AuthorizerRegistry();
|
||||
register(registry, "judge", { kind: "allow" });
|
||||
const selection = new AuthorizerSelection(
|
||||
makeDeps({
|
||||
prompter: makeInvokingPrompter(),
|
||||
authorizerRegistry: registry,
|
||||
getAuthorizerChain: () => ["judge"],
|
||||
}),
|
||||
);
|
||||
// No UI, not a subagent → the terminal is DenyingAuthorizer.
|
||||
selection.activate(makeCtx({ hasUI: false }));
|
||||
|
||||
const decision = await selection.escalate(
|
||||
makeDetailsOn("external_directory"),
|
||||
);
|
||||
|
||||
// The envelope downgraded the link's allow to defer, so the terminal
|
||||
// (denying) owns the decision — the allow did not leak through.
|
||||
expect(decision.approved).toBe(false);
|
||||
});
|
||||
|
||||
it("lets a link's allow through on a non-excluded surface", async () => {
|
||||
it("lets a configured authorizer approve the path surface", async () => {
|
||||
const registry = new AuthorizerRegistry();
|
||||
register(registry, "judge", { kind: "allow" });
|
||||
const selection = new AuthorizerSelection(
|
||||
@@ -374,10 +353,10 @@ describe("AuthorizerSelection", () => {
|
||||
);
|
||||
selection.activate(makeCtx({ hasUI: false }));
|
||||
|
||||
const decision = await selection.escalate(makeDetailsOn("bash"));
|
||||
const decision = await selection.escalate(makeDetailsOn("path"));
|
||||
|
||||
// bash is not excluded, so the link's allow stands (a non-persistent
|
||||
// approved grant) — the denying terminal is never reached.
|
||||
// A configured authorizer's allow is final for this ask and does not
|
||||
// create a persistent session grant. The terminal is never reached.
|
||||
expect(decision).toEqual({
|
||||
approved: true,
|
||||
state: "approved",
|
||||
|
||||
Reference in New Issue
Block a user