{"record":{"id":"81eb2f1ea40ded72","repo":"santifer/career-ops","slug":"outcome-types-mjs-key-is-accepted-by-outcome","errorCode":null,"errorMessage":"outcome-types.mjs: \"${key}\" is accepted by outcome.mjs but has no canonical meaning; add it to ALIASES or CANONICAL_OUTCOMES","messagePattern":"outcome-types\\.mjs: \"(.+?)\" is accepted by outcome\\.mjs but has no canonical meaning; add it to ALIASES or CANONICAL_OUTCOMES","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/outcome-types.mjs","lineNumber":78,"sourceCode":" * result. What stops an omission here is the coverage check below and the drift\n * test, not cleverness.\n */\nconst ALIASES = {\n  stage_reached: 'interview_progress',\n  interview: 'interview_progress',\n  offer: 'offer_received',\n  accepted: 'hired',\n  declined: 'offer_declined',\n  rejection: 'rejected',\n  ghosted: 'no_response',\n};\n\n// A synonym added to OUTCOME_MAP without a meaning here is a real decision, not\n// a spelling. Fail loudly at load rather than let it read as unknown wherever\n// the journal is consumed — which is the failure this module exists to end.\nfor (const key of Object.keys(OUTCOME_MAP)) {\n  if (!CANONICAL_OUTCOMES.includes(key) && !(key in ALIASES)) {\n    throw new Error(`outcome-types.mjs: \"${key}\" is accepted by outcome.mjs but has no canonical meaning; add it to ALIASES or CANONICAL_OUTCOMES`);\n  }\n}\n\n/**\n * Resolve any accepted spelling to its canonical type.\n *\n * Applies the same normalization `outcome.mjs` applies before writing\n * (lowercase, `-` → `_`), so a hand-edited journal saying `Offer-Declined`\n * still resolves.\n *\n * @param {unknown} raw - A type as written in a journal or typed on the CLI.\n * @returns {string|null} The canonical type, or null when unrecognized.\n */\nexport function canonicalOutcome(raw) {\n  const key = String(raw ?? '').trim().toLowerCase().replace(/-/g, '_');\n  if (CANONICAL_OUTCOMES.includes(key)) return key;\n  return ALIASES[key] ?? null;\n}","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/lib/outcome-types.mjs#L60-L96","documentation":"lib/outcome-types.mjs performs a load-time self-check: every key in OUTCOME_MAP (the spellings outcome.mjs accepts) must have a canonical meaning — either being listed in CANONICAL_OUTCOMES or mapped through ALIASES. A key that is accepted but has no canonical classification is a real semantic decision, so the module fails at load instead of letting it surface as 'unknown' wherever the journal is consumed.","triggerScenarios":"A developer adds a new synonym to OUTCOME_MAP (e.g. 'turned-down') but forgets to add it to ALIASES or CANONICAL_OUTCOMES; the very first import of outcome-types.mjs then throws for that key.","commonSituations":"Contributing a new outcome spelling to outcome.mjs; rebasing branches where one side added the map entry and the other added the canonical list; copy-editing a key's casing so it no longer matches the alias table.","solutions":["Add the new key to ALIASES, mapping it to an existing canonical outcome, if it is just a spelling.","Add it to CANONICAL_OUTCOMES if it is a genuinely new outcome type.","Rerun the test suite after editing so the load-time invariant check validates the full map."],"exampleFix":"// before\nconst OUTCOME_MAP = { ...ALIASES, ...CANONICAL_OUTCOMES.reduce(...), 'turned-down': undefined };\n// after\nconst ALIASES = { ..., 'turned-down': 'rejected' };","handlingStrategy":"validation","validationCode":"// CI guard before commit\nfor (const key of Object.keys(OUTCOME_MAP)) {\n  if (!CANONICAL_OUTCOMES.includes(key) && !(key in ALIASES)) {\n    throw new Error(`outcome key \"${key}\" needs a canonical meaning`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await import('./lib/outcome-types.mjs');\n} catch (err) {\n  if (err.message.includes('no canonical meaning')) {\n    console.error('Add the named key to ALIASES (spelling) or CANONICAL_OUTCOMES (new type).');\n  } else throw err;\n}","preventionTips":["Every time you add an OUTCOME_MAP key, update ALIASES or CANONICAL_OUTCOMES in the same commit.","Import outcome-types.mjs in unit tests so the load-time invariant runs in CI.","Keep synonyms in ALIASES only; new semantics belong in CANONICAL_OUTCOMES."],"tags":["invariant","load-time","outcome","mapping"],"backgroundTag":"internal-invariant-violation","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}