Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
00c2c14
feat: DAG-based post-processing + taxonomy handler
cedricvidal Jun 9, 2026
e9bf6ad
feat: add taxonomy API route and archive bundling (Phase 3)
cedricvidal Jun 9, 2026
2273286
fix: taxonomy handler Dockerfile and docker-compose dev setup
cedricvidal Jun 9, 2026
4507fb8
feat: add taxonomy tab to portal run detail view
cedricvidal Jun 9, 2026
3756ccc
refactor: move handler registration from migration to worker registra…
cedricvidal Jun 9, 2026
d02ec68
refactor: YAML-driven handler registration via scheduler endpoint
cedricvidal Jun 9, 2026
02900bd
feat: scheduler triggers report generation when handler DAG drains
cedricvidal Jun 9, 2026
c6cd9b2
feat(taxonomy): add dev CLI, API-based ATIF fetch, and default to gpt…
cedricvidal Jun 10, 2026
07127ae
chore: remove taxonomy changes (split to #1053)
cedricvidal Jun 24, 2026
ca11ff0
Merge remote-tracking branch 'origin/main' into cedricvidal-microsoft…
cedricvidal Jun 24, 2026
d1ea709
merge: bring in origin/main
cedricvidal Jun 25, 2026
e87bb85
Merge remote-tracking branch 'origin/main' into cedricvidal-microsoft…
cedricvidal Jun 26, 2026
8901933
Merge remote-tracking branch 'origin/main' into cedricvidal-microsoft…
cedricvidal Jun 29, 2026
1fb829c
feat(observations): observation criteria + pp-taxonomy handler, CLI, …
cedricvidal Jun 29, 2026
19b0299
feat(portal): observation criteria kind/taxonomy UI, submit picker, o…
cedricvidal Jun 29, 2026
78899c2
test(judge): live ATIF-trajectory observation acceptance (issue #1156)
cedricvidal Jun 29, 2026
c0a2093
fix(post-processor): copy handler.taxonomy.yaml into image so pp-taxo…
cedricvidal Jun 29, 2026
d5f866b
fix(compose): give post-processor JUDGE_SERVICE_URL so pp-taxonomy re…
cedricvidal Jun 29, 2026
7fde27f
docs(env): clarify post-processor JUDGE_SERVICE_URL wiring in compose…
cedricvidal Jun 29, 2026
7a639ad
fix(pp-taxonomy): read selected observations from request top-level, …
cedricvidal Jun 29, 2026
f689b01
feat(portal): rename run-detail Observations tab to Taxonomy with Obs…
cedricvidal Jun 29, 2026
85eb446
fix(portal): aggregate Enrichment badge over handler DAG + rename obs…
cedricvidal Jun 29, 2026
84f6e7b
fix(judge): unify trajectory navigation into one source-agnostic tool…
cedricvidal Jun 30, 2026
4c1785f
feat(shared): add criterion subject (run|iteration) + run-level obser…
cedricvidal Jun 30, 2026
01ec0a7
feat(api): validate criterion subject + AI auto-detect (#1156)
cedricvidal Jun 30, 2026
aa92dbe
feat(judge): merge whole-run trajectory from atifUrls[] (#1156)
cedricvidal Jun 30, 2026
4fc56b5
feat(pp-taxonomy): honor criterion subject — whole-run vs per-iterati…
cedricvidal Jun 30, 2026
1daf022
feat(portal): subject toggle + whole-run observations + steering copy…
cedricvidal Jun 30, 2026
f1b24e9
feat(cli): subject parity — --subject flag + whole-run observations (…
cedricvidal Jun 30, 2026
a7cfe9b
docs: criterion subject (run|iteration) + run-level observations (#1156)
cedricvidal Jun 30, 2026
688fbb5
fix(scheduler): allow autoBackfill to re-dispatch runs with outdated …
cedricvidal Jul 1, 2026
d3e5d78
Merge remote-tracking branch 'origin/main' into cedricvidal-microsoft…
cedricvidal Jul 1, 2026
7288b65
fix(scheduler): ignore stale handler completion notifications
cedricvidal Jul 1, 2026
5c64dea
fix(post-processing): enforce worker-entrypoint idempotency
cedricvidal Jul 1, 2026
fe5b9ee
docs(post-processing): clarify enqueue and claim boundaries
cedricvidal Jul 1, 2026
87df1b0
perf(scheduler): cache handler topology with short TTL
cedricvidal Jul 1, 2026
a56c0be
perf(scheduler): raise handler topology cache TTL to 5min, make it en…
cedricvidal Jul 1, 2026
b55299c
docs: call out single-replica limitation of the handler topology cache
cedricvidal Jul 1, 2026
ab696a2
feat(scheduler): cap notify/register request body size (64 KB)
cedricvidal Jul 1, 2026
726e0cd
fix(post-processing): let worker claim scheduler-queued runs
cedricvidal Jul 1, 2026
8b86d2d
Merge remote-tracking branch 'origin/main' into cedricvidal-microsoft…
cedricvidal Jul 8, 2026
0531a0a
chore(db-migrations): renumber handler-DAG migrations to 025-027
cedricvidal Jul 10, 2026
90dfca4
Merge origin/main into cedricvidal-microsoft/pp-dag-orchestration
cedricvidal Oct 11, 2026
17e8c50
feat(portal): add Copilot SDK AI backend
cedricvidal Oct 11, 2026
15f5c8d
docs: clarify Copilot SDK production tradeoffs
cedricvidal Oct 11, 2026
8f30583
fix(api): harden Copilot pool startup
cedricvidal Oct 11, 2026
4b28413
fix(api): bound Copilot force-stop cleanup
cedricvidal Oct 11, 2026
2ca370b
Merge remote-tracking branch 'origin/feat/portal-copilot-ai' into ced…
cedricvidal Oct 12, 2026
a9e9dbd
merge: restack #1206 onto #1147
cedricvidal Oct 12, 2026
edf89b6
test: align observation contracts
cedricvidal Oct 21, 2026
7359efb
fix(cli): keep taxonomy import bundle-safe
cedricvidal Oct 21, 2026
08cc74d
docs(cli): name bundle-safe taxonomy subpath
cedricvidal Oct 21, 2026
d912225
fix(portal): restore criteria badge import
cedricvidal Oct 21, 2026
a6ab495
Merge main into feat/portal-copilot-ai for migration synchronization
cedricvidal Oct 21, 2026
6375653
Merge feat/portal-copilot-ai into pp-dag-orchestration
cedricvidal Oct 21, 2026
92a9a24
merge: forward #1147 into #1206
cedricvidal Oct 21, 2026
2afb5cf
docs: share agent code readability instructions
cedricvidal Oct 21, 2026
bc06e8a
Merge shared agent guidance into feat/portal-copilot-ai
cedricvidal Oct 21, 2026
21ad65b
Merge shared agent guidance into pp-dag-orchestration
cedricvidal Oct 21, 2026
bd4bf1a
merge: prepare shared agent guidance for #1206
cedricvidal Oct 21, 2026
fd11640
Merge main ancestry after shared agent guidance squash merge
cedricvidal Oct 22, 2026
2ef7ea8
feat(taxonome): extract standalone foundation below consumers
cedricvidal Oct 28, 2026
2daf9af
merge: synchronize Taxonome foundation into #1206
cedricvidal Oct 28, 2026
6e0dac7
fix(website): add missing license headers
cedricvidal Nov 4, 2026
3a702c0
Merge fd11640052e10203b7e33e24be10741a43f86afa into 05d9435005711a96c…
cedricvidal Nov 4, 2026
ac8c6d2
merge: sync portal copilot AI base
cedricvidal Nov 4, 2026
fd40d39
chore: refresh PR mergeability
cedricvidal Nov 4, 2026
4f736ff
merge: propagate parent stack merge
cedricvidal Nov 4, 2026
4c7433d
Merge main into feat/portal-copilot-ai to refresh stacked checks
cedricvidal Nov 5, 2026
954af63
Merge 4c7433df5631f7f94a44bcb567a400088da1f8a8 into 16dd16f51e8a71751…
cedricvidal Nov 5, 2026
e499844
merge: refresh stacked parent checks
cedricvidal Nov 5, 2026
07a0eae
Merge refreshed post-processing DAG parent into Taxonome foundation
cedricvidal Nov 5, 2026
8991105
merge: refresh observation taxonomy stack
cedricvidal Nov 5, 2026
cbca7d0
docs(taxonome): publish workflow guide and canonical catalog references
cedricvidal Nov 5, 2026
2be01e4
Merge main into portal Copilot AI
cedricvidal Nov 5, 2026
7e12048
Merge refreshed portal Copilot AI into handler DAG
cedricvidal Nov 5, 2026
07932f8
Merge refreshed handler DAG into Taxonome foundation
cedricvidal Nov 5, 2026
8ff02e3
Merge refreshed Taxonome foundation into observations
cedricvidal Nov 5, 2026
1e9ab41
Merge main and regenerate the Portal API lockfile from the public reg…
cedricvidal Dec 1, 2026
70e333c
fix(post-processor): guard taxonomy reads and results by run attempt …
cedricvidal Dec 1, 2026
b99d1ca
Do not retry exhausted Copilot acquisition or idle deadlines
cedricvidal Dec 1, 2026
47ca510
Keep standalone targets out of quality generation and resolve workspa…
cedricvidal Dec 1, 2026
3c922ed
Recover handler leases and fence artifact and terminal writes by acqu…
cedricvidal Dec 1, 2026
2f32c63
D15: Resolve leading-slash judge paths within the snapshot
cedricvidal Dec 1, 2026
130ae3b
D18: Record stable identities of applied observation backfills
cedricvidal Dec 1, 2026
2a2836b
D14: Track judge symlink containment as separate hardening
cedricvidal Dec 1, 2026
fd42da1
D10: Preserve criterion semantics in Portal YAML exports
cedricvidal Dec 1, 2026
e3b6a20
D12: Treat undispatched taxonomy blocked by failed ATIF as terminal
cedricvidal Dec 1, 2026
523a44c
fix(post-processor): isolate iteration observation evidence (#1206 D6)
cedricvidal Dec 1, 2026
2326a07
Treat completion as a wake-up for the exact persisted terminal claim
cedricvidal Dec 1, 2026
a1485f3
D3: Verify observation-specific API errors using the scoped test server
cedricvidal Dec 1, 2026
0dcd985
Bound session creation and the full send with one response deadline
cedricvidal Dec 1, 2026
d46b534
Lease report intent delivery and acknowledge only the matching attemp…
cedricvidal Dec 1, 2026
a396b10
Anchor Taxonome reference excerpts to complete TypeScript declarations
cedricvidal Dec 1, 2026
318ccce
Evict failed Copilot credentials without replaying on another provider
cedricvidal Dec 1, 2026
84bdc25
Move Taxonome schema consumers to patched Zod 4.6.6
cedricvidal Dec 1, 2026
6d92d61
Document model entitlement limits and explicit override for Taxonome
cedricvidal Dec 1, 2026
27c3ec0
Rotate bounded report scans by indexed request ID and wrap at a fixed…
cedricvidal Dec 1, 2026
15bc6cb
fix(judge): skip developer feedback for record-only observations (#12…
cedricvidal Dec 1, 2026
f29be9e
fix(api): retain observations across request fan-out and resubmission…
cedricvidal Dec 1, 2026
340b08d
Use packaged handler metadata for both registration and execution
cedricvidal Dec 1, 2026
09e9232
Validate Portal Copilot model overrides against the client catalog
cedricvidal Dec 1, 2026
77e12c5
D12: Exercise the failed enrichment badge and actual run poller
cedricvidal Dec 1, 2026
b7a32dc
Describe criteria generation through the configured Portal AI provider
cedricvidal Dec 1, 2026
564b37a
Gate automatic reports on a durable first-deploy epoch and a register…
cedricvidal Dec 1, 2026
b3eeb16
Preserve the parent tar-stream production resolution
cedricvidal Dec 1, 2026
c1c992c
Isolate handler queue failures and authenticate completion callbacks
cedricvidal Dec 1, 2026
12a6cb8
Cover criterion subject suggestions in the authoring contract and off…
cedricvidal Dec 1, 2026
23e35bf
Make the explicit seven-session Portal AI smoke fail closed
cedricvidal Dec 1, 2026
a118e0e
Restore the legacy v1 service only on rollback and retire its dispatc…
cedricvidal Dec 1, 2026
1e79d6f
fix(criteria): preserve observation metadata through scoped imports (…
cedricvidal Dec 1, 2026
e0167a9
fix(criteria): enforce reverse kind compatibility before updates (#12…
cedricvidal Dec 1, 2026
f3f23d4
Escape untrusted fields before rendering CLI text and progress
cedricvidal Dec 1, 2026
07f7eab
Authenticate scheduler control requests and validate handler registra…
cedricvidal Dec 1, 2026
de5b011
fix(api): validate implicit Select gates on every submission (D8)
cedricvidal Dec 1, 2026
2a99ded
Exercise fenced takeover, DAG continuation and crash recovery on disp…
cedricvidal Dec 1, 2026
eae5919
Bound cancellable SDK startup and session acquisition, including late…
cedricvidal Dec 1, 2026
edc0cb0
Parse scheduler origin-form targets inside the request handler (B9)
cedricvidal Dec 1, 2026
69bde88
Require deployed scheduler service URLs instead of guessing Kubernete…
cedricvidal Dec 1, 2026
7137675
Join Portal runtime retirements and retain a pending graceful exit
cedricvidal Dec 1, 2026
ad8bf45
Publish D4/D11/D13/D16 criterion API contracts in generated OpenAPI
cedricvidal Dec 1, 2026
2586770
Document handler fences, deployment cutover and the logical report de…
cedricvidal Dec 1, 2026
a381ba5
Prove queue waits do not consume the Copilot response budget
cedricvidal Dec 1, 2026
b478ac1
fix(criteria): persist explicit taxonomy clears from Portal and CLI (…
cedricvidal Dec 1, 2026
a35dce6
Persist attempt-scoped report plans and recoverable queue delivery
cedricvidal Dec 1, 2026
da4c747
fix(observations): schedule the complete DAG in its declared evidence…
cedricvidal Dec 1, 2026
9a90731
Wait for registered dependency versions before draining or dispatchin…
cedricvidal Dec 1, 2026
5e08245
Scope criterion dependency suggestions to compatible kinds and discar…
cedricvidal Dec 1, 2026
1c799ee
Fence downstream deliveries at pickup and publication; recover stale …
cedricvidal Dec 1, 2026
d77a6b6
Re-evaluate automatic report templates in the destination project on …
cedricvidal Dec 1, 2026
774bd69
Lease report generation and fence publication across duplicate queue …
cedricvidal Dec 1, 2026
38f6c2c
Validate fair scans and duplicate report consumption through real sto…
cedricvidal Dec 1, 2026
4fe65d3
Exercise a YAML-only upgrade with separately initialized worker images
cedricvidal Dec 1, 2026
a66d7df
Require confirmed report-trigger completion before acknowledging an i…
cedricvidal Dec 1, 2026
198dee6
Confirm Portal Copilot CLI exit before releasing runtime capacity
cedricvidal Dec 1, 2026
f3e376c
Merge reviewed #1482 changes into #1147
cedricvidal Dec 1, 2026
99a4b5f
Merge reviewed #1147 changes into #1595
cedricvidal Dec 1, 2026
a0bf1c9
Extract Judge Observations from the Taxonome stack layer
cedricvidal Dec 1, 2026
417372e
Merge reviewed #1595 changes into #1206
cedricvidal Dec 1, 2026
cb6a960
Decode Docker log frames before parsing ACP integration results
cedricvidal Dec 2, 2026
9f30c14
Merge current post-processing DAG parent into Taxonome foundation
cedricvidal Dec 2, 2026
c3a5240
Generate the ATIF Scope extension field reference from its input schemas
cedricvidal Dec 2, 2026
f9914c7
Carry generated ATIF schema reference through stack layer #1206
cedricvidal Dec 2, 2026
1dd6519
Route CI criteria generation and grading through GitHub Models
cedricvidal Dec 2, 2026
95a8f91
Merge deterministic OpenAPI generation from main for the stacked API …
cedricvidal Dec 2, 2026
f7d8911
Merge Portal AI parent and regenerate the DAG report-trigger OpenAPI …
cedricvidal Dec 2, 2026
da3e28b
Merge the resolved handler DAG parent into the Taxonome foundation
cedricvidal Dec 2, 2026
8c06c56
Merge Taxonome parent and regenerate the API snapshot for scoped requ…
cedricvidal Dec 2, 2026
757e969
Evaluate criteria generation and grading in separate Copilot SDK sess…
cedricvidal Dec 2, 2026
4ead6ba
Integrate reviewed parent fixes for #1147
cedricvidal Dec 2, 2026
ff9d0c1
Integrate reviewed parent fixes for #1595
cedricvidal Dec 2, 2026
4c1748d
Integrate reviewed parent fixes for #1206
cedricvidal Dec 2, 2026
8ea6c08
Merge integration/taxonomy into the criteria PR after the foundation …
cedricvidal Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions apps/api/src/__snapshots__/openapi-snapshot.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5052,13 +5052,12 @@ exports[`OpenAPI spec snapshot > matches the committed snapshot 1`] = `
"post": {
"parameters": [
{
"description": "Optional project scope. When provided, a slug/id is resolved within that project (slugs may repeat across projects); when omitted, resolution falls back to a legacy global lookup for backward compatibility.",
"description": "Scope for dependency suggestions. Without a project, only the prompt is authored.",
"in": "query",
"name": "projectId",
"required": false,
"schema": {
"description": "Optional project scope. When provided, a slug/id is resolved within that project (slugs may repeat across projects); when omitted, resolution falls back to a legacy global lookup for backward compatibility.",
"example": "00000000-0000-0000-0000-000000000000",
"description": "Scope for dependency suggestions. Without a project, only the prompt is authored.",
"minLength": 1,
"type": "string",
},
Expand All @@ -5077,6 +5076,13 @@ exports[`OpenAPI spec snapshot > matches the committed snapshot 1`] = `
},
"gates": {
"items": {
"enum": [
"select",
"build",
"test",
"run",
"deploy",
],
"type": "string",
},
"type": "array",
Expand All @@ -5091,7 +5097,7 @@ exports[`OpenAPI spec snapshot > matches the committed snapshot 1`] = `
},
},
"responses": {
"201": {
"200": {
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -5287,7 +5293,7 @@ exports[`OpenAPI spec snapshot > matches the committed snapshot 1`] = `
},
},
"responses": {
"201": {
"200": {
"content": {
"application/json": {
"schema": {
Expand All @@ -5313,7 +5319,7 @@ exports[`OpenAPI spec snapshot > matches the committed snapshot 1`] = `
"description": "Success",
},
"400": {
"description": "Seed batch would introduce a dependency cycle",
"description": "Invalid criteria, dependency cycle, or incompatible gates in seed batch",
},
},
"summary": "Seed criteria in bulk",
Expand Down
58 changes: 58 additions & 0 deletions apps/api/src/endpoints.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,41 @@ describe("API Endpoints", () => {
});
});

describe("POST /api/v1/criteria/generate-prompt", () => {
it("loads candidates from the selected project and excludes the criterion being edited", async () => {
const { isLlmAvailable, generateCriteriaPrompt } = await import("./llm.js");
vi.mocked(isLlmAvailable).mockReturnValueOnce(true);
const candidate = { id: "builds", prompt: "Build succeeds", gates: ["build"] };
const project = vi.fn().mockReturnValue({ toArray: async () => [candidate] });
vi.mocked(mocks.criteriaCollection.find).mockReturnValueOnce({ project } as never);
vi.mocked(generateCriteriaPrompt).mockResolvedValueOnce({
prompt: "p", suggestedId: "new_id", suggestedParents: ["builds"], suggestedChildren: [],
});

const response = await request(testServer()).post("/api/v1/criteria/generate-prompt")
.query({ projectId: TEST_PROJECT_ID })
.send({ behavior: "Build without warnings", currentId: "edited", gates: ["build"] })
.expect(200);
expect(mocks.criteriaCollection.find).toHaveBeenCalledWith({
projectId: TEST_PROJECT_ID, deletedAt: { $exists: false }, id: { $ne: "edited" },
});
expect(project).toHaveBeenCalledWith(expect.objectContaining({ gates: 1 }));
expect(generateCriteriaPrompt).toHaveBeenCalledWith("Build without warnings", [candidate], ["build"]);
expect(response.body.suggestedParents).toEqual(["builds"]);
});

it("authors for legacy callers without querying an unscoped catalog", async () => {
const { isLlmAvailable, generateCriteriaPrompt } = await import("./llm.js");
vi.mocked(isLlmAvailable).mockReturnValueOnce(true);
vi.mocked(generateCriteriaPrompt).mockResolvedValueOnce({
prompt: "p", suggestedId: "x", suggestedParents: [], suggestedChildren: [],
});
await request(testServer()).post("/api/v1/criteria/generate-prompt").send({ behavior: "p" }).expect(200);
expect(mocks.criteriaCollection.find).not.toHaveBeenCalled();
expect(generateCriteriaPrompt).toHaveBeenCalledWith("p", [], undefined);
});
});

describe("POST /api/v1/criteria", () => {
it("returns 201 when creating a new criterion", async () => {
// findOne returns null (no duplicate)
Expand Down Expand Up @@ -1797,7 +1832,17 @@ describe("API Endpoints", () => {
// Submit with profile — server-side field resolution
// ===================================================================

/** Seed the implicit Select gate used by submit fixtures that exercise
* unrelated fields such as profile overrides, reasoning effort and lineage. */
function mockSubmittedCriterion(id: string) {
vi.mocked(mocks.criteriaCollection.find).mockReturnValue(
createMockCollection([{ projectId: TEST_PROJECT_ID, id }]).find(),
);
}

describe("POST /api/v1/requests?worker=... (profile)", () => {
beforeEach(() => mockSubmittedCriterion("works"));

const resourceRevision = {
_id: "rev-github-simulator-1",
resourceId: "res-github-simulator",
Expand Down Expand Up @@ -2068,6 +2113,8 @@ describe("API Endpoints", () => {
});

describe("POST /api/v1/requests?worker=... (reasoning effort)", () => {
beforeEach(() => mockSubmittedCriterion("works"));

it("rejects when effort is incompatible with model capabilities", async () => {
(mocks.agentCollection.findOne as any).mockResolvedValue({
_id: "coder-acp-copilot",
Expand Down Expand Up @@ -2189,6 +2236,8 @@ describe("API Endpoints", () => {
// ===================================================================

describe("POST /api/v1/requests?worker=... (AGENTS.md)", () => {
beforeEach(() => mockSubmittedCriterion("works"));

const setupCopilotAgent = () => {
(mocks.agentCollection.findOne as any).mockResolvedValue({
_id: "coder-acp-copilot",
Expand Down Expand Up @@ -2624,9 +2673,12 @@ describe("API Endpoints", () => {
// ===================================================================

describe("POST /api/v1/requests/bulk-resubmit (reasoning effort)", () => {
beforeEach(() => mockSubmittedCriterion("has_react"));

it("applies reasoning effort override in bulk resubmit", async () => {
const originalRun = {
_id: "run-original",
projectId: TEST_PROJECT_ID,
scenario: { task: "Build a form", criteria: ["has_react"] },
workerType: "coder-acp-copilot",
status: "completed",
Expand Down Expand Up @@ -2665,6 +2717,7 @@ describe("API Endpoints", () => {
it("clears reasoning effort when override is null", async () => {
const originalRun = {
_id: "run-original",
projectId: TEST_PROJECT_ID,
scenario: { task: "Build a form", criteria: ["has_react"] },
workerType: "coder-acp-copilot",
status: "completed",
Expand Down Expand Up @@ -2706,9 +2759,12 @@ describe("API Endpoints", () => {
// ===================================================================

describe("POST /api/v1/requests/bulk-resubmit", () => {
beforeEach(() => mockSubmittedCriterion("has_react"));

it("preserves agentVersion and taskPromptId from original run", async () => {
const originalRun = {
_id: "run-original",
projectId: TEST_PROJECT_ID,
scenario: { task: "Build a form", criteria: ["has_react"] },
workerType: "coder-acp-copilot",
status: "completed",
Expand Down Expand Up @@ -2757,6 +2813,7 @@ describe("API Endpoints", () => {
it("applies profile override: uses profile fields for worker, model, mcpServers, skillRevisions, extensions", async () => {
const originalRun = {
_id: "run-original",
projectId: TEST_PROJECT_ID,
scenario: { task: "Build a form", criteria: ["has_react"] },
workerType: "coder-acp-copilot",
status: "completed",
Expand Down Expand Up @@ -2839,6 +2896,7 @@ describe("API Endpoints", () => {
it("detaches profile when profileId override is null", async () => {
const originalRun = {
_id: "run-original",
projectId: TEST_PROJECT_ID,
scenario: { task: "Build a form", criteria: ["has_react"] },
workerType: "coder-acp-copilot",
status: "completed",
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/portal-ai-copilot.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ describe("Portal AI Copilot end-to-end smoke", () => {

const criterion = await request(app)
.post("/api/v1/criteria/generate-prompt")
.query({ projectId: "portal-ai-smoke" })
.send({
behavior: "The project includes meaningful automated tests.",
gates: ["select"],
Expand Down
59 changes: 57 additions & 2 deletions apps/api/src/routes/catalog-isolation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { RouteContext } from "../route-context.js";
import { registerSkillsRoutes } from "./skills.js";
import { registerExtensionsRoutes } from "./extensions.js";
import { registerPromptFeaturesRoutes } from "./prompt-features.js";
import { registerCriteriaRoutes } from "./criteria.js";
import { useTestServer } from "../test-server.js";

extendZodWithOpenApi(z);

Expand All @@ -30,6 +32,10 @@ function matches(doc: any, filter: any): boolean {
if ((cond as any).$exists === false && has) return false;
continue;
}
if (cond && typeof cond === "object" && "$in" in cond && Array.isArray(cond.$in)) {
if (!cond.$in.includes(doc[key])) return false;
continue;
}
if (doc[key] !== cond) return false;
}
return true;
Expand All @@ -44,8 +50,12 @@ function fakeCollection() {
docs.push({ ...doc });
return { insertedId: doc._id };
}),
updateOne: vi.fn(async (filter: any, update: any) => {
const doc = docs.find((d) => matches(d, filter));
updateOne: vi.fn(async (filter: any, update: any, options?: { upsert?: boolean }) => {
let doc = docs.find((d) => matches(d, filter));
if (!doc && options?.upsert) {
doc = { ...filter, ...update.$setOnInsert };
docs.push(doc);
}
if (doc) {
if (update.$set) Object.assign(doc, update.$set);
if (update.$unset) for (const k of Object.keys(update.$unset)) delete doc[k];
Expand Down Expand Up @@ -88,6 +98,51 @@ function buildCtx(
return { app, ctx };
}

describe("criteria catalog — scoped mutations", () => {
const criteriaCollection = fakeCollection();
const { app } = buildCtx(registerCriteriaRoutes, { criteriaCollection });
const server = useTestServer(app);
const base = "/api/v1/criteria";

it("preserves scoped gates and validates dependencies activated by later imports", async () => {
// Same id in the source and destination projects must not interfere.
const seed = (project: string, criteria: unknown[]) =>
request(server()).post(`${base}/seed?projectId=${project}`).send({ criteria });
const criterion = {
id: "build_clean", prompt: "Did the build complete?", gates: ["build"], dependsOn: ["baseline"],
};
await seed("source", [{ id: criterion.id, prompt: "Original gate" }]).expect(200);
// Forward references within the batch and references to future partial imports are legal.
await seed("destination", [criterion, { id: "baseline", prompt: "Baseline?", gates: ["build", "test"], dependsOn: ["future"] }])
.expect(200, { seeded: 2, errors: [] });
await seed("destination", [{ id: criterion.id, prompt: "Do not replace" }]).expect(200);

const read = (project: string, id: string) => request(server()).get(`${base}/${id}?projectId=${project}`);
expect((await read("destination", criterion.id).expect(200)).body).toMatchObject(criterion);
expect((await read("source", criterion.id).expect(200)).body.prompt).toBe("Original gate");

// Revive the stored gate, not the replacement content in the import.
await request(server()).delete(`${base}/${criterion.id}?projectId=destination`).expect(200);
await seed("destination", [{ id: criterion.id, prompt: "Still not a replacement" }]).expect(200);
expect((await read("destination", criterion.id).expect(200)).body).toMatchObject(criterion);

// A later import that resolves the previously absent parent must validate its reverse edge.
await seed("destination", [{ id: "future", prompt: "Only build", gates: ["build"] }]).expect(400);
await read("destination", "future").expect(404);
});

it("rejects a gate-incompatible edge before inserting any row", async () => {
const project = "invalid";
await request(server()).post(`${base}/seed?projectId=${project}`).send({
criteria: [
{ id: "new_gate", prompt: "Build only", gates: ["build"] },
{ id: "invalid", prompt: "Test", gates: ["test"], dependsOn: ["new_gate"] },
],
}).expect(400);
expect((await request(server()).get(`${base}?projectId=${project}`).expect(200)).body).toEqual([]);
});
});

// ─── skills ──────────────────────────────────────────────────────────────────

describe("skills catalog — per-project isolation (migration 026)", () => {
Expand Down
Loading