Skip to content

Commit 538e09a

Browse files
committed
test(evals): add director-graded cases on the dir-shop fixture
1 parent 22d9c16 commit 538e09a

11 files changed

Lines changed: 128 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "dir-counsel",
3+
"tier": "easy",
4+
"title": "Counsel plans a coupon feature",
5+
"fixture": "fixtures/dir-shop",
6+
"prompt": "Plan adding coupon codes (percentage off, single use per cart) to this cart. Give an ordered engineering plan. Do not change source. Save your final plan (the same text you return) to PLAN.md.",
7+
"verify": "verify.sh"
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
source "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"
3+
dirty=$(git status --porcelain | grep -v -E "(REPORT|PLAN)\.md$|\.corbits/" || true)
4+
[[ -z "$dirty" ]] || { echo "FAIL: source files changed: $dirty"; exit 1; }
5+
[[ -f PLAN.md ]] || { echo 'FAIL: no PLAN.md'; exit 1; }
6+
grep -q 'src/cart.ts' PLAN.md && grep -q 'tests/' PLAN.md || { echo 'FAIL: plan missing files'; exit 1; }
7+
n=$(grep -c -E '^\s*([0-9]+[.)]|-|\*)\s' PLAN.md || true)
8+
[[ "$n" -ge 4 ]] || { echo 'FAIL: fewer than 4 steps'; exit 1; }
9+
echo 'PASS: counsel'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "dir-critic",
3+
"tier": "easy",
4+
"title": "Critic finds planted defects",
5+
"fixture": "fixtures/dir-shop",
6+
"prompt": "Review src/cart.ts for defects. Do not fix anything. Save your final report (the same text you return) to REPORT.md.",
7+
"verify": "verify.sh"
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
source "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"
3+
dirty=$(git status --porcelain | grep -v -E "(REPORT|PLAN)\.md$|\.corbits/" || true)
4+
[[ -z "$dirty" ]] || { echo "FAIL: source files changed: $dirty"; exit 1; }
5+
[[ -f REPORT.md ]] || { echo 'FAIL: no REPORT.md'; exit 1; }
6+
grep -qi -E 'twice|double|both.*(lineTotal|cartTotal)|applied again|compound' REPORT.md || { echo 'FAIL: missed double discount'; exit 1; }
7+
grep -qi -E 'splice|skip|mutat|index' REPORT.md || { echo 'FAIL: missed removeSku splice bug'; exit 1; }
8+
echo 'PASS: critic found both'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "dir-explorer",
3+
"tier": "easy",
4+
"title": "Explorer locates discount logic",
5+
"fixture": "fixtures/dir-shop",
6+
"prompt": "Where is the discount applied to a cart, and which functions are involved? Do not change any source. Save your final report (the same text you return) to REPORT.md.",
7+
"verify": "verify.sh"
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
source "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"
3+
dirty=$(git status --porcelain | grep -v -E "(REPORT|PLAN)\.md$|\.corbits/" || true)
4+
[[ -z "$dirty" ]] || { echo "FAIL: source files changed: $dirty"; exit 1; }
5+
[[ -f REPORT.md ]] || { echo 'FAIL: no REPORT.md'; exit 1; }
6+
grep -q 'src/cart.ts' REPORT.md && grep -q 'lineTotal' REPORT.md && grep -q 'cartTotal' REPORT.md || { echo 'FAIL: report missing path or functions'; exit 1; }
7+
echo 'PASS: explorer'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "dir-tester",
3+
"tier": "easy",
4+
"title": "Tester reports failing test",
5+
"fixture": "fixtures/dir-shop",
6+
"prompt": "Run the test suite and report exactly which test fails and the likely cause. Do not fix anything. Save your final report (the same text you return) to REPORT.md.",
7+
"verify": "verify.sh"
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
source "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"
3+
dirty=$(git status --porcelain | grep -v -E "(REPORT|PLAN)\.md$|\.corbits/" || true)
4+
[[ -z "$dirty" ]] || { echo "FAIL: source files changed: $dirty"; exit 1; }
5+
[[ -f REPORT.md ]] || { echo 'FAIL: no REPORT.md'; exit 1; }
6+
grep -qi 'removes all matching skus' REPORT.md || { echo 'FAIL: failing test not named'; exit 1; }
7+
grep -qi -E 'splice|skip|mutat|index' REPORT.md || { echo 'FAIL: cause not identified'; exit 1; }
8+
grep -qi -E 'bun test|exit' REPORT.md || { echo 'FAIL: no command evidence'; exit 1; }
9+
echo 'PASS: tester'

‎fixtures/dir-shop/package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "dir-shop-fixture",
3+
"private": true,
4+
"type": "module"
5+
}

‎fixtures/dir-shop/src/cart.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export interface Item {
2+
sku: string;
3+
price: number;
4+
qty: number;
5+
}
6+
7+
export function lineTotal(item: Item, discountPct: number): number {
8+
const discounted = item.price * (1 - discountPct / 100);
9+
return discounted * item.qty;
10+
}
11+
12+
export function cartTotal(items: Item[], discountPct = 0): number {
13+
const sum = items.reduce(
14+
(acc, item) => acc + lineTotal(item, discountPct),
15+
0,
16+
);
17+
return sum * (1 - discountPct / 100);
18+
}
19+
20+
export function removeSku(items: Item[], sku: string): Item[] {
21+
for (let i = 0; i < items.length; i++) {
22+
if (items[i]?.sku === sku) items.splice(i, 1);
23+
}
24+
return items;
25+
}

0 commit comments

Comments
 (0)