@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,235 @@
|
|
|
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
|
+
"surface": "harness",
|
|
38
|
+
"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"
|
|
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
|
+
"success": {
|
|
47
|
+
"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.",
|
|
48
|
+
"deliverables": [
|
|
49
|
+
{
|
|
50
|
+
"path": "tasks/eval/baseline.md",
|
|
51
|
+
"kind": "markdown-notes",
|
|
52
|
+
"artifact": true,
|
|
53
|
+
"minBytes": 500,
|
|
54
|
+
"checks": [
|
|
55
|
+
{
|
|
56
|
+
"kind": "contains",
|
|
57
|
+
"file": "tasks/eval/baseline.md",
|
|
58
|
+
"pattern": "^##\\s+Current behavior[\\s\\S]*^##\\s+Measurements[\\s\\S]*^##\\s+Guardrail",
|
|
59
|
+
"flags": "im",
|
|
60
|
+
"label": "baseline sections in order"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"kind": "contains",
|
|
64
|
+
"file": "tasks/eval/baseline.md",
|
|
65
|
+
"pattern": "^##\\s+Measurements[\\s\\S]*\\d",
|
|
66
|
+
"flags": "im",
|
|
67
|
+
"label": "baseline numbers recorded"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"kind": "citationsResolve",
|
|
71
|
+
"file": "tasks/eval/baseline.md",
|
|
72
|
+
"minCitations": 2,
|
|
73
|
+
"artifact": true
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "tasks/eval/plan.md",
|
|
79
|
+
"kind": "markdown-notes",
|
|
80
|
+
"artifact": true,
|
|
81
|
+
"minBytes": 500,
|
|
82
|
+
"checks": [
|
|
83
|
+
{
|
|
84
|
+
"kind": "contains",
|
|
85
|
+
"file": "tasks/eval/plan.md",
|
|
86
|
+
"pattern": "^##\\s+Target[\\s\\S]*^##\\s+Stages[\\s\\S]*^##\\s+Acceptance criteria",
|
|
87
|
+
"flags": "im",
|
|
88
|
+
"label": "plan sections in order"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"kind": "citationsResolve",
|
|
92
|
+
"file": "tasks/eval/plan.md",
|
|
93
|
+
"minCitations": 2,
|
|
94
|
+
"artifact": true
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"path": "tasks/eval/change-notes.md",
|
|
100
|
+
"kind": "markdown-notes",
|
|
101
|
+
"artifact": true,
|
|
102
|
+
"minBytes": 600,
|
|
103
|
+
"checks": [
|
|
104
|
+
{
|
|
105
|
+
"kind": "contains",
|
|
106
|
+
"file": "tasks/eval/change-notes.md",
|
|
107
|
+
"pattern": "^##\\s+Stages executed[\\s\\S]*^##\\s+Files touched[\\s\\S]*^##\\s+Deviations from plan",
|
|
108
|
+
"flags": "im",
|
|
109
|
+
"label": "change-notes sections in order"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"kind": "citationsResolve",
|
|
113
|
+
"file": "tasks/eval/change-notes.md",
|
|
114
|
+
"minCitations": 2,
|
|
115
|
+
"artifact": true
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"path": "tasks/eval/verification.md",
|
|
121
|
+
"kind": "markdown-notes",
|
|
122
|
+
"artifact": true,
|
|
123
|
+
"minBytes": 400,
|
|
124
|
+
"checks": [
|
|
125
|
+
{
|
|
126
|
+
"kind": "contains",
|
|
127
|
+
"file": "tasks/eval/verification.md",
|
|
128
|
+
"pattern": "^##\\s+Before\\s*/\\s*after[\\s\\S]*^##\\s+Suite[\\s\\S]*^##\\s+Result",
|
|
129
|
+
"flags": "im",
|
|
130
|
+
"label": "verification sections in order"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"kind": "contains",
|
|
134
|
+
"file": "tasks/eval/verification.md",
|
|
135
|
+
"pattern": "^##\\s+Before\\s*/\\s*after[\\s\\S]*\\d",
|
|
136
|
+
"flags": "im",
|
|
137
|
+
"label": "both numbers quoted"
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"path": "tasks/eval/review.md",
|
|
143
|
+
"kind": "markdown-report",
|
|
144
|
+
"artifact": true,
|
|
145
|
+
"minBytes": 400,
|
|
146
|
+
"checks": [
|
|
147
|
+
{
|
|
148
|
+
"kind": "contains",
|
|
149
|
+
"file": "tasks/eval/review.md",
|
|
150
|
+
"pattern": "Verdict:\\s*(?:PASS|REVISE)",
|
|
151
|
+
"flags": "i",
|
|
152
|
+
"label": "explicit reviewer verdict"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"checks": [
|
|
158
|
+
{
|
|
159
|
+
"kind": "notContains",
|
|
160
|
+
"file": "src/find-duplicates.js",
|
|
161
|
+
"pattern": "for\\s*\\(let j = 0; j < items\\.length",
|
|
162
|
+
"label": "the seeded inner full-list rescan is gone"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"kind": "sourceParses",
|
|
166
|
+
"file": "src/find-duplicates.js"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"kind": "nodeScriptPasses",
|
|
170
|
+
"script": "tests/verify-perf.mjs",
|
|
171
|
+
"timeoutMs": 60000,
|
|
172
|
+
"requiredOutput": [
|
|
173
|
+
{
|
|
174
|
+
"pattern": "PERF_OPTIMIZATION_ORACLE results ok",
|
|
175
|
+
"label": "results identical to the reference"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"pattern": "PERF_OPTIMIZATION_ORACLE ops \\d+ within budget",
|
|
179
|
+
"label": "instrumented op-count under the stated budget"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"pattern": "PERF_OPTIMIZATION_ORACLE suite green",
|
|
183
|
+
"label": "suite green on the optimized tree"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
"taskNotes": {
|
|
189
|
+
"minBytes": 120,
|
|
190
|
+
"checks": [
|
|
191
|
+
{
|
|
192
|
+
"kind": "contains",
|
|
193
|
+
"file": "task-notes.md",
|
|
194
|
+
"pattern": "\\bDONE\\b[\\s\\S]*(npm\\s+run\\s+test|node\\s+--test)",
|
|
195
|
+
"flags": "i",
|
|
196
|
+
"label": "DONE note names the real test command"
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
"taskGraph": {
|
|
201
|
+
"requireCraftbookTask": true,
|
|
202
|
+
"requireTerminalStep": true
|
|
203
|
+
},
|
|
204
|
+
"unchangedFixtures": [
|
|
205
|
+
"source/perf-brief.md",
|
|
206
|
+
"package.json",
|
|
207
|
+
"src/instrument.js"
|
|
208
|
+
]
|
|
209
|
+
},
|
|
210
|
+
"rubric": {
|
|
211
|
+
"artifact": {
|
|
212
|
+
"path": "tasks/eval/verification.md",
|
|
213
|
+
"kind": "markdown"
|
|
214
|
+
},
|
|
215
|
+
"axes": [
|
|
216
|
+
{
|
|
217
|
+
"name": "Measurement honesty",
|
|
218
|
+
"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."
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "Bottleneck focus",
|
|
222
|
+
"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."
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"name": "Correctness under speed",
|
|
226
|
+
"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."
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
"qualityFocus": [
|
|
231
|
+
"numbers with their method",
|
|
232
|
+
"same-method re-measurement",
|
|
233
|
+
"enforced review loop"
|
|
234
|
+
]
|
|
235
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"title": "Behavior-preserving extraction of duplicated logic",
|
|
4
|
+
"objective": "The craftbook drives a disciplined refactor of copy-pasted name-normalization logic: a green baseline recorded before anything moves, reversible stages with the suite green throughout, a re-measured duplication target, and an enforced review — verified mechanically via a reference matrix across both call sites, a duplication count across src/, and a green-suite run.",
|
|
5
|
+
"tags": [
|
|
6
|
+
"code",
|
|
7
|
+
"refactor",
|
|
8
|
+
"tactical-fleet"
|
|
9
|
+
],
|
|
10
|
+
"prompt": "Use the Behavior-Preserving Refactor craftbook for this: the same name-normalization logic is copy-pasted in src/format-name.js and src/report.js, and the copies have drifted once already. The brief is in source/refactor-brief.md. Extract the shared logic into a new src/normalize-name.js used by both files, without changing behavior.",
|
|
11
|
+
"setup": {
|
|
12
|
+
"projectName": "Crewlog",
|
|
13
|
+
"about": "A tiny crew-hours logging module. Tests run with `npm run test` (node --test).",
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "package.json",
|
|
17
|
+
"content": "{\n \"name\": \"crewlog\",\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/format-name.js",
|
|
21
|
+
"content": "export function formatName(raw) {\n const words = String(raw).trim().split(/\\s+/);\n const fixed = [];\n for (const word of words) {\n fixed.push(word.charAt(0).toUpperCase() + word.slice(1).toLowerCase());\n }\n return fixed.join(' ');\n}\n"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "src/report.js",
|
|
25
|
+
"content": "function titleCaseName(raw) {\n const words = String(raw).trim().split(/\\s+/);\n const fixed = [];\n for (const word of words) {\n fixed.push(word.charAt(0).toUpperCase() + word.slice(1).toLowerCase());\n }\n return fixed.join(' ');\n}\n\nexport function reportLine(entry) {\n return titleCaseName(entry.name) + ': ' + entry.hours + 'h';\n}\n\nexport function reportSummary(entries) {\n return entries.map((entry) => reportLine(entry)).join('\\n');\n}\n"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "tests/format.test.mjs",
|
|
29
|
+
"content": "import assert from 'node:assert/strict';\nimport { test } from 'node:test';\nimport { formatName } from '../src/format-name.js';\n\ntest('formats a messy name', () => {\n assert.equal(formatName(' ada lovelace '), 'Ada Lovelace');\n});\n"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "tests/report.test.mjs",
|
|
33
|
+
"content": "import assert from 'node:assert/strict';\nimport { test } from 'node:test';\nimport { reportLine } from '../src/report.js';\n\ntest('report line normalizes the name', () => {\n assert.equal(reportLine({ name: 'grace hopper', hours: 2 }), 'Grace Hopper: 2h');\n});\n"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "source/refactor-brief.md",
|
|
37
|
+
"content": "# Refactor brief\n\nThe same name-normalization logic (trim, collapse inner whitespace, title-case each word) is copy-pasted in two places:\n\n- src/format-name.js - `formatName`, used by the profile screens\n- src/report.js - a private `titleCaseName` helper feeding `reportLine`\n\nThe copies drifted once before and had to be manually re-synced. Extract the shared logic into a NEW `src/normalize-name.js` module used by both files, WITHOUT changing behavior. Every output must stay byte-for-byte identical, including edge cases: extra inner spaces, ALL-CAPS input, single letters, and the empty string. Public exports must survive unchanged: `formatName`, `reportLine`, and `reportSummary` keep their names and signatures.\n"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "tests/verify-refactor.mjs",
|
|
41
|
+
"surface": "harness",
|
|
42
|
+
"content": "import assert from 'node:assert/strict';\nimport { execFileSync } from 'node:child_process';\nimport { readFileSync, readdirSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { formatName } from '../src/format-name.js';\nimport { reportLine, reportSummary } from '../src/report.js';\n\n// 1) Behavior: a reference matrix across BOTH call sites, quirks included.\nconst matrix = [\n [' ada lovelace ', 'Ada Lovelace'],\n ['GRACE HOPPER', 'Grace Hopper'],\n ['katherine g. johnson', 'Katherine G. Johnson'],\n ['a', 'A'],\n ['', ''],\n];\nfor (const [input, expected] of matrix) {\n assert.equal(formatName(input), expected, 'formatName(' + JSON.stringify(input) + ')');\n}\nassert.equal(reportLine({ name: ' grace HOPPER ', hours: 4 }), 'Grace Hopper: 4h');\nassert.equal(reportLine({ name: 'ada lovelace', hours: 2 }), 'Ada Lovelace: 2h');\nassert.equal(\n reportSummary([\n { name: 'ADA LOVELACE', hours: 1 },\n { name: ' mary jackson ', hours: 3 },\n ]),\n 'Ada Lovelace: 1h\\nMary Jackson: 3h',\n);\nconsole.log('REFACTOR_MODULE_ORACLE behavior ok');\n\n// 2) Deduplication: the title-case implementation exists at most once\n// across src/ - two surviving copies mean the extraction did not happen.\nconst root = process.cwd();\nfunction countMarker(relDir) {\n let count = 0;\n for (const entry of readdirSync(join(root, relDir), { withFileTypes: true })) {\n const relPath = relDir + '/' + entry.name;\n if (entry.isDirectory()) {\n count += countMarker(relPath);\n } else if (/\\.(js|mjs|cjs|ts)$/.test(entry.name)) {\n const text = readFileSync(join(root, relPath), 'utf8');\n count += (text.match(/toUpperCase/g) ?? []).length;\n }\n }\n return count;\n}\nconst occurrences = countMarker('src');\nassert.ok(\n occurrences <= 1,\n 'the title-case implementation appears ' + occurrences + ' times across src/ - the duplication was not extracted to one shared place',\n);\nconsole.log('REFACTOR_MODULE_ORACLE dedupe ok');\n\n// 3) The whole suite is green on the refactored 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(root), 0, 'the suite must be green on the refactored tree');\nconsole.log('REFACTOR_MODULE_ORACLE suite green');\nconsole.log('REFACTOR_MODULE_ORACLE done');\n"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"craftbookParams": {
|
|
46
|
+
"workPath": "tasks/eval",
|
|
47
|
+
"scope": "Extract the duplicated name normalization in src/format-name.js and src/report.js into a shared src/normalize-name.js used by both, without changing behavior; see source/refactor-brief.md."
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"success": {
|
|
51
|
+
"summary": "The duplicated normalization lives in exactly one place, both call sites behave byte-for-byte as before (reference matrix), the suite is green on a real run, and every fleet artifact exists with honest citations.",
|
|
52
|
+
"deliverables": [
|
|
53
|
+
{
|
|
54
|
+
"path": "tasks/eval/baseline.md",
|
|
55
|
+
"kind": "markdown-notes",
|
|
56
|
+
"artifact": true,
|
|
57
|
+
"minBytes": 500,
|
|
58
|
+
"checks": [
|
|
59
|
+
{
|
|
60
|
+
"kind": "contains",
|
|
61
|
+
"file": "tasks/eval/baseline.md",
|
|
62
|
+
"pattern": "^##\\s+Current behavior[\\s\\S]*^##\\s+Measurements[\\s\\S]*^##\\s+Guardrail",
|
|
63
|
+
"flags": "im",
|
|
64
|
+
"label": "baseline sections in order"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"kind": "citationsResolve",
|
|
68
|
+
"file": "tasks/eval/baseline.md",
|
|
69
|
+
"minCitations": 2,
|
|
70
|
+
"artifact": true
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"path": "tasks/eval/plan.md",
|
|
76
|
+
"kind": "markdown-notes",
|
|
77
|
+
"artifact": true,
|
|
78
|
+
"minBytes": 500,
|
|
79
|
+
"checks": [
|
|
80
|
+
{
|
|
81
|
+
"kind": "contains",
|
|
82
|
+
"file": "tasks/eval/plan.md",
|
|
83
|
+
"pattern": "^##\\s+Target[\\s\\S]*^##\\s+Stages[\\s\\S]*^##\\s+Acceptance criteria",
|
|
84
|
+
"flags": "im",
|
|
85
|
+
"label": "plan sections in order"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"kind": "citationsResolve",
|
|
89
|
+
"file": "tasks/eval/plan.md",
|
|
90
|
+
"minCitations": 2,
|
|
91
|
+
"artifact": true
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"path": "tasks/eval/change-notes.md",
|
|
97
|
+
"kind": "markdown-notes",
|
|
98
|
+
"artifact": true,
|
|
99
|
+
"minBytes": 600,
|
|
100
|
+
"checks": [
|
|
101
|
+
{
|
|
102
|
+
"kind": "contains",
|
|
103
|
+
"file": "tasks/eval/change-notes.md",
|
|
104
|
+
"pattern": "^##\\s+Stages executed[\\s\\S]*^##\\s+Files touched[\\s\\S]*^##\\s+Deviations from plan",
|
|
105
|
+
"flags": "im",
|
|
106
|
+
"label": "change-notes sections in order"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"kind": "citationsResolve",
|
|
110
|
+
"file": "tasks/eval/change-notes.md",
|
|
111
|
+
"minCitations": 2,
|
|
112
|
+
"artifact": true
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"path": "tasks/eval/verification.md",
|
|
118
|
+
"kind": "markdown-notes",
|
|
119
|
+
"artifact": true,
|
|
120
|
+
"minBytes": 400,
|
|
121
|
+
"checks": [
|
|
122
|
+
{
|
|
123
|
+
"kind": "contains",
|
|
124
|
+
"file": "tasks/eval/verification.md",
|
|
125
|
+
"pattern": "^##\\s+Before\\s*/\\s*after[\\s\\S]*^##\\s+Suite[\\s\\S]*^##\\s+Result",
|
|
126
|
+
"flags": "im",
|
|
127
|
+
"label": "verification sections in order"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"kind": "contains",
|
|
131
|
+
"file": "tasks/eval/verification.md",
|
|
132
|
+
"pattern": "^##\\s+Before\\s*/\\s*after[\\s\\S]*\\d",
|
|
133
|
+
"flags": "im",
|
|
134
|
+
"label": "before/after figures quoted"
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"path": "tasks/eval/review.md",
|
|
140
|
+
"kind": "markdown-report",
|
|
141
|
+
"artifact": true,
|
|
142
|
+
"minBytes": 400,
|
|
143
|
+
"checks": [
|
|
144
|
+
{
|
|
145
|
+
"kind": "contains",
|
|
146
|
+
"file": "tasks/eval/review.md",
|
|
147
|
+
"pattern": "Verdict:\\s*(?:PASS|REVISE)",
|
|
148
|
+
"flags": "i",
|
|
149
|
+
"label": "explicit reviewer verdict"
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"checks": [
|
|
155
|
+
{
|
|
156
|
+
"kind": "notContains",
|
|
157
|
+
"file": "src/format-name.js",
|
|
158
|
+
"pattern": "toUpperCase",
|
|
159
|
+
"label": "format-name.js no longer carries its own title-case copy"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"kind": "notContains",
|
|
163
|
+
"file": "src/report.js",
|
|
164
|
+
"pattern": "toUpperCase",
|
|
165
|
+
"label": "report.js no longer carries its own title-case copy"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"kind": "sourceParses",
|
|
169
|
+
"file": "src/format-name.js"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"kind": "sourceParses",
|
|
173
|
+
"file": "src/report.js"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"kind": "nodeScriptPasses",
|
|
177
|
+
"script": "tests/verify-refactor.mjs",
|
|
178
|
+
"timeoutMs": 60000,
|
|
179
|
+
"requiredOutput": [
|
|
180
|
+
{
|
|
181
|
+
"pattern": "REFACTOR_MODULE_ORACLE behavior ok",
|
|
182
|
+
"label": "both call sites match the reference matrix"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"pattern": "REFACTOR_MODULE_ORACLE dedupe ok",
|
|
186
|
+
"label": "the implementation exists at most once across src/"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"pattern": "REFACTOR_MODULE_ORACLE suite green",
|
|
190
|
+
"label": "suite green on the refactored tree"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"taskNotes": {
|
|
196
|
+
"minBytes": 120,
|
|
197
|
+
"checks": [
|
|
198
|
+
{
|
|
199
|
+
"kind": "contains",
|
|
200
|
+
"file": "task-notes.md",
|
|
201
|
+
"pattern": "\\bDONE\\b[\\s\\S]*(npm\\s+run\\s+test|node\\s+--test)",
|
|
202
|
+
"flags": "i",
|
|
203
|
+
"label": "DONE note names the real test command"
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
"taskGraph": {
|
|
208
|
+
"requireCraftbookTask": true,
|
|
209
|
+
"requireTerminalStep": true
|
|
210
|
+
},
|
|
211
|
+
"unchangedFixtures": [
|
|
212
|
+
"source/refactor-brief.md",
|
|
213
|
+
"package.json"
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
"rubric": {
|
|
217
|
+
"artifact": {
|
|
218
|
+
"path": "tasks/eval/change-notes.md",
|
|
219
|
+
"kind": "markdown"
|
|
220
|
+
},
|
|
221
|
+
"axes": [
|
|
222
|
+
{
|
|
223
|
+
"name": "Guardrail-first discipline",
|
|
224
|
+
"description": "The suite was genuinely run and recorded green before any restructuring, characterization coverage was considered honestly, and the baseline counted the duplication with a stated method."
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"name": "Reversible-stage execution",
|
|
228
|
+
"description": "The restructure happened in small planned stages at the real sites, with the suite kept green between stages and deviations recorded honestly rather than papered over."
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"name": "Genuine deduplication",
|
|
232
|
+
"description": "One shared implementation remains, both call sites use it, public exports survived unchanged, and no behavior change was smuggled in under cover of the refactor."
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
"qualityFocus": [
|
|
237
|
+
"green-before/green-after receipts",
|
|
238
|
+
"same-method re-measurement",
|
|
239
|
+
"enforced review loop"
|
|
240
|
+
]
|
|
241
|
+
}
|