@bendyline/gilde 0.1.40 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/authoring/gstack/overlays/investigate.json +1 -0
- package/authoring/gstack/overlays/qa-only.json +1 -0
- package/authoring/gstack/wave.json +12 -2
- package/authoring/tactical/books/accessibility-retrofit.json +188 -0
- package/authoring/tactical/books/apply-review-findings.json +189 -0
- package/authoring/tactical/books/bug-fix-tdd.json +237 -0
- package/authoring/tactical/books/ci-pipeline.json +168 -0
- package/authoring/tactical/books/codemod-sweep.json +182 -0
- package/authoring/tactical/books/dependency-upgrade.json +196 -0
- package/authoring/tactical/books/flaky-test-fix.json +238 -0
- package/authoring/tactical/books/hotfix-flow.json +187 -0
- package/authoring/tactical/books/perf-optimization.json +219 -0
- package/authoring/tactical/books/refactor-module.json +217 -0
- package/authoring/tactical/books/schema-migration.json +192 -0
- package/authoring/tactical/books/test-suite-backfill.json +172 -0
- package/authoring/tactical/books/type-safety-pass.json +185 -0
- package/authoring/tactical/books/ux-update.json +178 -0
- package/authoring/tactical/evals/accessibility-retrofit.json +230 -0
- package/authoring/tactical/evals/apply-review-findings.json +290 -0
- package/authoring/tactical/evals/bug-fix-tdd.json +221 -0
- package/authoring/tactical/evals/ci-pipeline.json +227 -0
- package/authoring/tactical/evals/codemod-sweep.json +252 -0
- package/authoring/tactical/evals/dependency-upgrade.json +235 -0
- package/authoring/tactical/evals/flaky-test-fix.json +239 -0
- package/authoring/tactical/evals/hotfix-flow.json +220 -0
- package/authoring/tactical/evals/perf-optimization.json +235 -0
- package/authoring/tactical/evals/refactor-module.json +241 -0
- package/authoring/tactical/evals/schema-migration.json +225 -0
- package/authoring/tactical/evals/test-suite-backfill.json +197 -0
- package/authoring/tactical/evals/type-safety-pass.json +221 -0
- package/authoring/tactical/evals/ux-update.json +206 -0
- package/authoring/tactical/wave.json +89 -0
- package/data/chat-models/de/deepseek-r1-8b-q4/manifest.json +56 -1
- package/data/chat-models/gl/glm-5.2-754b-q2/manifest.json +56 -0
- package/data/chat-models/gp/gpt-oss-120b-q4/manifest.json +73 -1
- package/data/chat-models/gp/gpt-oss-20b-q4/manifest.json +77 -1
- package/data/chat-models/index.json +1 -1
- package/data/chat-models/ll/llama3.2-3b-q4/manifest.json +3 -1
- package/data/chat-models/mi/mistral-7b-q4/manifest.json +54 -3
- package/data/chat-models/mi/mistral-medium-3.5-128b-q4/manifest.json +76 -1
- package/data/craftbook-templates/ac/accessibility-retrofit/manifest.json +5 -4
- package/data/craftbook-templates/ac/accessibility-retrofit/versions/2.0.0/craftbook.json +451 -0
- package/data/craftbook-templates/ac/accessibility-retrofit/versions/2.0.0/test.json +231 -0
- package/data/craftbook-templates/al/alt-text-pass/manifest.json +5 -1
- package/data/craftbook-templates/ap/apply-review-findings/art.json +12 -0
- package/data/craftbook-templates/ap/apply-review-findings/logo.webp +0 -0
- package/data/craftbook-templates/ap/apply-review-findings/manifest.json +23 -0
- package/data/craftbook-templates/ap/apply-review-findings/versions/1.0.0/craftbook.json +436 -0
- package/data/craftbook-templates/ap/apply-review-findings/versions/1.0.0/test.json +291 -0
- package/data/craftbook-templates/br/browser-qa-audit/manifest.json +5 -1
- package/data/craftbook-templates/br/browser-qa-audit/versions/2.0.5/craftbook.json +438 -0
- package/data/craftbook-templates/br/browser-qa-audit/versions/2.0.5/test.json +379 -0
- package/data/craftbook-templates/bu/bug-fix-tdd/manifest.json +3 -3
- package/data/craftbook-templates/bu/bug-fix-tdd/versions/2.0.0/craftbook.json +545 -0
- package/data/craftbook-templates/bu/bug-fix-tdd/versions/2.0.0/test.json +222 -0
- package/data/craftbook-templates/ch/changelog-cut/manifest.json +5 -1
- package/data/craftbook-templates/ch/changelog-writeup/manifest.json +5 -1
- package/data/craftbook-templates/ci/ci-pipeline/manifest.json +5 -3
- package/data/craftbook-templates/ci/ci-pipeline/versions/2.0.0/craftbook.json +423 -0
- package/data/craftbook-templates/ci/ci-pipeline/versions/2.0.0/test.json +228 -0
- package/data/craftbook-templates/co/codemod-sweep/art.json +12 -0
- package/data/craftbook-templates/co/codemod-sweep/logo.webp +0 -0
- package/data/craftbook-templates/co/codemod-sweep/manifest.json +23 -0
- package/data/craftbook-templates/co/codemod-sweep/versions/1.0.0/craftbook.json +441 -0
- package/data/craftbook-templates/co/codemod-sweep/versions/1.0.0/test.json +253 -0
- package/data/craftbook-templates/de/dependency-upgrade/art.json +12 -0
- package/data/craftbook-templates/de/dependency-upgrade/logo.webp +0 -0
- package/data/craftbook-templates/de/dependency-upgrade/manifest.json +23 -0
- package/data/craftbook-templates/de/dependency-upgrade/versions/1.0.0/craftbook.json +459 -0
- package/data/craftbook-templates/de/dependency-upgrade/versions/1.0.0/test.json +236 -0
- package/data/craftbook-templates/fe/feature-flag-release/manifest.json +5 -1
- package/data/craftbook-templates/fe/feature-flag-rollout/manifest.json +4 -1
- package/data/craftbook-templates/fe/feature-flag-rollout/versions/1.1.0/craftbook.json +203 -0
- package/data/craftbook-templates/fe/feature-flag-rollout/versions/1.1.0/test.json +165 -0
- package/data/craftbook-templates/fl/flaky-test-fix/art.json +12 -0
- package/data/craftbook-templates/fl/flaky-test-fix/logo.webp +0 -0
- package/data/craftbook-templates/fl/flaky-test-fix/manifest.json +24 -0
- package/data/craftbook-templates/fl/flaky-test-fix/versions/1.0.0/craftbook.json +534 -0
- package/data/craftbook-templates/fl/flaky-test-fix/versions/1.0.0/test.json +240 -0
- package/data/craftbook-templates/ho/hotfix-flow/manifest.json +5 -3
- package/data/craftbook-templates/ho/hotfix-flow/versions/2.0.0/craftbook.json +442 -0
- package/data/craftbook-templates/ho/hotfix-flow/versions/2.0.0/test.json +221 -0
- package/data/craftbook-templates/in/investigate/manifest.json +4 -1
- package/data/craftbook-templates/in/investigate-root-cause/manifest.json +5 -1
- package/data/craftbook-templates/index.json +1 -1
- package/data/craftbook-templates/li/live-browser-qa/manifest.json +5 -1
- package/data/craftbook-templates/ni/nightly-fix-sweep/art.json +12 -0
- package/data/craftbook-templates/ni/nightly-fix-sweep/logo.webp +0 -0
- package/data/craftbook-templates/ni/nightly-fix-sweep/manifest.json +23 -0
- package/data/craftbook-templates/ni/nightly-fix-sweep/versions/1.0.0/craftbook.json +145 -0
- package/data/craftbook-templates/ni/nightly-fix-sweep/versions/1.0.0/test.json +121 -0
- package/data/craftbook-templates/pe/perf-audit/versions/1.1.0/craftbook.json +195 -0
- package/data/craftbook-templates/pe/perf-audit/versions/1.1.0/test.json +165 -0
- package/data/craftbook-templates/pe/perf-optimization/manifest.json +3 -3
- package/data/craftbook-templates/pe/perf-optimization/versions/2.0.0/craftbook.json +511 -0
- package/data/craftbook-templates/pe/perf-optimization/versions/2.0.0/test.json +236 -0
- package/data/craftbook-templates/qa/qa/manifest.json +3 -1
- package/data/craftbook-templates/re/refactor-module/manifest.json +2 -2
- package/data/craftbook-templates/re/refactor-module/versions/1.0.4/craftbook.json +150 -0
- package/data/craftbook-templates/re/refactor-module/versions/1.0.4/test.json +95 -0
- package/data/craftbook-templates/re/refactor-module/versions/2.0.0/craftbook.json +509 -0
- package/data/craftbook-templates/re/refactor-module/versions/2.0.0/test.json +242 -0
- package/data/craftbook-templates/re/release-notes/manifest.json +5 -1
- package/data/craftbook-templates/re/release-notes/versions/1.0.3/craftbook.json +220 -0
- package/data/craftbook-templates/re/release-notes/versions/1.0.3/test.json +114 -0
- package/data/craftbook-templates/re/release-pipeline-ci/manifest.json +5 -1
- package/data/craftbook-templates/re/release-readiness-review/versions/1.1.0/craftbook.json +192 -0
- package/data/craftbook-templates/re/release-readiness-review/versions/1.1.0/test.json +113 -0
- package/data/craftbook-templates/ro/root-cause-investigation/manifest.json +7 -1
- package/data/craftbook-templates/ro/root-cause-investigation/versions/2.0.5/craftbook.json +433 -0
- package/data/craftbook-templates/ro/root-cause-investigation/versions/2.0.5/test.json +157 -0
- package/data/craftbook-templates/sc/schema-migration/manifest.json +4 -4
- package/data/craftbook-templates/sc/schema-migration/versions/2.0.0/craftbook.json +459 -0
- package/data/craftbook-templates/sc/schema-migration/versions/2.0.0/test.json +226 -0
- package/data/craftbook-templates/te/test-coverage-review/versions/1.2.0/craftbook.json +195 -0
- package/data/craftbook-templates/te/test-coverage-review/versions/1.2.0/test.json +116 -0
- package/data/craftbook-templates/te/test-suite-backfill/manifest.json +1 -2
- package/data/craftbook-templates/te/test-suite-backfill/versions/2.0.0/craftbook.json +428 -0
- package/data/craftbook-templates/te/test-suite-backfill/versions/2.0.0/test.json +198 -0
- package/data/craftbook-templates/ty/type-safety-pass/manifest.json +3 -3
- package/data/craftbook-templates/ty/type-safety-pass/versions/2.0.0/craftbook.json +428 -0
- package/data/craftbook-templates/ty/type-safety-pass/versions/2.0.0/test.json +222 -0
- package/data/craftbook-templates/ux/ux-update/art.json +12 -0
- package/data/craftbook-templates/ux/ux-update/logo.webp +0 -0
- package/data/craftbook-templates/ux/ux-update/manifest.json +22 -0
- package/data/craftbook-templates/ux/ux-update/versions/1.0.0/craftbook.json +439 -0
- package/data/craftbook-templates/ux/ux-update/versions/1.0.0/test.json +207 -0
- package/data/craftbook-templates/ve/version-bump/versions/1.1.0/craftbook.json +206 -0
- package/data/craftbook-templates/ve/version-bump/versions/1.1.0/test.json +95 -0
- package/data/gezel-templates/bo/boekwachter/versions/1.1.0/about.md +29 -0
- package/data/gezel-templates/bo/boekwachter/versions/1.1.0/manifest.json +16 -0
- package/data/gezel-templates/bu/builder/versions/1.5.0/about.md +34 -0
- package/data/gezel-templates/bu/builder/versions/1.5.0/manifest.json +16 -0
- package/data/gezel-templates/de/developer/versions/1.5.0/about.md +34 -0
- package/data/gezel-templates/de/developer/versions/1.5.0/manifest.json +21 -0
- package/data/gezel-templates/index.json +1 -1
- package/data/gezel-templates/re/reviewer/versions/1.4.0/about.md +49 -0
- package/data/gezel-templates/re/reviewer/versions/1.4.0/manifest.json +21 -0
- package/data/project-types/index.json +1 -1
- package/data/project-types/so/software-project/manifest.json +20 -0
- package/data/project-types/so/software-project/versions/1.0.0/about.md +3 -0
- package/data/project-types/so/software-project/versions/1.0.0/manifest.json +41 -0
- package/data/project-types/so/software-project/versions/1.0.0/mission.md +4 -0
- package/package.json +1 -1
- package/schemas/craftbook-doc.schema.json +248 -0
- package/schemas/craftbook-template-version.schema.json +248 -0
- package/schemas/craftbook-test.schema.json +200 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"title": "Measured near-linear fix for a quadratic hot path",
|
|
4
|
+
"objective": "The craftbook drives a measured optimization of a seeded O(n^2) duplicate finder: baseline numbers recorded with their method, one bottleneck fixed at the real site, the same measurement re-run to prove the gain, and an enforced review — verified mechanically via a deterministic instrumented op-count budget, reference-equal results, and a green-suite run.",
|
|
5
|
+
"tags": [
|
|
6
|
+
"code",
|
|
7
|
+
"performance",
|
|
8
|
+
"tactical-fleet"
|
|
9
|
+
],
|
|
10
|
+
"prompt": "Use the Targeted Performance Fix craftbook for this: support says importing a 200-row sheet crawls, and profiling points at findDuplicates - a 200-item list burns about 40,000 comparisons. The brief is in source/perf-brief.md. Get findDuplicates near-linear without changing its results.",
|
|
11
|
+
"setup": {
|
|
12
|
+
"projectName": "Sheet Importer",
|
|
13
|
+
"about": "A tiny sheet-import module with an instrumented duplicate finder. Tests run with `npm run test` (node --test).",
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "package.json",
|
|
17
|
+
"content": "{\n \"name\": \"sheet-importer\",\n \"private\": true,\n \"version\": \"1.0.0\",\n \"type\": \"module\",\n \"scripts\": {\n \"test\": \"node --test\"\n }\n}\n"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"path": "src/instrument.js",
|
|
21
|
+
"content": "let comparisons = 0;\n\nexport function countComparison() {\n comparisons += 1;\n}\n\nexport function comparisonCount() {\n return comparisons;\n}\n\nexport function resetComparisons() {\n comparisons = 0;\n}\n"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "src/find-duplicates.js",
|
|
25
|
+
"content": "import { countComparison } from './instrument.js';\n\nexport function findDuplicates(items) {\n const duplicates = [];\n for (let i = 0; i < items.length; i += 1) {\n let count = 0;\n for (let j = 0; j < items.length; j += 1) {\n countComparison();\n if (items[j] === items[i]) count += 1;\n }\n if (count > 1 && !duplicates.includes(items[i])) duplicates.push(items[i]);\n }\n return duplicates;\n}\n"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "tests/duplicates.test.mjs",
|
|
29
|
+
"content": "import assert from 'node:assert/strict';\nimport { test } from 'node:test';\nimport { findDuplicates } from '../src/find-duplicates.js';\n\ntest('reports each duplicate once, in first-appearance order', () => {\n assert.deepEqual(findDuplicates(['a', 'b', 'a', 'c', 'b']), ['a', 'b']);\n});\n\ntest('returns empty for unique lists', () => {\n assert.deepEqual(findDuplicates(['x', 'y', 'z']), []);\n});\n\ntest('order pins to first appearance, not second occurrence', () => {\n assert.deepEqual(findDuplicates(['a', 'b', 'b', 'a']), ['a', 'b']);\n});\n"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "source/perf-brief.md",
|
|
33
|
+
"content": "# Performance brief\n\nSupport reports that importing a 200-row sheet crawls. Profiling points at `findDuplicates` in src/find-duplicates.js: for a 200-item list it performs about 40,000 instrumented comparisons (200 x 200 full rescans). The counter lives in src/instrument.js - `comparisonCount()` reads it, `resetComparisons()` clears it.\n\nTarget: get `findDuplicates` near-linear - well under 2,000 instrumented comparisons for a 200-item list - WITHOUT changing its results. Each duplicated value is reported once, in order of FIRST appearance.\n\nRules:\n\n- src/instrument.js is measurement infrastructure; leave it exactly as it is.\n- Keep the measurement honest: keep calling `countComparison()` for every equality comparison the new implementation still performs. Deleting instrumentation instead of deleting work is measurement theater.\n- Measure with a repeatable command: a small script that builds a 200-item list, calls `findDuplicates`, and prints `comparisonCount()`.\n"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "tests/verify-perf.mjs",
|
|
37
|
+
"content": "import assert from 'node:assert/strict';\nimport { execFileSync } from 'node:child_process';\nimport { findDuplicates } from '../src/find-duplicates.js';\nimport { comparisonCount, resetComparisons } from '../src/instrument.js';\n\n// Independent reference: each duplicated value once, first-appearance order.\nfunction referenceDuplicates(items) {\n const counts = new Map();\n for (const item of items) counts.set(item, (counts.get(item) ?? 0) + 1);\n const out = [];\n const added = new Set();\n for (const item of items) {\n if ((counts.get(item) ?? 0) > 1 && !added.has(item)) {\n added.add(item);\n out.push(item);\n }\n }\n return out;\n}\n\n// 1) Results identical to reference on small pinned cases.\nassert.deepEqual(findDuplicates(['a', 'b', 'a', 'c', 'b']), ['a', 'b']);\nassert.deepEqual(findDuplicates([]), []);\nassert.deepEqual(findDuplicates(['a', 'b', 'b', 'a']), ['a', 'b']);\n\n// 2) Deterministic 200-item workload: results equal reference AND the\n// instrumented op-count is under the stated budget (seeded code: 40000).\nconst items = [];\nfor (let i = 0; i < 200; i += 1) items.push('v' + ((i * 7) % 149));\nresetComparisons();\nconst result = findDuplicates(items);\nassert.deepEqual(result, referenceDuplicates(items), 'results changed - speed that changes answers is a bug');\nconsole.log('PERF_OPTIMIZATION_ORACLE results ok');\nconst ops = comparisonCount();\nassert.ok(\n ops <= 2000,\n 'findDuplicates on 200 items performed ' + ops + ' instrumented comparisons - the budget is 2000 and the seeded code did 40000',\n);\nconsole.log('PERF_OPTIMIZATION_ORACLE ops ' + ops + ' within budget');\n\n// 3) The whole suite is green on the optimized tree (real run).\nfunction runSuite(cwd) {\n try {\n execFileSync(process.execPath, ['--test'], { cwd, stdio: 'pipe', timeout: 30000 });\n return 0;\n } catch (err) {\n return typeof err.status === 'number' ? err.status : 1;\n }\n}\nassert.equal(runSuite(process.cwd()), 0, 'the suite must be green on the optimized tree');\nconsole.log('PERF_OPTIMIZATION_ORACLE suite green');\nconsole.log('PERF_OPTIMIZATION_ORACLE done');\n",
|
|
38
|
+
"surface": "harness"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"craftbookParams": {
|
|
42
|
+
"workPath": "tasks/eval",
|
|
43
|
+
"scope": "findDuplicates in src/find-duplicates.js does about 40,000 instrumented comparisons for a 200-item list; get it near-linear (well under 2,000 comparisons) without changing its results. See source/perf-brief.md."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"mocks": [],
|
|
47
|
+
"success": {
|
|
48
|
+
"summary": "The quadratic rescan is gone, the instrumented op-count for 200 items is under budget, results are identical to the reference on a deterministic workload, the suite is green on a real run, and every fleet artifact exists with honest numbers and citations.",
|
|
49
|
+
"deliverables": [
|
|
50
|
+
{
|
|
51
|
+
"path": "tasks/eval/baseline.md",
|
|
52
|
+
"kind": "markdown-notes",
|
|
53
|
+
"artifact": true,
|
|
54
|
+
"minBytes": 500,
|
|
55
|
+
"checks": [
|
|
56
|
+
{
|
|
57
|
+
"kind": "contains",
|
|
58
|
+
"file": "tasks/eval/baseline.md",
|
|
59
|
+
"pattern": "^##\\s+Current behavior[\\s\\S]*^##\\s+Measurements[\\s\\S]*^##\\s+Guardrail",
|
|
60
|
+
"flags": "im",
|
|
61
|
+
"label": "baseline sections in order"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"kind": "contains",
|
|
65
|
+
"file": "tasks/eval/baseline.md",
|
|
66
|
+
"pattern": "^##\\s+Measurements[\\s\\S]*\\d",
|
|
67
|
+
"flags": "im",
|
|
68
|
+
"label": "baseline numbers recorded"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"kind": "citationsResolve",
|
|
72
|
+
"file": "tasks/eval/baseline.md",
|
|
73
|
+
"minCitations": 2,
|
|
74
|
+
"artifact": true
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"path": "tasks/eval/plan.md",
|
|
80
|
+
"kind": "markdown-notes",
|
|
81
|
+
"artifact": true,
|
|
82
|
+
"minBytes": 500,
|
|
83
|
+
"checks": [
|
|
84
|
+
{
|
|
85
|
+
"kind": "contains",
|
|
86
|
+
"file": "tasks/eval/plan.md",
|
|
87
|
+
"pattern": "^##\\s+Target[\\s\\S]*^##\\s+Stages[\\s\\S]*^##\\s+Acceptance criteria",
|
|
88
|
+
"flags": "im",
|
|
89
|
+
"label": "plan sections in order"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"kind": "citationsResolve",
|
|
93
|
+
"file": "tasks/eval/plan.md",
|
|
94
|
+
"minCitations": 2,
|
|
95
|
+
"artifact": true
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"path": "tasks/eval/change-notes.md",
|
|
101
|
+
"kind": "markdown-notes",
|
|
102
|
+
"artifact": true,
|
|
103
|
+
"minBytes": 600,
|
|
104
|
+
"checks": [
|
|
105
|
+
{
|
|
106
|
+
"kind": "contains",
|
|
107
|
+
"file": "tasks/eval/change-notes.md",
|
|
108
|
+
"pattern": "^##\\s+Stages executed[\\s\\S]*^##\\s+Files touched[\\s\\S]*^##\\s+Deviations from plan",
|
|
109
|
+
"flags": "im",
|
|
110
|
+
"label": "change-notes sections in order"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"kind": "citationsResolve",
|
|
114
|
+
"file": "tasks/eval/change-notes.md",
|
|
115
|
+
"minCitations": 2,
|
|
116
|
+
"artifact": true
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"path": "tasks/eval/verification.md",
|
|
122
|
+
"kind": "markdown-notes",
|
|
123
|
+
"artifact": true,
|
|
124
|
+
"minBytes": 400,
|
|
125
|
+
"checks": [
|
|
126
|
+
{
|
|
127
|
+
"kind": "contains",
|
|
128
|
+
"file": "tasks/eval/verification.md",
|
|
129
|
+
"pattern": "^##\\s+Before\\s*/\\s*after[\\s\\S]*^##\\s+Suite[\\s\\S]*^##\\s+Result",
|
|
130
|
+
"flags": "im",
|
|
131
|
+
"label": "verification sections in order"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"kind": "contains",
|
|
135
|
+
"file": "tasks/eval/verification.md",
|
|
136
|
+
"pattern": "^##\\s+Before\\s*/\\s*after[\\s\\S]*\\d",
|
|
137
|
+
"flags": "im",
|
|
138
|
+
"label": "both numbers quoted"
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"path": "tasks/eval/review.md",
|
|
144
|
+
"kind": "markdown-report",
|
|
145
|
+
"artifact": true,
|
|
146
|
+
"minBytes": 400,
|
|
147
|
+
"checks": [
|
|
148
|
+
{
|
|
149
|
+
"kind": "contains",
|
|
150
|
+
"file": "tasks/eval/review.md",
|
|
151
|
+
"pattern": "Verdict:\\s*(?:PASS|REVISE)",
|
|
152
|
+
"flags": "i",
|
|
153
|
+
"label": "explicit reviewer verdict"
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"checks": [
|
|
159
|
+
{
|
|
160
|
+
"kind": "notContains",
|
|
161
|
+
"file": "src/find-duplicates.js",
|
|
162
|
+
"pattern": "for\\s*\\(let j = 0; j < items\\.length",
|
|
163
|
+
"label": "the seeded inner full-list rescan is gone"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"kind": "sourceParses",
|
|
167
|
+
"file": "src/find-duplicates.js"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"kind": "nodeScriptPasses",
|
|
171
|
+
"script": "tests/verify-perf.mjs",
|
|
172
|
+
"timeoutMs": 60000,
|
|
173
|
+
"requiredOutput": [
|
|
174
|
+
{
|
|
175
|
+
"pattern": "PERF_OPTIMIZATION_ORACLE results ok",
|
|
176
|
+
"label": "results identical to the reference"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"pattern": "PERF_OPTIMIZATION_ORACLE ops \\d+ within budget",
|
|
180
|
+
"label": "instrumented op-count under the stated budget"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"pattern": "PERF_OPTIMIZATION_ORACLE suite green",
|
|
184
|
+
"label": "suite green on the optimized tree"
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
"taskNotes": {
|
|
190
|
+
"minBytes": 120,
|
|
191
|
+
"checks": [
|
|
192
|
+
{
|
|
193
|
+
"kind": "contains",
|
|
194
|
+
"file": "task-notes.md",
|
|
195
|
+
"pattern": "\\bDONE\\b[\\s\\S]*(npm\\s+run\\s+test|node\\s+--test)",
|
|
196
|
+
"flags": "i",
|
|
197
|
+
"label": "DONE note names the real test command"
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
"taskGraph": {
|
|
202
|
+
"requireCraftbookTask": true,
|
|
203
|
+
"requireTerminalStep": true
|
|
204
|
+
},
|
|
205
|
+
"unchangedFixtures": [
|
|
206
|
+
"source/perf-brief.md",
|
|
207
|
+
"package.json",
|
|
208
|
+
"src/instrument.js"
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
"rubric": {
|
|
212
|
+
"artifact": {
|
|
213
|
+
"path": "tasks/eval/verification.md",
|
|
214
|
+
"kind": "markdown"
|
|
215
|
+
},
|
|
216
|
+
"axes": [
|
|
217
|
+
{
|
|
218
|
+
"name": "Measurement honesty",
|
|
219
|
+
"description": "Baseline numbers were gathered by a stated, repeatable method before the change, and verification re-ran the identical method and quoted both figures side by side - no adjectives standing in for numbers, no swapped workload."
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "Bottleneck focus",
|
|
223
|
+
"description": "One bottleneck was named with its mechanism and fixed at the real site by that mechanism - not a synthetic proxy, a weakened measurement, or scattered micro-tweaks."
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"name": "Correctness under speed",
|
|
227
|
+
"description": "Results stayed identical on the same inputs, the suite stayed green between stages with real receipts, and residual risk or unverified claims are labeled honestly."
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
"qualityFocus": [
|
|
232
|
+
"numbers with their method",
|
|
233
|
+
"same-method re-measurement",
|
|
234
|
+
"enforced review loop"
|
|
235
|
+
]
|
|
236
|
+
}
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
"role": "maintenance-review",
|
|
6
6
|
"category": "code-quality",
|
|
7
7
|
"name": "Behavior-Preserving Refactor",
|
|
8
|
-
"description": "
|
|
8
|
+
"description": "Restructure code without changing what it does, with proof at every stage: a green suite recorded before anything moves (characterization tests pinned first when coverage is thin), small reversible stages that keep the tests green, a re-measured structure target, and an enforced independent review.",
|
|
9
9
|
"tags": [
|
|
10
|
-
"gallery",
|
|
11
10
|
"refactor",
|
|
12
11
|
"cleanup",
|
|
13
12
|
"code-quality",
|
|
14
13
|
"maintainability",
|
|
14
|
+
"duplication",
|
|
15
15
|
"tests"
|
|
16
16
|
],
|
|
17
17
|
"maintainer": {
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "refactor-module",
|
|
3
|
+
"name": "Behavior-Preserving Refactor",
|
|
4
|
+
"description": "Refactor a module to improve its structure, readability, or design WITHOUT changing observable behavior — the defining constraint is that the tests stay green throughout. Plans the refactor FIRST — the target structure, the seams to introduce, the safe step sequence, and the green-tests guardrail — then refactors in small reversible steps, then a reviewer confirms behavior is unchanged and the code is genuinely cleaner. Covers extract-function/module, dependency seams, removing duplication, naming, and test-green-as-invariant refactoring.\n\nA gallery craftbook generated from an archetype spec. It runs\n`phase → (per-phase gate) → … → evaluate → (loop) → finish`. Each build\nphase that produces a checkable artifact is followed by a **runtime\ngate-checkpoint** — the runtime verifies the artifact and routes with no\nmodel turn, looping back to redo the phase on a miss. The final `evaluate`\nstep holds a static deliverable gate plus a reviewer QA pass. What it adds\nover the generic `build-loop`: a specialist role per phase, a\ndomain-correct ordering, and a concrete per-phase quality bar.\n\nDeliverables marked \"artifact\" land in the project's artifacts drawer (`write_artifact` / `read_artifact`), not the shipped workspace — review output is not product source.\n\nPhases:\n\n1. Plan the refactor (planner) — lock target structure, steps, green-tests guardrail → gated on artifact `{{workPath}}/plan.md` (markdown-notes)\n2. Refactor (developer) — apply small reversible steps, tests green throughout → gated on artifact `{{workPath}}/refactor.md` (markdown-notes)\n3. Verify behavior preserved (reviewer) — confirm tests green and code is genuinely cleaner → gated on artifact `{{workPath}}/verify.md` (markdown-notes)\n\nThe gates never advance with an unmet criterion, and loop back to the\nowning phase to fix named gaps.\n",
|
|
5
|
+
"entryStepId": "plan",
|
|
6
|
+
"triggers": [
|
|
7
|
+
"refactor this module",
|
|
8
|
+
"clean up the code",
|
|
9
|
+
"improve code structure",
|
|
10
|
+
"behavior-preserving refactor",
|
|
11
|
+
"reduce duplication"
|
|
12
|
+
],
|
|
13
|
+
"paramSchema": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"workPath": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"title": "Working folder",
|
|
19
|
+
"description": "Per-task working folder in the artifacts drawer. Defaults to this task's own folder so runs never collide; override with a stable name when you deliberately want runs to share files.",
|
|
20
|
+
"default": "{{task.dir}}"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"steps": [
|
|
25
|
+
{
|
|
26
|
+
"id": "plan",
|
|
27
|
+
"name": "Plan the refactor",
|
|
28
|
+
"description": "lock target structure, steps, green-tests guardrail",
|
|
29
|
+
"prompt": "Plan the refactor before touching code — the prime directive is preserving behavior. Step 1: Identify the specific smells (duplication, long function, tangled responsibilities, poor names) and the target structure you want. Step 2: Confirm there is a test safety net; if coverage is thin, note the characterization tests to add FIRST so behavior is pinned before changing structure. Step 3: Break the work into small, individually-reversible steps (extract this function, introduce this seam, rename that), each of which keeps tests green. Step 4: Write a numbered acceptance-criteria checklist of 5-9 items (e.g. 'all existing tests pass before and after', 'public API/behavior is unchanged', 'the targeted duplication is gone', 'no function exceeds N lines / responsibilities are separated'). `write_task_note` the plan + checklist and write the same to the produces path.\n\nThe deliverable `{{workPath}}/plan.md` lands in the project's artifacts drawer — write it with `write_artifact` and read it back with `read_artifact`; the shipped workspace stays untouched.",
|
|
30
|
+
"suggestedRole": "planner",
|
|
31
|
+
"advanceWhen": {
|
|
32
|
+
"file": "{{workPath}}/plan.md",
|
|
33
|
+
"minBytes": 1,
|
|
34
|
+
"sniff": "nonempty",
|
|
35
|
+
"artifact": true
|
|
36
|
+
},
|
|
37
|
+
"gate": {
|
|
38
|
+
"at": "completion",
|
|
39
|
+
"checks": [
|
|
40
|
+
{
|
|
41
|
+
"kind": "minBytes",
|
|
42
|
+
"file": "{{workPath}}/plan.md",
|
|
43
|
+
"bytes": 120,
|
|
44
|
+
"artifact": true
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"kind": "sniff",
|
|
48
|
+
"file": "{{workPath}}/plan.md",
|
|
49
|
+
"sniff": "nonempty",
|
|
50
|
+
"artifact": true
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"onReject": "plan",
|
|
54
|
+
"maxAttempts": 3
|
|
55
|
+
},
|
|
56
|
+
"next": "refactor"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "refactor",
|
|
60
|
+
"name": "Refactor",
|
|
61
|
+
"description": "apply small reversible steps, tests green throughout",
|
|
62
|
+
"prompt": "Execute the refactor in small steps, keeping the tests green the entire time. The code changes happen IN PLACE in the module's existing files — there is no separate output file for the code. Step 1: If the plan called for characterization tests, add them first and confirm they pass against current behavior. Step 2: Apply one planned step at a time — extract, rename, dedupe, introduce a seam — and run the tests after EACH step; if a step breaks them, revert it and try smaller. Step 3: Do not change public signatures or observable behavior unless the plan explicitly says so. Step 4: Stop when the target structure is reached and the smells are gone. Write the refactor summary (which files changed, what changed structurally, tests still green) to the produces path. On a loop-back, address only the reviewer's points. `write_task_note` the summary and which criteria now pass.\n\nThe deliverable `{{workPath}}/refactor.md` lands in the project's artifacts drawer — write it with `write_artifact` and read it back with `read_artifact`; the shipped workspace stays untouched.",
|
|
63
|
+
"suggestedRole": "developer",
|
|
64
|
+
"advanceWhen": {
|
|
65
|
+
"file": "{{workPath}}/refactor.md",
|
|
66
|
+
"minBytes": 1,
|
|
67
|
+
"sniff": "nonempty",
|
|
68
|
+
"artifact": true
|
|
69
|
+
},
|
|
70
|
+
"gate": {
|
|
71
|
+
"at": "completion",
|
|
72
|
+
"checks": [
|
|
73
|
+
{
|
|
74
|
+
"kind": "minBytes",
|
|
75
|
+
"file": "{{workPath}}/refactor.md",
|
|
76
|
+
"bytes": 120,
|
|
77
|
+
"artifact": true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"kind": "sniff",
|
|
81
|
+
"file": "{{workPath}}/refactor.md",
|
|
82
|
+
"sniff": "nonempty",
|
|
83
|
+
"artifact": true
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"onReject": "refactor",
|
|
87
|
+
"maxAttempts": 3
|
|
88
|
+
},
|
|
89
|
+
"next": "verify"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"id": "verify",
|
|
93
|
+
"name": "Verify behavior preserved",
|
|
94
|
+
"description": "confirm tests green and code is genuinely cleaner",
|
|
95
|
+
"prompt": "Verify the refactor preserved behavior and actually improved the code. Step 1: Run the full test suite and confirm it is green (this is the hard gate). Step 2: Confirm the public API/observable behavior is identical to before. Step 3: Confirm the targeted smell is actually fixed — the duplication is gone, the function is decomposed, names are clearer — not just moved around. Step 4: Confirm no behavior was sneaked in under cover of the refactor. Write a verification note with the test result and a before/after readability assessment to the produces path.\n\nThe deliverable `{{workPath}}/verify.md` lands in the project's artifacts drawer — write it with `write_artifact` and read it back with `read_artifact`; the shipped workspace stays untouched.",
|
|
96
|
+
"suggestedRole": "reviewer",
|
|
97
|
+
"advanceWhen": {
|
|
98
|
+
"file": "{{workPath}}/verify.md",
|
|
99
|
+
"minBytes": 1,
|
|
100
|
+
"sniff": "nonempty",
|
|
101
|
+
"artifact": true
|
|
102
|
+
},
|
|
103
|
+
"gate": {
|
|
104
|
+
"at": "completion",
|
|
105
|
+
"checks": [
|
|
106
|
+
{
|
|
107
|
+
"kind": "minBytes",
|
|
108
|
+
"file": "{{workPath}}/verify.md",
|
|
109
|
+
"bytes": 120,
|
|
110
|
+
"artifact": true
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"kind": "sniff",
|
|
114
|
+
"file": "{{workPath}}/verify.md",
|
|
115
|
+
"sniff": "nonempty",
|
|
116
|
+
"artifact": true
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"onReject": "verify",
|
|
120
|
+
"maxAttempts": 4
|
|
121
|
+
},
|
|
122
|
+
"next": "evaluate"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"id": "evaluate",
|
|
126
|
+
"name": "Evaluate",
|
|
127
|
+
"description": "Grade the deliverable against every acceptance criterion. All pass → finish; any fail → loop back and fix the gap.",
|
|
128
|
+
"prompt": "Run the test suite. For EACH acceptance criterion: confirm ALL existing tests pass (green is mandatory), confirm public behavior is unchanged, confirm the targeted smell is genuinely fixed, and confirm no new behavior crept in. Write PASS/FAIL per criterion; a single failing test is an automatic FAIL of the whole refactor.\n\nThe deliverable lives in the project's artifacts drawer — open `{{workPath}}/verify.md` with `read_artifact`, not `read_file`.\n\nThen route — this is the whole point of the loop:\n\n- **Every criterion PASSES →** call `advance_task_step({ ref, stepId: \"evaluate\", next: \"finish\" })`.\n- **Any criterion FAILS →** write the specific gaps to notes, then call `advance_task_step({ ref, stepId: \"evaluate\", next: \"refactor\" })` to loop back. The builder fixes exactly those gaps.\n\nNever route to `finish` while any criterion is unmet. The build phase's completion gate already blocked a grossly-incomplete deliverable; your job is the judgment an automated check cannot make (does it actually work, read well, look right). After ~3 unproductive loops, stop and report DONE_WITH_CONCERNS so the user can step in.",
|
|
129
|
+
"suggestedRole": "reviewer",
|
|
130
|
+
"consumes": [
|
|
131
|
+
{
|
|
132
|
+
"file": "{{workPath}}/verify.md",
|
|
133
|
+
"artifact": true
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"next": "refactor"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "finish",
|
|
140
|
+
"name": "Finish",
|
|
141
|
+
"description": "All acceptance criteria met. Stamp a short summary and report DONE.",
|
|
142
|
+
"prompt": "Every acceptance criterion passed. Write a one-paragraph DONE summary to task notes via `write_task_note`: what was built, the deliverable path(s), and a one-line confirmation that each criterion is met. Then report DONE.",
|
|
143
|
+
"suggestedRole": "developer",
|
|
144
|
+
"terminal": true
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"version": "1.0.4",
|
|
148
|
+
"releasedAt": "2026-08-24T00:00:00Z",
|
|
149
|
+
"minGezelVersion": "1.26233"
|
|
150
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"title": "Behavior-Preserving Refactor smoke eval",
|
|
4
|
+
"objective": "Self-contained smoke eval for the Behavior-Preserving Refactor craftbook using the code generic harness.",
|
|
5
|
+
"tags": [
|
|
6
|
+
"code"
|
|
7
|
+
],
|
|
8
|
+
"prompt": "We need a small Node helper for this — the requirments are in source/requirements.md. Put it in src/solution.mjs.",
|
|
9
|
+
"setup": {
|
|
10
|
+
"projectName": "Behavior-Preserving Refactor Eval",
|
|
11
|
+
"about": "Self-contained eval project for refactor-module. Seeded inputs are under workspace/source or workspace/fixtures; final deliverable is workspace/src/solution.mjs.",
|
|
12
|
+
"missionObjectives": "Use the Behavior-Preserving Refactor craftbook/template, read the seeded local fixtures, and write src/solution.mjs without network calls, real credentials, or live services.",
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "source/brief.md",
|
|
16
|
+
"content": "# Behavior-Preserving Refactor Eval Brief\n\nClient: Boreal Desk, a home-office accessories company.\nAudience: operations leads who need an artifact they can use this week.\n\nFixed source facts for grounding:\n- The returns desk pilot covered 18 SKUs.\n- Median first response improved from 18 hours to 6 hours.\n- Preventable refund leakage fell from 14.2% to 8.9%.\n- The top unresolved complaint is status silence after photo submission.\n- Required next actions are automated status emails, barcode-exception training, and a weekly Finance exception export.\n\nUse these facts when the task asks for prose, analysis, copy, UI content, or test data. Do not use live web services, real credentials, or current outside data.\n\nCraftbook under test: refactor-module - Behavior-Preserving Refactor.\n"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "source/requirements.md",
|
|
20
|
+
"content": "# Runner Requirements\n\nBuild a dependency-free Node ESM helper for Boreal Desk support operations. Export at least one function. Include a tiny self-test section using node:assert or an equivalent assertion helper. Use fixture values for 18 -> 6 hour response time and 14.2 -> 8.9 refund leakage.\n"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"worker": {
|
|
24
|
+
"name": "Jules",
|
|
25
|
+
"role": "Developer"
|
|
26
|
+
},
|
|
27
|
+
"craftbookParams": {
|
|
28
|
+
"workPath": "tasks/eval"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"mocks": [],
|
|
32
|
+
"success": {
|
|
33
|
+
"summary": "src/solution.mjs is a local ESM module with basic self-test scaffolding.",
|
|
34
|
+
"deliverables": [
|
|
35
|
+
{
|
|
36
|
+
"path": "src/solution.mjs",
|
|
37
|
+
"kind": "code-with-tests",
|
|
38
|
+
"minBytes": 1500,
|
|
39
|
+
"checks": [
|
|
40
|
+
{
|
|
41
|
+
"kind": "esmImports",
|
|
42
|
+
"file": "src/solution.mjs"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"kind": "contains",
|
|
46
|
+
"file": "src/solution.mjs",
|
|
47
|
+
"pattern": "export\\s+(function|const|class)|export\\s*\\{",
|
|
48
|
+
"flags": "i"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"kind": "contains",
|
|
52
|
+
"file": "src/solution.mjs",
|
|
53
|
+
"pattern": "assert|test|describe|it|expect",
|
|
54
|
+
"flags": "i"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"kind": "contains",
|
|
58
|
+
"file": "src/solution.mjs",
|
|
59
|
+
"pattern": "18|6|14\\.2|8\\.9|Boreal",
|
|
60
|
+
"flags": "i"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"rubric": {
|
|
67
|
+
"artifact": {
|
|
68
|
+
"path": "src/solution.mjs",
|
|
69
|
+
"kind": "typescript"
|
|
70
|
+
},
|
|
71
|
+
"axes": [
|
|
72
|
+
{
|
|
73
|
+
"name": "correctness",
|
|
74
|
+
"description": "The module does what the requirements ask, with sensible edge handling."
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "verification",
|
|
78
|
+
"description": "Self-tests exercise real behavior, not trivial truths."
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "clarity",
|
|
82
|
+
"description": "Exports, naming, and structure make the module usable without reading every line."
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "robustness",
|
|
86
|
+
"description": "Invalid input and boundary cases fail loudly rather than silently."
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"qualityFocus": [
|
|
91
|
+
"runnable ESM",
|
|
92
|
+
"test scaffolding",
|
|
93
|
+
"local fixtures"
|
|
94
|
+
]
|
|
95
|
+
}
|