{"record":{"id":"dbe5d326aa9a3d44","repo":"santifer/career-ops","slug":"decision-must-be-one-of-decisions-join","errorCode":null,"errorMessage":"decision must be one of: ${[...DECISIONS].join(', ')}","messagePattern":"decision must be one of: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"application-artifacts.mjs","lineNumber":86,"sourceCode":"    join(paths.root, 'jd'),\n    join(paths.root, 'cv', 'source'),\n    paths.cv.tailored.root,\n    join(paths.root, 'decision'),\n  ]) mkdirSync(directory, { recursive: true });\n  return paths;\n}\n\n/** Write an auditable CV reuse decision beside the application artifacts. */\nexport function writeReuseDecision(paths, {\n  decision,\n  score = null,\n  sourceCv = null,\n  currentJd = null,\n  previousSource = null,\n  changedSections = [],\n  userOverride = false,\n}) {\n  if (!DECISIONS.has(decision)) throw new Error(`decision must be one of: ${[...DECISIONS].join(', ')}`);\n  if (!Array.isArray(changedSections)) throw new Error('changedSections must be an array');\n  ensureApplicationArtifactDirs(paths);\n  const record = {\n    schema_version: 1,\n    decision,\n    score,\n    source_cv: sourceCv,\n    current_jd: currentJd,\n    previous_source: previousSource,\n    changed_sections: changedSections,\n    user_override: Boolean(userOverride),\n    recorded_at: new Date().toISOString(),\n  };\n  writeFileSync(paths.decision.reuse, `${JSON.stringify(record, null, 2)}\\n`);\n  return record;\n}\n\nfunction usage() {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/application-artifacts.mjs#L68-L104","documentation":"Validation in `writeReuseDecision`: the `decision` field must be a member of `DECISIONS` (defined as the set `['reuse', 'reuse-with-edits', 'regenerate']`). The decision is persisted into an auditable record beside the application artifacts, so an unrecognized value would make the audit log unreadable. The check fires before any directory or file write.","triggerScenarios":"Passing `decision: 'edit'`, `'modified'`, `'new'`, `'custom'`, `'REUSE'` (case-sensitive — must be exactly lowercase as defined), `undefined`, or `null`.","commonSituations":"Caller uses its own status vocabulary; agent invents a decision label; case mismatch (capital first letter); migrating from a system with different reuse semantics; passing a user-typed string straight through.","solutions":["Use exactly one of: `reuse`, `reuse-with-edits`, `regenerate` (lowercase, exact spelling).","Map your caller's vocabulary onto these three before invoking `writeReuseDecision`.","If you need a new decision type, extend `DECISIONS` deliberately and update the schema_version + docs.","Guard upstream: `if (!['reuse','reuse-with-edits','regenerate'].includes(d)) throw ...`.","Add a unit test enumerating accepted and rejected values."],"exampleFix":"// before\nwriteReuseDecision(paths, { decision: 'edited', score: 0.8 }); // throws\n// after\nwriteReuseDecision(paths, { decision: 'reuse-with-edits', score: 0.8, changedSections: ['summary'] });","handlingStrategy":"validation","validationCode":"const DECISIONS = new Set(['reuse', 'reuse-with-edits', 'regenerate']);\nfunction validDecision(d) {\n  if (!DECISIONS.has(d)) throw new Error(`decision must be one of: ${[...DECISIONS].join(', ')}`);\n  return d;\n}","typeGuard":"function isReuseDecision(d) {\n  return ['reuse', 'reuse-with-edits', 'regenerate'].includes(d);\n}","tryCatchPattern":null,"preventionTips":["Map caller vocabulary onto the three accepted values before invoking.","Treat the decision set as a schema enum; extend it deliberately with a schema_version bump.","Validate in tests covering all three plus one invalid value.","Lowercase exact spelling — 'REUSE' is rejected."],"tags":["validation","audit","application-artifacts","state-machine"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}