mirror of
https://github.com/SikongJueluo/pi-extensions.git
synced 2026-10-05 11:52:55 +08:00
refactor(ai-judge): group src modules into domain directories
- move evidence.ts and conversation.ts into evidence/ as bash.ts and conversation.ts - move prompt.ts and model.ts into judge/ - move highrisk.ts and judge.ts into authority/, renaming judge.ts to enforce.ts to avoid clashing with the judge/ directory - move review.ts and audit.ts into telemetry/ - move config.ts and catalog.ts into config/ as judge.ts and catalog.ts - rewrite static and dynamic imports across src, tools, and tests to the new paths - fix the models-catalog.json relative URL broken by the move (caught by fallow unresolved-import) - update the PIEXTENSIO-12 module map in the ADR to the new paths - add editorconfig for 4-space ts indentation
This commit is contained in:
@@ -2,7 +2,7 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { createAuditLog } from "../src/audit";
|
||||
import { createAuditLog } from "../src/telemetry/audit";
|
||||
|
||||
const dirs: string[] = [];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
classifyModel,
|
||||
loadModelCatalog,
|
||||
type CatalogDeps,
|
||||
} from "../src/catalog";
|
||||
} from "../src/config/catalog";
|
||||
|
||||
/**
|
||||
* PIEXTENSIO-24: the advisory model catalog shipped with the package.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { loadJudgeConfig, type ConfigLoadDeps } from "../src/config";
|
||||
import { loadJudgeConfig, type ConfigLoadDeps } from "../src/config/judge";
|
||||
|
||||
function deps(files: Record<string, string> = {}): ConfigLoadDeps {
|
||||
return {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildConversationEvidence,
|
||||
type ConversationProbe,
|
||||
} from "../src/conversation";
|
||||
} from "../src/evidence/conversation";
|
||||
|
||||
function entry(text: string): unknown {
|
||||
return {
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
DEFAULT_TIMEOUT_MS,
|
||||
MIN_TIMEOUT_MS,
|
||||
MAX_TIMEOUT_MS,
|
||||
} from "../src/model";
|
||||
import { createModelAvailability } from "../src/model";
|
||||
} from "../src/judge/model";
|
||||
import { createModelAvailability } from "../src/judge/model";
|
||||
import {
|
||||
applyTimeoutOption,
|
||||
replayCorpus,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { PromptPermissionDetails } from "@gotgenes/pi-permission-system";
|
||||
import { buildBashJudgmentEvidence } from "../src/evidence";
|
||||
import { buildBashJudgmentEvidence } from "../src/evidence/bash";
|
||||
|
||||
function details(
|
||||
unit: string,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { classifyHighRisk } from "../src/highrisk";
|
||||
import { classifyHighRisk } from "../src/authority/highrisk";
|
||||
|
||||
describe("classifyHighRisk — data_loss", () => {
|
||||
it.each([
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
evaluateEnforceAuthority,
|
||||
type EnforceGateState,
|
||||
} from "../src/judge";
|
||||
} from "../src/authority/enforce";
|
||||
|
||||
const ALL_OPEN: EnforceGateState = {
|
||||
auditHealthy: true,
|
||||
|
||||
@@ -41,8 +41,8 @@ const { mockCatalog } = vi.hoisted(() => ({
|
||||
diagnostics: [] as Array<Record<string, unknown>>,
|
||||
},
|
||||
}));
|
||||
vi.mock("../src/catalog", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../src/catalog")>();
|
||||
vi.mock("../src/config/catalog", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../src/config/catalog")>();
|
||||
return {
|
||||
...actual,
|
||||
loadModelCatalog: () => ({
|
||||
@@ -69,8 +69,8 @@ import {
|
||||
unpublishPermissionsService,
|
||||
} from "@gotgenes/pi-permission-system";
|
||||
import extension from "../src/index";
|
||||
import type { ModelCatalogEntry } from "../src/catalog";
|
||||
import { PROMPT_VERSION, TOOL_SCHEMA_VERSION } from "../src/prompt";
|
||||
import type { ModelCatalogEntry } from "../src/config/catalog";
|
||||
import { PROMPT_VERSION, TOOL_SCHEMA_VERSION } from "../src/judge/prompt";
|
||||
|
||||
function createFakePi(): {
|
||||
pi: ExtensionAPI;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
createModelAvailability,
|
||||
requestStructuredVerdict,
|
||||
type ModelAvailability,
|
||||
} from "../src/model";
|
||||
} from "../src/judge/model";
|
||||
|
||||
const metadata = {
|
||||
provider: "test-provider",
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
MAX_REASON_CODE_POINTS,
|
||||
PROMPT_VERSION,
|
||||
REPORT_VERDICT_TOOL_NAME,
|
||||
} from "../src/prompt";
|
||||
} from "../src/judge/prompt";
|
||||
import type { Context } from "@earendil-works/pi-ai";
|
||||
|
||||
describe("buildJudgeContext", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createReviewSink, type ReviewSinkDeps } from "../src/review";
|
||||
import { createReviewSink, type ReviewSinkDeps } from "../src/telemetry/review";
|
||||
import type { AuthorizerLog } from "@gotgenes/pi-permission-system";
|
||||
|
||||
function fakeLog(): AuthorizerLog & {
|
||||
|
||||
Reference in New Issue
Block a user