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:
@@ -76,8 +76,6 @@ function makePolicyPathProvider(
|
||||
(): ResolvedPolicyPaths => ({
|
||||
globalConfigPath: "/agent/config.json",
|
||||
globalConfigExists: false,
|
||||
projectConfigPath: null,
|
||||
projectConfigExists: false,
|
||||
agentsDir: "/agent/agents",
|
||||
agentsDirExists: false,
|
||||
projectAgentsDir: null,
|
||||
@@ -161,25 +159,23 @@ describe("ConfigStore", () => {
|
||||
// ── refresh() ─────────────────────────────────────────────────────────
|
||||
|
||||
describe("refresh()", () => {
|
||||
it("uses the passed ctx cwd for loadAndMergeConfigs and includes the project scope when trusted", () => {
|
||||
it("uses the passed ctx cwd for global-only config loading", () => {
|
||||
const { store } = makeStore();
|
||||
store.refresh(makeCtx({ cwd: "/my/project" }), true);
|
||||
expect(mockLoadAndMergeConfigs).toHaveBeenCalledWith(
|
||||
"/test/agent",
|
||||
"/my/project",
|
||||
expect.any(String),
|
||||
{ includeProjectScope: true },
|
||||
);
|
||||
});
|
||||
|
||||
it("withholds the project scope when the project is untrusted", () => {
|
||||
it("does not add a project config scope when the project is untrusted", () => {
|
||||
const { store } = makeStore();
|
||||
store.refresh(makeCtx({ cwd: "/my/project" }), false);
|
||||
expect(mockLoadAndMergeConfigs).toHaveBeenCalledWith(
|
||||
"/test/agent",
|
||||
"/my/project",
|
||||
expect.any(String),
|
||||
{ includeProjectScope: false },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -190,7 +186,6 @@ describe("ConfigStore", () => {
|
||||
"/test/agent",
|
||||
"",
|
||||
expect.any(String),
|
||||
{ includeProjectScope: true },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -307,17 +302,6 @@ describe("ConfigStore", () => {
|
||||
expect(mockSyncPermissionSystemStatus).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("carries piInfrastructureReadPaths from merged config into current()", () => {
|
||||
const { store } = makeStore();
|
||||
mockLoadAndMergeConfigs.mockReturnValue({
|
||||
merged: { piInfrastructureReadPaths: ["/extra/path"] },
|
||||
issues: [],
|
||||
});
|
||||
store.refresh(undefined, true);
|
||||
expect(store.current().piInfrastructureReadPaths).toEqual([
|
||||
"/extra/path",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
// ── save() ─────────────────────────────────────────────────────────────
|
||||
@@ -459,13 +443,12 @@ describe("ConfigStore", () => {
|
||||
expect(mockBuildResolvedConfigLogEntry).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
legacyGlobalPolicyDetected: expect.any(Boolean),
|
||||
legacyProjectPolicyDetected: expect.any(Boolean),
|
||||
legacyExtensionConfigDetected: expect.any(Boolean),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not check project legacy path when no cwd is provided", () => {
|
||||
it("checks only supported global legacy paths", () => {
|
||||
const { store } = makeStore();
|
||||
store.logResolvedPaths(); // no cwd
|
||||
// existsSync called for global and ext-config legacy paths only (not project)
|
||||
|
||||
Reference in New Issue
Block a user