@bendyline/gilde 0.1.40 → 0.1.42
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/po/powerpoint-deck/versions/1.7.4/test.json +0 -1
- package/data/craftbook-templates/pu/pull-request-review/versions/1.8.0/craftbook.json +304 -0
- package/data/craftbook-templates/pu/pull-request-review/versions/1.8.0/test.json +144 -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,225 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"title": "Expand/contract data migration with no record stranded",
|
|
4
|
+
"objective": "The craftbook drives an expand/contract migration of a JSON user store from a flat name field to a nested profile shape: a plan grounded in the real files, accessors changed at their real sites with the suite green between stages, the data transformed with every value surviving exactly, and the old shape fully retired - verified mechanically, including a pure-nested-record probe proving the dual-read did not linger.",
|
|
5
|
+
"tags": [
|
|
6
|
+
"code",
|
|
7
|
+
"schema-migration",
|
|
8
|
+
"expand-contract",
|
|
9
|
+
"tactical-fleet"
|
|
10
|
+
],
|
|
11
|
+
"prompt": "Use the Schema / Type Migration craftbook for this: migrate our user records from the flat name field to the nested profile shape described in source/migration-brief.md. No record may be lost, the accessors in src/users.js must keep working at every stage, and when it is done nothing may read the flat field any more.",
|
|
12
|
+
"setup": {
|
|
13
|
+
"projectName": "Crew Roster",
|
|
14
|
+
"about": "A tiny user-roster module backed by a JSON data file. Tests run with `npm run test` (node --test).",
|
|
15
|
+
"files": [
|
|
16
|
+
{
|
|
17
|
+
"path": "package.json",
|
|
18
|
+
"content": "{\n \"name\": \"crew-roster\",\n \"private\": true,\n \"version\": \"1.0.0\",\n \"type\": \"module\",\n \"scripts\": {\n \"test\": \"node --test\"\n }\n}\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "data/users.json",
|
|
22
|
+
"content": "[\n { \"id\": 1, \"name\": \"Ada Lovelace\", \"email\": \"ada@example.com\" },\n { \"id\": 2, \"name\": \"Grace Hopper\", \"email\": \"grace@example.com\" },\n { \"id\": 3, \"name\": \"Annie Easley\", \"email\": \"annie@example.com\" }\n]\n"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"path": "src/users.js",
|
|
26
|
+
"content": "import { readFileSync } from 'node:fs';\n\nconst DB_URL = new URL('../data/users.json', import.meta.url);\n\nexport function loadUsers() {\n return JSON.parse(readFileSync(DB_URL, 'utf8'));\n}\n\nexport function fullName(user) {\n return user.name;\n}\n\nexport function byFullName(users, wanted) {\n return users.find((user) => user.name === wanted);\n}\n"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"path": "tests/users.test.mjs",
|
|
30
|
+
"content": "import assert from 'node:assert/strict';\nimport { test } from 'node:test';\nimport { byFullName, fullName, loadUsers } from '../src/users.js';\n\ntest('loads every user record', () => {\n assert.equal(loadUsers().length, 3);\n});\n\ntest('fullName renders the display name', () => {\n assert.deepEqual(loadUsers().map(fullName), [\n 'Ada Lovelace',\n 'Grace Hopper',\n 'Annie Easley',\n ]);\n});\n\ntest('byFullName finds a user by display name', () => {\n assert.equal(byFullName(loadUsers(), 'Grace Hopper').email, 'grace@example.com');\n});\n"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"path": "source/migration-brief.md",
|
|
34
|
+
"content": "# Migration brief: nested profile shape\n\nWe sort and filter by last name now, so the flat `name` field has to go.\n\nCurrent record shape in `data/users.json`:\n\n { \"id\": 1, \"name\": \"Ada Lovelace\", \"email\": \"ada@example.com\" }\n\nTarget record shape:\n\n { \"id\": 1, \"profile\": { \"first\": \"Ada\", \"last\": \"Lovelace\" }, \"email\": \"ada@example.com\" }\n\nRules:\n\n- Every existing record must survive the migration exactly - same people, same\n emails, names split on the single space between first and last name.\n- The accessors in `src/users.js` must keep working for their callers at every\n stage: `fullName` and `byFullName` keep returning the same display names as\n today.\n- When the migration is done, nothing reads the flat `name` field any more.\n"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"path": "tests/verify-migration.mjs",
|
|
38
|
+
"surface": "harness",
|
|
39
|
+
"content": "import assert from 'node:assert/strict';\nimport { execFileSync } from 'node:child_process';\nimport { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nconst root = process.cwd();\n\n// 1) The data moved to the target shape with no record stranded.\nconst records = JSON.parse(readFileSync(join(root, 'data/users.json'), 'utf8'));\nassert.ok(Array.isArray(records), 'data/users.json must stay a JSON array');\nassert.equal(records.length, 3, 'all three records must survive the migration');\nconst expected = new Map([\n ['ada@example.com', ['Ada', 'Lovelace']],\n ['grace@example.com', ['Grace', 'Hopper']],\n ['annie@example.com', ['Annie', 'Easley']],\n]);\nfor (const record of records) {\n assert.ok(record && typeof record === 'object', 'each record must stay an object');\n assert.ok(!('name' in record), `record ${record.id} still carries the flat name field`);\n const want = expected.get(record.email);\n assert.ok(want, `record ${record.id} lost or changed its email`);\n assert.equal(record.profile?.first, want[0], `record ${record.id} must keep its first name exactly`);\n assert.equal(record.profile?.last, want[1], `record ${record.id} must keep its last name exactly`);\n}\nconsole.log('SCHEMAMIG_ORACLE data intact');\n\n// 2) The accessors read the new shape - a pure nested record, no flat fallback.\nconst users = await import(pathToFileURL(join(root, 'src/users.js')).href);\nassert.equal(\n users.fullName({ profile: { first: 'Test', last: 'User' } }),\n 'Test User',\n 'fullName must read profile.first and profile.last',\n);\nassert.equal(\n users.byFullName([{ profile: { first: 'Grace', last: 'Hopper' }, email: 'x' }], 'Grace Hopper')?.email,\n 'x',\n 'byFullName must match display names on the new shape',\n);\nconsole.log('SCHEMAMIG_ORACLE accessors migrated');\n\n// 3) Contract landed: no flat-shape read remains in the accessor module.\nconst accessorSource = readFileSync(join(root, 'src/users.js'), 'utf8');\nassert.ok(\n !/\\.name\\b|\\[[\"']name[\"']\\]/.test(accessorSource),\n 'src/users.js still reads the flat name field',\n);\nconsole.log('SCHEMAMIG_ORACLE contract complete');\n\n// 4) The suite is green on the migrated tree, and the seeded test file survives.\nreadFileSync(join(root, 'tests/users.test.mjs'));\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 after the migration');\nconsole.log('SCHEMAMIG_ORACLE suite green');\nconsole.log('SCHEMAMIG_ORACLE done');\n"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"craftbookParams": {
|
|
43
|
+
"workPath": "tasks/eval",
|
|
44
|
+
"scope": "Migrate data/users.json and src/users.js from the flat name field to profile.first/profile.last per source/migration-brief.md, with no record loss and reads working at every stage."
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"success": {
|
|
48
|
+
"summary": "Every record reaches the nested profile shape with its values intact, the accessors read the new shape with the dual-read retired, the flat field is gone from data and code, the suite is green, and every fleet artifact exists with honest receipts.",
|
|
49
|
+
"deliverables": [
|
|
50
|
+
{
|
|
51
|
+
"path": "tasks/eval/migration-plan.md",
|
|
52
|
+
"kind": "markdown-notes",
|
|
53
|
+
"artifact": true,
|
|
54
|
+
"minBytes": 700,
|
|
55
|
+
"checks": [
|
|
56
|
+
{
|
|
57
|
+
"kind": "contains",
|
|
58
|
+
"file": "tasks/eval/migration-plan.md",
|
|
59
|
+
"pattern": "^##\\s+Current shape[\\s\\S]*^##\\s+Target shape[\\s\\S]*^##\\s+Stages[\\s\\S]*^##\\s+Data safety[\\s\\S]*^##\\s+Rollback per stage",
|
|
60
|
+
"flags": "im",
|
|
61
|
+
"label": "plan sections in order"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"kind": "contains",
|
|
65
|
+
"file": "tasks/eval/migration-plan.md",
|
|
66
|
+
"pattern": "data/users\\.json",
|
|
67
|
+
"label": "names the real data file"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"kind": "citationsResolve",
|
|
71
|
+
"file": "tasks/eval/migration-plan.md",
|
|
72
|
+
"minCitations": 2,
|
|
73
|
+
"artifact": true
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "tasks/eval/change-notes.md",
|
|
79
|
+
"kind": "markdown-notes",
|
|
80
|
+
"artifact": true,
|
|
81
|
+
"minBytes": 700,
|
|
82
|
+
"checks": [
|
|
83
|
+
{
|
|
84
|
+
"kind": "contains",
|
|
85
|
+
"file": "tasks/eval/change-notes.md",
|
|
86
|
+
"pattern": "^##\\s+Stages executed[\\s\\S]*^##\\s+Files touched[\\s\\S]*^##\\s+Data transformed[\\s\\S]*^##\\s+Deviations",
|
|
87
|
+
"flags": "im",
|
|
88
|
+
"label": "change-notes sections in order"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"kind": "citationsResolve",
|
|
92
|
+
"file": "tasks/eval/change-notes.md",
|
|
93
|
+
"minCitations": 2,
|
|
94
|
+
"artifact": true
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"path": "tasks/eval/verification.md",
|
|
100
|
+
"kind": "markdown-notes",
|
|
101
|
+
"artifact": true,
|
|
102
|
+
"minBytes": 500,
|
|
103
|
+
"checks": [
|
|
104
|
+
{
|
|
105
|
+
"kind": "contains",
|
|
106
|
+
"file": "tasks/eval/verification.md",
|
|
107
|
+
"pattern": "^##\\s+Old shape check[\\s\\S]*^##\\s+Data integrity[\\s\\S]*^##\\s+Suite[\\s\\S]*^##\\s+Result",
|
|
108
|
+
"flags": "im",
|
|
109
|
+
"label": "verification sections in order"
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"path": "tasks/eval/review.md",
|
|
115
|
+
"kind": "markdown-report",
|
|
116
|
+
"artifact": true,
|
|
117
|
+
"minBytes": 400,
|
|
118
|
+
"checks": [
|
|
119
|
+
{
|
|
120
|
+
"kind": "contains",
|
|
121
|
+
"file": "tasks/eval/review.md",
|
|
122
|
+
"pattern": "Verdict:\\s*(?:PASS|REVISE)",
|
|
123
|
+
"flags": "i",
|
|
124
|
+
"label": "explicit reviewer verdict"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"checks": [
|
|
130
|
+
{
|
|
131
|
+
"kind": "notContains",
|
|
132
|
+
"file": "data/users.json",
|
|
133
|
+
"pattern": "\"name\"\\s*:",
|
|
134
|
+
"label": "the flat name field is gone from the data"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"kind": "notContains",
|
|
138
|
+
"file": "src/users.js",
|
|
139
|
+
"pattern": "\\.name\\b|\\[[\"']name[\"']\\]",
|
|
140
|
+
"label": "no flat-shape read remains in the accessors"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"kind": "sourceParses",
|
|
144
|
+
"file": "src/users.js"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"kind": "sniff",
|
|
148
|
+
"file": "data/users.json",
|
|
149
|
+
"sniff": "json-valid"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"kind": "nodeRuns",
|
|
153
|
+
"file": "tests/users.test.mjs"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"kind": "nodeScriptPasses",
|
|
157
|
+
"script": "tests/verify-migration.mjs",
|
|
158
|
+
"timeoutMs": 60000,
|
|
159
|
+
"requiredOutput": [
|
|
160
|
+
{
|
|
161
|
+
"pattern": "SCHEMAMIG_ORACLE data intact",
|
|
162
|
+
"label": "every record migrated with values intact"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"pattern": "SCHEMAMIG_ORACLE accessors migrated",
|
|
166
|
+
"label": "accessors read the new shape"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"pattern": "SCHEMAMIG_ORACLE contract complete",
|
|
170
|
+
"label": "the dual-read retired with the old shape"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"pattern": "SCHEMAMIG_ORACLE suite green",
|
|
174
|
+
"label": "suite green on the migrated tree"
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"taskNotes": {
|
|
180
|
+
"minBytes": 120,
|
|
181
|
+
"checks": [
|
|
182
|
+
{
|
|
183
|
+
"kind": "contains",
|
|
184
|
+
"file": "task-notes.md",
|
|
185
|
+
"pattern": "\\bDONE\\b[\\s\\S]*(npm\\s+run\\s+test|node\\s+--test)",
|
|
186
|
+
"flags": "i",
|
|
187
|
+
"label": "DONE note names the real test command"
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
"taskGraph": {
|
|
192
|
+
"requireCraftbookTask": true,
|
|
193
|
+
"requireTerminalStep": true
|
|
194
|
+
},
|
|
195
|
+
"unchangedFixtures": [
|
|
196
|
+
"source/migration-brief.md",
|
|
197
|
+
"package.json"
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
"rubric": {
|
|
201
|
+
"artifact": {
|
|
202
|
+
"path": "tasks/eval/change-notes.md",
|
|
203
|
+
"kind": "markdown"
|
|
204
|
+
},
|
|
205
|
+
"axes": [
|
|
206
|
+
{
|
|
207
|
+
"name": "Expand/contract discipline",
|
|
208
|
+
"description": "The stages genuinely followed expand, migrate, contract in order - readers accepted both shapes while the data moved, and the old shape was dropped only after the transform completed with a green suite."
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "Data preservation",
|
|
212
|
+
"description": "The transform is real and lossless: every record reached the target shape with names and emails surviving exactly, proven by counts and spot-checks rather than asserted."
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"name": "Honest verification",
|
|
216
|
+
"description": "Verification searched for leftover old-shape reads, quoted what it found, ran the real suite, and labeled anything unrun as unverified instead of claiming it."
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
"qualityFocus": [
|
|
221
|
+
"expand/contract data safety",
|
|
222
|
+
"no record stranded",
|
|
223
|
+
"real-site accessor changes"
|
|
224
|
+
]
|
|
225
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"title": "Test backfill proven by mutants",
|
|
4
|
+
"objective": "The craftbook drives a risk-ranked backfill of an untested date-range module. The oracle proves the new tests bite: three seeded mutations (an exclusive boundary, a duration off-by-one, overlap collapsed to containment) are applied in copies and the model's suite must fail at least two of them while staying green on the real tree — with the module under test byte-identical to the fixture.",
|
|
5
|
+
"tags": [
|
|
6
|
+
"code",
|
|
7
|
+
"tests",
|
|
8
|
+
"coverage",
|
|
9
|
+
"tactical-fleet"
|
|
10
|
+
],
|
|
11
|
+
"prompt": "Use the Test Suite Backfill craftbook: src/date-range.js schedules bookings across the product and has no tests at all — tests/ only covers the formatter. Backfill a meaningful suite for the date-range module in the existing test layout, highest-risk behavior first: its bounds are inclusive on both ends and an inverted range must throw.",
|
|
12
|
+
"setup": {
|
|
13
|
+
"projectName": "Booking Ranges",
|
|
14
|
+
"about": "A tiny scheduling library. Tests run with `npm run test` (node --test). src/date-range.js is untested; src/format.js has an existing test that shows the layout and style.",
|
|
15
|
+
"files": [
|
|
16
|
+
{
|
|
17
|
+
"path": "package.json",
|
|
18
|
+
"content": "{\n \"name\": \"booking-ranges\",\n \"private\": true,\n \"version\": \"1.0.0\",\n \"type\": \"module\",\n \"scripts\": {\n \"test\": \"node --test\"\n }\n}\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "src/date-range.js",
|
|
22
|
+
"content": "// Inclusive [start, end] day ranges. Days are ISO strings like '2026-03-14'.\nconst DAY_MS = 86400000;\n\nfunction dayValue(day) {\n if (typeof day !== 'string' || !/^\\d{4}-\\d{2}-\\d{2}$/.test(day)) {\n throw new Error(`invalid day: ${day}`);\n }\n const value = Date.parse(`${day}T00:00:00Z`);\n if (Number.isNaN(value)) throw new Error(`invalid day: ${day}`);\n return value;\n}\n\nfunction assertRange(range) {\n const start = dayValue(range.start);\n const end = dayValue(range.end);\n if (start > end) {\n throw new Error(`invalid range: ${range.start} is after ${range.end}`);\n }\n return { start, end };\n}\n\nexport function overlaps(a, b) {\n const ra = assertRange(a);\n const rb = assertRange(b);\n return ra.start <= rb.end && rb.start <= ra.end;\n}\n\nexport function containsDay(range, day) {\n const r = assertRange(range);\n const d = dayValue(day);\n return d >= r.start && d <= r.end;\n}\n\nexport function durationDays(range) {\n const r = assertRange(range);\n return Math.round((r.end - r.start) / DAY_MS) + 1;\n}\n"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"path": "src/format.js",
|
|
26
|
+
"content": "export function slugify(text) {\n return String(text)\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"path": "tests/format.test.mjs",
|
|
30
|
+
"content": "import assert from 'node:assert/strict';\nimport { test } from 'node:test';\nimport { slugify } from '../src/format.js';\n\ntest('slugify collapses spaces and punctuation', () => {\n assert.equal(slugify('Walnut writing desk!'), 'walnut-writing-desk');\n});\n\ntest('slugify trims stray dashes', () => {\n assert.equal(slugify(' --Oak shelf-- '), 'oak-shelf');\n});\n"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"path": "tests/verify-backfill.mjs",
|
|
34
|
+
"surface": "harness",
|
|
35
|
+
"content": "import assert from 'node:assert/strict';\nimport { execFileSync } from 'node:child_process';\nimport { cpSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nconst root = process.cwd();\nconst ORACLE = 'verify-backfill.mjs';\n\n// Bare `node --test` discovery: finds tests/**/*.test.* from cwd and skips\n// dot-directories, so the .oracle-* mutant copies never leak into a run.\n// (A literal `--test tests/` directory argument no longer resolves on\n// modern Node - it is treated as a module path.)\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}\n\n// 1) New tests exist in the real layout and target the date-range module.\nconst testFiles = readdirSync(join(root, 'tests'), { recursive: true })\n .map(String)\n .filter((f) => /\\.test\\.(mjs|js|cjs)$/.test(f) && !f.endsWith('format.test.mjs'));\nassert.ok(testFiles.length >= 1, 'no new test file found in tests/');\nconst newTestText = testFiles.map((f) => readFileSync(join(root, 'tests', f), 'utf8')).join('\\n');\nassert.ok(/date-range/.test(newTestText), 'the new tests never reference the date-range module');\nconsole.log('BACKFILL_ORACLE new tests found');\n\n// 2) The suite is green on the real tree.\nassert.equal(runSuite(root), 0, 'the suite must pass on the real tree');\nconsole.log('BACKFILL_ORACLE suite green');\n\n// 3) Seeded defects in copies must make the new suite fail - proof the tests bite.\nconst source = readFileSync(join(root, 'src', 'date-range.js'), 'utf8');\nfunction mutantCaught(name, mutate) {\n const mroot = join(root, `.oracle-${name}`);\n rmSync(mroot, { recursive: true, force: true });\n mkdirSync(mroot, { recursive: true });\n cpSync(join(root, 'src'), join(mroot, 'src'), { recursive: true });\n cpSync(join(root, 'tests'), join(mroot, 'tests'), { recursive: true });\n rmSync(join(mroot, 'tests', ORACLE), { force: true });\n cpSync(join(root, 'package.json'), join(mroot, 'package.json'));\n const mutated = mutate(source);\n assert.notEqual(mutated, source, `mutation ${name} failed to apply - src/date-range.js was altered`);\n writeFileSync(join(mroot, 'src', 'date-range.js'), mutated);\n const caught = runSuite(mroot) !== 0;\n console.log(`BACKFILL_ORACLE mutant ${name} ${caught ? 'caught' : 'MISSED'}`);\n return caught;\n}\n\nconst caught = [\n mutantCaught('boundary', (s) => s.replace('rb.start <= ra.end', 'rb.start < ra.end')),\n mutantCaught('duration', (s) => s.replace('/ DAY_MS) + 1', '/ DAY_MS)')),\n mutantCaught('containment', (s) => s.replace('ra.start <= rb.end && rb.start <= ra.end', 'ra.start <= rb.start && rb.end <= ra.end')),\n].filter(Boolean).length;\nassert.ok(caught >= 2, `the new tests caught only ${caught}/3 seeded defects - they do not pin real behavior`);\nconsole.log(`BACKFILL_ORACLE mutants ${caught}/3`);\nconsole.log('BACKFILL_ORACLE done');\n"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"craftbookParams": {
|
|
39
|
+
"workPath": "tasks/eval"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"success": {
|
|
43
|
+
"summary": "New tests for the date-range module live in the real layout, the whole suite is green on the untouched tree, and the tests catch at least two of three seeded mutations — with every fleet artifact present and honestly cited.",
|
|
44
|
+
"deliverables": [
|
|
45
|
+
{
|
|
46
|
+
"path": "tasks/eval/risk-map.md",
|
|
47
|
+
"kind": "markdown-notes",
|
|
48
|
+
"artifact": true,
|
|
49
|
+
"minBytes": 500,
|
|
50
|
+
"checks": [
|
|
51
|
+
{
|
|
52
|
+
"kind": "contains",
|
|
53
|
+
"file": "tasks/eval/risk-map.md",
|
|
54
|
+
"pattern": "^##\\s+Modules[\\s\\S]*^##\\s+Risks ranked[\\s\\S]*^##\\s+Chosen targets",
|
|
55
|
+
"flags": "im",
|
|
56
|
+
"label": "risk-map sections in order"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"kind": "contains",
|
|
60
|
+
"file": "tasks/eval/risk-map.md",
|
|
61
|
+
"pattern": "src/date-range\\.js",
|
|
62
|
+
"label": "names the real target module"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"kind": "citationsResolve",
|
|
66
|
+
"file": "tasks/eval/risk-map.md",
|
|
67
|
+
"minCitations": 2,
|
|
68
|
+
"artifact": true
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"path": "tasks/eval/test-notes.md",
|
|
74
|
+
"kind": "markdown-notes",
|
|
75
|
+
"artifact": true,
|
|
76
|
+
"minBytes": 600,
|
|
77
|
+
"checks": [
|
|
78
|
+
{
|
|
79
|
+
"kind": "contains",
|
|
80
|
+
"file": "tasks/eval/test-notes.md",
|
|
81
|
+
"pattern": "^##\\s+Tests added[\\s\\S]*^##\\s+Behaviors pinned[\\s\\S]*^##\\s+How each test would catch a realistic break",
|
|
82
|
+
"flags": "im",
|
|
83
|
+
"label": "test-notes sections in order"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"kind": "citationsResolve",
|
|
87
|
+
"file": "tasks/eval/test-notes.md",
|
|
88
|
+
"minCitations": 2,
|
|
89
|
+
"artifact": true
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"path": "tasks/eval/verification.md",
|
|
95
|
+
"kind": "markdown-notes",
|
|
96
|
+
"artifact": true,
|
|
97
|
+
"minBytes": 400,
|
|
98
|
+
"checks": [
|
|
99
|
+
{
|
|
100
|
+
"kind": "contains",
|
|
101
|
+
"file": "tasks/eval/verification.md",
|
|
102
|
+
"pattern": "^##\\s+Suite[\\s\\S]*^##\\s+Coverage summary[\\s\\S]*^##\\s+Result",
|
|
103
|
+
"flags": "im",
|
|
104
|
+
"label": "verification sections in order"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"path": "tasks/eval/review.md",
|
|
110
|
+
"kind": "markdown-report",
|
|
111
|
+
"artifact": true,
|
|
112
|
+
"minBytes": 400,
|
|
113
|
+
"checks": [
|
|
114
|
+
{
|
|
115
|
+
"kind": "contains",
|
|
116
|
+
"file": "tasks/eval/review.md",
|
|
117
|
+
"pattern": "Verdict:\\s*(?:PASS|REVISE)",
|
|
118
|
+
"flags": "i",
|
|
119
|
+
"label": "explicit reviewer verdict"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"checks": [
|
|
125
|
+
{
|
|
126
|
+
"kind": "nodeRuns",
|
|
127
|
+
"file": "tests/format.test.mjs"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"kind": "nodeScriptPasses",
|
|
131
|
+
"script": "tests/verify-backfill.mjs",
|
|
132
|
+
"timeoutMs": 120000,
|
|
133
|
+
"requiredOutput": [
|
|
134
|
+
{
|
|
135
|
+
"pattern": "BACKFILL_ORACLE new tests found",
|
|
136
|
+
"label": "new tests exist in the real layout"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"pattern": "BACKFILL_ORACLE suite green",
|
|
140
|
+
"label": "the whole suite passes on the real tree"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"pattern": "BACKFILL_ORACLE mutants [23]/3",
|
|
144
|
+
"label": "the new tests catch seeded defects"
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"taskNotes": {
|
|
150
|
+
"minBytes": 120,
|
|
151
|
+
"checks": [
|
|
152
|
+
{
|
|
153
|
+
"kind": "contains",
|
|
154
|
+
"file": "task-notes.md",
|
|
155
|
+
"pattern": "\\bDONE\\b[\\s\\S]*(npm\\s+run\\s+test|node\\s+--test)",
|
|
156
|
+
"flags": "i",
|
|
157
|
+
"label": "DONE note names the real test command"
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
"taskGraph": {
|
|
162
|
+
"requireCraftbookTask": true,
|
|
163
|
+
"requireTerminalStep": true
|
|
164
|
+
},
|
|
165
|
+
"unchangedFixtures": [
|
|
166
|
+
"package.json",
|
|
167
|
+
"src/date-range.js",
|
|
168
|
+
"src/format.js",
|
|
169
|
+
"tests/format.test.mjs"
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
"rubric": {
|
|
173
|
+
"artifact": {
|
|
174
|
+
"path": "tasks/eval/test-notes.md",
|
|
175
|
+
"kind": "markdown"
|
|
176
|
+
},
|
|
177
|
+
"axes": [
|
|
178
|
+
{
|
|
179
|
+
"name": "Risk-driven targeting",
|
|
180
|
+
"description": "The tests pin the behaviors whose silent breakage costs most — inclusive bounds, duration arithmetic, the invalid-range throw — following the risk map rather than the easiest paths."
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "Tests that bite",
|
|
184
|
+
"description": "Each test asserts real values, errors, and edge cases a wrong implementation would fail; no tautologies, and seeded mutations to the module are actually caught."
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"name": "Layout fidelity and honesty",
|
|
188
|
+
"description": "Tests follow the existing layout and style, the suite result comes from real runs, the module under test is untouched, and uncovered targets are deferred honestly."
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
"qualityFocus": [
|
|
193
|
+
"mutation-proof regression guards",
|
|
194
|
+
"risk-ranked coverage",
|
|
195
|
+
"enforced review of assertions"
|
|
196
|
+
]
|
|
197
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"title": "Counted tightening of seeded unsafe patterns",
|
|
4
|
+
"objective": "The craftbook drives a counted type-safety pass over a module with three seeded unsafe patterns and their real consequences: a loose-equality guard that lets 0 through, an implicit string-number concat corrupting a total, and a swallowed catch hiding data loss. Verified mechanically: the patterns are structurally gone, the three behavioral consequences are fixed by probes, the suite is green, and the fleet artifacts quote honest before/after counts.",
|
|
5
|
+
"tags": [
|
|
6
|
+
"code",
|
|
7
|
+
"type-safety",
|
|
8
|
+
"tactical-fleet"
|
|
9
|
+
],
|
|
10
|
+
"prompt": "Use the Type-Safety Pass craftbook for this: src/expenses.js has unsafe patterns with real consequences - splitting across zero people returns Infinity, string amounts silently corrupt the running total, and corrupt imports vanish without a trace. The brief is in source/cleanup-brief.md. Tighten the module and fix those three consequences without breaking the pinned happy-path behavior.",
|
|
11
|
+
"setup": {
|
|
12
|
+
"projectName": "Expense Tracker",
|
|
13
|
+
"about": "A tiny expense-tracking module. Tests run with `npm run test` (node --test).",
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "package.json",
|
|
17
|
+
"content": "{\n \"name\": \"expense-tracker\",\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/expenses.js",
|
|
21
|
+
"content": "const DEFAULT_CATEGORY = 'general';\n\nexport function splitEvenly(total, people) {\n if (people == null) throw new Error('people required');\n return Math.round((total / people) * 100) / 100;\n}\n\nexport function addExpense(report, entry) {\n report.total = report.total + entry.amount;\n report.entries.push({\n label: entry.label,\n amount: entry.amount,\n category: entry.category || DEFAULT_CATEGORY,\n });\n return report;\n}\n\nexport function importEntry(report, json) {\n try {\n const entry = JSON.parse(json);\n return addExpense(report, entry);\n } catch (err) {\n return report;\n }\n}\n"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "tests/expenses.test.mjs",
|
|
25
|
+
"content": "import assert from 'node:assert/strict';\nimport { test } from 'node:test';\nimport { addExpense, importEntry, splitEvenly } from '../src/expenses.js';\n\ntest('splits evenly with rounding', () => {\n assert.equal(splitEvenly(100, 4), 25);\n assert.equal(splitEvenly(100, 3), 33.33);\n});\n\ntest('adds numeric expenses', () => {\n const report = { total: 0, entries: [] };\n addExpense(report, { label: 'lunch', amount: 12 });\n assert.equal(report.total, 12);\n assert.equal(report.entries.length, 1);\n});\n\ntest('imports a valid entry', () => {\n const report = { total: 0, entries: [] };\n importEntry(report, '{\"label\":\"bus\",\"amount\":3}');\n assert.equal(report.entries.length, 1);\n});\n"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "source/cleanup-brief.md",
|
|
29
|
+
"content": "# Cleanup brief\n\nsrc/expenses.js has unsafe patterns with three consequences we can reproduce:\n\n1. `splitEvenly(100, 0)` returns `Infinity` - the loose `== null` guard lets `0` through. Splitting across zero people must throw, exactly like a missing count.\n2. Legacy JSON entries sometimes carry `amount` as a numeric string like `\"12.50\"`. `addExpense` then concatenates instead of adding and the running total silently becomes a string like `\"1012.50\"`. A string amount must be treated as the number it spells, and a total must always stay a number.\n3. `importEntry` swallows every parse error, so a corrupt import vanishes without a trace - we lost a day of expenses to this once. A corrupt import must throw, not return as if nothing happened.\n\nTighten the module: strict checks instead of loose equality, validate or normalize values at the boundary they cross, surface errors instead of swallowing them. Happy-path behavior pinned by the tests must not change. Do not silence anything to make a count fall.\n"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "tests/verify-expenses.mjs",
|
|
33
|
+
"surface": "harness",
|
|
34
|
+
"content": "import assert from 'node:assert/strict';\nimport { execFileSync } from 'node:child_process';\nimport { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { addExpense, importEntry, splitEvenly } from '../src/expenses.js';\n\n// 1) Structural: the seeded unsafe patterns are gone from the module.\nconst source = readFileSync(join(process.cwd(), 'src', 'expenses.js'), 'utf8');\nassert.ok(\n !/(^|[^=!<>])==[^=]|!=[^=]/.test(source),\n 'loose equality is still present in src/expenses.js',\n);\nassert.ok(\n !/catch[^{]*\\{\\s*\\}/.test(source),\n 'an empty catch still swallows errors in src/expenses.js',\n);\nassert.ok(\n !/@ts-ignore|@ts-expect-error|eslint-disable/.test(source),\n 'a suppression comment was introduced to move a count',\n);\nconsole.log('TYPE_SAFETY_PASS_ORACLE patterns gone');\n\n// 2) Behavior: the three declared consequences are fixed, happy path preserved.\nassert.equal(splitEvenly(100, 4), 25);\nassert.equal(splitEvenly(100, 3), 33.33);\nassert.throws(() => splitEvenly(100, 0), undefined, 'zero people must be rejected, not Infinity');\nassert.throws(() => splitEvenly(100, null));\nassert.throws(() => splitEvenly(100, undefined));\n\nconst stringAmounts = { total: 10, entries: [] };\naddExpense(stringAmounts, { label: 'taxi', amount: '12.50' });\nassert.equal(stringAmounts.total, 22.5, 'a string amount must be treated as the number it spells');\nassert.equal(typeof stringAmounts.total, 'number', 'the running total must stay a number');\n\nconst numeric = { total: 0, entries: [] };\naddExpense(numeric, { label: 'lunch', amount: 12 });\nassert.equal(numeric.total, 12);\n\nconst report = { total: 0, entries: [] };\nassert.throws(() => importEntry(report, 'not json {'), undefined, 'a corrupt import must throw, not vanish');\nimportEntry(report, '{\"label\":\"bus\",\"amount\":\"3.25\"}');\nassert.equal(report.total, 3.25);\nassert.equal(report.entries.length, 1);\nconsole.log('TYPE_SAFETY_PASS_ORACLE behavior ok');\n\n// 3) The whole suite is green after the pass (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 after the pass');\nconsole.log('TYPE_SAFETY_PASS_ORACLE suite green');\nconsole.log('TYPE_SAFETY_PASS_ORACLE done');\n"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"craftbookParams": {
|
|
38
|
+
"workPath": "tasks/eval",
|
|
39
|
+
"scope": "Tighten src/expenses.js: fix the loose-equality zero bug in splitEvenly, the string-amount concat bug in addExpense, and the swallowed catch in importEntry, per source/cleanup-brief.md."
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"success": {
|
|
43
|
+
"summary": "The seeded unsafe patterns are structurally gone, the three declared behavioral consequences are fixed (probes), the suite is green on a real run, and the fleet artifacts quote honest before/after counts gathered by the same method.",
|
|
44
|
+
"deliverables": [
|
|
45
|
+
{
|
|
46
|
+
"path": "tasks/eval/audit.md",
|
|
47
|
+
"kind": "markdown-notes",
|
|
48
|
+
"artifact": true,
|
|
49
|
+
"minBytes": 600,
|
|
50
|
+
"checks": [
|
|
51
|
+
{
|
|
52
|
+
"kind": "contains",
|
|
53
|
+
"file": "tasks/eval/audit.md",
|
|
54
|
+
"pattern": "^##\\s+Inventory[\\s\\S]*^##\\s+Targets[\\s\\S]*^##\\s+Guardrail",
|
|
55
|
+
"flags": "im",
|
|
56
|
+
"label": "audit sections in order"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"kind": "contains",
|
|
60
|
+
"file": "tasks/eval/audit.md",
|
|
61
|
+
"pattern": "^##\\s+Inventory[\\s\\S]*\\d",
|
|
62
|
+
"flags": "im",
|
|
63
|
+
"label": "inventory carries counts"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"kind": "citationsResolve",
|
|
67
|
+
"file": "tasks/eval/audit.md",
|
|
68
|
+
"minCitations": 2,
|
|
69
|
+
"artifact": true
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"path": "tasks/eval/change-notes.md",
|
|
75
|
+
"kind": "markdown-notes",
|
|
76
|
+
"artifact": true,
|
|
77
|
+
"minBytes": 600,
|
|
78
|
+
"checks": [
|
|
79
|
+
{
|
|
80
|
+
"kind": "contains",
|
|
81
|
+
"file": "tasks/eval/change-notes.md",
|
|
82
|
+
"pattern": "^##\\s+Patterns addressed[\\s\\S]*^##\\s+Files touched[\\s\\S]*^##\\s+Deviations",
|
|
83
|
+
"flags": "im",
|
|
84
|
+
"label": "change-notes sections in order"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"kind": "citationsResolve",
|
|
88
|
+
"file": "tasks/eval/change-notes.md",
|
|
89
|
+
"minCitations": 2,
|
|
90
|
+
"artifact": true
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"path": "tasks/eval/verification.md",
|
|
96
|
+
"kind": "markdown-notes",
|
|
97
|
+
"artifact": true,
|
|
98
|
+
"minBytes": 400,
|
|
99
|
+
"checks": [
|
|
100
|
+
{
|
|
101
|
+
"kind": "contains",
|
|
102
|
+
"file": "tasks/eval/verification.md",
|
|
103
|
+
"pattern": "^##\\s+Before\\s*/\\s*after counts[\\s\\S]*^##\\s+Suite[\\s\\S]*^##\\s+Result",
|
|
104
|
+
"flags": "im",
|
|
105
|
+
"label": "verification sections in order"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"kind": "contains",
|
|
109
|
+
"file": "tasks/eval/verification.md",
|
|
110
|
+
"pattern": "^##\\s+Before\\s*/\\s*after counts[\\s\\S]*\\d",
|
|
111
|
+
"flags": "im",
|
|
112
|
+
"label": "before/after counts quoted"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"path": "tasks/eval/review.md",
|
|
118
|
+
"kind": "markdown-report",
|
|
119
|
+
"artifact": true,
|
|
120
|
+
"minBytes": 400,
|
|
121
|
+
"checks": [
|
|
122
|
+
{
|
|
123
|
+
"kind": "contains",
|
|
124
|
+
"file": "tasks/eval/review.md",
|
|
125
|
+
"pattern": "Verdict:\\s*(?:PASS|REVISE)",
|
|
126
|
+
"flags": "i",
|
|
127
|
+
"label": "explicit reviewer verdict"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"checks": [
|
|
133
|
+
{
|
|
134
|
+
"kind": "notContains",
|
|
135
|
+
"file": "src/expenses.js",
|
|
136
|
+
"pattern": "(^|[^=!<>])==[^=]|!=[^=]",
|
|
137
|
+
"label": "loose equality is gone from the module"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"kind": "notContains",
|
|
141
|
+
"file": "src/expenses.js",
|
|
142
|
+
"pattern": "catch[^{]*\\{\\s*\\}",
|
|
143
|
+
"label": "no empty catch swallows errors"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"kind": "notContains",
|
|
147
|
+
"file": "src/expenses.js",
|
|
148
|
+
"pattern": "@ts-ignore|@ts-expect-error|eslint-disable",
|
|
149
|
+
"label": "no suppression comment bought the improvement"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"kind": "sourceParses",
|
|
153
|
+
"file": "src/expenses.js"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"kind": "nodeScriptPasses",
|
|
157
|
+
"script": "tests/verify-expenses.mjs",
|
|
158
|
+
"timeoutMs": 60000,
|
|
159
|
+
"requiredOutput": [
|
|
160
|
+
{
|
|
161
|
+
"pattern": "TYPE_SAFETY_PASS_ORACLE patterns gone",
|
|
162
|
+
"label": "seeded unsafe patterns structurally gone"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"pattern": "TYPE_SAFETY_PASS_ORACLE behavior ok",
|
|
166
|
+
"label": "the three declared consequences are fixed"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"pattern": "TYPE_SAFETY_PASS_ORACLE suite green",
|
|
170
|
+
"label": "suite green after the pass"
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"taskNotes": {
|
|
176
|
+
"minBytes": 120,
|
|
177
|
+
"checks": [
|
|
178
|
+
{
|
|
179
|
+
"kind": "contains",
|
|
180
|
+
"file": "task-notes.md",
|
|
181
|
+
"pattern": "\\bDONE\\b[\\s\\S]*(npm\\s+run\\s+test|node\\s+--test)",
|
|
182
|
+
"flags": "i",
|
|
183
|
+
"label": "DONE note names the real test command"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
"taskGraph": {
|
|
188
|
+
"requireCraftbookTask": true,
|
|
189
|
+
"requireTerminalStep": true
|
|
190
|
+
},
|
|
191
|
+
"unchangedFixtures": [
|
|
192
|
+
"source/cleanup-brief.md",
|
|
193
|
+
"package.json"
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
"rubric": {
|
|
197
|
+
"artifact": {
|
|
198
|
+
"path": "tasks/eval/verification.md",
|
|
199
|
+
"kind": "markdown"
|
|
200
|
+
},
|
|
201
|
+
"axes": [
|
|
202
|
+
{
|
|
203
|
+
"name": "Honest counting",
|
|
204
|
+
"description": "The audit counted real patterns with a stated, repeatable method, and verification re-counted with exactly that method, quoting before and after per pattern - no method swap, no adjectives standing in for counts."
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "No suppression",
|
|
208
|
+
"description": "Every count fell because the code got stronger: strict checks, boundary validation, surfaced errors - never a deleted assertion, silenced error path, cast, or ignore-comment."
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "Consequence-fix discipline",
|
|
212
|
+
"description": "The three declared consequences were fixed and named in the notes, happy-path behavior stayed pinned and green with real receipts, and anything unverified is labeled honestly."
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
"qualityFocus": [
|
|
217
|
+
"counts with their method",
|
|
218
|
+
"no suppression-by-cast",
|
|
219
|
+
"enforced review loop"
|
|
220
|
+
]
|
|
221
|
+
}
|